aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-07-17 15:46:49 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-07-17 15:46:49 -0300
commitb3dd9b1bb13a7ea904b74819d265f77a8e54f47f (patch)
tree24820264b0dac4b046946bfa0e8d09952599169e
parentd8f37bf42a3dc05bf3b6f1c658ee1024116abcf2 (diff)
downloadlua-b3dd9b1bb13a7ea904b74819d265f77a8e54f47f.tar.gz
lua-b3dd9b1bb13a7ea904b74819d265f77a8e54f47f.tar.bz2
lua-b3dd9b1bb13a7ea904b74819d265f77a8e54f47f.zip
`format' can handle \0 in format string (why not?)
-rw-r--r--lstrlib.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lstrlib.c b/lstrlib.c
index a1f1acf7..5462222a 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.67 2001/03/06 20:09:38 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.68 2001/03/26 14:31:49 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*/
@@ -580,10 +580,12 @@ static const l_char *scanformat (lua_State *L, const l_char *strfrmt,
580 580
581static int str_format (lua_State *L) { 581static int str_format (lua_State *L) {
582 int arg = 1; 582 int arg = 1;
583 const l_char *strfrmt = luaL_check_string(L, arg); 583 size_t sfl;
584 const l_char *strfrmt = luaL_check_lstr(L, arg, &sfl);
585 const l_char *strfrmt_end = strfrmt+sfl;
584 luaL_Buffer b; 586 luaL_Buffer b;
585 luaL_buffinit(L, &b); 587 luaL_buffinit(L, &b);
586 while (*strfrmt) { 588 while (strfrmt < strfrmt_end) {
587 if (*strfrmt != l_c('%')) 589 if (*strfrmt != l_c('%'))
588 luaL_putchar(&b, *strfrmt++); 590 luaL_putchar(&b, *strfrmt++);
589 else if (*++strfrmt == l_c('%')) 591 else if (*++strfrmt == l_c('%'))