fixed segfault by correcting indexes for recursively printing tables
git-svn-id: svn://anubis/anaglym/trunk@7 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
6686404032
commit
689349d2b6
12
ag.cc
12
ag.cc
@ -21,11 +21,13 @@ namespace ag
|
||||
switch (type)
|
||||
{
|
||||
case LUA_TNUMBER:
|
||||
cout << lua_tonumber(L, index);
|
||||
break;
|
||||
case LUA_TSTRING:
|
||||
cout << lua_tostring(L, index);
|
||||
break;
|
||||
case LUA_TTABLE:
|
||||
cout << '[';
|
||||
cout << "{ ";
|
||||
|
||||
/* traverse the table and print the keys/values */
|
||||
lua_checkstack(L, 3);
|
||||
@ -34,13 +36,15 @@ namespace ag
|
||||
{
|
||||
if (!first)
|
||||
cout << ", ";
|
||||
ag_print_val(L, -2);
|
||||
cout << '[';
|
||||
ag_print_val(L, index + 1);
|
||||
cout << ']';
|
||||
cout << " => ";
|
||||
ag_print_val(L, -1);
|
||||
ag_print_val(L, index + 2);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
cout << ']';
|
||||
cout << " }";
|
||||
break;
|
||||
case LUA_TFUNCTION:
|
||||
cout << "<function>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user