-/* $NetBSD: vocab.c,v 1.9 1998/09/14 09:29:09 hubertf Exp $ */
+/* $NetBSD: vocab.c,v 1.13 2006/03/18 23:35:51 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#if 0
static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: vocab.c,v 1.9 1998/09/14 09:29:09 hubertf Exp $");
+__RCSID("$NetBSD: vocab.c,v 1.13 2006/03/18 23:35:51 christos Exp $");
#endif
#endif /* not lint */
#include "extern.h"
void
-dstroy(object)
- int object;
+dstroy(int object)
{
move(object, 0);
}
void
-juggle(object)
- int object;
+juggle(int object)
{
int i, j;
move(object + 100, j);
}
-
void
-move(object, where)
- int object, where;
+move(int object, int where)
{
int from;
}
int
-put(object, where, pval)
- int object, where, pval;
+put(int object, int where, int pval)
{
move(object, where);
return (-1 - pval);
}
void
-carry(object, where)
- int object, where;
+carry(int object, int where)
{
int temp;
void
-drop(object, where)
- int object, where;
+drop(int object, int where)
{
if (object > 100)
fixed[object - 100] = where;
atloc[where] = object;
}
+/* look up or store a word */
+/* -2 for store, -1 for user word, >=0 for canned lookup */
+/* used for storing only */
int
-vocab(word, type, value) /* look up or store a word */
- const char *word;
- int type; /* -2 for store, -1 for user word, >=0 for
- * canned lookup */
- int value; /* used for storing only */
+vocab(const char *word, int type, int value)
{
int adr;
const char *s;
int hash, i;
struct hashtab *h;
- for (hash = 0, s = word, i = 0; i < 5 && *s; i++) /* some kind of hash */
+ for (hash = 0, s = word, i = 0; i < 5 && *s; i++) /* some kind of hash*/
hash += *s++; /* add all chars in the word */
hash = (hash * 3719) & 077777; /* pulled that one out of a hat */
hash %= HTSIZE; /* put it into range of table */
h->val = value;
h->atab = malloc(length(word));
if (h->atab == NULL)
- errx(1, "Out of memory!");
+ err(1, NULL);
for (s = word, t = h->atab; *s;)
*t++ = *s++ ^ '=';
*t = 0 ^ '=';
}
exitloop2: /* hashed entry does not match */
- if (adr + 1 == hash || (adr == HTSIZE && hash == 0))
+ if (adr + 1 == hash || hash == 0)
errx(1,"Hash table overflow");
}
}
+/* print hash table */
void
-prht()
-{ /* print hash table */
+prht(void)
+{
int i, j, l;
char *c;
struct hashtab *h;