mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 03:53:09 +00:00
update lua 5.5.1
This commit is contained in:
@@ -141,8 +141,8 @@ static int str_rep (lua_State *L) {
|
||||
const char *s = luaL_checklstring(L, 1, &len);
|
||||
lua_Integer n = luaL_checkinteger(L, 2);
|
||||
const char *sep = luaL_optlstring(L, 3, "", &lsep);
|
||||
if (n <= 0)
|
||||
lua_pushliteral(L, "");
|
||||
if (n <= 0 || (len | lsep) == 0)
|
||||
lua_pushliteral(L, ""); /* no repetitions or both strings empty */
|
||||
else if (l_unlikely(len > MAX_SIZE - lsep ||
|
||||
cast_st2S(len + lsep) > cast_st2S(MAX_SIZE) / n))
|
||||
return luaL_error(L, "resulting string too large");
|
||||
@@ -757,19 +757,25 @@ static int nospecials (const char *p, size_t l) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Prepare state for matches. These fields are not affected by each match.
|
||||
*/
|
||||
static void prepstate (MatchState *ms, lua_State *L,
|
||||
const char *s, size_t ls, const char *p, size_t lp) {
|
||||
ms->L = L;
|
||||
ms->matchdepth = MAXCCALLS;
|
||||
ms->src_init = s;
|
||||
ms->src_end = s + ls;
|
||||
ms->p_end = p + lp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** (Re)prepare state for a match, setting fields that change during
|
||||
** each match.
|
||||
*/
|
||||
static void reprepstate (MatchState *ms) {
|
||||
ms->matchdepth = MAXCCALLS;
|
||||
ms->level = 0;
|
||||
lua_assert(ms->matchdepth == MAXCCALLS);
|
||||
}
|
||||
|
||||
|
||||
@@ -968,7 +974,7 @@ static int str_gsub (lua_State *L) {
|
||||
reprepstate(&ms); /* (re)prepare state for new match */
|
||||
if ((e = match(&ms, src, p)) != NULL && e != lastmatch) { /* match? */
|
||||
n++;
|
||||
changed = add_value(&ms, &b, src, e, tr) | changed;
|
||||
changed = add_value(&ms, &b, src, e, tr) || changed;
|
||||
src = lastmatch = e;
|
||||
}
|
||||
else if (src < ms.src_end) /* otherwise, skip one character */
|
||||
@@ -1726,7 +1732,7 @@ static int str_packsize (lua_State *L) {
|
||||
luaL_argcheck(L, opt != Kstring && opt != Kzstr, 1,
|
||||
"variable-length format");
|
||||
size += ntoalign; /* total space used by option */
|
||||
luaL_argcheck(L, totalsize <= LUA_MAXINTEGER - size,
|
||||
luaL_argcheck(L, totalsize <= MAX_SIZE - size,
|
||||
1, "format result too large");
|
||||
totalsize += size;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user