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

View File

@@ -68,9 +68,8 @@ endif # clang
# leave it out by default.
#CFLAGS+=-Wunreachable-code
#
# Can't use these; NetHack uses old-style-definitions
#CFLAGS+=-Wold-style-definition
#CFLAGS+=-Wstrict-prototypes
CFLAGS+=-Wold-style-definition
CFLAGS+=-Wstrict-prototypes
#end of compiler.2020
#------------------------------------------------------------------------------

View File

@@ -165,7 +165,11 @@ override TARGET_AR = $(TOOLTOP1)/i586-pc-msdosdjgpp-gcc-ar
override TARGET_STUBEDIT = ../lib/djgpp/i586-pc-msdosdjgpp/bin/stubedit
override TARGET_CFLAGS = -c -O -I../include -I../sys/msdos -I../win/share \
$(LUAINCL) -DDLB $(PDCURSESDEF) \
-DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_TARGET -DCROSS_TO_MSDOS
-DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_TARGET -DCROSS_TO_MSDOS \
-Wall -Wextra -Wno-missing-field-initializers -Wimplicit \
-Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings \
-Wimplicit-function-declaration -Wimplicit-int \
-Wmissing-declarations -Wmissing-prototypes -Wmissing-parameter-type
override TARGET_CXXFLAGS = $(TARGET_CFLAGS)
override TARGET_LINK = $(TOOLTOP1)/i586-pc-msdosdjgpp-gcc
override TARGET_LFLAGS=

View File

@@ -19,36 +19,34 @@
#if !defined(_BULL_SOURCE) && !defined(__sgi) && !defined(_M_UNIX)
#if !defined(SUNOS4) && !(defined(ULTRIX) && defined(__GNUC__))
#if defined(POSIX_TYPES) || defined(SVR4) || defined(HPUX)
extern struct passwd *FDECL(getpwuid, (uid_t));
extern struct passwd *getpwuid(uid_t);
#else
extern struct passwd *FDECL(getpwuid, (int));
extern struct passwd *getpwuid(int);
#endif
#endif
#endif
extern struct passwd *FDECL(getpwnam, (const char *));
extern struct passwd *getpwnam(const char *);
#ifdef CHDIR
static void FDECL(chdirx, (const char *, BOOLEAN_P));
static void chdirx(const char *, boolean);
#endif /* CHDIR */
static boolean NDECL(whoami);
static void FDECL(process_options, (int, char **));
static boolean whoami(void);
static void process_options(int, char **);
#ifdef _M_UNIX
extern void NDECL(check_sco_console);
extern void NDECL(init_sco_cons);
extern void check_sco_console(void);
extern void init_sco_cons(void);
#endif
#ifdef __linux__
extern void NDECL(check_linux_console);
extern void NDECL(init_linux_cons);
extern void check_linux_console(void);
extern void init_linux_cons(void);
#endif
static void NDECL(wd_message);
static void wd_message(void);
static boolean wiz_error_flag = FALSE;
static struct passwd *NDECL(get_unix_pw);
static struct passwd *get_unix_pw(void);
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
#ifdef CHDIR
register char *dir;
@@ -343,9 +341,7 @@ char *argv[];
/* caveat: argv elements might be arbitrary long */
static void
process_options(argc, argv)
int argc;
char *argv[];
process_options(int argc, char *argv[])
{
int i, l;
@@ -465,9 +461,7 @@ char *argv[];
#ifdef CHDIR
static void
chdirx(dir, wr)
const char *dir;
boolean wr;
chdirx(const char *dir, boolean wr)
{
if (dir /* User specified directory? */
#ifdef HACKDIR
@@ -525,7 +519,7 @@ boolean wr;
/* returns True iff we set plname[] to username which contains a hyphen */
static boolean
whoami()
whoami(void)
{
/*
* Who am i? Algorithm: 1. Use name as specified in NETHACKOPTIONS
@@ -557,8 +551,7 @@ whoami()
}
void
sethanguphandler(handler)
void FDECL((*handler), (int));
sethanguphandler(void (*handler)(int))
{
#ifdef SA_RESTART
/* don't want reads to restart. If SA_RESTART is defined, we know
@@ -585,7 +578,7 @@ void FDECL((*handler), (int));
#ifdef PORT_HELP
void
port_help()
port_help(void)
{
/*
* Display unix-specific help. Just show contents of the helpfile
@@ -597,7 +590,7 @@ port_help()
/* validate wizard mode if player has requested access to it */
boolean
authorize_wizard_mode()
authorize_wizard_mode(void)
{
struct passwd *pw = get_unix_pw();
@@ -610,7 +603,7 @@ authorize_wizard_mode()
}
static void
wd_message()
wd_message(void)
{
if (wiz_error_flag) {
if (sysopt.wizards && sysopt.wizards[0]) {
@@ -630,8 +623,7 @@ wd_message()
* be room for the /
*/
void
append_slash(name)
char *name;
append_slash(char *name)
{
char *ptr;
@@ -646,8 +638,7 @@ char *name;
}
boolean
check_user_string(optstr)
const char *optstr;
check_user_string(const char *optstr)
{
struct passwd *pw;
int pwlen;
@@ -683,7 +674,7 @@ const char *optstr;
}
static struct passwd *
get_unix_pw()
get_unix_pw(void)
{
char *user;
unsigned uid;
@@ -714,7 +705,7 @@ get_unix_pw()
}
char *
get_login_name()
get_login_name(void)
{
static char buf[BUFSZ];
struct passwd *pw = get_unix_pw();
@@ -730,8 +721,7 @@ get_login_name()
extern int errno;
void
port_insert_pastebuf(buf)
char *buf;
port_insert_pastebuf(char *buf)
{
/* This should be replaced when there is a Cocoa port. */
const char *errfmt;
@@ -765,7 +755,7 @@ char *buf;
#endif /* __APPLE__ */
unsigned long
sys_random_seed()
sys_random_seed(void)
{
unsigned long seed = 0L;
unsigned long pid = (unsigned long) getpid();

View File

@@ -24,8 +24,7 @@
#include <dlfcn.h>
static int
real_getresuid(ruid, euid, suid)
uid_t *ruid, *euid, *suid;
real_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid)
{
int (*f)(uid_t *, uid_t *, uid_t *); /* getresuid signature */
@@ -37,8 +36,7 @@ uid_t *ruid, *euid, *suid;
}
static int
real_getresgid(rgid, egid, sgid)
gid_t *rgid, *egid, *sgid;
real_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid)
{
int (*f)(gid_t *, gid_t *, gid_t *); /* getresgid signature */
@@ -55,8 +53,7 @@ gid_t *rgid, *egid, *sgid;
#ifdef SYS_getresuid
static int
real_getresuid(ruid, euid, suid)
uid_t *ruid, *euid, *suid;
real_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid)
{
return syscall(SYS_getresuid, ruid, euid, suid);
}
@@ -68,8 +65,7 @@ uid_t *ruid, *euid, *suid;
#endif /* SVR4 */
static int
real_getresuid(ruid, euid, suid)
uid_t *ruid, *euid, *suid;
real_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid)
{
int retval;
int pfd[2];
@@ -93,8 +89,7 @@ uid_t *ruid, *euid, *suid;
#ifdef SYS_getresgid
static int
real_getresgid(rgid, egid, sgid)
gid_t *rgid, *egid, *sgid;
real_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid)
{
return syscall(SYS_getresgid, rgid, egid, sgid);
}
@@ -102,8 +97,7 @@ gid_t *rgid, *egid, *sgid;
#else /* SYS_getresgid */
static int
real_getresgid(rgid, egid, sgid)
gid_t *rgid, *egid, *sgid;
real_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid)
{
int retval;
int pfd[2];
@@ -133,8 +127,7 @@ static unsigned int hiding_privileges = 0;
*/
int
hide_privileges(flag)
boolean flag;
hide_privileges(boolean flag)
{
if (flag)
hiding_privileges++;
@@ -144,8 +137,7 @@ boolean flag;
}
int
nh_getresuid(ruid, euid, suid)
uid_t *ruid, *euid, *suid;
nh_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid)
{
int retval = real_getresuid(ruid, euid, suid);
@@ -155,7 +147,7 @@ uid_t *ruid, *euid, *suid;
}
uid_t
nh_getuid()
nh_getuid(void)
{
uid_t ruid, euid, suid;
@@ -164,7 +156,7 @@ nh_getuid()
}
uid_t
nh_geteuid()
nh_geteuid(void)
{
uid_t ruid, euid, suid;
@@ -175,8 +167,7 @@ nh_geteuid()
}
int
nh_getresgid(rgid, egid, sgid)
gid_t *rgid, *egid, *sgid;
nh_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid)
{
int retval = real_getresgid(rgid, egid, sgid);
@@ -186,7 +177,7 @@ gid_t *rgid, *egid, *sgid;
}
gid_t
nh_getgid()
nh_getgid(void)
{
gid_t rgid, egid, sgid;
@@ -195,7 +186,7 @@ nh_getgid()
}
gid_t
nh_getegid()
nh_getegid(void)
{
gid_t rgid, egid, sgid;
@@ -209,8 +200,7 @@ nh_getegid()
#ifdef GNOME_GRAPHICS
int
hide_privileges(flag)
boolean flag;
hide_privileges(boolean flag)
{
return 0;
}

View File

@@ -15,12 +15,12 @@
#include <signal.h>
#ifdef _M_UNIX
extern void NDECL(sco_mapon);
extern void NDECL(sco_mapoff);
extern void sco_mapon(void);
extern void sco_mapoff(void);
#endif
#ifdef __linux__
extern void NDECL(linux_mapon);
extern void NDECL(linux_mapoff);
extern void linux_mapon(void);
extern void linux_mapoff(void);
#endif
#ifndef NHSTDC
@@ -32,8 +32,7 @@ static struct stat buf;
/* see whether we should throw away this xlock file;
if yes, close it, otherwise leave it open */
static int
veryold(fd)
int fd;
veryold(int fd)
{
time_t date;
@@ -71,7 +70,7 @@ int fd;
}
static int
eraseoldlocks()
eraseoldlocks(void)
{
register int i;
@@ -92,7 +91,7 @@ eraseoldlocks()
}
void
getlock()
getlock(void)
{
register int i = 0, fd, c;
const char *fq_lock;
@@ -215,8 +214,7 @@ gotlock:
/* normalize file name - we don't like .'s, /'s, spaces */
void
regularize(s)
register char *s;
regularize(char *s)
{
register char *lp;
@@ -250,8 +248,7 @@ register char *s;
#include <poll.h>
void
msleep(msec)
unsigned msec; /* milliseconds */
msleep(unsigned msec) /* milliseconds */
{
struct pollfd unused;
int msecs = msec; /* poll API is signed */
@@ -264,7 +261,7 @@ unsigned msec; /* milliseconds */
#ifdef SHELL
int
dosh()
dosh(void)
{
char *str;
@@ -290,8 +287,7 @@ dosh()
#if defined(SHELL) || defined(DEF_PAGER) || defined(DEF_MAILREADER)
int
child(wt)
int wt;
child(int wt)
{
register int f;
@@ -342,44 +338,42 @@ int wt;
#ifdef GETRES_SUPPORT
extern int FDECL(nh_getresuid, (uid_t *, uid_t *, uid_t *));
extern uid_t NDECL(nh_getuid);
extern uid_t NDECL(nh_geteuid);
extern int FDECL(nh_getresgid, (gid_t *, gid_t *, gid_t *));
extern gid_t NDECL(nh_getgid);
extern gid_t NDECL(nh_getegid);
extern int nh_getresuid(uid_t *, uid_t *, uid_t *);
extern uid_t nh_getuid(void);
extern uid_t nh_geteuid(void);
extern int nh_getresgid(gid_t *, gid_t *, gid_t *);
extern gid_t nh_getgid(void);
extern gid_t nh_getegid(void);
/* the following several functions assume __STDC__ where parentheses
around the name of a function-like macro prevent macro expansion */
int (getresuid)(ruid, euid, suid)
uid_t *ruid, *euid, *suid;
int (getresuid)(uid_t *ruid, *euid, *suid)
{
return nh_getresuid(ruid, euid, suid);
}
uid_t (getuid)()
uid_t (getuid)(void)
{
return nh_getuid();
}
uid_t (geteuid)()
uid_t (geteuid)(void)
{
return nh_geteuid();
}
int (getresgid)(rgid, egid, sgid)
gid_t *rgid, *egid, *sgid;
int (getresgid)(gid_t *rgid, *egid, *sgid)
{
return nh_getresgid(rgid, egid, sgid);
}
gid_t (getgid)()
gid_t (getgid)(void)
{
return nh_getgid();
}
gid_t (getegid)()
gid_t (getegid)(void)
{
return nh_getegid();
}
@@ -389,8 +383,7 @@ gid_t (getegid)()
/* XXX should be ifdef PANICTRACE_GDB, but there's no such symbol yet */
#ifdef PANICTRACE
boolean
file_exists(path)
const char *path;
file_exists(const char *path)
{
struct stat sb;