From b3dd9b1bb13a7ea904b74819d265f77a8e54f47f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 17 Jul 2001 15:46:49 -0300 Subject: [PATCH] `format' can handle \0 in format string (why not?) --- lstrlib.c | 8 +++++--- 1 file 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 @@ /* -** $Id: lstrlib.c,v 1.67 2001/03/06 20:09:38 roberto Exp roberto $ +** $Id: lstrlib.c,v 1.68 2001/03/26 14:31:49 roberto Exp roberto $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -580,10 +580,12 @@ static const l_char *scanformat (lua_State *L, const l_char *strfrmt, static int str_format (lua_State *L) { int arg = 1; - const l_char *strfrmt = luaL_check_string(L, arg); + size_t sfl; + const l_char *strfrmt = luaL_check_lstr(L, arg, &sfl); + const l_char *strfrmt_end = strfrmt+sfl; luaL_Buffer b; luaL_buffinit(L, &b); - while (*strfrmt) { + while (strfrmt < strfrmt_end) { if (*strfrmt != l_c('%')) luaL_putchar(&b, *strfrmt++); else if (*++strfrmt == l_c('%'))