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

@@ -149,7 +149,7 @@ char *path;
strncpy(fileName, path, sizeof(fileName) - 1);
fileName[31] = 0;
if (colon = index(fileName, ':'))
if (colon = strchr(fileName, ':'))
colon[1] = '\0';
else
fileName[0] = '\0';
@@ -511,6 +511,6 @@ register char *s;
{
register char *lp;
while ((lp = index(s, ':')) || (lp = index(s, '/')))
while ((lp = strchr(s, ':')) || (lp = strchr(s, '/')))
*lp = '_';
}

View File

@@ -476,7 +476,7 @@ amii_player_selection()
#if 0 /* OBSOLETE */
if( *g.pl_character ){
g.pl_character[ 0 ] = toupper( g.pl_character[ 0 ] );
if( index( pl_classes, g.pl_character[ 0 ] ) )
if( strchr( pl_classes, g.pl_character[ 0 ] ) )
return;
}
#endif
@@ -528,7 +528,7 @@ amii_player_selection()
switch( class )
{
case VANILLAKEY:
if( index( pl_classes, toupper( code ) ) )
if( strchr( pl_classes, toupper( code ) ) )
{
g.pl_character[0] = toupper( code );
aredone = 1;
@@ -1016,10 +1016,10 @@ char def;
if (resp) {
char *rb, respbuf[QBUFSZ];
allow_num = (index(resp, '#') != 0);
allow_num = (strchr(resp, '#') != 0);
Strcpy(respbuf, resp);
/* any acceptable responses that follow <esc> aren't displayed */
if ((rb = index(respbuf, '\033')) != 0)
if ((rb = strchr(respbuf, '\033')) != 0)
*rb = '\0';
(void) strncpy(prompt, query, QBUFSZ - 1);
prompt[QBUFSZ - 1] = '\0';
@@ -1062,18 +1062,18 @@ char def;
#endif /*0*/
digit_ok = allow_num && isdigit(q);
if (q == '\033') {
if (index(resp, 'q'))
if (strchr(resp, 'q'))
q = 'q';
else if (index(resp, 'n'))
else if (strchr(resp, 'n'))
q = 'n';
else
q = def;
break;
} else if (index(quitchars, q)) {
} else if (strchr(quitchars, q)) {
q = def;
break;
}
if (!index(resp, q) && !digit_ok) {
if (!strchr(resp, q) && !digit_ok) {
amii_bell();
q = (char) 0;
} else if (q == '#' || digit_ok) {
@@ -1099,7 +1099,7 @@ char def;
break; /* overflow: try again */
digit_string[0] = z;
amii_addtopl(digit_string), n_len++;
} else if (z == 'y' || index(quitchars, z)) {
} else if (z == 'y' || strchr(quitchars, z)) {
if (z == '\033')
value = -1; /* abort */
z = '\n'; /* break */
@@ -1176,7 +1176,7 @@ boolean complain;
cw->morestr = (char *) fn;
while (dlb_fgets(buf, sizeof(buf), fp) != NULL) {
if (t = index(buf, '\n'))
if (t = strchr(buf, '\n'))
*t = 0;
amii_putstr(win, 0, buf);
}
@@ -1362,9 +1362,9 @@ amii_player_selection()
cursor_on(WIN_MESSAGE);
pick4u = lowc(WindowGetchar());
cursor_off(WIN_MESSAGE);
if (index(quitchars, pick4u))
if (strchr(quitchars, pick4u))
pick4u = 'y';
} while (!index(ynqchars, pick4u));
} while (!strchr(ynqchars, pick4u));
pbuf[0] = pick4u;
pbuf[1] = 0;
amii_addtopl(pbuf);