aboutsummaryrefslogtreecommitdiff
path: root/src/tools.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools.cpp')
-rw-r--r--src/tools.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/tools.cpp b/src/tools.cpp
index 94e941d..e6dadd2 100644
--- a/src/tools.cpp
+++ b/src/tools.cpp
@@ -151,14 +151,12 @@ static void update_lookup_entry(lua_State* L_, int ctxBase_, int depth_)
151 std::string_view const _newName{ tools::PushFQN(L_, _fqn, depth_) }; // L_: ... {bfc} k o name? "f.q.n" 151 std::string_view const _newName{ tools::PushFQN(L_, _fqn, depth_) }; // L_: ... {bfc} k o name? "f.q.n"
152 // Lua 5.2 introduced a hash randomizer seed which causes table iteration to yield a different key order 152 // Lua 5.2 introduced a hash randomizer seed which causes table iteration to yield a different key order
153 // on different VMs even when the tables are populated the exact same way. 153 // on different VMs even when the tables are populated the exact same way.
154 // When Lua is built with compatibility options (such as LUA_COMPAT_ALL), 154 // Also, when Lua is built with compatibility options (such as LUA_COMPAT_ALL), some base libraries register functions under multiple names.
155 // this causes several base libraries to register functions under multiple names. 155 // This, with the randomizer, can cause the first generated name of an object to be different on different VMs, which breaks function transfer.
156 // This, with the randomizer, can cause the first generated name of an object to be different on different VMs,
157 // which breaks function transfer.
158 // Also, nothing prevents any external module from exposing a given object under several names, so... 156 // Also, nothing prevents any external module from exposing a given object under several names, so...
159 // Therefore, when we encounter an object for which a name was previously registered, we need to select the names 157 // Therefore, when we encounter an object for which a name was previously registered, we need to select the a single name
160 // based on some sorting order so that we end up with the same name in all databases whatever order the table walk yielded 158 // based on some sorting order so that we end up with the same name in all databases whatever order the table walk yielded
161 if (!_prevName.empty() && (_prevName.size() < _newName.size() || lua_lessthan(L_, -2, -1))) { 159 if (!_prevName.empty() && ((_prevName.size() < _newName.size()) || (_prevName <= _newName))) {
162 DEBUGSPEW_CODE(DebugSpew(_U) << lua_typename(L_, lua_type(L_, -3)) << " '" << _newName << "' remains named '" << _prevName << "'" << std::endl); 160 DEBUGSPEW_CODE(DebugSpew(_U) << lua_typename(L_, lua_type(L_, -3)) << " '" << _newName << "' remains named '" << _prevName << "'" << std::endl);
163 // the previous name is 'smaller' than the one we just generated: keep it! 161 // the previous name is 'smaller' than the one we just generated: keep it!
164 lua_pop(L_, 3); // L_: ... {bfc} k 162 lua_pop(L_, 3); // L_: ... {bfc} k