diff options
| -rw-r--r-- | strlib.c | 4 |
1 files changed, 2 insertions, 2 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** String library to LUA | 3 | ** String library to LUA |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_strlib="$Id: strlib.c,v 1.19 1996/03/14 15:52:35 roberto Exp roberto $"; | 6 | char *rcs_strlib="$Id: strlib.c,v 1.20 1996/03/19 22:28:37 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| @@ -75,7 +75,7 @@ static void str_find (void) | |||
| 75 | char *s2 = lua_check_string(2, "strfind"); | 75 | char *s2 = lua_check_string(2, "strfind"); |
| 76 | int init = (lua_getparam(3) == LUA_NOOBJECT) ? 0 : | 76 | int init = (lua_getparam(3) == LUA_NOOBJECT) ? 0 : |
| 77 | (int)lua_check_number(3, "strfind")-1; | 77 | (int)lua_check_number(3, "strfind")-1; |
| 78 | char *f = strstr(s1+init,s2); | 78 | char *f = (init>=0 && init<=strlen(s1)) ? strstr(s1+init,s2) : NULL; |
| 79 | if (f != NULL) | 79 | if (f != NULL) |
| 80 | { | 80 | { |
| 81 | int pos = f-s1+1; | 81 | int pos = f-s1+1; |
