aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-04-30 11:12:05 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-04-30 11:12:05 -0300
commitcc0f635ef70c0a3f9e5359dee80978111b529864 (patch)
tree9e2cf4e3af3a80b17bee40f578caf89b8e22f350 /lstrlib.c
parente64dbc390a25dac45b62d33833c202d1fa9c0b7e (diff)
downloadlua-cc0f635ef70c0a3f9e5359dee80978111b529864.tar.gz
lua-cc0f635ef70c0a3f9e5359dee80978111b529864.tar.bz2
lua-cc0f635ef70c0a3f9e5359dee80978111b529864.zip
'$' at end of pattern was matching regular '$', too.
Diffstat (limited to 'lstrlib.c')
-rw-r--r--lstrlib.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lstrlib.c b/lstrlib.c
index ac0b4f24..977861e4 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.27 1999/02/25 19:13:56 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.28 1999/02/26 15:49:53 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*/
@@ -285,10 +285,12 @@ static char *match (char *s, char *p, struct Capture *cap) {
285 cap->capture[l].len = -1; /* undo capture */ 285 cap->capture[l].len = -1; /* undo capture */
286 return res; 286 return res;
287 } 287 }
288 case '\0': case '$': /* (possibly) end of pattern */ 288 case '\0': /* end of pattern */
289 if (*p == 0 || (*(p+1) == 0 && s == cap->src_end)) 289 return s; /* match succeeded */
290 return s; 290 case '$':
291 /* else go through */ 291 if (*(p+1) == '\0') /* is the '$' the last char in pattern? */
292 return (s == cap->src_end) ? s : NULL; /* check end of string */
293 /* else is a regular '$'; go through */
292 default: { /* it is a pattern item */ 294 default: { /* it is a pattern item */
293 char *ep; /* will point to what is next */ 295 char *ep; /* will point to what is next */
294 char *s1 = matchitem(s, p, cap, &ep); 296 char *s1 = matchitem(s, p, cap, &ep);