]> granicus.if.org Git - nethack/commitdiff
USE_OLDARGS update (3 of 2 :-)
authorPatR <rankin@nethack.org>
Thu, 3 Aug 2017 23:31:55 +0000 (16:31 -0700)
committerPatR <rankin@nethack.org>
Thu, 3 Aug 2017 23:31:55 +0000 (16:31 -0700)
Handle the few variadic calls in pline.c a better way.

include/sp_lev.h
include/tradstdc.h
src/pline.c

index 9befcd6694c675a7f47ccd19e18e4e4c705b6c2b..da6424c561361377383fa663fe28ab25785dbf74 100644 (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                          */
 /* 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
index ddd7d20374aff932887d7cbc9358479b8ed317b2..8ab152b5267b00c013f14bd976a58362254b97d2 100644 (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. */
 /* NetHack may be freely redistributed.  See license for details. */
 
 #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
 #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
 
index 745385ada109200ad1c0438e46a16054fe7f1b19..07e55e67934624c9ec9d815780f9bdf9044eb058 100644 (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. */
 /* 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__) */