USE_OLDARGS update (3 of 2 :-)
Handle the few variadic calls in pline.c a better way.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 sp_lev.h $NHDT-Date: 1501723399 2017/08/03 01:23:19 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.20 $ */
|
||||
/* NetHack 3.6 sp_lev.h $NHDT-Date: 1501803105 2017/08/03 23:31:45 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.21 $ */
|
||||
/* Copyright (c) 1989 by Jean-Christophe Collet */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -490,6 +490,7 @@ typedef const char *vA;
|
||||
#endif
|
||||
#undef VA_ARGS /* redefine with the maximum number actually used */
|
||||
#undef VA_SHIFT /* ditto */
|
||||
#undef VA_PASS1
|
||||
#define VA_ARGS \
|
||||
arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, \
|
||||
arg12, arg13, arg14
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 tradstdc.h $NHDT-Date: 1501723401 2017/08/03 01:23:21 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.28 $ */
|
||||
/* NetHack 3.6 tradstdc.h $NHDT-Date: 1501803107 2017/08/03 23:31:47 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.29 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
#define VA_END() \
|
||||
va_end(the_args); \
|
||||
}
|
||||
#define VA_PASS1(a1) a1
|
||||
#if defined(ULTRIX_PROTO) && !defined(_VA_LIST_)
|
||||
#define _VA_LIST_ /* prevents multiple def in stdio.h */
|
||||
#endif
|
||||
@@ -125,6 +126,7 @@
|
||||
#define VA_END() \
|
||||
va_end(the_args); \
|
||||
}
|
||||
#define VA_PASS1(a1) a1
|
||||
#else
|
||||
|
||||
/*USE_OLDARGS*/
|
||||
@@ -162,6 +164,9 @@ typedef const char *vA;
|
||||
arg6 = arg7, arg7 = arg8, arg8 = arg9, arg9 = 0)
|
||||
#define VA_NEXT(var1, typ1) ((var1 = (typ1) arg1), VA_SHIFT(), var1)
|
||||
#define VA_END() }
|
||||
/* needed in pline.c, where full number of arguments is known and expected */
|
||||
#define VA_PASS1(a1) \
|
||||
(vA) a1, (vA) 0, (vA) 0, (vA) 0, (vA) 0, (vA) 0, (vA) 0, (vA) 0, (vA) 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
22
src/pline.c
22
src/pline.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 pline.c $NHDT-Date: 1501725406 2017/08/03 01:56:46 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.60 $ */
|
||||
/* NetHack 3.6 pline.c $NHDT-Date: 1501803108 2017/08/03 23:31:48 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.61 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -435,18 +435,8 @@ VA_DECL(const char *, s)
|
||||
Vsprintf(pbuf, s, VA_ARGS);
|
||||
pbuf[BUFSZ - 1] = '\0'; /* sanity */
|
||||
paniclog("impossible", pbuf);
|
||||
#ifndef USE_OLDARGS
|
||||
#define DUMMY_PLINE_ARGS /*empty*/
|
||||
#else /* needed because we follow the definition of pline() itself;
|
||||
* passing 1 arg, pline takes 9 (for USE_OLDARGS) so add 8 dummies */
|
||||
#define DUMMY_PLINE_ARGS , (vA) 0, (vA) 0, (vA) 0, (vA) 0, \
|
||||
(vA) 0, (vA) 0, (vA) 0, (vA) 0
|
||||
#endif
|
||||
pline("%s", pbuf /* no comma here; when needed, it's in DUMMY_ARGS */
|
||||
DUMMY_PLINE_ARGS);
|
||||
pline("%s", "Program in disorder - perhaps you'd better #quit."
|
||||
DUMMY_PLINE_ARGS);
|
||||
#undef DUMMY_PLINE_ARGS
|
||||
pline("%s", VA_PASS1(pbuf));
|
||||
pline("%s", VA_PASS1("Program in disorder - perhaps you'd better #quit."));
|
||||
program_state.in_impossible = 0;
|
||||
VA_END();
|
||||
}
|
||||
@@ -478,16 +468,16 @@ const char *line;
|
||||
(void) setuid(getuid());
|
||||
(void) execv(args[0], (char *const *) args);
|
||||
perror((char *) 0);
|
||||
(void) fprintf(stderr, "Exec to message handler %s failed.\n",
|
||||
env);
|
||||
(void) fprintf(stderr, "Exec to message handler %s failed.\n", env);
|
||||
terminate(EXIT_FAILURE);
|
||||
} else if (f > 0) {
|
||||
int status;
|
||||
|
||||
waitpid(f, &status, 0);
|
||||
} else if (f == -1) {
|
||||
perror((char *) 0);
|
||||
use_pline_handler = FALSE;
|
||||
pline("Fork to message handler failed.");
|
||||
pline("%s", VA_PASS1("Fork to message handler failed."));
|
||||
}
|
||||
}
|
||||
#endif /* defined(POSIX_TYPES) || defined(__GNUC__) */
|
||||
|
||||
Reference in New Issue
Block a user