From fc319a4be06f0c7ebf83f2cad7e6244ec7790ab0 Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Tue, 20 Aug 2002 08:05:20 +0000 Subject: [PATCH] string constants wrote: > Linux, Redhat 7.1 nethack 3.4.0 > >Please see attached patch file. > >I'm attempting to move more stuff into the "read-only" area, in >preparation for a port to another OS. --- include/decl.h | 2 +- include/extern.h | 2 +- include/mkroom.h | 2 +- src/apply.c | 16 ++++++++-------- src/artifact.c | 4 ++-- src/attrib.c | 4 ++-- src/botl.c | 2 +- src/cmd.c | 24 ++++++++++++------------ src/detect.c | 2 +- src/dig.c | 4 ++-- src/display.c | 2 +- src/do.c | 4 ++-- src/do_name.c | 10 +++++----- src/do_wear.c | 24 ++++++++++++------------ src/drawing.c | 8 ++++---- src/shknam.c | 24 ++++++++++++------------ src/sit.c | 4 ++-- src/sounds.c | 28 ++++++++++++++-------------- src/steal.c | 2 +- src/timeout.c | 12 ++++++------ src/topten.c | 14 +++++++------- src/trap.c | 14 +++++++------- src/u_init.c | 28 ++++++++++++++-------------- src/version.c | 2 +- src/weapon.c | 10 +++++----- src/wizard.c | 4 ++-- src/zap.c | 4 ++-- 27 files changed, 128 insertions(+), 128 deletions(-) diff --git a/include/decl.h b/include/decl.h index a1e3cbc40..996277027 100644 --- a/include/decl.h +++ b/include/decl.h @@ -337,7 +337,7 @@ E struct tc_gbl_data { /* also declared in tcap.h */ #endif /* xxxexplain[] is in drawing.c */ -E const char *monexplain[], *invisexplain, *objexplain[], *oclass_names[]; +E const char * const monexplain[], invisexplain[], * const objexplain[], * const oclass_names[]; /* Some systems want to use full pathnames for some subsets of file names, * rather than assuming that they're all in the current directory. This diff --git a/include/extern.h b/include/extern.h index 6ee6e5ce1..0914ab464 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2190,7 +2190,7 @@ E int FDECL(weapon_type, (struct obj *)); E int NDECL(uwep_skill_type); E int FDECL(weapon_hit_bonus, (struct obj *)); E int FDECL(weapon_dam_bonus, (struct obj *)); -E void FDECL(skill_init, (struct def_skill *)); +E void FDECL(skill_init, (const struct def_skill *)); /* ### were.c ### */ diff --git a/include/mkroom.h b/include/mkroom.h index 72bd50423..b1363bd08 100644 --- a/include/mkroom.h +++ b/include/mkroom.h @@ -31,7 +31,7 @@ struct shclass { int iprob; /* probability of an item type */ int itype; /* item type: if >=0 a class, if < 0 a specific item */ } iprobs[5]; - const char **shknms; /* list of shopkeeper names for this type */ + const char * const *shknms; /* list of shopkeeper names for this type */ }; extern NEARDATA struct mkroom rooms[(MAXNROFROOMS+1)*2]; diff --git a/src/apply.c b/src/apply.c index e9ea15edb..c432f24d8 100644 --- a/src/apply.c +++ b/src/apply.c @@ -46,7 +46,7 @@ STATIC_DCL void FDECL(add_class, (char *, CHAR_P)); void FDECL( amii_speaker, ( struct obj *, char *, int ) ); #endif -static char no_elbow_room[] = "don't have enough elbow-room to maneuver."; +static const char no_elbow_room[] = "don't have enough elbow-room to maneuver."; #ifdef TOURIST STATIC_OVL int @@ -192,7 +192,7 @@ int rx, ry, *resp; return FALSE; } -static char hollow_str[] = "a hollow sound. This must be a secret %s!"; +static const char hollow_str[] = "a hollow sound. This must be a secret %s!"; /* Strictly speaking it makes no sense for usage of a stethoscope to not take any time; however, unless it did, the stethoscope would be @@ -291,7 +291,7 @@ use_stethoscope(obj) return res; } -static char whistle_str[] = "produce a %s whistling sound."; +static const char whistle_str[] = "produce a %s whistling sound."; STATIC_OVL void use_whistle(obj) @@ -617,7 +617,7 @@ struct obj *obj; #define WEAK 3 /* from eat.c */ -static char look_str[] = "look %s."; +static const char look_str[] = "look %s."; STATIC_OVL int use_mirror(obj) @@ -1839,7 +1839,7 @@ struct obj *tstone; const char *streak_color; char stonebuf[QBUFSZ]; static const char scritch[] = "\"scritch, scritch\""; - static char allowall[3] = { COIN_CLASS, ALL_CLASSES, 0 }; + static const char allowall[3] = { COIN_CLASS, ALL_CLASSES, 0 }; #ifndef GOLDOBJ struct obj goldobj; #endif @@ -2317,9 +2317,9 @@ struct obj *obj; static const char - *not_enough_room = "There's not enough room here to use that.", - *where_to_hit = "Where do you want to hit?", - *cant_see_spot = "won't hit anything if you can't see that spot."; + not_enough_room[] = "There's not enough room here to use that.", + where_to_hit[] = "Where do you want to hit?", + cant_see_spot[] = "won't hit anything if you can't see that spot."; /* Distance attacks by pole-weapons */ STATIC_OVL int diff --git a/src/artifact.c b/src/artifact.c index d93944ca3..da806018a 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -876,7 +876,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */ } if (youdefend || mdef->mhp > 0) { /* ??? -dkh- */ - static const char *mb_verb[4] = + static const char * const mb_verb[4] = {"probe", "stun", "scare", "purge"}; if (youattack || youdefend || vis) { @@ -987,7 +987,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */ } } else if (otmp->oartifact == ART_VORPAL_BLADE && (dieroll == 1 || mdef->data == &mons[PM_JABBERWOCK])) { - static const char *behead_msg[2] = { + static const char * const behead_msg[2] = { "%s beheads %s!", "%s decapitates %s!" }; diff --git a/src/attrib.c b/src/attrib.c index 7719710fa..8e4ac5308 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -13,10 +13,10 @@ /* part of the output on gain or loss of attribute */ static -const char *plusattr[] = { +const char * const plusattr[] = { "strong", "smart", "wise", "agile", "tough", "charismatic" }, - *minusattr[] = { + * const minusattr[] = { "weak", "stupid", "foolish", "clumsy", "fragile", "repulsive" }; diff --git a/src/botl.c b/src/botl.c index 4934572f5..6534ad797 100644 --- a/src/botl.c +++ b/src/botl.c @@ -7,7 +7,7 @@ #ifdef OVL0 extern const char *hu_stat[]; /* defined in eat.c */ -const char *enc_stat[] = { +const char * const enc_stat[] = { "", "Burdened", "Stressed", diff --git a/src/cmd.c b/src/cmd.c index d284d664e..411eb90f6 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -736,13 +736,13 @@ wiz_show_wmodes() /* -enlightenment and conduct- */ static winid en_win; static const char - *You_ = "You ", - *are = "are ", *were = "were ", - *have = "have ", *had = "had ", - *can = "can ", *could = "could "; + You_[] = "You ", + are[] = "are ", were[] = "were ", + have[] = "have ", had[] = "had ", + can[] = "can ", could[] = "could "; static const char - *have_been = "have been ", - *have_never = "have never ", *never = "never "; + have_been[] = "have been ", + have_never[] = "have never ", never[] = "never "; #define enl_msg(prefix,present,past,suffix) \ enlght_line(prefix, final ? past : present, suffix) @@ -776,7 +776,7 @@ int final; /* 0 => still in progress; 1 => over, survived; 2 => dead */ #ifdef ELBERETH if (u.uevent.uhand_of_elbereth) { - static const char *hofe_titles[3] = { + static const char * const hofe_titles[3] = { "the Hand of Elbereth", "the Envoy of Balance", "the Glory of Arioch" @@ -1061,8 +1061,8 @@ minimal_enlightenment() menu_item *selected; anything any; char buf[BUFSZ], buf2[BUFSZ]; - static char fmtstr[] = "%-15s: %-12s"; - static char deity_fmtstr[] = "%-17s%s"; + static const char fmtstr[] = "%-15s: %-12s"; + static const char deity_fmtstr[] = "%-17s%s"; any.a_void = 0; buf[0] = buf2[0] = '\0'; @@ -1482,9 +1482,9 @@ add_debug_extended_commands() } -static const char *template = "%-18s %4ld %6ld"; -static const char *count_str = " count bytes"; -static const char *separator = "------------------ ----- ------"; +static const char template[] = "%-18s %4ld %6ld"; +static const char count_str[] = " count bytes"; +static const char separator[] = "------------------ ----- ------"; STATIC_OVL void count_obj(chain, total_count, total_size, top, recurse) diff --git a/src/detect.c b/src/detect.c index 799f3eb4d..325d8c59b 100644 --- a/src/detect.c +++ b/src/detect.c @@ -753,7 +753,7 @@ d_level *where; else return "near you"; } -static struct { +static const struct { const char *what; d_level *where; } level_detects[] = { diff --git a/src/dig.c b/src/dig.c index 980790f86..7016de891 100644 --- a/src/dig.c +++ b/src/dig.c @@ -410,7 +410,7 @@ cleanup: digging.level.dlevel = -1; return(0); } else { /* not enough effort has been spent yet */ - static const char *d_target[6] = { + static const char *const d_target[6] = { "", "rock", "statue", "boulder", "door", "tree" }; int dig_target = dig_typ(uwep, dpx, dpy); @@ -923,7 +923,7 @@ struct obj *obj; You("swing your %s through thin air.", aobjnam(obj, (char *)0)); } else { - static const char *d_action[6] = { + static const char * const d_action[6] = { "swinging", "digging", "chipping the statue", diff --git a/src/display.c b/src/display.c index ae48324bb..6f0811db5 100644 --- a/src/display.c +++ b/src/display.c @@ -1857,7 +1857,7 @@ STATIC_OVL void t_warn(lev) struct rm *lev; { - static const char *warn_str = "wall_angle: %s: case %d: seenv = 0x%x"; + static const char warn_str[] = "wall_angle: %s: case %d: seenv = 0x%x"; const char *wname; if (lev->typ == TUWALL) wname = "tuwall"; diff --git a/src/do.c b/src/do.c index e876a21cb..9d5f067c1 100644 --- a/src/do.c +++ b/src/do.c @@ -1233,13 +1233,13 @@ boolean at_stairs, falling, portal; } if (familiar) { - static const char *fam_msgs[4] = { + static const char * const fam_msgs[4] = { "You have a sense of deja vu.", "You feel like you've been here before.", "This place %s familiar...", 0 /* no message */ }; - static const char *halu_fam_msgs[4] = { + static const char * const halu_fam_msgs[4] = { "Whoa! Everything %s different.", "You are surrounded by twisty little passages, all alike.", "Gee, this %s like uncle Conan's place...", diff --git a/src/do_name.c b/src/do_name.c index 32b7eaac7..a833b6ae5 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -49,7 +49,7 @@ const char *goal; int cx, cy, i, c; int sidx, tx, ty; boolean msg_given = TRUE; /* clear message window by default */ - static const char *pick_chars = ".,;:"; + static const char pick_chars[] = ".,;:"; const char *cp; const char *sdp; if(iflags.num_pad) sdp = ndir; else sdp = sdir; /* DICE workaround */ @@ -525,7 +525,7 @@ register struct obj *obj; #endif /*OVLB*/ #ifdef OVL0 -static const char *ghostnames[] = { +static const char * const ghostnames[] = { /* these names should have length < PL_NSIZ */ /* Capitalize the names for aesthetics -dgk */ "Adri", "Andries", "Andreas", "Bert", "David", "Dirk", "Emile", @@ -871,7 +871,7 @@ char *outbuf; return outbuf; } -static const char *bogusmons[] = { +static const char * const bogusmons[] = { "jumbo shrimp", "giant pigmy", "gnu", "killer penguin", "giant cockroach", "giant slug", "maggot", "pterodactyl", "tyrannosaurus rex", "basilisk", "beholder", "nightmare", @@ -968,7 +968,7 @@ roguename() /* Name of a Rogue player */ #ifdef OVL2 -static NEARDATA const char *hcolors[] = { +static NEARDATA const char * const hcolors[] = { "ultraviolet", "infrared", "bluish-orange", "reddish-green", "dark white", "light black", "sky blue-pink", "salty", "sweet", "sour", "bitter", @@ -991,7 +991,7 @@ const char *colorpref; /* Aliases for road-runner nemesis * See also http://www.geocities.com/EnchantedForest/1141/latin.html */ -static const char *coynames[] = { +static const char * const coynames[] = { "Carnivorous Vulgaris","Road-Runnerus Digestus", "Eatibus Anythingus" ,"Famishus-Famishus", "Eatibus Almost Anythingus","Eatius Birdius", diff --git a/src/do_wear.c b/src/do_wear.c index cc79dad4f..4129816a7 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -17,20 +17,20 @@ static boolean cancelled_don = FALSE; static NEARDATA const char see_yourself[] = "see yourself"; static NEARDATA const char unknown_type[] = "Unknown type of %s (%d)"; -static NEARDATA const char *c_armor = "armor", - *c_suit = "suit", +static NEARDATA const char c_armor[] = "armor", + c_suit[] = "suit", #ifdef TOURIST - *c_shirt = "shirt", + c_shirt[] = "shirt", #endif - *c_cloak = "cloak", - *c_gloves = "gloves", - *c_boots = "boots", - *c_helmet = "helmet", - *c_shield = "shield", - *c_weapon = "weapon", - *c_sword = "sword", - *c_axe = "axe", - *c_that_ = "that"; + c_cloak[] = "cloak", + c_gloves[] = "gloves", + c_boots[] = "boots", + c_helmet[] = "helmet", + c_shield[] = "shield", + c_weapon[] = "weapon", + c_sword[] = "sword", + c_axe[] = "axe", + c_that_[] = "that"; static NEARDATA const long takeoff_order[] = { WORN_BLINDF, W_WEP, WORN_SHIELD, WORN_GLOVES, LEFT_RING, RIGHT_RING, WORN_CLOAK, diff --git a/src/drawing.c b/src/drawing.c index 62054ea77..da6e95abe 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -46,10 +46,10 @@ const char def_oc_syms[MAXOCLASSES] = { VENOM_SYM }; -const char *invisexplain = "remembered, unseen, creature"; +const char invisexplain[] = "remembered, unseen, creature"; /* Object descriptions. Used in do_look(). */ -const char *objexplain[] = { /* these match def_oc_syms, above */ +const char * const objexplain[] = { /* these match def_oc_syms, above */ /* 0*/ 0, "strange object", "weapon", @@ -71,7 +71,7 @@ const char *objexplain[] = { /* these match def_oc_syms, above */ }; /* Object class names. Used in object_detect(). */ -const char *oclass_names[] = { +const char * const oclass_names[] = { /* 0*/ 0, "illegal objects", "weapons", @@ -161,7 +161,7 @@ const char def_monsyms[MAXMCLASSES] = { * for blessed genocide, so no text should wholly contain any later * text. They should also always contain obvious names (eg. cat/feline). */ -const char *monexplain[MAXMCLASSES] = { +const char * const monexplain[MAXMCLASSES] = { 0, "ant or other insect", "blob", "cockatrice", "dog or other canine", "eye or sphere", "cat or other feline", diff --git a/src/shknam.c b/src/shknam.c index 76fd007d8..9c2e8c2a5 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -13,10 +13,10 @@ extern const struct shclass shtypes[]; #else STATIC_DCL void FDECL(mkshobj_at, (const struct shclass *,int,int)); -STATIC_DCL void FDECL(nameshk, (struct monst *,const char **)); +STATIC_DCL void FDECL(nameshk, (struct monst *,const char * const *)); STATIC_DCL int FDECL(shkinit, (const struct shclass *,struct mkroom *)); -static const char *shkliquors[] = { +static const char * const shkliquors[] = { /* Ukraine */ "Njezjin", "Tsjernigof", "Gomel", "Ossipewsk", "Gorlowka", /* N. Russia */ @@ -31,7 +31,7 @@ static const char *shkliquors[] = { 0 }; -static const char *shkbooks[] = { +static const char * const shkbooks[] = { /* Eire */ "Skibbereen", "Kanturk", "Rath Luirc", "Ennistymon", "Lahinch", "Kinnegad", "Lugnaquillia", "Enniscorthy", "Gweebarra", @@ -42,7 +42,7 @@ static const char *shkbooks[] = { 0 }; -static const char *shkarmors[] = { +static const char * const shkarmors[] = { /* Turquie */ "Demirci", "Kalecik", "Boyabai", "Yildizeli", "Gaziantep", "Siirt", "Akhalataki", "Tirebolu", "Aksaray", "Ermenak", @@ -53,7 +53,7 @@ static const char *shkarmors[] = { 0 }; -static const char *shkwands[] = { +static const char * const shkwands[] = { /* Wales */ "Yr Wyddgrug", "Trallwng", "Mallwyd", "Pontarfynach", "Rhaeader", "Llandrindod", "Llanfair-ym-muallt", @@ -67,7 +67,7 @@ static const char *shkwands[] = { 0 }; -static const char *shkrings[] = { +static const char * const shkrings[] = { /* Hollandse familienamen */ "Feyfer", "Flugi", "Gheel", "Havic", "Haynin", "Hoboken", "Imbyze", "Juyn", "Kinsky", "Massis", "Matray", "Moy", @@ -80,7 +80,7 @@ static const char *shkrings[] = { 0 }; -static const char *shkfoods[] = { +static const char * const shkfoods[] = { /* Indonesia */ "Djasinga", "Tjibarusa", "Tjiwidej", "Pengalengan", "Bandjar", "Parbalingga", "Bojolali", "Sarangan", @@ -92,7 +92,7 @@ static const char *shkfoods[] = { 0 }; -static const char *shkweapons[] = { +static const char * const shkweapons[] = { /* Perigord */ "Voulgezac", "Rouffiac", "Lerignac", "Touverac", "Guizengeard", "Melac", "Neuvicq", "Vanzac", "Picq", "Urignac", "Corignac", @@ -103,7 +103,7 @@ static const char *shkweapons[] = { 0 }; -static const char *shktools[] = { +static const char * const shktools[] = { /* Spmi */ "Ymla", "Eed-morra", "Cubask", "Nieb", "Bnowr Falr", "Telloc Cyaj", "Sperc", "Noskcirdneh", "Yawolloh", "Hyeghu", "Niskal", "Trahnil", @@ -134,7 +134,7 @@ static const char *shktools[] = { 0 }; -static const char *shklight[] = { +static const char * const shklight[] = { /* Romania */ "Zarnesti", "Slanic", "Nehoiasu", "Ludus", "Sighisoara", "Nisipitu", "Razboieni", "Bicaz", "Dorohoi", "Vaslui", "Fetesti", "Tirgu Neamt", @@ -146,7 +146,7 @@ static const char *shklight[] = { 0 }; -static const char *shkgeneral[] = { +static const char * const shkgeneral[] = { /* Suriname */ "Hebiwerie", "Possogroenoe", "Asidonhopo", "Manlobbi", "Adjama", "Pakka Pakka", "Kabalebo", "Wonotobo", @@ -271,7 +271,7 @@ int sx, sy; STATIC_OVL void nameshk(shk, nlp) struct monst *shk; -const char *nlp[]; +const char * const nlp[]; { int i, trycnt, names_avail; const char *shname = 0; diff --git a/src/sit.c b/src/sit.c index 9e2eb0b75..75b8ad5d9 100644 --- a/src/sit.c +++ b/src/sit.c @@ -37,7 +37,7 @@ take_gold() int dosit() { - static const char *sit_message = "sit on the %s."; + static const char sit_message[] = "sit on the %s."; register struct trap *trap; register int typ = levl[u.ux][u.uy].typ; @@ -312,7 +312,7 @@ rndcurse() /* curse a few inventory items at random! */ int nobj = 0; int cnt, onum; struct obj *otmp; - static const char *mal_aura = "feel a malignant aura surround %s."; + static const char mal_aura[] = "feel a malignant aura surround %s."; if (uwep && (uwep->oartifact == ART_MAGICBANE) && rn2(20)) { You(mal_aura, "the magic-absorbing blade"); diff --git a/src/sounds.c b/src/sounds.c index 32f83c9ce..fad33099b 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -45,7 +45,7 @@ dosounds() hallu = Hallucination ? 1 : 0; if (level.flags.nfountains && !rn2(400)) { - static const char *fountain_msg[4] = { + static const char * const fountain_msg[4] = { "bubbling water.", "water falling on coins.", "the splashing of a naiad.", @@ -55,7 +55,7 @@ dosounds() } #ifdef SINK if (level.flags.nsinks && !rn2(300)) { - static const char *sink_msg[3] = { + static const char * const sink_msg[3] = { "a slow drip.", "a gurgling noise.", "dishes being washed!", @@ -64,7 +64,7 @@ dosounds() } #endif if (level.flags.has_court && !rn2(200)) { - static const char *throne_msg[4] = { + static const char * const throne_msg[4] = { "the tones of courtly conversation.", "a sceptre pounded in judgment.", "Someone shouts \"Off with %s head!\"", @@ -86,7 +86,7 @@ dosounds() } } if (level.flags.has_swamp && !rn2(200)) { - static const char *swamp_msg[3] = { + static const char * const swamp_msg[3] = { "hear mosquitoes!", "smell marsh gas!", /* so it's a smell...*/ "hear Donald Duck!", @@ -181,7 +181,7 @@ dosounds() } } if (level.flags.has_barracks && !rn2(200)) { - static const char *barracks_msg[4] = { + static const char * const barracks_msg[4] = { "blades being honed.", "loud snoring.", "dice being thrown.", @@ -205,7 +205,7 @@ dosounds() } } if (level.flags.has_zoo && !rn2(200)) { - static const char *zoo_msg[3] = { + static const char * const zoo_msg[3] = { "a sound reminiscent of an elephant stepping on a peanut.", "a sound reminiscent of a seal barking.", "Doctor Doolittle!", @@ -227,7 +227,7 @@ dosounds() } if (tended_shop(sroom) && !index(u.ushops, ROOM_INDEX(sroom) + ROOMOFFSET)) { - static const char *shop_msg[3] = { + static const char * const shop_msg[3] = { "someone cursing shoplifters.", "the chime of a cash register.", "Neiman and Marcus arguing!", @@ -243,7 +243,7 @@ dosounds() break; /* and don't produce silly effects when she's clearly visible */ if (mtmp && (hallu || !canseemon(mtmp))) { - static const char *ora_msg[5] = { + static const char * const ora_msg[5] = { "a strange wind.", /* Jupiter at Dodona */ "convulsive ravings.", /* Apollo at Delphi */ "snoring snakes.", /* AEsculapius at Epidaurus */ @@ -259,7 +259,7 @@ dosounds() #endif /* OVL0 */ #ifdef OVLB -static const char *h_sounds[] = { +static const char * const h_sounds[] = { "beep", "boing", "sing", "belche", "creak", "cough", "rattle", "ululate", "pop", "jingle", "sniffle", "tinkle", "eep" }; @@ -495,7 +495,7 @@ register struct monst *mtmp; verbl_msg = "I only drink... potions."; } else { int vampindex; - static const char *vampmsg[] = { + static const char * const vampmsg[] = { /* These first two (0 and 1) are specially handled below */ "I vant to suck your %s!", "I vill come after %s without regret!", @@ -623,7 +623,7 @@ register struct monst *mtmp; break; case MS_LAUGH: { - static const char *laugh_msg[4] = { + static const char * const laugh_msg[4] = { "giggles.", "chuckles.", "snickers.", "laughs.", }; pline_msg = laugh_msg[rn2(4)]; @@ -739,7 +739,7 @@ register struct monst *mtmp; verbalize("Just the facts, %s.", flags.female ? "Ma'am" : "Sir"); else { - static const char *arrest_msg[3] = { + static const char * const arrest_msg[3] = { "Anything you say can be used against you.", "You're under arrest!", "Stop in the name of the Law!", @@ -787,11 +787,11 @@ register struct monst *mtmp; break; case MS_SOLDIER: { - static const char *soldier_foe_msg[3] = { + static const char * const soldier_foe_msg[3] = { "Resistance is useless!", "You're dog meat!", "Surrender!", - }, *soldier_pax_msg[3] = { + }, * const soldier_pax_msg[3] = { "What lousy pay we're getting here!", "The food's not fit for Orcs!", "My feet hurt, I've been on them all day!", diff --git a/src/steal.c b/src/steal.c index 7d11a8a3f..922ca6094 100644 --- a/src/steal.c +++ b/src/steal.c @@ -313,7 +313,7 @@ gotobj: ostuck = (otmp->cursed && otmp->owornmask); if (ostuck || !can_carry(mtmp, otmp)) { - static const char *how[] = { "steal","snatch","grab","take" }; + static const char * const how[] = { "steal","snatch","grab","take" }; cant_take: pline("%s tries to %s your %s but gives up.", Monnam(mtmp), how[rn2(SIZE(how))], diff --git a/src/timeout.c b/src/timeout.c index 0f0dcbbee..f23e5900f 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -17,7 +17,7 @@ STATIC_DCL void FDECL(cleanup_burn, (genericptr_t,long)); #ifdef OVLB /* He is being petrified - dialogue by inmet!tower */ -static NEARDATA const char *stoned_texts[] = { +static NEARDATA const char * const stoned_texts[] = { "You are slowing down.", /* 5 */ "Your limbs are stiffening.", /* 4 */ "Your limbs have turned to stone.", /* 3 */ @@ -40,7 +40,7 @@ stoned_dialogue() } /* He is getting sicker and sicker prior to vomiting */ -static NEARDATA const char *vomiting_texts[] = { +static NEARDATA const char * const vomiting_texts[] = { "are feeling mildly nauseous.", /* 14 */ "feel slightly confused.", /* 11 */ "can't seem to think straight.", /* 8 */ @@ -72,7 +72,7 @@ vomiting_dialogue() exercise(A_CON, FALSE); } -static NEARDATA const char *choke_texts[] = { +static NEARDATA const char * const choke_texts[] = { "You find it hard to breathe.", "You're gasping for air.", "You can no longer breathe.", @@ -80,7 +80,7 @@ static NEARDATA const char *choke_texts[] = { "You suffocate." }; -static NEARDATA const char *choke_texts2[] = { +static NEARDATA const char * const choke_texts2[] = { "Your %s is becoming constricted.", "Your blood is having trouble reaching your brain.", "The pressure on your %s increases.", @@ -108,7 +108,7 @@ choke_dialogue() exercise(A_STR, FALSE); } -static NEARDATA const char *slime_texts[] = { +static NEARDATA const char * const slime_texts[] = { "You are turning a little %s.", /* 5 */ "Your limbs are getting oozy.", /* 4 */ "Your skin begins to peel away.", /* 3 */ @@ -1309,7 +1309,7 @@ typedef struct { } ttable; /* table of timeout functions */ -static ttable timeout_funcs[NUM_TIME_FUNCS] = { +static const ttable timeout_funcs[NUM_TIME_FUNCS] = { TTAB(rot_organic, (timeout_proc)0, "rot_organic"), TTAB(rot_corpse, (timeout_proc)0, "rot_corpse"), TTAB(revive_mon, (timeout_proc)0, "revive_mon"), diff --git a/src/topten.c b/src/topten.c index 0191997e5..08f80e96c 100644 --- a/src/topten.c +++ b/src/topten.c @@ -76,7 +76,7 @@ STATIC_DCL void FDECL(nsb_unmung_line,(char*)); #endif /* must fit with end.c; used in rip.c */ -NEARDATA const char *killed_by_prefix[] = { +NEARDATA const char * const killed_by_prefix[] = { "killed by ", "choked on ", "poisoned by ", "", "drowned in ", "burned by ", "dissolved in ", "crushed to death by ", "petrified by ", "turned to slime by ", "killed by ", "", "", "", "", "" @@ -128,13 +128,13 @@ FILE *rfile; struct toptenentry *tt; { #ifdef NO_SCAN_BRACK /* Version_ Pts DgnLevs_ Hp___ Died__Born id */ - static const char *fmt = "%d %d %d %ld %d %d %d %d %d %d %ld %ld %d%*c"; - static const char *fmt32 = "%c%c %s %s%*c"; - static const char *fmt33 = "%s %s %s %s %s %s%*c"; + static const char fmt[] = "%d %d %d %ld %d %d %d %d %d %d %ld %ld %d%*c"; + static const char fmt32[] = "%c%c %s %s%*c"; + static const char fmt33[] = "%s %s %s %s %s %s%*c"; #else - static const char *fmt = "%d.%d.%d %ld %d %d %d %d %d %d %ld %ld %d "; - static const char *fmt32 = "%c%c %[^,],%[^\n]%*c"; - static const char *fmt33 = "%s %s %s %s %[^,],%[^\n]%*c"; + static const char fmt[] = "%d.%d.%d %ld %d %d %d %d %d %d %ld %ld %d "; + static const char fmt32[] = "%c%c %[^,],%[^\n]%*c"; + static const char fmt33[] = "%s %s %s %s %[^,],%[^\n]%*c"; #endif #ifdef UPDATE_RECORD_IN_PLACE diff --git a/src/trap.c b/src/trap.c index 526e7bd68..f26a300da 100644 --- a/src/trap.c +++ b/src/trap.c @@ -38,11 +38,11 @@ STATIC_VAR const char * const blindgas[6]; #else -STATIC_VAR const char *a_your[2] = { "a", "your" }; -STATIC_VAR const char *A_Your[2] = { "A", "Your" }; -STATIC_VAR const char *the_your[2] = { "the", "your" }; +STATIC_VAR const char * const a_your[2] = { "a", "your" }; +STATIC_VAR const char * const A_Your[2] = { "A", "Your" }; +STATIC_VAR const char * const the_your[2] = { "the", "your" }; STATIC_VAR const char tower_of_flame[] = "tower of flame"; -STATIC_VAR const char *A_gush_of_water_hits = "A gush of water hits"; +STATIC_VAR const char * const A_gush_of_water_hits = "A gush of water hits"; STATIC_VAR const char * const blindgas[6] = {"humid", "odorless", "pungent", "chilling", "acrid", "biting"}; @@ -120,8 +120,8 @@ int type; boolean print; struct monst *victim; { - static NEARDATA const char *action[] = { "smoulder", "rust", "rot", "corrode" }; - static NEARDATA const char *msg[] = { "burnt", "rusted", "rotten", "corroded" }; + static NEARDATA const char * const action[] = { "smoulder", "rust", "rot", "corrode" }; + static NEARDATA const char * const msg[] = { "burnt", "rusted", "rotten", "corroded" }; boolean vulnerable = FALSE; boolean grprot = FALSE; boolean is_primary = TRUE; @@ -3668,7 +3668,7 @@ unconscious() !strncmp(nomovemsg,"You are consci", 14)))); } -static char lava_killer[] = "molten lava"; +static const char lava_killer[] = "molten lava"; boolean lava_effects() diff --git a/src/u_init.c b/src/u_init.c index da6839a62..2a371916a 100644 --- a/src/u_init.c +++ b/src/u_init.c @@ -251,7 +251,7 @@ static struct inv_sub { short race_pm, item_otyp, subs_otyp; } inv_subs[] = { { NON_PM, STRANGE_OBJECT, STRANGE_OBJECT } }; -static struct def_skill Skill_A[] = { +static const struct def_skill Skill_A[] = { { P_DAGGER, P_BASIC }, { P_KNIFE, P_BASIC }, { P_PICK_AXE, P_EXPERT }, { P_SHORT_SWORD, P_BASIC }, { P_SCIMITAR, P_SKILLED }, { P_SABER, P_EXPERT }, @@ -269,7 +269,7 @@ static struct def_skill Skill_A[] = { { P_NONE, 0 } }; -static struct def_skill Skill_B[] = { +static const struct def_skill Skill_B[] = { { P_DAGGER, P_BASIC }, { P_AXE, P_EXPERT }, { P_PICK_AXE, P_EXPERT }, { P_SHORT_SWORD, P_BASIC }, { P_BROAD_SWORD, P_SKILLED }, { P_LONG_SWORD, P_SKILLED }, @@ -288,7 +288,7 @@ static struct def_skill Skill_B[] = { { P_NONE, 0 } }; -static struct def_skill Skill_C[] = { +static const struct def_skill Skill_C[] = { { P_DAGGER, P_BASIC }, { P_KNIFE, P_SKILLED }, { P_AXE, P_SKILLED }, { P_PICK_AXE, P_BASIC }, { P_CLUB, P_EXPERT }, { P_MACE, P_EXPERT }, @@ -303,7 +303,7 @@ static struct def_skill Skill_C[] = { { P_NONE, 0 } }; -static struct def_skill Skill_H[] = { +static const struct def_skill Skill_H[] = { { P_DAGGER, P_SKILLED }, { P_KNIFE, P_EXPERT }, { P_SHORT_SWORD, P_SKILLED }, { P_SCIMITAR, P_BASIC }, { P_SABER, P_BASIC }, { P_CLUB, P_SKILLED }, @@ -317,7 +317,7 @@ static struct def_skill Skill_H[] = { { P_NONE, 0 } }; -static struct def_skill Skill_K[] = { +static const struct def_skill Skill_K[] = { { P_DAGGER, P_BASIC }, { P_KNIFE, P_BASIC }, { P_AXE, P_SKILLED }, { P_PICK_AXE, P_BASIC }, { P_SHORT_SWORD, P_SKILLED }, { P_BROAD_SWORD, P_SKILLED }, @@ -339,7 +339,7 @@ static struct def_skill Skill_K[] = { { P_NONE, 0 } }; -static struct def_skill Skill_Mon[] = { +static const struct def_skill Skill_Mon[] = { { P_QUARTERSTAFF, P_BASIC }, { P_SPEAR, P_BASIC }, { P_JAVELIN, P_BASIC }, { P_CROSSBOW, P_BASIC }, { P_SHURIKEN, P_BASIC }, @@ -351,7 +351,7 @@ static struct def_skill Skill_Mon[] = { { P_NONE, 0 } }; -static struct def_skill Skill_P[] = { +static const struct def_skill Skill_P[] = { { P_CLUB, P_EXPERT }, { P_MACE, P_EXPERT }, { P_MORNING_STAR, P_EXPERT }, { P_FLAIL, P_EXPERT }, { P_HAMMER, P_EXPERT }, { P_QUARTERSTAFF, P_EXPERT }, @@ -367,7 +367,7 @@ static struct def_skill Skill_P[] = { { P_NONE, 0 } }; -static struct def_skill Skill_R[] = { +static const struct def_skill Skill_R[] = { { P_DAGGER, P_EXPERT }, { P_KNIFE, P_EXPERT }, { P_SHORT_SWORD, P_EXPERT }, { P_BROAD_SWORD, P_SKILLED }, { P_LONG_SWORD, P_SKILLED }, { P_TWO_HANDED_SWORD, P_BASIC }, @@ -387,7 +387,7 @@ static struct def_skill Skill_R[] = { { P_NONE, 0 } }; -static struct def_skill Skill_Ran[] = { +static const struct def_skill Skill_Ran[] = { { P_DAGGER, P_EXPERT }, { P_KNIFE, P_SKILLED }, { P_AXE, P_SKILLED }, { P_PICK_AXE, P_BASIC }, { P_SHORT_SWORD, P_BASIC }, { P_MORNING_STAR, P_BASIC }, @@ -408,7 +408,7 @@ static struct def_skill Skill_Ran[] = { { P_NONE, 0 } }; -static struct def_skill Skill_S[] = { +static const struct def_skill Skill_S[] = { { P_DAGGER, P_BASIC }, { P_KNIFE, P_SKILLED }, { P_SHORT_SWORD, P_EXPERT }, { P_BROAD_SWORD, P_SKILLED }, { P_LONG_SWORD, P_EXPERT }, { P_TWO_HANDED_SWORD, P_EXPERT }, @@ -427,7 +427,7 @@ static struct def_skill Skill_S[] = { }; #ifdef TOURIST -static struct def_skill Skill_T[] = { +static const struct def_skill Skill_T[] = { { P_DAGGER, P_EXPERT }, { P_KNIFE, P_SKILLED }, { P_AXE, P_BASIC }, { P_PICK_AXE, P_BASIC }, { P_SHORT_SWORD, P_EXPERT }, { P_BROAD_SWORD, P_BASIC }, @@ -453,7 +453,7 @@ static struct def_skill Skill_T[] = { }; #endif /* TOURIST */ -static struct def_skill Skill_V[] = { +static const struct def_skill Skill_V[] = { { P_DAGGER, P_EXPERT }, { P_AXE, P_EXPERT }, { P_PICK_AXE, P_SKILLED }, { P_SHORT_SWORD, P_SKILLED }, { P_BROAD_SWORD, P_SKILLED }, { P_LONG_SWORD, P_EXPERT }, @@ -472,7 +472,7 @@ static struct def_skill Skill_V[] = { { P_NONE, 0 } }; -static struct def_skill Skill_W[] = { +static const struct def_skill Skill_W[] = { { P_DAGGER, P_EXPERT }, { P_KNIFE, P_SKILLED }, { P_AXE, P_SKILLED }, { P_SHORT_SWORD, P_BASIC }, { P_CLUB, P_SKILLED }, { P_MACE, P_BASIC }, @@ -850,7 +850,7 @@ STATIC_OVL boolean restricted_spell_discipline(otyp) int otyp; { - struct def_skill *skills; + const struct def_skill *skills; int this_skill = spell_skilltype(otyp); switch (Role_switch) { diff --git a/src/version.c b/src/version.c index 669d22d9c..3b0c8077b 100644 --- a/src/version.c +++ b/src/version.c @@ -112,7 +112,7 @@ void store_version(fd) int fd; { - static struct version_info version_data = { + const static struct version_info version_data = { VERSION_NUMBER, VERSION_FEATURES, VERSION_SANITY1, VERSION_SANITY2 }; diff --git a/src/weapon.c b/src/weapon.c index 638146bd6..9089f7983 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -56,7 +56,7 @@ STATIC_VAR NEARDATA const short skill_names_indices[P_NUM_SKILLS] = { }; /* note: entry [0] isn't used */ -STATIC_VAR NEARDATA const char *odd_skill_names[] = { +STATIC_VAR NEARDATA const char * const odd_skill_names[] = { "no skill", "bare hands", /* use barehands_or_martial[] instead */ "two weapon combat", @@ -74,7 +74,7 @@ STATIC_VAR NEARDATA const char *odd_skill_names[] = { "matter spells", }; /* indexed vis `is_martial() */ -STATIC_VAR NEARDATA const char *barehands_or_martial[] = { +STATIC_VAR NEARDATA const char * const barehands_or_martial[] = { "bare handed combat", "martial arts" }; @@ -472,7 +472,7 @@ register struct monst *mtmp; } /* Weapons in order of preference */ -static NEARDATA short hwep[] = { +static const NEARDATA short hwep[] = { CORPSE, /* cockatrice corpse */ TSURUGI, RUNESWORD, DWARVISH_MATTOCK, TWO_HANDED_SWORD, BATTLE_AXE, KATANA, UNICORN_HORN, CRYSKNIFE, TRIDENT, LONG_SWORD, @@ -835,7 +835,7 @@ int skill; P_NAME(skill)); } -static struct skill_range { +const static struct skill_range { short first, last; const char *name; } skill_ranges[] = { @@ -1237,7 +1237,7 @@ struct obj *weapon; */ void skill_init(class_skill) -struct def_skill *class_skill; +const struct def_skill *class_skill; { struct obj *obj; int skmax, skill; diff --git a/src/wizard.c b/src/wizard.c index e35723415..e6dbca12f 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -550,7 +550,7 @@ wizdead() } } -const char *random_insult[] = { +const char * const random_insult[] = { "antic", "blackguard", "caitiff", @@ -581,7 +581,7 @@ const char *random_insult[] = { "wretch", }; -const char *random_malediction[] = { +const char * const random_malediction[] = { "Hell shall soon claim thy remains,", "I chortle at thee, thou pathetic", "Prepare to die, thou", diff --git a/src/zap.c b/src/zap.c index 56cc896cd..cabaf61c9 100644 --- a/src/zap.c +++ b/src/zap.c @@ -62,7 +62,7 @@ extern const char *flash_types[]; #else STATIC_VAR const char are_blinded_by_the_flash[] = "are blinded by the flash!"; -const char *flash_types[] = { /* also used in buzzmu(mcastu.c) */ +const char * const flash_types[] = { /* also used in buzzmu(mcastu.c) */ "magic missile", /* Wands must be 0-9 */ "bolt of fire", "bolt of cold", @@ -3752,7 +3752,7 @@ register struct obj *obj; return TRUE; } -const char *destroy_strings[] = { +const char * const destroy_strings[] = { "freezes and shatters", "freeze and shatter", "shattered potion", "boils and explodes", "boil and explode", "boiling potion", "catches fire and burns", "catch fire and burn", "burning scroll", -- 2.40.0