Showing the changes to src/lstrlib.c (1 of 60 files). Show all
Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lstrlib.c,v 1.132a 2006/04/26 20:41:19 roberto Exp $ | |
| 2 | +** $Id: lstrlib.c,v 1.132.1.3 2007/12/28 15:32:23 roberto Exp $ | |
| 3 | 3 | ** Standard library for string operations and pattern-matching |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -629,10 +629,6 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, · 623 unmodified lines | ||
| 629 | 629 | lua_gettable(L, 3); |
| 630 | 630 | break; |
| 631 | 631 | } |
| 632 | − default: { | |
| 633 | − luaL_argerror(L, 3, "string/function/table expected"); | |
| 634 | − return; | |
| 635 | − } | |
| 636 | 632 | } |
| 637 | 633 | if (!lua_toboolean(L, -1)) { /* nil or false? */ |
| 638 | 634 | lua_pop(L, 1); |
| @@ -648,11 +644,15 @@ static int str_gsub (lua_State *L) { · 9 unmodified lines | ||
| 648 | 644 | size_t srcl; |
| 649 | 645 | const char *src = luaL_checklstring(L, 1, &srcl); |
| 650 | 646 | const char *p = luaL_checkstring(L, 2); |
| 647 | + int tr = lua_type(L, 3); | |
| 651 | 648 | int max_s = luaL_optint(L, 4, srcl+1); |
| 652 | 649 | int anchor = (*p == '^') ? (p++, 1) : 0; |
| 653 | 650 | int n = 0; |
| 654 | 651 | MatchState ms; |
| 655 | 652 | luaL_Buffer b; |
| 653 | + luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || | |
| 654 | + tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, | |
| 655 | + "string/function/table expected"); | |
| 656 | 656 | luaL_buffinit(L, &b); |
| 657 | 657 | ms.L = L; |
| 658 | 658 | ms.src_init = src; |