5 #include "lixp_debug.h"
8 l_stack_dump (lua_State
*l
)
11 int top
= lua_gettop(l
);
13 char *e
= buf
+sizeof(buf
);
16 fprintf (stderr
, "--- stack ---\n");
20 for (i
= 1; i
<= top
; i
++) { /* repeat for each level */
21 int t
= lua_type(l
, i
);
24 case LUA_TNIL
: /* nothing */
25 p
+= rc
= snprintf (p
, e
- p
, " NIL");
29 case LUA_TSTRING
: /* strings */
30 p
+= rc
= snprintf (p
, e
- p
, " `%s'",
35 case LUA_TBOOLEAN
: /* booleans */
36 p
+= rc
= snprintf (p
, e
-p
,
37 lua_toboolean(l
, i
) ? "true" : "false");
41 case LUA_TNUMBER
: /* numbers */
42 p
+= rc
= snprintf (p
, e
-p
, " %g",
47 case LUA_TTABLE
: /* table */
48 p
+= rc
= snprintf (p
, e
-p
, " table");
52 default: /* other values */
53 p
+= rc
= snprintf (p
, e
-p
, " %s",
60 fprintf (stderr
, "%s\n", buf
); /* end the listing */
62 fprintf (stderr
, "-------------\n");