diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-04-30 11:12:05 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-04-30 11:12:05 -0300 |
commit | cc0f635ef70c0a3f9e5359dee80978111b529864 (patch) | |
tree | 9e2cf4e3af3a80b17bee40f578caf89b8e22f350 | |
parent | e64dbc390a25dac45b62d33833c202d1fa9c0b7e (diff) | |
download | lua-cc0f635ef70c0a3f9e5359dee80978111b529864.tar.gz lua-cc0f635ef70c0a3f9e5359dee80978111b529864.tar.bz2 lua-cc0f635ef70c0a3f9e5359dee80978111b529864.zip |
'$' at end of pattern was matching regular '$', too.
-rw-r--r-- | bugs | 19 | ||||
-rw-r--r-- | lstrlib.c | 12 |
2 files changed, 24 insertions, 7 deletions
@@ -4,6 +4,7 @@ Tue Dec 2 10:45:48 EDT 1997 | |||
4 | >> started only in the 2nd line of a function. | 4 | >> started only in the 2nd line of a function. |
5 | 5 | ||
6 | 6 | ||
7 | |||
7 | --- Version 3.1 alpha | 8 | --- Version 3.1 alpha |
8 | 9 | ||
9 | ** lua.c | 10 | ** lua.c |
@@ -13,7 +14,7 @@ Thu Jan 15 14:34:58 EDT 1998 | |||
13 | ** lbuiltin.c / lobject.h | 14 | ** lbuiltin.c / lobject.h |
14 | Thu Jan 15 14:34:58 EDT 1998 | 15 | Thu Jan 15 14:34:58 EDT 1998 |
15 | >> MAX_WORD may be bigger than MAX_INT | 16 | >> MAX_WORD may be bigger than MAX_INT |
16 | 17 | (by lhf) | |
17 | 18 | ||
18 | ** llex.c | 19 | ** llex.c |
19 | Mon Jan 19 18:17:18 EDT 1998 | 20 | Mon Jan 19 18:17:18 EDT 1998 |
@@ -42,6 +43,7 @@ Mon May 18 19:20:00 EST 1998 | |||
42 | >> arguments for "format" 'x', 'X', 'o' and 'u' must be unsigned int. | 43 | >> arguments for "format" 'x', 'X', 'o' and 'u' must be unsigned int. |
43 | 44 | ||
44 | 45 | ||
46 | |||
45 | --- Version 3.1 | 47 | --- Version 3.1 |
46 | 48 | ||
47 | ** liolib.c / lauxlib.c | 49 | ** liolib.c / lauxlib.c |
@@ -52,11 +54,13 @@ of view) when functions have upvalues. | |||
52 | ** lstrlib.c | 54 | ** lstrlib.c |
53 | Tue Nov 10 17:29:36 EDT 1998 | 55 | Tue Nov 10 17:29:36 EDT 1998 |
54 | >> gsub/strfind do not check whether captures are properly finished. | 56 | >> gsub/strfind do not check whether captures are properly finished. |
57 | (by roberto/tomas) | ||
55 | 58 | ||
56 | ** lbuiltin.c | 59 | ** lbuiltin.c |
57 | Fri Dec 18 11:22:55 EDT 1998 | 60 | Fri Dec 18 11:22:55 EDT 1998 |
58 | >> "tonumber" goes crazy with negative numbers in other bases (not 10), | 61 | >> "tonumber" goes crazy with negative numbers in other bases (not 10), |
59 | because "strtol" returns long, not unsigned long. | 62 | because "strtol" returns long, not unsigned long. |
63 | (by Visual C++) | ||
60 | 64 | ||
61 | ** lstrlib.c | 65 | ** lstrlib.c |
62 | Mon Jan 4 10:41:40 EDT 1999 | 66 | Mon Jan 4 10:41:40 EDT 1999 |
@@ -70,8 +74,19 @@ lua_isnumber can modify it. | |||
70 | ** lstrlib.c | 74 | ** lstrlib.c |
71 | Thu Feb 4 17:08:50 EDT 1999 | 75 | Thu Feb 4 17:08:50 EDT 1999 |
72 | >> format "%s" may break limit of "sprintf" on some machines. | 76 | >> format "%s" may break limit of "sprintf" on some machines. |
73 | 77 | (by Marcelo Sales) | |
74 | 78 | ||
75 | ** lzio.c | 79 | ** lzio.c |
76 | Thu Mar 4 11:49:37 EST 1999 | 80 | Thu Mar 4 11:49:37 EST 1999 |
77 | >> file stream cannot call fread after EOF. | 81 | >> file stream cannot call fread after EOF. |
82 | (by lhf) | ||
83 | |||
84 | |||
85 | |||
86 | --- Version 3.2 (beta) | ||
87 | |||
88 | ** lstrlib.c | ||
89 | Fri Apr 30 11:10:20 EST 1999 | ||
90 | >> '$' at end of pattern was matching regular '$', too. | ||
91 | (by anna) | ||
92 | |||
@@ -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); |