From 5d379991de3fa21113c64c8465fa3403e2b69a7f Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 9 May 2010 00:30:12 +0000 Subject: * ext/json/{generator/generator.c,parser/parser.rl}: fixed indent. * ext/json/{generator,parser}/depend: added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/json/generator/depend | 1 + ext/json/generator/generator.c | 32 ++++---- ext/json/parser/depend | 1 + ext/json/parser/parser.c | 166 ++++++++++++++++++++--------------------- ext/json/parser/parser.rl | 30 ++++---- 5 files changed, 116 insertions(+), 114 deletions(-) create mode 100644 ext/json/generator/depend create mode 100644 ext/json/parser/depend (limited to 'ext/json') diff --git a/ext/json/generator/depend b/ext/json/generator/depend new file mode 100644 index 0000000000..bb76ad6400 --- /dev/null +++ b/ext/json/generator/depend @@ -0,0 +1 @@ +generator.o: generator.c generator.h diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c index b398cac386..12e35d10e1 100644 --- a/ext/json/generator/generator.c +++ b/ext/json/generator/generator.c @@ -17,9 +17,9 @@ static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before, /* * Copyright 2001-2004 Unicode, Inc. - * + * * Disclaimer - * + * * This source code is provided as is by Unicode, Inc. No claims are * made as to fitness for any particular purpose. No warranties of any * kind are expressed or implied. The recipient agrees to determine @@ -27,9 +27,9 @@ static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before, * purchased on magnetic or optical media from Unicode, Inc., the * sole remedy for any claim will be exchange of defective media * within 90 days of receipt. - * + * * Limitations on Rights to Redistribute This Code - * + * * Unicode, Inc. hereby grants the right to freely use the information * supplied in this file in the creation of products supporting the * Unicode Standard, and to make copies of this file in any form @@ -60,7 +60,7 @@ static const char trailingBytesForUTF8[256] = { * This table contains as many values as there might be trailing bytes * in a UTF-8 sequence. */ -static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, +static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; /* @@ -362,23 +362,23 @@ static void fbuffer_append_char(FBuffer *fb, char newchr) static void freverse(char *start, char *end) { - char c; + char c; - while (end > start) { - c = *end, *end-- = *start, *start++ = c; + while (end > start) { + c = *end, *end-- = *start, *start++ = c; } } static int fltoa(long number, char *buf) { - static char digits[] = "0123456789"; - long sign = number; - char* tmp = buf; + static char digits[] = "0123456789"; + long sign = number; + char* tmp = buf; - if (sign < 0) number = -number; + if (sign < 0) number = -number; do *tmp++ = digits[number % 10]; while (number /= 10); - if (sign < 0) *tmp++ = '-'; - freverse(buf, tmp - 1); + if (sign < 0) *tmp++ = '-'; + freverse(buf, tmp - 1); return tmp - buf; } @@ -403,7 +403,7 @@ static FBuffer *fbuffer_dup(FBuffer *fb) return result; } -/* +/* * Document-module: JSON::Ext::Generator * * This is the JSON generator implemented as a C extension. It can be @@ -956,7 +956,7 @@ static VALUE cState_generate(VALUE self, VALUE obj) * * *indent*: a string used to indent levels (default: ''), * * *space*: a string that is put after, a : or , delimiter (default: ''), * * *space_before*: a string that is put before a : pair delimiter (default: ''), - * * *object_nl*: a string that is put at the end of a JSON object (default: ''), + * * *object_nl*: a string that is put at the end of a JSON object (default: ''), * * *array_nl*: a string that is put at the end of a JSON array (default: ''), * * *allow_nan*: true if NaN, Infinity, and -Infinity should be * generated, otherwise an exception is thrown, if these values are diff --git a/ext/json/parser/depend b/ext/json/parser/depend new file mode 100644 index 0000000000..5eaf6dd040 --- /dev/null +++ b/ext/json/parser/depend @@ -0,0 +1 @@ +parser.o: parser.c parser.h diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c index 1d639d29b8..cf4bbfa531 100644 --- a/ext/json/parser/parser.c +++ b/ext/json/parser/parser.c @@ -4,7 +4,7 @@ /* unicode */ -static const char digit_values[256] = { +static const char digit_values[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, @@ -40,7 +40,7 @@ static UTF32 unescape_unicode(const unsigned char *p) return result; } -static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) +static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) { int len = 1; if (ch <= 0x7F) { @@ -94,7 +94,7 @@ static const int JSON_object_error = 0; static const int JSON_object_en_main = 1; -#line 143 "parser.rl" +#line 144 "parser.rl" static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -115,7 +115,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu cs = JSON_object_start; } -#line 158 "parser.rl" +#line 159 "parser.rl" #line 121 "parser.c" { @@ -158,7 +158,7 @@ st3: if ( ++p == pe ) goto _test_eof3; case 3: -#line 161 "parser.c" +#line 162 "parser.c" switch( (*p) ) { case 13: goto st3; case 32: goto st3; @@ -228,7 +228,7 @@ tr11: #line 116 "parser.rl" { VALUE v = Qnil; - char *np = JSON_parse_value(json, p, pe, &v); + char *np = JSON_parse_value(json, p, pe, &v); if (np == NULL) { p--; {p++; cs = 9; goto _out;} } else { @@ -241,7 +241,7 @@ st9: if ( ++p == pe ) goto _test_eof9; case 9: -#line 244 "parser.c" +#line 245 "parser.c" switch( (*p) ) { case 13: goto st9; case 32: goto st9; @@ -330,14 +330,14 @@ case 18: goto st9; goto st18; tr4: -#line 134 "parser.rl" +#line 135 "parser.rl" { p--; {p++; cs = 27; goto _out;} } goto st27; st27: if ( ++p == pe ) goto _test_eof27; case 27: -#line 340 "parser.c" +#line 341 "parser.c" goto st0; st19: if ( ++p == pe ) @@ -435,7 +435,7 @@ case 26: _out: {} } -#line 159 "parser.rl" +#line 160 "parser.rl" if (cs >= JSON_object_first_final) { if (RTEST(json->create_id)) { @@ -454,7 +454,7 @@ case 26: } -#line 457 "parser.c" +#line 458 "parser.c" static const int JSON_value_start = 1; static const int JSON_value_first_final = 21; static const int JSON_value_error = 0; @@ -462,7 +462,7 @@ static const int JSON_value_error = 0; static const int JSON_value_en_main = 1; -#line 257 "parser.rl" +#line 258 "parser.rl" static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -470,14 +470,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul int cs = EVIL; -#line 473 "parser.c" +#line 474 "parser.c" { cs = JSON_value_start; } -#line 264 "parser.rl" +#line 265 "parser.rl" -#line 480 "parser.c" +#line 481 "parser.c" { if ( p == pe ) goto _test_eof; @@ -502,14 +502,14 @@ st0: cs = 0; goto _out; tr0: -#line 205 "parser.rl" +#line 206 "parser.rl" { char *np = JSON_parse_string(json, p, pe, result); if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;} } goto st21; tr2: -#line 210 "parser.rl" +#line 211 "parser.rl" { char *np; if(pe > p + 9 && !strncmp(MinusInfinity, p, 9)) { @@ -529,8 +529,8 @@ tr2: } goto st21; tr5: -#line 228 "parser.rl" - { +#line 229 "parser.rl" + { char *np; json->current_nesting++; np = JSON_parse_array(json, p, pe, result); @@ -539,8 +539,8 @@ tr5: } goto st21; tr9: -#line 236 "parser.rl" - { +#line 237 "parser.rl" + { char *np; json->current_nesting++; np = JSON_parse_object(json, p, pe, result); @@ -549,7 +549,7 @@ tr9: } goto st21; tr16: -#line 198 "parser.rl" +#line 199 "parser.rl" { if (json->allow_nan) { *result = CInfinity; @@ -559,7 +559,7 @@ tr16: } goto st21; tr18: -#line 191 "parser.rl" +#line 192 "parser.rl" { if (json->allow_nan) { *result = CNaN; @@ -569,19 +569,19 @@ tr18: } goto st21; tr22: -#line 185 "parser.rl" +#line 186 "parser.rl" { *result = Qfalse; } goto st21; tr25: -#line 182 "parser.rl" +#line 183 "parser.rl" { *result = Qnil; } goto st21; tr28: -#line 188 "parser.rl" +#line 189 "parser.rl" { *result = Qtrue; } @@ -590,9 +590,9 @@ st21: if ( ++p == pe ) goto _test_eof21; case 21: -#line 244 "parser.rl" +#line 245 "parser.rl" { p--; {p++; cs = 21; goto _out;} } -#line 595 "parser.c" +#line 596 "parser.c" goto st0; st2: if ( ++p == pe ) @@ -753,7 +753,7 @@ case 20: _out: {} } -#line 265 "parser.rl" +#line 266 "parser.rl" if (cs >= JSON_value_first_final) { return p; @@ -763,7 +763,7 @@ case 20: } -#line 766 "parser.c" +#line 767 "parser.c" static const int JSON_integer_start = 1; static const int JSON_integer_first_final = 5; static const int JSON_integer_error = 0; @@ -771,7 +771,7 @@ static const int JSON_integer_error = 0; static const int JSON_integer_en_main = 1; -#line 281 "parser.rl" +#line 282 "parser.rl" static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -779,15 +779,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res int cs = EVIL; -#line 782 "parser.c" +#line 783 "parser.c" { cs = JSON_integer_start; } -#line 288 "parser.rl" +#line 289 "parser.rl" json->memo = p; -#line 790 "parser.c" +#line 791 "parser.c" { if ( p == pe ) goto _test_eof; @@ -821,14 +821,14 @@ case 3: goto st0; goto tr4; tr4: -#line 278 "parser.rl" +#line 279 "parser.rl" { p--; {p++; cs = 5; goto _out;} } goto st5; st5: if ( ++p == pe ) goto _test_eof5; case 5: -#line 831 "parser.c" +#line 832 "parser.c" goto st0; st4: if ( ++p == pe ) @@ -847,7 +847,7 @@ case 4: _out: {} } -#line 290 "parser.rl" +#line 291 "parser.rl" if (cs >= JSON_integer_first_final) { long len = p - json->memo; @@ -859,7 +859,7 @@ case 4: } -#line 862 "parser.c" +#line 863 "parser.c" static const int JSON_float_start = 1; static const int JSON_float_first_final = 10; static const int JSON_float_error = 0; @@ -867,7 +867,7 @@ static const int JSON_float_error = 0; static const int JSON_float_en_main = 1; -#line 312 "parser.rl" +#line 313 "parser.rl" static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -875,15 +875,15 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul int cs = EVIL; -#line 878 "parser.c" +#line 879 "parser.c" { cs = JSON_float_start; } -#line 319 "parser.rl" +#line 320 "parser.rl" json->memo = p; -#line 886 "parser.c" +#line 887 "parser.c" { if ( p == pe ) goto _test_eof; @@ -941,14 +941,14 @@ case 5: goto st0; goto tr7; tr7: -#line 306 "parser.rl" +#line 307 "parser.rl" { p--; {p++; cs = 10; goto _out;} } goto st10; st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 951 "parser.c" +#line 952 "parser.c" goto st0; st6: if ( ++p == pe ) @@ -1009,7 +1009,7 @@ case 9: _out: {} } -#line 321 "parser.rl" +#line 322 "parser.rl" if (cs >= JSON_float_first_final) { long len = p - json->memo; @@ -1022,7 +1022,7 @@ case 9: -#line 1025 "parser.c" +#line 1026 "parser.c" static const int JSON_array_start = 1; static const int JSON_array_first_final = 17; static const int JSON_array_error = 0; @@ -1030,7 +1030,7 @@ static const int JSON_array_error = 0; static const int JSON_array_en_main = 1; -#line 357 "parser.rl" +#line 358 "parser.rl" static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -1044,14 +1044,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class); -#line 1047 "parser.c" +#line 1048 "parser.c" { cs = JSON_array_start; } -#line 370 "parser.rl" +#line 371 "parser.rl" -#line 1054 "parser.c" +#line 1055 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1090,10 +1090,10 @@ case 2: goto st2; goto st0; tr2: -#line 338 "parser.rl" +#line 339 "parser.rl" { VALUE v = Qnil; - char *np = JSON_parse_value(json, p, pe, &v); + char *np = JSON_parse_value(json, p, pe, &v); if (np == NULL) { p--; {p++; cs = 3; goto _out;} } else { @@ -1106,7 +1106,7 @@ st3: if ( ++p == pe ) goto _test_eof3; case 3: -#line 1109 "parser.c" +#line 1110 "parser.c" switch( (*p) ) { case 13: goto st3; case 32: goto st3; @@ -1206,14 +1206,14 @@ case 12: goto st3; goto st12; tr4: -#line 349 "parser.rl" +#line 350 "parser.rl" { p--; {p++; cs = 17; goto _out;} } goto st17; st17: if ( ++p == pe ) goto _test_eof17; case 17: -#line 1216 "parser.c" +#line 1217 "parser.c" goto st0; st13: if ( ++p == pe ) @@ -1269,7 +1269,7 @@ case 16: _out: {} } -#line 371 "parser.rl" +#line 372 "parser.rl" if(cs >= JSON_array_first_final) { return p + 1; @@ -1312,7 +1312,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) unescape = (char *) "\f"; break; case 'u': - if (pe > stringEnd - 4) { + if (pe > stringEnd - 4) { return Qnil; } else { char buf[4]; @@ -1350,7 +1350,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) } -#line 1353 "parser.c" +#line 1354 "parser.c" static const int JSON_string_start = 1; static const int JSON_string_first_final = 8; static const int JSON_string_error = 0; @@ -1358,7 +1358,7 @@ static const int JSON_string_error = 0; static const int JSON_string_en_main = 1; -#line 470 "parser.rl" +#line 471 "parser.rl" static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -1367,15 +1367,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu *result = rb_str_buf_new(0); -#line 1370 "parser.c" +#line 1371 "parser.c" { cs = JSON_string_start; } -#line 478 "parser.rl" +#line 479 "parser.rl" json->memo = p; -#line 1378 "parser.c" +#line 1379 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1400,25 +1400,25 @@ case 2: goto st0; goto st2; tr2: -#line 456 "parser.rl" +#line 457 "parser.rl" { *result = json_string_unescape(*result, json->memo + 1, p); if (NIL_P(*result)) { - p--; - {p++; cs = 8; goto _out;} - } else { - FORCE_UTF8(*result); - {p = (( p + 1))-1;} - } - } -#line 467 "parser.rl" + p--; + {p++; cs = 8; goto _out;} + } else { + FORCE_UTF8(*result); + {p = (( p + 1))-1;} + } + } +#line 468 "parser.rl" { p--; {p++; cs = 8; goto _out;} } goto st8; st8: if ( ++p == pe ) goto _test_eof8; case 8: -#line 1421 "parser.c" +#line 1422 "parser.c" goto st0; st3: if ( ++p == pe ) @@ -1494,7 +1494,7 @@ case 7: _out: {} } -#line 480 "parser.rl" +#line 481 "parser.rl" if (json->symbolize_names && json->parsing_name) { *result = rb_str_intern(*result); @@ -1508,7 +1508,7 @@ case 7: -#line 1511 "parser.c" +#line 1512 "parser.c" static const int JSON_start = 1; static const int JSON_first_final = 10; static const int JSON_error = 0; @@ -1516,10 +1516,10 @@ static const int JSON_error = 0; static const int JSON_en_main = 1; -#line 517 "parser.rl" +#line 518 "parser.rl" -/* +/* * Document-class: JSON::Ext::Parser * * This is the JSON parser implemented as a C extension. It can be configured @@ -1698,16 +1698,16 @@ static VALUE cParser_parse(VALUE self) GET_PARSER; -#line 1701 "parser.c" +#line 1702 "parser.c" { cs = JSON_start; } -#line 698 "parser.rl" +#line 699 "parser.rl" p = json->source; pe = p + json->len; -#line 1710 "parser.c" +#line 1711 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1763,7 +1763,7 @@ case 5: goto st1; goto st5; tr3: -#line 506 "parser.rl" +#line 507 "parser.rl" { char *np; json->current_nesting = 1; @@ -1772,7 +1772,7 @@ tr3: } goto st10; tr4: -#line 499 "parser.rl" +#line 500 "parser.rl" { char *np; json->current_nesting = 1; @@ -1784,7 +1784,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 1787 "parser.c" +#line 1788 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -1841,7 +1841,7 @@ case 9: _out: {} } -#line 701 "parser.rl" +#line 702 "parser.rl" if (cs >= JSON_first_final && p == pe) { return result; diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl index dd07485f3a..05b4890366 100644 --- a/ext/json/parser/parser.rl +++ b/ext/json/parser/parser.rl @@ -2,7 +2,7 @@ /* unicode */ -static const char digit_values[256] = { +static const char digit_values[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, @@ -38,7 +38,7 @@ static UTF32 unescape_unicode(const unsigned char *p) return result; } -static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) +static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) { int len = 1; if (ch <= 0x7F) { @@ -115,7 +115,7 @@ static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, action parse_value { VALUE v = Qnil; - char *np = JSON_parse_value(json, fpc, pe, &v); + char *np = JSON_parse_value(json, fpc, pe, &v); if (np == NULL) { fhold; fbreak; } else { @@ -226,7 +226,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu fhold; fbreak; } - action parse_array { + action parse_array { char *np; json->current_nesting++; np = JSON_parse_array(json, fpc, pe, result); @@ -234,7 +234,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu if (np == NULL) { fhold; fbreak; } else fexec np; } - action parse_object { + action parse_object { char *np; json->current_nesting++; np = JSON_parse_object(json, fpc, pe, result); @@ -338,7 +338,7 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul action parse_value { VALUE v = Qnil; - char *np = JSON_parse_value(json, fpc, pe, &v); + char *np = JSON_parse_value(json, fpc, pe, &v); if (np == NULL) { fhold; fbreak; } else { @@ -411,7 +411,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) unescape = (char *) "\f"; break; case 'u': - if (pe > stringEnd - 4) { + if (pe > stringEnd - 4) { return Qnil; } else { char buf[4]; @@ -457,13 +457,13 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) action parse_string { *result = json_string_unescape(*result, json->memo + 1, p); if (NIL_P(*result)) { - fhold; - fbreak; - } else { - FORCE_UTF8(*result); - fexec p + 1; - } - } + fhold; + fbreak; + } else { + FORCE_UTF8(*result); + fexec p + 1; + } + } action exit { fhold; fbreak; } @@ -517,7 +517,7 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu ) ignore*; }%% -/* +/* * Document-class: JSON::Ext::Parser * * This is the JSON parser implemented as a C extension. It can be configured -- cgit v1.2.3