From d7494964a3a32de5969b1fd907c9bfcad8072adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Wed, 28 Jan 2015 14:17:37 +0100 Subject: [PATCH] Fix format_signature for zero-argument functions. E.g. void f() has only one signature element (void) but the following string 1 * 2 + 3 = % string elements: < > <(> <)>. Thus, 3 instead of 2 must be added to the n argument for concat in case of zero-argument functions. Found while fixing #25. --- luabind/detail/format_signature.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/luabind/detail/format_signature.hpp b/luabind/detail/format_signature.hpp index 22922535..e0b53e79 100644 --- a/luabind/detail/format_signature.hpp +++ b/luabind/detail/format_signature.hpp @@ -138,8 +138,9 @@ void format_signature(lua_State* L, char const* function, Signature) , typename mpl::end::type() ); lua_pushliteral(L, ")"); - - lua_concat(L, static_cast(mpl::size()) * 2 + 2); + int const signature_len = static_cast(mpl::size()); + lua_concat(L, signature_len * 2 + (signature_len == 1 ? + 3 /* zero-argument function: account for ')' */ : 2)); } }} // namespace luabind::detail