From 0011937699d876e871f27abc7c5cc6d1a30be649 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 8 Jan 2019 08:57:37 +0000 Subject: [PATCH] removed unnecessary restoration code in string_to_fpdec() --- lib/read.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/read.c b/lib/read.c index c355150..f4ba8c1 100644 --- a/lib/read.c +++ b/lib/read.c @@ -259,16 +259,18 @@ static hcl_oop_t string_to_fpdec (hcl_t* hcl, hcl_oocs_t* str, const hcl_ioloc_t } HCL_ASSERT (hcl, scale > 0); - /*if (scale > 0)*/ HCL_MEMMOVE (&str->ptr[pos], &str->ptr[pos + 1], scale * HCL_SIZEOF(str->ptr[0])); + /*if (scale > 0)*/ HCL_MEMMOVE (&str->ptr[pos], &str->ptr[pos + 1], scale * HCL_SIZEOF(str->ptr[0])); /* remove the decimal point */ break; } } + /* if no decimal point is included or no digit after the point , you must not call this function */ + HCL_ASSERT (hcl, scale > 0); + v = hcl_strtoint(hcl, str->ptr, str->len - 1, 10); - /*if (scale > 0)*/ HCL_MEMMOVE (&str->ptr[pos + 1], &str->ptr[pos], scale * HCL_SIZEOF(str->ptr[0])); if (!v) return HCL_NULL; - return hcl_makefpdec (hcl, v, scale); + return hcl_makefpdec(hcl, v, scale); } static HCL_INLINE int is_spacechar (hcl_ooci_t c)