diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 2000-09-24 21:55:27 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 2000-09-24 21:55:27 +0000 |
commit | 654557dffeb038709ab092a1bb4d7cd2915b63fc (patch) | |
tree | 5f082621e7dec25217cfc7ea28a3e29228e9eeef | |
parent | 4ff27aafec200e4e31826c8b962d50681ce9f25e (diff) |
numerous changes from jsm@netbsd.org:
static where appropriate, add a few comments, format a bit better, and
deal with WEIGHT/CUMBER being zero (and not less).
-rw-r--r-- | games/battlestar/com1.c | 14 | ||||
-rw-r--r-- | games/battlestar/com2.c | 7 | ||||
-rw-r--r-- | games/battlestar/com3.c | 7 | ||||
-rw-r--r-- | games/battlestar/com5.c | 10 | ||||
-rw-r--r-- | games/battlestar/com6.c | 7 | ||||
-rw-r--r-- | games/battlestar/cypher.c | 18 | ||||
-rw-r--r-- | games/battlestar/extern.h | 21 | ||||
-rw-r--r-- | games/battlestar/fly.c | 39 | ||||
-rw-r--r-- | games/battlestar/getcom.c | 6 | ||||
-rw-r--r-- | games/battlestar/globals.c | 36 | ||||
-rw-r--r-- | games/battlestar/init.c | 29 | ||||
-rw-r--r-- | games/battlestar/parse.c | 34 |
12 files changed, 127 insertions, 101 deletions
diff --git a/games/battlestar/com1.c b/games/battlestar/com1.c index dbf9b76b2cc..1262e4c55bb 100644 --- a/games/battlestar/com1.c +++ b/games/battlestar/com1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com1.c,v 1.9 2000/07/24 01:02:43 pjanzen Exp $ */ +/* $OpenBSD: com1.c,v 1.10 2000/09/24 21:55:22 pjanzen Exp $ */ /* $NetBSD: com1.c,v 1.3 1995/03/21 15:06:51 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)com1.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: com1.c,v 1.9 2000/07/24 01:02:43 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: com1.c,v 1.10 2000/09/24 21:55:22 pjanzen Exp $"; #endif #endif /* not lint */ @@ -212,11 +212,17 @@ news() WEIGHT = 0; } if (injuries[ARM] == 2) { - CUMBER -= 5; + if (CUMBER > 5) + CUMBER -= 5; + else + CUMBER = 0; injuries[ARM]++; } if (injuries[RIBS] == 2) { - CUMBER -= 2; + if (CUMBER > 2) + CUMBER -= 2; + else + CUMBER = 0; injuries[RIBS]++; } if (injuries[SPINE] == 2) { diff --git a/games/battlestar/com2.c b/games/battlestar/com2.c index 06ff869c542..dc43b94008d 100644 --- a/games/battlestar/com2.c +++ b/games/battlestar/com2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com2.c,v 1.10 2000/09/23 03:02:35 pjanzen Exp $ */ +/* $OpenBSD: com2.c,v 1.11 2000/09/24 21:55:22 pjanzen Exp $ */ /* $NetBSD: com2.c,v 1.3 1995/03/21 15:06:55 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)com2.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: com2.c,v 1.10 2000/09/23 03:02:35 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: com2.c,v 1.11 2000/09/24 21:55:22 pjanzen Exp $"; #endif #endif /* not lint */ @@ -279,7 +279,8 @@ murder() void ravage() { - while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount); + while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount) + ; if (wordtype[wordnumber] == NOUNS && (TestBit(location[position].objects, wordvalue[wordnumber]) || (wordvalue[wordnumber] == NORMGOD && TestBit(location[position].objects, BATHGOD)))) { ourtime++; diff --git a/games/battlestar/com3.c b/games/battlestar/com3.c index 1f733ccd03c..a0390686826 100644 --- a/games/battlestar/com3.c +++ b/games/battlestar/com3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com3.c,v 1.8 2000/09/23 03:02:35 pjanzen Exp $ */ +/* $OpenBSD: com3.c,v 1.9 2000/09/24 21:55:23 pjanzen Exp $ */ /* $NetBSD: com3.c,v 1.3 1995/03/21 15:07:00 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)com3.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: com3.c,v 1.8 2000/09/23 03:02:35 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: com3.c,v 1.9 2000/09/24 21:55:23 pjanzen Exp $"; #endif #endif /* not lint */ @@ -114,7 +114,8 @@ bury() int value; if (TestBit(inven, SHOVEL)) { - while (wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber <= wordcount); + while (wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber <= wordcount) + ; value = wordvalue[wordnumber]; if (wordtype[wordnumber] == NOUNS && (TestBit(location[position].objects, value) || value == BODY)) switch (value) { diff --git a/games/battlestar/com5.c b/games/battlestar/com5.c index 906fae36242..09d758e9b0c 100644 --- a/games/battlestar/com5.c +++ b/games/battlestar/com5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com5.c,v 1.7 2000/09/23 03:02:36 pjanzen Exp $ */ +/* $OpenBSD: com5.c,v 1.8 2000/09/24 21:55:23 pjanzen Exp $ */ /* $NetBSD: com5.c,v 1.3 1995/03/21 15:07:07 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)com5.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: com5.c,v 1.7 2000/09/23 03:02:36 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: com5.c,v 1.8 2000/09/24 21:55:23 pjanzen Exp $"; #endif #endif /* not lint */ @@ -275,7 +275,8 @@ give() last1 = last2 = wordcount + 2; firstnumber = wordnumber; - while (wordtype[++wordnumber] != OBJECT && wordvalue[wordnumber] != AMULET && wordvalue[wordnumber] != MEDALION && wordvalue[wordnumber] != TALISMAN && wordnumber <= wordcount); + while (wordtype[++wordnumber] != OBJECT && wordvalue[wordnumber] != AMULET && wordvalue[wordnumber] != MEDALION && wordvalue[wordnumber] != TALISMAN && wordnumber <= wordcount) + ; if (wordnumber <= wordcount) { obj = wordvalue[wordnumber]; if (obj == EVERYTHING) @@ -283,7 +284,8 @@ give() last1 = wordnumber; } wordnumber = firstnumber; - while ((wordtype[++wordnumber] != NOUNS || wordvalue[wordnumber] == obj) && wordnumber <= wordcount); + while ((wordtype[++wordnumber] != NOUNS || wordvalue[wordnumber] == obj) && wordnumber <= wordcount) + ; if (wordtype[wordnumber] == NOUNS) { person = wordvalue[wordnumber]; last2 = wordnumber; diff --git a/games/battlestar/com6.c b/games/battlestar/com6.c index 6d63fc5e000..007fc78192b 100644 --- a/games/battlestar/com6.c +++ b/games/battlestar/com6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com6.c,v 1.14 2000/09/23 03:02:36 pjanzen Exp $ */ +/* $OpenBSD: com6.c,v 1.15 2000/09/24 21:55:23 pjanzen Exp $ */ /* $NetBSD: com6.c,v 1.5 1995/04/27 21:30:23 mycroft Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)com6.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: com6.c,v 1.14 2000/09/23 03:02:36 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: com6.c,v 1.15 2000/09/24 21:55:23 pjanzen Exp $"; #endif #endif /* not lint */ @@ -199,7 +199,8 @@ ride() puts("You climb onto the stallion and kick it in the guts. The stupid steed launches"); puts("forward through bush and fern. You are thrown and the horse gallops off."); ClearBit(location[position].objects, HORSE); - while (!(position = rnd(NUMOFROOMS + 1)) || !OUTSIDE || !beenthere[position] || location[position].flyhere); + while (!(position = rnd(NUMOFROOMS + 1)) || !OUTSIDE || !beenthere[position] || location[position].flyhere) + ; SetBit(location[position].objects, HORSE); if (location[position].north) position = location[position].north; diff --git a/games/battlestar/cypher.c b/games/battlestar/cypher.c index a8ed667c5d9..e4addc5ebcc 100644 --- a/games/battlestar/cypher.c +++ b/games/battlestar/cypher.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cypher.c,v 1.10 2000/09/23 03:02:36 pjanzen Exp $ */ +/* $OpenBSD: cypher.c,v 1.11 2000/09/24 21:55:23 pjanzen Exp $ */ /* $NetBSD: cypher.c,v 1.3 1995/03/21 15:07:15 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: cypher.c,v 1.10 2000/09/23 03:02:36 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: cypher.c,v 1.11 2000/09/24 21:55:23 pjanzen Exp $"; #endif #endif /* not lint */ @@ -299,8 +299,18 @@ cypher() for (n = 0; n < NUMOFOBJECTS; n++) if (TestBit(inven, n)) printf("\t%s\n", objsht[n]); - printf("\n= %d kilogram%s (%d%%)\n", carrying, (carrying == 1 ? "." : "s."), (WEIGHT ? carrying * 100 / WEIGHT : -1)); - printf("Your arms are %d%% full.\n", encumber * 100 / CUMBER); + printf("\n= %d kilogram%s ", carrying, + (carrying == 1 ? "." : "s.")); + if (WEIGHT) + printf("(%d%%)\n", carrying * 100 / WEIGHT); + else + printf("(can't lift any weight%s)\n", + (carrying ? " or move with what you have" : "")); + if (CUMBER) + printf("Your arms are %d%% full.\n", + encumber * 100 / CUMBER); + else + printf("You can't pick anything up.\n"); } else puts("You aren't carrying anything."); diff --git a/games/battlestar/extern.h b/games/battlestar/extern.h index 1e911bfa111..15f982ea99d 100644 --- a/games/battlestar/extern.h +++ b/games/battlestar/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.9 2000/09/23 03:02:36 pjanzen Exp $ */ +/* $OpenBSD: extern.h,v 1.10 2000/09/24 21:55:24 pjanzen Exp $ */ /* $NetBSD: extern.h,v 1.5 1995/04/24 12:22:18 cgd Exp $ */ /* @@ -305,17 +305,13 @@ extern char beenthere[NUMOFROOMS+1]; extern char injuries[NUMOFINJURIES]; extern int verbose; -extern char username[LOGIN_NAME_MAX + 1]; +extern const char *username; struct wlist { const char *string; int value, article; struct wlist *next; }; -#define HASHSIZE 256 -#define HASHMUL 81 -#define HASHMASK (HASHSIZE - 1) -extern struct wlist *hashtab[HASHSIZE]; extern struct wlist wlist[]; struct objs { @@ -325,10 +321,8 @@ struct objs { extern const struct objs dayobjs[]; extern const struct objs nightobjs[]; -void blast __P((void)); void bury __P((void)); int card __P((const char *, int)); -int checkout __P((const char *)); void chime __P((void)); void convert __P((int)); void crash __P((void)); @@ -341,30 +335,23 @@ void drink __P((void)); int drive __P((void)); int drop __P((const char *)); int eat __P((void)); -void endfly __P((void)); int fight __P((int, int)); int follow __P((void)); char *getcom __P((char *, int, const char *, const char *)); -void getutmp __P((char *)); char *getword __P((char *, char *, int)); int give __P((void)); -int hash __P((const char *)); void initialize __P((const char *)); -void install __P((struct wlist *)); int jump __P((void)); void kiss __P((void)); int land __P((void)); int launch __P((void)); void light __P((void)); void live __P((void)); -struct wlist *lookup __P((const char *)); void love __P((void)); -void moveenemy __P((int)); int moveplayer __P((int, int)); void murder __P((void)); void news __P((void)); void newway __P((int)); -void notarget __P((void)); void open_score_file __P((void)); void parse __P((void)); void post __P((char)); @@ -377,12 +364,9 @@ void restore __P((const char *)); int ride __P((void)); void save __P((const char *)); char *save_file_name __P((const char *, size_t)); -void screen __P((void)); int shoot __P((void)); -void succumb __P((int)); int take __P((unsigned int[])); int takeoff __P((void)); -void target __P((void)); int throw __P((const char *)); const char *truedirec __P((int, char)); int ucard __P((const unsigned int *)); @@ -390,7 +374,6 @@ int use __P((void)); int visual __P((void)); int wearit __P((void)); void whichway __P((struct room)); -int wizard __P((const char *)); void wordinit __P((void)); void writedes __P((void)); int zzz __P((void)); diff --git a/games/battlestar/fly.c b/games/battlestar/fly.c index 1454dc416c0..e5053748717 100644 --- a/games/battlestar/fly.c +++ b/games/battlestar/fly.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fly.c,v 1.7 1999/09/25 20:30:45 pjanzen Exp $ */ +/* $OpenBSD: fly.c,v 1.8 2000/09/24 21:55:25 pjanzen Exp $ */ /* $NetBSD: fly.c,v 1.3 1995/03/21 15:07:28 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)fly.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: fly.c,v 1.7 1999/09/25 20:30:45 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: fly.c,v 1.8 2000/09/24 21:55:25 pjanzen Exp $"; #endif #endif /* not lint */ @@ -46,19 +46,26 @@ static char rcsid[] = "$OpenBSD: fly.c,v 1.7 1999/09/25 20:30:45 pjanzen Exp $"; #undef UP #include <curses.h> -#define abs(a) ((a) < 0 ? -(a) : (a)) #define MIDR (LINES/2 - 1) #define MIDC (COLS/2 - 1) -int row, column; -int dr = 0, dc = 0; -char destroyed; int ourclock = 120; /* time for all the flights in the game */ -char cross = 0; -sig_t oldsig; - -void +static int row, column; +static int dr = 0, dc = 0; +static char destroyed; +static char cross = 0; +static sig_t oldsig; + +static void blast __P((void)); +static void endfly __P((void)); +static void moveenemy __P((int)); +static void notarget __P((void)); +static void screen __P((void)); +static void succumb __P((int)); +static void target __P((void)); + +static void succumb(sigraised) int sigraised; { @@ -179,7 +186,7 @@ visual() } } -void +static void screen() { int r, c, n; @@ -196,7 +203,7 @@ screen() refresh(); } -void +static void target() { int n; @@ -209,7 +216,7 @@ target() } } -void +static void notarget() { int n; @@ -222,7 +229,7 @@ notarget() } } -void +static void blast() { int n; @@ -244,7 +251,7 @@ blast() alarm(1); } -void +static void moveenemy(sigraised) int sigraised; { @@ -284,7 +291,7 @@ moveenemy(sigraised) alarm(1); } -void +static void endfly() { alarm(0); diff --git a/games/battlestar/getcom.c b/games/battlestar/getcom.c index 113b3906442..9da57cbaaf0 100644 --- a/games/battlestar/getcom.c +++ b/games/battlestar/getcom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getcom.c,v 1.8 2000/09/23 02:58:40 pjanzen Exp $ */ +/* $OpenBSD: getcom.c,v 1.9 2000/09/24 21:55:25 pjanzen Exp $ */ /* $NetBSD: getcom.c,v 1.3 1995/03/21 15:07:30 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)getcom.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: getcom.c,v 1.8 2000/09/23 02:58:40 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: getcom.c,v 1.9 2000/09/24 21:55:25 pjanzen Exp $"; #endif #endif /* not lint */ @@ -68,7 +68,7 @@ getcom(buf, size, prompt, error) /* If we didn't get to the end of the line, don't read it in next time */ if (buf[strlen(buf) - 1] != '\n') { int i; - while ((i = fgetc(stdin)) != '\n' && i != EOF) + while ((i = getchar()) != '\n' && i != EOF) ; } return (buf); diff --git a/games/battlestar/globals.c b/games/battlestar/globals.c index 42dca2bba0c..2d88ae6707b 100644 --- a/games/battlestar/globals.c +++ b/games/battlestar/globals.c @@ -1,4 +1,4 @@ -/* $OpenBSD: globals.c,v 1.8 2000/09/23 03:02:36 pjanzen Exp $ */ +/* $OpenBSD: globals.c,v 1.9 2000/09/24 21:55:25 pjanzen Exp $ */ /* $NetBSD: globals.c,v 1.3 1995/03/21 15:07:32 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: globals.c,v 1.8 2000/09/23 03:02:36 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: globals.c,v 1.9 2000/09/24 21:55:25 pjanzen Exp $"; #endif #endif /* not lint */ @@ -118,7 +118,7 @@ const char *const objdes[NUMOFOBJECTS] = { const char *const objsht[NUMOFOBJECTS] = { "knife", "fine sword", - NULL, + NULL, /* can land from here */ "Woodsman", "two-handed sword", "meat cleaver", @@ -130,7 +130,7 @@ const char *const objsht[NUMOFOBJECTS] = { "viper", "lantern", "shoes", - NULL, + NULL, /* cylon */ "pajamas", "robe", "amulet", @@ -139,8 +139,8 @@ const char *const objsht[NUMOFOBJECTS] = { "woodsman's body", "wooden mallet", "laser", - NULL, - NULL, + NULL, /* bathing goddess */ + NULL, /* goddess */ "grenade", "chain", "rope", @@ -149,12 +149,12 @@ const char *const objsht[NUMOFOBJECTS] = { "shovel", "halberd", "compass", - NULL, + NULL, /* crash debris */ "Elf", - NULL, + NULL, /* footsteps */ "coins", "match book", - NULL, + NULL, /* man and dwarf */ "papayas", "pineapple", "kiwi", @@ -163,18 +163,18 @@ const char *const objsht[NUMOFOBJECTS] = { "ring", "potion", "bracelet", - NULL, - NULL, + NULL, /* swarthy woman */ + NULL, /* swarthy woman (with message) */ "Dark Lord", - NULL, - NULL, - NULL, - NULL, + NULL, /* old-timer */ + NULL, /* asteroid field */ + NULL, /* nearby planet */ + NULL, /* charred ground */ "warhead", "goddess's body", "old-timer's body", "girl's body", - NULL, + NULL, /* native girl */ "stallion", "car", "pot of jewels", @@ -269,6 +269,4 @@ char beenthere[NUMOFROOMS + 1]; char injuries[NUMOFINJURIES]; int verbose = 0; -char username[LOGIN_NAME_MAX + 1]; - -struct wlist *hashtab[HASHSIZE]; +const char *username; diff --git a/games/battlestar/init.c b/games/battlestar/init.c index ce87433e9fa..e100fcbcae1 100644 --- a/games/battlestar/init.c +++ b/games/battlestar/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.6 1999/09/25 20:30:46 pjanzen Exp $ */ +/* $OpenBSD: init.c,v 1.7 2000/09/24 21:55:25 pjanzen Exp $ */ /* $NetBSD: init.c,v 1.4 1995/03/21 15:07:35 cgd Exp $ */ /* @@ -38,12 +38,16 @@ #if 0 static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 4/30/95"; #else -static char rcsid[] = "$OpenBSD: init.c,v 1.6 1999/09/25 20:30:46 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: init.c,v 1.7 2000/09/24 21:55:25 pjanzen Exp $"; #endif #endif /* not lint */ #include "extern.h" +static int checkout __P((const char *)); +static const char *getutmp __P((void)); +static int wizard __P((const char *)); + void initialize(filename) const char *filename; @@ -56,7 +60,7 @@ initialize(filename) puts("Admiral D.W. Riggle\n"); location = dayfile; srandom(getpid()); - getutmp(username); + username = getutmp(); wordinit(); if (filename == NULL) { direction = NORTH; @@ -77,17 +81,20 @@ initialize(filename) signal(SIGINT, die); } -void -getutmp(username) - char *username; +static const char * +getutmp() { struct passwd *ptr; ptr = getpwuid(getuid()); - strcpy(username, ptr ? ptr->pw_name : ""); + if (ptr == NULL) + return(""); + else + return(strdup(ptr->pw_name)); } -const char *const list[] = { /* hereditary wizards */ +/* Hereditary wizards. A configuration file might make more sense. */ +static const char *const list[] = { "riggle", "chris", "edward", @@ -98,14 +105,14 @@ const char *const list[] = { /* hereditary wizards */ 0 }; -const char *const badguys[] = { +static const char *const badguys[] = { "wnj", "root", "ted", 0 }; -int +static int wizard(username) const char *username; { @@ -116,7 +123,7 @@ wizard(username) return flag; } -int +static int checkout(username) const char *username; { diff --git a/games/battlestar/parse.c b/games/battlestar/parse.c index 37265f2b1d5..67272f6562e 100644 --- a/games/battlestar/parse.c +++ b/games/battlestar/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.8 2000/09/23 03:02:38 pjanzen Exp $ */ +/* $OpenBSD: parse.c,v 1.9 2000/09/24 21:55:26 pjanzen Exp $ */ /* $NetBSD: parse.c,v 1.3 1995/03/21 15:07:48 cgd Exp $ */ /* @@ -38,12 +38,22 @@ #if 0 static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: parse.c,v 1.8 2000/09/23 03:02:38 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: parse.c,v 1.9 2000/09/24 21:55:26 pjanzen Exp $"; #endif #endif /* not lint */ #include "extern.h" +#define HASHSIZE 256 +#define HASHMUL 81 +#define HASHMASK (HASHSIZE - 1) + +static int hash __P((const char *)); +static void install __P((struct wlist *)); +static struct wlist *lookup __P((const char *)); + +struct wlist *hashtab[HASHSIZE]; + void wordinit() { @@ -53,7 +63,7 @@ wordinit() install(w); } -int +static int hash(s) const char *s; { @@ -67,7 +77,7 @@ hash(s) return hashval; } -struct wlist * +static struct wlist * lookup(s) const char *s; { @@ -79,7 +89,7 @@ lookup(s) return NULL; } -void +static void install(wp) struct wlist *wp; { @@ -110,13 +120,6 @@ parse() wordtype[n] = wp->article; } } - /* Don't let a comma mean AND if followed by a verb. */ - for (n = 0; n < wordcount; n++) - if (wordvalue[n] == AND && words[n][0] == ',' - && wordtype[n + 1] == VERB) { - wordvalue[n] = -1; - wordtype[n] = -1; - } /* We never use adjectives, so yank them all; disambiguation * code would need to go before this. */ @@ -130,6 +133,13 @@ parse() } wordcount--; } + /* Don't let a comma mean AND if followed by a verb. */ + for (n = 0; n < wordcount; n++) + if (wordvalue[n] == AND && words[n][0] == ',' + && wordtype[n + 1] == VERB) { + wordvalue[n] = -1; + wordtype[n] = -1; + } /* Trim "AND AND" which can happen naturally at the end of a * comma-delimited list. */ |