summaryrefslogtreecommitdiff
path: root/lstrlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-07-31 13:47:34 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-07-31 13:47:34 -0300
commit280f7becb86fccd14122964341b4556754c31b3b (patch)
tree0f5dd877a8c11ea1132cccebc3569be6b5d47642 /lstrlib.c
parentd6ff5d9f46be3db99dd3fec0c12504b7ba1854e1 (diff)
downloadlua-github-280f7becb86fccd14122964341b4556754c31b3b.tar.gz
"%0" stands for the whole pattern (in gsub)
Diffstat (limited to 'lstrlib.c')
-rw-r--r--lstrlib.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lstrlib.c b/lstrlib.c
index 25aa7748..4a99d4d2 100644
--- a/lstrlib.c
+++ b/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
** See Copyright Notice in lua.h
*/
@@ -600,8 +600,12 @@ static void add_s (MatchState *ms, luaL_Buffer *b,
if (!isdigit(uchar(news[i])))
luaL_putchar(b, news[i]);
else {
- int level = check_capture(ms, news[i]);
- push_onecapture(ms, level);
+ if (news[i] == '0')
+ 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 */
}
}