diff options
Diffstat (limited to 'lstrlib.c')
| -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('%')) |
