From 0ba05dd5a679e7723ea4b9f1426175b1651926cf Mon Sep 17 00:00:00 2001 From: jsm Date: Thu, 21 Sep 2000 17:44:34 +0000 Subject: Various improvements to parsing in battlestar, mostly from OpenBSD. Define a constant WORDLEN. Always use this constant and NWORD where appropriate. Use NWORD - 1 in battlestar.c to avoid off-by-one error. Increment wordnumber after the INVEN verb to allow it to be followed by a comma and other actions. Avoid overflowing elements of the words array if input words are too long. Parse "," as AND except when followed by a verb, to allow such constructions as "take foo, bar, and baz". Trim AND AND which may occur from the ", and" in such a list. Avoid crashes from EVERYTHING in the wrong place by moving it to the start of OBJECT AND EVERYTHING and NOUNS AND EVERYTHING sequences, and trimming EVERYTHING AND EVERYTHING. --- battlestar/cypher.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'battlestar/cypher.c') diff --git a/battlestar/cypher.c b/battlestar/cypher.c index ea39fd39..0f6c92cc 100644 --- a/battlestar/cypher.c +++ b/battlestar/cypher.c @@ -1,4 +1,4 @@ -/* $NetBSD: cypher.c,v 1.14 2000/09/17 23:03:43 jsm Exp $ */ +/* $NetBSD: cypher.c,v 1.15 2000/09/21 17:44:34 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: cypher.c,v 1.14 2000/09/17 23:03:43 jsm Exp $"); +__RCSID("$NetBSD: cypher.c,v 1.15 2000/09/21 17:44:34 jsm Exp $"); #endif #endif /* not lint */ @@ -287,6 +287,7 @@ cypher() printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT, (WEIGHT == 1 ? "." : "s.")); } else puts("\nYou are in perfect health."); + wordnumber++; break; case USE: -- cgit v1.2.3