lua

A copy of the Lua development repository
Log | Files | Refs | README

commit be6d215f674f3d148d3f80a0553e8b2aa6da51d7
parent e74817f8aa1f81224aeed40f8aff8d8f75fba9d9
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Mon,  9 Mar 1998 15:27:47 -0300

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

Diffstat:
Mbugs | 4++++
Mlstrlib.c | 6+++---
2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/bugs b/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). + diff --git a/lstrlib.c b/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); */ }