aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-01-03 15:27:43 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-01-03 15:27:43 -0200
commitcfaa8fbf1dee6757af90f0612eb9f96a64e6a61e (patch)
tree4d0a076e2db94e57a39308385b8adb7dd2e3c370
parentf42cc90d2d51b1121aa2ed44530013f1df09fec6 (diff)
downloadlua-cfaa8fbf1dee6757af90f0612eb9f96a64e6a61e.tar.gz
lua-cfaa8fbf1dee6757af90f0612eb9f96a64e6a61e.tar.bz2
lua-cfaa8fbf1dee6757af90f0612eb9f96a64e6a61e.zip
better check for option in `strfind'
-rw-r--r--lstrlib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lstrlib.c b/lstrlib.c
index 2172a09c..f2582cfe 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -449,8 +449,9 @@ static int str_find (lua_State *L) {
449 const char *p = luaL_check_lstr(L, 2, &l2); 449 const char *p = luaL_check_lstr(L, 2, &l2);
450 sint32 init = posrelat(luaL_opt_long(L, 3, 1), l1) - 1; 450 sint32 init = posrelat(luaL_opt_long(L, 3, 1), l1) - 1;
451 luaL_arg_check(L, 0 <= init && (size_t)(init) <= l1, 3, "out of range"); 451 luaL_arg_check(L, 0 <= init && (size_t)(init) <= l1, 3, "out of range");
452 if (lua_gettop(L) > 3 || /* extra argument? */ 452 if (lua_istrue(L, 4) || /* explicit request? */
453 strpbrk(p, SPECIALS) == NULL) { /* or no special characters? */ 453 strpbrk(p, SPECIALS) == NULL) { /* or no special characters? */
454 /* do a plain search */
454 const char *s2 = lmemfind(s+init, l1-init, p, l2); 455 const char *s2 = lmemfind(s+init, l1-init, p, l2);
455 if (s2) { 456 if (s2) {
456 lua_pushnumber(L, s2-s+1); 457 lua_pushnumber(L, s2-s+1);