commit 24434b59f79975bcca9a15e7bc55d5cab7984bbe
parent beb2aa5a46d0f0a8464f4045b1cfb790e97f08c7
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 2 Jan 2004 09:53:52 -0200
'%' must be '%%' to avoid formatting problems
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lstrlib.c b/lstrlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstrlib.c,v 1.99 2003/05/14 14:35:54 roberto Exp roberto $
+** $Id: lstrlib.c,v 1.100 2003/10/07 20:13:41 roberto Exp roberto $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -200,7 +200,7 @@ static const char *luaI_classend (MatchState *ms, const char *p) {
switch (*p++) {
case ESC: {
if (*p == '\0')
- luaL_error(ms->L, "malformed pattern (ends with `%')");
+ luaL_error(ms->L, "malformed pattern (ends with `%%')");
return p+1;
}
case '[': {
@@ -682,7 +682,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt,
luaL_error(L, "invalid format (width or precision too long)");
if (p-strfrmt+2 > MAX_FORMAT) /* +2 to include `%' and the specifier */
luaL_error(L, "invalid format (too long)");
- form[0] = '%';
+ form[0] = ESC;
strncpy(form+1, strfrmt, p-strfrmt+1);
form[p-strfrmt+2] = 0;
return p;
@@ -697,9 +697,9 @@ static int str_format (lua_State *L) {
luaL_Buffer b;
luaL_buffinit(L, &b);
while (strfrmt < strfrmt_end) {
- if (*strfrmt != '%')
+ if (*strfrmt != ESC)
luaL_putchar(&b, *strfrmt++);
- else if (*++strfrmt == '%')
+ else if (*++strfrmt == ESC)
luaL_putchar(&b, *strfrmt++); /* %% */
else { /* format item */
char form[MAX_FORMAT]; /* to store the format (`%...') */