Skip to content

Commit

Permalink
fix string_gsub
Browse files Browse the repository at this point in the history
see moonjit#86

Signed-off-by: Francois Perrad <[email protected]>
  • Loading branch information
fperrad authored and siddhesh committed Jan 26, 2020
1 parent 5ca4df7 commit cabe3b3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,14 +621,17 @@ LJLIB_CF(string_gsub)
const char *p = luaL_checklstring(L, 2, &lp);
int tr = lua_type(L, 3);
int max_s = luaL_optint(L, 4, (int)(srcl+1));
int anchor = (*p == '^') ? (p++, 1) : 0;
int anchor = (*p == '^');
int n = 0;
MatchState ms;
luaL_Buffer b;
if (!(tr == LUA_TNUMBER || tr == LUA_TSTRING ||
tr == LUA_TFUNCTION || tr == LUA_TTABLE))
lj_err_arg(L, 3, LJ_ERR_NOSFT);
luaL_buffinit(L, &b);
if (anchor) {
p++; lp--; /* skip anchor character */
}
ms.L = L;
ms.src_init = src;
ms.src_end = src+srcl;
Expand Down

0 comments on commit cabe3b3

Please sign in to comment.