Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com,
	sergos@tarantool.org
Subject: [Tarantool-patches] [PATCH 3/5] decimal: rename decimal_to_string to decimal_str
Date: Tue, 27 Jul 2021 23:24:13 +0200
Message-ID: <9fa0fdfa9ef6075dc14acf40040f7ed0e2f6c7e2.1627420835.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1627420835.git.v.shpilevoy@tarantool.org>

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)


  parent reply	other threads:[~2021-07-27 21:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27 21:24 [Tarantool-patches] [PATCH 0/5] Static buf in Lua, part 3 Vladislav Shpilevoy via Tarantool-patches
2021-07-27 21:24 ` [Tarantool-patches] [PATCH 1/5] uuid: introduce and use luaL_pushuuidstr() Vladislav Shpilevoy via Tarantool-patches
2021-07-29 11:30   ` Sergey Ostanevich via Tarantool-patches
2021-07-27 21:24 ` [Tarantool-patches] [PATCH 2/5] info: use luaL_pushuuidstr() for box.info uuids Vladislav Shpilevoy via Tarantool-patches
2021-07-29 11:38   ` Sergey Ostanevich via Tarantool-patches
2021-08-01 15:03     ` Vladislav Shpilevoy via Tarantool-patches
2021-08-01 17:01       ` Sergey Ostanevich via Tarantool-patches
2021-07-27 21:24 ` Vladislav Shpilevoy via Tarantool-patches [this message]
2021-07-29 11:41   ` [Tarantool-patches] [PATCH 3/5] decimal: rename decimal_to_string to decimal_str Sergey Ostanevich via Tarantool-patches
2021-08-01 15:03     ` Vladislav Shpilevoy via Tarantool-patches
2021-08-01 17:01       ` Sergey Ostanevich via Tarantool-patches
2021-07-27 21:24 ` [Tarantool-patches] [PATCH 4/5] decimal: introduce decimal_to_string Vladislav Shpilevoy via Tarantool-patches
2021-07-29 11:52   ` Sergey Ostanevich via Tarantool-patches
2021-08-01 15:04     ` Vladislav Shpilevoy via Tarantool-patches
2021-08-01 17:06       ` Sergey Ostanevich via Tarantool-patches
2021-07-27 21:24 ` [Tarantool-patches] [PATCH 5/5] decimal: introduce and use lua_pushdecimalstr() Vladislav Shpilevoy via Tarantool-patches
2021-07-29 12:28   ` Sergey Ostanevich via Tarantool-patches
2021-08-01 15:04     ` Vladislav Shpilevoy via Tarantool-patches
2021-07-27 21:39 ` [Tarantool-patches] [PATCH 0/5] Static buf in Lua, part 3 Cyrill Gorcunov via Tarantool-patches
2021-08-02 19:45 ` Vladislav Shpilevoy via Tarantool-patches

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=9fa0fdfa9ef6075dc14acf40040f7ed0e2f6c7e2.1627420835.git.v.shpilevoy@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=sergos@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    /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

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git