diff --git a/internal/cgen/auxiliary/json.cc b/internal/cgen/auxiliary/json.cc index 643b677f..64326d65 100644 --- a/internal/cgen/auxiliary/json.cc +++ b/internal/cgen/auxiliary/json.cc @@ -40,50 +40,50 @@ const char DecodeJson_NoMatch[] = "wuffs_aux::DecodeJson: no match"; // -------- -#define WUFFS_AUX__DECODE_JSON__GET_THE_NEXT_TOKEN \ - while (tok_buf.meta.ri >= tok_buf.meta.wi) { \ - if (tok_status.repr == nullptr) { \ - goto done; \ - } else if (tok_status.repr == wuffs_base__suspension__short_write) { \ - tok_buf.compact(); \ - } else if (tok_status.repr == wuffs_base__suspension__short_read) { \ - if (!io_error_message.empty()) { \ - ret_error_message = std::move(io_error_message); \ - goto done; \ - } else if (cursor_index != io_buf->meta.ri) { \ - ret_error_message = \ - "wuffs_aux::DecodeJson: internal error: bad cursor_index"; \ - goto done; \ - } else if (io_buf->meta.closed) { \ - ret_error_message = \ - "wuffs_aux::DecodeJson: internal error: io_buf is closed"; \ - goto done; \ - } \ - io_buf->compact(); \ - if (io_buf->meta.wi >= io_buf->data.len) { \ - ret_error_message = \ - "wuffs_aux::DecodeJson: internal error: io_buf is full"; \ - goto done; \ - } \ - cursor_index = io_buf->meta.ri; \ - io_error_message = input.CopyIn(io_buf); \ - } else { \ - ret_error_message = tok_status.message(); \ - goto done; \ - } \ - wuffs_base__slice_u8 work_buf = wuffs_base__empty_slice_u8(); \ - tok_status = dec->decode_tokens(&tok_buf, io_buf, work_buf); \ - } \ - wuffs_base__token token = tok_buf.data.ptr[tok_buf.meta.ri++]; \ - uint64_t token_len = token.length(); \ - if ((io_buf->meta.ri < cursor_index) || \ - ((io_buf->meta.ri - cursor_index) < token_len)) { \ - ret_error_message = \ - "wuffs_aux::DecodeJson: internal error: bad token indexes"; \ - goto done; \ - } \ - uint8_t* token_ptr = io_buf->data.ptr + cursor_index; \ - (void)(token_ptr); \ +#define WUFFS_AUX__DECODE_JSON__GET_THE_NEXT_TOKEN \ + while (tok_buf.meta.ri >= tok_buf.meta.wi) { \ + if (tok_status.repr == nullptr) { \ + goto done; \ + } else if (tok_status.repr == wuffs_base__suspension__short_write) { \ + tok_buf.compact(); \ + } else if (tok_status.repr == wuffs_base__suspension__short_read) { \ + if (!io_error_message.empty()) { \ + ret_error_message = std::move(io_error_message); \ + goto done; \ + } else if (cursor_index != io_buf->meta.ri) { \ + ret_error_message = \ + "wuffs_aux::DecodeJson: internal error: bad cursor_index"; \ + goto done; \ + } else if (io_buf->meta.closed) { \ + ret_error_message = \ + "wuffs_aux::DecodeJson: internal error: io_buf is closed"; \ + goto done; \ + } \ + io_buf->compact(); \ + if (io_buf->meta.wi >= io_buf->data.len) { \ + ret_error_message = \ + "wuffs_aux::DecodeJson: internal error: io_buf is full"; \ + goto done; \ + } \ + cursor_index = io_buf->meta.ri; \ + io_error_message = input.CopyIn(io_buf); \ + } else { \ + ret_error_message = tok_status.message(); \ + goto done; \ + } \ + tok_status = \ + dec->decode_tokens(&tok_buf, io_buf, wuffs_base__empty_slice_u8()); \ + } \ + wuffs_base__token token = tok_buf.data.ptr[tok_buf.meta.ri++]; \ + uint64_t token_len = token.length(); \ + if ((io_buf->meta.ri < cursor_index) || \ + ((io_buf->meta.ri - cursor_index) < token_len)) { \ + ret_error_message = \ + "wuffs_aux::DecodeJson: internal error: bad token indexes"; \ + goto done; \ + } \ + uint8_t* token_ptr = io_buf->data.ptr + cursor_index; \ + (void)(token_ptr); \ cursor_index += static_cast(token_len) // -------- diff --git a/internal/cgen/data/data.go b/internal/cgen/data/data.go index 9ca61f20..e9b14a20 100644 --- a/internal/cgen/data/data.go +++ b/internal/cgen/data/data.go @@ -857,10 +857,10 @@ const AuxImageHh = "" + const AuxJsonCc = "" + "// ---------------- Auxiliary - JSON\n\n#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__AUX__JSON)\n\n#include \n\nnamespace wuffs_aux {\n\nDecodeJsonResult::DecodeJsonResult(std::string&& error_message0,\n uint64_t cursor_position0)\n : error_message(std::move(error_message0)),\n cursor_position(cursor_position0) {}\n\nDecodeJsonCallbacks::~DecodeJsonCallbacks() {}\n\nvoid //\nDecodeJsonCallbacks::Done(DecodeJsonResult& result,\n sync_io::Input& input,\n IOBuffer& buffer) {}\n\nconst char DecodeJson_BadJsonPointer[] =\n \"wuffs_aux::DecodeJson: bad JSON Pointer\";\nconst char DecodeJson_NoMatch[] = \"wuffs_aux::DecodeJson: no match\";\n\n" + "" + - "// --------\n\n#define WUFFS_AUX__DECODE_JSON__GET_THE_NEXT_TOKEN \\\n while (tok_buf.meta.ri >= tok_buf.meta.wi) { \\\n if (tok_status.repr == nullptr) { \\\n goto done; \\\n } else if (tok_status.repr == wuffs_base__suspension__short_write) { \\\n tok_buf.compact(); \\\n } else if (tok_status.repr == wuffs_base__suspension__short_read) { \\\n if (!io_error_message.empty()) { \\\n ret_error_message = std::move(io_error_message); \\\n goto done; \\\n } else if (cursor_index != io_buf->meta.ri) { \\\n ret_error_message = \\\n \"wuffs_aux::DecodeJson: internal error: bad cursor_index\"; \\\n goto done; " + - " \\\n } else if (io_buf->meta.closed) { \\\n ret_error_message = \\\n \"wuffs_aux::DecodeJson: internal error: io_buf is closed\"; \\\n goto done; \\\n } \\\n io_buf->compact(); \\\n if (io_buf->meta.wi >= io_buf->data.len) { \\\n ret_error_message = \\\n \"wuffs_aux::DecodeJson: internal error: io_buf is full\"; \\\n goto done; \\\n } \\\n cursor_index = io_buf->meta.ri; \\\n io_error_message = input.CopyIn(io_buf); \\\n } else" + - " { \\\n ret_error_message = tok_status.message(); \\\n goto done; \\\n } \\\n wuffs_base__slice_u8 work_buf = wuffs_base__empty_slice_u8(); \\\n tok_status = dec->decode_tokens(&tok_buf, io_buf, work_buf); \\\n } \\\n wuffs_base__token token = tok_buf.data.ptr[tok_buf.meta.ri++]; \\\n uint64_t token_len = token.length(); \\\n if ((io_buf->meta.ri < cursor_index) || \\\n ((io_buf->meta.ri - cursor_index) < token_len)) { \\\n ret_error_message = \\\n \"wuffs_aux::DecodeJson: internal error: bad token indexes\"; \\\n goto done; " + - " \\\n } \\\n uint8_t* token_ptr = io_buf->data.ptr + cursor_index; \\\n (void)(token_ptr); \\\n cursor_index += static_cast(token_len)\n\n" + + "// --------\n\n#define WUFFS_AUX__DECODE_JSON__GET_THE_NEXT_TOKEN \\\n while (tok_buf.meta.ri >= tok_buf.meta.wi) { \\\n if (tok_status.repr == nullptr) { \\\n goto done; \\\n } else if (tok_status.repr == wuffs_base__suspension__short_write) { \\\n tok_buf.compact(); \\\n } else if (tok_status.repr == wuffs_base__suspension__short_read) { \\\n if (!io_error_message.empty()) { \\\n ret_error_message = std::move(io_error_message); \\\n goto done; \\\n } else if (cursor_index != io_buf->meta.ri) { \\\n ret_error_message = \\\n \"wuffs_aux::DecodeJson: internal error: bad cursor_index\"; " + + " \\\n goto done; \\\n } else if (io_buf->meta.closed) { \\\n ret_error_message = \\\n \"wuffs_aux::DecodeJson: internal error: io_buf is closed\"; \\\n goto done; \\\n } \\\n io_buf->compact(); \\\n if (io_buf->meta.wi >= io_buf->data.len) { \\\n ret_error_message = \\\n \"wuffs_aux::DecodeJson: internal error: io_buf is full\"; \\\n goto done; \\\n } \\\n cursor_index = io_buf->meta.ri; \\\n i" + + "o_error_message = input.CopyIn(io_buf); \\\n } else { \\\n ret_error_message = tok_status.message(); \\\n goto done; \\\n } \\\n tok_status = \\\n dec->decode_tokens(&tok_buf, io_buf, wuffs_base__empty_slice_u8()); \\\n } \\\n wuffs_base__token token = tok_buf.data.ptr[tok_buf.meta.ri++]; \\\n uint64_t token_len = token.length(); \\\n if ((io_buf->meta.ri < cursor_index) || \\\n ((io_buf->meta.ri - cursor_index) < token_len)) { \\\n ret_error_message = \\\n \"wuffs_au" + + "x::DecodeJson: internal error: bad token indexes\"; \\\n goto done; \\\n } \\\n uint8_t* token_ptr = io_buf->data.ptr + cursor_index; \\\n (void)(token_ptr); \\\n cursor_index += static_cast(token_len)\n\n" + "" + "// --------\n\nnamespace {\n\n// DecodeJson_SplitJsonPointer returns (\"bar\", 8) for (\"/foo/bar/b~1z/qux\", 5,\n// etc). It returns a 0 size_t when s has invalid JSON Pointer syntax.\n//\n// The string returned is unescaped. If calling it again, this time with i=8,\n// the \"b~1z\" substring would be returned as \"b/z\".\nstd::pair //\nDecodeJson_SplitJsonPointer(std::string& s,\n size_t i,\n bool allow_tilde_n_tilde_r_tilde_t) {\n std::string fragment;\n while (i < s.size()) {\n char c = s[i];\n if (c == '/') {\n break;\n } else if (c != '~') {\n fragment.push_back(c);\n i++;\n continue;\n }\n i++;\n if (i >= s.size()) {\n return std::make_pair(std::string(), 0);\n }\n c = s[i];\n if (c == '0') {\n fragment.push_back('~');\n i++;\n continue;\n } else if (c == '1') {\n fragment.push_back('/');\n i++;\n continue;\n } else if (allow_tilde_n_tilde_r_tilde_t) {\n if (c == 'n') {\n " + "fragment.push_back('\\n');\n i++;\n continue;\n } else if (c == 'r') {\n fragment.push_back('\\r');\n i++;\n continue;\n } else if (c == 't') {\n fragment.push_back('\\t');\n i++;\n continue;\n }\n }\n return std::make_pair(std::string(), 0);\n }\n return std::make_pair(std::move(fragment), i);\n}\n\n" + diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index c4f09c5d..bd10abab 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -40053,50 +40053,50 @@ const char DecodeJson_NoMatch[] = "wuffs_aux::DecodeJson: no match"; // -------- -#define WUFFS_AUX__DECODE_JSON__GET_THE_NEXT_TOKEN \ - while (tok_buf.meta.ri >= tok_buf.meta.wi) { \ - if (tok_status.repr == nullptr) { \ - goto done; \ - } else if (tok_status.repr == wuffs_base__suspension__short_write) { \ - tok_buf.compact(); \ - } else if (tok_status.repr == wuffs_base__suspension__short_read) { \ - if (!io_error_message.empty()) { \ - ret_error_message = std::move(io_error_message); \ - goto done; \ - } else if (cursor_index != io_buf->meta.ri) { \ - ret_error_message = \ - "wuffs_aux::DecodeJson: internal error: bad cursor_index"; \ - goto done; \ - } else if (io_buf->meta.closed) { \ - ret_error_message = \ - "wuffs_aux::DecodeJson: internal error: io_buf is closed"; \ - goto done; \ - } \ - io_buf->compact(); \ - if (io_buf->meta.wi >= io_buf->data.len) { \ - ret_error_message = \ - "wuffs_aux::DecodeJson: internal error: io_buf is full"; \ - goto done; \ - } \ - cursor_index = io_buf->meta.ri; \ - io_error_message = input.CopyIn(io_buf); \ - } else { \ - ret_error_message = tok_status.message(); \ - goto done; \ - } \ - wuffs_base__slice_u8 work_buf = wuffs_base__empty_slice_u8(); \ - tok_status = dec->decode_tokens(&tok_buf, io_buf, work_buf); \ - } \ - wuffs_base__token token = tok_buf.data.ptr[tok_buf.meta.ri++]; \ - uint64_t token_len = token.length(); \ - if ((io_buf->meta.ri < cursor_index) || \ - ((io_buf->meta.ri - cursor_index) < token_len)) { \ - ret_error_message = \ - "wuffs_aux::DecodeJson: internal error: bad token indexes"; \ - goto done; \ - } \ - uint8_t* token_ptr = io_buf->data.ptr + cursor_index; \ - (void)(token_ptr); \ +#define WUFFS_AUX__DECODE_JSON__GET_THE_NEXT_TOKEN \ + while (tok_buf.meta.ri >= tok_buf.meta.wi) { \ + if (tok_status.repr == nullptr) { \ + goto done; \ + } else if (tok_status.repr == wuffs_base__suspension__short_write) { \ + tok_buf.compact(); \ + } else if (tok_status.repr == wuffs_base__suspension__short_read) { \ + if (!io_error_message.empty()) { \ + ret_error_message = std::move(io_error_message); \ + goto done; \ + } else if (cursor_index != io_buf->meta.ri) { \ + ret_error_message = \ + "wuffs_aux::DecodeJson: internal error: bad cursor_index"; \ + goto done; \ + } else if (io_buf->meta.closed) { \ + ret_error_message = \ + "wuffs_aux::DecodeJson: internal error: io_buf is closed"; \ + goto done; \ + } \ + io_buf->compact(); \ + if (io_buf->meta.wi >= io_buf->data.len) { \ + ret_error_message = \ + "wuffs_aux::DecodeJson: internal error: io_buf is full"; \ + goto done; \ + } \ + cursor_index = io_buf->meta.ri; \ + io_error_message = input.CopyIn(io_buf); \ + } else { \ + ret_error_message = tok_status.message(); \ + goto done; \ + } \ + tok_status = \ + dec->decode_tokens(&tok_buf, io_buf, wuffs_base__empty_slice_u8()); \ + } \ + wuffs_base__token token = tok_buf.data.ptr[tok_buf.meta.ri++]; \ + uint64_t token_len = token.length(); \ + if ((io_buf->meta.ri < cursor_index) || \ + ((io_buf->meta.ri - cursor_index) < token_len)) { \ + ret_error_message = \ + "wuffs_aux::DecodeJson: internal error: bad token indexes"; \ + goto done; \ + } \ + uint8_t* token_ptr = io_buf->data.ptr + cursor_index; \ + (void)(token_ptr); \ cursor_index += static_cast(token_len) // --------