… | |
… | |
372 | // actually, this is mostly due to the stupid so-called |
372 | // actually, this is mostly due to the stupid so-called |
373 | // security workaround added somewhere in 5.8.x. |
373 | // security workaround added somewhere in 5.8.x. |
374 | // that randomises hash orderings |
374 | // that randomises hash orderings |
375 | if (enc->flags & F_CANONICAL) |
375 | if (enc->flags & F_CANONICAL) |
376 | { |
376 | { |
377 | HE *he, *hes [count]; // if your compiler dies here, you need to enable C99 mode |
|
|
378 | int fast = 1; |
377 | int fast = 1; |
|
|
378 | HE *he; |
|
|
379 | #if WIN32 |
|
|
380 | HE **hes = _alloca (count * sizeof (HE)); |
|
|
381 | #else |
|
|
382 | HE *hes [count]; // if your compiler dies here, you need to enable C99 mode |
|
|
383 | #endif |
379 | |
384 | |
380 | i = 0; |
385 | i = 0; |
381 | while ((he = hv_iternext (hv))) |
386 | while ((he = hv_iternext (hv))) |
382 | { |
387 | { |
383 | hes [i++] = he; |
388 | hes [i++] = he; |
… | |
… | |
1009 | dec.maxdepth = DEC_DEPTH (dec.flags); |
1014 | dec.maxdepth = DEC_DEPTH (dec.flags); |
1010 | |
1015 | |
1011 | *dec.end = 0; // this should basically be a nop, too, but make sure it's there |
1016 | *dec.end = 0; // this should basically be a nop, too, but make sure it's there |
1012 | sv = decode_sv (&dec); |
1017 | sv = decode_sv (&dec); |
1013 | |
1018 | |
1014 | if (offset_return || !sv) |
1019 | if (!(offset_return || !sv)) |
1015 | { |
|
|
1016 | offset = dec.flags & F_UTF8 |
|
|
1017 | ? dec.cur - SvPVX (string) |
|
|
1018 | : utf8_distance (dec.cur, SvPVX (string)); |
|
|
1019 | |
|
|
1020 | if (offset_return) |
|
|
1021 | *offset_return = offset; |
|
|
1022 | } |
|
|
1023 | else |
|
|
1024 | { |
1020 | { |
1025 | // check for trailing garbage |
1021 | // check for trailing garbage |
1026 | decode_ws (&dec); |
1022 | decode_ws (&dec); |
1027 | |
1023 | |
1028 | if (*dec.cur) |
1024 | if (*dec.cur) |
1029 | { |
1025 | { |
1030 | dec.err = "garbage after JSON object"; |
1026 | dec.err = "garbage after JSON object"; |
1031 | SvREFCNT_dec (sv); |
1027 | SvREFCNT_dec (sv); |
1032 | sv = 0; |
1028 | sv = 0; |
1033 | } |
1029 | } |
|
|
1030 | } |
|
|
1031 | |
|
|
1032 | if (offset_return || !sv) |
|
|
1033 | { |
|
|
1034 | offset = dec.flags & F_UTF8 |
|
|
1035 | ? dec.cur - SvPVX (string) |
|
|
1036 | : utf8_distance (dec.cur, SvPVX (string)); |
|
|
1037 | |
|
|
1038 | if (offset_return) |
|
|
1039 | *offset_return = offset; |
1034 | } |
1040 | } |
1035 | |
1041 | |
1036 | if (!sv) |
1042 | if (!sv) |
1037 | { |
1043 | { |
1038 | SV *uni = sv_newmortal (); |
1044 | SV *uni = sv_newmortal (); |