diff options
Diffstat (limited to 'lstrlib.c')
-rw-r--r-- | lstrlib.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.99 2003/05/14 14:35:54 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.100 2003/10/07 20:13:41 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 | */ |
@@ -200,7 +200,7 @@ static const char *luaI_classend (MatchState *ms, const char *p) { | |||
200 | switch (*p++) { | 200 | switch (*p++) { |
201 | case ESC: { | 201 | case ESC: { |
202 | if (*p == '\0') | 202 | if (*p == '\0') |
203 | luaL_error(ms->L, "malformed pattern (ends with `%')"); | 203 | luaL_error(ms->L, "malformed pattern (ends with `%%')"); |
204 | return p+1; | 204 | return p+1; |
205 | } | 205 | } |
206 | case '[': { | 206 | case '[': { |
@@ -682,7 +682,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt, | |||
682 | luaL_error(L, "invalid format (width or precision too long)"); | 682 | luaL_error(L, "invalid format (width or precision too long)"); |
683 | if (p-strfrmt+2 > MAX_FORMAT) /* +2 to include `%' and the specifier */ | 683 | if (p-strfrmt+2 > MAX_FORMAT) /* +2 to include `%' and the specifier */ |
684 | luaL_error(L, "invalid format (too long)"); | 684 | luaL_error(L, "invalid format (too long)"); |
685 | form[0] = '%'; | 685 | form[0] = ESC; |
686 | strncpy(form+1, strfrmt, p-strfrmt+1); | 686 | strncpy(form+1, strfrmt, p-strfrmt+1); |
687 | form[p-strfrmt+2] = 0; | 687 | form[p-strfrmt+2] = 0; |
688 | return p; | 688 | return p; |
@@ -697,9 +697,9 @@ static int str_format (lua_State *L) { | |||
697 | luaL_Buffer b; | 697 | luaL_Buffer b; |
698 | luaL_buffinit(L, &b); | 698 | luaL_buffinit(L, &b); |
699 | while (strfrmt < strfrmt_end) { | 699 | while (strfrmt < strfrmt_end) { |
700 | if (*strfrmt != '%') | 700 | if (*strfrmt != ESC) |
701 | luaL_putchar(&b, *strfrmt++); | 701 | luaL_putchar(&b, *strfrmt++); |
702 | else if (*++strfrmt == '%') | 702 | else if (*++strfrmt == ESC) |
703 | luaL_putchar(&b, *strfrmt++); /* %% */ | 703 | luaL_putchar(&b, *strfrmt++); /* %% */ |
704 | else { /* format item */ | 704 | else { /* format item */ |
705 | char form[MAX_FORMAT]; /* to store the format (`%...') */ | 705 | char form[MAX_FORMAT]; /* to store the format (`%...') */ |