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/globals.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'battlestar/globals.c') diff --git a/battlestar/globals.c b/battlestar/globals.c index d285e527..5805cf96 100644 --- a/battlestar/globals.c +++ b/battlestar/globals.c @@ -1,4 +1,4 @@ -/* $NetBSD: globals.c,v 1.12 2000/09/17 23:03:43 jsm Exp $ */ +/* $NetBSD: globals.c,v 1.13 2000/09/21 17:44:34 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: globals.c,v 1.12 2000/09/17 23:03:43 jsm Exp $"); +__RCSID("$NetBSD: globals.c,v 1.13 2000/09/21 17:44:34 jsm Exp $"); #endif #endif /* not lint */ @@ -228,7 +228,7 @@ int followfight = -1; struct room *location; /* current input line */ -char words[NWORD][15]; +char words[NWORD][WORDLEN]; int wordvalue[NWORD]; int wordtype[NWORD]; int wordcount, wordnumber; -- cgit v1.2.3