diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2016-04-24 01:47:49 +0900 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2016-06-21 10:56:58 +0200 |
commit | 0a49b1f7d5bccfa324cdc74ba6f899f3925a7830 (patch) | |
tree | 09c8f18fd1720d58d0dd620a6970690153cee0df /ext | |
parent | a20bc3c5fcd0e93b85803e685b527ac1ea14c1be (diff) | |
download | json-0a49b1f7d5bccfa324cdc74ba6f899f3925a7830.tar.gz |
Use rb_encoding
Use rb_encoding functions to convert encodings.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/json/ext/parser/mkmf.log | 60 | ||||
-rw-r--r-- | ext/json/ext/parser/parser.c | 97 |
2 files changed, 68 insertions, 89 deletions
diff --git a/ext/json/ext/parser/mkmf.log b/ext/json/ext/parser/mkmf.log new file mode 100644 index 0000000..e725db5 --- /dev/null +++ b/ext/json/ext/parser/mkmf.log @@ -0,0 +1,60 @@ +have_func: checking for rb_enc_raise() in ruby.h... -------------------- yes + +"gcc -o conftest -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin15 -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/flori/.rvm/rubies/ruby-2.3.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.3.0 -lpthread -ldl -lobjc " +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main(int argc, char **argv) +4: { +5: return 0; +6: } +/* end */ + +"gcc -o conftest -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin15 -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/flori/.rvm/rubies/ruby-2.3.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.3.0 -lpthread -ldl -lobjc " +conftest.c:15:57: error: use of undeclared identifier 'rb_enc_raise' +int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enc_raise; return !p; } + ^ +1 error generated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include <ruby.h> + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: printf("%p", &t); +11: } +12: +13: return 0; +14: } +15: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enc_raise; return !p; } +/* end */ + +"gcc -o conftest -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin15 -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/flori/.rvm/rubies/ruby-2.3.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.3.0 -lpthread -ldl -lobjc " +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include <ruby.h> + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: printf("%p", &t); +11: } +12: +13: return 0; +14: } +15: extern void rb_enc_raise(); +16: int t(void) { rb_enc_raise(); return 0; } +/* end */ + +-------------------- + diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index afa2864..269c9ca 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -102,17 +102,10 @@ static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 106 "parser.c" -static const int JSON_object_start = 1; -static const int JSON_object_first_final = 27; -static const int JSON_object_error = 0; -======= -#line 92 "parser.c" enum {JSON_object_start = 1}; enum {JSON_object_first_final = 27}; enum {JSON_object_error = 0}; ->>>>>>> Use enum enum {JSON_object_en_main = 1}; @@ -487,17 +480,10 @@ case 26: -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 484 "parser.c" -static const int JSON_value_start = 1; -static const int JSON_value_first_final = 29; -static const int JSON_value_error = 0; -======= -#line 470 "parser.c" enum {JSON_value_start = 1}; enum {JSON_value_first_final = 29}; enum {JSON_value_error = 0}; ->>>>>>> Use enum enum {JSON_value_en_main = 1}; @@ -892,17 +878,10 @@ case 28: } -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 882 "parser.c" -static const int JSON_integer_start = 1; -static const int JSON_integer_first_final = 3; -static const int JSON_integer_error = 0; -======= -#line 868 "parser.c" enum {JSON_integer_start = 1}; enum {JSON_integer_first_final = 3}; enum {JSON_integer_error = 0}; ->>>>>>> Use enum enum {JSON_integer_en_main = 1}; @@ -998,17 +977,10 @@ case 5: } -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 981 "parser.c" -static const int JSON_float_start = 1; -static const int JSON_float_first_final = 8; -static const int JSON_float_error = 0; -======= -#line 967 "parser.c" enum {JSON_float_start = 1}; enum {JSON_float_first_final = 8}; enum {JSON_float_error = 0}; ->>>>>>> Use enum enum {JSON_float_en_main = 1}; @@ -1171,17 +1143,10 @@ case 7: -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 1147 "parser.c" -static const int JSON_array_start = 1; -static const int JSON_array_first_final = 17; -static const int JSON_array_error = 0; -======= -#line 1133 "parser.c" enum {JSON_array_start = 1}; enum {JSON_array_first_final = 17}; enum {JSON_array_error = 0}; ->>>>>>> Use enum enum {JSON_array_en_main = 1}; @@ -1510,17 +1475,10 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) } -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 1479 "parser.c" -static const int JSON_string_start = 1; -static const int JSON_string_first_final = 8; -static const int JSON_string_error = 0; -======= -#line 1465 "parser.c" enum {JSON_string_start = 1}; enum {JSON_string_first_final = 8}; enum {JSON_string_error = 0}; ->>>>>>> Use enum enum {JSON_string_en_main = 1}; @@ -1852,30 +1810,15 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 -#line 1813 "parser.c" -static const int JSON_start = 1; -static const int JSON_first_final = 10; -static const int JSON_error = 0; -======= -#line 1788 "parser.c" -======= -#line 1787 "parser.c" ->>>>>>> Remove unnecessary conversion +#line 1814 "parser.c" enum {JSON_start = 1}; enum {JSON_first_final = 10}; enum {JSON_error = 0}; ->>>>>>> Use enum enum {JSON_en_main = 1}; -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 721 "parser.rl" -======= -#line 695 "parser.rl" ->>>>>>> Remove unnecessary conversion +#line 722 "parser.rl" /* @@ -1892,28 +1835,16 @@ static VALUE cParser_parse(VALUE self) GET_PARSER; -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 1838 "parser.c" -======= -#line 1812 "parser.c" ->>>>>>> Remove unnecessary conversion +#line 1839 "parser.c" { cs = JSON_start; } -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 737 "parser.rl" +#line 738 "parser.rl" p = json->source; pe = p + json->len; -#line 1847 "parser.c" -======= -#line 711 "parser.rl" - p = json->source; - pe = p + json->len; - -#line 1821 "parser.c" ->>>>>>> Remove unnecessary conversion +#line 1848 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1947,11 +1878,7 @@ st0: cs = 0; goto _out; tr2: -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 713 "parser.rl" -======= -#line 687 "parser.rl" ->>>>>>> Remove unnecessary conversion +#line 714 "parser.rl" { char *np = JSON_parse_value(json, p, pe, &result); if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} @@ -1961,11 +1888,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 1891 "parser.c" -======= -#line 1865 "parser.c" ->>>>>>> Remove unnecessary conversion +#line 1892 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -2054,11 +1977,7 @@ case 9: _out: {} } -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 740 "parser.rl" -======= -#line 714 "parser.rl" ->>>>>>> Remove unnecessary conversion +#line 741 "parser.rl" if (cs >= JSON_first_final && p == pe) { return result; |