[MacRuby] #1310: JSON.parse fails with NSString

MacRuby ruby-noreply at macosforge.org
Wed Jun 1 20:34:54 PDT 2011


#1310: JSON.parse fails with NSString
-----------------------------------+----------------------------------------
 Reporter:  isaackearse@…          |       Owner:  lsansonetti@…        
     Type:  defect                 |      Status:  new                  
 Priority:  blocker                |   Milestone:                       
Component:  MacRuby                |    Keywords:                       
-----------------------------------+----------------------------------------

Comment(by watson1978@…):

 Maybe,
 {{{
 #!diff
 diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl
 index 5862698..1251c63 100644
 --- a/ext/json/parser/parser.rl
 +++ b/ext/json/parser/parser.rl
 @@ -1,4 +1,5 @@
  #include "parser.h"
 +RUBY_EXTERN VALUE rb_cRubyString;

  /* unicode */

 @@ -634,7 +635,11 @@ static VALUE cParser_initialize(int argc, VALUE
 *argv, VALUE self)
      VALUE source, opts;
      GET_PARSER;
      rb_scan_args(argc, argv, "11", &source, &opts);
 -    source = convert_encoding(StringValue(source));
 +    StringValue(source);
 +    if (CLASS_OF(source) == rb_cRubyString) {
 +       // MacRuby : convert only RubyString
 +       source = convert_encoding(source);
 +    }
      ptr = RSTRING_PTR(source);
      len = RSTRING_LEN(source);
      if (!NIL_P(opts)) {
 }}}

 create parser.c
 {{{
 $ ragel parser.rl
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1310#comment:4>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list