summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/json/fbuffer/fbuffer.h21
-rw-r--r--ext/json/generator/depend2
-rw-r--r--ext/json/generator/generator.c2
-rw-r--r--ext/json/generator/generator.h21
-rw-r--r--ext/json/lib/json/add/time.rb5
-rw-r--r--ext/json/lib/json/common.rb13
-rw-r--r--ext/json/lib/json/version.rb2
-rw-r--r--ext/json/parser/depend2
8 files changed, 40 insertions, 28 deletions
diff --git a/ext/json/fbuffer/fbuffer.h b/ext/json/fbuffer/fbuffer.h
index 0c532967c4..b5e47eec42 100644
--- a/ext/json/fbuffer/fbuffer.h
+++ b/ext/json/fbuffer/fbuffer.h
@@ -5,6 +5,27 @@
#include "ruby.h"
#include <assert.h>
+#ifndef RHASH_SIZE
+#define RHASH_SIZE(hsh) (RHASH(hsh)->tbl->num_entries)
+#endif
+
+#ifndef RFLOAT_VALUE
+#define RFLOAT_VALUE(val) (RFLOAT(val)->value)
+#endif
+
+#ifndef RARRAY_PTR
+#define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
+#endif
+#ifndef RARRAY_LEN
+#define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len
+#endif
+#ifndef RSTRING_PTR
+#define RSTRING_PTR(string) RSTRING(string)->ptr
+#endif
+#ifndef RSTRING_LEN
+#define RSTRING_LEN(string) RSTRING(string)->len
+#endif
+
#ifdef HAVE_RUBY_ENCODING_H
#include "ruby/encoding.h"
#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding())
diff --git a/ext/json/generator/depend b/ext/json/generator/depend
index 1f0ea0a624..1a042a2501 100644
--- a/ext/json/generator/depend
+++ b/ext/json/generator/depend
@@ -1 +1 @@
-generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h $(ruby_headers)
+generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
index b1babb15f3..3cff87d7d5 100644
--- a/ext/json/generator/generator.c
+++ b/ext/json/generator/generator.c
@@ -864,7 +864,7 @@ static int isArrayOrObject(VALUE string)
if (string_len < 2) return 0;
for (; p < q && isspace(*p); p++);
for (; q > p && isspace(*q); q--);
- return *p == '[' && *q == ']' || *p == '{' && *q == '}';
+ return (*p == '[' && *q == ']') || (*p == '{' && *q == '}');
}
/*
diff --git a/ext/json/generator/generator.h b/ext/json/generator/generator.h
index 901b62c251..7d429d512c 100644
--- a/ext/json/generator/generator.h
+++ b/ext/json/generator/generator.h
@@ -16,27 +16,6 @@
#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
-#ifndef RHASH_SIZE
-#define RHASH_SIZE(hsh) (RHASH(hsh)->tbl->num_entries)
-#endif
-
-#ifndef RFLOAT_VALUE
-#define RFLOAT_VALUE(val) (RFLOAT(val)->value)
-#endif
-
-#ifndef RARRAY_PTR
-#define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
-#endif
-#ifndef RARRAY_LEN
-#define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len
-#endif
-#ifndef RSTRING_PTR
-#define RSTRING_PTR(string) RSTRING(string)->ptr
-#endif
-#ifndef RSTRING_LEN
-#define RSTRING_LEN(string) RSTRING(string)->len
-#endif
-
/* unicode defintions */
#define UNI_STRICT_CONVERSION 1
diff --git a/ext/json/lib/json/add/time.rb b/ext/json/lib/json/add/time.rb
index 9755707e68..338209d899 100644
--- a/ext/json/lib/json/add/time.rb
+++ b/ext/json/lib/json/add/time.rb
@@ -20,10 +20,13 @@ class Time
# Returns a hash, that will be turned into a JSON object and represent this
# object.
def as_json(*)
+ nanoseconds = [ tv_usec * 1000 ]
+ respond_to?(:tv_nsec) and nanoseconds << tv_nsec
+ nanoseconds = nanoseconds.max
{
JSON.create_id => self.class.name,
's' => tv_sec,
- 'n' => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000
+ 'n' => nanoseconds,
}
end
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index a30e4ce136..3349501337 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/lib/json/common.rb
@@ -103,7 +103,13 @@ module JSON
MinusInfinity = -Infinity
# The base exception for JSON errors.
- class JSONError < StandardError; end
+ class JSONError < StandardError
+ def self.wrap(exception)
+ obj = new("Wrapped(#{exception.class}): #{exception.message.inspect}")
+ obj.set_backtrace exception.backtrace
+ obj
+ end
+ end
# This exception is raised if a parser error occurs.
class ParserError < JSONError; end
@@ -399,7 +405,10 @@ module JSON
end
# Shortuct for iconv.
- if ::String.method_defined?(:encode)
+ if ::String.method_defined?(:encode) &&
+ # XXX Rubinius doesn't support ruby 1.9 encoding yet
+ defined?(RUBY_ENGINE) && RUBY_ENGINE != 'rbx'
+ then
# Encodes string using Ruby's _String.encode_
def self.iconv(to, from, string)
string.encode(to, from)
diff --git a/ext/json/lib/json/version.rb b/ext/json/lib/json/version.rb
index b1cf47f295..45af03fd40 100644
--- a/ext/json/lib/json/version.rb
+++ b/ext/json/lib/json/version.rb
@@ -1,6 +1,6 @@
module JSON
# JSON version
- VERSION = '1.7.1'
+ VERSION = '1.7.5'
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
diff --git a/ext/json/parser/depend b/ext/json/parser/depend
index 25e74781e6..498ffa964c 100644
--- a/ext/json/parser/depend
+++ b/ext/json/parser/depend
@@ -1 +1 @@
-parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h $(ruby_headers)
+parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h