aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-03-18 16:02:33 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-03-18 16:02:33 -0300
commita25416a8d580c0dd72ae014f6a83b5205fbd11ce (patch)
treef6a28a95c093cf0e2d4062e2c577634b0df8bfed
parent682cce3813381305a8c36f9988af10ec33b43d44 (diff)
downloadlua-a25416a8d580c0dd72ae014f6a83b5205fbd11ce.tar.gz
lua-a25416a8d580c0dd72ae014f6a83b5205fbd11ce.tar.bz2
lua-a25416a8d580c0dd72ae014f6a83b5205fbd11ce.zip
use of 'luaL_tolstring' for option '%s' in 'string.format'
-rw-r--r--lstrlib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lstrlib.c b/lstrlib.c
index 2efed9c0..ccecd311 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -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 }