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_SSE2 "Use SSE2 instead of x87 instructions." ON)
option(LUAJIT_CPU_NOCMOV "Disable NOCMOV." OFF) option(LUAJIT_CPU_NOCMOV "Disable NOCMOV." OFF)
option(LUAJIT_DISABLE_GC64 "Disable GC64" 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) option(LUAJIT_NUMMODE "num mode" 2)
MARK_AS_ADVANCED(LUAJIT_DISABLE_FFI LUAJIT_ENABLE_LUA52COMPAT MARK_AS_ADVANCED(LUAJIT_DISABLE_FFI LUAJIT_ENABLE_LUA52COMPAT
LUAJIT_DISABLE_GC64 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 LJ_DS_LOADBUFFER_PATCH
if (buf != name){ if (buf != name){
if (lj_path_map){ if (name[0] != '@'){
const char* real_path = lj_path_map(name); if (lj_path_map){
if (real_path){ 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]; char path[260];
snprintf(path, 260, "@%s", real_path); snprintf(path, 260, "@%s", name);
return luaL_loadbufferx(L, buf, size, path, NULL); 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 #endif
return luaL_loadbufferx(L, buf, size, name, NULL); 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? */ if ((int32_t)reg >= 0) { /* Local in this function? */
expr_init(e, VLOCAL, reg); expr_init(e, VLOCAL, reg);
#if LUA_COMPAT_VARARG #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){ if (name->len == (sizeof("arg") - 1) && strncmp(strdata(name), "arg", name->len) == 0){
fs->need_vararg = 1; fs->need_vararg = 1;
} }