diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-07-31 13:47:34 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-07-31 13:47:34 -0300 |
commit | 280f7becb86fccd14122964341b4556754c31b3b (patch) | |
tree | 0f5dd877a8c11ea1132cccebc3569be6b5d47642 | |
parent | d6ff5d9f46be3db99dd3fec0c12504b7ba1854e1 (diff) | |
download | lua-280f7becb86fccd14122964341b4556754c31b3b.tar.gz lua-280f7becb86fccd14122964341b4556754c31b3b.tar.bz2 lua-280f7becb86fccd14122964341b4556754c31b3b.zip |
"%0" stands for the whole pattern (in gsub)
-rw-r--r-- | lstrlib.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.118 2005/07/05 14:30:38 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.119 2005/07/12 14:32:08 roberto Exp $ |
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 | */ |
@@ -600,8 +600,12 @@ static void add_s (MatchState *ms, luaL_Buffer *b, | |||
600 | if (!isdigit(uchar(news[i]))) | 600 | if (!isdigit(uchar(news[i]))) |
601 | luaL_putchar(b, news[i]); | 601 | luaL_putchar(b, news[i]); |
602 | else { | 602 | else { |
603 | int level = check_capture(ms, news[i]); | 603 | if (news[i] == '0') |
604 | push_onecapture(ms, level); | 604 | lua_pushlstring(L, s, e - s); /* add whole match */ |
605 | else { | ||
606 | int level = check_capture(ms, news[i]); | ||
607 | push_onecapture(ms, level); | ||
608 | } | ||
605 | luaL_addvalue(b); /* add capture to accumulated result */ | 609 | luaL_addvalue(b); /* add capture to accumulated result */ |
606 | } | 610 | } |
607 | } | 611 | } |