isspace() usage
Replace most uses of isspace() with a simple test for ' ' after processing the string buffer with mungspaces (which replaces tab with space, converts instances of consecutive whitespace into a single space, and removes leading and trailing spaces). The uses where this wasn't done now cast their argument to (uchar) so that platforms with signed chars will never pass negative values to it. I didn't mess with the menu coloring code (except for casts to the isspace() argument); it almost certainly could benefit from using mungspaces. I did mess with the symset processing quite a bit, and hope I haven't accidentally broken anything. Default symbols and DECgraphics symbols still parse and display ok, so the rest of dat/symbols should be ok too. I didn't test symbols in the user's config file because I don't remember how that's supposed to work.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.5 end.c $NHDT-Date: 1425319883 2015/03/02 18:11:23 $ $NHDT-Branch: master $:$NHDT-Revision: 1.81 $ */
|
/* NetHack 3.5 end.c $NHDT-Date: 1429953061 2015/04/25 09:11:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.93 $ */
|
||||||
/* NetHack 3.5 end.c $Date: 2012/04/09 02:56:30 $ $Revision: 1.79 $ */
|
/* NetHack 3.5 end.c $Date: 2012/04/09 02:56:30 $ $Revision: 1.79 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -1605,10 +1605,11 @@ wordcount(p)
|
|||||||
char *p;
|
char *p;
|
||||||
{
|
{
|
||||||
int words = 0;
|
int words = 0;
|
||||||
while(*p){
|
|
||||||
while(*p && isspace(*p))p++;
|
while (*p) {
|
||||||
if(*p) words++;
|
while (*p && isspace((uchar)*p)) p++;
|
||||||
while(*p && !isspace(*p))p++;
|
if (*p) words++;
|
||||||
|
while (*p && !isspace((uchar)*p)) p++;
|
||||||
}
|
}
|
||||||
return words;
|
return words;
|
||||||
}
|
}
|
||||||
@@ -1620,8 +1621,8 @@ bel_copy1(inp, out)
|
|||||||
char *in = *inp;
|
char *in = *inp;
|
||||||
|
|
||||||
out += strlen(out); /* eos() */
|
out += strlen(out); /* eos() */
|
||||||
while(*in && isspace(*in)) in++;
|
while (*in && isspace((uchar)*in)) in++;
|
||||||
while(*in && !isspace(*in)) *out++ = *in++;
|
while (*in && !isspace((uchar)*in)) *out++ = *in++;
|
||||||
*out = '\0';
|
*out = '\0';
|
||||||
*inp = in;
|
*inp = in;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-5
@@ -1,11 +1,10 @@
|
|||||||
/* NetHack 3.5 engrave.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
/* NetHack 3.5 engrave.c $NHDT-Date: 1429953062 2015/04/25 09:11:02 $ $NHDT-Branch: master $:$NHDT-Revision: 1.47 $ */
|
||||||
/* NetHack 3.5 engrave.c $Date: 2012/12/20 01:48:36 $ $Revision: 1.39 $ */
|
/* NetHack 3.5 engrave.c $Date: 2012/12/20 01:48:36 $ $Revision: 1.39 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
#include "hack.h"
|
#include "hack.h"
|
||||||
#include "lev.h"
|
#include "lev.h"
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
STATIC_VAR NEARDATA struct engr *head_engr;
|
STATIC_VAR NEARDATA struct engr *head_engr;
|
||||||
|
|
||||||
@@ -973,10 +972,13 @@ doengrave()
|
|||||||
/* Prompt for engraving! */
|
/* Prompt for engraving! */
|
||||||
Sprintf(qbuf,"What do you want to %s the %s here?", everb, eloc);
|
Sprintf(qbuf,"What do you want to %s the %s here?", everb, eloc);
|
||||||
getlin(qbuf, ebuf);
|
getlin(qbuf, ebuf);
|
||||||
|
/* convert tabs to spaces and condense consecutive spaces to one */
|
||||||
|
mungspaces(ebuf);
|
||||||
|
|
||||||
/* Count the actual # of chars engraved not including spaces */
|
/* Count the actual # of chars engraved not including spaces */
|
||||||
len = strlen(ebuf);
|
len = strlen(ebuf);
|
||||||
for (sp = ebuf; *sp; sp++) if (isspace(*sp)) len -= 1;
|
for (sp = ebuf; *sp; sp++)
|
||||||
|
if (*sp == ' ') len -= 1;
|
||||||
|
|
||||||
if (len == 0 || index(ebuf, '\033')) {
|
if (len == 0 || index(ebuf, '\033')) {
|
||||||
if (zapwand) {
|
if (zapwand) {
|
||||||
@@ -997,7 +999,7 @@ doengrave()
|
|||||||
/* Mix up engraving if surface or state of mind is unsound.
|
/* Mix up engraving if surface or state of mind is unsound.
|
||||||
Note: this won't add or remove any spaces. */
|
Note: this won't add or remove any spaces. */
|
||||||
for (sp = ebuf; *sp; sp++) {
|
for (sp = ebuf; *sp; sp++) {
|
||||||
if (isspace(*sp)) continue;
|
if (*sp == ' ') continue;
|
||||||
if (((type == DUST || type == ENGR_BLOOD) && !rn2(25)) ||
|
if (((type == DUST || type == ENGR_BLOOD) && !rn2(25)) ||
|
||||||
(Blind && !rn2(11)) || (Confusion && !rn2(7)) ||
|
(Blind && !rn2(11)) || (Confusion && !rn2(7)) ||
|
||||||
(Stunned && !rn2(4)) || (Hallucination && !rn2(2)))
|
(Stunned && !rn2(4)) || (Hallucination && !rn2(2)))
|
||||||
@@ -1081,7 +1083,7 @@ doengrave()
|
|||||||
/* Chop engraving down to size if necessary */
|
/* Chop engraving down to size if necessary */
|
||||||
if (len > maxelen) {
|
if (len > maxelen) {
|
||||||
for (sp = ebuf; (maxelen && *sp); sp++)
|
for (sp = ebuf; (maxelen && *sp); sp++)
|
||||||
if (!isspace(*sp)) maxelen--;
|
if (*sp == ' ') maxelen--;
|
||||||
if (!maxelen && *sp) {
|
if (!maxelen && *sp) {
|
||||||
*sp = (char)0;
|
*sp = (char)0;
|
||||||
if (multi) nomovemsg = "You cannot write any more.";
|
if (multi) nomovemsg = "You cannot write any more.";
|
||||||
|
|||||||
+88
-99
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.5 files.c $NHDT-Date: 1428972596 2015/04/14 00:49:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.164 $ */
|
/* NetHack 3.5 files.c $NHDT-Date: 1429953063 2015/04/25 09:11:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.166 $ */
|
||||||
/* NetHack 3.5 files.c $Date: 2012/03/10 02:49:08 $ $Revision: 1.124 $ */
|
/* NetHack 3.5 files.c $Date: 2012/03/10 02:49:08 $ $Revision: 1.124 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -10,8 +10,6 @@
|
|||||||
#include "wintty.h" /* more() */
|
#include "wintty.h" /* more() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#if (!defined(MAC) && !defined(O_WRONLY) && !defined(AZTEC_C)) || defined(USE_FCNTL)
|
#if (!defined(MAC) && !defined(O_WRONLY) && !defined(AZTEC_C)) || defined(USE_FCNTL)
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -2060,9 +2058,9 @@ int prefixid;
|
|||||||
#define match_varname(INP,NAM,LEN) match_optname(INP, NAM, LEN, TRUE)
|
#define match_varname(INP,NAM,LEN) match_optname(INP, NAM, LEN, TRUE)
|
||||||
|
|
||||||
int
|
int
|
||||||
parse_config_line(fp, buf, src)
|
parse_config_line(fp, origbuf, src)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *buf;
|
char *origbuf;
|
||||||
int src;
|
int src;
|
||||||
{
|
{
|
||||||
#if defined(MICRO) && !defined(NOCWD_ASSUMPTIONS)
|
#if defined(MICRO) && !defined(NOCWD_ASSUMPTIONS)
|
||||||
@@ -2071,37 +2069,39 @@ int src;
|
|||||||
#ifdef SYSCF
|
#ifdef SYSCF
|
||||||
int n;
|
int n;
|
||||||
#endif
|
#endif
|
||||||
char *bufp, *altp;
|
char *bufp, *altp, buf[BUFSZ];
|
||||||
uchar translate[MAXPCHARS];
|
uchar translate[MAXPCHARS];
|
||||||
int len;
|
int len;
|
||||||
/* lines beginning with '#' are comments */
|
|
||||||
if (*buf == '#')
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/* remove trailing whitespace */
|
/* convert any tab to space, condense consecutive spaces into one,
|
||||||
bufp = eos(buf);
|
remove leading and trailing spaces (exception: if there is nothing
|
||||||
while (--bufp > buf && isspace(*bufp))
|
but spaces, one of them will be kept even though it leads/trails) */
|
||||||
continue;
|
mungspaces(strcpy(buf, origbuf));
|
||||||
|
/* lines beginning with '#' are comments; accept empty lines too */
|
||||||
if (bufp <= buf)
|
if (!*buf || *buf == '#' || !strcmp(buf, " ")) return 1;
|
||||||
return 1; /* skip all-blank lines */
|
|
||||||
else
|
|
||||||
*(bufp + 1) = '\0'; /* terminate line */
|
|
||||||
|
|
||||||
/* find the '=' or ':' */
|
/* find the '=' or ':' */
|
||||||
bufp = index(buf, '=');
|
bufp = index(buf, '=');
|
||||||
altp = index(buf, ':');
|
altp = index(buf, ':');
|
||||||
if (!bufp || (altp && altp < bufp)) bufp = altp;
|
if (!bufp || (altp && altp < bufp)) bufp = altp;
|
||||||
if (!bufp) return 0;
|
if (!bufp) return 0;
|
||||||
|
/* skip past '=', then space between it and value, if any */
|
||||||
/* skip whitespace between '=' and value */
|
++bufp;
|
||||||
do { ++bufp; } while (isspace(*bufp));
|
if (*bufp == ' ') ++bufp;
|
||||||
|
|
||||||
/* Go through possible variables */
|
/* Go through possible variables */
|
||||||
/* some of these (at least LEVELS and SAVE) should now set the
|
/* some of these (at least LEVELS and SAVE) should now set the
|
||||||
* appropriate fqn_prefix[] rather than specialized variables
|
* appropriate fqn_prefix[] rather than specialized variables
|
||||||
*/
|
*/
|
||||||
if (match_varname(buf, "OPTIONS", 4)) {
|
if (match_varname(buf, "OPTIONS", 4)) {
|
||||||
|
/* hack: un-mungspaces to allow consecutive spaces in
|
||||||
|
general options until we verify that this is unnecessary;
|
||||||
|
'=' or ':' is guaranteed to be present */
|
||||||
|
bufp = index(origbuf, '=');
|
||||||
|
altp = index(origbuf, ':');
|
||||||
|
if (!bufp || (altp && altp < bufp)) bufp = altp;
|
||||||
|
++bufp; /* skip '='; parseoptions() handles spaces */
|
||||||
|
|
||||||
parseoptions(bufp, TRUE, TRUE);
|
parseoptions(bufp, TRUE, TRUE);
|
||||||
if (plname[0]) /* If a name was given */
|
if (plname[0]) /* If a name was given */
|
||||||
plnamesuffix(); /* set the character class */
|
plnamesuffix(); /* set the character class */
|
||||||
@@ -2190,16 +2190,17 @@ int src;
|
|||||||
} else if (src == SET_IN_SYS && match_varname(buf, "SHELLERS", 8)) {
|
} else if (src == SET_IN_SYS && match_varname(buf, "SHELLERS", 8)) {
|
||||||
if (sysopt.shellers) free(sysopt.shellers);
|
if (sysopt.shellers) free(sysopt.shellers);
|
||||||
sysopt.shellers = dupstr(bufp);
|
sysopt.shellers = dupstr(bufp);
|
||||||
} else if (src == SET_IN_SYS && match_varname(buf, "EXPLORERS", 7)) {
|
} else if (src == SET_IN_SYS && match_varname(buf, "EXPLORERS", 7)) {
|
||||||
if (sysopt.explorers) free(sysopt.explorers);
|
if (sysopt.explorers) free(sysopt.explorers);
|
||||||
sysopt.explorers = dupstr(bufp);
|
sysopt.explorers = dupstr(bufp);
|
||||||
} else if (src == SET_IN_SYS && match_varname(buf, "DEBUGFILES", 5)) {
|
} else if (src == SET_IN_SYS && match_varname(buf, "DEBUGFILES", 5)) {
|
||||||
if (sysopt.debugfiles) free(sysopt.debugfiles);
|
|
||||||
/* if showdebug() has already been called (perhaps we've added
|
/* if showdebug() has already been called (perhaps we've added
|
||||||
some debugpline() calls to option processing) and has found
|
some debugpline() calls to option processing) and has found
|
||||||
a value for getenv("DEBUGFILES"), don't override that */
|
a value for getenv("DEBUGFILES"), don't override that */
|
||||||
if (sysopt.env_dbgfl == 0)
|
if (sysopt.env_dbgfl == 0) {
|
||||||
sysopt.debugfiles = dupstr(bufp);
|
if (sysopt.debugfiles) free(sysopt.debugfiles);
|
||||||
|
sysopt.debugfiles = dupstr(bufp);
|
||||||
|
}
|
||||||
} else if (src == SET_IN_SYS && match_varname(buf, "SUPPORT", 7)) {
|
} else if (src == SET_IN_SYS && match_varname(buf, "SUPPORT", 7)) {
|
||||||
if (sysopt.support) free(sysopt.support);
|
if (sysopt.support) free(sysopt.support);
|
||||||
sysopt.support = dupstr(bufp);
|
sysopt.support = dupstr(bufp);
|
||||||
@@ -2308,33 +2309,29 @@ int src;
|
|||||||
} else if (match_varname(buf, "SYMBOLS", 4)) {
|
} else if (match_varname(buf, "SYMBOLS", 4)) {
|
||||||
char *op, symbuf[BUFSZ];
|
char *op, symbuf[BUFSZ];
|
||||||
boolean morelines;
|
boolean morelines;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
morelines = FALSE;
|
|
||||||
|
|
||||||
/* strip leading and trailing white space */
|
|
||||||
while (isspace(*bufp)) bufp++;
|
|
||||||
op = eos(bufp);
|
|
||||||
while (--op >= bufp && isspace(*op)) *op = '\0';
|
|
||||||
|
|
||||||
/* check for line continuation (trailing '\') */
|
/* check for line continuation (trailing '\') */
|
||||||
op = eos(bufp);
|
op = eos(bufp);
|
||||||
if (--op >= bufp && *op == '\\') {
|
morelines = (--op >= bufp && *op == '\\');
|
||||||
|
if (morelines) {
|
||||||
*op = '\0';
|
*op = '\0';
|
||||||
morelines = TRUE;
|
|
||||||
/* strip trailing space now that '\' is gone */
|
/* strip trailing space now that '\' is gone */
|
||||||
while (--op >= bufp && isspace(*op)) *op = '\0';
|
if (--op >= bufp && *op == ' ') *op = '\0';
|
||||||
}
|
}
|
||||||
/* parse here */
|
/* parse here */
|
||||||
parsesymbols(bufp);
|
parsesymbols(bufp);
|
||||||
if (morelines)
|
if (morelines) {
|
||||||
do {
|
do {
|
||||||
*symbuf = '\0';
|
*symbuf = '\0';
|
||||||
if (!fgets(symbuf, BUFSZ, fp)) {
|
if (!fgets(symbuf, BUFSZ, fp)) {
|
||||||
morelines = FALSE;
|
morelines = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bufp = symbuf;
|
mungspaces(symbuf);
|
||||||
} while (*bufp == '#');
|
bufp = symbuf;
|
||||||
|
} while (*bufp == '#');
|
||||||
|
}
|
||||||
} while (morelines);
|
} while (morelines);
|
||||||
switch_symbols(TRUE);
|
switch_symbols(TRUE);
|
||||||
} else if (match_varname(buf, "WIZKIT", 6)) {
|
} else if (match_varname(buf, "WIZKIT", 6)) {
|
||||||
@@ -2355,7 +2352,7 @@ int src;
|
|||||||
extern int amii_numcolors;
|
extern int amii_numcolors;
|
||||||
int val = atoi( bufp );
|
int val = atoi( bufp );
|
||||||
amii_numcolors = 1L << min( DEPTH, val );
|
amii_numcolors = 1L << min( DEPTH, val );
|
||||||
#if defined(SYSFLAGS)
|
# ifdef SYSFLAGS
|
||||||
} else if (match_varname(buf, "DRIPENS", 7)) {
|
} else if (match_varname(buf, "DRIPENS", 7)) {
|
||||||
int i, val;
|
int i, val;
|
||||||
char *t;
|
char *t;
|
||||||
@@ -2364,7 +2361,7 @@ int src;
|
|||||||
sscanf(t, "%d", &val );
|
sscanf(t, "%d", &val );
|
||||||
sysflags.amii_dripens[i] = val;
|
sysflags.amii_dripens[i] = val;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
} else if (match_varname(buf, "SCREENMODE", 10 )) {
|
} else if (match_varname(buf, "SCREENMODE", 10 )) {
|
||||||
extern long amii_scrnmode;
|
extern long amii_scrnmode;
|
||||||
if (!stricmp(bufp,"req"))
|
if (!stricmp(bufp,"req"))
|
||||||
@@ -2450,7 +2447,7 @@ int src;
|
|||||||
{
|
{
|
||||||
sscanf(t, "%d", &backg[i]);
|
sscanf(t, "%d", &backg[i]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*AMIGA*/
|
||||||
#ifdef USER_SOUNDS
|
#ifdef USER_SOUNDS
|
||||||
} else if (match_varname(buf, "SOUNDDIR", 8)) {
|
} else if (match_varname(buf, "SOUNDDIR", 8)) {
|
||||||
sounddir = dupstr(bufp);
|
sounddir = dupstr(bufp);
|
||||||
@@ -2717,46 +2714,36 @@ int which_set;
|
|||||||
struct symparse *symp = (struct symparse *)0;
|
struct symparse *symp = (struct symparse *)0;
|
||||||
char *bufp, *commentp, *altp;
|
char *bufp, *commentp, *altp;
|
||||||
|
|
||||||
if (*buf == '#')
|
/* convert each instance of whitespace (tabs, consecutive spaces)
|
||||||
|
into a single space; leading and trailing spaces are stripped */
|
||||||
|
mungspaces(buf);
|
||||||
|
if (!*buf || *buf == '#' || !strcmp(buf, " "))
|
||||||
return 1;
|
return 1;
|
||||||
|
/* remove trailing comment, if any */
|
||||||
/* remove trailing comment(s) */
|
if ((commentp = rindex(buf, '#')) != 0) {
|
||||||
commentp = eos(buf);
|
|
||||||
while (--commentp > buf) {
|
|
||||||
if (*commentp != '#') continue;
|
|
||||||
*commentp = '\0';
|
*commentp = '\0';
|
||||||
|
/* remove space preceding the stripped comment, if any;
|
||||||
|
we know 'commentp > buf' because *buf=='#' was caught above */
|
||||||
|
if (commentp[-1] == ' ') *--commentp = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove trailing whitespace */
|
|
||||||
bufp = eos(buf);
|
|
||||||
while (--bufp > buf && isspace(*bufp))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (bufp <= buf)
|
|
||||||
return 1; /* skip all-blank lines */
|
|
||||||
else
|
|
||||||
*(bufp + 1) = '\0'; /* terminate line */
|
|
||||||
|
|
||||||
/* skip leading whitespace on option name */
|
|
||||||
while (isspace(*buf)) ++buf;
|
|
||||||
|
|
||||||
/* find the '=' or ':' */
|
/* find the '=' or ':' */
|
||||||
bufp = index(buf, '=');
|
bufp = index(buf, '=');
|
||||||
altp = index(buf, ':');
|
altp = index(buf, ':');
|
||||||
if (!bufp || (altp && altp < bufp)) bufp = altp;
|
if (!bufp || (altp && altp < bufp)) bufp = altp;
|
||||||
if (!bufp) {
|
if (!bufp) {
|
||||||
if (strncmpi(buf, "finish", 6) == 0) {
|
if (strncmpi(buf, "finish", 6) == 0) {
|
||||||
/* end current graphics set */
|
/* end current graphics set */
|
||||||
if (chosen_symset_start)
|
if (chosen_symset_start)
|
||||||
chosen_symset_end = TRUE;
|
chosen_symset_end = TRUE;
|
||||||
chosen_symset_start = FALSE;
|
chosen_symset_start = FALSE;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/* skip '=' and space which follows, if any */
|
||||||
/* skip whitespace between '=' and value */
|
++bufp;
|
||||||
do { ++bufp; } while (isspace(*bufp));
|
if (*bufp == ' ') ++bufp;
|
||||||
|
|
||||||
symp = match_sym(buf);
|
symp = match_sym(buf);
|
||||||
if (!symp)
|
if (!symp)
|
||||||
@@ -2829,17 +2816,19 @@ int which_set;
|
|||||||
case 0:
|
case 0:
|
||||||
/* start of symset */
|
/* start of symset */
|
||||||
if (!strcmpi(bufp, symset[which_set].name)) {
|
if (!strcmpi(bufp, symset[which_set].name)) {
|
||||||
/* matches desired one */
|
/* matches desired one */
|
||||||
chosen_symset_start = TRUE;
|
chosen_symset_start = TRUE;
|
||||||
/* these init_*() functions clear symset fields too */
|
/* these init_*() functions clear symset fields too */
|
||||||
if (which_set == ROGUESET) init_r_symbols();
|
if (which_set == ROGUESET)
|
||||||
else if (which_set == PRIMARY) init_l_symbols();
|
init_r_symbols();
|
||||||
|
else if (which_set == PRIMARY)
|
||||||
|
init_l_symbols();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/* finish symset */
|
/* finish symset */
|
||||||
if (chosen_symset_start)
|
if (chosen_symset_start)
|
||||||
chosen_symset_end = TRUE;
|
chosen_symset_end = TRUE;
|
||||||
chosen_symset_start = FALSE;
|
chosen_symset_start = FALSE;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@@ -2851,14 +2840,14 @@ int which_set;
|
|||||||
case 4: /* color:off */
|
case 4: /* color:off */
|
||||||
if (chosen_symset_start) {
|
if (chosen_symset_start) {
|
||||||
if (bufp) {
|
if (bufp) {
|
||||||
if (!strcmpi(bufp, "true") ||
|
if (!strcmpi(bufp, "true") ||
|
||||||
!strcmpi(bufp, "yes") ||
|
!strcmpi(bufp, "yes") ||
|
||||||
!strcmpi(bufp, "on"))
|
!strcmpi(bufp, "on"))
|
||||||
symset[which_set].nocolor = 0;
|
symset[which_set].nocolor = 0;
|
||||||
else if (!strcmpi(bufp, "false") ||
|
else if (!strcmpi(bufp, "false") ||
|
||||||
!strcmpi(bufp, "no") ||
|
!strcmpi(bufp, "no") ||
|
||||||
!strcmpi(bufp, "off"))
|
!strcmpi(bufp, "off"))
|
||||||
symset[which_set].nocolor = 1;
|
symset[which_set].nocolor = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2866,17 +2855,17 @@ int which_set;
|
|||||||
if (chosen_symset_start) {
|
if (chosen_symset_start) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while (known_restrictions[n]) {
|
while (known_restrictions[n]) {
|
||||||
if (!strcmpi(known_restrictions[n], bufp)) {
|
if (!strcmpi(known_restrictions[n], bufp)) {
|
||||||
switch(n) {
|
switch(n) {
|
||||||
case 0: symset[which_set].primary = 1;
|
case 0: symset[which_set].primary = 1;
|
||||||
break;
|
break;
|
||||||
case 1: symset[which_set].rogue = 1;
|
case 1: symset[which_set].rogue = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break; /* while loop */
|
break; /* while loop */
|
||||||
}
|
}
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.5 hacklib.c $NHDT-Date: 1428806394 2015/04/12 02:39:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.34 $ */
|
/* NetHack 3.5 hacklib.c $NHDT-Date: 1429953063 2015/04/25 09:11:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.38 $ */
|
||||||
/* NetHack 3.5 hacklib.c $Date: 2009/05/06 10:46:32 $ $Revision: 1.23 $ */
|
/* NetHack 3.5 hacklib.c $Date: 2009/05/06 10:46:32 $ $Revision: 1.23 $ */
|
||||||
/* SCCS Id: @(#)hacklib.c 3.5 2007/04/30 */
|
/* SCCS Id: @(#)hacklib.c 3.5 2007/04/30 */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
@@ -135,6 +135,7 @@ char *bp;
|
|||||||
boolean was_space = TRUE;
|
boolean was_space = TRUE;
|
||||||
|
|
||||||
for (p = p2 = bp; (c = *p) != '\0'; p++) {
|
for (p = p2 = bp; (c = *p) != '\0'; p++) {
|
||||||
|
if (c == '\n') break; /* treat newline the same as end-of-string */
|
||||||
if (c == '\t') c = ' ';
|
if (c == '\t') c = ' ';
|
||||||
if (c != ' ' || !was_space) *p2++ = c;
|
if (c != ' ' || !was_space) *p2++ = c;
|
||||||
was_space = (c == ' ');
|
was_space = (c == ' ');
|
||||||
|
|||||||
+28
-30
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.5 options.c $NHDT-Date: 1428088105 2015/04/03 19:08:25 $ $NHDT-Branch: scshunt-regex $:$NHDT-Revision: 1.182 $ */
|
/* NetHack 3.5 options.c $NHDT-Date: 1429953065 2015/04/25 09:11:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.186 $ */
|
||||||
/* NetHack 3.5 options.c $Date: 2012/04/09 02:56:30 $ $Revision: 1.153 $ */
|
/* NetHack 3.5 options.c $Date: 2012/04/09 02:56:30 $ $Revision: 1.153 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -544,7 +544,7 @@ boolean val_allowed;
|
|||||||
*q = index(user_string, '=');
|
*q = index(user_string, '=');
|
||||||
|
|
||||||
if (!p || (q && q < p)) p = q;
|
if (!p || (q && q < p)) p = q;
|
||||||
while(p && p > user_string && isspace(*(p-1))) p--;
|
while (p && p > user_string && isspace((uchar)*(p-1))) p--;
|
||||||
if (p) len = (int)(p - user_string);
|
if (p) len = (int)(p - user_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1176,7 +1176,7 @@ char *str;
|
|||||||
|
|
||||||
tmps = cs;
|
tmps = cs;
|
||||||
tmps++;
|
tmps++;
|
||||||
while (*tmps && isspace(*tmps)) tmps++;
|
while (*tmps && isspace((uchar)*tmps)) tmps++;
|
||||||
|
|
||||||
for (i = 0; i < SIZE(colornames); i++)
|
for (i = 0; i < SIZE(colornames); i++)
|
||||||
if (strstri(tmps, colornames[i].name) == tmps) {
|
if (strstri(tmps, colornames[i].name) == tmps) {
|
||||||
@@ -1191,7 +1191,7 @@ char *str;
|
|||||||
tmps = strchr(str, '&');
|
tmps = strchr(str, '&');
|
||||||
if (tmps) {
|
if (tmps) {
|
||||||
tmps++;
|
tmps++;
|
||||||
while (*tmps && isspace(*tmps)) tmps++;
|
while (*tmps && isspace((uchar)*tmps)) tmps++;
|
||||||
for (i = 0; i < SIZE(attrnames); i++)
|
for (i = 0; i < SIZE(attrnames); i++)
|
||||||
if (strstri(tmps, attrnames[i].name) == tmps) {
|
if (strstri(tmps, attrnames[i].name) == tmps) {
|
||||||
a = attrnames[i].attr;
|
a = attrnames[i].attr;
|
||||||
@@ -1205,7 +1205,7 @@ char *str;
|
|||||||
tmps = str;
|
tmps = str;
|
||||||
if ((*tmps == '"') || (*tmps == '\'')) {
|
if ((*tmps == '"') || (*tmps == '\'')) {
|
||||||
cs--;
|
cs--;
|
||||||
while (isspace(*cs)) cs--;
|
while (isspace((uchar)*cs)) cs--;
|
||||||
if (*cs == *tmps) {
|
if (*cs == *tmps) {
|
||||||
*cs = '\0';
|
*cs = '\0';
|
||||||
tmps++;
|
tmps++;
|
||||||
@@ -1281,9 +1281,9 @@ boolean tinitial, tfrom_file;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* strip leading and trailing white space */
|
/* strip leading and trailing white space */
|
||||||
while (isspace(*opts)) opts++;
|
while (isspace((uchar)*opts)) opts++;
|
||||||
op = eos(opts);
|
op = eos(opts);
|
||||||
while (--op >= opts && isspace(*op)) *op = '\0';
|
while (--op >= opts && isspace((uchar)*op)) *op = '\0';
|
||||||
|
|
||||||
if (!*opts) return;
|
if (!*opts) return;
|
||||||
negated = FALSE;
|
negated = FALSE;
|
||||||
@@ -4115,8 +4115,7 @@ const char *mapping;
|
|||||||
ape->pattern = (char *) alloc(textsize+1);
|
ape->pattern = (char *) alloc(textsize+1);
|
||||||
Strcpy(ape->pattern, text2);
|
Strcpy(ape->pattern, text2);
|
||||||
ape->grab = grab;
|
ape->grab = grab;
|
||||||
if (!*apehead) ape->next = (struct autopickup_exception *)0;
|
ape->next = *apehead;
|
||||||
else ape->next = *apehead;
|
|
||||||
*apehead = ape;
|
*apehead = ape;
|
||||||
} else {
|
} else {
|
||||||
raw_print("syntax error in AUTOPICKUP_EXCEPTION");
|
raw_print("syntax error in AUTOPICKUP_EXCEPTION");
|
||||||
@@ -4207,7 +4206,7 @@ parsesymbols(opts)
|
|||||||
register char *opts;
|
register char *opts;
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
char *op, *symname, *strval, *p;
|
char *op, *symname, *strval;
|
||||||
struct symparse *symp;
|
struct symparse *symp;
|
||||||
|
|
||||||
if ((op = index(opts, ',')) != 0) {
|
if ((op = index(opts, ',')) != 0) {
|
||||||
@@ -4218,18 +4217,13 @@ register char *opts;
|
|||||||
/* S_sample:string */
|
/* S_sample:string */
|
||||||
symname = opts;
|
symname = opts;
|
||||||
strval = index(opts, ':');
|
strval = index(opts, ':');
|
||||||
if (!symname || !strval) return;
|
if (!strval) strval = index(opts, '=');
|
||||||
*strval++ = 0;
|
if (!strval) return;
|
||||||
|
*strval++ = '\0';
|
||||||
|
|
||||||
/* strip leading and trailing white space from symname */
|
/* strip leading and trailing white space from symname and strval */
|
||||||
while (isspace(*symname)) symname++;
|
mungspaces(symname);
|
||||||
p = eos(symname);
|
mungspaces(strval);
|
||||||
while (--p >= symname && isspace(*p)) *p = '\0';
|
|
||||||
|
|
||||||
/* strip leading and trailing white space from strval */
|
|
||||||
while (isspace(*strval)) strval++;
|
|
||||||
p = eos(strval);
|
|
||||||
while (--p >= strval && isspace(*p)) *p = '\0';
|
|
||||||
|
|
||||||
symp = match_sym(symname);
|
symp = match_sym(symname);
|
||||||
if (!symp) return;
|
if (!symp) return;
|
||||||
@@ -4250,8 +4244,12 @@ char *buf;
|
|||||||
struct symparse *sp = loadsyms;
|
struct symparse *sp = loadsyms;
|
||||||
|
|
||||||
if (!p || (q && q < p)) p = q;
|
if (!p || (q && q < p)) p = q;
|
||||||
while(p && p > buf && isspace(*(p-1))) p--;
|
if (p) {
|
||||||
if (p) len = (int)(p - buf);
|
/* note: there will be at most one space before the '='
|
||||||
|
because caller has condensed buf[] with mungspaces() */
|
||||||
|
if (p > buf && p[-1] == ' ') p--;
|
||||||
|
len = (int)(p - buf);
|
||||||
|
}
|
||||||
while(sp->range) {
|
while(sp->range) {
|
||||||
if ((len >= strlen(sp->name)) && !strncmpi(buf, sp->name, len))
|
if ((len >= strlen(sp->name)) && !strncmpi(buf, sp->name, len))
|
||||||
return sp;
|
return sp;
|
||||||
@@ -4424,7 +4422,7 @@ struct fruit *replace_fruit;
|
|||||||
|
|
||||||
for(c = pl_fruit; *c >= '0' && *c <= '9'; c++)
|
for(c = pl_fruit; *c >= '0' && *c <= '9'; c++)
|
||||||
;
|
;
|
||||||
if (isspace(*c) || *c == 0) numeric = TRUE;
|
if (isspace((uchar)*c) || *c == 0) numeric = TRUE;
|
||||||
}
|
}
|
||||||
if (found || numeric ||
|
if (found || numeric ||
|
||||||
!strncmp(str, "cursed ", 7) ||
|
!strncmp(str, "cursed ", 7) ||
|
||||||
@@ -4847,34 +4845,34 @@ char *op;
|
|||||||
wn = tfg = tbg = (char *)0;
|
wn = tfg = tbg = (char *)0;
|
||||||
|
|
||||||
/* until first non-space in case there's leading spaces - before colorname*/
|
/* until first non-space in case there's leading spaces - before colorname*/
|
||||||
while(*newop && isspace(*newop)) newop++;
|
if (*newop == ' ') newop++;
|
||||||
if (*newop) wn = newop;
|
if (*newop) wn = newop;
|
||||||
else return 0;
|
else return 0;
|
||||||
|
|
||||||
/* until first space - colorname*/
|
/* until first space - colorname*/
|
||||||
while(*newop && !isspace(*newop)) newop++;
|
while (*newop && *newop != ' ') newop++;
|
||||||
if (*newop) *newop = '\0';
|
if (*newop) *newop = '\0';
|
||||||
else return 0;
|
else return 0;
|
||||||
newop++;
|
newop++;
|
||||||
|
|
||||||
/* until first non-space - before foreground*/
|
/* until first non-space - before foreground*/
|
||||||
while(*newop && isspace(*newop)) newop++;
|
if (*newop == ' ') newop++;
|
||||||
if (*newop) tfg = newop;
|
if (*newop) tfg = newop;
|
||||||
else return 0;
|
else return 0;
|
||||||
|
|
||||||
/* until slash - foreground */
|
/* until slash - foreground */
|
||||||
while(*newop && *newop != '/') newop++;
|
while (*newop && *newop != '/') newop++;
|
||||||
if (*newop) *newop = '\0';
|
if (*newop) *newop = '\0';
|
||||||
else return 0;
|
else return 0;
|
||||||
newop++;
|
newop++;
|
||||||
|
|
||||||
/* until first non-space (in case there's leading space after slash) - before background */
|
/* until first non-space (in case there's leading space after slash) - before background */
|
||||||
while(*newop && isspace(*newop)) newop++;
|
if (*newop == ' ') newop++;
|
||||||
if (*newop) tbg = newop;
|
if (*newop) tbg = newop;
|
||||||
else return 0;
|
else return 0;
|
||||||
|
|
||||||
/* until first space - background */
|
/* until first space - background */
|
||||||
while(*newop && !isspace(*newop)) newop++;
|
while (*newop && *newop != ' ') newop++;
|
||||||
if (*newop) *newop++ = '\0';
|
if (*newop) *newop++ = '\0';
|
||||||
|
|
||||||
for (j = 0; j < 4; ++j) {
|
for (j = 0; j < 4; ++j) {
|
||||||
|
|||||||
Reference in New Issue
Block a user