mirror of
https://github.com/lua/lua
synced 2025-02-16 21:23:58 +03:00
new lua function "getstack"; new interface to function luaI_reportbug.
This commit is contained in:
parent
18ea2eff80
commit
ec79f25286
26
inout.c
26
inout.c
@ -5,7 +5,7 @@
|
||||
** Also provides some predefined lua functions.
|
||||
*/
|
||||
|
||||
char *rcs_inout="$Id: inout.c,v 2.18 1995/03/17 20:42:20 roberto Exp roberto $";
|
||||
char *rcs_inout="$Id: inout.c,v 2.19 1995/05/02 18:43:03 roberto Exp roberto $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -19,6 +19,14 @@ char *rcs_inout="$Id: inout.c,v 2.18 1995/03/17 20:42:20 roberto Exp roberto $";
|
||||
#include "tree.h"
|
||||
#include "lua.h"
|
||||
|
||||
|
||||
#ifndef MAXFUNCSTACK
|
||||
#define MAXFUNCSTACK 100
|
||||
#endif
|
||||
|
||||
#define MAXMESSAGE MAXFUNCSTACK*80
|
||||
|
||||
|
||||
/* Exported variables */
|
||||
Word lua_linenumber;
|
||||
Bool lua_debug;
|
||||
@ -145,10 +153,12 @@ void lua_popfunction (void)
|
||||
}
|
||||
|
||||
/*
|
||||
** Report bug building a message.
|
||||
** Report bug building a message and pushing it on the stack.
|
||||
*/
|
||||
void luaI_reportbug (char *msg, int size)
|
||||
void luaI_reportbug (char *s, int err)
|
||||
{
|
||||
char msg[MAXMESSAGE];
|
||||
strcpy (msg, s);
|
||||
if (lua_debugline != 0)
|
||||
{
|
||||
if (funcStack)
|
||||
@ -163,7 +173,7 @@ void luaI_reportbug (char *msg, int size)
|
||||
lua_constant[func->function]->str, func->file, line);
|
||||
line = func->line;
|
||||
func = func->next;
|
||||
lua_popfunction();
|
||||
if (err) lua_popfunction();
|
||||
} while (func);
|
||||
}
|
||||
else
|
||||
@ -173,6 +183,7 @@ void luaI_reportbug (char *msg, int size)
|
||||
lua_debugline, lua_filename());
|
||||
}
|
||||
}
|
||||
lua_pushstring(msg);
|
||||
}
|
||||
|
||||
|
||||
@ -288,3 +299,10 @@ void luaI_error (void)
|
||||
lua_error(s);
|
||||
}
|
||||
|
||||
void luaI_getstack (void)
|
||||
{
|
||||
char *s = lua_getstring(lua_getparam(1));
|
||||
if (s == NULL) s = "";
|
||||
luaI_reportbug(s, 0);
|
||||
}
|
||||
|
||||
|
8
inout.h
8
inout.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: inout.h,v 1.7 1994/12/20 21:20:36 roberto Exp roberto $
|
||||
** $Id: inout.h,v 1.8 1995/05/02 18:43:03 roberto Exp roberto $
|
||||
*/
|
||||
|
||||
|
||||
@ -8,9 +8,6 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifndef MAXFUNCSTACK
|
||||
#define MAXFUNCSTACK 100
|
||||
#endif
|
||||
|
||||
extern Word lua_linenumber;
|
||||
extern Bool lua_debug;
|
||||
@ -22,13 +19,14 @@ char *lua_openstring (char *s);
|
||||
void lua_closestring (void);
|
||||
void lua_pushfunction (char *file, Word function);
|
||||
void lua_popfunction (void);
|
||||
void luaI_reportbug (char *s, int size);
|
||||
void luaI_reportbug (char *s, int err);
|
||||
|
||||
void lua_internaldofile (void);
|
||||
void lua_internaldostring (void);
|
||||
void lua_print (void);
|
||||
void luaI_type (void);
|
||||
void lua_obj2number (void);
|
||||
void luaI_getstack (void);
|
||||
void luaI_error (void);
|
||||
|
||||
#endif
|
||||
|
8
opcode.c
8
opcode.c
@ -3,7 +3,7 @@
|
||||
** TecCGraf - PUC-Rio
|
||||
*/
|
||||
|
||||
char *rcs_opcode="$Id: opcode.c,v 3.36 1995/04/11 17:56:30 celes Exp roberto $";
|
||||
char *rcs_opcode="$Id: opcode.c,v 3.37 1995/05/02 18:43:03 roberto Exp roberto $";
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <stdlib.h>
|
||||
@ -68,14 +68,10 @@ Object *luaI_Address (lua_Object o)
|
||||
** Error messages
|
||||
*/
|
||||
|
||||
#define MAXMESSAGE MAXFUNCSTACK*80
|
||||
|
||||
static void lua_message (char *s)
|
||||
{
|
||||
char msg[MAXMESSAGE];
|
||||
strcpy (msg, s);
|
||||
luaI_reportbug(msg, MAXMESSAGE-strlen(s));
|
||||
lua_pushstring(msg);
|
||||
luaI_reportbug(s, 1);
|
||||
do_call(&luaI_fallBacks[FB_ERROR].function, (top-stack)-1, 0, (top-stack)-1);
|
||||
}
|
||||
|
||||
|
4
table.c
4
table.c
@ -3,7 +3,7 @@
|
||||
** Module to control static tables
|
||||
*/
|
||||
|
||||
char *rcs_table="$Id: table.c,v 2.28 1995/01/18 20:15:54 celes Exp roberto $";
|
||||
char *rcs_table="$Id: table.c,v 2.29 1995/05/02 18:43:03 roberto Exp roberto $";
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -68,6 +68,8 @@ static void lua_initsymbol (void)
|
||||
s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = lua_internaldostring;
|
||||
n = luaI_findsymbolbyname("setfallback");
|
||||
s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = luaI_setfallback;
|
||||
n = luaI_findsymbolbyname("getstack");
|
||||
s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = luaI_getstack;
|
||||
n = luaI_findsymbolbyname("error");
|
||||
s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = luaI_error;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user