X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/83d87cc2642c6958b99e98c44891b486b944c6fe..21063bf128e3391402d4b9d63a7f8a532e3252c9:/gomoku/stoc.c diff --git a/gomoku/stoc.c b/gomoku/stoc.c index 71a9dde2..48430c83 100644 --- a/gomoku/stoc.c +++ b/gomoku/stoc.c @@ -1,5 +1,5 @@ -/* $NetBSD: stoc.c,v 1.2 1996/12/28 18:57:05 tls Exp $ -*/ +/* $NetBSD: stoc.c,v 1.9 2005/04/19 20:17:12 rillig Exp $ */ + /* * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. @@ -15,11 +15,7 @@ * 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. * @@ -36,39 +32,42 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)stoc.c 8.1 (Berkeley) 7/24/94"; #else -static char rcsid[] = "$NetBSD: stoc.c,v 1.2 1996/12/28 18:57:05 tls Exp $"; +__RCSID("$NetBSD: stoc.c,v 1.9 2005/04/19 20:17:12 rillig Exp $"); #endif #endif /* not lint */ -#include "gomoku.h" #include +#include +#include +#include "gomoku.h" -char *letters = ""; +const char *letters = ""; struct mvstr { int m_code; - char *m_text; + const char *m_text; }; -static struct mvstr mv[] = { - RESIGN, "resign", - RESIGN, "quit", - SAVE, "save", - -1, 0 +static const struct mvstr mv[] = { + { RESIGN, "resign" }, + { RESIGN, "quit" }, + { SAVE, "save" }, + { -1, 0 } }; /* * Turn the spot number form of a move into the character form. */ -char * +const char * stoc(s) int s; { static char buf[32]; - register int i; + int i; for (i = 0; mv[i].m_code >= 0; i++) if (s == mv[i].m_code) @@ -80,29 +79,31 @@ stoc(s) /* * Turn the character form of a move into the spot number form. */ +int ctos(mp) - char *mp; + const char *mp; { - register int i; + int i; for (i = 0; mv[i].m_code >= 0; i++) if (strcmp(mp, mv[i].m_text) == 0) return(mv[i].m_code); - if (!isalpha(mp[0])) + if (!isalpha((unsigned char)mp[0])) return(ILLEGAL); i = atoi(&mp[1]); if (i < 1 || i > 19) return(ILLEGAL); - return(PT(lton(mp[0]), i)); + return(PT(lton((unsigned char)mp[0]), i)); } /* * Turn a letter into a number. */ +int lton(c) int c; { - register int i; + int i; if (islower(c)) c = toupper(c);