some C99 changes

Instead of using index() macro defined to strchr, use C99 strchr.
Instead of using rindex() macro defined to strrchr, use C99 strrchr.

If you want to try building on a platform that doesn't offer those
two functions, these are available:
    define NOT_C99       /* to make some non-C99 code available */
    define NEED_INDEX    /* to define a macro for index()  */
    define NEED_RINDX    /* to define a macro for rindex() */
This commit is contained in:
nhmall
2022-10-29 10:54:25 -04:00
parent 943c1bc3c3
commit 99a93fe50b
99 changed files with 463 additions and 460 deletions

View File

@@ -336,8 +336,8 @@ lopt(
return (char *) 0;
}
if ((p = index(arg, '=')) == 0)
p = index(arg, ':');
if ((p = strchr(arg, '=')) == 0)
p = strchr(arg, ':');
if (p && opttype == ArgValDisallowed)
goto loptnotallowed;
@@ -831,7 +831,7 @@ whoami(void)
if (s && *s) {
(void) strncpy(g.plname, s, sizeof g.plname - 1);
if (index(g.plname, '-'))
if (strchr(g.plname, '-'))
return TRUE;
}
}
@@ -897,7 +897,7 @@ wd_message(void)
if (sysopt.wizards && sysopt.wizards[0]) {
char *tmp = build_english_list(sysopt.wizards);
pline("Only user%s %s may access debug (wizard) mode.",
index(sysopt.wizards, ' ') ? "s" : "", tmp);
strchr(sysopt.wizards, ' ') ? "s" : "", tmp);
free(tmp);
} else
pline("Entering explore/discovery mode instead.");

View File

@@ -5,7 +5,7 @@
/* This file collects some Unix dependencies */
#include "hack.h" /* mainly for index() which depends on BSD */
#include "hack.h" /* mainly for strchr() which depends on BSD */
#include <errno.h>
#include <sys/stat.h>
@@ -218,8 +218,8 @@ regularize(char *s)
{
register char *lp;
while ((lp = index(s, '.')) != 0 || (lp = index(s, '/')) != 0
|| (lp = index(s, ' ')) != 0)
while ((lp = strchr(s, '.')) != 0 || (lp = strchr(s, '/')) != 0
|| (lp = strchr(s, ' ')) != 0)
*lp = '_';
#if defined(SYSV) && !defined(AIX_31) && !defined(SVR4) && !defined(LINUX) \
&& !defined(__APPLE__)