From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id C15946EC55; Wed, 28 Jul 2021 00:25:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C15946EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627421148; bh=TjaeOnYgeQgDjZFUjWqMqBMkKJDnOp41GIZkppWYsSo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=r+2BIO61/KP02N9Z1WVKW6iyogccDhKLFXa7R7YVPFmsNQ6TkvA9DoFVrKsX99p5S 6nQaqajX9EArJolNRgqx4WuoOGugesI6Hc2pfG8QkLQf4zVwVdBwoKScOxolEDchJG FdFiony9q8+F65D9xQQXZ6BJUH4ByWj/hKjKhovY= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (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 14A766EC5E for ; Wed, 28 Jul 2021 00:24:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 14A766EC5E Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1m8UYl-0005in-5J; Wed, 28 Jul 2021 00:24:19 +0300 To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergos@tarantool.org Date: Tue, 27 Jul 2021 23:24:13 +0200 Message-Id: <9fa0fdfa9ef6075dc14acf40040f7ed0e2f6c7e2.1627420835.git.v.shpilevoy@tarantool.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD941C43E597735A9C3104FC76DFAAAAF7DA068FE323FAC4379182A05F538085040136092ED787CFEE7B32AD8466D69BF2CF6CC91A0CC67100EF04B20FF9B018B4D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7AA1605287C7F04D6EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D19C480A18FAEE108638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8A2F4410A842385960E59589E1D5A63D7117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC3A703B70628EAD7BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B613439FA09F3DCB32089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C7BEA09003D200E083EA03D6D297E546C4879B71DE9FABE449C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFA5DF9383870C0FED699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D344B4608D01B1CB59A8D00340AFE1778710C6830A1BEB9A89F03E3E64E4DAB254925D35489E2057A601D7E09C32AA3244CEB75A35CA628DB9FA45359B19BC6ACD6B4DF56057A86259FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojiF1u9eOpfTRebCcRRhdACg== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DFBCFA3B373C5A2AB92224335D6BDD6F63841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 3/5] decimal: rename decimal_to_string to decimal_str X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" To be consistent with tt_uuid_str() and tt_uuid_to_string(). _str() returns a string. _to_string() copies it into an externally passed buffer. Part of #6259 --- src/box/lua/serialize_lua.c | 2 +- src/lib/core/decimal.c | 2 +- src/lib/core/decimal.h | 2 +- src/lib/core/mp_decimal.c | 4 ++-- src/lua/decimal.c | 2 +- test/unit/decimal.c | 4 ++-- third_party/lua-cjson/lua_cjson.c | 2 +- third_party/lua-yaml/lyaml.cc | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/box/lua/serialize_lua.c b/src/box/lua/serialize_lua.c index 7144305cf..1f791980f 100644 --- a/src/box/lua/serialize_lua.c +++ b/src/box/lua/serialize_lua.c @@ -853,7 +853,7 @@ dump_node(struct lua_dumper *d, struct node *nd, int indent) switch (field->ext_type) { case MP_DECIMAL: nd->mask |= NODE_QUOTE; - str = decimal_to_string(field->decval); + str = decimal_str(field->decval); len = strlen(str); break; case MP_UUID: diff --git a/src/lib/core/decimal.c b/src/lib/core/decimal.c index 118c311d5..4befbda37 100644 --- a/src/lib/core/decimal.c +++ b/src/lib/core/decimal.c @@ -165,7 +165,7 @@ decimal_from_uint64(decimal_t *dec, uint64_t num) } const char * -decimal_to_string(const decimal_t *dec) +decimal_str(const decimal_t *dec) { char *buf = tt_static_buf(); /* No errors are possible. */ diff --git a/src/lib/core/decimal.h b/src/lib/core/decimal.h index 6f8762ed3..d2f2dfbdb 100644 --- a/src/lib/core/decimal.h +++ b/src/lib/core/decimal.h @@ -126,7 +126,7 @@ decimal_from_uint64(decimal_t *dec, uint64_t num); * the decimal representation. */ const char * -decimal_to_string(const decimal_t *dec); +decimal_str(const decimal_t *dec); /** * Convert a given decimal to int64_t diff --git a/src/lib/core/mp_decimal.c b/src/lib/core/mp_decimal.c index ffc2c5773..3610b8af5 100644 --- a/src/lib/core/mp_decimal.c +++ b/src/lib/core/mp_decimal.c @@ -77,7 +77,7 @@ mp_snprint_decimal(char *buf, int size, const char **data, uint32_t len) decimal_t d; if (decimal_unpack(data, len, &d) == NULL) return -1; - return snprintf(buf, size, "%s", decimal_to_string(&d)); + return snprintf(buf, size, "%s", decimal_str(&d)); } int @@ -86,5 +86,5 @@ mp_fprint_decimal(FILE *file, const char **data, uint32_t len) decimal_t d; if (decimal_unpack(data, len, &d) == NULL) return -1; - return fprintf(file, "%s", decimal_to_string(&d)); + return fprintf(file, "%s", decimal_str(&d)); } diff --git a/src/lua/decimal.c b/src/lua/decimal.c index 003680a48..e25b3ec18 100644 --- a/src/lua/decimal.c +++ b/src/lua/decimal.c @@ -376,7 +376,7 @@ ldecimal_tostring(struct lua_State *L) if (lua_gettop(L) < 1) return luaL_error(L, "usage: decimal.tostring(decimal)"); decimal_t *lhs = lua_checkdecimal(L, 1); - lua_pushstring(L, decimal_to_string(lhs)); + lua_pushstring(L, decimal_str(lhs)); return 1; } diff --git a/test/unit/decimal.c b/test/unit/decimal.c index 32694b88a..756c68518 100644 --- a/test/unit/decimal.c +++ b/test/unit/decimal.c @@ -107,7 +107,7 @@ char buf[32]; is(b1, b2, "mp_decode(mp_encode("str") len");\ is(decimal_compare(&dec, &d2), 0, "mp_decode(mp_encode("str")) value");\ is(decimal_scale(&dec), decimal_scale(&d2), "mp_decode(mp_encode("str")) scale");\ - is(strcmp(decimal_to_string(&d2), str), 0, "str(mp_decode(mp_encode("str"))) == "str);\ + is(strcmp(decimal_str(&d2), str), 0, "str(mp_decode(mp_encode("str"))) == "str);\ b2 = buf;\ int8_t type;\ uint32_t l2 = mp_decode_extl(&b2, &type);\ @@ -131,7 +131,7 @@ char buf[32]; is(decimal_compare(&dec, &d2), 0, "decimal_unpack(decimal_pack("str")) value");\ is(decimal_scale(&dec), decimal_scale(&d2), "decimal_unpack(decimal_pack("str")) scale");\ is(decimal_precision(&dec), decimal_precision(&d2), "decimal_unpack(decimal_pack("str")) precision");\ - is(strcmp(decimal_to_string(&d2), str), 0, "str(decimal_unpack(decimal_pack("str")) == "str);\ + is(strcmp(decimal_str(&d2), str), 0, "str(decimal_unpack(decimal_pack("str")) == "str);\ }) #define test_toint(type, num, out_fmt) ({\ diff --git a/third_party/lua-cjson/lua_cjson.c b/third_party/lua-cjson/lua_cjson.c index 5123b9a74..7a326075a 100644 --- a/third_party/lua-cjson/lua_cjson.c +++ b/third_party/lua-cjson/lua_cjson.c @@ -420,7 +420,7 @@ static void json_append_data(lua_State *l, struct luaL_serializer *cfg, switch (field.ext_type) { case MP_DECIMAL: { - const char *str = decimal_to_string(field.decval); + const char *str = decimal_str(field.decval); return json_append_string(cfg, json, str, strlen(str)); } case MP_UUID: diff --git a/third_party/lua-yaml/lyaml.cc b/third_party/lua-yaml/lyaml.cc index 5469e9f4f..2b67dcc6a 100644 --- a/third_party/lua-yaml/lyaml.cc +++ b/third_party/lua-yaml/lyaml.cc @@ -700,7 +700,7 @@ static int dump_node(struct lua_yaml_dumper *dumper) case MP_EXT: switch (field.ext_type) { case MP_DECIMAL: - str = decimal_to_string(field.decval); + str = decimal_str(field.decval); len = strlen(str); break; case MP_UUID: -- 2.24.3 (Apple Git-128)