File: panic.c

package info (click to toggle)
nethack 3.6.7-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 21,468 kB
  • sloc: ansic: 266,495; cpp: 13,652; yacc: 2,903; perl: 1,426; lex: 581; sh: 535; xml: 372; awk: 98; makefile: 68; fortran: 51; sed: 11
file content (63 lines) | stat: -rw-r--r-- 1,459 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* NetHack 3.6	panic.c	$NHDT-Date: 1448210012 2015/11/22 16:33:32 $  $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2015. */
/* 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, (const char *, ...));

void panic
VA_DECL(const 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 */
}

#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*/