Make the variadic functions look more like ordinary code rather than
have the function opening brace be hidden inside the VA_DECL() macro.
That brace is still there, but VA_DECL() now needs to be followed by
a visible brace (which introduces a nested block rather than the
start of the funciton). VA_END() now provides a hidden closing brace
to end the nested block, and the existing closing brace still matches
the one in VA_DECL().
Sample usage:
void foo VA_DECL(int, arg) --macro expansion has a hidden opening brace
{ --new, explicit opening brace (actually introduces a nested block)
VA_START(bar);
...code for foo...
VA_END(); --expansion now provides a closing brace for the nested block
} --existing closing brace, still pairs with the hidden one in VA_DECL()
This should help if/when another round of reformatting ever takes place,
and also with editors or other tools that do brace/bracket/parenthesis
matching.
I had forgotten that there were variadic functions in sys/* and ended
up modifying a lot more files than intended. The majority of changes
to those just inserted a new '{' line so that revised VA_END()'s '}'
won't introduce a syntax error. A couple of them needed VA_END() moved
so that local variables wouldn't go out of scope too soon. Only the
Unix ones have been tested.
66 lines
1.5 KiB
C
66 lines
1.5 KiB
C
/* NetHack 3.6 panic.c $NHDT-Date: 1431737058 2015/05/16 00:44:18 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
|
|
/* NetHack 3.6 panic.c $Date: 2009/05/06 10:54:39 $ $Revision: 1.4 $ */
|
|
/* SCCS Id: @(#)panic.c 3.5 1994/03/02 */
|
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
/*
|
|
* This code was adapted from the code in end.c to run in a standalone
|
|
* mode for the makedefs / drg code.
|
|
*/
|
|
|
|
#define NEED_VARARGS
|
|
#include "config.h"
|
|
|
|
#ifdef AZTEC
|
|
#define abort() exit()
|
|
#endif
|
|
#ifdef VMS
|
|
extern void NDECL(vms_abort);
|
|
#endif
|
|
|
|
/*VARARGS1*/
|
|
boolean panicking;
|
|
void VDECL(panic, (char *, ...));
|
|
|
|
void panic
|
|
VA_DECL(char *, str)
|
|
{
|
|
VA_START(str);
|
|
VA_INIT(str, char *);
|
|
if (panicking++)
|
|
#ifdef SYSV
|
|
(void)
|
|
#endif
|
|
abort(); /* avoid loops - this should never happen*/
|
|
|
|
(void) fputs(" ERROR: ", stderr);
|
|
Vfprintf(stderr, str, VA_ARGS);
|
|
(void) fflush(stderr);
|
|
#if defined(UNIX) || defined(VMS)
|
|
#ifdef SYSV
|
|
(void)
|
|
#endif
|
|
abort(); /* generate core dump */
|
|
#endif
|
|
VA_END();
|
|
exit(EXIT_FAILURE); /* redundant */
|
|
return;
|
|
}
|
|
|
|
#ifdef ALLOCA_HACK
|
|
/*
|
|
* In case bison-generated foo_yacc.c tries to use alloca(); if we don't
|
|
* have it then just use malloc() instead. This may not work on some
|
|
* systems, but they should either use yacc or get a real alloca routine.
|
|
*/
|
|
long *
|
|
alloca(cnt)
|
|
unsigned cnt;
|
|
{
|
|
return cnt ? alloc(cnt) : (long *) 0;
|
|
}
|
|
#endif
|
|
|
|
/*panic.c*/
|