8 l_stack_dump (const char *prefix
, lua_State
*l
)
11 int top
= lua_gettop(l
);
13 char *e
= buf
+sizeof(buf
);
16 fprintf (stderr
, "%s--- stack ---\n", prefix
);
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",
61 fprintf (stderr
, "%s%s\n", prefix
, buf
); /* end the listing */
63 fprintf (stderr
, "%s-------------\n", prefix
);