diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-07-17 15:46:49 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-07-17 15:46:49 -0300 |
commit | b3dd9b1bb13a7ea904b74819d265f77a8e54f47f (patch) | |
tree | 24820264b0dac4b046946bfa0e8d09952599169e | |
parent | d8f37bf42a3dc05bf3b6f1c658ee1024116abcf2 (diff) | |
download | lua-b3dd9b1bb13a7ea904b74819d265f77a8e54f47f.tar.gz lua-b3dd9b1bb13a7ea904b74819d265f77a8e54f47f.tar.bz2 lua-b3dd9b1bb13a7ea904b74819d265f77a8e54f47f.zip |
`format' can handle \0 in format string (why not?)
-rw-r--r-- | lstrlib.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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 | ||
581 | static int str_format (lua_State *L) { | 581 | static 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('%')) |