From 63e571cca69e7558ecb2d0e2e654eff896c0ac62 Mon Sep 17 00:00:00 2001 From: dholland Date: Wed, 12 Aug 2009 04:28:27 +0000 Subject: sprinkle static --- adventure/crc.c | 10 ++++----- adventure/extern.h | 22 +------------------ adventure/hdr.h | 5 ++--- adventure/init.c | 13 ++++++----- adventure/io.c | 45 ++++++++++++++++++++++---------------- adventure/save.c | 10 ++++----- adventure/subr.c | 26 ++++++++++++++-------- adventure/vocab.c | 8 +++---- adventure/wizard.c | 10 +++++---- arithmetic/arithmetic.c | 57 +++++++++++++++++++++++-------------------------- 10 files changed, 102 insertions(+), 104 deletions(-) diff --git a/adventure/crc.c b/adventure/crc.c index d13bdd42..c43297a1 100644 --- a/adventure/crc.c +++ b/adventure/crc.c @@ -1,4 +1,4 @@ -/* $NetBSD: crc.c,v 1.9 2005/07/01 00:03:36 jmc Exp $ */ +/* $NetBSD: crc.c,v 1.10 2009/08/12 04:28:27 dholland Exp $ */ /*- * Copyright (c) 1993 @@ -38,13 +38,13 @@ static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 5/31/93"; static char ORIGINAL_sccsid[] = "@(#)crc.c 5.2 (Berkeley) 4/4/91"; #else -__RCSID("$NetBSD: crc.c,v 1.9 2005/07/01 00:03:36 jmc Exp $"); +__RCSID("$NetBSD: crc.c,v 1.10 2009/08/12 04:28:27 dholland Exp $"); #endif #endif /* not lint */ #include "extern.h" -const unsigned long crctab[] = { +static const unsigned long crctab[] = { 0x7fffffff, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, @@ -106,8 +106,8 @@ const unsigned long crctab[] = { * it. */ -unsigned long crcval; -unsigned int step; +static unsigned long crcval; +static unsigned int step; void crc_start() diff --git a/adventure/extern.h b/adventure/extern.h index b9950b59..178017b9 100644 --- a/adventure/extern.h +++ b/adventure/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.10 2004/01/27 20:30:28 jsm Exp $ */ +/* $NetBSD: extern.h,v 1.11 2009/08/12 04:28:27 dholland Exp $ */ /* * Copyright (c) 1997 Christos Zoulas. All rights reserved. @@ -43,7 +43,6 @@ void die(int); /* init.c */ void init(void); char *decr(int, int, int, int, int); -void linkdata(void); void trapdel(int); void startup(void); @@ -51,19 +50,10 @@ void startup(void); void getin(char **, char **); int yes(int, int, int); int yesm(int, int, int); -int next(void); void rdata(void); -int rnum(void); -void rdesc(int); -void rtrav(void); #ifdef DEBUG void twrite(int); #endif -void rvoc(void); -void rlocs(void); -void rdflt(void); -void rliq(void); -void rhints(void); void rspeak(int); void mspeak(int); struct text; @@ -78,24 +68,17 @@ int restore(const char *); int toting(int); int here(int); int at(int); -int liq2(int); int liq(void); int liqloc(int); -int bitset(int, int); int forced(int); int dark(void); int pct(int); int fdwarf(void); int march(void); -int mback(void); -int specials(void); -int trbridge(void); -void badmove(void); void bug(int) __attribute__((__noreturn__)); void checkhints(void); int trsay(void); int trtake(void); -int dropper(void); int trdrop(void); int tropen(void); int trkill(void); @@ -119,12 +102,9 @@ int vocab(const char *, int, int); #define weq(str1, str2) (!strncmp((str1), (str2), 5)) #define length(str) (strlen((str)) + 1) -void prht(void); - /* wizard.c */ void datime(int *, int *); void poof(void); int Start(void); -int wizard(void); void ciao(void); int ran(int); diff --git a/adventure/hdr.h b/adventure/hdr.h index 43dee3ec..ee6af9f1 100644 --- a/adventure/hdr.h +++ b/adventure/hdr.h @@ -1,4 +1,4 @@ -/* $NetBSD: hdr.h,v 1.11 2005/07/01 00:03:36 jmc Exp $ */ +/* $NetBSD: hdr.h,v 1.12 2009/08/12 04:28:27 dholland Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -56,7 +56,6 @@ #include -extern int datfd; /* message file descriptor */ extern volatile sig_atomic_t delhit; extern int yea; extern char data_file[]; /* Virtual data file */ @@ -141,7 +140,7 @@ extern int keys, lamp, grate, cage, rod, rod2, steps, /* mnemonics */ axe, mirror, dragon, chasm, troll, troll2, bear, messag, vend, batter, nugget, coins, chest, eggs, tridnt, vase, emrald, pyram, pearl, rug, chain, spices, back, look, cave, - null, entrnc, dprssn, enter, stream, pour, say, lock, throw, + null, entrnc, dprssn, /*enter, stream, pour,*/ say, lock, throw, find, invent; extern int chloc, chloc2, dseen[7], dloc[7], /* dwarf stuff */ diff --git a/adventure/init.c b/adventure/init.c index 5269b96c..5a4ca15f 100644 --- a/adventure/init.c +++ b/adventure/init.c @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.17 2007/12/15 19:44:38 perry Exp $ */ +/* $NetBSD: init.c,v 1.18 2009/08/12 04:28:27 dholland Exp $ */ /*- * Copyright (c) 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 6/2/93"; #else -__RCSID("$NetBSD: init.c,v 1.17 2007/12/15 19:44:38 perry Exp $"); +__RCSID("$NetBSD: init.c,v 1.18 2009/08/12 04:28:27 dholland Exp $"); #endif #endif /* not lint */ @@ -55,12 +55,13 @@ __RCSID("$NetBSD: init.c,v 1.17 2007/12/15 19:44:38 perry Exp $"); #include "hdr.h" #include "extern.h" +static void linkdata(void); + int blklin = TRUE; int setbit[16] = {1, 2, 4, 010, 020, 040, 0100, 0200, 0400, 01000, 02000, 04000, 010000, 020000, 040000, 0100000}; -int datfd; /* message file descriptor */ volatile sig_atomic_t delhit; int yea; @@ -111,9 +112,11 @@ int keys, lamp, grate, cage, rod, rod2, steps, /* mnemonics */ axe, mirror, dragon, chasm, troll, troll2, bear, messag, vend, batter, nugget, coins, chest, eggs, tridnt, vase, emrald, pyram, pearl, rug, chain, spices, back, look, cave, - null, entrnc, dprssn, enter, stream, pour, say, lock, throw, + null, entrnc, dprssn, say, lock, throw, find, invent; +static int enter, /*stream,*/ pour; + int chloc, chloc2, dseen[7], dloc[7], /* dwarf stuff */ odloc[7], dflag, daltlc; @@ -148,7 +151,7 @@ decr(int a, int b, int c, int d, int e) return buf; } -void +static void linkdata(void) { /* secondary data manipulation */ int i, j; diff --git a/adventure/io.c b/adventure/io.c index 05984817..7382f5a9 100644 --- a/adventure/io.c +++ b/adventure/io.c @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.20 2006/05/18 18:42:59 mrg Exp $ */ +/* $NetBSD: io.c,v 1.21 2009/08/12 04:28:27 dholland Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: io.c,v 1.20 2006/05/18 18:42:59 mrg Exp $"); +__RCSID("$NetBSD: io.c,v 1.21 2009/08/12 04:28:27 dholland Exp $"); #endif #endif /* not lint */ @@ -52,6 +52,15 @@ __RCSID("$NetBSD: io.c,v 1.20 2006/05/18 18:42:59 mrg Exp $"); #include "hdr.h" #include "extern.h" +static int next(void); +static void rdesc(int); +static void rdflt(void); +static void rhints(void); +static void rliq(void); +static void rlocs(void); +static int rnum(void); +static void rtrav(void); +static void rvoc(void); /* get command from user */ /* no prompt, usually */ @@ -159,15 +168,15 @@ yesm(int x, int y, int z) } /* FILE *inbuf,*outbuf; */ -char *inptr; /* Pointer into virtual disk */ +static char *inptr; /* Pointer into virtual disk */ -int outsw = 0; /* putting stuff to data file? */ +static int outsw = 0; /* putting stuff to data file? */ -const char iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l"; -const char *tape = iotape; /* pointer to encryption tape */ +static const char iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l"; +static const char *tape = iotape; /* pointer to encryption tape */ /* next virtual char, bump adr */ -int +static int next(void) { int ch; @@ -182,7 +191,7 @@ next(void) return (ch); } -char breakch; /* tell which char ended rnum */ +static char breakch; /* tell which char ended rnum */ /* "read" data from virtual file */ void @@ -259,10 +268,10 @@ rdata(void) } } -char nbf[12]; +static char nbf[12]; /* read initial location num */ -int +static int rnum(void) { char *s; @@ -277,10 +286,10 @@ rnum(void) return (atoi(nbf)); /* convert it to integer */ } -char *seekhere; +static char *seekhere; /* read description-format msgs */ -void +static void rdesc(int sect) { int locc; @@ -343,7 +352,7 @@ rdesc(int sect) } /* read travel table */ -void +static void rtrav(void) { int locc; @@ -424,7 +433,7 @@ twrite(int loq) #endif /* DEBUG */ /* read the vocabulary */ -void +static void rvoc(void) { char *s; @@ -449,7 +458,7 @@ rvoc(void) } /* initial object locations */ -void +static void rlocs(void) { for (;;) { @@ -464,7 +473,7 @@ rlocs(void) } /* default verb messages */ -void +static void rdflt(void) { for (;;) { @@ -475,7 +484,7 @@ rdflt(void) } /* liquid assets &c: cond bits */ -void +static void rliq(void) { int bitnum; @@ -493,7 +502,7 @@ rliq(void) } } -void +static void rhints(void) { int hintnum, i; diff --git a/adventure/save.c b/adventure/save.c index 8e25c54b..4557ab35 100644 --- a/adventure/save.c +++ b/adventure/save.c @@ -1,4 +1,4 @@ -/* $NetBSD: save.c,v 1.9 2005/07/01 00:03:36 jmc Exp $ */ +/* $NetBSD: save.c,v 1.10 2009/08/12 04:28:27 dholland Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: save.c,v 1.9 2005/07/01 00:03:36 jmc Exp $"); +__RCSID("$NetBSD: save.c,v 1.10 2009/08/12 04:28:27 dholland Exp $"); #endif #endif /* not lint */ @@ -54,7 +54,7 @@ struct savestruct { int width; }; -struct savestruct save_array[] = +static const struct savestruct save_array[] = { {&abbnum, sizeof(abbnum)}, {&attack, sizeof(attack)}, @@ -126,7 +126,7 @@ int save(const char *outfile) { FILE *out; - struct savestruct *p; + const struct savestruct *p; char *s; long sum; int i; @@ -159,7 +159,7 @@ int restore(const char *infile) { FILE *in; - struct savestruct *p; + const struct savestruct *p; char *s; long sum, cksum = 0; int i; diff --git a/adventure/subr.c b/adventure/subr.c index 4ce56561..bd4dea78 100644 --- a/adventure/subr.c +++ b/adventure/subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr.c,v 1.11 2005/07/01 00:03:36 jmc Exp $ */ +/* $NetBSD: subr.c,v 1.12 2009/08/12 04:28:27 dholland Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: subr.c,v 1.11 2005/07/01 00:03:36 jmc Exp $"); +__RCSID("$NetBSD: subr.c,v 1.12 2009/08/12 04:28:27 dholland Exp $"); #endif #endif /* not lint */ @@ -50,6 +50,14 @@ __RCSID("$NetBSD: subr.c,v 1.11 2005/07/01 00:03:36 jmc Exp $"); #include "hdr.h" #include "extern.h" +static void badmove(void); +static int bitset(int, int); +static int dropper(void); +static int liq2(int); +static int mback(void); +static int specials(void); +static int trbridge(void); + /* Statement functions */ int toting(int objj) @@ -78,7 +86,7 @@ at(int objj) return (FALSE); } -int +static int liq2(int pbotl) { return ((1 - pbotl) * water + (pbotl / 2) * (water + oil)); @@ -107,7 +115,7 @@ liqloc(int locc) return (liq2(j * l + 1)); } -int +static int bitset(int l, int n) { if (cond[l] & setbit[n]) @@ -373,7 +381,7 @@ l12: /* alternative to probability move */ } /* 20 */ -int +static int mback(void) { struct travlist *tk2, *j; @@ -411,7 +419,7 @@ mback(void) } /* 30000 */ -int +static int specials(void) { switch (newloc -= 300) { @@ -433,7 +441,7 @@ specials(void) } /* 30300 */ -int +static int trbridge(void) { if (prop[troll] == 1) { @@ -465,7 +473,7 @@ trbridge(void) } /* 20 */ -void +static void badmove(void) { spk = 12; @@ -616,7 +624,7 @@ l9014: if ((obj == bird || obj == cage) && prop[bird] != 0) } /* 9021 */ -int +static int dropper(void) { k = liq(); diff --git a/adventure/vocab.c b/adventure/vocab.c index 6d361e21..01beeeeb 100644 --- a/adventure/vocab.c +++ b/adventure/vocab.c @@ -1,4 +1,4 @@ -/* $NetBSD: vocab.c,v 1.13 2006/03/18 23:35:51 christos Exp $ */ +/* $NetBSD: vocab.c,v 1.14 2009/08/12 04:28:27 dholland Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: vocab.c,v 1.13 2006/03/18 23:35:51 christos Exp $"); +__RCSID("$NetBSD: vocab.c,v 1.14 2009/08/12 04:28:27 dholland Exp $"); #endif #endif /* not lint */ @@ -189,8 +189,8 @@ exitloop2: /* hashed entry does not match */ } } -/* print hash table */ -void +/* print hash table (for debugging) */ +static __unused void prht(void) { int i, j, l; diff --git a/adventure/wizard.c b/adventure/wizard.c index a63aa069..c0819ffa 100644 --- a/adventure/wizard.c +++ b/adventure/wizard.c @@ -1,4 +1,4 @@ -/* $NetBSD: wizard.c,v 1.12 2005/07/01 00:03:36 jmc Exp $ */ +/* $NetBSD: wizard.c,v 1.13 2009/08/12 04:28:27 dholland Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)wizard.c 8.1 (Berkeley) 6/2/93"; #else -__RCSID("$NetBSD: wizard.c,v 1.12 2005/07/01 00:03:36 jmc Exp $"); +__RCSID("$NetBSD: wizard.c,v 1.13 2009/08/12 04:28:27 dholland Exp $"); #endif #endif /* not lint */ @@ -52,6 +52,8 @@ __RCSID("$NetBSD: wizard.c,v 1.12 2005/07/01 00:03:36 jmc Exp $"); #include "hdr.h" #include "extern.h" +static int wizard(void); + void datime(int *d, int *t) { @@ -71,7 +73,7 @@ datime(int *d, int *t) } /* pretty painless */ -char magic[6]; +static char magic[6]; void poof(void) @@ -109,7 +111,7 @@ Start(void) } /* not as complex as advent/10 (for now) */ -int +static int wizard(void) { char *word, *x; diff --git a/arithmetic/arithmetic.c b/arithmetic/arithmetic.c index 1488bf65..db43730c 100644 --- a/arithmetic/arithmetic.c +++ b/arithmetic/arithmetic.c @@ -1,4 +1,4 @@ -/* $NetBSD: arithmetic.c,v 1.23 2008/07/20 01:03:20 lukem Exp $ */ +/* $NetBSD: arithmetic.c,v 1.24 2009/08/12 04:30:21 dholland Exp $ */ /* * Copyright (c) 1989, 1993 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\ #if 0 static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: arithmetic.c,v 1.23 2008/07/20 01:03:20 lukem Exp $"); +__RCSID("$NetBSD: arithmetic.c,v 1.24 2009/08/12 04:30:21 dholland Exp $"); #endif #endif /* not lint */ @@ -84,22 +84,21 @@ __RCSID("$NetBSD: arithmetic.c,v 1.23 2008/07/20 01:03:20 lukem Exp $"); #include #include -int getrandom(int, int, int); -void intr(int) __dead; -int main(int, char *[]); -int opnum(int); -void penalise(int, int, int); -int problem(void); -void showstats(int); -void usage(void) __dead; - -const char keylist[] = "+-x/"; -const char defaultkeys[] = "+-"; -const char *keys = defaultkeys; -int nkeys = sizeof(defaultkeys) - 1; -int rangemax = 10; -int nright, nwrong; -time_t qtime; +static int getrandom(int, int, int); +static void intr(int) __dead; +static int opnum(int); +static void penalise(int, int, int); +static int problem(void); +static void showstats(int); +static void usage(void) __dead; + +static const char keylist[] = "+-x/"; +static const char defaultkeys[] = "+-"; +static const char *keys = defaultkeys; +static int nkeys = sizeof(defaultkeys) - 1; +static int rangemax = 10; +static int nright, nwrong; +static time_t qtime; #define NQUESTS 20 /* @@ -110,9 +109,7 @@ time_t qtime; * so far are printed. */ int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { int ch, cnt; @@ -157,7 +154,7 @@ main(argc, argv) } /* Handle interrupt character. Print score and exit. */ -void +static void intr(dummy) int dummy __unused; { @@ -166,7 +163,7 @@ intr(dummy) } /* Print score. Original `arithmetic' had a delay after printing it. */ -void +static void showstats(bool_sigint) int bool_sigint; { @@ -192,7 +189,7 @@ showstats(bool_sigint) * answer causes the numbers in the problem to be penalised, so that they are * more likely to appear in subsequent problems. */ -int +static int problem() { char *p; @@ -292,8 +289,8 @@ retry: * penalties themselves. */ -int penalty[sizeof(keylist) - 1][2]; -struct penalty { +static int penalty[sizeof(keylist) - 1][2]; +static struct penalty { int value, penalty; /* Penalised value and its penalty. */ struct penalty *next; } *penlist[sizeof(keylist) - 1][2]; @@ -305,7 +302,7 @@ struct penalty { * operand number `operand' (0 or 1). If we run out of memory, we just * forget about the penalty (how likely is this, anyway?). */ -void +static void penalise(value, op, operand) int value, op, operand; { @@ -326,7 +323,7 @@ penalise(value, op, operand) * as a value, or represents a position in the penalty list. If the latter, * we find the corresponding value and return that, decreasing its penalty. */ -int +static int getrandom(maxval, op, operand) int maxval, op, operand; { @@ -371,7 +368,7 @@ getrandom(maxval, op, operand) } /* Return an index for the character op, which is one of [+-x/]. */ -int +static int opnum(op) int op; { @@ -384,7 +381,7 @@ opnum(op) } /* Print usage message and quit. */ -void +static void usage() { (void)fprintf(stderr, "Usage: %s [-o +-x/] [-r range]\n", -- cgit v1.2.3-56-ge451