summaryrefslogtreecommitdiff
path: root/games/battlestar/parse.c
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>2000-09-23 03:02:39 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>2000-09-23 03:02:39 +0000
commitf6309a870e25a5f3bdffac70b081140ced9881c8 (patch)
treef32005b4b51cc4f5cda9705ab238dd5feb29cff4 /games/battlestar/parse.c
parent72ac17839d819818408469ecafad2cae36fbb3e8 (diff)
drop adjectives in parse(), since they're never used.
tidy a little. fix love() a bit. From conversations with jsm@netbsd.org: Add objflags[] to deal with plurals and a/an usage. Commas don't mean AND if followed by a verb. Check for object presence before trying to lift or eat it.
Diffstat (limited to 'games/battlestar/parse.c')
-rw-r--r--games/battlestar/parse.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/games/battlestar/parse.c b/games/battlestar/parse.c
index 9a96dac673a..37265f2b1d5 100644
--- a/games/battlestar/parse.c
+++ b/games/battlestar/parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.c,v 1.7 2000/09/17 21:28:33 pjanzen Exp $ */
+/* $OpenBSD: parse.c,v 1.8 2000/09/23 03:02:38 pjanzen Exp $ */
/* $NetBSD: parse.c,v 1.3 1995/03/21 15:07:48 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: parse.c,v 1.7 2000/09/17 21:28:33 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: parse.c,v 1.8 2000/09/23 03:02:38 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -110,13 +110,33 @@ 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.
+ */
+ for (n = 1; n < wordcount; n++)
+ if (wordtype[n] == ADJS) {
+ int i;
+ for (i = n + 1; i < wordcount; i++) {
+ wordtype[i - 1] = wordtype[i];
+ wordvalue[i - 1] = wordvalue[i];
+ strlcpy(words[i - 1], words[i], WORDLEN);
+ }
+ wordcount--;
+ }
/* Trim "AND AND" which can happen naturally at the end of a
- * comma-delimited list
+ * comma-delimited list.
*/
for (n = 1; n < wordcount; n++)
if (wordvalue[n - 1] == AND && wordvalue[n] == AND) {
int i;
- for (i = n + 1; i < wordcount; i++) {
+ for (i = n + 1; i <= wordcount; i++) {
wordtype[i - 1] = wordtype[i];
wordvalue[i - 1] = wordvalue[i];
strlcpy(words[i - 1], words[i], WORDLEN);