History

Lua 5.1.3-rc1

Lua Team committed 18 years ago

Commit ea97e791 parent 4d388a360 files · +732 −439Browse files

Showing the changes to src/lstrlib.c (1 of 60 files). Show all

Unified · Split

src/lstrlib.c+5−5
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Standard library for string operations and pattern-matching
44 ** See Copyright Notice in lua.h
55 */
@@ -629,10 +629,6 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, · 623 unmodified lines
629629 lua_gettable(L, 3);
630630 break;
631631 }
632− default: {
633− luaL_argerror(L, 3, "string/function/table expected");
634− return;
635− }
636632 }
637633 if (!lua_toboolean(L, -1)) { /* nil or false? */
638634 lua_pop(L, 1);
@@ -648,11 +644,15 @@ static int str_gsub (lua_State *L) { · 9 unmodified lines
648644 size_t srcl;
649645 const char *src = luaL_checklstring(L, 1, &srcl);
650646 const char *p = luaL_checkstring(L, 2);
647+ int tr = lua_type(L, 3);
651648 int max_s = luaL_optint(L, 4, srcl+1);
652649 int anchor = (*p == '^') ? (p++, 1) : 0;
653650 int n = 0;
654651 MatchState ms;
655652 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");
656656 luaL_buffinit(L, &b);
657657 ms.L = L;
658658 ms.src_init = src;