--- JSON-XS/XS.xs 2007/06/12 01:27:02 1.40 +++ JSON-XS/XS.xs 2007/06/23 23:49:29 1.43 @@ -11,6 +11,12 @@ # define snprintf _snprintf // C compilers have this in stdio.h #endif +// some old perls do not have this, try to make it work, no +// guarentees, though. if it breaks, you get to keep the pieces. +#ifndef UTF8_MAXBYTES +# define UTF8_MAXBYTES 13 +#endif + #define F_ASCII 0x00000001UL #define F_LATIN1 0x00000002UL #define F_UTF8 0x00000004UL @@ -51,6 +57,7 @@ #define expect_true(expr) expect ((expr) != 0, 1) static HV *json_stash; // JSON::XS:: +static SV *json_true, *json_false; ///////////////////////////////////////////////////////////////////////////// // utility functions @@ -1027,7 +1034,7 @@ if (dec->end - dec->cur >= 4 && !memcmp (dec->cur, "true", 4)) { dec->cur += 4; - return newSViv (1); + return SvREFCNT_inc (json_true); } else ERR ("'true' expected"); @@ -1038,7 +1045,7 @@ if (dec->end - dec->cur >= 5 && !memcmp (dec->cur, "false", 5)) { dec->cur += 5; - return newSViv (0); + return SvREFCNT_inc (json_false); } else ERR ("'false' expected"); @@ -1159,6 +1166,9 @@ : -1; json_stash = gv_stashpv ("JSON::XS", 1); + + json_true = get_sv ("JSON::XS::true" , 1); SvREADONLY_on (json_true ); + json_false = get_sv ("JSON::XS::false", 1); SvREADONLY_on (json_false); } PROTOTYPES: DISABLE