Skip to content
Browse files

A couple of tidy ups regarding strings

  • Loading branch information...
1 parent 1b6558e commit c7989bae5c42f49c7086a43c5cab8f40c4be5d0a @nickgammon committed
Showing with 7 additions and 3 deletions.
  1. +1 −1 Utilities.cpp
  2. +6 −2 scripting/lua_scripting.cpp
View
2 Utilities.cpp
@@ -1532,7 +1532,7 @@ void MakeTableItem (lua_State *L, const char * name, const CString & str)
void MakeTableItem (lua_State *L, const char * name, const string & str)
{
lua_pushstring (L, name);
- lua_pushstring (L, str.c_str ());
+ lua_pushlstring (L, str.c_str (), str.size ());
lua_rawset(L, -3);
}
View
8 scripting/lua_scripting.cpp
@@ -470,7 +470,8 @@ bool CScriptEngine::ExecuteLua (DISPID & dispid, // dispatch ID, will be set to
for (i = 0; i <= ncapt; i++)
{
- lua_pushstring(L, regexp->GetWildcard (i).c_str ());
+ string wildcard (regexp->GetWildcard (i));
+ lua_pushlstring (L, wildcard.c_str (), wildcard.size ());
lua_rawseti (L, -2, i);
}
@@ -508,7 +509,10 @@ bool CScriptEngine::ExecuteLua (DISPID & dispid, // dispatch ID, will be set to
lua_pushstring (L, (LPCTSTR) name);
if (n >= 0 && n <= ncapt)
- lua_pushstring(L, regexp->GetWildcard (n).c_str ());
+ {
+ string wildcard (regexp->GetWildcard (n));
+ lua_pushlstring (L, wildcard.c_str (), wildcard.size ());
+ }
else
lua_pushnil (L); /* n out of range */
lua_settable (L, -3);

0 comments on commit c7989ba

Please sign in to comment.
Something went wrong with that request. Please try again.