Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Alexander Turenko <alexander.turenko@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()
Date: Tue, 19 May 2020 22:48:43 +0200	[thread overview]
Message-ID: <9a00f70a-26dd-1456-7956-d53874743ee0@tarantool.org> (raw)
In-Reply-To: <20200519121422.2ipko477fonb4363@tkn_work_nb>

Hi! Thanks for the review!

On 19/05/2020 14:14, Alexander Turenko wrote:
>>  	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);						\
> 
> The header file still contains this comment:
> 
>  | /**
>  |  * \brief Default MP_EXT serializer into a file. Skips the object,
>  |  * ignores all the other arguments, and writes 'undefined'.
>  |                                         ^^^^^^^^^^^^^^^^^^
>  |  */
>  | int
>  | mp_fprint_ext_default(FILE *file, const char **data, int depth);
> 
> (Same for mp_snprint_ext_default).

Shame on me, I didn't notice it. Changed on the branch in this commit.
See below diff. Also I changed comments in the third commit. See in the
other email.

====================
diff --git a/msgpuck.h b/msgpuck.h
index 5dfbbd9..82e078b 100644
--- a/msgpuck.h
+++ b/msgpuck.h
@@ -970,7 +970,19 @@ mp_vformat(char *data, size_t data_size, const char *format, va_list args);
 
 /**
  * \brief print MsgPack data \a file using JSON-like format.
- * MP_EXT is printed as "undefined"
+ * MP_EXT is printed as a non-standard JSON 'list':
+ *
+ *     (extension: type <type>, len <len>)
+ *
+ * For example:
+ *
+ *     (extension: type 10, len 35)
+ *
+ * Type is the MP_EXT type. Length is of the MP_EXT body, not
+ * counting its header. Since the 'list' and what is in it is not
+ * a standard JSON, printing a MessagePack buffer, having MP_EXT
+ * in it, may lead to an invalid JSON.
+ *
  * \param file - pointer to file (or NULL for stdout)
  * \param data - pointer to buffer containing msgpack object
  * \retval >=0 - the number of bytes printed
@@ -982,6 +994,8 @@ mp_fprint(FILE *file, const char *data);
 
 /**
  * \brief format MsgPack data to \a buf using JSON-like format.
+ * Behaves the same as \sa mp_fprint(), but with snprintf()
+ * semantics.
  * \sa mp_fprint()
  * \param buf - buffer to use
  * \param size - buffer size. This function write at most size bytes

  reply	other threads:[~2020-05-19 20:48 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 ` [Tarantool-patches] [PATCH msgpuck 1.5/2] Provide more details at MP_EXT mp_fprint/snprint() Vladislav Shpilevoy
2020-05-19 12:14   ` Alexander Turenko
2020-05-19 20:48     ` Vladislav Shpilevoy [this message]
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=9a00f70a-26dd-1456-7956-d53874743ee0@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=alexander.turenko@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