aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-03-09 15:28:08 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-03-09 15:28:08 -0300
commitbe6d215f674f3d148d3f80a0553e8b2aa6da51d7 (patch)
tree6ff346eb5c1f2858f4cf6d41a79289bfbf53b545
parente74817f8aa1f81224aeed40f8aff8d8f75fba9d9 (diff)
downloadlua-be6d215f674f3d148d3f80a0553e8b2aa6da51d7.tar.gz
lua-be6d215f674f3d148d3f80a0553e8b2aa6da51d7.tar.bz2
lua-be6d215f674f3d148d3f80a0553e8b2aa6da51d7.zip
BUG: gsub('a', '(b?)%1*' ...) loops (because the capture is empty).
-rw-r--r--bugs4
-rw-r--r--lstrlib.c6
2 files changed, 7 insertions, 3 deletions
diff --git a/bugs b/bugs
index df6a0ef9..b1bee0fc 100644
--- a/bugs
+++ b/bugs
@@ -33,3 +33,7 @@ Tue Jan 27 17:12:36 EDT 1998
33Wed Jan 28 14:48:12 EDT 1998 33Wed Jan 28 14:48:12 EDT 1998
34>> tables can become full of "emptys" slots, and keep growing without limits. 34>> tables can become full of "emptys" slots, and keep growing without limits.
35 35
36** lstrlib.c
37Mon Mar 9 15:26:09 EST 1998
38>> gsub('a', '(b?)%1*' ...) loops (because the capture is empty).
39
diff --git a/lstrlib.c b/lstrlib.c
index 5f88656c..13d87ac6 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.9 1998/03/06 16:54:42 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.10 1998/03/06 18:47:42 roberto Exp roberto $
3** Standard library for strings and pattern-matching 3** Standard library for strings and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -286,7 +286,7 @@ static char *match (char *s, char *p, struct Capture *cap)
286 switch (*ep) { 286 switch (*ep) {
287 case '*': { /* repetition */ 287 case '*': { /* repetition */
288 char *res; 288 char *res;
289 if (s1 && (res = match(s1, p, cap))) 289 if (s1 && s1>s && (res = match(s1, p, cap)))
290 return res; 290 return res;
291 p=ep+1; goto init; /* else return match(s, ep+1, cap); */ 291 p=ep+1; goto init; /* else return match(s, ep+1, cap); */
292 } 292 }
@@ -300,7 +300,7 @@ static char *match (char *s, char *p, struct Capture *cap)
300 char *res; 300 char *res;
301 if ((res = match(s, ep+1, cap)) != 0) 301 if ((res = match(s, ep+1, cap)) != 0)
302 return res; 302 return res;
303 else if (s1) { 303 else if (s1 && s1>s) {
304 s = s1; 304 s = s1;
305 goto init; /* return match(s1, p, cap); */ 305 goto init; /* return match(s1, p, cap); */
306 } 306 }