ruby-changes:19468
From: yugui <ko1@a...>
Date: Thu, 12 May 2011 06:25:56 +0900 (JST)
Subject: [ruby-changes:19468] Ruby:r31508 (ruby_1_9_2): merges r30791 and r30792 from trunk into ruby_1_9_2.
yugui 2011-05-12 06:23:16 +0900 (Thu, 12 May 2011) New Revision: 31508 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31508 Log: merges r30791 and r30792 from trunk into ruby_1_9_2. -- * ext/json/parser/parser.h (GET_PARSER): check if initialized. [ruby-core:35079] * ext/json/parser/parser.rl (cParser_initialize): ditto. -- * ext/json/parser/parser.h (GET_PARSER): raise TypeError. * ext/json/parser/parser.rl (cParser_initialize): ditto. Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/ext/json/parser/parser.c branches/ruby_1_9_2/ext/json/parser/parser.h branches/ruby_1_9_2/ext/json/parser/parser.rl branches/ruby_1_9_2/test/json/test_json.rb branches/ruby_1_9_2/version.h Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 31507) +++ ruby_1_9_2/ChangeLog (revision 31508) @@ -1,3 +1,14 @@ +Sat Feb 5 11:29:10 2011 Nobuyoshi Nakada <nobu@r...> + + * ext/json/parser/parser.h (GET_PARSER): raise TypeError. + + * ext/json/parser/parser.rl (cParser_initialize): ditto. + + * ext/json/parser/parser.h (GET_PARSER): check if initialized. + [ruby-core:35079] + + * ext/json/parser/parser.rl (cParser_initialize): ditto. + Sun May 1 18:35:34 2011 Yuki Sonoda (Yugui) <yugui@y...> * test/fileutils/fileasserts.rb (assert_block): little workaround Index: ruby_1_9_2/ext/json/parser/parser.h =================================================================== --- ruby_1_9_2/ext/json/parser/parser.h (revision 31507) +++ ruby_1_9_2/ext/json/parser/parser.h (revision 31508) @@ -44,6 +44,9 @@ } JSON_Parser; #define GET_PARSER \ + GET_PARSER_INIT; \ + if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance") +#define GET_PARSER_INIT \ JSON_Parser *json; \ Data_Get_Struct(self, JSON_Parser, json) Index: ruby_1_9_2/ext/json/parser/parser.rl =================================================================== --- ruby_1_9_2/ext/json/parser/parser.rl (revision 31507) +++ ruby_1_9_2/ext/json/parser/parser.rl (revision 31508) @@ -608,7 +608,11 @@ char *ptr; long len; VALUE source, opts; - GET_PARSER; + GET_PARSER_INIT; + + if (json->Vsource) { + rb_raise(rb_eTypeError, "already initialized instance"); + } rb_scan_args(argc, argv, "11", &source, &opts); source = convert_encoding(StringValue(source)); ptr = RSTRING_PTR(source); Index: ruby_1_9_2/ext/json/parser/parser.c =================================================================== --- ruby_1_9_2/ext/json/parser/parser.c (revision 31507) +++ ruby_1_9_2/ext/json/parser/parser.c (revision 31508) @@ -1610,7 +1610,11 @@ char *ptr; long len; VALUE source, opts; - GET_PARSER; + GET_PARSER_INIT; + + if (json->Vsource) { + rb_raise(rb_eTypeError, "already initialized instance"); + } rb_scan_args(argc, argv, "11", &source, &opts); source = convert_encoding(StringValue(source)); ptr = RSTRING_PTR(source); @@ -1698,16 +1702,16 @@ GET_PARSER; -#line 1702 "parser.c" +#line 1706 "parser.c" { cs = JSON_start; } -#line 699 "parser.rl" +#line 703 "parser.rl" p = json->source; pe = p + json->len; -#line 1711 "parser.c" +#line 1715 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1784,7 +1788,7 @@ if ( ++p == pe ) goto _test_eof10; case 10: -#line 1788 "parser.c" +#line 1792 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -1841,7 +1845,7 @@ _out: {} } -#line 702 "parser.rl" +#line 706 "parser.rl" if (cs >= JSON_first_final && p == pe) { return result; Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 31507) +++ ruby_1_9_2/version.h (revision 31508) @@ -1,13 +1,13 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 192 +#define RUBY_PATCHLEVEL 193 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_YEAR 2011 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 1 -#define RUBY_RELEASE_DATE "2011-05-01" +#define RUBY_RELEASE_DAY 12 +#define RUBY_RELEASE_DATE "2011-05-12" #include "ruby/version.h" Index: ruby_1_9_2/test/json/test_json.rb =================================================================== --- ruby_1_9_2/test/json/test_json.rb (revision 31507) +++ ruby_1_9_2/test/json/test_json.rb (revision 31508) @@ -337,4 +337,11 @@ json5 = JSON([orig = 1 << 64]) assert_equal orig, JSON[json5][0] end + + def test_allocate + json = JSON::Parser.new("{}") + assert_raises(TypeError, '[ruby-core:35079]') {json.__send__(:initialize, "{}")} + json = JSON::Parser.allocate + assert_raises(TypeError, '[ruby-core:35079]') {json.source} + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/