Skip to content

Instantly share code, notes, and snippets.

@fperrad
Created Apr 19, 2020
Embed
What would you like to do?
const parameters in static function
diff --git a/src/lapi.c b/src/lapi.c
index 3e24781..871fad2 100644
--- a/src/lapi.c
+++ b/src/lapi.c
@@ -851,7 +851,7 @@ LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) {
}
-static void aux_rawset (lua_State *L, int idx, TValue *key, int n) {
+static void aux_rawset (lua_State *L, int idx, const TValue *key, int n) {
Table *t;
TValue *slot;
lua_lock(L);
@@ -1309,7 +1309,7 @@ LUA_API void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue) {
-static const char *aux_upvalue (TValue *fi, int n, TValue **val,
+static const char *aux_upvalue (const TValue *fi, int n, TValue **val,
GCObject **owner) {
switch (ttypetag(fi)) {
case LUA_VCCL: { /* C closure */
diff --git a/src/lauxlib.c b/src/lauxlib.c
index 7235909..907db63 100644
--- a/src/lauxlib.c
+++ b/src/lauxlib.c
@@ -517,7 +517,7 @@ static void newbox (lua_State *L) {
** Compute new size for buffer 'B', enough to accommodate extra 'sz'
** bytes.
*/
-static size_t newbuffsize (luaL_Buffer *B, size_t sz) {
+static size_t newbuffsize (const luaL_Buffer *B, size_t sz) {
size_t newsize = B->size * 2; /* double buffer size */
if (MAX_SIZET - sz < B->n) /* overflow in (B->n + sz)? */
return luaL_error(B->L, "buffer too large");
diff --git a/src/lcode.c b/src/lcode.c
index 6f241c9..4d0e7ac 100644
--- a/src/lcode.c
+++ b/src/lcode.c
@@ -70,7 +70,7 @@ static int tonumeral (const expdesc *e, TValue *v) {
/*
** Get the constant value from a constant expression
*/
-static TValue *const2val (FuncState *fs, const expdesc *e) {
+static TValue *const2val (const FuncState *fs, const expdesc *e) {
lua_assert(e->k == VCONST);
return &fs->ls->dyd->actvar.arr[e->u.info].k;
}
@@ -112,7 +112,7 @@ int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v) {
** previous one, return an invalid instruction (to avoid wrong
** optimizations).
*/
-static Instruction *previousinstruction (FuncState *fs) {
+static Instruction *previousinstruction (const FuncState *fs) {
static const Instruction invalidinstruction = ~(Instruction)0;
if (fs->pc > fs->lasttarget)
return &fs->f->code[fs->pc - 1]; /* previous instruction */
@@ -150,7 +150,7 @@ void luaK_nil (FuncState *fs, int from, int n) {
** Gets the destination address of a jump instruction. Used to traverse
** a list of jumps.
*/
-static int getjump (FuncState *fs, int pc) {
+static int getjump (const FuncState *fs, int pc) {
int offset = GETARG_sJ(fs->f->code[pc]);
if (offset == NO_JUMP) /* point to itself represents end of list */
return NO_JUMP; /* end of list */
@@ -163,7 +163,7 @@ static int getjump (FuncState *fs, int pc) {
** Fix jump instruction at position 'pc' to jump to 'dest'.
** (Jump addresses are relative in Lua)
*/
-static void fixjump (FuncState *fs, int pc, int dest) {
+static void fixjump (const FuncState *fs, int pc, int dest) {
Instruction *jmp = &fs->f->code[pc];
int offset = dest - (pc + 1);
lua_assert(dest != NO_JUMP);
@@ -239,7 +239,7 @@ int luaK_getlabel (FuncState *fs) {
** jump (that is, its condition), or the jump itself if it is
** unconditional.
*/
-static Instruction *getjumpcontrol (FuncState *fs, int pc) {
+static Instruction *getjumpcontrol (const FuncState *fs, int pc) {
Instruction *pi = &fs->f->code[pc];
if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
return pi-1;
@@ -255,7 +255,7 @@ static Instruction *getjumpcontrol (FuncState *fs, int pc) {
** register. Otherwise, change instruction to a simple 'TEST' (produces
** no register value)
*/
-static int patchtestreg (FuncState *fs, int node, int reg) {
+static int patchtestreg (const FuncState *fs, int node, int reg) {
Instruction *i = getjumpcontrol(fs, node);
if (GET_OPCODE(*i) != OP_TESTSET)
return 0; /* cannot patch other instructions */
@@ -273,7 +273,7 @@ static int patchtestreg (FuncState *fs, int node, int reg) {
/*
** Traverse a list of tests ensuring no one produces a value
*/
-static void removevalues (FuncState *fs, int list) {
+static void removevalues (const FuncState *fs, int list) {
for (; list != NO_JUMP; list = getjump(fs, list))
patchtestreg(fs, list, NO_REG);
}
@@ -284,7 +284,7 @@ static void removevalues (FuncState *fs, int list) {
** registers: tests producing values jump to 'vtarget' (and put their
** values in 'reg'), other tests jump to 'dtarget'.
*/
-static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
+static void patchlistaux (const FuncState *fs, int list, int vtarget, int reg,
int dtarget) {
while (list != NO_JUMP) {
int next = getjump(fs, list);
@@ -522,7 +522,7 @@ static void freeregs (FuncState *fs, int r1, int r2) {
/*
** Free register used by expression 'e' (if any)
*/
-static void freeexp (FuncState *fs, expdesc *e) {
+static void freeexp (FuncState *fs, const expdesc *e) {
if (e->k == VNONRELOC)
freereg(fs, e->u.info);
}
@@ -532,7 +532,7 @@ static void freeexp (FuncState *fs, expdesc *e) {
** Free registers used by expressions 'e1' and 'e2' (if any) in proper
** order.
*/
-static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) {
+static void freeexps (FuncState *fs, const expdesc *e1, const expdesc *e2) {
int r1 = (e1->k == VNONRELOC) ? e1->u.info : -1;
int r2 = (e2->k == VNONRELOC) ? e2->u.info : -1;
freeregs(fs, r1, r2);
@@ -546,7 +546,7 @@ static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) {
** as keys (nil cannot be a key, integer keys can collapse with float
** keys), the caller must provide a useful 'key' for indexing the cache.
*/
-static int addk (FuncState *fs, TValue *key, TValue *v) {
+static int addk (FuncState *fs, const TValue *key, const TValue *v) {
lua_State *L = fs->ls->L;
Proto *f = fs->f;
TValue *idx = luaH_set(L, fs->ls->h, key); /* index scanner table */
@@ -676,7 +676,7 @@ static void luaK_float (FuncState *fs, int reg, lua_Number f) {
/*
** Convert a constant in 'v' into an expression description 'e'
*/
-static void const2exp (TValue *v, expdesc *e) {
+static void const2exp (const TValue *v, expdesc *e) {
switch (ttypetag(v)) {
case LUA_VNUMINT:
e->k = VKINT; e->u.ival = ivalue(v);
@@ -881,7 +881,7 @@ static int code_loadbool (FuncState *fs, int A, OpCode op) {
** check whether list has any jump that do not produce a value
** or produce an inverted value
*/
-static int need_value (FuncState *fs, int list) {
+static int need_value (const FuncState *fs, int list) {
for (; list != NO_JUMP; list = getjump(fs, list)) {
Instruction i = *getjumpcontrol(fs, list);
if (GET_OPCODE(i) != OP_TESTSET) return 1;
@@ -1081,7 +1081,7 @@ void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
/*
** Negate condition 'e' (where 'e' is a comparison).
*/
-static void negatecondition (FuncState *fs, expdesc *e) {
+static void negatecondition (const FuncState *fs, const expdesc *e) {
Instruction *pc = getjumpcontrol(fs, e->u.info);
lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
GET_OPCODE(*pc) != OP_TEST);
@@ -1200,7 +1200,7 @@ static void codenot (FuncState *fs, expdesc *e) {
/*
** Check whether expression 'e' is a small literal string
*/
-static int isKstr (FuncState *fs, expdesc *e) {
+static int isKstr (const FuncState *fs, const expdesc *e) {
return (e->k == VK && !hasjumps(e) && e->u.info <= MAXARG_B &&
ttisshrstring(&fs->f->k[e->u.info]));
}
@@ -1235,7 +1235,7 @@ static int isSCint (expdesc *e) {
** Check whether expression 'e' is a literal integer or float in
** proper range to fit in a register (sB or sC).
*/
-static int isSCnumber (expdesc *e, int *pi, int *isfloat) {
+static int isSCnumber (const expdesc *e, int *pi, int *isfloat) {
lua_Integer i;
if (e->k == VKINT)
i = e->u.ival;
@@ -1294,7 +1294,7 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
** Bitwise operations need operands convertible to integers; division
** operations cannot have 0 as divisor.
*/
-static int validop (int op, TValue *v1, TValue *v2) {
+static int validop (int op, const TValue *v1, const TValue *v2) {
switch (op) {
case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */
@@ -1312,7 +1312,7 @@ static int validop (int op, TValue *v1, TValue *v2) {
** Try to "constant-fold" an operation; return 1 iff successful.
** (In this case, 'e1' has the final result.)
*/
-static int constfolding (FuncState *fs, int op, expdesc *e1,
+static int constfolding (const FuncState *fs, int op, expdesc *e1,
const expdesc *e2) {
TValue v1, v2, res;
if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2))
@@ -1353,7 +1353,7 @@ static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) {
** operators).
** Expression to produce final result will be encoded in 'e1'.
*/
-static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2,
+static void finishbinexpval (FuncState *fs, expdesc *e1, const expdesc *e2,
OpCode op, int v2, int flip, int line,
OpCode mmop, TMS event) {
int v1 = luaK_exp2anyreg(fs, e1);
@@ -1384,7 +1384,7 @@ static void codebinexpval (FuncState *fs, OpCode op,
** Code binary operators with immediate operands.
*/
static void codebini (FuncState *fs, OpCode op,
- expdesc *e1, expdesc *e2, int flip, int line,
+ expdesc *e1, const expdesc *e2, int flip, int line,
TMS event) {
int v2 = int2sC(cast_int(e2->u.ival)); /* immediate operand */
lua_assert(e2->k == VKINT);
@@ -1619,7 +1619,7 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
** For '(e1 .. e2.1 .. e2.2)' (which is '(e1 .. (e2.1 .. e2.2))',
** because concatenation is right associative), merge both CONCATs.
*/
-static void codeconcat (FuncState *fs, expdesc *e1, expdesc *e2, int line) {
+static void codeconcat (FuncState *fs, const expdesc *e1, const expdesc *e2, int line) {
Instruction *ie2 = previousinstruction(fs);
if (GET_OPCODE(*ie2) == OP_CONCAT) { /* is 'e2' a concatenation? */
int n = GETARG_B(*ie2); /* # of elements concatenated in 'e2' */
@@ -1766,7 +1766,7 @@ void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
/*
** return the final target of a jump (skipping jumps to jumps)
*/
-static int finaltarget (Instruction *code, int i) {
+static int finaltarget (const Instruction *code, int i) {
int count;
for (count = 0; count < 100; count++) { /* avoid infinite loops */
Instruction pc = code[i];
diff --git a/src/lcorolib.c b/src/lcorolib.c
index 7d6e585..be9d7ba 100644
--- a/src/lcorolib.c
+++ b/src/lcorolib.c
@@ -120,7 +120,7 @@ static const char *const statname[] =
{"running", "dead", "suspended", "normal"};
-static int auxstatus (lua_State *L, lua_State *co) {
+static int auxstatus (const lua_State *L, lua_State *co) {
if (L == co) return COS_RUN;
else {
switch (lua_status(co)) {
diff --git a/src/ldebug.c b/src/ldebug.c
index eaac16f..c6c838c 100644
--- a/src/ldebug.c
+++ b/src/ldebug.c
@@ -38,11 +38,11 @@
#define ci_func(ci) (clLvalue(s2v((ci)->func)))
-static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
+static const char *funcnamefromcode (const lua_State *L, const CallInfo *ci,
const char **name);
-static int currentpc (CallInfo *ci) {
+static int currentpc (const CallInfo *ci) {
lua_assert(isLua(ci));
return pcRel(ci->u.l.savedpc, ci_func(ci)->p);
}
@@ -101,7 +101,7 @@ int luaG_getfuncline (const Proto *f, int pc) {
}
-static int getcurrentline (CallInfo *ci) {
+static int getcurrentline (const CallInfo *ci) {
return luaG_getfuncline(ci_func(ci)->p, currentpc(ci));
}
@@ -187,7 +187,7 @@ static const char *upvalname (const Proto *p, int uv) {
}
-static const char *findvararg (CallInfo *ci, int n, StkId *pos) {
+static const char *findvararg (const CallInfo *ci, int n, StkId *pos) {
if (clLvalue(s2v(ci->func))->p->is_vararg) {
int nextra = ci->u.l.nextraargs;
if (n <= nextra) {
@@ -259,7 +259,7 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
}
-static void funcinfo (lua_Debug *ar, Closure *cl) {
+static void funcinfo (lua_Debug *ar, const Closure *cl) {
if (noLuaClosure(cl)) {
ar->source = "=[C]";
ar->srclen = LL("=[C]");
@@ -293,7 +293,7 @@ static int nextline (const Proto *p, int currentline, int pc) {
}
-static void collectvalidlines (lua_State *L, Closure *f) {
+static void collectvalidlines (lua_State *L, const Closure *f) {
if (noLuaClosure(f)) {
setnilvalue(s2v(L->top));
api_incr_top(L);
@@ -315,7 +315,7 @@ static void collectvalidlines (lua_State *L, Closure *f) {
}
-static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
+static const char *getfuncname (const lua_State *L, const CallInfo *ci, const char **name) {
if (ci == NULL) /* no 'ci'? */
return NULL; /* no info */
else if (ci->callstatus & CIST_FIN) { /* is this a finalizer? */
@@ -329,8 +329,8 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
}
-static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
- Closure *f, CallInfo *ci) {
+static int auxgetinfo (const lua_State *L, const char *what, lua_Debug *ar,
+ const Closure *f, const CallInfo *ci) {
int status = 1;
for (; *what; what++) {
switch (*what) {
@@ -596,7 +596,7 @@ static const char *getobjname (const Proto *p, int lastpc, int reg,
** Returns what the name is (e.g., "for iterator", "method",
** "metamethod") and sets '*name' to point to the name.
*/
-static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
+static const char *funcnamefromcode (const lua_State *L, const CallInfo *ci,
const char **name) {
TMS tm = (TMS)0; /* (initial value avoids warnings) */
const Proto *p = ci_func(ci)->p; /* calling function */
@@ -653,7 +653,7 @@ static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
** not ISO C, but it should not crash a program; the subsequent
** checks are ISO C and ensure a correct result.
*/
-static int isinstack (CallInfo *ci, const TValue *o) {
+static int isinstack (const CallInfo *ci, const TValue *o) {
StkId base = ci->func + 1;
ptrdiff_t i = cast(StkId, o) - base;
return (0 <= i && i < (ci->top - base) && s2v(base + i) == o);
@@ -665,7 +665,7 @@ static int isinstack (CallInfo *ci, const TValue *o) {
** with instructions OP_GETTABUP/OP_SETTABUP, which operate directly on
** upvalues.)
*/
-static const char *getupvalname (CallInfo *ci, const TValue *o,
+static const char *getupvalname (const CallInfo *ci, const TValue *o,
const char **name) {
LClosure *c = ci_func(ci);
int i;
diff --git a/src/ldo.c b/src/ldo.c
index 64fe291..5f0d663 100644
--- a/src/ldo.c
+++ b/src/ldo.c
@@ -232,7 +232,7 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) {
}
-static int stackinuse (lua_State *L) {
+static int stackinuse (const lua_State *L) {
CallInfo *ci;
StkId lim = L->top;
for (ci = L->ci; ci != NULL; ci = ci->previous) {
@@ -581,7 +581,7 @@ static void unroll (lua_State *L, void *ud) {
** Try to find a suspended protected call (a "recover point") for the
** given thread.
*/
-static CallInfo *findpcall (lua_State *L) {
+static CallInfo *findpcall (const lua_State *L) {
CallInfo *ci;
for (ci = L->ci; ci != NULL; ci = ci->previous) { /* search for a pcall */
if (ci->callstatus & CIST_YPCALL)
diff --git a/src/ldump.c b/src/ldump.c
index fbadbcc..5d4295e 100644
--- a/src/ldump.c
+++ b/src/ldump.c
@@ -103,7 +103,7 @@ static void dumpCode (DumpState *D, const Proto *f) {
}
-static void dumpFunction(DumpState *D, const Proto *f, TString *psource);
+static void dumpFunction(DumpState *D, const Proto *f, const TString *psource);
static void dumpConstants (DumpState *D, const Proto *f) {
int i;
@@ -176,7 +176,7 @@ static void dumpDebug (DumpState *D, const Proto *f) {
}
-static void dumpFunction (DumpState *D, const Proto *f, TString *psource) {
+static void dumpFunction (DumpState *D, const Proto *f, const TString *psource) {
if (D->strip || f->source == psource)
dumpString(D, NULL); /* no debug info or same source as its parent */
else
diff --git a/src/lfunc.c b/src/lfunc.c
index 10100e5..9997d3f 100644
--- a/src/lfunc.c
+++ b/src/lfunc.c
@@ -110,7 +110,7 @@ static void callclose (lua_State *L, void *ud) {
** Prepare closing method plus its arguments for object 'obj' with
** error message 'err'. (This function assumes EXTRA_STACK.)
*/
-static int prepclosingmethod (lua_State *L, TValue *obj, TValue *err) {
+static int prepclosingmethod (lua_State *L, const TValue *obj, const TValue *err) {
StkId top = L->top;
const TValue *tm = luaT_gettmbyobj(L, obj, TM_CLOSE);
if (ttisnil(tm)) /* no metamethod? */
diff --git a/src/lgc.c b/src/lgc.c
index f26c921..48f7603 100644
--- a/src/lgc.c
+++ b/src/lgc.c
@@ -520,7 +520,7 @@ static int traverseudata (global_State *g, Udata *u) {
** arrays can be larger than needed; the extra slots are filled with
** NULL, so the use of 'markobjectN')
*/
-static int traverseproto (global_State *g, Proto *f) {
+static int traverseproto (global_State *g, const Proto *f) {
int i;
markobjectN(g, f->source);
for (i = 0; i < f->sizek; i++) /* mark literals */
@@ -535,7 +535,7 @@ static int traverseproto (global_State *g, Proto *f) {
}
-static int traverseCclosure (global_State *g, CClosure *cl) {
+static int traverseCclosure (global_State *g, const CClosure *cl) {
int i;
for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */
markvalue(g, &cl->upvalue[i]);
@@ -546,7 +546,7 @@ static int traverseCclosure (global_State *g, CClosure *cl) {
** Traverse a Lua closure, marking its prototype and its upvalues.
** (Both can be NULL while closure is being created.)
*/
-static int traverseLclosure (global_State *g, LClosure *cl) {
+static int traverseLclosure (global_State *g, const LClosure *cl) {
int i;
markobjectN(g, cl->p); /* mark its prototype */
for (i = 0; i < cl->nupvalues; i++) { /* visit its upvalues */
@@ -680,7 +680,7 @@ static void clearbykeys (global_State *g, GCObject *l) {
** clear entries with unmarked values from all weaktables in list 'l' up
** to element 'f'
*/
-static void clearbyvalues (global_State *g, GCObject *l, GCObject *f) {
+static void clearbyvalues (global_State *g, GCObject *l, const GCObject *f) {
for (; l != f; l = gco2t(l)->gclist) {
Table *h = gco2t(l);
Node *n, *limit = gnodelast(h);
@@ -996,8 +996,8 @@ static void sweep2old (lua_State *L, GCObject **p) {
** non-dead objects, advance their ages and clear the color of
** new objects. (Old objects keep their colors.)
*/
-static GCObject **sweepgen (lua_State *L, global_State *g, GCObject **p,
- GCObject *limit) {
+static GCObject **sweepgen (lua_State *L, const global_State *g, GCObject **p,
+ const GCObject *limit) {
static const lu_byte nextage[] = {
G_SURVIVAL, /* from G_NEW */
G_OLD1, /* from G_SURVIVAL */
@@ -1030,7 +1030,7 @@ static GCObject **sweepgen (lua_State *L, global_State *g, GCObject **p,
** Traverse a list making all its elements white and clearing their
** age.
*/
-static void whitelist (global_State *g, GCObject *p) {
+static void whitelist (const global_State *g, GCObject *p) {
int white = luaC_white(g);
for (; p != NULL; p = p->next)
p->marked = cast_byte((p->marked & maskcolors) | white);
@@ -1104,7 +1104,7 @@ static void correctgraylists (global_State *g) {
** Gray objects are already in some gray list, and so will be visited
** in the atomic step.
*/
-static void markold (global_State *g, GCObject *from, GCObject *to) {
+static void markold (global_State *g, GCObject *from, const GCObject *to) {
GCObject *p;
for (p = from; p != to; p = p->next) {
if (getage(p) == G_OLD1) {
@@ -1387,7 +1387,7 @@ static void entersweep (lua_State *L) {
** Delete all objects in list 'p' until (but not including) object
** 'limit'.
*/
-static void deletelist (lua_State *L, GCObject *p, GCObject *limit) {
+static void deletelist (lua_State *L, GCObject *p, const GCObject *limit) {
while (p != limit) {
GCObject *next = p->next;
freeobj(L, p);
diff --git a/src/lobject.c b/src/lobject.c
index b4efae4..ed7beac 100644
--- a/src/lobject.c
+++ b/src/lobject.c
@@ -340,7 +340,7 @@ int luaO_utf8esc (char *buff, unsigned long x) {
/*
** Convert a number object to a string, adding it to a buffer
*/
-static int tostringbuff (TValue *obj, char *buff) {
+static int tostringbuff (const TValue *obj, char *buff) {
int len;
lua_assert(ttisnumber(obj));
if (ttisinteger(obj))
@@ -446,7 +446,7 @@ static void addstr2buff (BuffFS *buff, const char *str, size_t slen) {
/*
** Add a number to the buffer.
*/
-static void addnum2buff (BuffFS *buff, TValue *num) {
+static void addnum2buff (BuffFS *buff, const TValue *num) {
char *numbuff = getbuff(buff, MAXNUMBER2STR);
int len = tostringbuff(num, numbuff); /* format number into 'numbuff' */
addsize(buff, len);
diff --git a/src/loslib.c b/src/loslib.c
index 29449e4..97297ca 100644
--- a/src/loslib.c
+++ b/src/loslib.c
@@ -225,7 +225,7 @@ static void setboolfield (lua_State *L, const char *key, int value) {
/*
** Set all fields from structure 'tm' in the table on top of the stack
*/
-static void setallfields (lua_State *L, struct tm *stm) {
+static void setallfields (lua_State *L, const struct tm *stm) {
setfield(L, "year", stm->tm_year, 1900);
setfield(L, "month", stm->tm_mon, 1);
setfield(L, "day", stm->tm_mday, 0);
diff --git a/src/lparser.c b/src/lparser.c
index b0dbb65..ec00acc 100644
--- a/src/lparser.c
+++ b/src/lparser.c
@@ -71,7 +71,7 @@ static l_noret error_expected (LexState *ls, int token) {
}
-static l_noret errorlimit (FuncState *fs, int limit, const char *what) {
+static l_noret errorlimit (const FuncState *fs, int limit, const char *what) {
lua_State *L = fs->ls->L;
const char *msg;
int line = fs->f->linedefined;
@@ -84,7 +84,7 @@ static l_noret errorlimit (FuncState *fs, int limit, const char *what) {
}
-static void checklimit (FuncState *fs, int v, int l, const char *what) {
+static void checklimit (const FuncState *fs, int v, int l, const char *what) {
if (v > l) errorlimit(fs, l, what);
}
@@ -172,7 +172,7 @@ static void codename (LexState *ls, expdesc *e) {
** Register a new local variable in the active 'Proto' (for debug
** information).
*/
-static int registerlocalvar (LexState *ls, FuncState *fs, TString *varname) {
+static int registerlocalvar (const LexState *ls, FuncState *fs, TString *varname) {
Proto *f = fs->f;
int oldsize = f->sizelocvars;
luaM_growvector(ls->L, f->locvars, fs->ndebugvars, f->sizelocvars,
@@ -190,7 +190,7 @@ static int registerlocalvar (LexState *ls, FuncState *fs, TString *varname) {
** Create a new local variable with the given 'name'. Return its index
** in the function.
*/
-static int new_localvar (LexState *ls, TString *name) {
+static int new_localvar (const LexState *ls, TString *name) {
lua_State *L = ls->L;
FuncState *fs = ls->fs;
Dyndata *dyd = ls->dyd;
@@ -215,7 +215,7 @@ static int new_localvar (LexState *ls, TString *name) {
** Return the "variable description" (Vardesc) of a given
** variable
*/
-static Vardesc *getlocalvardesc (FuncState *fs, int i) {
+static Vardesc *getlocalvardesc (const FuncState *fs, int i) {
return &fs->ls->dyd->actvar.arr[fs->firstlocal + i];
}
@@ -224,7 +224,7 @@ static Vardesc *getlocalvardesc (FuncState *fs, int i) {
** Convert 'nvar' (number of active variables at some point) to
** number of variables in the stack at that point.
*/
-static int stacklevel (FuncState *fs, int nvar) {
+static int stacklevel (const FuncState *fs, int nvar) {
while (nvar > 0) {
Vardesc *vd = getlocalvardesc(fs, nvar - 1);
if (vd->vd.kind != RDKCTC) /* is in the stack? */
@@ -247,7 +247,7 @@ int luaY_nvarstack (FuncState *fs) {
/*
** Get the debug-information entry for current variable 'i'.
*/
-static LocVar *localdebuginfo (FuncState *fs, int i) {
+static LocVar *localdebuginfo (const FuncState *fs, int i) {
Vardesc *vd = getlocalvardesc(fs, i);
if (vd->vd.kind == RDKCTC)
return NULL; /* no debug info. for constants */
@@ -259,7 +259,7 @@ static LocVar *localdebuginfo (FuncState *fs, int i) {
}
-static void init_var (FuncState *fs, expdesc *e, int i) {
+static void init_var (const FuncState *fs, expdesc *e, int i) {
e->f = e->t = NO_JUMP;
e->k = VLOCAL;
e->u.var.vidx = i;
@@ -267,7 +267,7 @@ static void init_var (FuncState *fs, expdesc *e, int i) {
}
-static void check_readonly (LexState *ls, expdesc *e) {
+static void check_readonly (LexState *ls, const expdesc *e) {
FuncState *fs = ls->fs;
TString *varname = NULL; /* to be set if variable is const */
switch (e->k) {
@@ -301,7 +301,7 @@ static void check_readonly (LexState *ls, expdesc *e) {
/*
** Start the scope for the last 'nvars' created variables.
*/
-static void adjustlocalvars (LexState *ls, int nvars) {
+static void adjustlocalvars (const LexState *ls, int nvars) {
FuncState *fs = ls->fs;
int stklevel = luaY_nvarstack(fs);
int i;
@@ -332,7 +332,7 @@ static void removevars (FuncState *fs, int tolevel) {
** Search the upvalues of the function 'fs' for one
** with the given 'name'.
*/
-static int searchupvalue (FuncState *fs, TString *name) {
+static int searchupvalue (const FuncState *fs, const TString *name) {
int i;
Upvaldesc *up = fs->f->upvalues;
for (i = 0; i < fs->nups; i++) {
@@ -354,7 +354,7 @@ static Upvaldesc *allocupvalue (FuncState *fs) {
}
-static int newupvalue (FuncState *fs, TString *name, expdesc *v) {
+static int newupvalue (FuncState *fs, TString *name, const expdesc *v) {
Upvaldesc *up = allocupvalue(fs);
FuncState *prev = fs->prev;
if (v->k == VLOCAL) {
@@ -379,7 +379,7 @@ static int newupvalue (FuncState *fs, TString *name, expdesc *v) {
** Look for an active local variable with the name 'n' in the
** function 'fs'.
*/
-static int searchvar (FuncState *fs, TString *n, expdesc *var) {
+static int searchvar (const FuncState *fs, const TString *n, expdesc *var) {
int i;
for (i = cast_int(fs->nactvar) - 1; i >= 0; i--) {
Vardesc *vd = getlocalvardesc(fs, i);
@@ -459,7 +459,7 @@ static void singlevar (LexState *ls, expdesc *var) {
** Adjust the number of results from an expression list 'e' with 'nexps'
** expressions to 'nvars' values.
*/
-static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
+static void adjust_assign (const LexState *ls, int nvars, int nexps, expdesc *e) {
FuncState *fs = ls->fs;
int needed = nvars - nexps; /* extra values needed */
if (hasmultret(e->k)) { /* last expression has multiple returns? */
@@ -493,7 +493,7 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
** Generates an error that a goto jumps into the scope of some
** local variable.
*/
-static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) {
+static l_noret jumpscopeerror (LexState *ls, const Labeldesc *gt) {
const char *varname = getstr(getlocalvardesc(ls->fs, gt->nactvar)->vd.name);
const char *msg = "<goto %s> at line %d jumps into the scope of local '%s'";
msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line, varname);
@@ -506,7 +506,7 @@ static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) {
** from the list of pending goto's.
** If it jumps into the scope of some variable, raises an error.
*/
-static void solvegoto (LexState *ls, int g, Labeldesc *label) {
+static void solvegoto (LexState *ls, int g, const Labeldesc *label) {
int i;
Labellist *gl = &ls->dyd->gt; /* list of goto's */
Labeldesc *gt = &gl->arr[g]; /* goto to be resolved */
@@ -523,7 +523,7 @@ static void solvegoto (LexState *ls, int g, Labeldesc *label) {
/*
** Search for an active label with the given name.
*/
-static Labeldesc *findlabel (LexState *ls, TString *name) {
+static Labeldesc *findlabel (const LexState *ls, const TString *name) {
int i;
Dyndata *dyd = ls->dyd;
/* check labels in current function for a match */
@@ -539,7 +539,7 @@ static Labeldesc *findlabel (LexState *ls, TString *name) {
/*
** Adds a new label/goto in the corresponding list.
*/
-static int newlabelentry (LexState *ls, Labellist *l, TString *name,
+static int newlabelentry (const LexState *ls, Labellist *l, TString *name,
int line, int pc) {
int n = l->n;
luaM_growvector(ls->L, l->arr, n, l->size,
@@ -554,7 +554,7 @@ static int newlabelentry (LexState *ls, Labellist *l, TString *name,
}
-static int newgotoentry (LexState *ls, TString *name, int line, int pc) {
+static int newgotoentry (const LexState *ls, TString *name, int line, int pc) {
return newlabelentry(ls, &ls->dyd->gt, name, line, pc);
}
@@ -564,7 +564,7 @@ static int newgotoentry (LexState *ls, TString *name, int line, int pc) {
** pending gotos in current block and solves them. Return true
** if any of the goto's need to close upvalues.
*/
-static int solvegotos (LexState *ls, Labeldesc *lb) {
+static int solvegotos (LexState *ls, const Labeldesc *lb) {
Labellist *gl = &ls->dyd->gt;
int i = ls->fs->bl->firstgoto;
int needsclose = 0;
@@ -607,7 +607,7 @@ static int createlabel (LexState *ls, TString *name, int line,
/*
** Adjust pending gotos to outer level of a block.
*/
-static void movegotosout (FuncState *fs, BlockCnt *bl) {
+static void movegotosout (const FuncState *fs, const BlockCnt *bl) {
int i;
Labellist *gl = &fs->ls->dyd->gt;
/* correct pending gotos to current block */
@@ -637,7 +637,7 @@ static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop) {
/*
** generates an error for an undefined 'goto'.
*/
-static l_noret undefgoto (LexState *ls, Labeldesc *gt) {
+static l_noret undefgoto (LexState *ls, const Labeldesc *gt) {
const char *msg;
if (eqstr(gt->name, luaS_newliteral(ls->L, "break"))) {
msg = "break outside loop at line %d";
@@ -677,7 +677,7 @@ static void leaveblock (FuncState *fs) {
/*
** adds a new prototype into list of prototypes
*/
-static Proto *addprototype (LexState *ls) {
+static Proto *addprototype (const LexState *ls) {
Proto *clp;
lua_State *L = ls->L;
FuncState *fs = ls->fs;
@@ -701,7 +701,7 @@ static Proto *addprototype (LexState *ls) {
** are in use at that time.
*/
-static void codeclosure (LexState *ls, expdesc *v) {
+static void codeclosure (const LexState *ls, expdesc *v) {
FuncState *fs = ls->fs->prev;
init_exp(v, VRELOC, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1));
luaK_exp2nextreg(fs, v); /* fix it at the last register */
@@ -766,7 +766,7 @@ static void close_func (LexState *ls) {
** 'until' closes syntactical blocks, but do not close scope,
** so it is handled in separate.
*/
-static int block_follow (LexState *ls, int withuntil) {
+static int block_follow (const LexState *ls, int withuntil) {
switch (ls->t.token) {
case TK_ELSE: case TK_ELSEIF:
case TK_END: case TK_EOS:
@@ -1309,7 +1309,7 @@ struct LHS_assign {
** table. If so, save original upvalue/local value in a safe place and
** use this safe copy in the previous assignment.
*/
-static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
+static void check_conflict (const LexState *ls, struct LHS_assign *lh, const expdesc *v) {
FuncState *fs = ls->fs;
int extra = fs->freereg; /* eventual position to save local variable */
int conflict = 0;
@@ -1508,7 +1508,7 @@ static void exp1 (LexState *ls) {
** (Jump addresses are relative in Lua). 'back' true means
** a back jump.
*/
-static void fixforjump (FuncState *fs, int pc, int dest, int back) {
+static void fixforjump (const FuncState *fs, int pc, int dest, int back) {
Instruction *jmp = &fs->f->code[pc];
int offset = dest - (pc + 1);
if (back)
@@ -1734,7 +1734,7 @@ static int getlocalattribute (LexState *ls) {
}
-static void checktoclose (LexState *ls, int level) {
+static void checktoclose (const LexState *ls, int level) {
if (level != -1) { /* is there a to-be-closed variable? */
FuncState *fs = ls->fs;
markupval(fs, level + 1);
diff --git a/src/lstring.c b/src/lstring.c
index 6f15747..c0f9c3b 100644
--- a/src/lstring.c
+++ b/src/lstring.c
@@ -183,7 +183,7 @@ void luaS_remove (lua_State *L, TString *ts) {
}
-static void growstrtab (lua_State *L, stringtable *tb) {
+static void growstrtab (lua_State *L, const stringtable *tb) {
if (unlikely(tb->nuse == MAX_INT)) { /* too many strings? */
luaC_fullgc(L, 1); /* try to free some... */
if (tb->nuse == MAX_INT) /* still too many? */
diff --git a/src/lstrlib.c b/src/lstrlib.c
index 2ba8bde..02f8167 100644
--- a/src/lstrlib.c
+++ b/src/lstrlib.c
@@ -381,7 +381,7 @@ static const char *match (MatchState *ms, const char *s, const char *p);
#define SPECIALS "^$*+?.([%-"
-static int check_capture (MatchState *ms, int l) {
+static int check_capture (const MatchState *ms, int l) {
l -= '1';
if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
return luaL_error(ms->L, "invalid capture index %%%d", l + 1);
@@ -389,7 +389,7 @@ static int check_capture (MatchState *ms, int l) {
}
-static int capture_to_close (MatchState *ms) {
+static int capture_to_close (const MatchState *ms) {
int level = ms->level;
for (level--; level>=0; level--)
if (ms->capture[level].len == CAP_UNFINISHED) return level;
@@ -397,7 +397,7 @@ static int capture_to_close (MatchState *ms) {
}
-static const char *classend (MatchState *ms, const char *p) {
+static const char *classend (const MatchState *ms, const char *p) {
switch (*p++) {
case L_ESC: {
if (p == ms->p_end)
@@ -464,7 +464,7 @@ static int matchbracketclass (int c, const char *p, const char *ec) {
}
-static int singlematch (MatchState *ms, const char *s, const char *p,
+static int singlematch (const MatchState *ms, const char *s, const char *p,
const char *ep) {
if (s >= ms->src_end)
return 0;
@@ -480,7 +480,7 @@ static int singlematch (MatchState *ms, const char *s, const char *p,
}
-static const char *matchbalance (MatchState *ms, const char *s,
+static const char *matchbalance (const MatchState *ms, const char *s,
const char *p) {
if (p >= ms->p_end - 1)
luaL_error(ms->L, "malformed pattern (missing arguments to '%%b')");
@@ -553,7 +553,7 @@ static const char *end_capture (MatchState *ms, const char *s,
}
-static const char *match_capture (MatchState *ms, const char *s, int l) {
+static const char *match_capture (const MatchState *ms, const char *s, int l) {
size_t len;
l = check_capture(ms, l);
len = ms->capture[l].len;
@@ -696,7 +696,7 @@ static const char *lmemfind (const char *s1, size_t l1,
** its length and put its address in '*cap'. If it is an integer
** (a position), push it on the stack and return CAP_POSITION.
*/
-static size_t get_onecapture (MatchState *ms, int i, const char *s,
+static size_t get_onecapture (const MatchState *ms, int i, const char *s,
const char *e, const char **cap) {
if (i >= ms->level) {
if (i != 0)
@@ -719,8 +719,8 @@ static size_t get_onecapture (MatchState *ms, int i, const char *s,
/*
** Push the i-th capture on the stack.
*/
-static void push_onecapture (MatchState *ms, int i, const char *s,
- const char *e) {
+static void push_onecapture (const MatchState *ms, int i, const char *s,
+ const char *e) {
const char *cap;
ptrdiff_t l = get_onecapture(ms, i, s, e, &cap);
if (l != CAP_POSITION)
@@ -729,7 +729,7 @@ static void push_onecapture (MatchState *ms, int i, const char *s,
}
-static int push_captures (MatchState *ms, const char *s, const char *e) {
+static int push_captures (const MatchState *ms, const char *s, const char *e) {
int i;
int nlevels = (ms->level == 0 && s) ? 1 : ms->level;
luaL_checkstack(ms->L, nlevels, "too many captures");
@@ -865,8 +865,8 @@ static int gmatch (lua_State *L) {
}
-static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
- const char *e) {
+static void add_s (const MatchState *ms, luaL_Buffer *b, const char *s,
+ const char *e) {
size_t l;
lua_State *L = ms->L;
const char *news = lua_tolstring(L, 3, &l);
@@ -900,8 +900,8 @@ static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
** Return true if the original string was changed. (Function calls and
** table indexing resulting in nil or false do not change the subject.)
*/
-static int add_value (MatchState *ms, luaL_Buffer *b, const char *s,
- const char *e, int tr) {
+static int add_value (const MatchState *ms, luaL_Buffer *b, const char *s,
+ const char *e, int tr) {
lua_State *L = ms->L;
switch (tr) {
case LUA_TFUNCTION: { /* call the function */
@@ -1418,7 +1418,7 @@ static int getnum (const char **fmt, int df) {
** Read an integer numeral and raises an error if it is larger
** than the maximum size for integers.
*/
-static int getnumlimit (Header *h, const char **fmt, int df) {
+static int getnumlimit (const Header *h, const char **fmt, int df) {
int sz = getnum(fmt, df);
if (sz > MAXINTSIZE || sz <= 0)
return luaL_error(h->L, "integral size (%d) out of limits [1,%d]",
diff --git a/src/ltable.c b/src/ltable.c
index d7eb69a..b109c64 100644
--- a/src/ltable.c
+++ b/src/ltable.c
@@ -252,7 +252,7 @@ static unsigned int setlimittosize (Table *t) {
** "Generic" get version. (Not that generic: not valid for integers,
** which may be in array part, nor for floats with integral values.)
*/
-static const TValue *getgeneric (Table *t, const TValue *key) {
+static const TValue *getgeneric (const Table *t, const TValue *key) {
Node *n = mainpositionTV(t, key);
for (;;) { /* check whether 'key' is somewhere in the chain */
if (equalkey(key, n))
@@ -284,7 +284,7 @@ static unsigned int arrayindex (lua_Integer k) {
** elements in the array part, then elements in the hash part. The
** beginning of a traversal is signaled by 0.
*/
-static unsigned int findindex (lua_State *L, Table *t, TValue *key,
+static unsigned int findindex (lua_State *L, const Table *t, const TValue *key,
unsigned int asize) {
unsigned int i;
if (ttisnil(key)) return 0; /* first iteration */
@@ -324,7 +324,7 @@ int luaH_next (lua_State *L, Table *t, StkId key) {
}
-static void freehash (lua_State *L, Table *t) {
+static void freehash (lua_State *L, const Table *t) {
if (!isdummy(t))
luaM_freearray(L, t->node, cast_sizet(sizenode(t)));
}
@@ -344,7 +344,7 @@ static void freehash (lua_State *L, Table *t) {
** will go to the array part; return the optimal size. (The condition
** 'twotoi > 0' in the for loop stops the loop if 'twotoi' overflows.)
*/
-static unsigned int computesizes (unsigned int nums[], unsigned int *pna) {
+static unsigned int computesizes (const unsigned int nums[], unsigned int *pna) {
int i;
unsigned int twotoi; /* 2^i (candidate for optimal size) */
unsigned int a = 0; /* number of elements smaller than 2^i */
@@ -461,7 +461,7 @@ static void setnodevector (lua_State *L, Table *t, unsigned int size) {
/*
** (Re)insert all elements from the hash part of 'ot' into table 't'.
*/
-static void reinsert (lua_State *L, Table *ot, Table *t) {
+static void reinsert (lua_State *L, const Table *ot, Table *t) {
int j;
int size = sizenode(ot);
for (j = 0; j < size; j++) {
diff --git a/src/lundump.c b/src/lundump.c
index 1736499..45b2485 100644
--- a/src/lundump.c
+++ b/src/lundump.c
@@ -37,7 +37,7 @@ typedef struct {
} LoadState;
-static l_noret error (LoadState *S, const char *why) {
+static l_noret error (const LoadState *S, const char *why) {
luaO_pushfstring(S->L, "%s: bad binary format (%s)", S->name, why);
luaD_throw(S->L, LUA_ERRSYNTAX);
}
@@ -49,7 +49,7 @@ static l_noret error (LoadState *S, const char *why) {
*/
#define loadVector(S,b,n) loadBlock(S,b,(n)*sizeof((b)[0]))
-static void loadBlock (LoadState *S, void *b, size_t size) {
+static void loadBlock (const LoadState *S, void *b, size_t size) {
if (luaZ_read(S->Z, b, size) != 0)
error(S, "truncated chunk");
}
@@ -58,7 +58,7 @@ static void loadBlock (LoadState *S, void *b, size_t size) {
#define loadVar(S,x) loadVector(S,&x,1)
-static lu_byte loadByte (LoadState *S) {
+static lu_byte loadByte (const LoadState *S) {
int b = zgetc(S->Z);
if (b == EOZ)
error(S, "truncated chunk");
@@ -66,7 +66,7 @@ static lu_byte loadByte (LoadState *S) {
}
-static size_t loadUnsigned (LoadState *S, size_t limit) {
+static size_t loadUnsigned (const LoadState *S, size_t limit) {
size_t x = 0;
int b;
limit >>= 7;
@@ -80,24 +80,24 @@ static size_t loadUnsigned (LoadState *S, size_t limit) {
}
-static size_t loadSize (LoadState *S) {
+static size_t loadSize (const LoadState *S) {
return loadUnsigned(S, ~(size_t)0);
}
-static int loadInt (LoadState *S) {
+static int loadInt (const LoadState *S) {
return cast_int(loadUnsigned(S, INT_MAX));
}
-static lua_Number loadNumber (LoadState *S) {
+static lua_Number loadNumber (const LoadState *S) {
lua_Number x;
loadVar(S, x);
return x;
}
-static lua_Integer loadInteger (LoadState *S) {
+static lua_Integer loadInteger (const LoadState *S) {
lua_Integer x;
loadVar(S, x);
return x;
@@ -107,7 +107,7 @@ static lua_Integer loadInteger (LoadState *S) {
/*
** Load a nullable string.
*/
-static TString *loadStringN (LoadState *S) {
+static TString *loadStringN (const LoadState *S) {
size_t size = loadSize(S);
if (size == 0)
return NULL;
@@ -127,7 +127,7 @@ static TString *loadStringN (LoadState *S) {
/*
** Load a non-nullable string.
*/
-static TString *loadString (LoadState *S) {
+static TString *loadString (const LoadState *S) {
TString *st = loadStringN(S);
if (st == NULL)
error(S, "bad format for constant string");
@@ -135,7 +135,7 @@ static TString *loadString (LoadState *S) {
}
-static void loadCode (LoadState *S, Proto *f) {
+static void loadCode (const LoadState *S, Proto *f) {
int n = loadInt(S);
f->code = luaM_newvectorchecked(S->L, n, Instruction);
f->sizecode = n;
@@ -143,10 +143,10 @@ static void loadCode (LoadState *S, Proto *f) {
}
-static void loadFunction(LoadState *S, Proto *f, TString *psource);
+static void loadFunction(const LoadState *S, Proto *f, TString *psource);
-static void loadConstants (LoadState *S, Proto *f) {
+static void loadConstants (const LoadState *S, Proto *f) {
int i;
int n = loadInt(S);
f->k = luaM_newvectorchecked(S->L, n, TValue);
@@ -182,7 +182,7 @@ static void loadConstants (LoadState *S, Proto *f) {
}
-static void loadProtos (LoadState *S, Proto *f) {
+static void loadProtos (const LoadState *S, Proto *f) {
int i;
int n = loadInt(S);
f->p = luaM_newvectorchecked(S->L, n, Proto *);
@@ -196,7 +196,7 @@ static void loadProtos (LoadState *S, Proto *f) {
}
-static void loadUpvalues (LoadState *S, Proto *f) {
+static void loadUpvalues (const LoadState *S, Proto *f) {
int i, n;
n = loadInt(S);
f->upvalues = luaM_newvectorchecked(S->L, n, Upvaldesc);
@@ -210,7 +210,7 @@ static void loadUpvalues (LoadState *S, Proto *f) {
}
-static void loadDebug (LoadState *S, Proto *f) {
+static void loadDebug (const LoadState *S, Proto *f) {
int i, n;
n = loadInt(S);
f->lineinfo = luaM_newvectorchecked(S->L, n, ls_byte);
@@ -239,7 +239,7 @@ static void loadDebug (LoadState *S, Proto *f) {
}
-static void loadFunction (LoadState *S, Proto *f, TString *psource) {
+static void loadFunction (const LoadState *S, Proto *f, TString *psource) {
f->source = loadStringN(S);
if (f->source == NULL) /* no source in dump? */
f->source = psource; /* reuse parent's source */
@@ -256,7 +256,7 @@ static void loadFunction (LoadState *S, Proto *f, TString *psource) {
}
-static void checkliteral (LoadState *S, const char *s, const char *msg) {
+static void checkliteral (const LoadState *S, const char *s, const char *msg) {
char buff[sizeof(LUA_SIGNATURE) + sizeof(LUAC_DATA)]; /* larger than both */
size_t len = strlen(s);
loadVector(S, buff, len);
@@ -265,7 +265,7 @@ static void checkliteral (LoadState *S, const char *s, const char *msg) {
}
-static void fchecksize (LoadState *S, size_t size, const char *tname) {
+static void fchecksize (const LoadState *S, size_t size, const char *tname) {
if (loadByte(S) != size)
error(S, luaO_pushfstring(S->L, "%s size mismatch", tname));
}
@@ -273,7 +273,7 @@ static void fchecksize (LoadState *S, size_t size, const char *tname) {
#define checksize(S,t) fchecksize(S,sizeof(t),#t)
-static void checkHeader (LoadState *S) {
+static void checkHeader (const LoadState *S) {
/* skip 1st char (already read and checked) */
checkliteral(S, &LUA_SIGNATURE[1], "not a binary chunk");
if (loadInt(S) != LUAC_VERSION)
diff --git a/src/lvm.c b/src/lvm.c
index e7781db..4eb8b2e 100644
--- a/src/lvm.c
+++ b/src/lvm.c
@@ -781,7 +781,7 @@ lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) {
** create a new Lua closure, push it in the stack, and initialize
** its upvalues.
*/
-static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
+static void pushclosure (lua_State *L, Proto *p, UpVal * const *encup, StkId base,
StkId ra) {
int nup = p->sizeupvalues;
Upvaldesc *uv = p->upvalues;
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment