From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp16.mail.ru (smtp16.mail.ru [94.100.176.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 85D21469711 for ; Tue, 19 May 2020 23:48:45 +0300 (MSK) References: <1c487bc6-4209-d4b4-6d69-1269037121ba@tarantool.org> <20200519121422.2ipko477fonb4363@tkn_work_nb> From: Vladislav Shpilevoy Message-ID: <9a00f70a-26dd-1456-7956-d53874743ee0@tarantool.org> Date: Tue, 19 May 2020 22:48:43 +0200 MIME-Version: 1.0 In-Reply-To: <20200519121422.2ipko477fonb4363@tkn_work_nb> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH msgpuck 1.5/2] Provide more details at MP_EXT mp_fprint/snprint() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Turenko Cc: tarantool-patches@dev.tarantool.org 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 , 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