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

@@ -14,8 +14,8 @@
#include <string.h>
#endif
static void FDECL(grow_ld, (libdir **, int *, int));
static void FDECL(xexit, (int)) NORETURN;
static void grow_ld(libdir **, int *, int);
static void xexit(int) NORETURN;
#ifdef DLB
#ifdef DLBLIB
@@ -24,16 +24,16 @@ static void FDECL(xexit, (int)) NORETURN;
#define LIBLISTFILE "dlb.lst" /* default list file */
/* library functions (from dlb.c) */
extern boolean FDECL(open_library, (const char *, library *));
extern void FDECL(close_library, (library *));
extern boolean open_library(const char *, library *);
extern void close_library(library *);
char *FDECL(eos, (char *)); /* also used by dlb.c */
FILE *FDECL(fopen_datafile, (const char *, const char *));
char *eos(char *); /* also used by dlb.c */
FILE *fopen_datafile(const char *, const char *);
static void FDECL(Write, (int, char *, long));
static void NDECL(usage) NORETURN;
static void NDECL(verbose_help) NORETURN;
static void FDECL(write_dlb_directory, (int, int, libdir *, long, long, long));
static void Write(int, char *, long);
static void usage(void) NORETURN;
static void verbose_help(void) NORETURN;
static void write_dlb_directory(int, int, libdir *, long, long, long);
static char default_progname[] = "dlb";
static char *progname = default_progname;
@@ -77,7 +77,7 @@ static char origdir[255] = "";
*/
static void
usage()
usage(void)
{
(void) printf("Usage: %s [ctxCIfv] arguments... [files...]\n", progname);
(void) printf(" default library is %s\n", library_file);
@@ -87,7 +87,7 @@ usage()
}
static void
verbose_help()
verbose_help(void)
{
static const char *const long_help[] = {
"", "dlb COMMANDoptions args... files...", " commands:",
@@ -109,10 +109,7 @@ verbose_help()
}
static void
Write(out, buf, len)
int out;
char *buf;
long len;
Write(int out, char *buf, long len)
{
#if defined(MSDOS) && !defined(__DJGPP__)
unsigned short slen;
@@ -133,8 +130,7 @@ long len;
}
char *
eos(s)
char *s;
eos(char *s)
{
while (*s)
s++;
@@ -143,8 +139,7 @@ char *s;
/* open_library(dlb.c) needs this (which normally comes from src/files.c) */
FILE *
fopen_datafile(filename, mode)
const char *filename, *mode;
fopen_datafile(const char *filename, const char *mode)
{
return fopen(filename, mode);
}
@@ -153,9 +148,7 @@ const char *filename, *mode;
#endif /* DLB */
int
main(argc, argv)
int argc;
char **argv;
main(int argc, char **argv)
{
#ifdef DLB
#ifdef DLBLIB
@@ -486,10 +479,7 @@ char **argv;
#ifdef DLBLIB
static void
grow_ld(ld_p, ldlimit_p, alloc_incr)
libdir **ld_p;
int *ldlimit_p;
int alloc_incr;
grow_ld(libdir **ld_p, int *ldlimit_p, int alloc_incr)
{
static libdir zerolibdir;
int i = 0, newlimit = *ldlimit_p + alloc_incr;
@@ -506,10 +496,8 @@ int alloc_incr;
}
static void
write_dlb_directory(out, nfiles, ld, slen, dir_size, flen)
int out, nfiles;
libdir *ld;
long slen, dir_size, flen;
write_dlb_directory(int out, int nfiles, libdir *ld,
long slen, long dir_size, long flen)
{
char buf[BUFSIZ];
int i;
@@ -539,8 +527,7 @@ long slen, dir_size, flen;
#endif /* DLB */
static void
xexit(retcd)
int retcd;
xexit(int retcd)
{
#ifdef DLB
#ifdef AMIGA

View File

@@ -125,51 +125,46 @@ char *file_prefix = "";
#endif
#ifdef MACsansMPWTOOL
int FDECL(main, (void));
int main(void);
#else
int FDECL(main, (int, char **));
int main(int, char **);
#endif
void FDECL(do_makedefs, (char *));
void NDECL(do_objs);
void NDECL(do_data);
void NDECL(do_dungeon);
void NDECL(do_options);
void NDECL(do_monstr);
void NDECL(do_permonst);
void NDECL(do_questtxt);
void NDECL(do_rumors);
void NDECL(do_oracles);
void NDECL(do_date);
void do_makedefs(char *);
void do_objs(void);
void do_data(void);
void do_dungeon(void);
void do_options(void);
void do_monstr(void);
void do_permonst(void);
void do_questtxt(void);
void do_rumors(void);
void do_oracles(void);
void do_date(void);
extern void NDECL(monst_globals_init); /* monst.c */
extern void NDECL(objects_globals_init); /* objects.c */
extern void monst_globals_init(void); /* monst.c */
extern void objects_globals_init(void); /* objects.c */
static char *FDECL(name_file, (const char *, const char *));
static FILE *FDECL(getfp, (const char *, const char *, const char *, int));
static void FDECL(do_ext_makedefs, (int, char **));
static char *FDECL(xcrypt, (const char *));
static unsigned long FDECL(read_rumors_file,
(const char *, int *, long *, unsigned long));
static void FDECL(do_rnd_access_file, (const char *, const char *));
static boolean FDECL(d_filter, (char *));
static boolean FDECL(h_filter, (char *));
static void FDECL(opt_out_words, (char *, int *));
static char *name_file(const char *, const char *);
static FILE *getfp(const char *, const char *, const char *, int);
static void do_ext_makedefs(int, char **);
static char *xcrypt(const char *);
static unsigned long read_rumors_file(const char *, int *,
long *, unsigned long);
static void do_rnd_access_file(const char *, const char *);
static boolean d_filter(char *);
static boolean h_filter(char *);
static void opt_out_words(char *, int *);
static char *FDECL(fgetline, (FILE*));
static char *FDECL(tmpdup, (const char *));
static char *FDECL(limit, (char *, int));
static void NDECL(windowing_sanity);
static boolean FDECL(get_gitinfo, (char *, char *));
static char *fgetline(FILE*);
static char *tmpdup(const char *);
static char *limit(char *, int);
static void windowing_sanity(void);
static boolean get_gitinfo(char *, char *);
/* input, output, tmp */
static FILE *ifp, *ofp, *tfp;
static boolean use_enum =
#ifdef ENUM_PM
TRUE;
#else
FALSE;
#endif
static boolean use_enum = TRUE;
#if defined(__BORLANDC__) && !defined(_WIN32)
extern unsigned _stklen = STKSIZ;
@@ -219,9 +214,7 @@ main(void)
#else /* ! MAC */
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
if ((argc == 1) ||
((argc != 2)
@@ -254,8 +247,7 @@ char *argv[];
#endif
void
do_makedefs(options)
char *options;
do_makedefs(char *options)
{
boolean more_than_one;
@@ -342,21 +334,17 @@ char *options;
static char namebuf[1000];
static char *
name_file(template, tag)
const char *template;
const char *tag;
name_file(const char* template, const char* tag)
{
Sprintf(namebuf, template, tag);
return namebuf;
}
#ifdef HAS_NO_MKSTEMP
static void FDECL(delete_file, (const char *template, const char *));
static void delete_file(const char *template, const char *);
static void
delete_file(template, tag)
const char *template;
const char *tag;
delete_file(const char *template, const char *tag)
{
char *name = name_file(template, tag);
@@ -365,15 +353,7 @@ const char *tag;
#endif
static FILE *
getfp(template, tag, mode, flg)
const char *template;
const char *tag;
const char *mode;
#ifndef HAS_NO_MKSTEMP
int flg;
#else
int flg UNUSED;
#endif
getfp(const char* template, const char* tag, const char* mode, int flg)
{
char *name = name_file(template, tag);
FILE *rv = (FILE *) 0;
@@ -389,7 +369,10 @@ int flg UNUSED;
rv = fdopen(tmpfd, WRTMODE); /* temp file is always read+write */
Unlink(tmpfbuf);
}
} else
}
else
#else
flg; // unused
#endif
rv = fopen(name, mode);
if (!rv) {
@@ -415,13 +398,13 @@ struct grep_var {
/* struct grep_var grep_vars[] and TODO_* constants in include file: */
#include "mdgrep.h"
static void NDECL(do_grep_showvars);
static struct grep_var *FDECL(grepsearch, (const char *));
static int FDECL(grep_check_id, (const char *));
static void FDECL(grep_show_wstack, (const char *));
static char *FDECL(do_grep_control, (char *));
static void NDECL(do_grep);
static void FDECL(grep0, (FILE *, FILE *, int));
static void do_grep_showvars(void);
static struct grep_var *grepsearch(const char *);
static int grep_check_id(const char *);
static void grep_show_wstack(const char *);
static char *do_grep_control(char *);
static void do_grep(void);
static void grep0(FILE *, FILE *, int);
static int grep_trace = 0;
@@ -615,7 +598,7 @@ static int grep_stack[GREP_STACK_SIZE] = { ST_LD(1, 0) };
static int grep_lineno = 0;
static void
do_grep_showvars()
do_grep_showvars(void)
{
int x;
@@ -625,8 +608,7 @@ do_grep_showvars()
}
static struct grep_var *
grepsearch(name)
const char *name;
grepsearch(const char* name)
{
/* XXX make into binary search */
int x = 0;
@@ -640,8 +622,7 @@ const char *name;
}
static int
grep_check_id(id)
const char *id;
grep_check_id(const char* id)
{
struct grep_var *rv;
@@ -670,8 +651,7 @@ const char *id;
}
static void
grep_show_wstack(tag)
const char *tag;
grep_show_wstack(const char* tag)
{
int x;
@@ -686,8 +666,7 @@ const char *tag;
}
static char *
do_grep_control(buf)
char *buf;
do_grep_control(char *buf)
{
int isif = 1;
char *buf0 = buf;
@@ -773,7 +752,7 @@ char *buf;
static void grep0(FILE *, FILE *, int);
static void
do_grep()
do_grep(void)
{
if (!inputfp) {
Fprintf(stderr, "--grep requires --input\n");
@@ -789,14 +768,7 @@ do_grep()
}
static void
grep0(inputfp0, outputfp0, flg)
FILE *inputfp0;
FILE *outputfp0;
#ifndef HAS_NO_MKSTEMP
int flg;
#else
int flg UNUSED;
#endif
grep0(FILE *inputfp0, FILE* outputfp0, int flg)
{
#ifndef HAS_NO_MKSTEMP
/* if grep0 is passed FLG_TEMPFILE flag, it will
@@ -804,6 +776,8 @@ int flg UNUSED;
The caller will have to take care of calling
fclose() when it is done with the file */
boolean istemp = (flg & FLG_TEMPFILE) != 0;
#else
flg; // unused
#endif
char buf[16384]; /* looong, just in case */
@@ -864,8 +838,7 @@ int flg UNUSED;
/* trivial text encryption routine which can't be broken with `tr' */
static char *
xcrypt(str)
const char *str;
xcrypt(const char* str)
{ /* duplicated in src/hacklib.c */
static char buf[BUFSZ];
register const char *p;
@@ -886,11 +859,8 @@ const char *str;
#define PAD_RUMORS_TO 60
/* common code for do_rumors(). Return 0 on error. */
static unsigned long
read_rumors_file(file_ext, rumor_count, rumor_size, old_rumor_offset)
const char *file_ext;
int *rumor_count;
long *rumor_size;
unsigned long old_rumor_offset;
read_rumors_file(const char* file_ext, int* rumor_count,
long* rumor_size, unsigned long old_rumor_offset)
{
char infile[MAXFNAMELEN];
char *line;
@@ -947,9 +917,7 @@ unsigned long old_rumor_offset;
}
static void
do_rnd_access_file(fname, deflt_content)
const char *fname;
const char *deflt_content;
do_rnd_access_file(const char* fname, const char* deflt_content)
{
char *line, buf[BUFSZ];
@@ -1001,7 +969,7 @@ const char *deflt_content;
}
void
do_rumors()
do_rumors(void)
{
char *line;
static const char rumors_header[] =
@@ -1093,7 +1061,7 @@ rumors_failure:
}
void
do_date()
do_date(void)
{
#ifdef KR1ED
long clocktim = 0;
@@ -1281,8 +1249,7 @@ do_date()
}
static boolean
get_gitinfo(githash, gitbranch)
char *githash, *gitbranch;
get_gitinfo(char *githash, char *gitbranch)
{
FILE *gifp;
size_t len;
@@ -1342,7 +1309,7 @@ char *githash, *gitbranch;
}
void
do_options()
do_options(void)
{
const char *optline;
int infocontext = 0;
@@ -1364,7 +1331,7 @@ do_options()
}
static void
windowing_sanity()
windowing_sanity(void)
{
#ifndef DEFAULT_WINDOW_SYS
/* pre-standard compilers didn't support #error; wait til run-time */
@@ -1404,8 +1371,7 @@ windowing_sanity()
/* routine to decide whether to discard something from data.base */
static boolean
d_filter(line)
char *line;
d_filter(char *line)
{
if (*line == '#')
return TRUE; /* ignore comment lines */
@@ -1435,7 +1401,7 @@ text-b/text-c at fseek(0x01234567L + 456L)
*/
void
do_data()
do_data(void)
{
char infile[60], tempfile[60];
boolean ok;
@@ -1550,8 +1516,7 @@ do_data()
/* routine to decide whether to discard something from oracles.txt */
static boolean
h_filter(line)
char *line;
h_filter(char *line)
{
static boolean skip = FALSE;
char *tag;
@@ -1590,7 +1555,7 @@ static const char *special_oracle[] = {
*/
void
do_oracles()
do_oracles(void)
{
char infile[60], tempfile[60];
boolean in_oracle, ok;
@@ -1752,7 +1717,7 @@ do_oracles()
}
void
do_dungeon()
do_dungeon(void)
{
char *line;
@@ -1810,8 +1775,8 @@ do_dungeon()
* transfer relevant generated monstr values to src/monst.c;
* delete src/monstr.c.
*/
static int FDECL(mstrength, (struct permonst *));
static boolean FDECL(ranged_attk, (struct permonst *));
static int mstrength(struct permonst *);
static boolean ranged_attk(struct permonst *);
/*
* This routine is designed to return an integer value which represents
@@ -1819,8 +1784,7 @@ static boolean FDECL(ranged_attk, (struct permonst *));
* determination as "experience()" to arrive at the strength.
*/
static int
mstrength(ptr)
struct permonst *ptr;
mstrength(struct permonst* ptr)
{
int i, tmp2, n, tmp = ptr->mlevel;
@@ -1879,8 +1843,7 @@ struct permonst *ptr;
/* returns True if monster can attack at range */
static boolean
ranged_attk(ptr)
register struct permonst *ptr;
ranged_attk(register struct permonst* ptr)
{
register int i, j;
register int atk_mask = (1 << AT_BREA) | (1 << AT_SPIT) | (1 << AT_GAZE);
@@ -1894,7 +1857,7 @@ register struct permonst *ptr;
}
void
do_monstr()
do_monstr(void)
{
struct permonst *ptr;
int i;
@@ -1945,9 +1908,9 @@ do_monstr()
}
Fprintf(ofp, " *\n */\n\n");
Fprintf(ofp, "\nvoid NDECL(monstr_init);\n");
Fprintf(ofp, "\nvoid monstr_init(void);\n");
Fprintf(ofp, "\nvoid\n");
Fprintf(ofp, "monstr_init()\n");
Fprintf(ofp, "monstr_init(void)\n");
Fprintf(ofp, "{\n");
Fprintf(ofp, " return;\n");
Fprintf(ofp, "}\n");
@@ -1958,7 +1921,7 @@ do_monstr()
}
void
do_permonst()
do_permonst(void)
{
int i;
char *c, *nam;
@@ -2015,7 +1978,7 @@ do_permonst()
/* Start of Quest text file processing. */
void
do_questtxt()
do_questtxt(void)
{
printf("DEPRECATION WARNINGS:\n");
printf("'makedefs -q' is no longer required. Remove all references\n");
@@ -2027,9 +1990,7 @@ do_questtxt()
static char temp[32];
static char *limit(name, pref) /* limit a name to 30 characters length */
char *name;
int pref;
static char *limit(char* name, int pref) /* limit a name to 30 characters length */
{
(void) strncpy(temp, name, pref ? 26 : 30);
temp[pref ? 26 : 30] = 0;
@@ -2037,7 +1998,7 @@ int pref;
}
void
do_objs()
do_objs(void)
{
int i, sum = 0;
char *c, *objnam;
@@ -2184,8 +2145,7 @@ do_objs()
* null pointer if no characters were read.
*/
static char *
fgetline(fd)
FILE *fd;
fgetline(FILE *fd)
{
static const int inc = 256;
int len = inc;
@@ -2208,8 +2168,7 @@ FILE *fd;
}
static char *
tmpdup(str)
const char *str;
tmpdup(const char* str)
{
static char buf[128];

View File

@@ -15,12 +15,12 @@
#define abort() exit()
#endif
#ifdef VMS
extern void NDECL(vms_abort);
extern void vms_abort(void);
#endif
/*VARARGS1*/
boolean panicking;
void VDECL(panic, (const char *, ...));
void panic(const char *, ...);
void panic
VA_DECL(const char *, str)
@@ -53,8 +53,7 @@ VA_DECL(const char *, str)
* systems, but they should either use yacc or get a real alloca routine.
*/
long *
alloca(cnt)
unsigned cnt;
alloca(unsigned int cnt)
{
return cnt ? alloc(cnt) : (long *) 0;
}

View File

@@ -18,16 +18,16 @@
#endif
#ifdef VMS
extern int FDECL(vms_creat, (const char *, unsigned));
extern int FDECL(vms_open, (const char *, int, unsigned));
extern int vms_creat(const char *, unsigned);
extern int vms_open(const char *, int, unsigned);
#endif /* VMS */
int FDECL(restore_savefile, (char *));
void FDECL(set_levelfile_name, (int));
int FDECL(open_levelfile, (int));
int NDECL(create_savefile);
void FDECL(copy_bytes, (int, int));
static void FDECL(store_formatindicator, (int));
int restore_savefile(char *);
void set_levelfile_name(int);
int open_levelfile(int);
int create_savefile(void);
void copy_bytes(int, int);
static void store_formatindicator(int);
#ifndef WIN_CE
#define Fprintf (void) fprintf
@@ -39,7 +39,7 @@ static void nhce_message(FILE *, const char *, ...);
#define Close (void) close
#if defined(EXEPATH)
char *FDECL(exepath, (char *));
char *exepath(char *);
#endif
#if defined(__BORLANDC__) && !defined(_WIN32)
@@ -50,9 +50,7 @@ extern unsigned _stklen = STKSIZ;
char savename[SAVESIZE]; /* holds relative path of save file from playground */
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
int argno;
const char *dir = (char *) 0;
@@ -141,8 +139,7 @@ char *argv[];
static char lock[256];
void
set_levelfile_name(lev)
int lev;
set_levelfile_name(int lev)
{
char *tf;
@@ -156,8 +153,7 @@ int lev;
}
int
open_levelfile(lev)
int lev;
open_levelfile(int lev)
{
int fd;
@@ -171,7 +167,7 @@ int lev;
}
int
create_savefile()
create_savefile(void)
{
int fd;
@@ -184,8 +180,7 @@ create_savefile()
}
void
copy_bytes(ifd, ofd)
int ifd, ofd;
copy_bytes(int ifd, int ofd)
{
char buf[BUFSIZ];
int nfrom, nto;
@@ -201,8 +196,7 @@ int ifd, ofd;
}
int
restore_savefile(basename)
char *basename;
restore_savefile(char *basename)
{
int gfd, lfd, sfd;
int res = 0, lev, savelev, hpid, pltmpsiz, filecmc;
@@ -390,8 +384,7 @@ char *basename;
}
static void
store_formatindicator(fd)
int fd;
store_formatindicator(int fd)
{
char indicate = 'h'; /* historical */
int cmc = 0;
@@ -413,8 +406,7 @@ int fd;
char exepathbuf[EXEPATHBUFSZ];
char *
exepath(str)
char *str;
exepath(char *str)
{
char *tmp, *tmp2;
int bsize;