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

@@ -193,22 +193,22 @@ mswin_color_from_string(char *colorstring, HBRUSH *brushptr,
return;
red_value =
index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
strchr(hexadecimals, tolower(*colorstring++)) - hexadecimals;
red_value *= 16;
red_value +=
index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
strchr(hexadecimals, tolower(*colorstring++)) - hexadecimals;
green_value =
index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
strchr(hexadecimals, tolower(*colorstring++)) - hexadecimals;
green_value *= 16;
green_value +=
index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
strchr(hexadecimals, tolower(*colorstring++)) - hexadecimals;
blue_value =
index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
strchr(hexadecimals, tolower(*colorstring++)) - hexadecimals;
blue_value *= 16;
blue_value +=
index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
strchr(hexadecimals, tolower(*colorstring++)) - hexadecimals;
*colorptr = RGB(red_value, blue_value, green_value);
} else {

View File

@@ -316,9 +316,9 @@ prompt_for_player_selection(void)
/* tty_putstr(BASE_WINDOW, 0, prompt); */
do {
/* pick4u = lowc(readchar()); */
if (index(quitchars, pick4u))
if (strchr(quitchars, pick4u))
pick4u = 'y';
} while (!index(ynqchars, pick4u));
} while (!strchr(ynqchars, pick4u));
if ((int) strlen(prompt) + 1 < CO) {
/* Echo choice and move back down line */
/* tty_putsym(BASE_WINDOW, (int)strlen(prompt)+1, echoline,
@@ -1377,7 +1377,7 @@ mswin_yn_function(const char *question, const char *choices, CHAR_P def)
if (choices) {
char *cb, choicebuf[QBUFSZ];
Strcpy(choicebuf, choices);
if ((cb = index(choicebuf, '\033')) != 0) {
if ((cb = strchr(choicebuf, '\033')) != 0) {
/* anything beyond <esc> is hidden */
*cb = '\0';
}
@@ -1389,7 +1389,7 @@ mswin_yn_function(const char *question, const char *choices, CHAR_P def)
Strcat(message, " ");
/* escape maps to 'q' or 'n' or default, in that order */
yn_esc_map =
(index(choices, 'q') ? 'q' : (index(choices, 'n') ? 'n' : def));
(strchr(choices, 'q') ? 'q' : (strchr(choices, 'n') ? 'n' : def));
} else {
Strcpy(message, question);
}
@@ -1399,7 +1399,7 @@ mswin_yn_function(const char *question, const char *choices, CHAR_P def)
char buf[BUFSZ];
ZeroMemory(buf, sizeof(buf));
if (choices) {
if (!index(choices, '\033'))
if (!strchr(choices, '\033'))
buf[0] = '\033'; /* make sure ESC is always available */
strncat(buf, choices, sizeof(buf) - 2);
NHSPhoneSetKeypadFromString(buf);
@@ -1431,7 +1431,7 @@ mswin_yn_function(const char *question, const char *choices, CHAR_P def)
ch = mswin_nhgetch();
if (ch == '\033') {
result = yn_esc_map;
} else if (choices && !index(choices, ch)) {
} else if (choices && !strchr(choices, ch)) {
/* FYI: ch==-115 is for KP_ENTER */
if (def
&& (ch == ' ' || ch == '\r' || ch == '\n' || ch == -115)) {