From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org, korablev@tarantool.org Subject: [Tarantool-patches] [PATCH msgpuck 1.5/2] Provide more details at MP_EXT mp_fprint/snprint() Date: Thu, 14 May 2020 23:26:01 +0200 [thread overview] Message-ID: <1c487bc6-4209-d4b4-6d69-1269037121ba@tarantool.org> (raw) In-Reply-To: <cover.1589240001.git.v.shpilevoy@tarantool.org> It was printed as 'undefined'. Which is not really helpful. The very least what can be done - print type and size. --- msgpuck.c | 9 +++++++-- test/msgpuck.c | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/msgpuck.c b/msgpuck.c index 7ea86e8..bdaa4ae 100644 --- a/msgpuck.c +++ b/msgpuck.c @@ -316,9 +316,14 @@ mp_format(char *data, size_t data_size, const char *format, ...) PRINTF("%lg", mp_decode_double(data)); \ break; \ case MP_EXT: \ - mp_next(data); \ - PRINTF("undefined"); \ + { \ + int8_t type; \ + uint32_t len; \ + mp_decode_ext(data, &type, &len); \ + PRINTF("(extension: type %d, len %u)", (int)type, \ + (unsigned)len); \ break; \ + } \ default: \ mp_unreachable(); \ return -1; \ diff --git a/test/msgpuck.c b/test/msgpuck.c index ecc2b26..eaf50e0 100644 --- a/test/msgpuck.c +++ b/test/msgpuck.c @@ -883,8 +883,10 @@ test_mp_print() d = mp_encode_double(d, 3.14); d = mp_encode_uint(d, 100); d = mp_encode_uint(d, 500); - /* let's pack zero-length ext */ - d = mp_encode_extl(d, 0, 0); + /* MP_EXT with type 123 and of size 3 bytes. */ + d = mp_encode_extl(d, 123, 3); + memcpy(d, "str", 3); + d += 3; char bin[] = "\x12test\x34\b\t\n\"bla\\-bla\"\f\r"; d = mp_encode_bin(d, bin, sizeof(bin)); d = mp_encode_map(d, 0); @@ -893,7 +895,8 @@ test_mp_print() const char *expected = "[-5, 42, \"kill bill\", [], " "{\"bool true\": true, \"bool false\": false, \"null\": null, " - "\"float\": 3.14, \"double\": 3.14, 100: 500}, undefined, " + "\"float\": 3.14, \"double\": 3.14, 100: 500}, " + "(extension: type 123, len 3), " "\"\\u0012test4\\b\\t\\n\\\"bla\\\\-bla\\\"\\f\\r\\u0000\", {}]"; int esize = strlen(expected); -- 2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-05-14 21:26 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-11 23:46 [Tarantool-patches] [PATCH msgpuck 0/2] MP_EXT virtual serializer Vladislav Shpilevoy 2020-05-11 23:46 ` [Tarantool-patches] [PATCH msgpuck 1/2] Return recursion to mp_snprint() and mp_fprint() Vladislav Shpilevoy 2020-05-11 23:46 ` [Tarantool-patches] [PATCH msgpuck 2/2] Make MP_EXT mp_snprint() and mp_fprint() customizable Vladislav Shpilevoy 2020-05-19 20:48 ` Vladislav Shpilevoy 2020-05-14 21:26 ` Vladislav Shpilevoy [this message] 2020-05-19 12:14 ` [Tarantool-patches] [PATCH msgpuck 1.5/2] Provide more details at MP_EXT mp_fprint/snprint() Alexander Turenko 2020-05-19 20:48 ` Vladislav Shpilevoy 2020-05-18 15:18 ` [Tarantool-patches] [PATCH msgpuck 0/2] MP_EXT virtual serializer Serge Petrenko 2020-05-19 9:10 ` Cyrill Gorcunov 2020-05-21 18:23 ` Alexander Turenko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1c487bc6-4209-d4b4-6d69-1269037121ba@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=gorcunov@gmail.com \ --cc=korablev@tarantool.org \ --cc=sergepetrenko@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH msgpuck 1.5/2] Provide more details at MP_EXT mp_fprint/snprint()' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox