"%0" stands for the whole pattern (in gsub)
This commit is contained in:
10
lstrlib.c
10
lstrlib.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.118 2005/07/05 14:30:38 roberto Exp roberto $
|
** $Id: lstrlib.c,v 1.119 2005/07/12 14:32:08 roberto Exp $
|
||||||
** Standard library for string operations and pattern-matching
|
** Standard library for string operations and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -600,8 +600,12 @@ static void add_s (MatchState *ms, luaL_Buffer *b,
|
|||||||
if (!isdigit(uchar(news[i])))
|
if (!isdigit(uchar(news[i])))
|
||||||
luaL_putchar(b, news[i]);
|
luaL_putchar(b, news[i]);
|
||||||
else {
|
else {
|
||||||
int level = check_capture(ms, news[i]);
|
if (news[i] == '0')
|
||||||
push_onecapture(ms, level);
|
lua_pushlstring(L, s, e - s); /* add whole match */
|
||||||
|
else {
|
||||||
|
int level = check_capture(ms, news[i]);
|
||||||
|
push_onecapture(ms, level);
|
||||||
|
}
|
||||||
luaL_addvalue(b); /* add capture to accumulated result */
|
luaL_addvalue(b); /* add capture to accumulated result */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user