fix parser bug

This commit is contained in:
fesily 2024-02-22 11:09:38 +08:00
parent 32d892111d
commit a3ce7c53cb
3 changed files with 13 additions and 11 deletions

View File

@ -37,7 +37,7 @@ option(LUAJIT_DISABLE_JIT "Disable JIT." OFF)
option(LUAJIT_CPU_SSE2 "Use SSE2 instead of x87 instructions." ON)
option(LUAJIT_CPU_NOCMOV "Disable NOCMOV." OFF)
option(LUAJIT_DISABLE_GC64 "Disable GC64" OFF)
option(LUAJIT_ENABLE_FSANITIZE "Enable fsanitize" ON)
option(LUAJIT_ENABLE_FSANITIZE "Enable fsanitize" OFF)
option(LUAJIT_NUMMODE "num mode" 2)
MARK_AS_ADVANCED(LUAJIT_DISABLE_FFI LUAJIT_ENABLE_LUA52COMPAT
LUAJIT_DISABLE_GC64

View File

@ -231,19 +231,21 @@ LUALIB_API int luaL_loadbuffer(lua_State *L, const char *buf, size_t size,
{
#if LJ_DS_LOADBUFFER_PATCH
if (buf != name){
if (lj_path_map){
const char* real_path = lj_path_map(name);
if (real_path){
if (name[0] != '@'){
if (lj_path_map){
const char* real_path = lj_path_map(name);
if (real_path){
char path[260];
snprintf(path, 260, "@%s", real_path);
return luaL_loadbufferx(L, buf, size, path, NULL);
}
}
if (strncmp(name, "scripts/", sizeof("scripts/") -1) == 0) {
char path[260];
snprintf(path, 260, "@%s", real_path);
snprintf(path, 260, "@%s", name);
return luaL_loadbufferx(L, buf, size, path, NULL);
}
}
if (strncmp(name, "scripts/", sizeof("scripts/") -1) == 0) {
char path[260];
snprintf(path, 260, "@%s", name);
return luaL_loadbufferx(L, buf, size, path, NULL);
}
}
#endif
return luaL_loadbufferx(L, buf, size, name, NULL);

View File

@ -1133,7 +1133,7 @@ static MSize var_lookup_(FuncState *fs, GCstr *name, ExpDesc *e, int first)
if ((int32_t)reg >= 0) { /* Local in this function? */
expr_init(e, VLOCAL, reg);
#if LUA_COMPAT_VARARG
if (!fs->need_vararg && fs->flags & PROTO_VARARG && reg == 0){
if (!fs->need_vararg && fs->flags & PROTO_VARARG){
if (name->len == (sizeof("arg") - 1) && strncmp(strdata(name), "arg", name->len) == 0){
fs->need_vararg = 1;
}