… | |
… | |
10 | #if defined(__BORLANDC__) || defined(_MSC_VER) |
10 | #if defined(__BORLANDC__) || defined(_MSC_VER) |
11 | # define snprintf _snprintf // C compilers have this in stdio.h |
11 | # define snprintf _snprintf // C compilers have this in stdio.h |
12 | #endif |
12 | #endif |
13 | |
13 | |
14 | // some old perls do not have this, try to make it work, no |
14 | // some old perls do not have this, try to make it work, no |
15 | // guarentees, though. |
15 | // guarentees, though. if it breaks, you get to keep the pieces. |
16 | #ifndef UTF8_MAXBYTES |
16 | #ifndef UTF8_MAXBYTES |
17 | # define UTF8_MAXBYTES 13 |
17 | # define UTF8_MAXBYTES 13 |
18 | #endif |
18 | #endif |
19 | |
19 | |
20 | #define F_ASCII 0x00000001UL |
20 | #define F_ASCII 0x00000001UL |
… | |
… | |
55 | |
55 | |
56 | #define expect_false(expr) expect ((expr) != 0, 0) |
56 | #define expect_false(expr) expect ((expr) != 0, 0) |
57 | #define expect_true(expr) expect ((expr) != 0, 1) |
57 | #define expect_true(expr) expect ((expr) != 0, 1) |
58 | |
58 | |
59 | static HV *json_stash; // JSON::XS:: |
59 | static HV *json_stash; // JSON::XS:: |
|
|
60 | static SV *json_true, *json_false; |
60 | |
61 | |
61 | ///////////////////////////////////////////////////////////////////////////// |
62 | ///////////////////////////////////////////////////////////////////////////// |
62 | // utility functions |
63 | // utility functions |
63 | |
64 | |
64 | static UV * |
65 | static UV * |
… | |
… | |
1031 | |
1032 | |
1032 | case 't': |
1033 | case 't': |
1033 | if (dec->end - dec->cur >= 4 && !memcmp (dec->cur, "true", 4)) |
1034 | if (dec->end - dec->cur >= 4 && !memcmp (dec->cur, "true", 4)) |
1034 | { |
1035 | { |
1035 | dec->cur += 4; |
1036 | dec->cur += 4; |
1036 | return newSViv (1); |
1037 | return SvREFCNT_inc (json_true); |
1037 | } |
1038 | } |
1038 | else |
1039 | else |
1039 | ERR ("'true' expected"); |
1040 | ERR ("'true' expected"); |
1040 | |
1041 | |
1041 | break; |
1042 | break; |
1042 | |
1043 | |
1043 | case 'f': |
1044 | case 'f': |
1044 | if (dec->end - dec->cur >= 5 && !memcmp (dec->cur, "false", 5)) |
1045 | if (dec->end - dec->cur >= 5 && !memcmp (dec->cur, "false", 5)) |
1045 | { |
1046 | { |
1046 | dec->cur += 5; |
1047 | dec->cur += 5; |
1047 | return newSViv (0); |
1048 | return SvREFCNT_inc (json_false); |
1048 | } |
1049 | } |
1049 | else |
1050 | else |
1050 | ERR ("'false' expected"); |
1051 | ERR ("'false' expected"); |
1051 | |
1052 | |
1052 | break; |
1053 | break; |
… | |
… | |
1163 | : i >= 'a' && i <= 'f' ? i - 'a' + 10 |
1164 | : i >= 'a' && i <= 'f' ? i - 'a' + 10 |
1164 | : i >= 'A' && i <= 'F' ? i - 'A' + 10 |
1165 | : i >= 'A' && i <= 'F' ? i - 'A' + 10 |
1165 | : -1; |
1166 | : -1; |
1166 | |
1167 | |
1167 | json_stash = gv_stashpv ("JSON::XS", 1); |
1168 | json_stash = gv_stashpv ("JSON::XS", 1); |
|
|
1169 | |
|
|
1170 | json_true = get_sv ("JSON::XS::true" , 1); SvREADONLY_on (json_true ); |
|
|
1171 | json_false = get_sv ("JSON::XS::false", 1); SvREADONLY_on (json_false); |
1168 | } |
1172 | } |
1169 | |
1173 | |
1170 | PROTOTYPES: DISABLE |
1174 | PROTOTYPES: DISABLE |
1171 | |
1175 | |
1172 | SV *new (char *dummy) |
1176 | SV *new (char *dummy) |