rmultimarkdown 4.7.1.1 → 6.2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +2 -2
  3. data/README.md +7 -9
  4. data/Rakefile +33 -18
  5. data/ext/Makefile +261 -0
  6. data/ext/extconf.rb +23 -3
  7. data/ext/mmd/aho-corasick.c +596 -0
  8. data/ext/mmd/aho-corasick.h +120 -0
  9. data/ext/mmd/beamer.c +344 -0
  10. data/ext/mmd/beamer.h +72 -0
  11. data/ext/mmd/char.c +156 -0
  12. data/ext/mmd/char.h +111 -0
  13. data/ext/mmd/char_lookup.c +212 -0
  14. data/ext/mmd/critic_markup.c +330 -0
  15. data/ext/mmd/critic_markup.h +94 -0
  16. data/ext/mmd/d_string.c +402 -0
  17. data/ext/mmd/epub.c +563 -0
  18. data/ext/mmd/epub.h +69 -0
  19. data/ext/mmd/fodt.c +2288 -0
  20. data/ext/mmd/fodt.h +81 -0
  21. data/ext/mmd/html.c +2460 -0
  22. data/ext/mmd/html.h +81 -0
  23. data/ext/mmd/i18n.h +170 -0
  24. data/ext/mmd/include/d_string.h +182 -0
  25. data/ext/mmd/include/libMultiMarkdown.h +548 -0
  26. data/ext/mmd/include/token.h +233 -0
  27. data/ext/mmd/latex.c +2435 -0
  28. data/ext/mmd/latex.h +83 -0
  29. data/ext/mmd/lexer.c +3001 -0
  30. data/ext/mmd/lexer.h +75 -0
  31. data/ext/mmd/memoir.c +138 -0
  32. data/ext/mmd/memoir.h +67 -0
  33. data/ext/mmd/miniz.c +7557 -0
  34. data/ext/mmd/miniz.h +1328 -0
  35. data/ext/mmd/mmd.c +2798 -0
  36. data/ext/mmd/mmd.h +120 -0
  37. data/ext/mmd/object_pool.c +141 -0
  38. data/ext/mmd/object_pool.h +101 -0
  39. data/ext/mmd/opendocument-content.c +2071 -0
  40. data/ext/mmd/opendocument-content.h +135 -0
  41. data/ext/mmd/opendocument.c +981 -0
  42. data/ext/mmd/opendocument.h +118 -0
  43. data/ext/mmd/parser.c +1760 -0
  44. data/ext/mmd/parser.h +39 -0
  45. data/{MultiMarkdown-4 → ext/mmd}/rng.c +90 -49
  46. data/ext/mmd/scanners.c +77512 -0
  47. data/ext/mmd/scanners.h +101 -0
  48. data/ext/mmd/stack.c +142 -0
  49. data/ext/mmd/stack.h +113 -0
  50. data/ext/mmd/textbundle.c +455 -0
  51. data/ext/mmd/textbundle.h +115 -0
  52. data/ext/mmd/token.c +773 -0
  53. data/ext/mmd/token_pairs.c +263 -0
  54. data/ext/mmd/token_pairs.h +123 -0
  55. data/ext/mmd/transclude.c +549 -0
  56. data/ext/mmd/transclude.h +87 -0
  57. data/ext/mmd/uthash.h +1074 -0
  58. data/ext/mmd/uuid.c +154 -0
  59. data/ext/mmd/uuid.h +77 -0
  60. data/ext/mmd/version.h +111 -0
  61. data/ext/mmd/writer.c +2652 -0
  62. data/ext/mmd/writer.h +260 -0
  63. data/ext/mmd/zip.c +210 -0
  64. data/ext/mmd/zip.h +120 -0
  65. data/ext/{multi_markdown.c → ruby_multi_markdown.c} +87 -18
  66. data/lib/multi_markdown.bundle +0 -0
  67. data/lib/multi_markdown.rb +5 -8
  68. data/lib/multi_markdown/version.rb +1 -1
  69. data/rmultimarkdown.gemspec +2 -2
  70. data/test/{extensions_test.rb.rb → extensions_test.rb} +10 -54
  71. data/test/multi_markdown_test.rb +13 -0
  72. metadata +67 -47
  73. data/MultiMarkdown-4/GLibFacade.c +0 -310
  74. data/MultiMarkdown-4/GLibFacade.h +0 -100
  75. data/MultiMarkdown-4/beamer.c +0 -182
  76. data/MultiMarkdown-4/beamer.h +0 -11
  77. data/MultiMarkdown-4/critic.c +0 -111
  78. data/MultiMarkdown-4/critic.h +0 -15
  79. data/MultiMarkdown-4/glib.h +0 -11
  80. data/MultiMarkdown-4/html.c +0 -1117
  81. data/MultiMarkdown-4/html.h +0 -14
  82. data/MultiMarkdown-4/latex.c +0 -1217
  83. data/MultiMarkdown-4/latex.h +0 -16
  84. data/MultiMarkdown-4/libMultiMarkdown.h +0 -177
  85. data/MultiMarkdown-4/lyx.c +0 -2265
  86. data/MultiMarkdown-4/lyx.h +0 -37
  87. data/MultiMarkdown-4/lyxbeamer.c +0 -265
  88. data/MultiMarkdown-4/lyxbeamer.h +0 -11
  89. data/MultiMarkdown-4/memoir.c +0 -80
  90. data/MultiMarkdown-4/memoir.h +0 -10
  91. data/MultiMarkdown-4/multimarkdown.c +0 -518
  92. data/MultiMarkdown-4/odf.c +0 -1222
  93. data/MultiMarkdown-4/odf.h +0 -18
  94. data/MultiMarkdown-4/opml.c +0 -189
  95. data/MultiMarkdown-4/opml.h +0 -15
  96. data/MultiMarkdown-4/parse_utilities.c +0 -884
  97. data/MultiMarkdown-4/parser.c +0 -16656
  98. data/MultiMarkdown-4/parser.h +0 -188
  99. data/MultiMarkdown-4/rtf.c +0 -665
  100. data/MultiMarkdown-4/rtf.h +0 -17
  101. data/MultiMarkdown-4/strtok.c +0 -56
  102. data/MultiMarkdown-4/strtok.h +0 -9
  103. data/MultiMarkdown-4/text.c +0 -53
  104. data/MultiMarkdown-4/text.h +0 -11
  105. data/MultiMarkdown-4/toc.c +0 -142
  106. data/MultiMarkdown-4/toc.h +0 -15
  107. data/MultiMarkdown-4/transclude.c +0 -307
  108. data/MultiMarkdown-4/transclude.h +0 -28
  109. data/MultiMarkdown-4/writer.c +0 -731
  110. data/MultiMarkdown-4/writer.h +0 -38
data/ext/mmd/beamer.h ADDED
@@ -0,0 +1,72 @@
1
+ /**
2
+
3
+ MultiMarkdown 6 -- Lightweight markup processor to produce HTML, LaTeX, and more.
4
+
5
+ @file beamer.h
6
+
7
+ @brief
8
+
9
+
10
+ @author Fletcher T. Penney
11
+ @bug
12
+
13
+ **/
14
+
15
+ /*
16
+
17
+ Copyright © 2016 - 2017 Fletcher T. Penney.
18
+
19
+
20
+ The `MultiMarkdown 6` project is released under the MIT License..
21
+
22
+ GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project:
23
+
24
+ https://github.com/fletcher/MultiMarkdown-4/
25
+
26
+ MMD 4 is released under both the MIT License and GPL.
27
+
28
+
29
+ CuTest is released under the zlib/libpng license. See CuTest.c for the text
30
+ of the license.
31
+
32
+
33
+ ## The MIT License ##
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining a copy
36
+ of this software and associated documentation files (the "Software"), to deal
37
+ in the Software without restriction, including without limitation the rights
38
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39
+ copies of the Software, and to permit persons to whom the Software is
40
+ furnished to do so, subject to the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be included in
43
+ all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
48
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
51
+ THE SOFTWARE.
52
+
53
+ */
54
+
55
+
56
+ #ifndef BEAMER_MULTIMARKDOWN_6_H
57
+ #define BEAMER_MULTIMARKDOWN_6_H
58
+
59
+ #include "d_string.h"
60
+ #include "token.h"
61
+ #include "writer.h"
62
+
63
+ void mmd_export_token_beamer(DString * out, const char * source, token * t, scratch_pad * scratch);
64
+ void mmd_export_token_tree_beamer(DString * out, const char * source, token * t, scratch_pad * scratch);
65
+
66
+ void mmd_outline_add_beamer(DString * out, token * current, scratch_pad * scratch);
67
+
68
+ void mmd_export_citation_list_beamer(DString * out, const char * source, scratch_pad * scratch);
69
+ void mmd_end_complete_beamer(DString * out, const char * source, scratch_pad * scratch);
70
+
71
+
72
+ #endif
data/ext/mmd/char.c ADDED
@@ -0,0 +1,156 @@
1
+ /**
2
+
3
+ MultiMarkdown 6 -- Lightweight markup processor to produce HTML, LaTeX, and more.
4
+
5
+ @file char.c
6
+
7
+ @brief Character lookup utility functions
8
+
9
+
10
+ @author Fletcher T. Penney
11
+ @bug
12
+
13
+ **/
14
+
15
+ /*
16
+
17
+ Copyright © 2016 - 2017 Fletcher T. Penney.
18
+
19
+
20
+ The `MultiMarkdown 6` project is released under the MIT License..
21
+
22
+ GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project:
23
+
24
+ https://github.com/fletcher/MultiMarkdown-4/
25
+
26
+ MMD 4 is released under both the MIT License and GPL.
27
+
28
+
29
+ CuTest is released under the zlib/libpng license. See CuTest.c for the text
30
+ of the license.
31
+
32
+
33
+ ## The MIT License ##
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining a copy
36
+ of this software and associated documentation files (the "Software"), to deal
37
+ in the Software without restriction, including without limitation the rights
38
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39
+ copies of the Software, and to permit persons to whom the Software is
40
+ furnished to do so, subject to the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be included in
43
+ all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
48
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
51
+ THE SOFTWARE.
52
+
53
+ */
54
+
55
+ #include <stdlib.h>
56
+
57
+ #include "char.h"
58
+
59
+
60
+ /// Create this lookup table using char_lookup.c
61
+ static unsigned char smart_char_type[256] = {
62
+ 16, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16, 0, 0, 16, 0, 0,
63
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
64
+ 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
65
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 2, 2, 2, 2, 2, 2,
66
+ 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
67
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2,
68
+ 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
69
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 0,
70
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
71
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
72
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
73
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
74
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
75
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
76
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
77
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
78
+ };
79
+
80
+
81
+ static int CHAR_ALPHANUMERIC = CHAR_ALPHA | CHAR_DIGIT;
82
+
83
+ static int CHAR_WHITESPACE_OR_PUNCTUATION = CHAR_WHITESPACE | CHAR_PUNCTUATION;
84
+
85
+ static int CHAR_WHITESPACE_OR_LINE_ENDING = CHAR_WHITESPACE | CHAR_LINE_ENDING;
86
+
87
+ static int CHAR_WHITESPACE_OR_LINE_ENDING_OR_PUNCTUATION = CHAR_WHITESPACE | CHAR_LINE_ENDING | CHAR_PUNCTUATION;
88
+
89
+
90
+ // Is character whitespace?
91
+ int char_is_whitespace(char c) {
92
+ return smart_char_type[(unsigned char) c] & CHAR_WHITESPACE;
93
+ }
94
+
95
+ // Is character a newline, return, or EOF?
96
+ int char_is_line_ending(char c) {
97
+ return smart_char_type[(unsigned char) c] & CHAR_LINE_ENDING;
98
+ }
99
+
100
+ // Is character part of Windows line ending ('\r\n')?
101
+ int char_is_windows_line_ending(char * c) {
102
+ if (*c == '\n') {
103
+ return (*(c - 1) == '\r') ? 1 : 0;
104
+ }
105
+
106
+ if (*c == '\r') {
107
+ return (*(c + 1) == '\n') ? 1 : 0;
108
+ }
109
+
110
+ return 0;
111
+ }
112
+
113
+ #ifdef TEST
114
+ void Test_char_is_windows_line_ending(CuTest* tc) {
115
+ char * test = "\r\n\n";
116
+
117
+ CuAssertIntEquals(tc, 1, char_is_windows_line_ending(&test[0]));
118
+ CuAssertIntEquals(tc, 1, char_is_windows_line_ending(&test[1]));
119
+ CuAssertIntEquals(tc, 0, char_is_windows_line_ending(&test[2]));
120
+ }
121
+ #endif
122
+
123
+ // Is character punctuation?
124
+ int char_is_punctuation(char c) {
125
+ return smart_char_type[(unsigned char) c] & CHAR_PUNCTUATION;
126
+ }
127
+
128
+ // Is character alpha?
129
+ int char_is_alpha(char c) {
130
+ return smart_char_type[(unsigned char) c] & CHAR_ALPHA;
131
+ }
132
+
133
+ // Is character digit?
134
+ int char_is_digit(char c) {
135
+ return smart_char_type[(unsigned char) c] & CHAR_DIGIT;
136
+ }
137
+
138
+ // Is character alphanumeric?
139
+ int char_is_alphanumeric(char c) {
140
+ return smart_char_type[(unsigned char) c] & CHAR_ALPHANUMERIC;
141
+ }
142
+
143
+ // Is character either whitespace or line ending?
144
+ int char_is_whitespace_or_line_ending(char c) {
145
+ return smart_char_type[(unsigned char) c] & CHAR_WHITESPACE_OR_LINE_ENDING;
146
+ }
147
+
148
+ // Is character either whitespace or punctuation?
149
+ int char_is_whitespace_or_punctuation(char c) {
150
+ return smart_char_type[(unsigned char) c] & CHAR_WHITESPACE_OR_PUNCTUATION;
151
+ }
152
+
153
+ // Is character either whitespace or line ending or punctuation?
154
+ int char_is_whitespace_or_line_ending_or_punctuation(char c) {
155
+ return smart_char_type[(unsigned char) c] & CHAR_WHITESPACE_OR_LINE_ENDING_OR_PUNCTUATION;
156
+ }
data/ext/mmd/char.h ADDED
@@ -0,0 +1,111 @@
1
+ /**
2
+
3
+ MultiMarkdown 6 -- Lightweight markup processor to produce HTML, LaTeX, and more.
4
+
5
+ @file char.h
6
+
7
+ @brief Character lookup utility functions
8
+
9
+
10
+ @author Fletcher T. Penney
11
+ @bug
12
+
13
+ **/
14
+
15
+ /*
16
+
17
+ Copyright © 2016 - 2017 Fletcher T. Penney.
18
+
19
+
20
+ The `MultiMarkdown 6` project is released under the MIT License..
21
+
22
+ GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project:
23
+
24
+ https://github.com/fletcher/MultiMarkdown-4/
25
+
26
+ MMD 4 is released under both the MIT License and GPL.
27
+
28
+
29
+ CuTest is released under the zlib/libpng license. See CuTest.c for the text
30
+ of the license.
31
+
32
+
33
+ ## The MIT License ##
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining a copy
36
+ of this software and associated documentation files (the "Software"), to deal
37
+ in the Software without restriction, including without limitation the rights
38
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39
+ copies of the Software, and to permit persons to whom the Software is
40
+ furnished to do so, subject to the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be included in
43
+ all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
48
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
51
+ THE SOFTWARE.
52
+
53
+ */
54
+
55
+
56
+ #ifndef CHAR_SMART_STRING_H
57
+ #define CHAR_SMART_STRING_H
58
+
59
+ #ifdef TEST
60
+ #include "CuTest.h"
61
+ #endif
62
+
63
+ /// Define character types
64
+ enum char_types {
65
+ CHAR_WHITESPACE = 1 << 0, //!< ' ','\t'
66
+ CHAR_PUNCTUATION = 1 << 1, //!< .!?,;:"'`~(){}[]#$%+-=<>&@\/^*_|
67
+ CHAR_ALPHA = 1 << 2, //!< a-zA-Z
68
+ CHAR_DIGIT = 1 << 3, //!< 0-9
69
+ CHAR_LINE_ENDING = 1 << 4, //!< \n,\r,\0
70
+ };
71
+
72
+
73
+ // Is character whitespace?
74
+ int char_is_whitespace(char c);
75
+
76
+ // Is character a newline, return, or EOF?
77
+ int char_is_line_ending(char c);
78
+
79
+ // Is character part of Windows line ending ('\r\n')?
80
+ int char_is_windows_line_ending(char * c);
81
+
82
+ // Is character punctuation?
83
+ int char_is_punctuation(char c);
84
+
85
+ // Is character alpha?
86
+ int char_is_alpha(char c);
87
+
88
+ // Is character digit?
89
+ int char_is_digit(char c);
90
+
91
+ // Is character alphanumeric?
92
+ int char_is_alphanumeric(char c);
93
+
94
+ // Is character either whitespace or line ending?
95
+ int char_is_whitespace_or_line_ending(char c);
96
+
97
+ // Is character either whitespace or punctuation?
98
+ int char_is_whitespace_or_punctuation(char c);
99
+
100
+ // Is character either whitespace or line ending or punctuation?
101
+ int char_is_whitespace_or_line_ending_or_punctuation(char c);
102
+
103
+ // Is byte a UTF-8 continuation byte
104
+ #define char_is_continuation_byte(x) ((x & 0xC0) == 0x80)
105
+
106
+ // Is byte the first byte of a multibyte UTF-8 sequence?
107
+ #define char_is_lead_multibyte(x) ((x & 0xC0) == 0xC0)
108
+
109
+
110
+ #endif
111
+
@@ -0,0 +1,212 @@
1
+ /**
2
+
3
+ MultiMarkdown 6 -- Lightweight markup processor to produce HTML, LaTeX, and more.
4
+
5
+ @file char_lookup.c
6
+
7
+ @brief Create lookup table for char.c
8
+
9
+
10
+ @author Fletcher T. Penney
11
+ @bug
12
+
13
+ **/
14
+
15
+ /*
16
+
17
+ Copyright © 2016 - 2017 Fletcher T. Penney.
18
+
19
+
20
+ The `MultiMarkdown 6` project is released under the MIT License..
21
+
22
+ GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project:
23
+
24
+ https://github.com/fletcher/MultiMarkdown-4/
25
+
26
+ MMD 4 is released under both the MIT License and GPL.
27
+
28
+
29
+ CuTest is released under the zlib/libpng license. See CuTest.c for the text
30
+ of the license.
31
+
32
+
33
+ ## The MIT License ##
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining a copy
36
+ of this software and associated documentation files (the "Software"), to deal
37
+ in the Software without restriction, including without limitation the rights
38
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39
+ copies of the Software, and to permit persons to whom the Software is
40
+ furnished to do so, subject to the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be included in
43
+ all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
48
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
51
+ THE SOFTWARE.
52
+
53
+ */
54
+
55
+
56
+ #include <stdlib.h>
57
+ #include <stdio.h>
58
+
59
+ #include "char.h"
60
+
61
+ // Shortcuts to assign values to characters in lookup table
62
+ #define punctuation(x) table[x] |= CHAR_PUNCTUATION
63
+ #define whitespace(x) table[x] |= CHAR_WHITESPACE
64
+ #define alpha(x) table[x] |= CHAR_ALPHA
65
+ #define digit(x) table[x] |= CHAR_DIGIT
66
+ #define line_ending(x) table[x] |= CHAR_LINE_ENDING
67
+
68
+ #define USE_EXTENDED_ASCII_disabled 1
69
+
70
+ int main( int argc, char** argv ) {
71
+ unsigned char table[256] = {0};
72
+
73
+ // Define punctuation
74
+ punctuation('.');
75
+ punctuation('!');
76
+ punctuation('?');
77
+
78
+ punctuation(',');
79
+ punctuation(';');
80
+ punctuation(':');
81
+
82
+ punctuation('"');
83
+ punctuation('\'');
84
+ punctuation('`');
85
+ punctuation('~');
86
+
87
+ punctuation('(');
88
+ punctuation(')');
89
+ punctuation('{');
90
+ punctuation('}');
91
+ punctuation('[');
92
+ punctuation(']');
93
+
94
+ punctuation('#');
95
+ punctuation('$');
96
+ punctuation('%');
97
+ punctuation('+');
98
+ punctuation('-');
99
+ punctuation('=');
100
+ punctuation('<');
101
+ punctuation('>');
102
+
103
+ punctuation('&');
104
+ punctuation('@');
105
+ punctuation('\\');
106
+ punctuation('/');
107
+ punctuation('^');
108
+
109
+ punctuation('*');
110
+ punctuation('_');
111
+
112
+ punctuation('|');
113
+
114
+
115
+ // Define whitespace
116
+ whitespace(' ');
117
+ whitespace('\t');
118
+
119
+
120
+ // Define line endings
121
+ line_ending('\n');
122
+ line_ending('\r');
123
+ line_ending('\0'); // Count EOF as line ending
124
+
125
+
126
+ // Define digits
127
+ for (char i = '0'; i <= '9'; ++i) {
128
+ digit(i);
129
+ }
130
+
131
+ // Define alpha
132
+ for (char i = 'a'; i <= 'z'; ++i) {
133
+ alpha(i);
134
+ }
135
+
136
+ for (char i = 'A'; i <= 'Z'; ++i) {
137
+ alpha(i);
138
+ }
139
+
140
+
141
+ // Extended ASCII
142
+ #ifdef USE_EXTENDED_ASCII
143
+
144
+ // Punctuation ranges
145
+ for (int i = 132; i < 138; ++i) {
146
+ punctuation(i);
147
+ }
148
+
149
+ for (int i = 145; i < 156; ++i) {
150
+ punctuation(i);
151
+ }
152
+
153
+ for (int i = 161; i < 192; ++i) {
154
+ punctuation(i);
155
+ }
156
+
157
+
158
+ // Alphanumeric ranges
159
+ for (int i = 192; i < 215; ++i) {
160
+ alpha(i);
161
+ }
162
+
163
+ for (int i = 216; i < 247; ++i) {
164
+ alpha(i);
165
+ }
166
+
167
+ for (int i = 248; i < 256; ++i) {
168
+ alpha(i);
169
+ }
170
+
171
+ // Isolated extended ASCII characters
172
+ for (int i = 128; i < 256; ++i) {
173
+ switch (i) {
174
+ case 128:
175
+ case 130:
176
+ case 139:
177
+ case 215:
178
+ case 247:
179
+ punctuation(i);
180
+ break;
181
+
182
+ case 160:
183
+ whitespace(i);
184
+ break;
185
+
186
+ case 131:
187
+ case 138:
188
+ case 140:
189
+ case 142:
190
+ case 156:
191
+ case 158:
192
+ case 159:
193
+ alpha(i);
194
+ break;
195
+
196
+ default:
197
+ break;
198
+ }
199
+ }
200
+
201
+ #endif
202
+
203
+
204
+ // Print output as 16 x 16 table
205
+ for (int i = 0; i < 16; ++i) {
206
+ for (int j = 0; j < 16; ++j) {
207
+ fprintf(stdout, "%3d,", table[i * 16 + j]);
208
+ }
209
+
210
+ fprintf(stdout, "\n");
211
+ }
212
+ }