util updates: lev_main.c and recover.c
Change lev_comp's add_opvars() to be like pline(), where there's a
single visible opening brace and a second one hidden in VA_DECL2
that introduces a nested block, plus a single visible closing brace
with a hidden one in VA_END() to close the nested block. This
addresses the erroneous report (sent directly to devteam, so no #H
number, subject "missing '{' in util/lev_main.c:634") that the code
for !USE_STDARG/!USE_VARARGS in add_opvars() wouldn't compile.
Also, fix the part of "#H5778: file descriptor leaks" dealing with
util/recover.c -- an open file not being closed after various errors.
I didn't take responsibility for this entry in the bugzilla list
since the report includes similar problems in other code that's not
addressed here.
And a blast from the past: some reformatting fixups in recover.c.
The most interesting bit is for a block of dead code....
This commit is contained in:
+9
-5
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 lev_main.c $NHDT-Date: 1448074107 2015/11/21 02:48:27 $ $NHDT-Branch: master $:$NHDT-Revision: 1.43 $ */
|
||||
/* NetHack 3.6 lev_main.c $NHDT-Date: 1501461281 2017/07/31 00:34:41 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.46 $ */
|
||||
/* Copyright (c) 1989 by Jean-Christophe Collet */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -615,14 +615,14 @@ VA_DECL2(sp_lev *, sp, const char *, fmt)
|
||||
#ifdef USE_STDARG
|
||||
static void
|
||||
vadd_opvars(sp_lev *sp, const char *fmt, va_list the_args)
|
||||
{
|
||||
|
||||
#else
|
||||
static void
|
||||
vadd_opvars(sp, fmt, the_args)
|
||||
sp_lev *sp;
|
||||
const char *fmt;
|
||||
va_list the_args;
|
||||
{
|
||||
|
||||
#endif
|
||||
|
||||
#else /* USE_STDARG | USE_VARARG */
|
||||
@@ -632,7 +632,7 @@ va_list the_args;
|
||||
void add_opvars
|
||||
VA_DECL2(sp_lev *, sp, const char *, fmt)
|
||||
#endif /* USE_STDARG | USE_VARARG */
|
||||
|
||||
{
|
||||
const char *p, *lp;
|
||||
long la;
|
||||
/* Do NOT use VA_START and VA_END in here... see above */
|
||||
@@ -710,7 +710,11 @@ VA_DECL2(sp_lev *, sp, const char *, fmt)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
#if !(defined(USE_STDARG) || defined(USE_VARARGS))
|
||||
/* provide closing brace for USE_OLDARGS nested block from VA_DECL2() */
|
||||
VA_END();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user