impossible fix - potentially invalid feedback
From a bug report, the message displayed to the screen by impossible() might be different from the one written into paniclog, if it had argument subsitution/formatting. I couldn't reproduce that myself, but stdarg.h/varargs.h is tricky stuff and I think that passing the va_list to a routine which steps through it requires that va_start be called again if you're going to use the va_list a second time. This changes impossible() to handle its arguments only once, like panic().
This commit is contained in:
@@ -847,6 +847,7 @@ when a monster zapped by polymorph drops inventory because of its new form,
|
|||||||
entering an untended shop while blind gave an inappropriate message
|
entering an untended shop while blind gave an inappropriate message
|
||||||
engraving feedback about partial text when weapon became too dull to finish
|
engraving feedback about partial text when weapon became too dull to finish
|
||||||
was lacking sentence-ending period
|
was lacking sentence-ending period
|
||||||
|
impossible() might display inaccurate feedback after updating paniclog
|
||||||
|
|
||||||
|
|
||||||
Platform- and/or Interface-Specific Fixes
|
Platform- and/or Interface-Specific Fixes
|
||||||
|
|||||||
+7
-7
@@ -302,17 +302,17 @@ raw_printf VA_DECL(const char *, line)
|
|||||||
/*VARARGS1*/
|
/*VARARGS1*/
|
||||||
void
|
void
|
||||||
impossible VA_DECL(const char *, s)
|
impossible VA_DECL(const char *, s)
|
||||||
|
char pbuf[2*BUFSZ];
|
||||||
VA_START(s);
|
VA_START(s);
|
||||||
VA_INIT(s, const char *);
|
VA_INIT(s, const char *);
|
||||||
if (program_state.in_impossible)
|
if (program_state.in_impossible)
|
||||||
panic("impossible called impossible");
|
panic("impossible called impossible");
|
||||||
|
|
||||||
program_state.in_impossible = 1;
|
program_state.in_impossible = 1;
|
||||||
{
|
Vsprintf(pbuf, s, VA_ARGS);
|
||||||
char pbuf[BUFSZ];
|
pbuf[BUFSZ-1] = '\0'; /* sanity */
|
||||||
Vsprintf(pbuf,s,VA_ARGS);
|
paniclog("impossible", pbuf);
|
||||||
paniclog("impossible", pbuf);
|
pline("%s", pbuf);
|
||||||
}
|
|
||||||
vpline(s,VA_ARGS);
|
|
||||||
pline("Program in disorder - perhaps you'd better #quit.");
|
pline("Program in disorder - perhaps you'd better #quit.");
|
||||||
program_state.in_impossible = 0;
|
program_state.in_impossible = 0;
|
||||||
VA_END();
|
VA_END();
|
||||||
|
|||||||
Reference in New Issue
Block a user