json_pure 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,11 @@
1
+ 2010-04-26 (1.4.2)
2
+ * Applied patch from naruse Yui NARUSE <naruse@airemix.com> to make building with
3
+ Microsoft Visual C possible again.
4
+ * Applied patch from devrandom <c1.github@niftybox.net> in order to allow building of
5
+ json_pure if extensiontask is not present.
6
+ * Thanks to Dustin Schneider <dustin@stocktwits.com>, who reported a memory
7
+ leak, which is fixed in this release.
8
+ * Applied 993f261ccb8f911d2ae57e9db48ec7acd0187283 patch from josh@github.
1
9
  2010-04-25 (1.4.1)
2
10
  * Fix for a bug reported by Dan DeLeo <dan@kallistec.com>, caused by T_FIXNUM
3
11
  being different on 32bit/64bit architectures.
data/Rakefile CHANGED
@@ -24,14 +24,16 @@ PKG_TITLE = 'JSON Implementation for Ruby'
24
24
  PKG_VERSION = File.read('VERSION').chomp
25
25
  PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|tmp|coverage|Makefile|\.nfs\./).exclude(/\.(so|bundle|o|#{CONFIG['DLEXT']})$/)
26
26
  EXT_ROOT_DIR = 'ext/json/ext'
27
- EXT_PARSER_DL = "#{EXT_ROOT_DIR}/parser.#{CONFIG['DLEXT']}"
28
- EXT_PARSER_SRC = "#{EXT_ROOT_DIR}/parser.c"
27
+ EXT_PARSER_DIR = "#{EXT_ROOT_DIR}/parser"
28
+ EXT_PARSER_DL = "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}"
29
+ EXT_PARSER_SRC = "#{EXT_PARSER_DIR}/parser.c"
29
30
  PKG_FILES << EXT_PARSER_SRC
30
- EXT_GENERATOR_DL = "#{EXT_ROOT_DIR}/generator.#{CONFIG['DLEXT']}"
31
- EXT_GENERATOR_SRC = "#{EXT_ROOT_DIR}/generator.c"
31
+ EXT_GENERATOR_DIR = "#{EXT_ROOT_DIR}/generator"
32
+ EXT_GENERATOR_DL = "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}"
33
+ EXT_GENERATOR_SRC = "#{EXT_GENERATOR_DIR}/generator.c"
32
34
  RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find { |c| system(c, '-v') }
33
35
  RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find { |c| system(c, '-v') }
34
- RAGEL_PATH = "#{EXT_ROOT_DIR}/parser.rl"
36
+ RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
35
37
 
36
38
  def myruby(*args, &block)
37
39
  @myruby ||= File.join(CONFIG['bindir'], CONFIG['ruby_install_name'])
@@ -73,17 +75,19 @@ desc "Compiling extension"
73
75
  task :compile_ext => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
74
76
 
75
77
  file EXT_PARSER_DL => EXT_PARSER_SRC do
76
- cd EXT_ROOT_DIR do
77
- myruby 'extconf_parser.rb'
78
+ cd EXT_PARSER_DIR do
79
+ myruby 'extconf.rb'
78
80
  sh MAKE
79
81
  end
82
+ cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
80
83
  end
81
84
 
82
85
  file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
83
- cd EXT_ROOT_DIR do
84
- myruby 'extconf_generator.rb'
86
+ cd EXT_GENERATOR_DIR do
87
+ myruby 'extconf.rb'
85
88
  sh MAKE
86
89
  end
90
+ cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
87
91
  end
88
92
 
89
93
  desc "Generate parser with ragel"
@@ -94,7 +98,7 @@ task :ragel_clean do
94
98
  end
95
99
 
96
100
  file EXT_PARSER_SRC => RAGEL_PATH do
97
- cd EXT_ROOT_DIR do
101
+ cd EXT_PARSER_DIR do
98
102
  if RAGEL_CODEGEN == 'ragel'
99
103
  sh "ragel parser.rl -G2 -o parser.c"
100
104
  else
@@ -173,7 +177,7 @@ task :doc => [ :version, EXT_PARSER_SRC ] do
173
177
  sh "rdoc -o doc -t '#{PKG_TITLE}' -m README README lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
174
178
  end
175
179
 
176
- if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::ExtensionTask)
180
+ if defined?(Gem) and defined?(Rake::GemPackageTask)
177
181
  spec_pure = Gem::Specification.new do |s|
178
182
  s.name = 'json_pure'
179
183
  s.version = PKG_VERSION
@@ -204,7 +208,9 @@ if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::Extension
204
208
  pkg.need_tar = true
205
209
  pkg.package_files = PKG_FILES
206
210
  end
211
+ end
207
212
 
213
+ if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::ExtensionTask)
208
214
  spec_ext = Gem::Specification.new do |s|
209
215
  s.name = 'json'
210
216
  s.version = PKG_VERSION
@@ -213,7 +219,7 @@ if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::Extension
213
219
 
214
220
  s.files = PKG_FILES
215
221
 
216
- s.extensions = FileList['ext/**/extconf_*.rb']
222
+ s.extensions = FileList['ext/**/extconf.rb']
217
223
 
218
224
  s.require_path = EXT_ROOT_DIR
219
225
  s.require_paths << 'ext'
@@ -242,21 +248,19 @@ if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::Extension
242
248
 
243
249
  Rake::ExtensionTask.new do |ext|
244
250
  ext.name = 'parser'
245
- ext.config_script = 'extconf_parser.rb'
246
251
  ext.gem_spec = spec_ext
247
252
  ext.cross_compile = true
248
253
  ext.cross_platform = %w[i386-mswin32 i386-mingw32]
249
- ext.ext_dir = 'ext/json/ext'
254
+ ext.ext_dir = 'ext/json/ext/parser'
250
255
  ext.lib_dir = 'lib/json/ext'
251
256
  end
252
257
 
253
258
  Rake::ExtensionTask.new do |ext|
254
259
  ext.name = 'generator'
255
- ext.config_script = 'extconf_generator.rb'
256
260
  ext.gem_spec = spec_ext
257
261
  ext.cross_compile = true
258
262
  ext.cross_platform = %w[i386-mswin32 i386-mingw32]
259
- ext.ext_dir = 'ext/json/ext'
263
+ ext.ext_dir = 'ext/json/ext/generator'
260
264
  ext.lib_dir = 'lib/json/ext'
261
265
  end
262
266
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.1
1
+ 1.4.2
@@ -13,4 +13,4 @@ end
13
13
 
14
14
  have_header("ruby/re.h") || have_header("re.h")
15
15
  have_header("ruby/encoding.h")
16
- create_makefile 'generator'
16
+ create_makefile 'json/ext/generator'
@@ -172,7 +172,7 @@ static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string)
172
172
  fbuffer_append(buffer, "\\\"", 2);
173
173
  break;
174
174
  default:
175
- fbuffer_append_char(buffer, ch);
175
+ fbuffer_append_char(buffer, (char)ch);
176
176
  break;
177
177
  }
178
178
  } else {
@@ -284,8 +284,9 @@ static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
284
284
  }
285
285
 
286
286
  static char *fstrndup(const char *ptr, int len) {
287
+ char *result;
287
288
  if (len <= 0) return NULL;
288
- char *result = ALLOC_N(char, len);
289
+ result = ALLOC_N(char, len);
289
290
  memccpy(result, ptr, 0, len);
290
291
  return result;
291
292
  }
@@ -302,8 +303,9 @@ static FBuffer *fbuffer_alloc()
302
303
 
303
304
  static FBuffer *fbuffer_alloc_with_length(unsigned int initial_length)
304
305
  {
306
+ FBuffer *fb;
305
307
  assert(initial_length > 0);
306
- FBuffer *fb = ALLOC(FBuffer);
308
+ fb = ALLOC(FBuffer);
307
309
  memset((void *) fb, 0, sizeof(FBuffer));
308
310
  fb->initial_length = initial_length;
309
311
  return fb;
@@ -641,36 +643,41 @@ static VALUE cState_configure(VALUE self, VALUE opts)
641
643
  opts = tmp;
642
644
  tmp = rb_hash_aref(opts, ID2SYM(i_indent));
643
645
  if (RTEST(tmp)) {
646
+ int len;
644
647
  Check_Type(tmp, T_STRING);
645
- int len = RSTRING_LEN(tmp);
648
+ len = RSTRING_LEN(tmp);
646
649
  state->indent = fstrndup(RSTRING_PTR(tmp), len);
647
650
  state->indent_len = len;
648
651
  }
649
652
  tmp = rb_hash_aref(opts, ID2SYM(i_space));
650
653
  if (RTEST(tmp)) {
654
+ int len;
651
655
  Check_Type(tmp, T_STRING);
652
- int len = RSTRING_LEN(tmp);
656
+ len = RSTRING_LEN(tmp);
653
657
  state->space = fstrndup(RSTRING_PTR(tmp), len);
654
658
  state->space_len = len;
655
659
  }
656
660
  tmp = rb_hash_aref(opts, ID2SYM(i_space_before));
657
661
  if (RTEST(tmp)) {
662
+ int len;
658
663
  Check_Type(tmp, T_STRING);
659
- int len = RSTRING_LEN(tmp);
664
+ len = RSTRING_LEN(tmp);
660
665
  state->space_before = fstrndup(RSTRING_PTR(tmp), len);
661
666
  state->space_before_len = len;
662
667
  }
663
668
  tmp = rb_hash_aref(opts, ID2SYM(i_array_nl));
664
669
  if (RTEST(tmp)) {
670
+ int len;
665
671
  Check_Type(tmp, T_STRING);
666
- int len = RSTRING_LEN(tmp);
672
+ len = RSTRING_LEN(tmp);
667
673
  state->array_nl = fstrndup(RSTRING_PTR(tmp), len);
668
674
  state->array_nl_len = len;
669
675
  }
670
676
  tmp = rb_hash_aref(opts, ID2SYM(i_object_nl));
671
677
  if (RTEST(tmp)) {
678
+ int len;
672
679
  Check_Type(tmp, T_STRING);
673
- int len = RSTRING_LEN(tmp);
680
+ len = RSTRING_LEN(tmp);
674
681
  state->object_nl = fstrndup(RSTRING_PTR(tmp), len);
675
682
  state->object_nl_len = len;
676
683
  }
@@ -744,14 +751,14 @@ static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *s
744
751
  char *delim2 = FBUFFER_PTR(state->object_delim2);
745
752
  long delim2_len = FBUFFER_LEN(state->object_delim2);
746
753
  int i, j;
754
+ VALUE key, key_to_s, keys;
747
755
  depth++;
748
756
  if (max_nesting != 0 && depth > max_nesting) {
749
757
  fbuffer_free(buffer);
750
758
  rb_raise(eNestingError, "nesting of %ld is too deep", depth);
751
759
  }
752
760
  fbuffer_append_char(buffer, '{');
753
- VALUE keys = rb_funcall(obj, rb_intern("keys"), 0);
754
- VALUE key, key_to_s;
761
+ keys = rb_funcall(obj, rb_intern("keys"), 0);
755
762
  for(i = 0; i < RARRAY_LEN(keys); i++) {
756
763
  if (i > 0) fbuffer_append(buffer, delim, delim_len);
757
764
  if (object_nl) {
@@ -914,7 +921,7 @@ static VALUE cState_partial_generate(VALUE self, VALUE obj, VALUE depth)
914
921
 
915
922
  generate_json(buffer, self, state, obj, NIL_P(depth) ? 0 : FIX2INT(depth));
916
923
  result = rb_str_new(FBUFFER_PAIR(buffer));
917
- fbuffer_free_only_buffer(buffer);
924
+ fbuffer_free(buffer);
918
925
  FORCE_UTF8(result);
919
926
  return result;
920
927
  }
@@ -12,4 +12,4 @@ if CONFIG['CC'] =~ /gcc/
12
12
  end
13
13
 
14
14
  have_header("re.h")
15
- create_makefile 'parser'
15
+ create_makefile 'json/ext/parser'
@@ -147,8 +147,9 @@ case 2:
147
147
  tr2:
148
148
  #line 127 "parser.rl"
149
149
  {
150
+ char *np;
150
151
  json->parsing_name = 1;
151
- char *np = JSON_parse_string(json, p, pe, &last_name);
152
+ np = JSON_parse_string(json, p, pe, &last_name);
152
153
  json->parsing_name = 0;
153
154
  if (np == NULL) { p--; {p++; cs = 3; goto _out;} } else {p = (( np))-1;}
154
155
  }
@@ -125,8 +125,9 @@ static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
125
125
  }
126
126
 
127
127
  action parse_name {
128
+ char *np;
128
129
  json->parsing_name = 1;
129
- char *np = JSON_parse_string(json, fpc, pe, &last_name);
130
+ np = JSON_parse_string(json, fpc, pe, &last_name);
130
131
  json->parsing_name = 0;
131
132
  if (np == NULL) { fhold; fbreak; } else fexec np;
132
133
  }
@@ -1,6 +1,6 @@
1
1
  module JSON
2
2
  # JSON version
3
- VERSION = '1.4.1'
3
+ VERSION = '1.4.2'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_pure
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-25 00:00:00 +02:00
12
+ date: 2010-04-28 00:00:00 +02:00
13
13
  default_executable: edit_json.rb
14
14
  dependencies: []
15
15
 
@@ -67,13 +67,13 @@ files:
67
67
  - benchmarks/generator_benchmark.rb
68
68
  - benchmarks/parser2_benchmark.rb
69
69
  - benchmarks/ohai.ruby
70
- - ext/json/ext/extconf_generator.rb
71
- - ext/json/ext/parser.rl
72
- - ext/json/ext/extconf_parser.rb
73
- - ext/json/ext/parser.h
74
- - ext/json/ext/parser.c
75
- - ext/json/ext/generator.c
76
- - ext/json/ext/generator.h
70
+ - ext/json/ext/generator/extconf.rb
71
+ - ext/json/ext/generator/generator.c
72
+ - ext/json/ext/generator/generator.h
73
+ - ext/json/ext/parser/extconf.rb
74
+ - ext/json/ext/parser/parser.rl
75
+ - ext/json/ext/parser/parser.h
76
+ - ext/json/ext/parser/parser.c
77
77
  - Rakefile
78
78
  - tools/fuzz.rb
79
79
  - tools/server.rb