USE_OLDARGS update (3 of 2 :-)

Handle the few variadic calls in pline.c a better way.
This commit is contained in:
PatR
2017-08-03 16:31:55 -07:00
parent 3b675c5b49
commit b90c5d5c4f
3 changed files with 14 additions and 18 deletions
+2 -1
View File
@@ -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 */ /* Copyright (c) 1989 by Jean-Christophe Collet */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -490,6 +490,7 @@ typedef const char *vA;
#endif #endif
#undef VA_ARGS /* redefine with the maximum number actually used */ #undef VA_ARGS /* redefine with the maximum number actually used */
#undef VA_SHIFT /* ditto */ #undef VA_SHIFT /* ditto */
#undef VA_PASS1
#define VA_ARGS \ #define VA_ARGS \
arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, \ arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, \
arg12, arg13, arg14 arg12, arg13, arg14
+6 -1
View File
@@ -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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -100,6 +100,7 @@
#define VA_END() \ #define VA_END() \
va_end(the_args); \ va_end(the_args); \
} }
#define VA_PASS1(a1) a1
#if defined(ULTRIX_PROTO) && !defined(_VA_LIST_) #if defined(ULTRIX_PROTO) && !defined(_VA_LIST_)
#define _VA_LIST_ /* prevents multiple def in stdio.h */ #define _VA_LIST_ /* prevents multiple def in stdio.h */
#endif #endif
@@ -125,6 +126,7 @@
#define VA_END() \ #define VA_END() \
va_end(the_args); \ va_end(the_args); \
} }
#define VA_PASS1(a1) a1
#else #else
/*USE_OLDARGS*/ /*USE_OLDARGS*/
@@ -162,6 +164,9 @@ typedef const char *vA;
arg6 = arg7, arg7 = arg8, arg8 = arg9, arg9 = 0) arg6 = arg7, arg7 = arg8, arg8 = arg9, arg9 = 0)
#define VA_NEXT(var1, typ1) ((var1 = (typ1) arg1), VA_SHIFT(), var1) #define VA_NEXT(var1, typ1) ((var1 = (typ1) arg1), VA_SHIFT(), var1)
#define VA_END() } #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
#endif #endif
+6 -16
View File
@@ -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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -435,18 +435,8 @@ VA_DECL(const char *, s)
Vsprintf(pbuf, s, VA_ARGS); Vsprintf(pbuf, s, VA_ARGS);
pbuf[BUFSZ - 1] = '\0'; /* sanity */ pbuf[BUFSZ - 1] = '\0'; /* sanity */
paniclog("impossible", pbuf); paniclog("impossible", pbuf);
#ifndef USE_OLDARGS pline("%s", VA_PASS1(pbuf));
#define DUMMY_PLINE_ARGS /*empty*/ pline("%s", VA_PASS1("Program in disorder - perhaps you'd better #quit."));
#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
program_state.in_impossible = 0; program_state.in_impossible = 0;
VA_END(); VA_END();
} }
@@ -478,16 +468,16 @@ const char *line;
(void) setuid(getuid()); (void) setuid(getuid());
(void) execv(args[0], (char *const *) args); (void) execv(args[0], (char *const *) args);
perror((char *) 0); perror((char *) 0);
(void) fprintf(stderr, "Exec to message handler %s failed.\n", (void) fprintf(stderr, "Exec to message handler %s failed.\n", env);
env);
terminate(EXIT_FAILURE); terminate(EXIT_FAILURE);
} else if (f > 0) { } else if (f > 0) {
int status; int status;
waitpid(f, &status, 0); waitpid(f, &status, 0);
} else if (f == -1) { } else if (f == -1) {
perror((char *) 0); perror((char *) 0);
use_pline_handler = FALSE; 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__) */ #endif /* defined(POSIX_TYPES) || defined(__GNUC__) */