[前][次][番号順一覧][スレッド一覧]

ruby-changes:32536

From: nobu <ko1@a...>
Date: Wed, 15 Jan 2014 17:17:17 +0900 (JST)
Subject: [ruby-changes:32536] nobu:r44615 (trunk): ext/json: backward compatibilities

nobu	2014-01-15 17:16:46 +0900 (Wed, 15 Jan 2014)

  New Revision: 44615

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44615

  Log:
    ext/json: backward compatibilities
    
    * ext/json/fbuffer/fbuffer.h, ext/json/generator/generator.c: add
      macros for backward compatibilities.

  Modified files:
    trunk/ext/json/fbuffer/fbuffer.h
    trunk/ext/json/generator/generator.c
Index: ext/json/fbuffer/fbuffer.h
===================================================================
--- ext/json/fbuffer/fbuffer.h	(revision 44614)
+++ ext/json/fbuffer/fbuffer.h	(revision 44615)
@@ -25,6 +25,15 @@ https://github.com/ruby/ruby/blob/trunk/ext/json/fbuffer/fbuffer.h#L25
 #define RSTRING_LEN(string) RSTRING(string)->len
 #endif
 
+#ifdef PRIsVALUE
+# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
+# define RB_OBJ_STRING(obj) (obj)
+#else
+# define PRIsVALUE "s"
+# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
+# define RB_OBJ_STRING(obj) StringValueCStr(obj)
+#endif
+
 #ifdef HAVE_RUBY_ENCODING_H
 #include "ruby/encoding.h"
 #define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding())
Index: ext/json/generator/generator.c
===================================================================
--- ext/json/generator/generator.c	(revision 44614)
+++ ext/json/generator/generator.c	(revision 44615)
@@ -812,10 +812,10 @@ static void generate_json_float(FBuffer https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.c#L812
     if (!allow_nan) {
         if (isinf(value)) {
             fbuffer_free(buffer);
-            rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
+            rb_raise(eGeneratorError, "%u: %"PRIsVALUE" not allowed in JSON", __LINE__, RB_OBJ_STRING(tmp));
         } else if (isnan(value)) {
             fbuffer_free(buffer);
-            rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
+            rb_raise(eGeneratorError, "%u: %"PRIsVALUE" not allowed in JSON", __LINE__, RB_OBJ_STRING(tmp));
         }
     }
     fbuffer_append_str(buffer, tmp);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]