]> granicus.if.org Git - nethack/commitdiff
some lint cleanup
authornethack.rankin <nethack.rankin>
Thu, 9 Jan 2003 09:18:14 +0000 (09:18 +0000)
committernethack.rankin <nethack.rankin>
Thu, 9 Jan 2003 09:18:14 +0000 (09:18 +0000)
     Building with an old version of gcc with various warnings enabled
generated a lot of noise.  Most of it was due to not guarding string
literals with `const', but there were a couple of actual problems too.

21 files changed:
include/extern.h
include/winprocs.h
src/apply.c
src/cmd.c
src/dig.c
src/dokick.c
src/dothrow.c
src/end.c
src/hack.c
src/mapglyph.c
src/mcastu.c
src/mhitu.c
src/options.c
src/pickup.c
src/polyself.c
src/rip.c
src/role.c
src/shk.c
src/trap.c
src/worn.c
src/zap.c

index 1fc00a2fa6c27c6b8e4ee06c5c953fd9cfc7f0fe..88955cc313032feed7bce09c34bb51779083d36e 100644 (file)
@@ -1379,7 +1379,7 @@ E void FDECL(assign_warnings, (uchar *));
 E char *FDECL(nh_getenv, (const char *));
 E void FDECL(set_duplicate_opt_detection, (int));
 E void FDECL(set_wc_option_mod_status, (unsigned long, int));
-E void FDECL(set_option_mod_status, (char *, int));
+E void FDECL(set_option_mod_status, (const char *,int));
 
 /* ### pager.c ### */
 
index 3f574370ffebfb5c850afed8c689c616fccb85bd..6063d283a7a42be7f3b8c7de9479f4492bf6ef5e 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)winprocs.h 3.4     1996/02/18      */
+/*     SCCS Id: @(#)winprocs.h 3.4     2003/01/08      */
 /* Copyright (c) David Cohrs, 1992                               */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -202,7 +202,7 @@ extern NEARDATA struct window_procs windowprocs;
 #endif
 
 struct wc_Opt {
-       char *wc_name;
+       const char *wc_name;
        unsigned long wc_bit;
 };
 
index 4c96955e22631b404f1cb57a16a8cafc6bfa796e..44e274b5aa3b087fcc5c2d71c836befb261219eb 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)apply.c    3.4     2002/11/07      */
+/*     SCCS Id: @(#)apply.c    3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -874,7 +874,7 @@ STATIC_OVL void
 use_candelabrum(obj)
 register struct obj *obj;
 {
-       char *s = obj->spe != 1 ? "candles" : "candle";
+       const char *s = (obj->spe != 1) ? "candles" : "candle";
 
        if(Underwater) {
                You("cannot make fire under water.");
@@ -926,7 +926,7 @@ use_candle(obj)
 register struct obj *obj;
 {
        register struct obj *otmp;
-       char *s = obj->quan != 1 ? "candles" : "candle";
+       const char *s = (obj->quan != 1) ? "candles" : "candle";
        char qbuf[QBUFSZ];
 
        if(u.uswallow) {
index 6b1e999768f894e5a5b8f68a33b379a3ceaf0e55..4ec4090011543823fc0609f357d069302f4e8990 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)cmd.c      3.4     2002/10/18      */
+/*     SCCS Id: @(#)cmd.c      3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -149,7 +149,7 @@ static void NDECL(end_of_input);
 static const char* readchar_queue="";
 
 STATIC_DCL char *NDECL(parse);
-STATIC_DCL boolean FDECL(help_dir, (CHAR_P, char *));
+STATIC_DCL boolean FDECL(help_dir, (CHAR_P,const char *));
 
 #ifdef OVL1
 
@@ -2035,11 +2035,11 @@ const char *s;
 STATIC_OVL boolean
 help_dir(sym, msg)
 char sym;
-char *msg;
+const char *msg;
 {
        char ctrl;
        winid win;
-       char *wiz_only_list = "EFGIOVW";
+       const char wiz_only_list[] = "EFGIOVW";
        char buf[BUFSZ], buf2[BUFSZ], *expl;
 
        win = create_nhwindow(NHW_TEXT);
index 1070d91e03d143ad1da426a4463207e5ac005472..e6b69b31920d763100eb718ea876dbe359fa99d7 100644 (file)
--- a/src/dig.c
+++ b/src/dig.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)dig.c      3.4     2002/12/18      */
+/*     SCCS Id: @(#)dig.c      3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1037,7 +1037,8 @@ watch_dig(mtmp, x, y, zap)
                    verbalize("Halt, vandal!  You're under arrest!");
                    (void) angry_guards(!(flags.soundok));
                } else {
-                   char *str;
+                   const char *str;
+
                    if (IS_DOOR(lev->typ))
                        str = "door";
                    else if (IS_TREE(lev->typ))
index 51305e83d33ff3a379d8347a376e3173f02f2de8..d6558acdef817571ce2257edca139f1d27764acc 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)dokick.c   3.4     2002/09/18      */
+/*     SCCS Id: @(#)dokick.c   3.4     2003/01/08      */
 /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1314,7 +1314,8 @@ boolean shop_floor_obj;
 
        /* some things break rather than ship */
        if (breaktest(otmp)) {
-           char *result;
+           const char *result;
+
            if (objects[otmp->otyp].oc_material == GLASS
 #ifdef TOURIST
                || otmp->otyp == EXPENSIVE_CAMERA
index f93600395bded33d90e7cc67985c85af153a7658..28a61d90abfb24b769c6223be1b00bcb6465af33 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)dothrow.c  3.4     2002/03/29      */
+/*     SCCS Id: @(#)dothrow.c  3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -443,7 +443,7 @@ hurtle_step(arg, x, y)
 
     if (!Passes_walls || !(may_pass = may_passwall(x, y))) {
        if (IS_ROCK(levl[x][y].typ) || closed_door(x,y)) {
-           char *s;
+           const char *s;
 
            pline("Ouch!");
            if (IS_TREE(levl[x][y].typ))
index a94b7006d74ae8f866dcb3bd0ff3b87bbf8e0563..cc389b9ece7c0f341eca8e9772fcb5378cb4df9b 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -18,7 +18,7 @@
  
 struct valuable_data { long count; int typ; };
 
-struct valuable_data
+static struct valuable_data
        gems[LAST_GEM+1 - FIRST_GEM + 1], /* 1 extra for glass */
        amulets[LAST_AMULET+1 - FIRST_AMULET];
 
@@ -39,9 +39,9 @@ STATIC_DCL void FDECL(get_valuables, (struct obj *));
 STATIC_DCL void FDECL(sort_valuables, (struct valuable_data *,int));
 STATIC_DCL void FDECL(artifact_score, (struct obj *,BOOLEAN_P,winid));
 STATIC_DCL void FDECL(savelife, (int));
-STATIC_DCL void FDECL(list_vanquished, (int, BOOLEAN_P));
-STATIC_DCL void FDECL(list_genocided, (int, BOOLEAN_P));
-STATIC_DCL boolean FDECL(should_query_disclose_option, (int, int*));
+STATIC_DCL void FDECL(list_vanquished, (CHAR_P,BOOLEAN_P));
+STATIC_DCL void FDECL(list_genocided, (CHAR_P,BOOLEAN_P));
+STATIC_DCL boolean FDECL(should_query_disclose_option, (int,char *));
 
 #if defined(__BEOS__) || defined(MICRO) || defined(WIN32) || defined(OS2)
 extern void FDECL(nethack_exit,(int));
@@ -84,8 +84,7 @@ static NEARDATA const char *ends[] = {                /* "when you..." */
        "quit", "escaped", "ascended"
 };
 
-extern const char *killed_by_prefix[];
-
+extern const char * const killed_by_prefix[];  /* from topten.c */
 
 /*ARGSUSED*/
 void
@@ -308,36 +307,39 @@ panic VA_DECL(const char *, str)
 STATIC_OVL boolean
 should_query_disclose_option(category, defquery)
 int category;
-int *defquery;
+char *defquery;
 {
-       int idx;
-       char *dop = index(disclosure_options, category);
-       if (dop && defquery) {
-               idx = (dop - disclosure_options) / sizeof(char);
-               if (idx < 0 || idx > (NUM_DISCLOSURE_OPTIONS - 1)) {
-                       impossible(
-                               "should_query_disclose_option: bad disclosure index %d %c",
-                               idx, category);
-                       *defquery = DISCLOSE_PROMPT_DEFAULT_YES;
-                       return TRUE;
-               }
-               if (flags.end_disclose[idx] == DISCLOSE_YES_WITHOUT_PROMPT) {
-                       *defquery = 'y';
-                       return FALSE;
-               } else if (flags.end_disclose[idx] == DISCLOSE_NO_WITHOUT_PROMPT) {
-                       *defquery = 'n';
-                       return FALSE;
-               } else if (flags.end_disclose[idx] == DISCLOSE_PROMPT_DEFAULT_YES) {
-                       *defquery = 'y';
-                       return TRUE;
-               } else if (flags.end_disclose[idx] == DISCLOSE_PROMPT_DEFAULT_NO) {
-                       *defquery = 'n';
-                       return TRUE;
-               }
+    int idx;
+    char *dop = index(disclosure_options, category);
+
+    if (dop && defquery) {
+       idx = dop - disclosure_options;
+       if (idx < 0 || idx > (NUM_DISCLOSURE_OPTIONS - 1)) {
+           impossible(
+                  "should_query_disclose_option: bad disclosure index %d %c",
+                      idx, category);
+           *defquery = DISCLOSE_PROMPT_DEFAULT_YES;
+           return TRUE;
        }
-       if (defquery)impossible("should_query_disclose_option: bad category %c", category);
-       else impossible("should_query_disclose_option: null defquery");
-       return TRUE;
+       if (flags.end_disclose[idx] == DISCLOSE_YES_WITHOUT_PROMPT) {
+           *defquery = 'y';
+           return FALSE;
+       } else if (flags.end_disclose[idx] == DISCLOSE_NO_WITHOUT_PROMPT) {
+           *defquery = 'n';
+           return FALSE;
+       } else if (flags.end_disclose[idx] == DISCLOSE_PROMPT_DEFAULT_YES) {
+           *defquery = 'y';
+           return TRUE;
+       } else if (flags.end_disclose[idx] == DISCLOSE_PROMPT_DEFAULT_NO) {
+           *defquery = 'n';
+           return TRUE;
+       }
+    }
+    if (defquery)
+       impossible("should_query_disclose_option: bad category %c", category);
+    else
+       impossible("should_query_disclose_option: null defquery");
+    return TRUE;
 }
 
 STATIC_OVL void
@@ -345,9 +347,8 @@ disclose(how,taken)
 int how;
 boolean taken;
 {
-       char    c = 0;
+       char    c = 0, defquery;
        char    qbuf[QBUFSZ];
-       int defquery;
        boolean ask;
 
        if (invent) {
@@ -359,12 +360,10 @@ boolean taken;
 
            ask = should_query_disclose_option('i', &defquery);
            if (!done_stopprint) {
-               if (ask)
-                  c = yn_function(qbuf, ynqchars, defquery);
-               if ((!ask && defquery == 'y') || (ask && c == 'y')) {
-                       /* New dump format by maartenj@cs.vu.nl */
+               c = ask ? yn_function(qbuf, ynqchars, defquery) : defquery;
+               if (c == 'y') {
                        struct obj *obj;
-                       
+
                        for (obj = invent; obj; obj = obj->nobj) {
                            makeknown(obj->otyp);
                            obj->known = obj->bknown = obj->dknown = obj->rknown = 1;
@@ -372,17 +371,17 @@ boolean taken;
                        (void) display_inventory((char *)0, TRUE);
                        container_contents(invent, TRUE, TRUE);
                }
-               if (ask && c == 'q')  done_stopprint++;
+               if (c == 'q')  done_stopprint++;
            }
        }
 
-       ask = should_query_disclose_option('a', &defquery);
+       ask = should_query_disclose_option('a', &defquery);
        if (!done_stopprint) {
-           if (ask)
-               c = yn_function("Do you want to see your attributes?",ynqchars, defquery);
-           if ((!ask && defquery == 'y') || (ask && c == 'y'))
+           c = ask ? yn_function("Do you want to see your attributes?",
+                                 ynqchars, defquery) : defquery;
+           if (c == 'y')
                enlightenment(how >= PANICKED ? 1 : 2); /* final */
-           if (ask && c == 'q') done_stopprint++;
+           if (c == 'q') done_stopprint++;
        }
 
        ask = should_query_disclose_option('v', &defquery);
@@ -395,11 +394,11 @@ boolean taken;
 
        ask = should_query_disclose_option('c', &defquery);
        if (!done_stopprint) {
-           if (ask)
-               c = yn_function("Do you want to see your conduct?",ynqchars,defquery);
-           if ((!ask && defquery == 'y') || (ask && c == 'y'))
+           c = ask ? yn_function("Do you want to see your conduct?",
+                                 ynqchars, defquery) : defquery;
+           if (c == 'y')
                show_conduct(how >= PANICKED ? 1 : 2);
-           if (ask && c == 'q') done_stopprint++;
+           if (c == 'q') done_stopprint++;
        }
 }
 
@@ -969,7 +968,7 @@ int status;
 
 STATIC_OVL void
 list_vanquished(defquery, ask)
-int defquery;
+char defquery;
 boolean ask;
 {
     register int i, lev;
@@ -990,11 +989,10 @@ boolean ask;
      * includes all dead monsters, not just those killed by the player
      */
     if (ntypes != 0) {
-       if (ask)
-           c = yn_function("Do you want an account of creatures vanquished?",
-                               ynqchars, defquery);
-       if (ask && c == 'q') done_stopprint++;
-       if ((!ask && defquery == 'y') || (ask && c == 'y')) {
+       c = ask ? yn_function("Do you want an account of creatures vanquished?",
+                             ynqchars, defquery) : defquery;
+       if (c == 'q') done_stopprint++;
+       if (c == 'y') {
            klwin = create_nhwindow(NHW_MENU);
            putstr(klwin, 0, "Vanquished creatures:");
            putstr(klwin, 0, "");
@@ -1009,11 +1007,11 @@ boolean ask;
                                mons[i].mname);
                        if (nkilled > 1) {
                            switch (nkilled) {
-                               case 2:  Sprintf(eos(buf)," (twice)");  break;
-                               case 3:  Sprintf(eos(buf)," (thrice)");  break;
-                               default: Sprintf(eos(buf)," (%d time%s)",
-                                               nkilled, plur(nkilled));
-                               break;
+                               case 2:  Sprintf(eos(buf)," (twice)");  break;
+                               case 3:  Sprintf(eos(buf)," (thrice)");  break;
+                               default: Sprintf(eos(buf)," (%d time%s)",
+                                                nkilled, plur(nkilled));
+                                        break;
                            }
                        }
                    } else {
@@ -1056,7 +1054,7 @@ num_genocides()
 
 STATIC_OVL void
 list_genocided(defquery, ask)
-int defquery;
+char defquery;
 boolean ask;
 {
     register int i;
@@ -1069,11 +1067,10 @@ boolean ask;
 
     /* genocided species list */
     if (ngenocided != 0) {
-       if (ask)
-           c = yn_function("Do you want a list of species genocided?",
-                               ynqchars, defquery);
-       if (ask && c == 'q') done_stopprint++;
-       if ((!ask && defquery == 'y') || (ask && c == 'y')) {
+       c = ask ? yn_function("Do you want a list of species genocided?",
+                             ynqchars, defquery) : defquery;
+       if (c == 'q') done_stopprint++;
+       if (c == 'y') {
            klwin = create_nhwindow(NHW_MENU);
            putstr(klwin, 0, "Genocided species:");
            putstr(klwin, 0, "");
index 56a9e7d57854d3329822355bacc2ab74237a9f5f..904221886a76fc7b2c1401fee18309cc809545e0 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)hack.c     3.4     2002/09/14      */
+/*     SCCS Id: @(#)hack.c     3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -787,15 +787,15 @@ boolean guess;
        /* if guessing, find best location in travel matrix and go there */
        if (guess) {
            int px = tx, py = ty;       /* pick location */
-           int dist, d;
+           int dist, nxtdist;
 
            dist = distmin(ux, uy, tx, ty);
            for (tx = 1; tx < COLNO; ++tx)
                for (ty = 0; ty < ROWNO; ++ty)
                    if (travel[tx][ty]) {
-                       d = distmin(ux, uy, tx, ty);
-                       if (d < dist && couldsee(tx, ty)) {
-                           px = tx; py = ty; dist = d;
+                       nxtdist = distmin(ux, uy, tx, ty);
+                       if (nxtdist < dist && couldsee(tx, ty)) {
+                           px = tx; py = ty; dist = nxtdist;
                        }
                    }
 
@@ -838,6 +838,7 @@ domove()
        xchar chainx, chainy, ballx, bally;     /* ball&chain new positions */
        int bc_control;                         /* control for ball&chain */
        boolean cause_delay = FALSE;    /* dragging ball will skip a move */
+       const char *predicament;
 
        u_wipe_engr(rnd(5));
 
@@ -1128,7 +1129,7 @@ domove()
                    }
                } else if (u.utraptype == TT_LAVA) {
                    if(flags.verbose) {
-                       char *predicament = "stuck in the lava";
+                       predicament = "stuck in the lava";
 #ifdef STEED
                        if (u.usteed)
                            Norep("%s is %s.", upstart(y_monnam(u.usteed)),
@@ -1159,7 +1160,7 @@ domove()
                    }
                    if(--u.utrap) {
                        if(flags.verbose) {
-                           char *predicament = "stuck to the web";
+                           predicament = "stuck to the web";
 #ifdef STEED
                            if (u.usteed)
                                Norep("%s is %s.", upstart(y_monnam(u.usteed)),
@@ -1180,7 +1181,7 @@ domove()
                } else if (u.utraptype == TT_INFLOOR) {
                    if(--u.utrap) {
                        if(flags.verbose) {
-                           char *predicament = "stuck in the";
+                           predicament = "stuck in the";
 #ifdef STEED
                            if (u.usteed)
                                Norep("%s is %s %s.",
@@ -1202,7 +1203,7 @@ domove()
                    }
                } else {
                    if(flags.verbose) {
-                       char *predicament = "caught in a bear trap";
+                       predicament = "caught in a bear trap";
 #ifdef STEED
                        if (u.usteed)
                            Norep("%s is %s.", upstart(y_monnam(u.usteed)),
index f9710f9b2eb1a9c116f5e33f711915d2217db0a1..e22af26e26782ba2b515e398febc2df15bc2d13f 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mapglyph.c 3.4     2002/07/17      */
+/*     SCCS Id: @(#)mapglyph.c 3.4     2003/01/08      */
 /* Copyright (c) David Cohrs, 1991                               */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -65,7 +65,9 @@ int *ochar;
 unsigned *ospecial;
 {
        register int offset;
+#if defined(TEXTCOLOR) || defined(ROGUE_COLOR)
        int color = NO_COLOR;
+#endif
        uchar ch;
        unsigned special = 0;
 
index 595b6a13f0e1e823afd5b978d958d28d6e015583..93d3b8d3381272d109f889b2b00197e59f6b08d1 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mcastu.c   3.4     2002/02/07      */
+/*     SCCS Id: @(#)mcastu.c   3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -40,7 +40,7 @@ STATIC_DCL boolean FDECL(spell_would_be_useless,(struct monst *,unsigned int,int
 
 #ifdef OVL0
 
-extern const char *flash_types[];      /* from zap.c */
+extern const char * const flash_types[];       /* from zap.c */
 
 /* feedback when frustrated monster couldn't cast a spell */
 STATIC_OVL
index 00e0225b69647fa21e246b65f402fd362a087759..04fb991d9d263db1320caa2b63206b953c48fb7d 100644 (file)
@@ -1636,7 +1636,7 @@ gulpmu(mtmp, mattk)       /* monster swallows you, or damage if u.uswallow */
 
                i = number_leashed();
                if (i > 0) {
-                   char *s = (i > 1) ? "leashes" : "leash";
+                   const char *s = (i > 1) ? "leashes" : "leash";
                    pline_The("%s %s loose.", s, vtense(s, "snap"));
                    unleash_all();
                }
index 02b03b8c0b230de7e05d2b1424b4766d75af3f47..56a6cb7bc14028e8626768db906da0eea3fb675f 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)options.c  3.4     2002/08/24      */
+/*     SCCS Id: @(#)options.c  3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -3207,12 +3207,13 @@ struct wc_Opt wc_options[] = {
  */
 void
 set_option_mod_status(optnam, status)
-char *optnam;
+const char *optnam;
 int status;
 {
        int k;
        if (status < SET_IN_FILE || status > SET_IN_GAME) {
-               impossible("set_option_mod_status: status out of range %d.", status);
+               impossible("set_option_mod_status: status out of range %d.",
+                          status);
                return;
        }
        for (k = 0; boolopt[k].name; k++) {
@@ -3244,7 +3245,8 @@ int status;
 {
        int k = 0;
        if (status < SET_IN_FILE || status > SET_IN_GAME) {
-               impossible("set_option_mod_status: status out of range %d.", status);
+               impossible("set_option_mod_status: status out of range %d.",
+                          status);
                return;
        }
        while (wc_options[k].wc_name) {
@@ -3327,8 +3329,8 @@ char *op;
        int j;
        char buf[BUFSZ];
        char *wn, *tfg, *tbg, *newop;
-       static char *wnames[] = {"menu", "message", "status", "text"};
-       static char *shortnames[] = {"mnu", "msg", "sts", "txt"};
+       static const char *wnames[] = { "menu", "message", "status", "text" };
+       static const char *shortnames[] = { "mnu", "msg", "sts", "txt" };
        static char **fgp[] = {
                &iflags.wc_foregrnd_menu,
                &iflags.wc_foregrnd_message,
index 93a35ef29212d45d592e0a00a329a85c7b61bfd0..22648343c228feb51986967c2905cac728f4de19 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)pickup.c   3.4     2002/09/08      */
+/*     SCCS Id: @(#)pickup.c   3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2226,7 +2226,7 @@ boolean outokay, inokay;
     menu_item *pick_list;
     char buf[BUFSZ];
     int n;
-    char *menuselector = iflags.lootabc ? "abc" : "oib";
+    const char *menuselector = iflags.lootabc ? "abc" : "oib";
 
     any.a_void = 0;
     win = create_nhwindow(NHW_MENU);
index cca8ceab666cea55def049936133d7a1395a9acc..01bc49efaf738b2f423c68248050c8b2a7e69205 100644 (file)
@@ -619,7 +619,7 @@ break_armor()
 
                /* Future possiblities: This could damage/destroy helmet */
                Sprintf(hornbuf, "horn%s", plur(num_horns(youmonst.data)));
-               Your("%s %s through %s %s.", vtense(hornbuf, "pierce"),
+               Your("%s through %s %s.", vtense(hornbuf, "pierce"),
                     shk_your(yourbuf, otmp), xname(otmp));
            } else {
                if (donning(otmp)) cancel_don();
index cab4d2e9e1e28bc7594790215688781df1373daa..9a82630058b64ae16e633f98fed70f0c28b92969 100644 (file)
--- a/src/rip.c
+++ b/src/rip.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)rip.c      3.4     2001/09/24      */
+/*     SCCS Id: @(#)rip.c      3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -6,7 +6,7 @@
 
 STATIC_DCL void FDECL(center, (int, char *));
 
-extern const char *killed_by_prefix[];
+extern const char * const killed_by_prefix[];  /* from topten.c */
 
 #if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) || defined(MSWIN_GRAPHICS)
 # define TEXT_TOMBSTONE
index 9da640912d825a9b487fb1a9945d9e9b95700b39..d8954709ffea413808df2c596978276860bc320a 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)role.c     3.4     2000/08/20      */
+/*     SCCS Id: @(#)role.c     3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985-1999. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1100,7 +1100,7 @@ int buflen, rolenum, racenum, gendnum, alignnum;
 {
        int k, gendercount = 0, aligncount = 0;
        char buf[BUFSZ];
-       char *err_ret = " character's";
+       static char err_ret[] = " character's";
        boolean donefirst = FALSE;
 
        if (!suppliedbuf || buflen < 1) return err_ret;
index 57a587baaf6d81d309ac5c194893231b597947ba..ce566d31b6543df19ccbe56b9041d1343f410e38 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)shk.c      3.4     2002/11/20      */
+/*     SCCS Id: @(#)shk.c      3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2441,7 +2441,8 @@ register boolean peaceful, silent;
            ESHK(shkp)->debit += value;
 
            if(!silent) {
-               char *still = "";
+               const char *still = "";
+
                if (credit_use) {
                    if (ESHK(shkp)->credit) {
                        You("have %ld %s credit remaining.",
@@ -2454,10 +2455,11 @@ register boolean peaceful, silent;
                    still = "still ";
                }
                if(obj->oclass == COIN_CLASS)
-                   You("%sowe %s %ld %s!", still, mon_nam(shkp), value, currency(value));
-               else You("%sowe %s %ld %s for %s!", still,
-                       mon_nam(shkp),
-                       value, currency(value),
+                   You("%sowe %s %ld %s!", still,
+                       mon_nam(shkp), value, currency(value));
+               else
+                   You("%sowe %s %ld %s for %s!", still,
+                       mon_nam(shkp), value, currency(value),
                        obj->quan > 1L ? "them" : "it");
            }
        } else {
index a85735a8962a3a3b9941a1d76767b6bb210cf281..74f88b1a3c391bd9033f5d978a85d81454132576 100644 (file)
@@ -1,10 +1,10 @@
-/*     SCCS Id: @(#)trap.c     3.4     2002/10/12      */
+/*     SCCS Id: @(#)trap.c     3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
 #include "hack.h"
 
-extern const char *destroy_strings[];
+extern const char * const destroy_strings[];   /* from zap.c */
 
 STATIC_DCL void FDECL(dofiretrap, (struct obj *));
 STATIC_DCL void NDECL(domagictrap);
@@ -793,13 +793,14 @@ glovecheck:               (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst);
                        u.umonnum == PM_PIT_FIEND)
                    pline("How pitiful.  Isn't that the pits?");
                if (ttype == SPIKED_PIT) {
-                   char *predicament = "on a set of sharp iron spikes";
+                   const char *predicament = "on a set of sharp iron spikes";
 #ifdef STEED
                    if (u.usteed) {
                        pline("%s lands %s!",
                                upstart(x_monnam(u.usteed,
                                         u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
-                                        "poor", SUPPRESS_SADDLE, FALSE)), predicament);
+                                        "poor", SUPPRESS_SADDLE, FALSE)),
+                             predicament);
                    } else
 #endif
                    You("land %s!", predicament);
@@ -1360,13 +1361,14 @@ int style;
                    }
                    if (otyp == BOULDER &&
                       (otmp2 = sobj_at(BOULDER, bhitpos.x, bhitpos.y)) != 0) {
-                       char *bmsg = " as one boulder sets another in motion";
+                       const char *bmsg =
+                                    " as one boulder sets another in motion";
 
                        if (!isok(bhitpos.x + dx, bhitpos.y + dy) || !dist ||
                            IS_ROCK(levl[bhitpos.x + dx][bhitpos.y + dy].typ))
                            bmsg = " as one boulder hits another";
-                           
-                       You_hear("a loud crash%s!",
+
+                       You_hear("a loud crash%s!",
                                cansee(bhitpos.x, bhitpos.y) ? bmsg : "");
                        obj_extract_self(otmp2);
                        /* pass off the otrapped flag to the next boulder */
index 0720c3d44d21ff422581fd76c842e8458d05f20f..61a239c8c00baf02ebc49acc99fe2be8dfd7011d 100644 (file)
@@ -147,7 +147,7 @@ int adjust; /* positive => increase speed, negative => decrease */
 struct obj *obj;       /* item to make known if effect can be seen */
 {
     struct obj *otmp;
-    boolean give_msg = !in_mklev, stoned = FALSE;
+    boolean give_msg = !in_mklev, petrify = FALSE;
     unsigned int oldspeed = mon->mspeed;
 
     switch (adjust) {
@@ -172,7 +172,7 @@ struct obj *obj;    /* item to make known if effect can be seen */
      case -3:                  /* petrification */
        /* take away intrinsic speed but don't reduce normal speed */
        if (mon->permspeed == MFAST) mon->permspeed = 0;
-       stoned = TRUE;
+       petrify = TRUE;
        break;
     }
 
@@ -184,12 +184,12 @@ struct obj *obj;  /* item to make known if effect can be seen */
     else
        mon->mspeed = mon->permspeed;
 
-    if (give_msg && (mon->mspeed != oldspeed || stoned) && canseemon(mon)) {
+    if (give_msg && (mon->mspeed != oldspeed || petrify) && canseemon(mon)) {
        /* fast to slow (skipping intermediate state) or vice versa */
        const char *howmuch = (mon->mspeed + oldspeed == MFAST + MSLOW) ?
                                "much " : "";
 
-       if (stoned) {
+       if (petrify) {
            /* mimic the player's petrification countdown; "slowing down"
               even if fast movement rate retained via worn speed boots */
            if (flags.verbose) pline("%s is slowing down.", Monnam(mon));
index 427cecf02caf2e98e4e35b0ceeace191dff4d212..90127d66ecc0d41adb192c2ab1f7117bcabd060b 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)zap.c      3.4     2002/11/07      */
+/*     SCCS Id: @(#)zap.c      3.4     2003/01/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -58,11 +58,11 @@ STATIC_DCL int FDECL(spell_hit_bonus, (int));
 
 #ifndef OVLB
 STATIC_VAR const char are_blinded_by_the_flash[];
-extern const char *flash_types[];
+extern const char * const flash_types[];
 #else
 STATIC_VAR const char are_blinded_by_the_flash[] = "are blinded by the flash!";
 
-const char * const 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",
@@ -3763,7 +3763,7 @@ register struct obj *obj;
        return TRUE;
 }
 
-const char * const destroy_strings[] = {
+const char * const destroy_strings[] = {       /* also used in trap.c */
        "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",