nutcracker 0.3.0.12 → 0.4.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +5 -13
  2. data/README.md +3 -3
  3. data/Rakefile +12 -10
  4. data/ext/nutcracker/Makefile.in +215 -162
  5. data/ext/nutcracker/README.md +16 -4
  6. data/ext/nutcracker/aclocal.m4 +432 -254
  7. data/ext/nutcracker/{contrib/yaml-0.1.4/configure → autom4te.cache/output.0} +11367 -4545
  8. data/ext/nutcracker/autom4te.cache/output.1 +19907 -0
  9. data/ext/nutcracker/autom4te.cache/output.2 +19907 -0
  10. data/ext/nutcracker/autom4te.cache/requests +518 -0
  11. data/ext/nutcracker/autom4te.cache/traces.0 +2715 -0
  12. data/ext/nutcracker/autom4te.cache/traces.1 +967 -0
  13. data/ext/nutcracker/autom4te.cache/traces.2 +2715 -0
  14. data/ext/nutcracker/config/compile +347 -0
  15. data/ext/nutcracker/config/config.guess +116 -78
  16. data/ext/nutcracker/config/config.sub +65 -45
  17. data/ext/nutcracker/config/depcomp +295 -192
  18. data/ext/nutcracker/config/install-sh +7 -7
  19. data/ext/nutcracker/config/ltmain.sh +15 -20
  20. data/ext/nutcracker/config/missing +149 -265
  21. data/ext/nutcracker/configure +493 -367
  22. data/ext/nutcracker/contrib/Makefile.in +158 -116
  23. data/ext/nutcracker/extconf.rb +0 -1
  24. data/ext/nutcracker/m4/libtool.m4 +4 -23
  25. data/ext/nutcracker/m4/ltoptions.m4 +0 -0
  26. data/ext/nutcracker/m4/ltsugar.m4 +0 -0
  27. data/ext/nutcracker/m4/ltversion.m4 +0 -0
  28. data/ext/nutcracker/m4/lt~obsolete.m4 +0 -0
  29. data/ext/nutcracker/notes/recommendation.md +1 -1
  30. data/ext/nutcracker/notes/redis.md +35 -3
  31. data/ext/nutcracker/scripts/benchmark-mget.py +43 -0
  32. data/ext/nutcracker/scripts/nutcracker.spec +61 -3
  33. data/ext/nutcracker/scripts/redis-check.sh +43 -0
  34. data/ext/nutcracker/src/Makefile.in +205 -142
  35. data/ext/nutcracker/src/event/Makefile.in +164 -66
  36. data/ext/nutcracker/src/hashkit/Makefile.in +164 -66
  37. data/ext/nutcracker/src/nc_conf.c +2 -0
  38. data/ext/nutcracker/src/nc_connection.c +31 -0
  39. data/ext/nutcracker/src/nc_connection.h +3 -0
  40. data/ext/nutcracker/src/nc_core.c +38 -2
  41. data/ext/nutcracker/src/nc_core.h +11 -0
  42. data/ext/nutcracker/src/nc_log.c +90 -12
  43. data/ext/nutcracker/src/nc_log.h +11 -0
  44. data/ext/nutcracker/src/nc_mbuf.h +1 -1
  45. data/ext/nutcracker/src/nc_message.c +162 -116
  46. data/ext/nutcracker/src/nc_message.h +161 -129
  47. data/ext/nutcracker/src/nc_proxy.c +34 -4
  48. data/ext/nutcracker/src/nc_request.c +158 -32
  49. data/ext/nutcracker/src/nc_server.c +59 -5
  50. data/ext/nutcracker/src/nc_server.h +1 -0
  51. data/ext/nutcracker/src/nc_signal.c +2 -2
  52. data/ext/nutcracker/src/nc_stats.c +21 -0
  53. data/ext/nutcracker/src/nc_stats.h +28 -26
  54. data/ext/nutcracker/src/nc_string.c +176 -1
  55. data/ext/nutcracker/src/nc_string.h +26 -0
  56. data/ext/nutcracker/src/nc_util.c +12 -0
  57. data/ext/nutcracker/src/nc_util.h +1 -0
  58. data/ext/nutcracker/src/proto/Makefile.in +164 -66
  59. data/ext/nutcracker/src/proto/nc_memcache.c +279 -88
  60. data/ext/nutcracker/src/proto/nc_proto.h +3 -4
  61. data/ext/nutcracker/src/proto/nc_redis.c +561 -134
  62. data/lib/nutcracker/version.rb +1 -1
  63. metadata +31 -67
  64. data/ext/nutcracker/contrib/yaml-0.1.4/LICENSE +0 -19
  65. data/ext/nutcracker/contrib/yaml-0.1.4/Makefile.am +0 -20
  66. data/ext/nutcracker/contrib/yaml-0.1.4/Makefile.in +0 -736
  67. data/ext/nutcracker/contrib/yaml-0.1.4/README +0 -27
  68. data/ext/nutcracker/contrib/yaml-0.1.4/aclocal.m4 +0 -956
  69. data/ext/nutcracker/contrib/yaml-0.1.4/config.h.in +0 -80
  70. data/ext/nutcracker/contrib/yaml-0.1.4/config/config.guess +0 -1561
  71. data/ext/nutcracker/contrib/yaml-0.1.4/config/config.sub +0 -1686
  72. data/ext/nutcracker/contrib/yaml-0.1.4/config/depcomp +0 -630
  73. data/ext/nutcracker/contrib/yaml-0.1.4/config/install-sh +0 -520
  74. data/ext/nutcracker/contrib/yaml-0.1.4/config/ltmain.sh +0 -8406
  75. data/ext/nutcracker/contrib/yaml-0.1.4/config/missing +0 -376
  76. data/ext/nutcracker/contrib/yaml-0.1.4/configure.ac +0 -75
  77. data/ext/nutcracker/contrib/yaml-0.1.4/doc/doxygen.cfg +0 -222
  78. data/ext/nutcracker/contrib/yaml-0.1.4/include/yaml.h +0 -1971
  79. data/ext/nutcracker/contrib/yaml-0.1.4/m4/libtool.m4 +0 -7357
  80. data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltoptions.m4 +0 -368
  81. data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltsugar.m4 +0 -123
  82. data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltversion.m4 +0 -23
  83. data/ext/nutcracker/contrib/yaml-0.1.4/m4/lt~obsolete.m4 +0 -92
  84. data/ext/nutcracker/contrib/yaml-0.1.4/src/Makefile.am +0 -4
  85. data/ext/nutcracker/contrib/yaml-0.1.4/src/Makefile.in +0 -484
  86. data/ext/nutcracker/contrib/yaml-0.1.4/src/api.c +0 -1392
  87. data/ext/nutcracker/contrib/yaml-0.1.4/src/dumper.c +0 -394
  88. data/ext/nutcracker/contrib/yaml-0.1.4/src/emitter.c +0 -2329
  89. data/ext/nutcracker/contrib/yaml-0.1.4/src/loader.c +0 -432
  90. data/ext/nutcracker/contrib/yaml-0.1.4/src/parser.c +0 -1374
  91. data/ext/nutcracker/contrib/yaml-0.1.4/src/reader.c +0 -465
  92. data/ext/nutcracker/contrib/yaml-0.1.4/src/scanner.c +0 -3570
  93. data/ext/nutcracker/contrib/yaml-0.1.4/src/writer.c +0 -141
  94. data/ext/nutcracker/contrib/yaml-0.1.4/src/yaml_private.h +0 -640
  95. data/ext/nutcracker/contrib/yaml-0.1.4/tests/Makefile.am +0 -8
  96. data/ext/nutcracker/contrib/yaml-0.1.4/tests/Makefile.in +0 -675
  97. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-deconstructor-alt.c +0 -800
  98. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-deconstructor.c +0 -1130
  99. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-reformatter-alt.c +0 -217
  100. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-reformatter.c +0 -202
  101. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-dumper.c +0 -311
  102. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-emitter.c +0 -327
  103. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-loader.c +0 -63
  104. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-parser.c +0 -63
  105. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-scanner.c +0 -63
  106. data/ext/nutcracker/contrib/yaml-0.1.4/tests/test-reader.c +0 -354
  107. data/ext/nutcracker/contrib/yaml-0.1.4/tests/test-version.c +0 -29
@@ -1,63 +0,0 @@
1
- #include <yaml.h>
2
-
3
- #include <stdlib.h>
4
- #include <stdio.h>
5
-
6
- #ifdef NDEBUG
7
- #undef NDEBUG
8
- #endif
9
- #include <assert.h>
10
-
11
- int
12
- main(int argc, char *argv[])
13
- {
14
- int number;
15
-
16
- if (argc < 2) {
17
- printf("Usage: %s file1.yaml ...\n", argv[0]);
18
- return 0;
19
- }
20
-
21
- for (number = 1; number < argc; number ++)
22
- {
23
- FILE *file;
24
- yaml_parser_t parser;
25
- yaml_token_t token;
26
- int done = 0;
27
- int count = 0;
28
- int error = 0;
29
-
30
- printf("[%d] Scanning '%s': ", number, argv[number]);
31
- fflush(stdout);
32
-
33
- file = fopen(argv[number], "rb");
34
- assert(file);
35
-
36
- assert(yaml_parser_initialize(&parser));
37
-
38
- yaml_parser_set_input_file(&parser, file);
39
-
40
- while (!done)
41
- {
42
- if (!yaml_parser_scan(&parser, &token)) {
43
- error = 1;
44
- break;
45
- }
46
-
47
- done = (token.type == YAML_STREAM_END_TOKEN);
48
-
49
- yaml_token_delete(&token);
50
-
51
- count ++;
52
- }
53
-
54
- yaml_parser_delete(&parser);
55
-
56
- assert(!fclose(file));
57
-
58
- printf("%s (%d tokens)\n", (error ? "FAILURE" : "SUCCESS"), count);
59
- }
60
-
61
- return 0;
62
- }
63
-
@@ -1,354 +0,0 @@
1
- #include <yaml.h>
2
-
3
- YAML_DECLARE(int)
4
- yaml_parser_update_buffer(yaml_parser_t *parser, size_t length);
5
-
6
- #include <stdlib.h>
7
- #include <stdio.h>
8
-
9
- #ifdef NDEBUG
10
- #undef NDEBUG
11
- #endif
12
- #include <assert.h>
13
-
14
- /*
15
- * Test cases are stolen from
16
- * http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
17
- */
18
-
19
- typedef struct {
20
- char *title;
21
- char *test;
22
- int result;
23
- } test_case;
24
-
25
- test_case utf8_sequences[] = {
26
- /* {"title", "test 1|test 2|...|test N!", (0 or 1)}, */
27
-
28
- {"a simple test", "'test' is '\xd0\xbf\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb5\xd1\x80\xd0\xba\xd0\xb0' in Russian!", 1},
29
- {"an empty line", "!", 1},
30
-
31
- {"u-0 is a control character", "\x00!", 0},
32
- {"u-80 is a control character", "\xc2\x80!", 0},
33
- {"u-800 is valid", "\xe0\xa0\x80!", 1},
34
- {"u-10000 is valid", "\xf0\x90\x80\x80!", 1},
35
- {"5 bytes sequences are not allowed", "\xf8\x88\x80\x80\x80!", 0},
36
- {"6 bytes sequences are not allowed", "\xfc\x84\x80\x80\x80\x80!", 0},
37
-
38
- {"u-7f is a control character", "\x7f!", 0},
39
- {"u-7FF is valid", "\xdf\xbf!", 1},
40
- {"u-FFFF is a control character", "\xef\xbf\xbf!", 0},
41
- {"u-1FFFFF is too large", "\xf7\xbf\xbf\xbf!", 0},
42
- {"u-3FFFFFF is 5 bytes", "\xfb\xbf\xbf\xbf\xbf!", 0},
43
- {"u-7FFFFFFF is 6 bytes", "\xfd\xbf\xbf\xbf\xbf\xbf!", 0},
44
-
45
- {"u-D7FF", "\xed\x9f\xbf!", 1},
46
- {"u-E000", "\xee\x80\x80!", 1},
47
- {"u-FFFD", "\xef\xbf\xbd!", 1},
48
- {"u-10FFFF", "\xf4\x8f\xbf\xbf!", 1},
49
- {"u-110000", "\xf4\x90\x80\x80!", 0},
50
-
51
- {"first continuation byte", "\x80!", 0},
52
- {"last continuation byte", "\xbf!", 0},
53
-
54
- {"2 continuation bytes", "\x80\xbf!", 0},
55
- {"3 continuation bytes", "\x80\xbf\x80!", 0},
56
- {"4 continuation bytes", "\x80\xbf\x80\xbf!", 0},
57
- {"5 continuation bytes", "\x80\xbf\x80\xbf\x80!", 0},
58
- {"6 continuation bytes", "\x80\xbf\x80\xbf\x80\xbf!", 0},
59
- {"7 continuation bytes", "\x80\xbf\x80\xbf\x80\xbf\x80!", 0},
60
-
61
- {"sequence of all 64 possible continuation bytes",
62
- "\x80|\x81|\x82|\x83|\x84|\x85|\x86|\x87|\x88|\x89|\x8a|\x8b|\x8c|\x8d|\x8e|\x8f|"
63
- "\x90|\x91|\x92|\x93|\x94|\x95|\x96|\x97|\x98|\x99|\x9a|\x9b|\x9c|\x9d|\x9e|\x9f|"
64
- "\xa0|\xa1|\xa2|\xa3|\xa4|\xa5|\xa6|\xa7|\xa8|\xa9|\xaa|\xab|\xac|\xad|\xae|\xaf|"
65
- "\xb0|\xb1|\xb2|\xb3|\xb4|\xb5|\xb6|\xb7|\xb8|\xb9|\xba|\xbb|\xbc|\xbd|\xbe|\xbf!", 0},
66
- {"32 first bytes of 2-byte sequences {0xc0-0xdf}",
67
- "\xc0 |\xc1 |\xc2 |\xc3 |\xc4 |\xc5 |\xc6 |\xc7 |\xc8 |\xc9 |\xca |\xcb |\xcc |\xcd |\xce |\xcf |"
68
- "\xd0 |\xd1 |\xd2 |\xd3 |\xd4 |\xd5 |\xd6 |\xd7 |\xd8 |\xd9 |\xda |\xdb |\xdc |\xdd |\xde |\xdf !", 0},
69
- {"16 first bytes of 3-byte sequences {0xe0-0xef}",
70
- "\xe0 |\xe1 |\xe2 |\xe3 |\xe4 |\xe5 |\xe6 |\xe7 |\xe8 |\xe9 |\xea |\xeb |\xec |\xed |\xee |\xef !", 0},
71
- {"8 first bytes of 4-byte sequences {0xf0-0xf7}", "\xf0 |\xf1 |\xf2 |\xf3 |\xf4 |\xf5 |\xf6 |\xf7 !", 0},
72
- {"4 first bytes of 5-byte sequences {0xf8-0xfb}", "\xf8 |\xf9 |\xfa |\xfb !", 0},
73
- {"2 first bytes of 6-byte sequences {0xfc-0xfd}", "\xfc |\xfd !", 0},
74
-
75
- {"sequences with last byte missing {u-0}",
76
- "\xc0|\xe0\x80|\xf0\x80\x80|\xf8\x80\x80\x80|\xfc\x80\x80\x80\x80!", 0},
77
- {"sequences with last byte missing {u-...FF}",
78
- "\xdf|\xef\xbf|\xf7\xbf\xbf|\xfb\xbf\xbf\xbf|\xfd\xbf\xbf\xbf\xbf!", 0},
79
-
80
- {"impossible bytes", "\xfe|\xff|\xfe\xfe\xff\xff!", 0},
81
-
82
- {"overlong sequences {u-2f}",
83
- "\xc0\xaf|\xe0\x80\xaf|\xf0\x80\x80\xaf|\xf8\x80\x80\x80\xaf|\xfc\x80\x80\x80\x80\xaf!", 0},
84
-
85
- {"maximum overlong sequences",
86
- "\xc1\xbf|\xe0\x9f\xbf|\xf0\x8f\xbf\xbf|\xf8\x87\xbf\xbf\xbf|\xfc\x83\xbf\xbf\xbf\xbf!", 0},
87
-
88
- {"overlong representation of the NUL character",
89
- "\xc0\x80|\xe0\x80\x80|\xf0\x80\x80\x80|\xf8\x80\x80\x80\x80|\xfc\x80\x80\x80\x80\x80!", 0},
90
-
91
- {"single UTF-16 surrogates",
92
- "\xed\xa0\x80|\xed\xad\xbf|\xed\xae\x80|\xed\xaf\xbf|\xed\xb0\x80|\xed\xbe\x80|\xed\xbf\xbf!", 0},
93
-
94
- {"paired UTF-16 surrogates",
95
- "\xed\xa0\x80\xed\xb0\x80|\xed\xa0\x80\xed\xbf\xbf|\xed\xad\xbf\xed\xb0\x80|"
96
- "\xed\xad\xbf\xed\xbf\xbf|\xed\xae\x80\xed\xb0\x80|\xed\xae\x80\xed\xbf\xbf|"
97
- "\xed\xaf\xbf\xed\xb0\x80|\xed\xaf\xbf\xed\xbf\xbf!", 0},
98
-
99
- {"other illegal code positions", "\xef\xbf\xbe|\xef\xbf\xbf!", 0},
100
-
101
- {NULL, NULL, 0}
102
- };
103
-
104
- test_case boms[] = {
105
-
106
- /* {"title", "test!", lenth}, */
107
-
108
- {"no bom (utf-8)", "Hi is \xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82!", 13},
109
- {"bom (utf-8)", "\xef\xbb\xbfHi is \xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82!", 13},
110
- {"bom (utf-16-le)", "\xff\xfeH\x00i\x00 \x00i\x00s\x00 \x00\x1f\x04@\x04""8\x04""2\x04""5\x04""B\x04!", 13},
111
- {"bom (utf-16-be)", "\xfe\xff\x00H\x00i\x00 \x00i\x00s\x00 \x04\x1f\x04@\x04""8\x04""2\x04""5\x04""B!", 13},
112
- {NULL, NULL, 0}
113
- };
114
-
115
- char *bom_original = "Hi is \xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82";
116
-
117
- int check_utf8_sequences(void)
118
- {
119
- yaml_parser_t parser;
120
- int failed = 0;
121
- int k;
122
- printf("checking utf-8 sequences...\n");
123
- for (k = 0; utf8_sequences[k].test; k++) {
124
- char *title = utf8_sequences[k].title;
125
- int check = utf8_sequences[k].result;
126
- int result;
127
- char *start = utf8_sequences[k].test;
128
- char *end = start;
129
- printf("\t%s:\n", title);
130
- while(1) {
131
- while (*end != '|' && *end != '!') end++;
132
- yaml_parser_initialize(&parser);
133
- yaml_parser_set_input_string(&parser, (unsigned char *)start, end-start);
134
- result = yaml_parser_update_buffer(&parser, end-start);
135
- if (result != check) {
136
- printf("\t\t- ");
137
- failed ++;
138
- }
139
- else {
140
- printf("\t\t+ ");
141
- }
142
- if (!parser.error) {
143
- printf("(no error)\n");
144
- }
145
- else if (parser.error == YAML_READER_ERROR) {
146
- if (parser.problem_value != -1) {
147
- printf("(reader error: %s: #%X at %d)\n",
148
- parser.problem, parser.problem_value, parser.problem_offset);
149
- }
150
- else {
151
- printf("(reader error: %s at %d)\n",
152
- parser.problem, parser.problem_offset);
153
- }
154
- }
155
- if (*end == '!') break;
156
- start = ++end;
157
- yaml_parser_delete(&parser);
158
- };
159
- printf("\n");
160
- }
161
- printf("checking utf-8 sequences: %d fail(s)\n", failed);
162
- return failed;
163
- }
164
-
165
- int check_boms(void)
166
- {
167
- yaml_parser_t parser;
168
- int failed = 0;
169
- int k;
170
- printf("checking boms...\n");
171
- for (k = 0; boms[k].test; k++) {
172
- char *title = boms[k].title;
173
- int check = boms[k].result;
174
- int result;
175
- char *start = boms[k].test;
176
- char *end = start;
177
- while (*end != '!') end++;
178
- printf("\t%s: ", title);
179
- yaml_parser_initialize(&parser);
180
- yaml_parser_set_input_string(&parser, (unsigned char *)start, end-start);
181
- result = yaml_parser_update_buffer(&parser, end-start);
182
- if (!result) {
183
- printf("- (reader error: %s at %d)\n", parser.problem, parser.problem_offset);
184
- failed++;
185
- }
186
- else {
187
- if (parser.unread != check) {
188
- printf("- (length=%d while expected length=%d)\n", parser.unread, check);
189
- failed++;
190
- }
191
- else if (memcmp(parser.buffer.start, bom_original, check) != 0) {
192
- printf("- (value '%s' does not equal to the original value '%s')\n", parser.buffer.start, bom_original);
193
- failed++;
194
- }
195
- else {
196
- printf("+\n");
197
- }
198
- }
199
- yaml_parser_delete(&parser);
200
- }
201
- printf("checking boms: %d fail(s)\n", failed);
202
- return failed;
203
- }
204
-
205
- #define LONG 100000
206
-
207
- int check_long_utf8(void)
208
- {
209
- yaml_parser_t parser;
210
- int k = 0;
211
- int j;
212
- int failed = 0;
213
- unsigned char ch0, ch1;
214
- unsigned char *buffer = malloc(3+LONG*2);
215
- assert(buffer);
216
- printf("checking a long utf8 sequence...\n");
217
- buffer[k++] = '\xef';
218
- buffer[k++] = '\xbb';
219
- buffer[k++] = '\xbf';
220
- for (j = 0; j < LONG; j ++) {
221
- if (j % 2) {
222
- buffer[k++] = '\xd0';
223
- buffer[k++] = '\x90';
224
- }
225
- else {
226
- buffer[k++] = '\xd0';
227
- buffer[k++] = '\xaf';
228
- }
229
- }
230
- yaml_parser_initialize(&parser);
231
- yaml_parser_set_input_string(&parser, buffer, 3+LONG*2);
232
- for (k = 0; k < LONG; k++) {
233
- if (!parser.unread) {
234
- if (!yaml_parser_update_buffer(&parser, 1)) {
235
- printf("\treader error: %s at %d\n", parser.problem, parser.problem_offset);
236
- failed = 1;
237
- break;
238
- }
239
- }
240
- if (!parser.unread) {
241
- printf("\tnot enough characters at %d\n", k);
242
- failed = 1;
243
- break;
244
- }
245
- if (k % 2) {
246
- ch0 = '\xd0';
247
- ch1 = '\x90';
248
- }
249
- else {
250
- ch0 = '\xd0';
251
- ch1 = '\xaf';
252
- }
253
- if (parser.buffer.pointer[0] != ch0 || parser.buffer.pointer[1] != ch1) {
254
- printf("\tincorrect UTF-8 sequence: %X %X instead of %X %X\n",
255
- (int)parser.buffer.pointer[0], (int)parser.buffer.pointer[1],
256
- (int)ch0, (int)ch1);
257
- failed = 1;
258
- break;
259
- }
260
- parser.buffer.pointer += 2;
261
- parser.unread -= 1;
262
- }
263
- if (!failed) {
264
- if (!yaml_parser_update_buffer(&parser, 1)) {
265
- printf("\treader error: %s at %d\n", parser.problem, parser.problem_offset);
266
- failed = 1;
267
- }
268
- else if (parser.buffer.pointer[0] != '\0') {
269
- printf("\texpected NUL, found %X (eof=%d, unread=%d)\n", (int)parser.buffer.pointer[0], parser.eof, parser.unread);
270
- failed = 1;
271
- }
272
- }
273
- yaml_parser_delete(&parser);
274
- free(buffer);
275
- printf("checking a long utf8 sequence: %d fail(s)\n", failed);
276
- return failed;
277
- }
278
-
279
- int check_long_utf16(void)
280
- {
281
- yaml_parser_t parser;
282
- int k = 0;
283
- int j;
284
- int failed = 0;
285
- unsigned char ch0, ch1;
286
- unsigned char *buffer = malloc(2+LONG*2);
287
- assert(buffer);
288
- printf("checking a long utf16 sequence...\n");
289
- buffer[k++] = '\xff';
290
- buffer[k++] = '\xfe';
291
- for (j = 0; j < LONG; j ++) {
292
- if (j % 2) {
293
- buffer[k++] = '\x10';
294
- buffer[k++] = '\x04';
295
- }
296
- else {
297
- buffer[k++] = '/';
298
- buffer[k++] = '\x04';
299
- }
300
- }
301
- yaml_parser_initialize(&parser);
302
- yaml_parser_set_input_string(&parser, buffer, 2+LONG*2);
303
- for (k = 0; k < LONG; k++) {
304
- if (!parser.unread) {
305
- if (!yaml_parser_update_buffer(&parser, 1)) {
306
- printf("\treader error: %s at %d\n", parser.problem, parser.problem_offset);
307
- failed = 1;
308
- break;
309
- }
310
- }
311
- if (!parser.unread) {
312
- printf("\tnot enough characters at %d\n", k);
313
- failed = 1;
314
- break;
315
- }
316
- if (k % 2) {
317
- ch0 = '\xd0';
318
- ch1 = '\x90';
319
- }
320
- else {
321
- ch0 = '\xd0';
322
- ch1 = '\xaf';
323
- }
324
- if (parser.buffer.pointer[0] != ch0 || parser.buffer.pointer[1] != ch1) {
325
- printf("\tincorrect UTF-8 sequence: %X %X instead of %X %X\n",
326
- (int)parser.buffer.pointer[0], (int)parser.buffer.pointer[1],
327
- (int)ch0, (int)ch1);
328
- failed = 1;
329
- break;
330
- }
331
- parser.buffer.pointer += 2;
332
- parser.unread -= 1;
333
- }
334
- if (!failed) {
335
- if (!yaml_parser_update_buffer(&parser, 1)) {
336
- printf("\treader error: %s at %d\n", parser.problem, parser.problem_offset);
337
- failed = 1;
338
- }
339
- else if (parser.buffer.pointer[0] != '\0') {
340
- printf("\texpected NUL, found %X (eof=%d, unread=%d)\n", (int)parser.buffer.pointer[0], parser.eof, parser.unread);
341
- failed = 1;
342
- }
343
- }
344
- yaml_parser_delete(&parser);
345
- free(buffer);
346
- printf("checking a long utf16 sequence: %d fail(s)\n", failed);
347
- return failed;
348
- }
349
-
350
- int
351
- main(void)
352
- {
353
- return check_utf8_sequences() + check_boms() + check_long_utf8() + check_long_utf16();
354
- }
@@ -1,29 +0,0 @@
1
- #include <yaml.h>
2
-
3
- #include <stdlib.h>
4
- #include <stdio.h>
5
-
6
- #ifdef NDEBUG
7
- #undef NDEBUG
8
- #endif
9
- #include <assert.h>
10
-
11
- int
12
- main(void)
13
- {
14
- int major = -1;
15
- int minor = -1;
16
- int patch = -1;
17
- char buf[64];
18
-
19
- yaml_get_version(&major, &minor, &patch);
20
- sprintf(buf, "%d.%d.%d", major, minor, patch);
21
- assert(strcmp(buf, yaml_get_version_string()) == 0);
22
-
23
- /* Print structure sizes. */
24
- printf("sizeof(token) = %d\n", sizeof(yaml_token_t));
25
- printf("sizeof(event) = %d\n", sizeof(yaml_event_t));
26
- printf("sizeof(parser) = %d\n", sizeof(yaml_parser_t));
27
-
28
- return 0;
29
- }