From a3f500cd3ef0b4b333cc3bf403c64995dea33d5f Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 24 Jun 2024 12:21:00 +0200 Subject: Having luaG_tostring return a non-empty string_view on non-string values was a bad idea --- src/compat.h | 2 +- src/intercopycontext.cpp | 2 +- src/lindafactory.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compat.h b/src/compat.h index 7049f3d..41c8ea9 100644 --- a/src/compat.h +++ b/src/compat.h @@ -328,7 +328,7 @@ template { size_t _len{ 0 }; char const* _str{ lua_tolstring(L_, idx_, &_len) }; - return _str ? std::string_view{ _str, _len } : ""; + return _str ? std::string_view{ _str, _len } : ""; } [[nodiscard]] inline std::string_view luaG_checkstring(lua_State* const L_, int const idx_) diff --git a/src/intercopycontext.cpp b/src/intercopycontext.cpp index 85c1ebb..4d3aaac 100644 --- a/src/intercopycontext.cpp +++ b/src/intercopycontext.cpp @@ -1326,7 +1326,7 @@ namespace { STACK_CHECK(L2, n_ + 1); // Remove the cache table. Persistent caching would cause i.e. multiple // messages passed in the same table to use the same table also in receiving end. - lua_remove(L2, _top_L2 + 1); // L2: ... {}n + lua_remove(L2, _c.L2_cache_i); // L2: ... {}n return InterCopyResult::Success; } diff --git a/src/lindafactory.cpp b/src/lindafactory.cpp index 771a4c3..d5ebc9b 100644 --- a/src/lindafactory.cpp +++ b/src/lindafactory.cpp @@ -105,7 +105,7 @@ std::string_view LindaFactory::moduleName() const DeepPrelude* LindaFactory::newDeepObjectInternal(lua_State* const L_) const { // we always expect name and group at the bottom of the stack (either can be nil). any extra stuff we ignore and keep unmodified - std::string_view _linda_name{ lua_isnil(L_, 1) ? "" : luaG_tostring(L_, 1) }; + std::string_view _linda_name{ luaG_tostring(L_, 1) }; LindaGroup _linda_group{ static_cast(lua_tointeger(L_, 2)) }; // store in the linda the location of the script that created it -- cgit v1.2.3-55-g6feb