File tree Expand file tree Collapse file tree 4 files changed +68
-16
lines changed
Expand file tree Collapse file tree 4 files changed +68
-16
lines changed Original file line number Diff line number Diff line change @@ -2522,14 +2522,27 @@ namespace LuaGlobalFunctions
25222522
25232523 static std::string GetStackAsString (Eluna* E)
25242524 {
2525- std::ostringstream oss ;
2525+ std::string output ;
25262526 int top = lua_gettop (E->L );
25272527 for (int i = 1 ; i <= top; ++i)
25282528 {
2529- oss << luaL_tolstring (E->L , i, NULL );
2530- lua_pop (E->L , 1 );
2529+ if (lua_isstring (E->L , i))
2530+ {
2531+ output += lua_tostring (E->L , i);
2532+ }
2533+ else
2534+ {
2535+ lua_getglobal (E->L , " tostring" );
2536+ lua_pushvalue (E->L , i);
2537+ lua_call (E->L , 1 , 1 );
2538+ output += lua_tostring (E->L , -1 );
2539+ lua_pop (E->L , 1 );
2540+ }
2541+
2542+ if (i < top)
2543+ output += " \t " ;
25312544 }
2532- return oss. str () ;
2545+ return output ;
25332546 }
25342547
25352548 /* *
Original file line number Diff line number Diff line change @@ -2279,14 +2279,27 @@ namespace LuaGlobalFunctions
22792279
22802280 static std::string GetStackAsString (Eluna* E)
22812281 {
2282- std::ostringstream oss ;
2282+ std::string output ;
22832283 int top = lua_gettop (E->L );
22842284 for (int i = 1 ; i <= top; ++i)
22852285 {
2286- oss << luaL_tolstring (E->L , i, NULL );
2287- lua_pop (E->L , 1 );
2286+ if (lua_isstring (E->L , i))
2287+ {
2288+ output += lua_tostring (E->L , i);
2289+ }
2290+ else
2291+ {
2292+ lua_getglobal (E->L , " tostring" );
2293+ lua_pushvalue (E->L , i);
2294+ lua_call (E->L , 1 , 1 );
2295+ output += lua_tostring (E->L , -1 );
2296+ lua_pop (E->L , 1 );
2297+ }
2298+
2299+ if (i < top)
2300+ output += " \t " ;
22882301 }
2289- return oss. str () ;
2302+ return output ;
22902303 }
22912304
22922305 /* *
Original file line number Diff line number Diff line change @@ -2404,14 +2404,27 @@ namespace LuaGlobalFunctions
24042404
24052405 static std::string GetStackAsString (Eluna* E)
24062406 {
2407- std::ostringstream oss ;
2407+ std::string output ;
24082408 int top = lua_gettop (E->L );
24092409 for (int i = 1 ; i <= top; ++i)
24102410 {
2411- oss << luaL_tolstring (E->L , i, NULL );
2412- lua_pop (E->L , 1 );
2411+ if (lua_isstring (E->L , i))
2412+ {
2413+ output += lua_tostring (E->L , i);
2414+ }
2415+ else
2416+ {
2417+ lua_getglobal (E->L , " tostring" );
2418+ lua_pushvalue (E->L , i);
2419+ lua_call (E->L , 1 , 1 );
2420+ output += lua_tostring (E->L , -1 );
2421+ lua_pop (E->L , 1 );
2422+ }
2423+
2424+ if (i < top)
2425+ output += " \t " ;
24132426 }
2414- return oss. str () ;
2427+ return output ;
24152428 }
24162429
24172430 /* *
Original file line number Diff line number Diff line change @@ -2222,14 +2222,27 @@ namespace LuaGlobalFunctions
22222222
22232223 static std::string GetStackAsString (Eluna* E)
22242224 {
2225- std::ostringstream oss ;
2225+ std::string output ;
22262226 int top = lua_gettop (E->L );
22272227 for (int i = 1 ; i <= top; ++i)
22282228 {
2229- oss << luaL_tolstring (E->L , i, NULL );
2230- lua_pop (E->L , 1 );
2229+ if (lua_isstring (E->L , i))
2230+ {
2231+ output += lua_tostring (E->L , i);
2232+ }
2233+ else
2234+ {
2235+ lua_getglobal (E->L , " tostring" );
2236+ lua_pushvalue (E->L , i);
2237+ lua_call (E->L , 1 , 1 );
2238+ output += lua_tostring (E->L , -1 );
2239+ lua_pop (E->L , 1 );
2240+ }
2241+
2242+ if (i < top)
2243+ output += " \t " ;
22312244 }
2232- return oss. str () ;
2245+ return output ;
22332246 }
22342247
22352248 /* *
You can’t perform that action at this time.
0 commit comments