diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-07-20 13:30:22 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-07-20 13:30:22 -0300 |
commit | 5273477cb9674e6580debfec502abd959d9fefa0 (patch) | |
tree | d0aea82e0df9657604c16633eb24165c43d3e62a /lstrlib.c | |
parent | b9db9bd0ef69488c9f3368f571ea53c061151055 (diff) | |
download | lua-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.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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; |