diff options
Diffstat (limited to 'lstrlib.c')
| -rw-r--r-- | lstrlib.c | 12 |
1 files changed, 7 insertions, 5 deletions
| @@ -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); |
