From 332983c97b7a729c4dc5f19aa9ee4a22c420f7d8 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Tue, 27 Jun 2023 20:23:44 +1000 Subject: The Formatting String Catastrophe --- source/core/StarLua.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source/core/StarLua.hpp') diff --git a/source/core/StarLua.hpp b/source/core/StarLua.hpp index 95b4499..9241ec4 100644 --- a/source/core/StarLua.hpp +++ b/source/core/StarLua.hpp @@ -1717,20 +1717,20 @@ T& LuaUserData::get() const { template void LuaCallbacks::registerCallback(String name, Function&& func) { if (!m_callbacks.insert(name, LuaDetail::wrapFunction(forward(func))).second) - throw LuaException::format("Lua callback '%s' was registered twice", name); + throw LuaException::format("Lua callback '{}' was registered twice", name); } template void LuaCallbacks::registerCallbackWithSignature(String name, Function&& func) { if (!m_callbacks.insert(name, LuaDetail::wrapFunctionWithSignature(forward(func))).second) - throw LuaException::format("Lua callback '%s' was registered twice", name); + throw LuaException::format("Lua callback '{}' was registered twice", name); } template template void LuaMethods::registerMethod(String name, Function&& func) { if (!m_methods.insert(name, LuaDetail::wrapMethod(forward(move(func)))).second) - throw LuaException::format("Lua method '%s' was registered twice", name); + throw LuaException::format("Lua method '{}' was registered twice", name); } template @@ -1738,7 +1738,7 @@ template void LuaMethods::registerMethodWithSignature(String name, Function&& func) { if (!m_methods.insert(name, LuaDetail::wrapMethodWithSignature(forward(move(func)))) .second) - throw LuaException::format("Lua method '%s' was registered twice", name); + throw LuaException::format("Lua method '{}' was registered twice", name); } template @@ -1766,7 +1766,7 @@ Ret LuaContext::invokePath(String const& key, Args const&... args) const { auto p = getPath(key); if (auto f = p.ptr()) return f->invoke(args...); - throw LuaException::format("invokePath called on path '%s' which is not function type", key); + throw LuaException::format("invokePath called on path '{}' which is not function type", key); } template @@ -1867,14 +1867,14 @@ template T LuaEngine::luaTo(LuaValue&& v) { if (auto res = luaMaybeTo(move(v))) return res.take(); - throw LuaConversionException::format("Error converting LuaValue to type '%s'", typeid(T).name()); + throw LuaConversionException::format("Error converting LuaValue to type '{}'", typeid(T).name()); } template T LuaEngine::luaTo(LuaValue const& v) { if (auto res = luaMaybeTo(v)) return res.take(); - throw LuaConversionException::format("Error converting LuaValue to type '%s'", typeid(T).name()); + throw LuaConversionException::format("Error converting LuaValue to type '{}'", typeid(T).name()); } template @@ -2089,7 +2089,7 @@ template T* LuaEngine::getUserData(int handleIndex) { int typeRef = m_registeredUserDataTypes.value(typeid(T), LUA_NOREF); if (typeRef == LUA_NOREF) - throw LuaException::format("Cannot convert userdata type of %s, not registered", typeid(T).name()); + throw LuaException::format("Cannot convert userdata type of {}, not registered", typeid(T).name()); lua_checkstack(m_state, 3); @@ -2103,7 +2103,7 @@ T* LuaEngine::getUserData(int handleIndex) { lua_rawgeti(m_state, LUA_REGISTRYINDEX, typeRef); if (!lua_rawequal(m_state, -1, -2)) { lua_pop(m_state, 3); - throw LuaException::format("Improper conversion from userdata to type %s", typeid(T).name()); + throw LuaException::format("Improper conversion from userdata to type {}", typeid(T).name()); } lua_pop(m_state, 3); -- cgit v1.2.3