json_pure 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/Rakefile +62 -6
- data/VERSION +1 -1
- data/benchmarks/benchmark_parser.rb +1 -1
- data/ext/json/ext/generator/unicode.c +1 -1
- data/ext/json/ext/parser/parser.c +1 -1
- data/ext/json/ext/parser/parser.rl +1 -1
- data/ext/json/ext/parser/unicode.c +1 -1
- data/lib/json/pure/parser.rb +16 -12
- data/lib/json/version.rb +1 -1
- data/tests/test_json_unicode.rb +4 -1
- data/tools/fuzz.rb +0 -2
- metadata +2 -2
data/CHANGES
CHANGED
data/Rakefile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# vim: set et sw=2 ts=2:
|
2
|
+
|
2
3
|
require 'rake/gempackagetask'
|
3
4
|
require 'rake/clean'
|
4
5
|
|
5
6
|
require 'rbconfig'
|
6
7
|
include Config
|
7
8
|
|
9
|
+
ON_WINDOWS = RUBY_PLATFORM =~ /mswin32/i
|
8
10
|
PKG_NAME = 'json'
|
9
11
|
PKG_VERSION = File.read('VERSION').chomp
|
10
12
|
PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|coverage|Makefile/).exclude(/\.(so|bundle|o|#{CONFIG['DLEXT']})$/)
|
@@ -19,7 +21,7 @@ EXT_GENERATOR_SRC = "#{EXT_GENERATOR_DIR}/generator.c"
|
|
19
21
|
RAGEL_CODEGEN = %w[rlcodegen rlgen-cd].find { |c| system(c, '-v') }
|
20
22
|
RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
|
21
23
|
CLEAN.include 'doc', 'coverage', FileList['diagrams/*.*'],
|
22
|
-
FileList["ext/**/*.{so,bundle,#{CONFIG['DLEXT']},o}"],
|
24
|
+
FileList["ext/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def}"],
|
23
25
|
FileList["ext/**/Makefile"]
|
24
26
|
|
25
27
|
|
@@ -28,8 +30,7 @@ task :install_pure => :version do
|
|
28
30
|
ruby 'install.rb'
|
29
31
|
end
|
30
32
|
|
31
|
-
|
32
|
-
task :install_ext => [ :compile, :install_pure ] do
|
33
|
+
task :install_ext_really do
|
33
34
|
sitearchdir = CONFIG["sitearchdir"]
|
34
35
|
cd 'ext' do
|
35
36
|
for file in Dir["json/ext/*.#{CONFIG['DLEXT']}"]
|
@@ -40,6 +41,9 @@ task :install_ext => [ :compile, :install_pure ] do
|
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
44
|
+
desc "Installing library (extension)"
|
45
|
+
task :install_ext => [ :compile, :install_pure, :install_ext_really ]
|
46
|
+
|
43
47
|
task :install => :install_ext
|
44
48
|
|
45
49
|
desc "Compiling extension"
|
@@ -48,7 +52,12 @@ task :compile => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
|
|
48
52
|
file EXT_PARSER_DL => EXT_PARSER_SRC do
|
49
53
|
cd EXT_PARSER_DIR do
|
50
54
|
ruby 'extconf.rb'
|
51
|
-
|
55
|
+
if ON_WINDOWS
|
56
|
+
sh 'nmake'
|
57
|
+
sh "mt -manifest parser.#{CONFIG['DLEXT']}.manifest -outputresource:parser.#{CONFIG['DLEXT']};2"
|
58
|
+
else
|
59
|
+
sh 'make'
|
60
|
+
end
|
52
61
|
end
|
53
62
|
cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
|
54
63
|
end
|
@@ -56,7 +65,12 @@ end
|
|
56
65
|
file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
|
57
66
|
cd EXT_GENERATOR_DIR do
|
58
67
|
ruby 'extconf.rb'
|
59
|
-
|
68
|
+
if ON_WINDOWS
|
69
|
+
sh 'nmake'
|
70
|
+
sh "mt -manifest generator.#{CONFIG['DLEXT']}.manifest -outputresource:generator.#{CONFIG['DLEXT']};2"
|
71
|
+
else
|
72
|
+
sh 'make'
|
73
|
+
end
|
60
74
|
end
|
61
75
|
cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
|
62
76
|
end
|
@@ -220,6 +234,44 @@ Rake::GemPackageTask.new(spec_ext) do |pkg|
|
|
220
234
|
pkg.package_files += PKG_FILES
|
221
235
|
end
|
222
236
|
|
237
|
+
task :package_win => :compile do
|
238
|
+
mkdir_p 'pkg'
|
239
|
+
spec_win_ext = Gem::Specification.new do |s|
|
240
|
+
s.name = 'json'
|
241
|
+
s.platform = Gem::Platform::WIN32
|
242
|
+
s.version = PKG_VERSION
|
243
|
+
s.summary = "A JSON implementation as a Ruby extension"
|
244
|
+
s.description = ""
|
245
|
+
|
246
|
+
s.files = PKG_FILES.to_a <<
|
247
|
+
"#{EXT_ROOT_DIR}/parser.#{CONFIG['DLEXT']}" <<
|
248
|
+
"#{EXT_ROOT_DIR}/generator.#{CONFIG['DLEXT']}"
|
249
|
+
|
250
|
+
s.require_path = EXT_ROOT_DIR
|
251
|
+
s.require_paths << 'ext'
|
252
|
+
s.require_paths << 'lib'
|
253
|
+
|
254
|
+
s.bindir = "bin"
|
255
|
+
s.executables = ["edit_json.rb"]
|
256
|
+
s.default_executable = "edit_json.rb"
|
257
|
+
|
258
|
+
s.has_rdoc = true
|
259
|
+
s.rdoc_options <<
|
260
|
+
'--title' << 'JSON -- A JSON implemention' <<
|
261
|
+
'--main' << 'JSON' << '--line-numbers'
|
262
|
+
s.test_files << 'tests/runner.rb'
|
263
|
+
|
264
|
+
s.author = "Florian Frank"
|
265
|
+
s.email = "flori@ping.de"
|
266
|
+
s.homepage = "http://json.rubyforge.org"
|
267
|
+
s.rubyforge_project = "json"
|
268
|
+
end
|
269
|
+
|
270
|
+
gem_file = "json-#{spec_win_ext.version}-#{spec_win_ext.platform}.gem"
|
271
|
+
Gem::Builder.new(spec_win_ext).build
|
272
|
+
mv gem_file, 'pkg'
|
273
|
+
end
|
274
|
+
|
223
275
|
task :mrproper => [ :ragel_clean, :clean ] do
|
224
276
|
for dir in [ EXT_PARSER_DIR, EXT_GENERATOR_DIR ]
|
225
277
|
cd(dir) { rm_f 'Makefile' }
|
@@ -243,6 +295,10 @@ EOT
|
|
243
295
|
end
|
244
296
|
end
|
245
297
|
|
246
|
-
|
298
|
+
if ON_WINDOWS
|
299
|
+
task :release => [ :version, :clean, :compile, :package_win ]
|
300
|
+
else
|
301
|
+
task :release => [ :version, :mrproper, :package ]
|
302
|
+
end
|
247
303
|
|
248
304
|
task :default => [ :version, :compile ]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
@@ -10,7 +10,7 @@ class BC_Parser < Bullshit::TimeCase
|
|
10
10
|
duration 10
|
11
11
|
|
12
12
|
def setup
|
13
|
-
a = [ nil, false, true, "
|
13
|
+
a = [ nil, false, true, "fÖß\nÄr", [ "n€st€d", true ], { "fooß" => "bär", "qu\r\nux" => true } ]
|
14
14
|
@big = a * 100
|
15
15
|
@json = JSON.generate(@big)
|
16
16
|
end
|
@@ -100,7 +100,7 @@ inline static unsigned char isLegalUTF8(const UTF8 *source, int length)
|
|
100
100
|
return 1;
|
101
101
|
}
|
102
102
|
|
103
|
-
|
103
|
+
void JSON_convert_UTF8_to_JSON(VALUE buffer, VALUE string, ConversionFlags flags)
|
104
104
|
{
|
105
105
|
char buf[7];
|
106
106
|
const UTF8* source = (UTF8 *) RSTRING(string)->ptr;
|
@@ -1349,10 +1349,10 @@ static VALUE cParser_initialize(VALUE self, VALUE source)
|
|
1349
1349
|
*/
|
1350
1350
|
static VALUE cParser_parse(VALUE self)
|
1351
1351
|
{
|
1352
|
-
GET_STRUCT;
|
1353
1352
|
char *p, *pe;
|
1354
1353
|
int cs = EVIL;
|
1355
1354
|
VALUE result = Qnil;
|
1355
|
+
GET_STRUCT;
|
1356
1356
|
|
1357
1357
|
|
1358
1358
|
#line 1359 "parser.c"
|
@@ -444,10 +444,10 @@ static VALUE cParser_initialize(VALUE self, VALUE source)
|
|
444
444
|
*/
|
445
445
|
static VALUE cParser_parse(VALUE self)
|
446
446
|
{
|
447
|
-
GET_STRUCT;
|
448
447
|
char *p, *pe;
|
449
448
|
int cs = EVIL;
|
450
449
|
VALUE result = Qnil;
|
450
|
+
GET_STRUCT;
|
451
451
|
|
452
452
|
%% write init;
|
453
453
|
p = json->source;
|
@@ -59,7 +59,7 @@ static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080
|
|
59
59
|
*/
|
60
60
|
static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
61
61
|
|
62
|
-
|
62
|
+
char *JSON_convert_UTF16_to_UTF8 (
|
63
63
|
VALUE buffer,
|
64
64
|
char *source,
|
65
65
|
char *sourceEnd,
|
data/lib/json/pure/parser.rb
CHANGED
@@ -77,22 +77,26 @@ module JSON
|
|
77
77
|
|
78
78
|
private
|
79
79
|
|
80
|
+
# Unescape characters in strings.
|
81
|
+
UNESCAPE_MAP = {
|
82
|
+
?" => '"',
|
83
|
+
?\\ => '\\',
|
84
|
+
?/ => '/',
|
85
|
+
?b => "\b",
|
86
|
+
?f => "\f",
|
87
|
+
?n => "\n",
|
88
|
+
?r => "\r",
|
89
|
+
?t => "\t",
|
90
|
+
}
|
91
|
+
|
80
92
|
def parse_string
|
81
93
|
if scan(STRING)
|
82
94
|
return '' if self[1].empty?
|
83
|
-
self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+))) do
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
when '\\/' then '/'
|
88
|
-
when '\\b' then "\b"
|
89
|
-
when '\\f' then "\f"
|
90
|
-
when '\\n' then "\n"
|
91
|
-
when '\\r' then "\r"
|
92
|
-
when '\\t' then "\t"
|
93
|
-
else
|
95
|
+
self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+))) do |c|
|
96
|
+
if u = UNESCAPE_MAP[c[1]]
|
97
|
+
u
|
98
|
+
else # \uXXXX
|
94
99
|
bytes = ''
|
95
|
-
c = $~[0]
|
96
100
|
i = 0
|
97
101
|
while c[6 * i] == ?\\ && c[6 * i + 1] == ?u
|
98
102
|
bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16)
|
data/lib/json/version.rb
CHANGED
data/tests/test_json_unicode.rb
CHANGED
@@ -41,7 +41,10 @@ class TC_JSONUnicode < Test::Unit::TestCase
|
|
41
41
|
(0..0x7f).each do |i|
|
42
42
|
json = '["\u%04x"]' % i
|
43
43
|
assert_equal i, JSON.parse(json).first[0]
|
44
|
-
if
|
44
|
+
if i == ?\b
|
45
|
+
generated = JSON.generate(["" << i])
|
46
|
+
assert '["\b"]' == generated || '["\10"]' == generated
|
47
|
+
elsif [?\n, ?\r, ?\t, ?\f].include?(i)
|
45
48
|
assert_equal '[' << ('' << i).dump << ']', JSON.generate(["" << i])
|
46
49
|
elsif i < 0x20
|
47
50
|
assert_equal json, JSON.generate(["" << i])
|
data/tools/fuzz.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: json_pure
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2007-04-
|
6
|
+
version: 1.0.3
|
7
|
+
date: 2007-04-26 00:00:00 +02:00
|
8
8
|
summary: A JSON implementation in Ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|