From 84e7d0704483ce39bbdeacd5e676168db6fa664f Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 19 Oct 1997 16:56:41 +0000 Subject: WARNsify... --- hack/hack.options.c | 205 +++++++++++++++++++++++++++------------------------- 1 file changed, 108 insertions(+), 97 deletions(-) (limited to 'hack/hack.options.c') diff --git a/hack/hack.options.c b/hack/hack.options.c index 078ec7f0..e9f30473 100644 --- a/hack/hack.options.c +++ b/hack/hack.options.c @@ -1,133 +1,135 @@ +/* $NetBSD: hack.options.c,v 1.4 1997/10/19 16:58:42 christos Exp $ */ + /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ +#include #ifndef lint -static char rcsid[] = "$NetBSD: hack.options.c,v 1.3 1995/03/23 08:31:14 cgd Exp $"; -#endif /* not lint */ +__RCSID("$NetBSD: hack.options.c,v 1.4 1997/10/19 16:58:42 christos Exp $"); +#endif /* not lint */ -#include "config.h" +#include #include "hack.h" -extern char *eos(); +#include "extern.h" +void initoptions() { - register char *opts; - extern char *getenv(); + char *opts; flags.time = flags.nonews = flags.notombstone = flags.end_own = - flags.standout = flags.nonull = FALSE; + flags.standout = flags.nonull = FALSE; flags.no_rest_on_space = TRUE; flags.invlet_constant = TRUE; flags.end_top = 5; flags.end_around = 4; - flags.female = FALSE; /* players are usually male */ + flags.female = FALSE; /* players are usually male */ - if(opts = getenv("HACKOPTIONS")) - parseoptions(opts,TRUE); + if ((opts = getenv("HACKOPTIONS")) != NULL) + parseoptions(opts, TRUE); } +void parseoptions(opts, from_env) -register char *opts; -boolean from_env; + char *opts; + boolean from_env; { - register char *op,*op2; - unsigned num; - boolean negated; + char *op, *op2; + unsigned num; + boolean negated; - if(op = index(opts, ',')) { + if ((op = strchr(opts, ',')) != NULL) { *op++ = 0; parseoptions(op, from_env); } - if(op = index(opts, ' ')) { + if ((op = strchr(opts, ' ')) != NULL) { op2 = op; - while(*op++) - if(*op != ' ') *op2++ = *op; + while (*op++) + if (*op != ' ') + *op2++ = *op; } - if(!*opts) return; + if (!*opts) + return; negated = FALSE; - while((*opts == '!') || !strncmp(opts, "no", 2)) { - if(*opts == '!') opts++; else opts += 2; + while ((*opts == '!') || !strncmp(opts, "no", 2)) { + if (*opts == '!') + opts++; + else + opts += 2; negated = !negated; } - - if(!strncmp(opts,"standout",8)) { + + if (!strncmp(opts, "standout", 8)) { flags.standout = !negated; return; } - - if(!strncmp(opts,"null",3)) { + if (!strncmp(opts, "null", 3)) { flags.nonull = negated; return; } - - if(!strncmp(opts,"tombstone",4)) { + if (!strncmp(opts, "tombstone", 4)) { flags.notombstone = negated; return; } - - if(!strncmp(opts,"news",4)) { + if (!strncmp(opts, "news", 4)) { flags.nonews = negated; return; } - - if(!strncmp(opts,"time",4)) { + if (!strncmp(opts, "time", 4)) { flags.time = !negated; flags.botl = 1; return; } - - if(!strncmp(opts,"restonspace",4)) { + if (!strncmp(opts, "restonspace", 4)) { flags.no_rest_on_space = negated; return; } - - if(!strncmp(opts,"fixinv",4)) { - if(from_env) + if (!strncmp(opts, "fixinv", 4)) { + if (from_env) flags.invlet_constant = !negated; else pline("The fixinvlet option must be in HACKOPTIONS."); return; } - - if(!strncmp(opts,"male",4)) { + if (!strncmp(opts, "male", 4)) { flags.female = negated; return; } - if(!strncmp(opts,"female",6)) { + if (!strncmp(opts, "female", 6)) { flags.female = !negated; return; } - /* name:string */ - if(!strncmp(opts,"name",4)) { - extern char plname[PL_NSIZ]; - if(!from_env) { - pline("The playername can be set only from HACKOPTIONS."); - return; + if (!strncmp(opts, "name", 4)) { + if (!from_env) { + pline("The playername can be set only from HACKOPTIONS."); + return; } - op = index(opts,':'); - if(!op) goto bad; - (void) strncpy(plname, op+1, sizeof(plname)-1); + op = strchr(opts, ':'); + if (!op) + goto bad; + (void) strncpy(plname, op + 1, sizeof(plname) - 1); return; } - /* endgame:5t[op] 5a[round] o[wn] */ - if(!strncmp(opts,"endgame",3)) { - op = index(opts,':'); - if(!op) goto bad; + if (!strncmp(opts, "endgame", 3)) { + op = strchr(opts, ':'); + if (!op) + goto bad; op++; - while(*op) { + while (*op) { num = 1; - if(digit(*op)) { + if (digit(*op)) { +/*###124 [cc] warning: implicit declaration of function `atoi'%%%*/ num = atoi(op); - while(digit(*op)) op++; - } else - if(*op == '!') { + while (digit(*op)) + op++; + } else if (*op == '!') { negated = !negated; op++; } - switch(*op) { + switch (*op) { case 't': flags.end_top = num; break; @@ -140,28 +142,29 @@ boolean from_env; default: goto bad; } - while(letter(*++op)) ; - if(*op == '/') op++; + while (letter(*++op)); + if (*op == '/') + op++; } return; } bad: - if(!from_env) { - if(!strncmp(opts, "help", 4)) { + if (!from_env) { + if (!strncmp(opts, "help", 4)) { pline("%s%s%s", -"To set options use `HACKOPTIONS=\"\"' in your environment, or ", -"give the command 'o' followed by the line `' while playing. ", -"Here is a list of