mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-01-07 07:22:49 +00:00
Fix substring bug in require() (#867)
Some checks failed
Build coop / build-linux (push) Has been cancelled
Build coop / build-steamos (push) Has been cancelled
Build coop / build-windows-opengl (push) Has been cancelled
Build coop / build-windows-directx (push) Has been cancelled
Build coop / build-macos-arm (push) Has been cancelled
Build coop / build-macos-intel (push) Has been cancelled
Some checks failed
Build coop / build-linux (push) Has been cancelled
Build coop / build-steamos (push) Has been cancelled
Build coop / build-windows-opengl (push) Has been cancelled
Build coop / build-windows-directx (push) Has been cancelled
Build coop / build-macos-arm (push) Has been cancelled
Build coop / build-macos-intel (push) Has been cancelled
* Fix substring bug in require()
When require() was searching for a matching module, it would only
consider the end of the filename. So foobar.lua and bar.lua could both
match a require('bar').
This commit fixes that.
* remove debug logs
---------
Co-authored-by: MysterD <myster@d>
This commit is contained in:
parent
c68ee859ea
commit
06e9c8aa2f
1 changed files with 5 additions and 3 deletions
|
|
@ -38,10 +38,12 @@ static struct ModFile* smlua_find_mod_file(const char* moduleName) {
|
|||
int bestTotalDepth = INT_MAX;
|
||||
bool foundRelativeFile = false;
|
||||
|
||||
char rawName[SYS_MAX_PATH] = "";
|
||||
char luaName[SYS_MAX_PATH] = "";
|
||||
char luacName[SYS_MAX_PATH] = "";
|
||||
snprintf(luaName, SYS_MAX_PATH, "%s.lua", moduleName);
|
||||
snprintf(luacName, SYS_MAX_PATH, "%s.luac", moduleName);
|
||||
snprintf(rawName, SYS_MAX_PATH, "/%s", moduleName);
|
||||
snprintf(luaName, SYS_MAX_PATH, "/%s.lua", moduleName);
|
||||
snprintf(luacName, SYS_MAX_PATH, "/%s.luac", moduleName);
|
||||
|
||||
for (int i = 0; i < gLuaActiveMod->fileCount; i++) {
|
||||
struct ModFile* file = &gLuaActiveMod->files[i];
|
||||
|
|
@ -57,7 +59,7 @@ static struct ModFile* smlua_find_mod_file(const char* moduleName) {
|
|||
}
|
||||
|
||||
// check for match
|
||||
if (!str_ends_with(file->relativePath, moduleName) && !str_ends_with(file->relativePath, luaName) && !str_ends_with(file->relativePath, luacName)) {
|
||||
if (!str_ends_with(file->relativePath, rawName) && !str_ends_with(file->relativePath, luaName) && !str_ends_with(file->relativePath, luacName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue