aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-05-02 15:32:22 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-05-02 15:32:22 -0300
commitfe5c37ae95ac64762f307d983000246e3429017f (patch)
tree2e35f41aa4d9fb697bc3c3a8d51651ca82671a57
parentc31f02948fb4431e2639948557dc5501fa1877b9 (diff)
downloadlua-fe5c37ae95ac64762f307d983000246e3429017f.tar.gz
lua-fe5c37ae95ac64762f307d983000246e3429017f.tar.bz2
lua-fe5c37ae95ac64762f307d983000246e3429017f.zip
BUG: `strfind' gets wrong subject length when there is an offset
-rw-r--r--bugs5
-rw-r--r--lstrlib.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/bugs b/bugs
index 58a17b97..b73c691e 100644
--- a/bugs
+++ b/bugs
@@ -170,3 +170,8 @@ in the following platforms:
170* IRIX - cc, cc-purify 170* IRIX - cc, cc-purify
171* Windows - Visual C++ (.c e .cpp, warning level=4) 171* Windows - Visual C++ (.c e .cpp, warning level=4)
172 172
173
174** lstrlib.c
175Tue May 2 15:27:58 EST 2000
176>> `strfind' gets wrong subject length when there is an offset
177(by Jon Kleiser; since 4.0a)
diff --git a/lstrlib.c b/lstrlib.c
index 3a1d8ba3..6a38fd01 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.40 2000/02/08 16:34:31 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.41 2000/03/03 14:58:26 roberto Exp roberto $
3** Standard library for string operations and pattern-matching 3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -405,7 +405,7 @@ static void str_find (lua_State *L) {
405 luaL_arg_check(L, 0 <= init && init <= l1, 3, "out of range"); 405 luaL_arg_check(L, 0 <= init && init <= l1, 3, "out of range");
406 if (lua_getparam(L, 4) != LUA_NOOBJECT || 406 if (lua_getparam(L, 4) != LUA_NOOBJECT ||
407 strpbrk(p, SPECIALS) == NULL) { /* no special characters? */ 407 strpbrk(p, SPECIALS) == NULL) { /* no special characters? */
408 const char *s2 = memfind(s+init, l1, p, l2); 408 const char *s2 = memfind(s+init, l1-init, p, l2);
409 if (s2) { 409 if (s2) {
410 lua_pushnumber(L, s2-s+1); 410 lua_pushnumber(L, s2-s+1);
411 lua_pushnumber(L, s2-s+l2); 411 lua_pushnumber(L, s2-s+l2);