diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-11 13:36:06 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-11 13:36:06 +0000 |
commit | 4d8d3184d18b1a9d2eadb86a6688dc62eca7eabc (patch) | |
tree | 03e3a00e4e484ffdb46d5d774ab887dc695b8ed0 /ext/json/generator/generator.h | |
parent | 9d9ab5a384de3877f29cef8c0293c1caa432692c (diff) | |
download | ruby-4d8d3184d18b1a9d2eadb86a6688dc62eca7eabc.tar.gz |
* ext/json: Merge 164a75c8bd2007d32c4d7665d53140d8fc126dcd.
[ruby-core:41917] [Bug #5846]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/json/generator/generator.h')
-rw-r--r-- | ext/json/generator/generator.h | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/ext/json/generator/generator.h b/ext/json/generator/generator.h index f882ea004b..3220178a8f 100644 --- a/ext/json/generator/generator.h +++ b/ext/json/generator/generator.h @@ -7,19 +7,10 @@ #include "ruby.h" -#if HAVE_RUBY_RE_H +#ifdef HAVE_RUBY_RE_H #include "ruby/re.h" -#endif - -#if HAVE_RE_H -#include "re.h" -#endif - -#ifdef HAVE_RUBY_ENCODING_H -#include "ruby/encoding.h" -#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding()) #else -#define FORCE_UTF8(obj) +#include "re.h" #endif #define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key)) @@ -45,38 +36,6 @@ #define RSTRING_LEN(string) RSTRING(string)->len #endif -/* We don't need to guard objects for rbx, so let's do nothing at all. */ -#ifndef RB_GC_GUARD -#define RB_GC_GUARD(object) -#endif - -/* fbuffer implementation */ - -typedef struct FBufferStruct { - unsigned long initial_length; - char *ptr; - unsigned long len; - unsigned long capa; -} FBuffer; - -#define FBUFFER_INITIAL_LENGTH 4096 - -#define FBUFFER_PTR(fb) (fb->ptr) -#define FBUFFER_LEN(fb) (fb->len) -#define FBUFFER_CAPA(fb) (fb->capa) -#define FBUFFER_PAIR(fb) FBUFFER_PTR(fb), FBUFFER_LEN(fb) - -static char *fstrndup(const char *ptr, unsigned long len); -static FBuffer *fbuffer_alloc(); -static FBuffer *fbuffer_alloc_with_length(unsigned long initial_length); -static void fbuffer_free(FBuffer *fb); -static void fbuffer_clear(FBuffer *fb); -static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len); -static void fbuffer_append_long(FBuffer *fb, long number); -static void fbuffer_append_char(FBuffer *fb, char newchr); -static FBuffer *fbuffer_dup(FBuffer *fb); -static VALUE fbuffer_to_s(FBuffer *fb); - /* unicode defintions */ #define UNI_STRICT_CONVERSION 1 @@ -106,6 +65,7 @@ static void unicode_escape(char *buf, UTF16 character); static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16 character); static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string); static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string); +static char *fstrndup(const char *ptr, unsigned long len); /* ruby api and some helpers */ @@ -128,6 +88,7 @@ typedef struct JSON_Generator_StateStruct { char ascii_only; char quirks_mode; long depth; + long buffer_initial_length; } JSON_Generator_State; #define GET_STATE(self) \ |