diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-03-18 16:02:33 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-03-18 16:02:33 -0300 |
commit | a25416a8d580c0dd72ae014f6a83b5205fbd11ce (patch) | |
tree | f6a28a95c093cf0e2d4062e2c577634b0df8bfed | |
parent | 682cce3813381305a8c36f9988af10ec33b43d44 (diff) | |
download | lua-a25416a8d580c0dd72ae014f6a83b5205fbd11ce.tar.gz lua-a25416a8d580c0dd72ae014f6a83b5205fbd11ce.tar.bz2 lua-a25416a8d580c0dd72ae014f6a83b5205fbd11ce.zip |
use of 'luaL_tolstring' for option '%s' in 'string.format'
-rw-r--r-- | lstrlib.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.163 2011/01/26 16:30:02 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.164 2011/02/07 19:15:24 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 | */ |
@@ -889,16 +889,16 @@ static int str_format (lua_State *L) { | |||
889 | } | 889 | } |
890 | case 's': { | 890 | case 's': { |
891 | size_t l; | 891 | size_t l; |
892 | const char *s = luaL_checklstring(L, arg, &l); | 892 | const char *s = luaL_tolstring(L, arg, &l); |
893 | if (!strchr(form, '.') && l >= 100) { | 893 | if (!strchr(form, '.') && l >= 100) { |
894 | /* no precision and string is too long to be formatted; | 894 | /* no precision and string is too long to be formatted; |
895 | keep original string */ | 895 | keep original string */ |
896 | lua_pushvalue(L, arg); | ||
897 | luaL_addvalue(&b); | 896 | luaL_addvalue(&b); |
898 | break; | 897 | break; |
899 | } | 898 | } |
900 | else { | 899 | else { |
901 | nb = sprintf(buff, form, s); | 900 | nb = sprintf(buff, form, s); |
901 | lua_pop(L, 1); /* remove result from 'luaL_tolstring' */ | ||
902 | break; | 902 | break; |
903 | } | 903 | } |
904 | } | 904 | } |