switch source tree from k&r to c99

This commit is contained in:
nhmall
2021-01-26 21:06:16 -05:00
parent a2a9cb7b4f
commit f963c5aca7
232 changed files with 12099 additions and 17782 deletions

152
src/end.c
View File

@@ -20,26 +20,26 @@
#define nowrap_add(a, b) (a = ((a + b) < 0 ? LONG_MAX : (a + b)))
#ifndef NO_SIGNAL
static void FDECL(done_intr, (int));
static void done_intr(int);
#if defined(UNIX) || defined(VMS) || defined(__EMX__)
static void FDECL(done_hangup, (int));
static void done_hangup(int);
#endif
#endif
static void FDECL(disclose, (int, BOOLEAN_P));
static void FDECL(get_valuables, (struct obj *));
static void FDECL(sort_valuables, (struct valuable_data *, int));
static void NDECL(done_object_cleanup);
static void FDECL(artifact_score, (struct obj *, BOOLEAN_P, winid));
static void FDECL(really_done, (int)) NORETURN;
static void FDECL(savelife, (int));
static boolean FDECL(should_query_disclose_option, (int, char *));
static void disclose(int, boolean);
static void get_valuables(struct obj *);
static void sort_valuables(struct valuable_data *, int);
static void done_object_cleanup(void);
static void artifact_score(struct obj *, boolean, winid);
static void really_done(int) NORETURN;
static void savelife(int);
static boolean should_query_disclose_option(int, char *);
#ifdef DUMPLOG
static void NDECL(dump_plines);
static void dump_plines(void);
#endif
static void FDECL(dump_everything, (int, time_t));
static void dump_everything(int, time_t);
#if defined(__BEOS__) || defined(MICRO) || defined(OS2) || defined(WIN32)
extern void FDECL(nethack_exit, (int)) NORETURN;
extern void nethack_exit(int) NORETURN;
#else
#define nethack_exit exit
#endif
@@ -94,19 +94,18 @@ extern void FDECL(nethack_exit, (int)) NORETURN;
#endif
#endif
static void NDECL(NH_abort);
static void NH_abort(void);
#ifndef NO_SIGNAL
static void FDECL(panictrace_handler, (int));
static void panictrace_handler(int);
#endif
static boolean NDECL(NH_panictrace_libc);
static boolean NDECL(NH_panictrace_gdb);
static boolean NH_panictrace_libc(void);
static boolean NH_panictrace_gdb(void);
#ifndef NO_SIGNAL
/* called as signal() handler, so sent at least one arg */
/*ARGUSED*/
void
panictrace_handler(sig_unused)
int sig_unused UNUSED;
panictrace_handler(int sig_unused UNUSED)
{
#define SIG_MSG "\nSignal received.\n"
int f2;
@@ -117,8 +116,7 @@ int sig_unused UNUSED;
}
void
panictrace_setsignals(set)
boolean set;
panictrace_setsignals(boolean set)
{
#define SETSIGNAL(sig) \
(void) signal(sig, set ? (SIG_RET_TYPE) panictrace_handler : SIG_DFL);
@@ -154,7 +152,7 @@ boolean set;
#endif /* NO_SIGNAL */
static void
NH_abort()
NH_abort(void)
{
int gdb_prio = SYSOPT_PANICTRACE_GDB;
int libc_prio = SYSOPT_PANICTRACE_LIBC;
@@ -190,7 +188,7 @@ NH_abort()
}
static boolean
NH_panictrace_libc()
NH_panictrace_libc(void)
{
#ifdef PANICTRACE_LIBC
void *bt[20];
@@ -229,7 +227,7 @@ NH_panictrace_libc()
#endif /* PANICTRACE_GDB */
static boolean
NH_panictrace_gdb()
NH_panictrace_gdb(void)
{
#ifdef PANICTRACE_GDB
/* A (more) generic method to get a stack trace - invoke
@@ -287,10 +285,10 @@ static NEARDATA const char *ends[] = {
static boolean Schroedingers_cat = FALSE;
/* called as signal() handler, so sent at least one arg */
/*ARGSUSED*/
void
done1(sig_unused) /* called as signal() handler, so sent at least one arg */
int sig_unused UNUSED;
done1(int sig_unused UNUSED)
{
#ifndef NO_SIGNAL
(void) signal(SIGINT, SIG_IGN);
@@ -311,7 +309,7 @@ int sig_unused UNUSED;
/* "#quit" command or keyboard interrupt */
int
done2()
done2(void)
{
if (iflags.debug_fuzzer)
return 0;
@@ -361,10 +359,10 @@ done2()
}
#ifndef NO_SIGNAL
/* called as signal() handler, so sent at least 1 arg */
/*ARGSUSED*/
static void
done_intr(sig_unused) /* called as signal() handler, so sent at least 1 arg */
int sig_unused UNUSED;
done_intr(int sig_unused UNUSED)
{
done_stopprint++;
(void) signal(SIGINT, SIG_IGN);
@@ -377,11 +375,10 @@ int sig_unused UNUSED;
#if defined(UNIX) || defined(VMS) || defined(__EMX__)
/* signal() handler */
static void
done_hangup(sig)
int sig;
done_hangup(int sig)
{
g.program_state.done_hup++;
sethanguphandler((void FDECL((*), (int) )) SIG_IGN);
sethanguphandler((void (*)(int)) SIG_IGN);
done_intr(sig);
return;
}
@@ -389,9 +386,7 @@ int sig;
#endif /* NO_SIGNAL */
void
done_in_by(mtmp, how)
struct monst *mtmp;
int how;
done_in_by(struct monst *mtmp, int how)
{
char buf[BUFSZ];
struct permonst *mptr = mtmp->data,
@@ -527,8 +522,7 @@ static const struct {
/* clear away while-helpless when the cause of death caused that
helplessness (ie, "petrified by <foo> while getting stoned") */
static void
fixup_death(how)
int how;
fixup_death(int how)
{
int i;
@@ -632,9 +626,7 @@ VA_DECL(const char *, str)
}
static boolean
should_query_disclose_option(category, defquery)
int category;
char *defquery;
should_query_disclose_option(int category, char *defquery)
{
int idx;
char disclose, *dop;
@@ -676,7 +668,7 @@ char *defquery;
#ifdef DUMPLOG
static void
dump_plines()
dump_plines(void)
{
int i, j;
char buf[BUFSZ], **strp;
@@ -699,9 +691,8 @@ dump_plines()
/*ARGSUSED*/
static void
dump_everything(how, when)
int how;
time_t when; /* date+time at end of game */
dump_everything(int how,
time_t when) /* date+time at end of game */
{
#ifdef DUMPLOG
char pbuf[BUFSZ], datetimebuf[24]; /* [24]: room for 64-bit bogus value */
@@ -769,9 +760,7 @@ time_t when; /* date+time at end of game */
}
static void
disclose(how, taken)
int how;
boolean taken;
disclose(int how, boolean taken)
{
char c = '\0', defquery;
char qbuf[QBUFSZ];
@@ -854,8 +843,7 @@ boolean taken;
/* try to get the player back in a viable state after being killed */
static void
savelife(how)
int how;
savelife(int how)
{
int uhpmin = max(2 * u.ulevel, 10);
@@ -902,8 +890,7 @@ int how;
* intact.
*/
static void
get_valuables(list)
struct obj *list; /* inventory or container contents */
get_valuables(struct obj *list) /* inventory or container contents */
{
register struct obj *obj;
register int i;
@@ -937,9 +924,8 @@ struct obj *list; /* inventory or container contents */
* as easily use qsort, but we don't care about efficiency here.
*/
static void
sort_valuables(list, size)
struct valuable_data list[];
int size; /* max value is less than 20 */
sort_valuables(struct valuable_data list[],
int size) /* max value is less than 20 */
{
register int i, j;
struct valuable_data ltmp;
@@ -965,14 +951,12 @@ int size; /* max value is less than 20 */
* odds_and_ends() was used for 3.6.0 and 3.6.1.
* Schroedinger's Cat is handled differently as of 3.6.2.
*/
static boolean FDECL(odds_and_ends, (struct obj *, int));
static boolean odds_and_ends(struct obj *, int);
#define CAT_CHECK 2
static boolean
odds_and_ends(list, what)
struct obj *list;
int what;
odds_and_ends(struct obj *list, int what)
{
struct obj *otmp;
@@ -993,7 +977,7 @@ int what;
/* deal with some objects which may be in an abnormal state at end of game */
static void
done_object_cleanup()
done_object_cleanup(void)
{
int ox, oy;
@@ -1049,10 +1033,10 @@ done_object_cleanup()
/* called twice; first to calculate total, then to list relevant items */
static void
artifact_score(list, counting, endwin)
struct obj *list;
boolean counting; /* true => add up points; false => display them */
winid endwin;
artifact_score(struct obj *list,
boolean counting, /* true => add up points;
false => display them */
winid endwin)
{
char pbuf[BUFSZ];
struct obj *otmp;
@@ -1086,8 +1070,7 @@ winid endwin;
/* Be careful not to call panic from here! */
void
done(how)
int how;
done(int how)
{
boolean survive = FALSE;
@@ -1195,8 +1178,7 @@ int how;
/* separated from done() in order to specify the __noreturn__ attribute */
static void
really_done(how)
int how;
really_done(int how)
{
boolean taken;
char pbuf[BUFSZ];
@@ -1629,9 +1611,8 @@ int how;
}
void
container_contents(list, identified, all_containers, reportempty)
struct obj *list;
boolean identified, all_containers, reportempty;
container_contents(struct obj *list, boolean identified,
boolean all_containers, boolean reportempty)
{
register struct obj *box, *obj;
char buf[BUFSZ];
@@ -1671,7 +1652,7 @@ boolean identified, all_containers, reportempty;
? SORTLOOT_LOOT : 0)
| (flags.sortpack ? SORTLOOT_PACK : 0));
sortedcobj = sortloot(&box->cobj, sortflags, FALSE,
(boolean FDECL((*), (OBJ_P))) 0);
(boolean (*)(OBJ_P)) 0);
for (srtc = sortedcobj; ((obj = srtc->obj) != 0); ++srtc) {
if (identified) {
discover_object(obj->otyp, TRUE, FALSE);
@@ -1707,8 +1688,7 @@ boolean identified, all_containers, reportempty;
/* should be called with either EXIT_SUCCESS or EXIT_FAILURE */
void
nh_terminate(status)
int status;
nh_terminate(int status)
{
g.program_state.in_moveloop = 0; /* won't be returning to normal play */
#ifdef MAC
@@ -1738,10 +1718,7 @@ int status;
/* set a delayed killer, ensure non-delayed killer is cleared out */
void
delayed_killer(id, format, killername)
int id;
int format;
const char *killername;
delayed_killer(int id, int format, const char *killername)
{
struct kinfo *k = find_delayed_killer(id);
@@ -1760,8 +1737,7 @@ const char *killername;
}
struct kinfo *
find_delayed_killer(id)
int id;
find_delayed_killer(int id)
{
struct kinfo *k;
@@ -1773,8 +1749,7 @@ int id;
}
void
dealloc_killer(kptr)
struct kinfo *kptr;
dealloc_killer(struct kinfo *kptr)
{
struct kinfo *prev = &g.killer, *k;
@@ -1796,8 +1771,7 @@ struct kinfo *kptr;
}
void
save_killers(nhfp)
NHFILE *nhfp;
save_killers(NHFILE *nhfp)
{
struct kinfo *kptr;
@@ -1817,8 +1791,7 @@ NHFILE *nhfp;
}
void
restore_killers(nhfp)
NHFILE *nhfp;
restore_killers(NHFILE *nhfp)
{
struct kinfo *kptr;
@@ -1832,8 +1805,7 @@ NHFILE *nhfp;
}
static int
wordcount(p)
char *p;
wordcount(char *p)
{
int words = 0;
@@ -1849,8 +1821,7 @@ char *p;
}
static void
bel_copy1(inp, out)
char **inp, *out;
bel_copy1(char **inp, char *out)
{
char *in = *inp;
@@ -1864,8 +1835,7 @@ char **inp, *out;
}
char *
build_english_list(in)
char *in;
build_english_list(char *in)
{
char *out, *p = in;
int len = (int) strlen(p), words = wordcount(p);