From 00b8e31689c6400d8ad915067f021b8e246df989 Mon Sep 17 00:00:00 2001 From: jsm Date: Sun, 25 Mar 2001 20:43:58 +0000 Subject: Make mostly gcc -W clean, and other cleanup: Use const. Add __noreturn__ attributes. Add a __format__ attribute. Add __unused__ attributes. Use symbolic constants for open() and lseek(). Declare types of all function parameters; convert some function definitions to ISO C form. Ensure standard file descriptors are open on startup. Check for errors writing output of makedefs. Avoid duplicate definitions of variables. --- hack/date.h | 4 +-- hack/def.func_tab.h | 8 ++--- hack/def.monst.h | 4 +-- hack/def.objclass.h | 6 ++-- hack/def.objects.h | 4 +-- hack/def.permonst.h | 7 +++-- hack/extern.h | 85 +++++++++++++++++++++++++++-------------------------- hack/hack.Decl.c | 9 +++--- hack/hack.apply.c | 12 ++++---- hack/hack.bones.c | 8 ++--- hack/hack.c | 8 ++--- hack/hack.cmd.c | 14 ++++----- hack/hack.do.c | 6 ++-- hack/hack.do_name.c | 14 ++++----- hack/hack.dog.c | 15 +++++----- hack/hack.eat.c | 10 +++---- hack/hack.end.c | 21 +++++++------ hack/hack.engrave.c | 8 ++--- hack/hack.fight.c | 12 ++++---- hack/hack.h | 33 +++++++++++---------- hack/hack.invent.c | 11 +++---- hack/hack.lev.c | 10 +++---- hack/hack.main.c | 24 +++++++++------ hack/hack.makemon.c | 11 ++++--- hack/hack.mhitu.c | 6 ++-- hack/hack.mklev.c | 9 ++---- hack/hack.mkmaze.c | 6 ++-- hack/hack.mkobj.c | 7 ++--- hack/hack.mkshop.c | 8 ++--- hack/hack.mon.c | 26 ++++++++-------- hack/hack.monst.c | 14 ++++----- hack/hack.o_init.c | 7 +++-- hack/hack.objnam.c | 23 +++++++-------- hack/hack.pager.c | 16 +++++----- hack/hack.potion.c | 10 +++---- hack/hack.pri.c | 6 ++-- hack/hack.read.c | 6 ++-- hack/hack.rip.c | 12 ++++---- hack/hack.save.c | 16 +++++----- hack/hack.shk.c | 12 ++++---- hack/hack.shknam.c | 28 +++++++++--------- hack/hack.timeout.c | 6 ++-- hack/hack.topl.c | 12 ++++---- hack/hack.trap.c | 10 +++---- hack/hack.tty.c | 10 +++---- hack/hack.u_init.c | 6 ++-- hack/hack.unix.c | 10 +++---- hack/hack.vault.c | 6 ++-- hack/hack.wield.c | 8 ++--- hack/hack.wizard.c | 6 ++-- hack/hack.zap.c | 18 ++++++------ hack/makedefs.c | 21 ++++++++----- 52 files changed, 339 insertions(+), 330 deletions(-) (limited to 'hack') diff --git a/hack/date.h b/hack/date.h index 0320b698..d3c66d12 100644 --- a/hack/date.h +++ b/hack/date.h @@ -1,3 +1,3 @@ -/* $NetBSD: date.h,v 1.3 1995/03/23 08:29:17 cgd Exp $ */ +/* $NetBSD: date.h,v 1.4 2001/03/25 20:43:58 jsm Exp $ */ -char datestring[] = "Tue Jul 23 1985"; +const char datestring[] = "Tue Jul 23 1985"; diff --git a/hack/def.func_tab.h b/hack/def.func_tab.h index 8295a350..100c0a6a 100644 --- a/hack/def.func_tab.h +++ b/hack/def.func_tab.h @@ -1,4 +1,4 @@ -/* $NetBSD: def.func_tab.h,v 1.4 1997/10/19 16:56:58 christos Exp $ */ +/* $NetBSD: def.func_tab.h,v 1.5 2001/03/25 20:43:58 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -10,12 +10,12 @@ struct func_tab { int (*f_funct) __P((void)); }; -extern struct func_tab cmdlist[]; +extern const struct func_tab cmdlist[]; struct ext_func_tab { - char *ef_txt; + const char *ef_txt; int (*ef_funct) __P((void)); }; -extern struct ext_func_tab extcmdlist[]; +extern const struct ext_func_tab extcmdlist[]; #endif /* _DEF_FUNC_TAB_H_ */ diff --git a/hack/def.monst.h b/hack/def.monst.h index 4d3ca91f..f9ba4eb0 100644 --- a/hack/def.monst.h +++ b/hack/def.monst.h @@ -1,4 +1,4 @@ -/* $NetBSD: def.monst.h,v 1.5 2001/01/16 02:50:28 cgd Exp $ */ +/* $NetBSD: def.monst.h,v 1.6 2001/03/25 20:43:58 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -7,7 +7,7 @@ #define _DEF_MONST_H_ struct monst { struct monst *nmon; - struct permonst *data; + const struct permonst *data; unsigned m_id; xchar mx,my; xchar mdx,mdy; /* if mdispl then pos where last displayed */ diff --git a/hack/def.objclass.h b/hack/def.objclass.h index 4281f49f..c6ac9686 100644 --- a/hack/def.objclass.h +++ b/hack/def.objclass.h @@ -1,4 +1,4 @@ -/* $NetBSD: def.objclass.h,v 1.4 1997/10/19 16:57:12 christos Exp $ */ +/* $NetBSD: def.objclass.h,v 1.5 2001/03/25 20:43:58 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -8,8 +8,8 @@ /* definition of a class of objects */ struct objclass { - char *oc_name; /* actual name */ - char *oc_descr; /* description when name unknown */ + const char *oc_name; /* actual name */ + const char *oc_descr; /* description when name unknown */ char *oc_uname; /* called by user */ Bitfield(oc_name_known,1); Bitfield(oc_merge,1); /* merge otherwise equal objects */ diff --git a/hack/def.objects.h b/hack/def.objects.h index 6a239957..1ad60ba0 100644 --- a/hack/def.objects.h +++ b/hack/def.objects.h @@ -1,4 +1,4 @@ -/* $NetBSD: def.objects.h,v 1.4 1997/10/19 16:57:16 christos Exp $ */ +/* $NetBSD: def.objects.h,v 1.5 2001/03/25 20:43:58 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -285,7 +285,7 @@ struct objclass objects[] = { { NULL, NULL, NULL, 0, 0, ILLOBJ_SYM, 0, 0, 0, 0, 0, 0 } }; -char obj_symbols[] = { +const char obj_symbols[] = { ILLOBJ_SYM, AMULET_SYM, FOOD_SYM, WEAPON_SYM, TOOL_SYM, BALL_SYM, CHAIN_SYM, ROCK_SYM, ARMOR_SYM, POTION_SYM, SCROLL_SYM, WAND_SYM, RING_SYM, GEM_SYM, 0 }; diff --git a/hack/def.permonst.h b/hack/def.permonst.h index 55ec4fb3..2e3aca61 100644 --- a/hack/def.permonst.h +++ b/hack/def.permonst.h @@ -1,4 +1,4 @@ -/* $NetBSD: def.permonst.h,v 1.4 1997/10/19 16:57:19 christos Exp $ */ +/* $NetBSD: def.permonst.h,v 1.5 2001/03/25 20:43:58 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -7,12 +7,13 @@ #ifndef _DEF_PERMONST_H_ #define _DEF_PERMONST_H_ struct permonst { - char *mname,mlet; + const char *mname; + char mlet; schar mlevel,mmove,ac,damn,damd; unsigned pxlth; }; -extern struct permonst mons[]; +extern const struct permonst mons[]; #define PM_ACID_BLOB &mons[7] #define PM_ZOMBIE &mons[13] #define PM_PIERCER &mons[17] diff --git a/hack/extern.h b/hack/extern.h index c7dfcf69..325531b8 100644 --- a/hack/extern.h +++ b/hack/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.3 2001/02/05 00:37:43 christos Exp $ */ +/* $NetBSD: extern.h,v 1.4 2001/03/25 20:43:58 jsm Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -74,7 +74,7 @@ void nomul __P((int)); int abon __P((void)); int dbon __P((void)); void losestr __P((int)); -void losehp __P((int, char *)); +void losehp __P((int, const char *)); void losehp_m __P((int, struct monst *)); void losexp __P((void)); int inv_weight __P((void)); @@ -82,7 +82,7 @@ int inv_cnt __P((void)); long newuexp __P((void)); /* hack.cmd.c */ -void rhack __P((char *)); +void rhack __P((const char *)); int doextcmd __P((void)); char lowc __P((int)); char unctrl __P((int)); @@ -110,7 +110,7 @@ void set_wounded_legs __P((long, int)); void heal_legs __P((void)); /* hack.do_name.c */ -coord getpos __P((int, char *)); +coord getpos __P((int, const char *)); int do_mname __P((void)); void do_oname __P((struct obj *)); int ddocall __P((void)); @@ -119,8 +119,8 @@ char *xmonnam __P((struct monst *, int)); char *lmonnam __P((struct monst *)); char *monnam __P((struct monst *)); char *Monnam __P((struct monst *)); -char *amonnam __P((struct monst *, char *)); -char *Amonnam __P((struct monst *, char *)); +char *amonnam __P((struct monst *, const char *)); +char *Amonnam __P((struct monst *, const char *)); char *Xmonnam __P((struct monst *)); char *visctrl __P((int)); @@ -169,26 +169,26 @@ void done1 __P((int)); void done_intr __P((int)); void done_hangup __P((int)); void done_in_by __P((struct monst *)); -void done __P((char *)); +void done __P((const char *)); void topten __P((void)); void outheader __P((void)); struct toptenentry; int outentry __P((int, struct toptenentry *, int)); char *itoa __P((int)); -char *ordin __P((int)); +const char *ordin __P((int)); void clearlocks __P((void)); -void hangup __P((int)); +void hangup __P((int)) __attribute__((__noreturn__)); char *eos __P((char *)); void charcat __P((char *, int)); void prscore __P((int, char **)); /* hack.engrave.c */ struct engr *engr_at __P((xchar, xchar)); -int sengr_at __P((char *, xchar, xchar)); +int sengr_at __P((const char *, xchar, xchar)); void u_wipe_engr __P((int)); void wipe_engr_at __P((xchar, xchar, xchar)); void read_engr_at __P((int, int)); -void make_engr_at __P((int, int, char *)); +void make_engr_at __P((int, int, const char *)); int doengrave __P((void)); void save_engravings __P((int)); void rest_engravings __P((int)); @@ -199,7 +199,7 @@ int hitmm __P((struct monst *, struct monst *)); void mondied __P((struct monst *)); void monstone __P((struct monst *)); int fightm __P((struct monst *)); -int thitu __P((int, int, char *)); +int thitu __P((int, int, const char *)); boolean hmon __P((struct monst *, struct obj *, int)); int attack __P((struct monst *)); @@ -220,9 +220,9 @@ struct obj *o_on __P((unsigned int, struct obj *)); struct trap *t_at __P((int, int)); struct gold *g_at __P((int, int)); struct obj *mkgoldobj __P((long)); -struct obj *getobj __P((char *, char *)); +struct obj *getobj __P((const char *, const char *)); int ckunpaid __P((struct obj *)); -int ggetobj __P((char *, int (*fn)(struct obj *), int)); +int ggetobj __P((const char *, int (*fn)(struct obj *), int)); int askchain __P((struct obj *, char *, int, int (*)(struct obj *), int (*)(struct obj *), int)); char obj_to_let __P((struct obj *)); @@ -247,7 +247,7 @@ int dosuspend __P((void)); /* hack.lev.c */ void savelev __P((int, xchar)); -void bwrite __P((int, char *, unsigned)); +void bwrite __P((int, const void *, unsigned)); void saveobjchn __P((int, struct obj *)); void savemonchn __P((int, struct monst *)); void savegoldchn __P((int, struct gold *)); @@ -264,7 +264,7 @@ void impossible __P((const char *, ...)) void stop_occupation __P((void)); /* hack.makemon.c */ -struct monst *makemon __P((struct permonst *, int, int)); +struct monst *makemon __P((const struct permonst *, int, int)); coord enexto __P((xchar, xchar)); int goodpos __P((int, int)); void rloc __P((struct monst *)); @@ -312,7 +312,7 @@ void mkgold __P((long, int, int)); /* hack.mkshop.c */ void mkshop __P((void)); void mkzoo __P((int)); -struct permonst *morguemon __P((void)); +const struct permonst *morguemon __P((void)); void mkswamp __P((void)); int nexttodoor __P((int, int)); int has_dnstairs __P((struct mkroom *)); @@ -323,8 +323,8 @@ int sq __P((int)); /* hack.mon.c */ void movemon __P((void)); -void justswld __P((struct monst *, char *)); -void youswld __P((struct monst *, int, int, char *)); +void justswld __P((struct monst *, const char *)); +void youswld __P((struct monst *, int, int, const char *)); int dochugw __P((struct monst *)); int dochug __P((struct monst *)); int m_move __P((struct monst *, int)); @@ -332,7 +332,7 @@ void mpickgold __P((struct monst *)); void mpickgems __P((struct monst *)); int mfndpos __P((struct monst *, coord[9 ], int[9 ], int)); int dist __P((int, int)); -void poisoned __P((char *, char *)); +void poisoned __P((const char *, const char *)); void mondead __P((struct monst *)); void replmon __P((struct monst *, struct monst *)); void relmon __P((struct monst *)); @@ -340,9 +340,9 @@ void monfree __P((struct monst *)); void dmonsfree __P((void)); void unstuck __P((struct monst *)); void killed __P((struct monst *)); -void kludge __P((char *, char *)); +void kludge __P((const char *, const char *)); void rescham __P((void)); -int newcham __P((struct monst *, struct permonst *)); +int newcham __P((struct monst *, const struct permonst *)); void mnexto __P((struct monst *)); int ishuman __P((struct monst *)); void setmangry __P((struct monst *)); @@ -367,8 +367,8 @@ char *sitoa __P((int)); char *typename __P((int)); char *xname __P((struct obj *)); char *doname __P((struct obj *)); -void setan __P((char *, char *)); -char *aobjnam __P((struct obj *, char *)); +void setan __P((const char *, char *)); +char *aobjnam __P((struct obj *, const char *)); char *Doname __P((struct obj *)); struct obj *readobjnam __P((char *)); @@ -384,17 +384,17 @@ void page_more __P((FILE *, int)); void set_whole_screen __P((void)); int readnews __P((void)); void set_pager __P((int)); -int page_line __P((char *)); -void cornline __P((int, char *)); +int page_line __P((const char *)); +void cornline __P((int, const char *)); int dohelp __P((void)); -int page_file __P((char *, boolean)); +int page_file __P((const char *, boolean)); int dosh __P((void)); int child __P((int)); /* hack.potion.c */ int dodrink __P((void)); void pluslvl __P((void)); -void strange_feeling __P((struct obj *, char *)); +void strange_feeling __P((struct obj *, const char *)); void potionhit __P((struct monst *, struct obj *)); void potionbreathe __P((struct obj *)); int dodip __P((void)); @@ -408,7 +408,7 @@ void atl __P((int, int, int)); void on_scr __P((int, int)); void tmp_at __P((schar, schar)); void Tmp_at __P((schar, schar)); -void setclipped __P((void)); +void setclipped __P((void)) __attribute__((__noreturn__)); void at __P((xchar, xchar, int)); void prme __P((void)); int doredraw __P((void)); @@ -526,16 +526,17 @@ void stoned_dialogue __P((void)); int doredotopl __P((void)); void redotoplin __P((void)); void remember_topl __P((void)); -void addtopl __P((char *)); -void xmore __P((char *)); +void addtopl __P((const char *)); +void xmore __P((const char *)); void more __P((void)); -void cmore __P((char *)); +void cmore __P((const char *)); void clrlin __P((void)); void pline __P((const char *, ...)) __attribute__((__format__(__printf__, 1, 2))); -void vpline __P((const char *, va_list)); +void vpline __P((const char *, va_list)) + __attribute__((__format__(__printf__, 1, 0))); void putsym __P((int)); -void putstr __P((char *)); +void putstr __P((const char *)); /* hack.track.c */ void initrack __P((void)); @@ -546,7 +547,7 @@ coord *gettrack __P((int, int)); struct trap *maketrap __P((int, int, int)); void dotrap __P((struct trap *)); int mintrap __P((struct monst *)); -void selftouch __P((char *)); +void selftouch __P((const char *)); void float_up __P((void)); void float_down __P((void)); void vtele __P((void)); @@ -561,18 +562,18 @@ void drown __P((void)); /* hack.tty.c */ void gettty __P((void)); -void settty __P((char *)); +void settty __P((const char *)); void setctty __P((void)); void setftty __P((void)); void error __P((const char *, ...)) __attribute__((__format__(__printf__, 1, 2),__noreturn__)); void getlin __P((char *)); void getret __P((void)); -void cgetret __P((char *)); -void xwaitforspace __P((char *)); +void cgetret __P((const char *)); +void xwaitforspace __P((const char *)); char *parse __P((void)); char readchar __P((void)); -void end_of_input __P((void)); +void end_of_input __P((void)) __attribute__((__noreturn__)); /* hack.u_init.c */ void u_init __P((void)); @@ -647,9 +648,9 @@ void setnotworn __P((struct obj *)); void bhitm __P((struct monst *, struct obj *)); int bhito __P((struct obj *, struct obj *)); int dozap __P((void)); -char *exclam __P((int)); -void hit __P((char *, struct monst *, char *)); -void miss __P((char *, struct monst *)); +const char *exclam __P((int)); +void hit __P((const char *, struct monst *, const char *)); +void miss __P((const char *, struct monst *)); struct monst *bhit __P((int, int, int, int, void (*)(struct monst *, struct obj *), int (*)(struct obj *, struct obj *), diff --git a/hack/hack.Decl.c b/hack/hack.Decl.c index 09051a8c..8a321095 100644 --- a/hack/hack.Decl.c +++ b/hack/hack.Decl.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.Decl.c,v 1.4 1997/10/19 16:57:30 christos Exp $ */ +/* $NetBSD: hack.Decl.c,v 1.5 2001/03/25 20:43:59 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.Decl.c,v 1.4 1997/10/19 16:57:30 christos Exp $"); +__RCSID("$NetBSD: hack.Decl.c,v 1.5 2001/03/25 20:43:59 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -35,7 +35,8 @@ struct monst youmonst; /* dummy; used as return value for boomhit */ xchar dlevel = 1; xchar xupstair, yupstair, xdnstair, ydnstair; -char *save_cm = 0, *killer, *nomovemsg; +char *save_cm = 0; +const char *killer, *nomovemsg; long moves = 1; long wailmsg = 0; @@ -49,4 +50,4 @@ xchar seelx, seehx, seely, seehy; /* corners of lit room */ coord bhitpos; -char quitchars[] = " \r\n\033"; +const char quitchars[] = " \r\n\033"; diff --git a/hack/hack.apply.c b/hack/hack.apply.c index af727d0d..ece39cd0 100644 --- a/hack/hack.apply.c +++ b/hack/hack.apply.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.apply.c,v 1.5 1997/10/19 16:57:32 christos Exp $ */ +/* $NetBSD: hack.apply.c,v 1.6 2001/03/25 20:43:59 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.apply.c,v 1.5 1997/10/19 16:57:32 christos Exp $"); +__RCSID("$NetBSD: hack.apply.c,v 1.6 2001/03/25 20:43:59 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -80,7 +80,7 @@ xit: /* ARGSUSED */ static void use_camera(obj) /* */ - struct obj *obj; + struct obj *obj __attribute__((__unused__)); { struct monst *mtmp; if (!getdir(1)) { /* ask: in what direction? */ @@ -246,7 +246,7 @@ bchit(ddx, ddy, range, sym) /* ARGSUSED */ static void use_whistle(obj) - struct obj *obj; + struct obj *obj __attribute__((__unused__)); { struct monst *mtmp = fmon; pline("You produce a high whistling sound."); @@ -264,7 +264,7 @@ use_whistle(obj) /* ARGSUSED */ static void use_magic_whistle(obj) - struct obj *obj; + struct obj *obj __attribute__((__unused__)); { struct monst *mtmp = fmon; pline("You produce a strange whistling sound."); @@ -317,7 +317,7 @@ dig() } } } else if (dig_effort > 100) { - char *digtxt; + const char *digtxt; struct obj *obj; lev = &levl[dpx][dpy]; diff --git a/hack/hack.bones.c b/hack/hack.bones.c index 177034a8..72285c51 100644 --- a/hack/hack.bones.c +++ b/hack/hack.bones.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.bones.c,v 1.4 1997/10/19 16:57:34 christos Exp $ */ +/* $NetBSD: hack.bones.c,v 1.5 2001/03/25 20:43:59 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.bones.c,v 1.4 1997/10/19 16:57:34 christos Exp $"); +__RCSID("$NetBSD: hack.bones.c,v 1.5 2001/03/25 20:43:59 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -31,7 +31,7 @@ savebones() return; /* not so many ghosts on low levels */ bones[6] = '0' + (dlevel / 10); bones[7] = '0' + (dlevel % 10); - if ((fd = open(bones, 0)) >= 0) { + if ((fd = open(bones, O_RDONLY)) >= 0) { (void) close(fd); return; } @@ -98,7 +98,7 @@ getbones() return (0); /* only once in three times do we find bones */ bones[6] = '0' + dlevel / 10; bones[7] = '0' + dlevel % 10; - if ((fd = open(bones, 0)) < 0) + if ((fd = open(bones, O_RDONLY)) < 0) return (0); if ((ok = uptodate(fd)) != 0) { getlev(fd, 0, dlevel); diff --git a/hack/hack.c b/hack/hack.c index ca523816..cc36aaaa 100644 --- a/hack/hack.c +++ b/hack/hack.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.c,v 1.4 1997/10/19 16:57:37 christos Exp $ */ +/* $NetBSD: hack.c,v 1.5 2001/03/25 20:43:59 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.c,v 1.4 1997/10/19 16:57:37 christos Exp $"); +__RCSID("$NetBSD: hack.c,v 1.5 2001/03/25 20:43:59 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -353,7 +353,7 @@ dopickup() } void -pickup(all) +pickup(int all) { struct gold *gold; struct obj *obj, *obj2; @@ -836,7 +836,7 @@ losestr(num) /* may kill you; cause may be poison or */ void losehp(n, knam) int n; - char *knam; + const char *knam; { u.uhp -= n; if (u.uhp > u.uhpmax) diff --git a/hack/hack.cmd.c b/hack/hack.cmd.c index f171db90..8ca6adda 100644 --- a/hack/hack.cmd.c +++ b/hack/hack.cmd.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.cmd.c,v 1.5 2001/01/16 02:50:28 cgd Exp $ */ +/* $NetBSD: hack.cmd.c,v 1.6 2001/03/25 20:43:59 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,14 +6,14 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.cmd.c,v 1.5 2001/01/16 02:50:28 cgd Exp $"); +__RCSID("$NetBSD: hack.cmd.c,v 1.6 2001/03/25 20:43:59 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" #include "def.func_tab.h" -struct func_tab cmdlist[] = { +const struct func_tab cmdlist[] = { { '\020', doredotopl }, { '\022', doredraw }, { '\024', dotele }, @@ -77,7 +77,7 @@ struct func_tab cmdlist[] = { { 0, 0 } }; -struct ext_func_tab extcmdlist[] = { +const struct ext_func_tab extcmdlist[] = { { "dip", dodip }, { "pray", dopray }, { (char *) 0, donull } @@ -85,9 +85,9 @@ struct ext_func_tab extcmdlist[] = { void rhack(cmd) - char *cmd; + const char *cmd; { - struct func_tab *tlist = cmdlist; + const struct func_tab *tlist = cmdlist; boolean firsttime = FALSE; int res; @@ -190,7 +190,7 @@ doextcmd() { /* here after # - now read a full-word * command */ char buf[BUFSZ]; - struct ext_func_tab *efp = extcmdlist; + const struct ext_func_tab *efp = extcmdlist; pline("# "); getlin(buf); diff --git a/hack/hack.do.c b/hack/hack.do.c index 2ac7f279..98921325 100644 --- a/hack/hack.do.c +++ b/hack/hack.do.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.do.c,v 1.4 1997/10/19 16:57:41 christos Exp $ */ +/* $NetBSD: hack.do.c,v 1.5 2001/03/25 20:43:59 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.do.c,v 1.4 1997/10/19 16:57:41 christos Exp $"); +__RCSID("$NetBSD: hack.do.c,v 1.5 2001/03/25 20:43:59 jsm Exp $"); #endif /* not lint */ /* Contains code for 'd', 'D' (drop), '>', '<' (up, down) and 't' (throw) */ @@ -185,7 +185,7 @@ goto_level(newlevel, at_stairs) if (!level_exists[dlevel]) mklev(); else { - if ((fd = open(lock, 0)) < 0) { + if ((fd = open(lock, O_RDONLY)) < 0) { pline("Cannot open %s .", lock); pline("Probably someone removed it."); done("tricked"); diff --git a/hack/hack.do_name.c b/hack/hack.do_name.c index 482c5e98..e6752e46 100644 --- a/hack/hack.do_name.c +++ b/hack/hack.do_name.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.do_name.c,v 1.4 1997/10/19 16:57:46 christos Exp $ */ +/* $NetBSD: hack.do_name.c,v 1.5 2001/03/25 20:43:59 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.do_name.c,v 1.4 1997/10/19 16:57:46 christos Exp $"); +__RCSID("$NetBSD: hack.do_name.c,v 1.5 2001/03/25 20:43:59 jsm Exp $"); #endif /* not lint */ #include @@ -16,7 +16,7 @@ __RCSID("$NetBSD: hack.do_name.c,v 1.4 1997/10/19 16:57:46 christos Exp $"); coord getpos(force, goal) int force; - char *goal; + const char *goal; { int cx, cy, i, c; coord cc; @@ -202,7 +202,7 @@ docall(obj) *str1 = str; } -char *ghostnames[] = {/* these names should have length < PL_NSIZ */ +const char *const ghostnames[] = {/* these names should have length < PL_NSIZ */ "adri", "andries", "andreas", "bert", "david", "dirk", "emile", "frans", "fred", "greg", "hether", "jay", "john", "jon", "kay", "kenny", "maud", "michiel", "mike", "peter", "robert", "ron", @@ -222,7 +222,7 @@ xmonnam(mtmp, vb) switch (mtmp->data->mlet) { case ' ': { - char *gn = (char *) mtmp->mextra; + const char *gn = (char *) mtmp->mextra; if (!*gn) { /* might also look in scorefile */ gn = ghostnames[rn2(SIZE(ghostnames))]; if (!rn2(2)) @@ -277,7 +277,7 @@ Monnam(mtmp) char * amonnam(mtmp, adj) struct monst *mtmp; - char *adj; + const char *adj; { char *bp = monnam(mtmp); static char buf[BUFSZ]; /* %% */ @@ -291,7 +291,7 @@ amonnam(mtmp, adj) char * Amonnam(mtmp, adj) struct monst *mtmp; - char *adj; + const char *adj; { char *bp = amonnam(mtmp, adj); diff --git a/hack/hack.dog.c b/hack/hack.dog.c index 4194e76f..5a8ebfb3 100644 --- a/hack/hack.dog.c +++ b/hack/hack.dog.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.dog.c,v 1.4 1997/10/19 16:57:50 christos Exp $ */ +/* $NetBSD: hack.dog.c,v 1.5 2001/03/25 20:43:59 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.dog.c,v 1.4 1997/10/19 16:57:50 christos Exp $"); +__RCSID("$NetBSD: hack.dog.c,v 1.5 2001/03/25 20:43:59 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -15,11 +15,11 @@ __RCSID("$NetBSD: hack.dog.c,v 1.4 1997/10/19 16:57:50 christos Exp $"); #include "def.edog.h" #include "def.mkroom.h" -struct permonst li_dog = +const struct permonst li_dog = {"little dog", 'd', 2, 18, 6, 1, 6, sizeof(struct edog)}; -struct permonst dog = +const struct permonst dog = {"dog", 'd', 4, 16, 5, 1, 6, sizeof(struct edog)}; -struct permonst la_dog = +const struct permonst la_dog = {"large dog", 'd', 6, 15, 4, 2, 4, sizeof(struct edog)}; @@ -131,13 +131,12 @@ dogfood(obj) /* return 0 (no move), 1 (move) or 2 (dead) */ int -dog_move(mtmp, after) - struct monst *mtmp; +dog_move(struct monst *mtmp, int after) { int nx, ny, omx, omy, appr, nearer, j; int udist, chi = 0, i, whappr; struct monst *mtmp2; - struct permonst *mdat = mtmp->data; + const struct permonst *mdat = mtmp->data; struct edog *edog = EDOG(mtmp); struct obj *obj; struct trap *trap; diff --git a/hack/hack.eat.c b/hack/hack.eat.c index 3685ba5d..4bbd1a45 100644 --- a/hack/hack.eat.c +++ b/hack/hack.eat.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.eat.c,v 1.4 1997/10/19 16:57:53 christos Exp $ */ +/* $NetBSD: hack.eat.c,v 1.5 2001/03/25 20:44:00 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.eat.c,v 1.4 1997/10/19 16:57:53 christos Exp $"); +__RCSID("$NetBSD: hack.eat.c,v 1.5 2001/03/25 20:44:00 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -22,7 +22,7 @@ char POISONOUS[] = "ADKSVabhks"; #define FAINTED 5 #define STARVED 6 -char *hu_stat[] = { +const char *const hu_stat[] = { "Satiated", " ", "Hungry ", @@ -40,8 +40,8 @@ init_uhunger() } #define TTSZ SIZE(tintxts) -struct { - char *txt; +const struct { + const char *txt; int nut; } tintxts[] = { { "It contains first quality peaches - what a surprise!", 40 }, diff --git a/hack/hack.end.c b/hack/hack.end.c index 0d99ef58..323d996e 100644 --- a/hack/hack.end.c +++ b/hack/hack.end.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.end.c,v 1.4 1997/10/19 16:57:55 christos Exp $ */ +/* $NetBSD: hack.end.c,v 1.5 2001/03/25 20:44:00 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.end.c,v 1.4 1997/10/19 16:57:55 christos Exp $"); +__RCSID("$NetBSD: hack.end.c,v 1.5 2001/03/25 20:44:00 jsm Exp $"); #endif /* not lint */ #include @@ -29,7 +29,7 @@ dodone() /*ARGSUSED*/ void done1(n) - int n; + int n __attribute__((__unused__)); { (void) signal(SIGINT, SIG_IGN); pline("Really quit?"); @@ -51,7 +51,7 @@ int done_hup; /*ARGSUSED*/ void done_intr(n) - int n; + int n __attribute__((__unused__)); { done_stopprint++; (void) signal(SIGINT, SIG_IGN); @@ -95,7 +95,7 @@ done_in_by(mtmp) /* Be careful not to call panic from here! */ void done(st1) - char *st1; + const char *st1; { #ifdef WIZARD @@ -265,8 +265,8 @@ topten() int rank, rank0 = -1, rank1 = 0; int occ_cnt = PERSMAX; struct toptenentry *t0, *t1, *tprev; - char *recfile = RECORD; - char *reclock = "record_lock"; + const char *recfile = RECORD; + const char *reclock = "record_lock"; int sleepct = 300; FILE *rfile; int flg = 0; @@ -439,8 +439,7 @@ outheader() /* so>0: standout line; so=0: ordinary line; so<0: no output, return lth */ int -outentry(rank, t1, so) - struct toptenentry *t1; +outentry(int rank, struct toptenentry *t1, int so) { boolean quit = FALSE, killed = FALSE, starv = FALSE; char linebuf[BUFSZ]; @@ -527,7 +526,7 @@ itoa(a) return (buf); } -char * +const char * ordin(n) int n; { @@ -593,7 +592,7 @@ prscore(argc, argv) int playerct; int rank; struct toptenentry *t1, *t2; - char *recfile = RECORD; + const char *recfile = RECORD; FILE *rfile; int flg = 0; int i; diff --git a/hack/hack.engrave.c b/hack/hack.engrave.c index 8261967f..a2f827f7 100644 --- a/hack/hack.engrave.c +++ b/hack/hack.engrave.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.engrave.c,v 1.4 1997/10/19 16:57:58 christos Exp $ */ +/* $NetBSD: hack.engrave.c,v 1.5 2001/03/25 20:44:00 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.engrave.c,v 1.4 1997/10/19 16:57:58 christos Exp $"); +__RCSID("$NetBSD: hack.engrave.c,v 1.5 2001/03/25 20:44:00 jsm Exp $"); #endif /* not lint */ #include @@ -42,7 +42,7 @@ engr_at(x, y) int sengr_at(s, x, y) - char *s; + const char *s; xchar x, y; { struct engr *ep = engr_at(x, y); @@ -126,7 +126,7 @@ read_engr_at(x, y) void make_engr_at(x, y, s) int x, y; - char *s; + const char *s; { struct engr *ep; diff --git a/hack/hack.fight.c b/hack/hack.fight.c index 9ca08a19..9db7893a 100644 --- a/hack/hack.fight.c +++ b/hack/hack.fight.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.fight.c,v 1.4 1997/10/19 16:58:00 christos Exp $ */ +/* $NetBSD: hack.fight.c,v 1.5 2001/03/25 20:44:00 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.fight.c,v 1.4 1997/10/19 16:58:00 christos Exp $"); +__RCSID("$NetBSD: hack.fight.c,v 1.5 2001/03/25 20:44:00 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -20,7 +20,7 @@ int hitmm(magr, mdef) struct monst *magr, *mdef; { - struct permonst *pa = magr->data, *pd = mdef->data; + const struct permonst *pa = magr->data, *pd = mdef->data; int hit; schar tmp; boolean vis; @@ -89,7 +89,7 @@ void mondied(mdef) struct monst *mdef; { - struct permonst *pd = mdef->data; + const struct permonst *pd = mdef->data; if (letter(pd->mlet) && rn2(3)) { (void) mkobj_at(pd->mlet, mdef->mx, mdef->my); if (cansee(mdef->mx, mdef->my)) { @@ -136,7 +136,7 @@ fightm(mtmp) int thitu(tlev, dam, name) int tlev, dam; - char *name; + const char *name; { char buf[BUFSZ]; setan(name, buf); @@ -291,7 +291,7 @@ attack(mtmp) { schar tmp; boolean malive = TRUE; - struct permonst *mdat; + const struct permonst *mdat; mdat = mtmp->data; u_wipe_engr(3); /* andrew@orca: prevent unlimited pick-axe diff --git a/hack/hack.h b/hack/hack.h index e343dfa2..252f9835 100644 --- a/hack/hack.h +++ b/hack/hack.h @@ -1,4 +1,4 @@ -/* $NetBSD: hack.h,v 1.7 2001/02/05 00:37:43 christos Exp $ */ +/* $NetBSD: hack.h,v 1.8 2001/03/25 20:44:00 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -105,7 +105,7 @@ struct you { #define Stoned u.uprops[STONED].p_flgs #define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */ unsigned umconf:1; - char *usick_cause; + const char *usick_cause; struct prop uprops[LAST_RING+10]; unsigned uswallow:1; /* set if swallowed by a monster */ @@ -133,13 +133,14 @@ extern boolean in_mklev; extern boolean level_exists[]; extern boolean restoring; extern char *CD; -extern char *catmore; +extern const char *catmore; extern char *hname; -extern char *hu_stat[]; /* in eat.c */ -extern char *nomovemsg; -extern char *occtxt; -extern char *save_cm,*killer; -extern char *traps[]; +extern const char *const hu_stat[]; /* in eat.c */ +extern const char *nomovemsg; +extern const char *occtxt; +extern char *save_cm; +extern const char *killer; +extern const char *const traps[]; extern char SAVEF[]; extern char fut_geno[60]; /* idem */ extern char genocided[60]; /* defined in Decl.c */ @@ -148,10 +149,10 @@ extern char mlarge[]; extern char morc; extern char nul[]; extern char plname[PL_NSIZ], pl_character[PL_CSIZ]; -extern char quitchars[]; +extern const char quitchars[]; extern char sdir[]; /* defined in hack.c */ -extern char shtypes[]; /* = "=/)%?!["; 8 types: 7 specialized, 1 mixed */ -extern char vowels[]; +extern const char shtypes[]; /* = "=/)%?!["; 8 types: 7 specialized, 1 mixed */ +extern const char vowels[]; extern coord bhitpos; /* place where thrown weapon falls to the ground */ extern int (*afternmv) __P((void)); extern int (*occupation) __P((void)); @@ -172,11 +173,11 @@ extern struct obj *uleft, *uright, *fcobj; extern struct obj *uball; /* defined if PUNISHED */ extern struct obj *uchain; /* defined iff PUNISHED */ extern struct obj zeroobj; -extern struct permonst li_dog, dog, la_dog; -extern struct permonst pm_eel; -extern struct permonst pm_ghost; -extern struct permonst pm_mail_daemon; -extern struct permonst pm_wizard; +extern const struct permonst li_dog, dog, la_dog; +extern const struct permonst pm_eel; +extern const struct permonst pm_ghost; +extern const struct permonst pm_mail_daemon; +extern const struct permonst pm_wizard; #ifndef NOWORM extern long wgrowtime[32]; extern struct wseg *m_atseg; diff --git a/hack/hack.invent.c b/hack/hack.invent.c index 9cd1bb92..c81bdef6 100644 --- a/hack/hack.invent.c +++ b/hack/hack.invent.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.invent.c,v 1.6 1997/10/23 07:05:55 fair Exp $ */ +/* $NetBSD: hack.invent.c,v 1.7 2001/03/25 20:44:00 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.invent.c,v 1.6 1997/10/23 07:05:55 fair Exp $"); +__RCSID("$NetBSD: hack.invent.c,v 1.7 2001/03/25 20:44:00 jsm Exp $"); #endif /* not lint */ #include @@ -335,7 +335,7 @@ mkgoldobj(q) */ struct obj * getobj(let, word) - char *let, *word; + const char *let, *word; { struct obj *otmp; char ilet, ilet1, ilet2; @@ -508,7 +508,7 @@ ckunpaid(otmp) /* return the number of times fn was called successfully */ int ggetobj(word, fn, max) - char *word; + const char *word; int (*fn) __P((struct obj *)); int max; { @@ -799,7 +799,7 @@ dolook() { struct obj *otmp = NULL, *otmp0 = NULL; struct gold *gold = NULL; - char *verb = Blind ? "feel" : "see"; + const char *verb = Blind ? "feel" : "see"; int ct = 0; if (!u.uswallow) { @@ -866,6 +866,7 @@ stackobj(obj) int merged(otmp, obj, lose) struct obj *otmp, *obj; + int lose; { if (obj->otyp == otmp->otyp && obj->unpaid == otmp->unpaid && diff --git a/hack/hack.lev.c b/hack/hack.lev.c index 1454d3db..9222b95a 100644 --- a/hack/hack.lev.c +++ b/hack/hack.lev.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.lev.c,v 1.4 1997/10/19 16:58:09 christos Exp $ */ +/* $NetBSD: hack.lev.c,v 1.5 2001/03/25 20:44:01 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.lev.c,v 1.4 1997/10/19 16:58:09 christos Exp $"); +__RCSID("$NetBSD: hack.lev.c,v 1.5 2001/03/25 20:44:01 jsm Exp $"); #endif /* not lint */ #include @@ -75,7 +75,7 @@ savelev(fd, lev) void bwrite(fd, loc, num) int fd; - char *loc; + const void *loc; unsigned num; { /* lint wants the 3rd arg of write to be an int; lint -p an unsigned */ @@ -111,9 +111,9 @@ savemonchn(fd, mtmp) struct monst *mtmp2; unsigned xl; int minusone = -1; - struct permonst *monbegin = &mons[0]; + const struct permonst *monbegin = &mons[0]; - bwrite(fd, (char *) &monbegin, sizeof(monbegin)); + bwrite(fd, &monbegin, sizeof(monbegin)); while (mtmp) { mtmp2 = mtmp->nmon; diff --git a/hack/hack.main.c b/hack/hack.main.c index 7f817da5..6c0e7491 100644 --- a/hack/hack.main.c +++ b/hack/hack.main.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.main.c,v 1.5 2000/03/02 18:19:06 kleink Exp $ */ +/* $NetBSD: hack.main.c,v 1.6 2001/03/25 20:44:01 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.main.c,v 1.5 2000/03/02 18:19:06 kleink Exp $"); +__RCSID("$NetBSD: hack.main.c,v 1.6 2001/03/25 20:44:01 jsm Exp $"); #endif /* not lint */ #include @@ -24,19 +24,19 @@ __RCSID("$NetBSD: hack.main.c,v 1.5 2000/03/02 18:19:06 kleink Exp $"); int (*afternmv) __P((void)); int (*occupation) __P((void)); -char *occtxt; /* defined when occupation != NULL */ +const char *occtxt; /* defined when occupation != NULL */ int hackpid; /* current pid */ int locknum; /* max num of players */ #ifdef DEF_PAGER -char *catmore; /* default pager */ +const char *catmore; /* default pager */ #endif char SAVEF[PL_NSIZ + 11] = "save/"; /* save/99999player */ char *hname; /* name of the game (argv[0] of call) */ char obuf[BUFSIZ]; /* BUFSIZ is defined in stdio.h */ int main __P((int, char *[])); -static void chdirx __P((char *, boolean)); +static void chdirx __P((const char *, boolean)); int main(argc, argv) @@ -48,6 +48,12 @@ main(argc, argv) char *dir; #endif + /* Check for dirty tricks with closed fds 0, 1, 2 */ + fd = open("/dev/null", O_RDONLY); + if (fd < 3) + exit(1); + close(fd); + hname = argv[0]; hackpid = getpid(); @@ -229,7 +235,7 @@ main(argc, argv) } if ((sfoo = getenv("GENOCIDED")) != NULL) { if (*sfoo == '!') { - struct permonst *pm = mons; + const struct permonst *pm = mons; char *gp = genocided; while (pm < mons + CMNUM + 2) { @@ -247,7 +253,7 @@ main(argc, argv) setftty(); (void) sprintf(SAVEF, "save/%d%s", getuid(), plname); regularize(SAVEF + 5); /* avoid . or / in name */ - if ((fd = open(SAVEF, 0)) >= 0 && + if ((fd = open(SAVEF, O_RDONLY)) >= 0 && (uptodate(fd) || unlink(SAVEF) == 666)) { (void) signal(SIGINT, done1); pline("Restoring old save file..."); @@ -484,7 +490,7 @@ impossible(va_alist) #ifdef CHDIR static void chdirx(dir, wr) - char *dir; + const char *dir; boolean wr; { @@ -516,7 +522,7 @@ chdirx(dir, wr) if (dir == NULL) dir = "."; - if ((fd = open(RECORD, 2)) < 0) { + if ((fd = open(RECORD, O_RDWR)) < 0) { printf("Warning: cannot write %s/%s", dir, RECORD); getret(); } else diff --git a/hack/hack.makemon.c b/hack/hack.makemon.c index b2e57fd1..1f6a174d 100644 --- a/hack/hack.makemon.c +++ b/hack/hack.makemon.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.makemon.c,v 1.4 1997/10/19 16:58:17 christos Exp $ */ +/* $NetBSD: hack.makemon.c,v 1.5 2001/03/25 20:44:01 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.makemon.c,v 1.4 1997/10/19 16:58:17 christos Exp $"); +__RCSID("$NetBSD: hack.makemon.c,v 1.5 2001/03/25 20:44:01 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -23,8 +23,7 @@ struct monst zeromonst; * note that in this case we return only one of them (the one at [x,y]). */ struct monst * -makemon(ptr, x, y) - struct permonst *ptr; +makemon(const struct permonst *ptr, int x, int y) { struct monst *mtmp; int tmp, ct; @@ -169,7 +168,7 @@ foofull: } int -goodpos(x, y) +goodpos(int x, int y) { /* used only in mnexto and rloc */ return ( !(x < 1 || x > COLNO - 2 || y < 1 || y > ROWNO - 2 || @@ -213,7 +212,7 @@ mkmon_at(let, x, y) int x, y; { int ct; - struct permonst *ptr; + const struct permonst *ptr; for (ct = 0; ct < CMNUM; ct++) { ptr = &mons[ct]; diff --git a/hack/hack.mhitu.c b/hack/hack.mhitu.c index c5749cc1..bf8477c9 100644 --- a/hack/hack.mhitu.c +++ b/hack/hack.mhitu.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.mhitu.c,v 1.4 1997/10/19 16:58:22 christos Exp $ */ +/* $NetBSD: hack.mhitu.c,v 1.5 2001/03/25 20:44:01 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.mhitu.c,v 1.4 1997/10/19 16:58:22 christos Exp $"); +__RCSID("$NetBSD: hack.mhitu.c,v 1.5 2001/03/25 20:44:01 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -20,7 +20,7 @@ int mhitu(mtmp) struct monst *mtmp; { - struct permonst *mdat = mtmp->data; + const struct permonst *mdat = mtmp->data; int tmp, ctmp; nomul(0); diff --git a/hack/hack.mklev.c b/hack/hack.mklev.c index 49020024..92febe3a 100644 --- a/hack/hack.mklev.c +++ b/hack/hack.mklev.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.mklev.c,v 1.4 1997/10/19 16:58:24 christos Exp $ */ +/* $NetBSD: hack.mklev.c,v 1.5 2001/03/25 20:44:01 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.mklev.c,v 1.4 1997/10/19 16:58:24 christos Exp $"); +__RCSID("$NetBSD: hack.mklev.c,v 1.5 2001/03/25 20:44:01 jsm Exp $"); #endif /* not lint */ #include @@ -23,15 +23,12 @@ __RCSID("$NetBSD: hack.mklev.c,v 1.4 1997/10/19 16:58:24 christos Exp $"); #define YLIM 3 boolean secret; /* TRUE while making a vault: increase * [XY]LIM */ -struct mkroom rooms[MAXNROFROOMS + 1]; int smeq[MAXNROFROOMS + 1]; -coord doors[DOORMAX]; int doorindex; struct rm zerorm; schar nxcor; boolean goldseen; int nroom; -xchar xdnstair, xupstair, ydnstair, yupstair; /* Definitions used by makerooms() and addrs() */ #define MAXRS 50 /* max lth of temp rectangle table - @@ -309,7 +306,7 @@ comp(vx, vy) } coord -finddpos(xl, yl, xh, yh) +finddpos(int xl, int yl, int xh, int yh) { coord ff; int x, y; diff --git a/hack/hack.mkmaze.c b/hack/hack.mkmaze.c index bb894202..d5d2f76f 100644 --- a/hack/hack.mkmaze.c +++ b/hack/hack.mkmaze.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.mkmaze.c,v 1.4 1997/10/19 16:58:27 christos Exp $ */ +/* $NetBSD: hack.mkmaze.c,v 1.5 2001/03/25 20:44:01 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,13 +6,13 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.mkmaze.c,v 1.4 1997/10/19 16:58:27 christos Exp $"); +__RCSID("$NetBSD: hack.mkmaze.c,v 1.5 2001/03/25 20:44:01 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" #include "def.mkroom.h" /* not really used */ -struct permonst hell_hound = +const struct permonst hell_hound = {"hell hound", 'd', 12, 14, 2, 3, 6, 0}; void diff --git a/hack/hack.mkobj.c b/hack/hack.mkobj.c index 39d4804f..9e0240e6 100644 --- a/hack/hack.mkobj.c +++ b/hack/hack.mkobj.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.mkobj.c,v 1.4 1997/10/19 16:58:29 christos Exp $ */ +/* $NetBSD: hack.mkobj.c,v 1.5 2001/03/25 20:44:01 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.mkobj.c,v 1.4 1997/10/19 16:58:29 christos Exp $"); +__RCSID("$NetBSD: hack.mkobj.c,v 1.5 2001/03/25 20:44:01 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -151,8 +151,7 @@ weight(obj) } void -mkgold(num, x, y) - long num; +mkgold(long num, int x, int y) { struct gold *gold; long amount = (num ? num : 1 + (rnd(dlevel + 2) * rnd(30))); diff --git a/hack/hack.mkshop.c b/hack/hack.mkshop.c index c6d8eb61..8ec09f9c 100644 --- a/hack/hack.mkshop.c +++ b/hack/hack.mkshop.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.mkshop.c,v 1.5 1997/10/19 16:58:31 christos Exp $ */ +/* $NetBSD: hack.mkshop.c,v 1.6 2001/03/25 20:44:01 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.mkshop.c,v 1.5 1997/10/19 16:58:31 christos Exp $"); +__RCSID("$NetBSD: hack.mkshop.c,v 1.6 2001/03/25 20:44:01 jsm Exp $"); #endif /* not lint */ #include @@ -16,7 +16,7 @@ __RCSID("$NetBSD: hack.mkshop.c,v 1.5 1997/10/19 16:58:31 christos Exp $"); #include "def.mkroom.h" #include "def.eshk.h" #define ESHK ((struct eshk *)(&(shk->mextra[0]))) -schar shprobs[] = {3, 3, 5, 5, 10, 10, 14, 50}; /* their probabilities */ +const schar shprobs[] = {3, 3, 5, 5, 10, 10, 14, 50}; /* their probabilities */ void mkshop() @@ -217,7 +217,7 @@ mkzoo(type) } } -struct permonst * +const struct permonst * morguemon() { int i = rn2(100), hd = rn2(dlevel); diff --git a/hack/hack.mon.c b/hack/hack.mon.c index df37d3a9..8c0d7223 100644 --- a/hack/hack.mon.c +++ b/hack/hack.mon.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.mon.c,v 1.4 1997/10/19 16:58:34 christos Exp $ */ +/* $NetBSD: hack.mon.c,v 1.5 2001/03/25 20:44:01 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.mon.c,v 1.4 1997/10/19 16:58:34 christos Exp $"); +__RCSID("$NetBSD: hack.mon.c,v 1.5 2001/03/25 20:44:01 jsm Exp $"); #endif /* not lint */ #include @@ -21,7 +21,7 @@ __RCSID("$NetBSD: hack.mon.c,v 1.4 1997/10/19 16:58:34 christos Exp $"); int warnlevel; /* used by movemon and dochugw */ long lastwarntime; int lastwarnlev; -char *warnings[] = { +const char *const warnings[] = { "white", "pink", "red", "ruby", "purple", "black" }; @@ -93,7 +93,7 @@ next_mon: warnlevel = SIZE(warnings) - 1; if (warnlevel >= 0) if (warnlevel > lastwarnlev || moves > lastwarntime + 5) { - char *rr; + const char *rr; switch (Warning & (LEFT_RING | RIGHT_RING)) { case LEFT_RING: rr = "Your left ring glows"; @@ -118,7 +118,7 @@ next_mon: void justswld(mtmp, name) struct monst *mtmp; - char *name; + const char *name; { mtmp->mx = u.ux; @@ -137,7 +137,7 @@ void youswld(mtmp, dam, die, name) struct monst *mtmp; int dam, die; - char *name; + const char *name; { if (mtmp != u.ustuck) return; @@ -178,7 +178,7 @@ int dochug(mtmp) struct monst *mtmp; { - struct permonst *mdat; + const struct permonst *mdat; int tmp = 0, nearby, scared; if (mtmp->cham && !rn2(6)) @@ -260,8 +260,7 @@ dochug(mtmp) } int -m_move(mtmp, after) - struct monst *mtmp; +m_move(struct monst *mtmp, int after) { struct monst *mtmp2; int nx, ny, omx, omy, appr, nearer, cnt, i, j; @@ -623,7 +622,7 @@ dist(x, y) void poisoned(string, pname) - char *string, *pname; + const char *string, *pname; { int i; @@ -749,7 +748,7 @@ killed(mtmp) #define NEW_SCORING #endif /* lint */ int tmp, nk, x, y; - struct permonst *mdat; + const struct permonst *mdat; if (mtmp->cham) mtmp->data = PM_CHAMELEON; @@ -869,8 +868,7 @@ killed(mtmp) } void -kludge(str, arg) - char *str, *arg; +kludge(const char *str, const char *arg) { if (Blind) { if (*str == '%') @@ -897,7 +895,7 @@ int newcham(mtmp, mdat) /* make a chameleon look like a new monster */ /* returns 1 if the monster actually changed */ struct monst *mtmp; - struct permonst *mdat; + const struct permonst *mdat; { int mhp, hpn, hpd; diff --git a/hack/hack.monst.c b/hack/hack.monst.c index bf2c11b0..11d05af9 100644 --- a/hack/hack.monst.c +++ b/hack/hack.monst.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.monst.c,v 1.4 1997/10/19 16:58:36 christos Exp $ */ +/* $NetBSD: hack.monst.c,v 1.5 2001/03/25 20:44:02 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,14 +6,14 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.monst.c,v 1.4 1997/10/19 16:58:36 christos Exp $"); +__RCSID("$NetBSD: hack.monst.c,v 1.5 2001/03/25 20:44:02 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" #include "def.eshk.h" -struct permonst mons[CMNUM + 2] = { +const struct permonst mons[CMNUM + 2] = { {"bat", 'B', 1, 22, 8, 1, 4, 0}, {"gnome", 'G', 1, 6, 5, 1, 6, 0}, {"hobgoblin", 'H', 1, 9, 5, 1, 8, 0}, @@ -77,11 +77,11 @@ struct permonst mons[CMNUM + 2] = { {"shopkeeper", '@', 12, 18, 0, 4, 8, sizeof(struct eshk)} }; -struct permonst pm_ghost = {"ghost", ' ', 10, 3, -5, 1, 1, sizeof(plname)}; -struct permonst pm_wizard = { +const struct permonst pm_ghost = {"ghost", ' ', 10, 3, -5, 1, 1, sizeof(plname)}; +const struct permonst pm_wizard = { "wizard of Yendor", '1', 15, 12, -2, 1, 12, 0 }; #ifdef MAIL -struct permonst pm_mail_daemon = {"mail daemon", '2', 100, 1, 10, 0, 0, 0}; +const struct permonst pm_mail_daemon = {"mail daemon", '2', 100, 1, 10, 0, 0, 0}; #endif /* MAIL */ -struct permonst pm_eel = {"giant eel", ';', 15, 6, -3, 3, 6, 0}; +const struct permonst pm_eel = {"giant eel", ';', 15, 6, -3, 3, 6, 0}; diff --git a/hack/hack.o_init.c b/hack/hack.o_init.c index cea820e5..b86c2cfd 100644 --- a/hack/hack.o_init.c +++ b/hack/hack.o_init.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.o_init.c,v 1.5 1997/10/19 16:58:37 christos Exp $ */ +/* $NetBSD: hack.o_init.c,v 1.6 2001/03/25 20:44:02 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.o_init.c,v 1.5 1997/10/19 16:58:37 christos Exp $"); +__RCSID("$NetBSD: hack.o_init.c,v 1.6 2001/03/25 20:44:02 jsm Exp $"); #endif /* not lint */ #include @@ -31,7 +31,8 @@ void init_objects() { int i, j, first, last, sum, end; - char let, *tmp; + char let; + const char *tmp; /* * init base; if probs given check that they add up to 100, otherwise * compute probs; shuffle descriptions diff --git a/hack/hack.objnam.c b/hack/hack.objnam.c index 9a0048ee..4416fafb 100644 --- a/hack/hack.objnam.c +++ b/hack/hack.objnam.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.objnam.c,v 1.4 1997/10/19 16:58:39 christos Exp $ */ +/* $NetBSD: hack.objnam.c,v 1.5 2001/03/25 20:44:02 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.objnam.c,v 1.4 1997/10/19 16:58:39 christos Exp $"); +__RCSID("$NetBSD: hack.objnam.c,v 1.5 2001/03/25 20:44:02 jsm Exp $"); #endif /* not lint */ #include @@ -46,8 +46,8 @@ typename(otyp) { static char buf[BUFSZ]; struct objclass *ocl = &objects[otyp]; - char *an = ocl->oc_name; - char *dn = ocl->oc_descr; + const char *an = ocl->oc_name; + const char *dn = ocl->oc_descr; char *un = ocl->oc_uname; int nn = ocl->oc_name_known; switch (ocl->oc_olet) { @@ -98,8 +98,8 @@ xname(obj) static char bufr[BUFSZ]; char *buf = &(bufr[PREFIX]); /* leave room for "17 -3 " */ int nn = objects[obj->otyp].oc_name_known; - char *an = objects[obj->otyp].oc_name; - char *dn = objects[obj->otyp].oc_descr; + const char *an = objects[obj->otyp].oc_name; + const char *dn = objects[obj->otyp].oc_descr; char *un = objects[obj->otyp].oc_uname; int pl = (obj->quan != 1); if (!obj->dknown && !Blind) @@ -308,8 +308,7 @@ doname(obj) /* used only in hack.fight.c (thitu) */ void -setan(str, buf) - char *str, *buf; +setan(const char *str, char *buf) { if (strchr(vowels, *str)) Sprintf(buf, "an %s", str); @@ -320,7 +319,7 @@ setan(str, buf) char * aobjnam(otmp, verb) struct obj *otmp; - char *verb; + const char *verb; { char *bp = xname(otmp); char prefix[PREFIX]; @@ -354,8 +353,8 @@ Doname(obj) return (s); } -char *wrp[] = {"wand", "ring", "potion", "scroll", "gem"}; -char wrpsym[] = {WAND_SYM, RING_SYM, POTION_SYM, SCROLL_SYM, GEM_SYM}; +const char *const wrp[] = {"wand", "ring", "potion", "scroll", "gem"}; +const char wrpsym[] = {WAND_SYM, RING_SYM, POTION_SYM, SCROLL_SYM, GEM_SYM}; struct obj * readobjnam(bp) @@ -533,7 +532,7 @@ srch: if (let) i = bases[letindex(let)]; while (i <= NROFOBJECTS && (!let || objects[i].oc_olet == let)) { - char *zn = objects[i].oc_name; + const char *zn = objects[i].oc_name; if (!zn) goto nxti; diff --git a/hack/hack.pager.c b/hack/hack.pager.c index dec6504b..3ef74a63 100644 --- a/hack/hack.pager.c +++ b/hack/hack.pager.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.pager.c,v 1.5 1997/10/19 16:58:46 christos Exp $ */ +/* $NetBSD: hack.pager.c,v 1.6 2001/03/25 20:44:02 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.pager.c,v 1.5 1997/10/19 16:58:46 christos Exp $"); +__RCSID("$NetBSD: hack.pager.c,v 1.6 2001/03/25 20:44:02 jsm Exp $"); #endif /* not lint */ /* This file contains the command routine dowhatis() and a pager. */ @@ -69,7 +69,7 @@ static int got_intrup; void intruph(n) - int n; + int n __attribute__((__unused__)); { got_intrup++; } @@ -160,7 +160,7 @@ set_pager(mode) int page_line(s) /* returns 1 if we should quit */ - char *s; + const char *s; { if (cury == LI - 1) { if (!*s) @@ -198,7 +198,7 @@ page_line(s) /* returns 1 if we should quit */ void cornline(mode, text) int mode; - char *text; + const char *text; { static struct line { struct line *next_line; @@ -307,14 +307,14 @@ dohelp() int page_file(fnam, silent) /* return: 0 - cannot open fnam; 1 - * otherwise */ - char *fnam; + const char *fnam; boolean silent; { #ifdef DEF_PAGER /* this implies that UNIX is defined */ { /* use external pager; this may give security problems */ - int fd = open(fnam, 0); + int fd = open(fnam, O_RDONLY); if (fd < 0) { if (!silent) @@ -399,7 +399,7 @@ union wait { /* used only for the cast (union wait *) 0 */ #endif /* NOWAITINCLUDE */ int -child(wt) +child(int wt) { int status; int f; diff --git a/hack/hack.potion.c b/hack/hack.potion.c index a94df1d9..477058c5 100644 --- a/hack/hack.potion.c +++ b/hack/hack.potion.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.potion.c,v 1.4 1997/10/19 16:58:48 christos Exp $ */ +/* $NetBSD: hack.potion.c,v 1.5 2001/03/25 20:44:02 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.potion.c,v 1.4 1997/10/19 16:58:48 christos Exp $"); +__RCSID("$NetBSD: hack.potion.c,v 1.5 2001/03/25 20:44:02 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -224,7 +224,7 @@ pluslvl() void strange_feeling(obj, txt) struct obj *obj; - char *txt; + const char *txt; { if (flags.beginner) pline("You have a strange feeling for a moment, then it passes."); @@ -235,7 +235,7 @@ strange_feeling(obj, txt) useup(obj); } -char *bottlenames[] = { +const char *const bottlenames[] = { "bottle", "phial", "flagon", "carafe", "flask", "jar", "vial" }; @@ -244,7 +244,7 @@ potionhit(mon, obj) struct monst *mon; struct obj *obj; { - char *botlnam = bottlenames[rn2(SIZE(bottlenames))]; + const char *botlnam = bottlenames[rn2(SIZE(bottlenames))]; boolean uclose, isyou = (mon == &youmonst); if (isyou) { diff --git a/hack/hack.pri.c b/hack/hack.pri.c index 8e8c5bd4..826b2599 100644 --- a/hack/hack.pri.c +++ b/hack/hack.pri.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.pri.c,v 1.5 1997/10/19 16:58:50 christos Exp $ */ +/* $NetBSD: hack.pri.c,v 1.6 2001/03/25 20:44:02 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.pri.c,v 1.5 1997/10/19 16:58:50 christos Exp $"); +__RCSID("$NetBSD: hack.pri.c,v 1.6 2001/03/25 20:44:02 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -344,7 +344,7 @@ pru() /* print a position that is visible for @ */ void -prl(x, y) +prl(int x, int y) { struct rm *room; struct monst *mtmp; diff --git a/hack/hack.read.c b/hack/hack.read.c index 53717f0f..9d37cd4a 100644 --- a/hack/hack.read.c +++ b/hack/hack.read.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.read.c,v 1.6 2001/02/05 00:37:43 christos Exp $ */ +/* $NetBSD: hack.read.c,v 1.7 2001/03/25 20:44:02 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.read.c,v 1.6 2001/02/05 00:37:43 christos Exp $"); +__RCSID("$NetBSD: hack.read.c,v 1.7 2001/03/25 20:44:02 jsm Exp $"); #endif /* not lint */ #include @@ -573,7 +573,7 @@ int monstersym(ch) /* arnold@ucsfcgl */ char ch; { - struct permonst *mp; + const struct permonst *mp; /* * can't genocide certain monsters diff --git a/hack/hack.rip.c b/hack/hack.rip.c index f9252d78..e1eaea95 100644 --- a/hack/hack.rip.c +++ b/hack/hack.rip.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.rip.c,v 1.5 1997/10/19 16:58:53 christos Exp $ */ +/* $NetBSD: hack.rip.c,v 1.6 2001/03/25 20:44:02 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,13 +6,13 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.rip.c,v 1.5 1997/10/19 16:58:53 christos Exp $"); +__RCSID("$NetBSD: hack.rip.c,v 1.6 2001/03/25 20:44:02 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" -static char *riptop = "\ +static const char *riptop = "\ ----------\n\ / \\\n\ / REST \\\n\ @@ -20,9 +20,9 @@ static char *riptop = "\ / PEACE \\\n\ / \\"; -static char *ripmid = " | %*s%*s |\n"; +static const char *ripmid = " | %*s%*s |\n"; -static char *ripbot = "\ +static const char *ripbot = "\ *| * * * | *\n\ _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______"; @@ -69,7 +69,7 @@ outrip() void center(line, text) - int line; + int line __attribute__((__unused__)); char *text; { int n = strlen(text) / 2; diff --git a/hack/hack.save.c b/hack/hack.save.c index 26386e70..de94db53 100644 --- a/hack/hack.save.c +++ b/hack/hack.save.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.save.c,v 1.6 1997/10/19 16:58:57 christos Exp $ */ +/* $NetBSD: hack.save.c,v 1.7 2001/03/25 20:44:02 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.save.c,v 1.6 1997/10/19 16:58:57 christos Exp $"); +__RCSID("$NetBSD: hack.save.c,v 1.7 2001/03/25 20:44:02 jsm Exp $"); #endif /* not lint */ #include @@ -30,7 +30,7 @@ dosave() #ifndef NOSAVEONHANGUP void hangup(n) - int n; + int n __attribute__((__unused__)); { (void) dosave0(1); exit(1); @@ -77,7 +77,7 @@ dosave0(hu) if (tmp == dlevel || !level_exists[tmp]) continue; glo(tmp); - if ((ofd = open(lock, 0)) < 0) { + if ((ofd = open(lock, O_RDONLY)) < 0) { if (!hu) pline("Error while saving: cannot read %s.", lock); (void) close(fd); @@ -146,7 +146,7 @@ dorecover(fd) savelev(nfd, tmp); (void) close(nfd); } - (void) lseek(fd, (off_t) 0, 0); + (void) lseek(fd, (off_t) 0, SEEK_SET); getlev(fd, 0, 0); (void) close(fd); (void) unlink(SAVEF); @@ -225,7 +225,7 @@ restmonchn(fd) long differ; mread(fd, (char *) &monbegin, sizeof(monbegin)); - differ = (char *) (&mons[0]) - (char *) (monbegin); + differ = (const char *) (&mons[0]) - (const char *) (monbegin); #ifdef lint /* suppress "used before set" warning from lint */ @@ -243,8 +243,8 @@ restmonchn(fd) mread(fd, (char *) mtmp, (unsigned) xl + sizeof(struct monst)); if (!mtmp->m_id) mtmp->m_id = flags.ident++; - mtmp->data = (struct permonst *) - ((char *) mtmp->data + differ); + mtmp->data = (const struct permonst *) + ((const char *) mtmp->data + differ); if (mtmp->minvent) mtmp->minvent = restobjchn(fd); mtmp2 = mtmp; diff --git a/hack/hack.shk.c b/hack/hack.shk.c index 0b86d578..16634e18 100644 --- a/hack/hack.shk.c +++ b/hack/hack.shk.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.shk.c,v 1.4 1997/10/19 16:59:01 christos Exp $ */ +/* $NetBSD: hack.shk.c,v 1.5 2001/03/25 20:44:02 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.shk.c,v 1.4 1997/10/19 16:59:01 christos Exp $"); +__RCSID("$NetBSD: hack.shk.c,v 1.5 2001/03/25 20:44:02 jsm Exp $"); #endif /* not lint */ #include @@ -127,12 +127,12 @@ static long int followmsg; /* last time of follow message */ */ -char shtypes[] = { /* 8 shoptypes: 7 specialized, 1 mixed */ +const char shtypes[] = { /* 8 shoptypes: 7 specialized, 1 mixed */ RING_SYM, WAND_SYM, WEAPON_SYM, FOOD_SYM, SCROLL_SYM, POTION_SYM, ARMOR_SYM, 0 }; -static char *shopnam[] = { +static const char *const shopnam[] = { "engagement ring", "walking cane", "antique weapon", "delicatessen", "second hand book", "liquor", "used armor", "assorted antiques" @@ -902,7 +902,7 @@ shk_move(shkp) struct monst *shkp; { struct monst *mtmp; - struct permonst *mdat = shkp->data; + const struct permonst *mdat = shkp->data; xchar gx, gy, omx, omy, nx, ny, nix, niy; schar appr, i; int udist; @@ -1092,7 +1092,7 @@ shopdig(fall) #endif /* QUEST */ int -online(x, y) +online(int x, int y) { return (x == u.ux || y == u.uy || (x - u.ux) * (x - u.ux) == (y - u.uy) * (y - u.uy)); diff --git a/hack/hack.shknam.c b/hack/hack.shknam.c index de3a6323..c13a5239 100644 --- a/hack/hack.shknam.c +++ b/hack/hack.shknam.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.shknam.c,v 1.4 1997/10/19 16:59:03 christos Exp $ */ +/* $NetBSD: hack.shknam.c,v 1.5 2001/03/25 20:44:03 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,13 +6,13 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.shknam.c,v 1.4 1997/10/19 16:59:03 christos Exp $"); +__RCSID("$NetBSD: hack.shknam.c,v 1.5 2001/03/25 20:44:03 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" -char *shkliquors[] = { +const char *const shkliquors[] = { /* Ukraine */ "Njezjin", "Tsjernigof", "Gomel", "Ossipewsk", "Gorlowka", /* N. Russia */ @@ -27,7 +27,7 @@ char *shkliquors[] = { 0 }; -char *shkbooks[] = { +const char *const shkbooks[] = { /* Eire */ "Skibbereen", "Kanturk", "Rath Luirc", "Ennistymon", "Lahinch", "Loughrea", "Croagh", "Maumakeogh", "Ballyjamesduff", @@ -39,7 +39,7 @@ char *shkbooks[] = { 0 }; -char *shkarmors[] = { +const char *const shkarmors[] = { /* Turquie */ "Demirci", "Kalecik", "Boyabai", "Yildizeli", "Gaziantep", "Siirt", "Akhalataki", "Tirebolu", "Aksaray", "Ermenak", @@ -50,7 +50,7 @@ char *shkarmors[] = { 0 }; -char *shkwands[] = { +const char *const shkwands[] = { /* Wales */ "Yr Wyddgrug", "Trallwng", "Mallwyd", "Pontarfynach", "Rhaeader", "Llandrindod", "Llanfair-ym-muallt", @@ -64,7 +64,7 @@ char *shkwands[] = { 0 }; -char *shkrings[] = { +const char *const shkrings[] = { /* Hollandse familienamen */ "Feyfer", "Flugi", "Gheel", "Havic", "Haynin", "Hoboken", "Imbyze", "Juyn", "Kinsky", "Massis", "Matray", "Moy", @@ -77,7 +77,7 @@ char *shkrings[] = { 0 }; -char *shkfoods[] = { +const char *const shkfoods[] = { /* Indonesia */ "Djasinga", "Tjibarusa", "Tjiwidej", "Pengalengan", "Bandjar", "Parbalingga", "Bojolali", "Sarangan", @@ -89,7 +89,7 @@ char *shkfoods[] = { 0 }; -char *shkweapons[] = { +const char *const shkweapons[] = { /* Perigord */ "Voulgezac", "Rouffiac", "Lerignac", "Touverac", "Guizengeard", "Melac", "Neuvicq", "Vanzac", "Picq", "Urignac", "Corignac", @@ -100,7 +100,7 @@ char *shkweapons[] = { 0 }; -char *shkgeneral[] = { +const char *const shkgeneral[] = { /* Suriname */ "Hebiwerie", "Possogroenoe", "Asidonhopo", "Manlobbi", "Adjama", "Pakka Pakka", "Kabalebo", "Wonotobo", @@ -118,9 +118,9 @@ char *shkgeneral[] = { 0 }; -struct shk_nx { +const struct shk_nx { char x; - char **xn; + const char *const *xn; } shk_nx[] = { { POTION_SYM, shkliquors @@ -153,8 +153,8 @@ findname(nampt, let) char *nampt; char let; { - struct shk_nx *p = shk_nx; - char **q; + const struct shk_nx *p = shk_nx; + const char *const *q; int i; while (p->x && p->x != let) p++; diff --git a/hack/hack.timeout.c b/hack/hack.timeout.c index c84312e7..2ee93b63 100644 --- a/hack/hack.timeout.c +++ b/hack/hack.timeout.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.timeout.c,v 1.4 1997/10/19 16:59:08 christos Exp $ */ +/* $NetBSD: hack.timeout.c,v 1.5 2001/03/25 20:44:03 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.timeout.c,v 1.4 1997/10/19 16:59:08 christos Exp $"); +__RCSID("$NetBSD: hack.timeout.c,v 1.5 2001/03/25 20:44:03 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -55,7 +55,7 @@ timeout() } /* He is being petrified - dialogue by inmet!tower */ -char *stoned_texts[] = { +const char *const stoned_texts[] = { "You are slowing down.",/* 5 */ "Your limbs are stiffening.", /* 4 */ "Your limbs have turned to stone.", /* 3 */ diff --git a/hack/hack.topl.c b/hack/hack.topl.c index 692e5154..53a0bea0 100644 --- a/hack/hack.topl.c +++ b/hack/hack.topl.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.topl.c,v 1.4 1997/10/19 16:59:10 christos Exp $ */ +/* $NetBSD: hack.topl.c,v 1.5 2001/03/25 20:44:03 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.topl.c,v 1.4 1997/10/19 16:59:10 christos Exp $"); +__RCSID("$NetBSD: hack.topl.c,v 1.5 2001/03/25 20:44:03 jsm Exp $"); #endif /* not lint */ #include @@ -81,7 +81,7 @@ remember_topl() void addtopl(s) - char *s; + const char *s; { curs(tlx, tly); if (tlx + strlen(s) > CO) @@ -94,7 +94,7 @@ addtopl(s) void xmore(s) - char *s; /* allowed chars besides space/return */ + const char *s; /* allowed chars besides space/return */ { if (flags.toplin) { curs(tlx, tly); @@ -124,7 +124,7 @@ more() void cmore(s) - char *s; + const char *s; { xmore(s); } @@ -252,7 +252,7 @@ putsym(c) void putstr(s) - char *s; + const char *s; { while (*s) putsym(*s++); diff --git a/hack/hack.trap.c b/hack/hack.trap.c index 55203b7e..ae2da877 100644 --- a/hack/hack.trap.c +++ b/hack/hack.trap.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.trap.c,v 1.5 1998/08/30 09:19:37 veego Exp $ */ +/* $NetBSD: hack.trap.c,v 1.6 2001/03/25 20:44:03 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.trap.c,v 1.5 1998/08/30 09:19:37 veego Exp $"); +__RCSID("$NetBSD: hack.trap.c,v 1.6 2001/03/25 20:44:03 jsm Exp $"); #endif /* not lint */ #include @@ -14,9 +14,9 @@ __RCSID("$NetBSD: hack.trap.c,v 1.5 1998/08/30 09:19:37 veego Exp $"); #include "extern.h" #include "def.mkroom.h" -char vowels[] = "aeiou"; +const char vowels[] = "aeiou"; -char *traps[] = { +const char *const traps[] = { " bear trap", "n arrow trap", " dart trap", @@ -243,7 +243,7 @@ mintrap(mtmp) void selftouch(arg) - char *arg; + const char *arg; { if (uwep && uwep->otyp == DEAD_COCKATRICE) { pline("%s touch the dead cockatrice.", arg); diff --git a/hack/hack.tty.c b/hack/hack.tty.c index aa684692..93831ce1 100644 --- a/hack/hack.tty.c +++ b/hack/hack.tty.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.tty.c,v 1.8 2001/02/05 00:37:43 christos Exp $ */ +/* $NetBSD: hack.tty.c,v 1.9 2001/03/25 20:44:03 jsm Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)hack.tty.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: hack.tty.c,v 1.8 2001/02/05 00:37:43 christos Exp $"); +__RCSID("$NetBSD: hack.tty.c,v 1.9 2001/03/25 20:44:03 jsm Exp $"); #endif #endif /* not lint */ @@ -93,7 +93,7 @@ gettty() /* reset terminal to original state */ void settty(s) - char *s; + const char *s; { clear_screen(); end_screen(); @@ -230,7 +230,7 @@ getret() void cgetret(s) - char *s; + const char *s; { putsym('\n'); if (flags.standout) @@ -247,7 +247,7 @@ char morc; /* tell the outside world what char he used */ void xwaitforspace(s) - char *s; /* chars allowed besides space or return */ + const char *s; /* chars allowed besides space or return */ { int c; diff --git a/hack/hack.u_init.c b/hack/hack.u_init.c index 9f7ba082..fbf07379 100644 --- a/hack/hack.u_init.c +++ b/hack/hack.u_init.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.u_init.c,v 1.5 1997/10/19 16:59:19 christos Exp $ */ +/* $NetBSD: hack.u_init.c,v 1.6 2001/03/25 20:44:03 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.u_init.c,v 1.5 1997/10/19 16:59:19 christos Exp $"); +__RCSID("$NetBSD: hack.u_init.c,v 1.6 2001/03/25 20:44:03 jsm Exp $"); #endif /* not lint */ #include @@ -22,7 +22,7 @@ __RCSID("$NetBSD: hack.u_init.c,v 1.5 1997/10/19 16:59:19 christos Exp $"); struct you zerou; char pl_character[PL_CSIZ]; -char *(roles[]) = { /* must all have distinct first letter */ +const char *(roles[]) = { /* must all have distinct first letter */ /* roles[4] may be changed to -woman */ "Tourist", "Speleologist", "Fighter", "Knight", "Cave-man", "Wizard" diff --git a/hack/hack.unix.c b/hack/hack.unix.c index a1f3d715..bb2a2c35 100644 --- a/hack/hack.unix.c +++ b/hack/hack.unix.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.unix.c,v 1.7 2001/02/05 00:37:43 christos Exp $ */ +/* $NetBSD: hack.unix.c,v 1.8 2001/03/25 20:44:03 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.unix.c,v 1.7 2001/02/05 00:37:43 christos Exp $"); +__RCSID("$NetBSD: hack.unix.c,v 1.8 2001/03/25 20:44:03 jsm Exp $"); #endif /* not lint */ /* This file collects some Unix dependencies; hack.pager.c contains some more */ @@ -127,7 +127,7 @@ gethdate(name) */ #define MAXPATHLEN 1024 - char *np, *path; + const char *np, *path; char filename[MAXPATHLEN + 1]; if (strchr(name, '/') != NULL || (path = getenv("PATH")) == NULL) path = ""; @@ -154,7 +154,7 @@ gethdate(name) } int -uptodate(fd) +uptodate(int fd) { if (fstat(fd, &buf)) { pline("Cannot get status of saved level? "); @@ -247,7 +247,7 @@ getlock() if (locknum) lock[0] = 'a' + i++; - if ((fd = open(lock, 0)) == -1) { + if ((fd = open(lock, O_RDONLY)) == -1) { if (errno == ENOENT) goto gotlock; /* no such file */ perror(lock); diff --git a/hack/hack.vault.c b/hack/hack.vault.c index 8717674f..28b0e6ff 100644 --- a/hack/hack.vault.c +++ b/hack/hack.vault.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.vault.c,v 1.4 1997/10/19 16:59:23 christos Exp $ */ +/* $NetBSD: hack.vault.c,v 1.5 2001/03/25 20:44:03 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.vault.c,v 1.4 1997/10/19 16:59:23 christos Exp $"); +__RCSID("$NetBSD: hack.vault.c,v 1.5 2001/03/25 20:44:03 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -50,7 +50,7 @@ struct egd { struct fakecorridor fakecorr[FCSIZ]; }; -static struct permonst pm_guard = +static const struct permonst pm_guard = {"guard", '@', 12, 12, -1, 4, 10, sizeof(struct egd)}; static struct monst *guard; diff --git a/hack/hack.wield.c b/hack/hack.wield.c index bd0b8d20..ebdef0a4 100644 --- a/hack/hack.wield.c +++ b/hack/hack.wield.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.wield.c,v 1.4 1997/10/19 16:59:27 christos Exp $ */ +/* $NetBSD: hack.wield.c,v 1.5 2001/03/25 20:44:03 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.wield.c,v 1.4 1997/10/19 16:59:27 christos Exp $"); +__RCSID("$NetBSD: hack.wield.c,v 1.5 2001/03/25 20:44:03 jsm Exp $"); #endif /* not lint */ #include "hack.h" @@ -76,8 +76,8 @@ chwepon(otmp, amount) struct obj *otmp; int amount; { - char *color = (amount < 0) ? "black" : "green"; - char *time; + const char *color = (amount < 0) ? "black" : "green"; + const char *time; if (!uwep || uwep->olet != WEAPON_SYM) { strange_feeling(otmp, (amount > 0) ? "Your hands twitch." diff --git a/hack/hack.wizard.c b/hack/hack.wizard.c index e26e480d..54c3ceef 100644 --- a/hack/hack.wizard.c +++ b/hack/hack.wizard.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.wizard.c,v 1.4 1997/10/19 16:59:28 christos Exp $ */ +/* $NetBSD: hack.wizard.c,v 1.5 2001/03/25 20:44:04 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,7 +6,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.wizard.c,v 1.4 1997/10/19 16:59:28 christos Exp $"); +__RCSID("$NetBSD: hack.wizard.c,v 1.5 2001/03/25 20:44:04 jsm Exp $"); #endif /* not lint */ /* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */ @@ -19,7 +19,7 @@ __RCSID("$NetBSD: hack.wizard.c,v 1.4 1997/10/19 16:59:28 christos Exp $"); #define BOLT_LIM 8 /* from this distance D and 1 will try to hit * you */ -char wizapp[] = "@DNPTUVXcemntx"; +const char wizapp[] = "@DNPTUVXcemntx"; /* If he has found the Amulet, make the wizard appear after some time */ void diff --git a/hack/hack.zap.c b/hack/hack.zap.c index fa17320d..951efbd2 100644 --- a/hack/hack.zap.c +++ b/hack/hack.zap.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.zap.c,v 1.4 1997/10/19 16:59:34 christos Exp $ */ +/* $NetBSD: hack.zap.c,v 1.5 2001/03/25 20:44:04 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. @@ -6,13 +6,13 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.zap.c,v 1.4 1997/10/19 16:59:34 christos Exp $"); +__RCSID("$NetBSD: hack.zap.c,v 1.5 2001/03/25 20:44:04 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" -char *fl[] = { +const char *const fl[] = { "magic missile", "bolt of fire", "sleep ray", @@ -279,7 +279,7 @@ dozap() return (1); } -char * +const char * exclam(force) int force; { @@ -293,9 +293,9 @@ exclam(force) void hit(str, mtmp, force) - char *str; + const char *str; struct monst *mtmp; - char *force; /* usually either "." or "!" */ + const char *force; /* usually either "." or "!" */ { if (!cansee(mtmp->mx, mtmp->my)) pline("The %s hits it.", str); @@ -305,7 +305,7 @@ hit(str, mtmp, force) void miss(str, mtmp) - char *str; + const char *str; struct monst *mtmp; { if (!cansee(mtmp->mx, mtmp->my)) @@ -374,7 +374,7 @@ bhit(ddx, ddy, range, sym, fhitm, fhito, obj) } struct monst * -boomhit(dx, dy) +boomhit(int dx, int dy) { int i, ct; struct monst *mtmp; @@ -441,7 +441,7 @@ buzz(type, sx, sy, dx, dy) int dx, dy; { int abstype = abs(type); - char *fltxt = (type == -1) ? "blaze of fire" : fl[abstype]; + const char *fltxt = (type == -1) ? "blaze of fire" : fl[abstype]; struct rm *lev; xchar range; struct monst *mon; diff --git a/hack/makedefs.c b/hack/makedefs.c index 3aa621c6..fd19fa84 100644 --- a/hack/makedefs.c +++ b/hack/makedefs.c @@ -1,15 +1,16 @@ -/* $NetBSD: makedefs.c,v 1.6 2000/07/31 11:35:03 simonb Exp $ */ +/* $NetBSD: makedefs.c,v 1.7 2001/03/25 20:44:04 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ #ifndef lint -static char rcsid[] = - "$NetBSD: makedefs.c,v 1.6 2000/07/31 11:35:03 simonb Exp $"; +static const char rcsid[] = + "$NetBSD: makedefs.c,v 1.7 2001/03/25 20:44:04 jsm Exp $"; #endif /* not lint */ #include +#include #include #include #include @@ -23,7 +24,7 @@ char string[STRSZ]; static void readline(void); static char nextchar(void); -static int skipuntil(char *); +static int skipuntil(const char *); static int getentry(void); static void capitalize(char *); static int letter(int); @@ -43,7 +44,7 @@ main(argc, argv) (void) fprintf(stderr, "usage: makedefs file\n"); exit(1); } - if ((fd = open(argv[1], 0)) < 0) { + if ((fd = open(argv[1], O_RDONLY)) < 0) { perror(argv[1]); exit(1); } @@ -74,6 +75,11 @@ main(argc, argv) printf("#define LAST_GEM (JADE+1)\n"); printf("#define LAST_RING %d\n", propct); printf("#define NROFOBJECTS %d\n", i - 1); + fflush(stdout); + if (ferror(stdout)) { + perror("standard output"); + exit(1); + } exit(0); } @@ -105,9 +111,10 @@ nextchar() static int skipuntil(s) - char *s; + const char *s; { - char *sp0, *sp1; + const char *sp0; + char *sp1; loop: while (*s != nextchar()) if (eof) { -- cgit v1.2.3-56-ge451