… | |
… | |
700 | U32 depth; // recursion depth |
700 | U32 depth; // recursion depth |
701 | U32 maxdepth; // recursion depth limit |
701 | U32 maxdepth; // recursion depth limit |
702 | } dec_t; |
702 | } dec_t; |
703 | |
703 | |
704 | inline void |
704 | inline void |
|
|
705 | decode_comment (dec_t *dec) |
|
|
706 | { |
|
|
707 | // only '#'-style comments allowed a.t.m. |
|
|
708 | |
|
|
709 | while (*dec->cur && *dec->cur != 0x0a && *dec->cur != 0x0d) |
|
|
710 | ++dec->cur; |
|
|
711 | } |
|
|
712 | |
|
|
713 | inline void |
705 | decode_ws (dec_t *dec) |
714 | decode_ws (dec_t *dec) |
706 | { |
715 | { |
707 | for (;;) |
716 | for (;;) |
708 | { |
717 | { |
709 | char ch = *dec->cur; |
718 | char ch = *dec->cur; |
710 | |
719 | |
711 | if (ch > 0x20 |
720 | if (ch > 0x20) |
|
|
721 | { |
|
|
722 | if (expect_false (ch == '#')) |
|
|
723 | { |
|
|
724 | if (dec->json.flags & F_RELAXED) |
|
|
725 | decode_comment (dec); |
|
|
726 | else |
|
|
727 | break; |
|
|
728 | } |
|
|
729 | else |
|
|
730 | break; |
|
|
731 | } |
712 | || (ch != 0x20 && ch != 0x0a && ch != 0x0d && ch != 0x09)) |
732 | else if (ch != 0x20 && ch != 0x0a && ch != 0x0d && ch != 0x09) |
713 | break; |
733 | break; // parse error, but let higher level handle it, gives better error messages |
714 | |
|
|
715 | if (ch == '#' && dec->json.flags & F_RELAXED) |
|
|
716 | ++dec->cur; |
|
|
717 | |
734 | |
718 | ++dec->cur; |
735 | ++dec->cur; |
719 | } |
736 | } |
720 | } |
737 | } |
721 | |
738 | |