display lua warnings instead of ignoring them
This will be an annoyance for wizard mode until someone actually figures out and fixes the problem. The complaints from lua during garbage collection aren't new, they were just being ignored before.
This commit is contained in:
@@ -911,6 +911,11 @@ using a marker to write "novel" or "paperback book" on a known blank spellbook
|
||||
was producing a randomly chosen Pratchett novel; make it fail instead
|
||||
when a monster killed a pudding and it left a glob, that glob might not be
|
||||
displayed on the map (wasn't an issue for killed-by-hero case)
|
||||
lua's garbage collection doesn't like the way nethack is trying to use it and
|
||||
issues a pair of warnings each time the relevant code gets run; they
|
||||
were vanishing into a bit bucket but now they will be displayed when
|
||||
running in wizard mode; we need to fix the usage rather than just
|
||||
hide the feedback
|
||||
|
||||
|
||||
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
|
||||
|
||||
30
src/nhlua.c
30
src/nhlua.c
@@ -2273,6 +2273,32 @@ nhl_panic(lua_State *L)
|
||||
return 0; /* return to Lua to abort */
|
||||
}
|
||||
|
||||
/* called when lua issues a warning message; the text of the message
|
||||
is passed to us in pieces across multiple function calls */
|
||||
static void
|
||||
nhl_warn(
|
||||
void *userdata UNUSED,
|
||||
const char *msg_fragment,
|
||||
int to_be_continued) /* 0: last fragment; 1: more to come */
|
||||
{
|
||||
static char warnbuf[BUFSZ];
|
||||
size_t fraglen, buflen = strlen(warnbuf);
|
||||
|
||||
if (msg_fragment && buflen < sizeof warnbuf - 1) {
|
||||
fraglen = strlen(msg_fragment);
|
||||
if (buflen + fraglen > sizeof warnbuf - 1)
|
||||
fraglen = sizeof warnbuf - 1 - buflen;
|
||||
(void) strncat(warnbuf, msg_fragment, fraglen);
|
||||
}
|
||||
if (!to_be_continued) {
|
||||
/* this is a warning so probably ought to be delivered via
|
||||
impossible() but until the current garbage collection issue
|
||||
gets fixed that would be way too verbose */
|
||||
pline("[lua] %s", warnbuf);
|
||||
warnbuf[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NHL_SANDBOX
|
||||
static void
|
||||
nhl_hookfn(lua_State *L, lua_Debug *ar UNUSED)
|
||||
@@ -2311,7 +2337,9 @@ nhlL_newstate(nhl_sandbox_info *sbi)
|
||||
|
||||
lua_atpanic(L, nhl_panic);
|
||||
#if LUA_VERSION_NUM == 504
|
||||
lua_setwarnf(L, (lua_WarnFunction) 0, L);
|
||||
/* issue lua warnings only when in wizard mode, at least until
|
||||
someone figures out and fixes the garbage collection problem */
|
||||
lua_setwarnf(L, wizard ? nhl_warn : (lua_WarnFunction) 0, L);
|
||||
#endif
|
||||
|
||||
#ifdef NHL_SANDBOX
|
||||
|
||||
Reference in New Issue
Block a user