X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/77e3814f0c0e3dea4d0032e25666f77e6f83bfff..4dd58b5eb4589ed8653e2e5f7d44138dcd56c357:/battlestar/parse.c diff --git a/battlestar/parse.c b/battlestar/parse.c index d4101e65..8d85e6c5 100644 --- a/battlestar/parse.c +++ b/battlestar/parse.c @@ -1,6 +1,8 @@ +/* $NetBSD: parse.c,v 1.7 1999/02/10 01:36:50 hubertf Exp $ */ + /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -31,24 +33,31 @@ * SUCH DAMAGE. */ +#include #ifndef lint -static char sccsid[] = "@(#)parse.c 5.3 (Berkeley) 6/1/90"; -#endif /* not lint */ +#if 0 +static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95"; +#else +__RCSID("$NetBSD: parse.c,v 1.7 1999/02/10 01:36:50 hubertf Exp $"); +#endif +#endif /* not lint */ -#include "externs.h" +#include "extern.h" +void wordinit() { - register struct wlist *w; + struct wlist *w; for (w = wlist; w->string; w++) install(w); } +int hash(s) - register char *s; + const char *s; { - register hashval = 0; + int hashval = 0; while (*s) { hashval += *s++; @@ -60,9 +69,9 @@ hash(s) struct wlist * lookup(s) - char *s; + const char *s; { - register struct wlist *wp; + struct wlist *wp; for (wp = hashtab[hash(s)]; wp != NULL; wp = wp->next) if (*s == *wp->string && strcmp(s, wp->string) == 0) @@ -70,10 +79,11 @@ lookup(s) return NULL; } +void install(wp) - register struct wlist *wp; + struct wlist *wp; { - int hashval; + int hashval; if (lookup(wp->string) == NULL) { hashval = hash(wp->string); @@ -83,19 +93,20 @@ install(wp) printf("Multiply defined %s.\n", wp->string); } +void parse() { - register struct wlist *wp; - register n; + struct wlist *wp; + int n; - wordnumber = 0; /* for cypher */ + wordnumber = 0; /* for cypher */ for (n = 0; n <= wordcount; n++) { if ((wp = lookup(words[n])) == NULL) { wordvalue[n] = -1; wordtype[n] = -1; } else { - wordvalue[n] = wp -> value; - wordtype[n] = wp -> article; + wordvalue[n] = wp->value; + wordtype[n] = wp->article; } } }