aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-07-20 13:30:22 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-07-20 13:30:22 -0300
commit5273477cb9674e6580debfec502abd959d9fefa0 (patch)
treed0aea82e0df9657604c16633eb24165c43d3e62a /lstrlib.c
parentb9db9bd0ef69488c9f3368f571ea53c061151055 (diff)
downloadlua-5273477cb9674e6580debfec502abd959d9fefa0.tar.gz
lua-5273477cb9674e6580debfec502abd959d9fefa0.tar.bz2
lua-5273477cb9674e6580debfec502abd959d9fefa0.zip
in 'lua_number2strx', use the call to 'l_sprintf' to add exponent
to result directly
Diffstat (limited to 'lstrlib.c')
-rw-r--r--lstrlib.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lstrlib.c b/lstrlib.c
index 712e55ee..4d8ff6f9 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.230 2015/06/18 14:26:05 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.231 2015/06/24 18:25:10 roberto Exp roberto $
3** Standard library for string operations and pattern-matching 3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -834,9 +834,8 @@ static int num2straux (char *buff, int sz, lua_Number x) {
834 if (x != x || x == HUGE_VAL || x == -HUGE_VAL) /* inf or NaN? */ 834 if (x != x || x == HUGE_VAL || x == -HUGE_VAL) /* inf or NaN? */
835 return l_sprintf(buff, sz, LUA_NUMBER_FMT, x); /* equal to '%g' */ 835 return l_sprintf(buff, sz, LUA_NUMBER_FMT, x); /* equal to '%g' */
836 else if (x == 0) { /* can be -0... */ 836 else if (x == 0) { /* can be -0... */
837 l_sprintf(buff, sz, LUA_NUMBER_FMT, x); /* create "0" or "-0" */ 837 /* create "0" or "-0" followed by exponent */
838 strcat(buff, "x0p+0"); /* add exponent to that */ 838 return l_sprintf(buff, sz, LUA_NUMBER_FMT "x0p+0", x);
839 return strlen(buff);
840 } 839 }
841 else { 840 else {
842 int e; 841 int e;