OSDN Git Service

shrink mine
[nethackexpress/trunk.git] / util / panic.c
1 /*      SCCS Id: @(#)panic.c    3.4     1994/03/02      */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 /*
6  *      This code was adapted from the code in end.c to run in a standalone
7  *      mode for the makedefs / drg code.
8  */
9
10 #define NEED_VARARGS
11 #include "config.h"
12
13 #ifdef AZTEC
14 #define abort() exit()
15 #endif
16 #ifdef VMS
17 extern void NDECL(vms_abort);
18 #endif
19
20 /*VARARGS1*/
21 boolean panicking;
22 void VDECL(panic, (char *,...));
23
24 void
25 panic VA_DECL(char *,str)
26         VA_START(str);
27         VA_INIT(str, char *);
28         if(panicking++)
29 #ifdef SYSV
30             (void)
31 #endif
32                 abort();    /* avoid loops - this should never happen*/
33
34         (void) fputs(" ERROR:  ", stderr);
35         Vfprintf(stderr, str, VA_ARGS);
36         (void) fflush(stderr);
37 #if defined(UNIX) || defined(VMS)
38 # ifdef SYSV
39                 (void)
40 # endif
41                     abort();    /* generate core dump */
42 #endif
43         VA_END();
44         exit(EXIT_FAILURE);             /* redundant */
45         return;
46 }
47
48 #ifdef ALLOCA_HACK
49 /*
50  * In case bison-generated foo_yacc.c tries to use alloca(); if we don't
51  * have it then just use malloc() instead.  This may not work on some
52  * systems, but they should either use yacc or get a real alloca routine.
53  */
54 long *alloca(cnt)
55 unsigned cnt;
56 {
57         return cnt ? alloc(cnt) : (long *)0;
58 }
59 #endif
60
61 /*panic.c*/