Преглед изворни кода

BUG: gsub('a', '(b?)%1*' ...) loops (because the capture is empty).

Roberto Ierusalimschy пре 27 година
родитељ
комит
be6d215f67
2 измењених фајлова са 7 додато и 3 уклоњено
  1. 4 0
      bugs
  2. 3 3
      lstrlib.c

+ 4 - 0
bugs

@@ -33,3 +33,7 @@ Tue Jan 27 17:12:36 EDT 1998
 Wed Jan 28 14:48:12 EDT 1998
 >> tables can become full of "emptys" slots, and keep growing without limits.
 
+** lstrlib.c
+Mon Mar  9 15:26:09 EST 1998
+>> gsub('a', '(b?)%1*' ...) loops (because the capture is empty).
+

+ 3 - 3
lstrlib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lstrlib.c,v 1.9 1998/03/06 16:54:42 roberto Exp roberto $
+** $Id: lstrlib.c,v 1.10 1998/03/06 18:47:42 roberto Exp roberto $
 ** Standard library for strings and pattern-matching
 ** See Copyright Notice in lua.h
 */
@@ -286,7 +286,7 @@ static char *match (char *s, char *p, struct Capture *cap)
       switch (*ep) {
         case '*': {  /* repetition */
           char *res;
-          if (s1 && (res = match(s1, p, cap)))
+          if (s1 && s1>s && (res = match(s1, p, cap)))
             return res;
           p=ep+1; goto init;  /* else return match(s, ep+1, cap); */
         }
@@ -300,7 +300,7 @@ static char *match (char *s, char *p, struct Capture *cap)
           char *res;
           if ((res = match(s, ep+1, cap)) != 0)
             return res;
-          else if (s1) {
+          else if (s1 && s1>s) {
             s = s1;
             goto init;  /* return match(s1, p, cap); */
           }