benschwarz-smoke 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +6 -0
- data/VERSION.yml +1 -1
- metadata +65 -196
- data/Gemfile +0 -10
- data/bin/edit_json.rb +0 -3
- data/bin/restclient +0 -3
- data/vendor/gems/cache/crack-0.1.1.gem +0 -0
- data/vendor/gems/cache/fakeweb-1.2.5.gem +0 -0
- data/vendor/gems/cache/json-1.1.3.gem +0 -0
- data/vendor/gems/cache/rest-client-1.0.1.gem +0 -0
- data/vendor/gems/cache/simple-rss-1.2.gem +0 -0
- data/vendor/gems/cache/wycats-moneta-0.6.0.gem +0 -0
- data/vendor/gems/environment.rb +0 -83
- data/vendor/gems/gems/crack-0.1.1/LICENSE +0 -20
- data/vendor/gems/gems/crack-0.1.1/README.rdoc +0 -22
- data/vendor/gems/gems/crack-0.1.1/VERSION.yml +0 -4
- data/vendor/gems/gems/crack-0.1.1/lib/crack.rb +0 -7
- data/vendor/gems/gems/crack-0.1.1/lib/crack/core_extensions.rb +0 -126
- data/vendor/gems/gems/crack-0.1.1/lib/crack/json.rb +0 -66
- data/vendor/gems/gems/crack-0.1.1/lib/crack/xml.rb +0 -211
- data/vendor/gems/gems/crack-0.1.1/test/crack_test.rb +0 -4
- data/vendor/gems/gems/crack-0.1.1/test/json_test.rb +0 -42
- data/vendor/gems/gems/crack-0.1.1/test/test_helper.rb +0 -12
- data/vendor/gems/gems/crack-0.1.1/test/xml_test.rb +0 -451
- data/vendor/gems/gems/fakeweb-1.2.5/CHANGELOG +0 -163
- data/vendor/gems/gems/fakeweb-1.2.5/LICENSE.txt +0 -281
- data/vendor/gems/gems/fakeweb-1.2.5/README.rdoc +0 -193
- data/vendor/gems/gems/fakeweb-1.2.5/Rakefile +0 -76
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web.rb +0 -172
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/ext/net_http.rb +0 -71
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/registry.rb +0 -103
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/responder.rb +0 -113
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/response.rb +0 -10
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/stub_socket.rb +0 -15
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/utility.rb +0 -22
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fakeweb.rb +0 -2
- data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_from_curl +0 -12
- data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_with_transfer_encoding +0 -17
- data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_without_transfer_encoding +0 -11
- data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_example.txt +0 -1
- data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_txt_file +0 -3
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_allow_net_connect.rb +0 -85
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_deprecations.rb +0 -54
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_authentication.rb +0 -92
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web.rb +0 -518
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web_open_uri.rb +0 -58
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_helper.rb +0 -74
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_missing_open_uri.rb +0 -25
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_precedence.rb +0 -51
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_query_string.rb +0 -45
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_regexes.rb +0 -103
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_response_headers.rb +0 -67
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_trailing_slashes.rb +0 -53
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_utility.rb +0 -70
- data/vendor/gems/gems/json-1.1.3/CHANGES +0 -93
- data/vendor/gems/gems/json-1.1.3/GPL +0 -340
- data/vendor/gems/gems/json-1.1.3/README +0 -78
- data/vendor/gems/gems/json-1.1.3/RUBY +0 -58
- data/vendor/gems/gems/json-1.1.3/Rakefile +0 -309
- data/vendor/gems/gems/json-1.1.3/TODO +0 -1
- data/vendor/gems/gems/json-1.1.3/VERSION +0 -1
- data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark.txt +0 -133
- data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_generator.rb +0 -48
- data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_parser.rb +0 -26
- data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_rails.rb +0 -26
- data/vendor/gems/gems/json-1.1.3/bin/edit_json.rb +0 -10
- data/vendor/gems/gems/json-1.1.3/bin/prettify_json.rb +0 -76
- data/vendor/gems/gems/json-1.1.3/data/example.json +0 -1
- data/vendor/gems/gems/json-1.1.3/data/index.html +0 -38
- data/vendor/gems/gems/json-1.1.3/data/prototype.js +0 -4184
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator.bundle +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/Makefile +0 -150
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/extconf.rb +0 -9
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.bundle +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.c +0 -875
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.o +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.c +0 -182
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.h +0 -53
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.o +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser.bundle +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/Makefile +0 -150
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/extconf.rb +0 -9
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.bundle +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.c +0 -1758
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.o +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.rl +0 -638
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.c +0 -154
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.h +0 -58
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.o +0 -0
- data/vendor/gems/gems/json-1.1.3/install.rb +0 -26
- data/vendor/gems/gems/json-1.1.3/lib/json.rb +0 -235
- data/vendor/gems/gems/json-1.1.3/lib/json/Array.xpm +0 -21
- data/vendor/gems/gems/json-1.1.3/lib/json/FalseClass.xpm +0 -21
- data/vendor/gems/gems/json-1.1.3/lib/json/Hash.xpm +0 -21
- data/vendor/gems/gems/json-1.1.3/lib/json/Key.xpm +0 -73
- data/vendor/gems/gems/json-1.1.3/lib/json/NilClass.xpm +0 -21
- data/vendor/gems/gems/json-1.1.3/lib/json/Numeric.xpm +0 -28
- data/vendor/gems/gems/json-1.1.3/lib/json/String.xpm +0 -96
- data/vendor/gems/gems/json-1.1.3/lib/json/TrueClass.xpm +0 -21
- data/vendor/gems/gems/json-1.1.3/lib/json/add/core.rb +0 -135
- data/vendor/gems/gems/json-1.1.3/lib/json/add/rails.rb +0 -58
- data/vendor/gems/gems/json-1.1.3/lib/json/common.rb +0 -354
- data/vendor/gems/gems/json-1.1.3/lib/json/editor.rb +0 -1362
- data/vendor/gems/gems/json-1.1.3/lib/json/ext.rb +0 -13
- data/vendor/gems/gems/json-1.1.3/lib/json/json.xpm +0 -1499
- data/vendor/gems/gems/json-1.1.3/lib/json/pure.rb +0 -75
- data/vendor/gems/gems/json-1.1.3/lib/json/pure/generator.rb +0 -394
- data/vendor/gems/gems/json-1.1.3/lib/json/pure/parser.rb +0 -259
- data/vendor/gems/gems/json-1.1.3/lib/json/version.rb +0 -9
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail1.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail10.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail11.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail12.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail13.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail14.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail18.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail19.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail2.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail20.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail21.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail22.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail23.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail24.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail25.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail27.json +0 -2
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail28.json +0 -2
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail3.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail4.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail5.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail6.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail7.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail8.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail9.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass1.json +0 -56
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass15.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass16.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass17.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass2.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass26.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass3.json +0 -6
- data/vendor/gems/gems/json-1.1.3/tests/runner.rb +0 -25
- data/vendor/gems/gems/json-1.1.3/tests/test_json.rb +0 -293
- data/vendor/gems/gems/json-1.1.3/tests/test_json_addition.rb +0 -161
- data/vendor/gems/gems/json-1.1.3/tests/test_json_fixtures.rb +0 -30
- data/vendor/gems/gems/json-1.1.3/tests/test_json_generate.rb +0 -100
- data/vendor/gems/gems/json-1.1.3/tests/test_json_rails.rb +0 -118
- data/vendor/gems/gems/json-1.1.3/tests/test_json_unicode.rb +0 -61
- data/vendor/gems/gems/json-1.1.3/tools/fuzz.rb +0 -140
- data/vendor/gems/gems/json-1.1.3/tools/server.rb +0 -62
- data/vendor/gems/gems/rest-client-1.0.1/README.rdoc +0 -151
- data/vendor/gems/gems/rest-client-1.0.1/Rakefile +0 -85
- data/vendor/gems/gems/rest-client-1.0.1/bin/restclient +0 -87
- data/vendor/gems/gems/rest-client-1.0.1/lib/rest_client.rb +0 -2
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient.rb +0 -93
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/exceptions.rb +0 -84
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/mixin/response.rb +0 -43
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/raw_response.rb +0 -30
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/request.rb +0 -236
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/resource.rb +0 -146
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/response.rb +0 -20
- data/vendor/gems/gems/rest-client-1.0.1/spec/base.rb +0 -4
- data/vendor/gems/gems/rest-client-1.0.1/spec/exceptions_spec.rb +0 -54
- data/vendor/gems/gems/rest-client-1.0.1/spec/mixin/response_spec.rb +0 -46
- data/vendor/gems/gems/rest-client-1.0.1/spec/raw_response_spec.rb +0 -17
- data/vendor/gems/gems/rest-client-1.0.1/spec/request_spec.rb +0 -462
- data/vendor/gems/gems/rest-client-1.0.1/spec/resource_spec.rb +0 -75
- data/vendor/gems/gems/rest-client-1.0.1/spec/response_spec.rb +0 -16
- data/vendor/gems/gems/rest-client-1.0.1/spec/restclient_spec.rb +0 -53
- data/vendor/gems/gems/simple-rss-1.2/LICENSE +0 -429
- data/vendor/gems/gems/simple-rss-1.2/README +0 -43
- data/vendor/gems/gems/simple-rss-1.2/Rakefile +0 -212
- data/vendor/gems/gems/simple-rss-1.2/lib/simple-rss.rb +0 -149
- data/vendor/gems/gems/simple-rss-1.2/test/base/base_test.rb +0 -51
- data/vendor/gems/gems/simple-rss-1.2/test/data/atom.xml +0 -45
- data/vendor/gems/gems/simple-rss-1.2/test/data/not-rss.xml +0 -8
- data/vendor/gems/gems/simple-rss-1.2/test/data/rss09.rdf +0 -79
- data/vendor/gems/gems/simple-rss-1.2/test/data/rss20.xml +0 -818
- data/vendor/gems/gems/simple-rss-1.2/test/test_helper.rb +0 -4
- data/vendor/gems/gems/wycats-moneta-0.6.0/LICENSE +0 -20
- data/vendor/gems/gems/wycats-moneta-0.6.0/README +0 -50
- data/vendor/gems/gems/wycats-moneta-0.6.0/Rakefile +0 -60
- data/vendor/gems/gems/wycats-moneta-0.6.0/TODO +0 -4
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta.rb +0 -76
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/datamapper.rb +0 -117
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/file.rb +0 -91
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memcache.rb +0 -52
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memory.rb +0 -11
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/xattr.rb +0 -58
- data/vendor/gems/specifications/crack-0.1.1.gemspec +0 -29
- data/vendor/gems/specifications/fakeweb-1.2.5.gemspec +0 -34
- data/vendor/gems/specifications/json-1.1.3.gemspec +0 -33
- data/vendor/gems/specifications/rest-client-1.0.1.gemspec +0 -30
- data/vendor/gems/specifications/simple-rss-1.2.gemspec +0 -27
- data/vendor/gems/specifications/wycats-moneta-0.6.0.gemspec +0 -29
@@ -1,154 +0,0 @@
|
|
1
|
-
#include "unicode.h"
|
2
|
-
|
3
|
-
/*
|
4
|
-
* Copyright 2001-2004 Unicode, Inc.
|
5
|
-
*
|
6
|
-
* Disclaimer
|
7
|
-
*
|
8
|
-
* This source code is provided as is by Unicode, Inc. No claims are
|
9
|
-
* made as to fitness for any particular purpose. No warranties of any
|
10
|
-
* kind are expressed or implied. The recipient agrees to determine
|
11
|
-
* applicability of information provided. If this file has been
|
12
|
-
* purchased on magnetic or optical media from Unicode, Inc., the
|
13
|
-
* sole remedy for any claim will be exchange of defective media
|
14
|
-
* within 90 days of receipt.
|
15
|
-
*
|
16
|
-
* Limitations on Rights to Redistribute This Code
|
17
|
-
*
|
18
|
-
* Unicode, Inc. hereby grants the right to freely use the information
|
19
|
-
* supplied in this file in the creation of products supporting the
|
20
|
-
* Unicode Standard, and to make copies of this file in any form
|
21
|
-
* for internal or external distribution as long as this notice
|
22
|
-
* remains attached.
|
23
|
-
*/
|
24
|
-
|
25
|
-
/*
|
26
|
-
* Index into the table below with the first byte of a UTF-8 sequence to
|
27
|
-
* get the number of trailing bytes that are supposed to follow it.
|
28
|
-
* Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
|
29
|
-
* left as-is for anyone who may want to do such conversion, which was
|
30
|
-
* allowed in earlier algorithms.
|
31
|
-
*/
|
32
|
-
static const char trailingBytesForUTF8[256] = {
|
33
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
34
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
35
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
37
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
38
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
39
|
-
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
40
|
-
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
|
41
|
-
};
|
42
|
-
|
43
|
-
/*
|
44
|
-
* Magic values subtracted from a buffer value during UTF8 conversion.
|
45
|
-
* This table contains as many values as there might be trailing bytes
|
46
|
-
* in a UTF-8 sequence.
|
47
|
-
*/
|
48
|
-
static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
|
49
|
-
0x03C82080UL, 0xFA082080UL, 0x82082080UL };
|
50
|
-
|
51
|
-
/*
|
52
|
-
* Once the bits are split out into bytes of UTF-8, this is a mask OR-ed
|
53
|
-
* into the first byte, depending on how many bytes follow. There are
|
54
|
-
* as many entries in this table as there are UTF-8 sequence types.
|
55
|
-
* (I.e., one byte sequence, two byte... etc.). Remember that sequencs
|
56
|
-
* for *legal* UTF-8 will be 4 or fewer bytes total.
|
57
|
-
*/
|
58
|
-
static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
59
|
-
|
60
|
-
char *JSON_convert_UTF16_to_UTF8 (
|
61
|
-
VALUE buffer,
|
62
|
-
char *source,
|
63
|
-
char *sourceEnd,
|
64
|
-
ConversionFlags flags)
|
65
|
-
{
|
66
|
-
UTF16 *tmp, *tmpPtr, *tmpEnd;
|
67
|
-
char buf[5];
|
68
|
-
long n = 0, i;
|
69
|
-
char *p = source - 1;
|
70
|
-
|
71
|
-
while (p < sourceEnd && p[0] == '\\' && p[1] == 'u') {
|
72
|
-
p += 6;
|
73
|
-
n++;
|
74
|
-
}
|
75
|
-
p = source + 1;
|
76
|
-
buf[4] = 0;
|
77
|
-
tmpPtr = tmp = ALLOC_N(UTF16, n);
|
78
|
-
tmpEnd = tmp + n;
|
79
|
-
for (i = 0; i < n; i++) {
|
80
|
-
buf[0] = *p++;
|
81
|
-
buf[1] = *p++;
|
82
|
-
buf[2] = *p++;
|
83
|
-
buf[3] = *p++;
|
84
|
-
tmpPtr[i] = strtol(buf, NULL, 16);
|
85
|
-
p += 2;
|
86
|
-
}
|
87
|
-
|
88
|
-
while (tmpPtr < tmpEnd) {
|
89
|
-
UTF32 ch;
|
90
|
-
unsigned short bytesToWrite = 0;
|
91
|
-
const UTF32 byteMask = 0xBF;
|
92
|
-
const UTF32 byteMark = 0x80;
|
93
|
-
ch = *tmpPtr++;
|
94
|
-
/* If we have a surrogate pair, convert to UTF32 first. */
|
95
|
-
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
|
96
|
-
/* If the 16 bits following the high surrogate are in the source
|
97
|
-
* buffer... */
|
98
|
-
if (tmpPtr < tmpEnd) {
|
99
|
-
UTF32 ch2 = *tmpPtr;
|
100
|
-
/* If it's a low surrogate, convert to UTF32. */
|
101
|
-
if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
|
102
|
-
ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
|
103
|
-
+ (ch2 - UNI_SUR_LOW_START) + halfBase;
|
104
|
-
++tmpPtr;
|
105
|
-
} else if (flags == strictConversion) { /* it's an unpaired high surrogate */
|
106
|
-
free(tmp);
|
107
|
-
rb_raise(rb_path2class("JSON::ParserError"),
|
108
|
-
"source sequence is illegal/malformed near %s", source);
|
109
|
-
}
|
110
|
-
} else { /* We don't have the 16 bits following the high surrogate. */
|
111
|
-
free(tmp);
|
112
|
-
rb_raise(rb_path2class("JSON::ParserError"),
|
113
|
-
"partial character in source, but hit end near %s", source);
|
114
|
-
break;
|
115
|
-
}
|
116
|
-
} else if (flags == strictConversion) {
|
117
|
-
/* UTF-16 surrogate values are illegal in UTF-32 */
|
118
|
-
if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
|
119
|
-
free(tmp);
|
120
|
-
rb_raise(rb_path2class("JSON::ParserError"),
|
121
|
-
"source sequence is illegal/malformed near %s", source);
|
122
|
-
}
|
123
|
-
}
|
124
|
-
/* Figure out how many bytes the result will require */
|
125
|
-
if (ch < (UTF32) 0x80) {
|
126
|
-
bytesToWrite = 1;
|
127
|
-
} else if (ch < (UTF32) 0x800) {
|
128
|
-
bytesToWrite = 2;
|
129
|
-
} else if (ch < (UTF32) 0x10000) {
|
130
|
-
bytesToWrite = 3;
|
131
|
-
} else if (ch < (UTF32) 0x110000) {
|
132
|
-
bytesToWrite = 4;
|
133
|
-
} else {
|
134
|
-
bytesToWrite = 3;
|
135
|
-
ch = UNI_REPLACEMENT_CHAR;
|
136
|
-
}
|
137
|
-
|
138
|
-
buf[0] = 0;
|
139
|
-
buf[1] = 0;
|
140
|
-
buf[2] = 0;
|
141
|
-
buf[3] = 0;
|
142
|
-
p = buf + bytesToWrite;
|
143
|
-
switch (bytesToWrite) { /* note: everything falls through. */
|
144
|
-
case 4: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
|
145
|
-
case 3: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
|
146
|
-
case 2: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
|
147
|
-
case 1: *--p = (UTF8) (ch | firstByteMark[bytesToWrite]);
|
148
|
-
}
|
149
|
-
rb_str_buf_cat(buffer, p, bytesToWrite);
|
150
|
-
}
|
151
|
-
free(tmp);
|
152
|
-
source += 5 + (n - 1) * 6;
|
153
|
-
return source;
|
154
|
-
}
|
@@ -1,58 +0,0 @@
|
|
1
|
-
|
2
|
-
#ifndef _PARSER_UNICODE_H_
|
3
|
-
#define _PARSER_UNICODE_H_
|
4
|
-
|
5
|
-
#include "ruby.h"
|
6
|
-
|
7
|
-
typedef unsigned long UTF32; /* at least 32 bits */
|
8
|
-
typedef unsigned short UTF16; /* at least 16 bits */
|
9
|
-
typedef unsigned char UTF8; /* typically 8 bits */
|
10
|
-
|
11
|
-
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
|
12
|
-
#define UNI_MAX_BMP (UTF32)0x0000FFFF
|
13
|
-
#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
|
14
|
-
#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
|
15
|
-
#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
|
16
|
-
|
17
|
-
#define UNI_SUR_HIGH_START (UTF32)0xD800
|
18
|
-
#define UNI_SUR_HIGH_END (UTF32)0xDBFF
|
19
|
-
#define UNI_SUR_LOW_START (UTF32)0xDC00
|
20
|
-
#define UNI_SUR_LOW_END (UTF32)0xDFFF
|
21
|
-
|
22
|
-
static const int halfShift = 10; /* used for shifting by 10 bits */
|
23
|
-
|
24
|
-
static const UTF32 halfBase = 0x0010000UL;
|
25
|
-
static const UTF32 halfMask = 0x3FFUL;
|
26
|
-
|
27
|
-
typedef enum {
|
28
|
-
conversionOK = 0, /* conversion successful */
|
29
|
-
sourceExhausted, /* partial character in source, but hit end */
|
30
|
-
targetExhausted, /* insuff. room in target for conversion */
|
31
|
-
sourceIllegal /* source sequence is illegal/malformed */
|
32
|
-
} ConversionResult;
|
33
|
-
|
34
|
-
typedef enum {
|
35
|
-
strictConversion = 0,
|
36
|
-
lenientConversion
|
37
|
-
} ConversionFlags;
|
38
|
-
|
39
|
-
char *JSON_convert_UTF16_to_UTF8 (
|
40
|
-
VALUE buffer,
|
41
|
-
char *source,
|
42
|
-
char *sourceEnd,
|
43
|
-
ConversionFlags flags);
|
44
|
-
|
45
|
-
#ifndef RARRAY_PTR
|
46
|
-
#define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
|
47
|
-
#endif
|
48
|
-
#ifndef RARRAY_LEN
|
49
|
-
#define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len
|
50
|
-
#endif
|
51
|
-
#ifndef RSTRING_PTR
|
52
|
-
#define RSTRING_PTR(string) RSTRING(string)->ptr
|
53
|
-
#endif
|
54
|
-
#ifndef RSTRING_LEN
|
55
|
-
#define RSTRING_LEN(string) RSTRING(string)->len
|
56
|
-
#endif
|
57
|
-
|
58
|
-
#endif
|
Binary file
|
@@ -1,26 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rbconfig'
|
4
|
-
require 'fileutils'
|
5
|
-
include FileUtils::Verbose
|
6
|
-
|
7
|
-
include Config
|
8
|
-
|
9
|
-
bindir = CONFIG["bindir"]
|
10
|
-
cd 'bin' do
|
11
|
-
filename = 'edit_json.rb'
|
12
|
-
#install(filename, bindir)
|
13
|
-
end
|
14
|
-
sitelibdir = CONFIG["sitelibdir"]
|
15
|
-
cd 'lib' do
|
16
|
-
install('json.rb', sitelibdir)
|
17
|
-
mkdir_p File.join(sitelibdir, 'json')
|
18
|
-
for file in Dir['json/**/*.{rb,xpm}']
|
19
|
-
d = File.join(sitelibdir, file)
|
20
|
-
mkdir_p File.dirname(d)
|
21
|
-
install(file, d)
|
22
|
-
end
|
23
|
-
install(File.join('json', 'editor.rb'), File.join(sitelibdir,'json'))
|
24
|
-
install(File.join('json', 'json.xpm'), File.join(sitelibdir,'json'))
|
25
|
-
end
|
26
|
-
warn " *** Installed PURE ruby library."
|
@@ -1,235 +0,0 @@
|
|
1
|
-
require 'json/common'
|
2
|
-
# = json - JSON for Ruby
|
3
|
-
#
|
4
|
-
# == Description
|
5
|
-
#
|
6
|
-
# This is a implementation of the JSON specification according to RFC 4627
|
7
|
-
# (http://www.ietf.org/rfc/rfc4627.txt). Starting from version 1.0.0 on there
|
8
|
-
# will be two variants available:
|
9
|
-
#
|
10
|
-
# * A pure ruby variant, that relies on the iconv and the stringscan
|
11
|
-
# extensions, which are both part of the ruby standard library.
|
12
|
-
# * The quite a bit faster C extension variant, which is in parts implemented
|
13
|
-
# in C and comes with its own unicode conversion functions and a parser
|
14
|
-
# generated by the ragel state machine compiler
|
15
|
-
# (http://www.cs.queensu.ca/~thurston/ragel).
|
16
|
-
#
|
17
|
-
# Both variants of the JSON generator escape all non-ASCII an control
|
18
|
-
# characters with \uXXXX escape sequences, and support UTF-16 surrogate pairs
|
19
|
-
# in order to be able to generate the whole range of unicode code points. This
|
20
|
-
# means that generated JSON text is encoded as UTF-8 (because ASCII is a subset
|
21
|
-
# of UTF-8) and at the same time avoids decoding problems for receiving
|
22
|
-
# endpoints, that don't expect UTF-8 encoded texts. On the negative side this
|
23
|
-
# may lead to a bit longer strings than necessarry.
|
24
|
-
#
|
25
|
-
# All strings, that are to be encoded as JSON strings, should be UTF-8 byte
|
26
|
-
# sequences on the Ruby side. To encode raw binary strings, that aren't UTF-8
|
27
|
-
# encoded, please use the to_json_raw_object method of String (which produces
|
28
|
-
# an object, that contains a byte array) and decode the result on the receiving
|
29
|
-
# endpoint.
|
30
|
-
#
|
31
|
-
# == Author
|
32
|
-
#
|
33
|
-
# Florian Frank <mailto:flori@ping.de>
|
34
|
-
#
|
35
|
-
# == License
|
36
|
-
#
|
37
|
-
# This software is distributed under the same license as Ruby itself, see
|
38
|
-
# http://www.ruby-lang.org/en/LICENSE.txt.
|
39
|
-
#
|
40
|
-
# == Download
|
41
|
-
#
|
42
|
-
# The latest version of this library can be downloaded at
|
43
|
-
#
|
44
|
-
# * http://rubyforge.org/frs?group_id=953
|
45
|
-
#
|
46
|
-
# Online Documentation should be located at
|
47
|
-
#
|
48
|
-
# * http://json.rubyforge.org
|
49
|
-
#
|
50
|
-
# == Usage
|
51
|
-
#
|
52
|
-
# To use JSON you can
|
53
|
-
# require 'json'
|
54
|
-
# to load the installed variant (either the extension 'json' or the pure
|
55
|
-
# variant 'json_pure'). If you have installed the extension variant, you can
|
56
|
-
# pick either the extension variant or the pure variant by typing
|
57
|
-
# require 'json/ext'
|
58
|
-
# or
|
59
|
-
# require 'json/pure'
|
60
|
-
#
|
61
|
-
# You can choose to load a set of common additions to ruby core's objects if
|
62
|
-
# you
|
63
|
-
# require 'json/add/core'
|
64
|
-
#
|
65
|
-
# After requiring this you can, e. g., serialise/deserialise Ruby ranges:
|
66
|
-
#
|
67
|
-
# JSON JSON(1..10) # => 1..10
|
68
|
-
#
|
69
|
-
# To find out how to add JSON support to other or your own classes, read the
|
70
|
-
# Examples section below.
|
71
|
-
#
|
72
|
-
# To get the best compatibility to rails' JSON implementation, you can
|
73
|
-
# require 'json/add/rails'
|
74
|
-
#
|
75
|
-
# Both of the additions attempt to require 'json' (like above) first, if it has
|
76
|
-
# not been required yet.
|
77
|
-
#
|
78
|
-
# == Speed Comparisons
|
79
|
-
#
|
80
|
-
# I have created some benchmark results (see the benchmarks subdir of the
|
81
|
-
# package) for the JSON-Parser to estimate the speed up in the C extension:
|
82
|
-
#
|
83
|
-
# JSON::Pure::Parser:: 28.90 calls/second
|
84
|
-
# JSON::Ext::Parser:: 505.50 calls/second
|
85
|
-
#
|
86
|
-
# This is ca. <b>17.5</b> times the speed of the pure Ruby implementation.
|
87
|
-
#
|
88
|
-
# I have benchmarked the JSON-Generator as well. This generates a few more
|
89
|
-
# values, because there are different modes, that also influence the achieved
|
90
|
-
# speed:
|
91
|
-
#
|
92
|
-
# * JSON::Pure::Generator:
|
93
|
-
# generate:: 35.06 calls/second
|
94
|
-
# pretty_generate:: 34.00 calls/second
|
95
|
-
# fast_generate:: 41.06 calls/second
|
96
|
-
#
|
97
|
-
# * JSON::Ext::Generator:
|
98
|
-
# generate:: 492.11 calls/second
|
99
|
-
# pretty_generate:: 348.85 calls/second
|
100
|
-
# fast_generate:: 541.60 calls/second
|
101
|
-
#
|
102
|
-
# * Speedup Ext/Pure:
|
103
|
-
# generate safe:: 14.0 times
|
104
|
-
# generate pretty:: 10.3 times
|
105
|
-
# generate fast:: 13.2 times
|
106
|
-
#
|
107
|
-
# The rails framework includes a generator as well, also it seems to be rather
|
108
|
-
# slow: I measured only 23.87 calls/second which is slower than any of my pure
|
109
|
-
# generator results. Here a comparison of the different speedups with the Rails
|
110
|
-
# measurement as the divisor:
|
111
|
-
#
|
112
|
-
# * Speedup Pure/Rails:
|
113
|
-
# generate safe:: 1.5 times
|
114
|
-
# generate pretty:: 1.4 times
|
115
|
-
# generate fast:: 1.7 times
|
116
|
-
#
|
117
|
-
# * Speedup Ext/Rails:
|
118
|
-
# generate safe:: 20.6 times
|
119
|
-
# generate pretty:: 14.6 times
|
120
|
-
# generate fast:: 22.7 times
|
121
|
-
#
|
122
|
-
# To achieve the fastest JSON text output, you can use the
|
123
|
-
# fast_generate/fast_unparse methods. Beware, that this will disable the
|
124
|
-
# checking for circular Ruby data structures, which may cause JSON to go into
|
125
|
-
# an infinite loop.
|
126
|
-
#
|
127
|
-
# == Examples
|
128
|
-
#
|
129
|
-
# To create a JSON text from a ruby data structure, you
|
130
|
-
# can call JSON.generate (or JSON.unparse) like that:
|
131
|
-
#
|
132
|
-
# json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
|
133
|
-
# # => "[1,2,{\"a\":3.141},false,true,null,\"4..10\"]"
|
134
|
-
#
|
135
|
-
# To create a valid JSON text you have to make sure, that the output is
|
136
|
-
# embedded in either a JSON array [] or a JSON object {}. The easiest way to do
|
137
|
-
# this, is by putting your values in a Ruby Array or Hash instance.
|
138
|
-
#
|
139
|
-
# To get back a ruby data structure from a JSON text, you have to call
|
140
|
-
# JSON.parse on it:
|
141
|
-
#
|
142
|
-
# JSON.parse json
|
143
|
-
# # => [1, 2, {"a"=>3.141}, false, true, nil, "4..10"]
|
144
|
-
#
|
145
|
-
# Note, that the range from the original data structure is a simple
|
146
|
-
# string now. The reason for this is, that JSON doesn't support ranges
|
147
|
-
# or arbitrary classes. In this case the json library falls back to call
|
148
|
-
# Object#to_json, which is the same as #to_s.to_json.
|
149
|
-
#
|
150
|
-
# It's possible to add JSON support serialization to arbitrary classes by
|
151
|
-
# simply implementing a more specialized version of the #to_json method, that
|
152
|
-
# should return a JSON object (a hash converted to JSON with #to_json) like
|
153
|
-
# this (don't forget the *a for all the arguments):
|
154
|
-
#
|
155
|
-
# class Range
|
156
|
-
# def to_json(*a)
|
157
|
-
# {
|
158
|
-
# 'json_class' => self.class.name, # = 'Range'
|
159
|
-
# 'data' => [ first, last, exclude_end? ]
|
160
|
-
# }.to_json(*a)
|
161
|
-
# end
|
162
|
-
# end
|
163
|
-
#
|
164
|
-
# The hash key 'json_class' is the class, that will be asked to deserialise the
|
165
|
-
# JSON representation later. In this case it's 'Range', but any namespace of
|
166
|
-
# the form 'A::B' or '::A::B' will do. All other keys are arbitrary and can be
|
167
|
-
# used to store the necessary data to configure the object to be deserialised.
|
168
|
-
#
|
169
|
-
# If a the key 'json_class' is found in a JSON object, the JSON parser checks
|
170
|
-
# if the given class responds to the json_create class method. If so, it is
|
171
|
-
# called with the JSON object converted to a Ruby hash. So a range can
|
172
|
-
# be deserialised by implementing Range.json_create like this:
|
173
|
-
#
|
174
|
-
# class Range
|
175
|
-
# def self.json_create(o)
|
176
|
-
# new(*o['data'])
|
177
|
-
# end
|
178
|
-
# end
|
179
|
-
#
|
180
|
-
# Now it possible to serialise/deserialise ranges as well:
|
181
|
-
#
|
182
|
-
# json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
|
183
|
-
# # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
|
184
|
-
# JSON.parse json
|
185
|
-
# # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
|
186
|
-
#
|
187
|
-
# JSON.generate always creates the shortest possible string representation of a
|
188
|
-
# ruby data structure in one line. This good for data storage or network
|
189
|
-
# protocols, but not so good for humans to read. Fortunately there's also
|
190
|
-
# JSON.pretty_generate (or JSON.pretty_generate) that creates a more
|
191
|
-
# readable output:
|
192
|
-
#
|
193
|
-
# puts JSON.pretty_generate([1, 2, {"a"=>3.141}, false, true, nil, 4..10])
|
194
|
-
# [
|
195
|
-
# 1,
|
196
|
-
# 2,
|
197
|
-
# {
|
198
|
-
# "a": 3.141
|
199
|
-
# },
|
200
|
-
# false,
|
201
|
-
# true,
|
202
|
-
# null,
|
203
|
-
# {
|
204
|
-
# "json_class": "Range",
|
205
|
-
# "data": [
|
206
|
-
# 4,
|
207
|
-
# 10,
|
208
|
-
# false
|
209
|
-
# ]
|
210
|
-
# }
|
211
|
-
# ]
|
212
|
-
#
|
213
|
-
# There are also the methods Kernel#j for unparse, and Kernel#jj for
|
214
|
-
# pretty_unparse output to the console, that work analogous to Core Ruby's p
|
215
|
-
# and the pp library's pp methods.
|
216
|
-
#
|
217
|
-
# The script tools/server.rb contains a small example if you want to test, how
|
218
|
-
# receiving a JSON object from a webrick server in your browser with the
|
219
|
-
# javasript prototype library (http://www.prototypejs.org) works.
|
220
|
-
#
|
221
|
-
module JSON
|
222
|
-
require 'json/version'
|
223
|
-
|
224
|
-
if VARIANT_BINARY
|
225
|
-
require 'json/ext'
|
226
|
-
else
|
227
|
-
begin
|
228
|
-
require 'json/ext'
|
229
|
-
rescue LoadError
|
230
|
-
require 'json/pure'
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
JSON_LOADED = true
|
235
|
-
end
|