Codechange: use std::string_view for SQ stack and function info

This commit is contained in:
Rubidium
2025-05-03 19:15:35 +02:00
committed by rubidium42
parent 0bc773215e
commit d464961c41
4 changed files with 14 additions and 22 deletions

View File

@@ -48,13 +48,9 @@ SQInteger SquirrelStd::require(HSQUIRRELVM vm)
/* Get the script-name of the current file, so we can work relative from it */
SQStackInfos si;
sq_stackinfos(vm, 1, &si);
if (si.source == nullptr) {
Debug(misc, 0, "[squirrel] Couldn't detect the script-name of the 'require'-caller; this should never happen!");
return SQ_ERROR;
}
/* Keep the dir, remove the rest */
std::string path = si.source;
std::string path{si.source};
auto p = path.find_last_of(PATHSEPCHAR);
/* Keep the PATHSEPCHAR there, remove the rest */
if (p != std::string::npos) path.erase(p + 1);