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/extern.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'battlestar/extern.h') diff --git a/battlestar/extern.h b/battlestar/extern.h index efd6366c..81ffa9c3 100644 --- a/battlestar/extern.h +++ b/battlestar/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.20 2000/09/17 23:03:43 jsm Exp $ */ +/* $NetBSD: extern.h,v 1.21 2000/09/21 17:44:34 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -253,8 +253,9 @@ extern const int objwt[NUMOFOBJECTS]; extern const int objcumber[NUMOFOBJECTS]; /* current input line */ +#define WORDLEN 15 #define NWORD 20 /* words per line */ -extern char words[NWORD][15]; +extern char words[NWORD][WORDLEN]; extern int wordvalue[NWORD]; extern int wordtype[NWORD]; extern int wordcount, wordnumber; -- cgit v1.2.3