… | |
… | |
1009 | dec.maxdepth = DEC_DEPTH (dec.flags); |
1009 | dec.maxdepth = DEC_DEPTH (dec.flags); |
1010 | |
1010 | |
1011 | *dec.end = 0; // this should basically be a nop, too, but make sure it's there |
1011 | *dec.end = 0; // this should basically be a nop, too, but make sure it's there |
1012 | sv = decode_sv (&dec); |
1012 | sv = decode_sv (&dec); |
1013 | |
1013 | |
1014 | if (offset_return || !sv) |
1014 | 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 | { |
1015 | { |
1025 | // check for trailing garbage |
1016 | // check for trailing garbage |
1026 | decode_ws (&dec); |
1017 | decode_ws (&dec); |
1027 | |
1018 | |
1028 | if (*dec.cur) |
1019 | if (*dec.cur) |
1029 | { |
1020 | { |
1030 | dec.err = "garbage after JSON object"; |
1021 | dec.err = "garbage after JSON object"; |
1031 | SvREFCNT_dec (sv); |
1022 | SvREFCNT_dec (sv); |
1032 | sv = 0; |
1023 | sv = 0; |
1033 | } |
1024 | } |
|
|
1025 | } |
|
|
1026 | |
|
|
1027 | if (offset_return || !sv) |
|
|
1028 | { |
|
|
1029 | offset = dec.flags & F_UTF8 |
|
|
1030 | ? dec.cur - SvPVX (string) |
|
|
1031 | : utf8_distance (dec.cur, SvPVX (string)); |
|
|
1032 | |
|
|
1033 | if (offset_return) |
|
|
1034 | *offset_return = offset; |
1034 | } |
1035 | } |
1035 | |
1036 | |
1036 | if (!sv) |
1037 | if (!sv) |
1037 | { |
1038 | { |
1038 | SV *uni = sv_newmortal (); |
1039 | SV *uni = sv_newmortal (); |