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:
@@ -4799,11 +4799,11 @@ void NetHackQtBind::qt_display_file(const char *filename, BOOLEAN_P must_exist)
|
||||
complain = must_exist;
|
||||
} else {
|
||||
while (dlb_fgets(buf, BUFSZ, f)) {
|
||||
if ((cr = index(buf, '\n')) != 0) *cr = 0;
|
||||
if ((cr = strchr(buf, '\n')) != 0) *cr = 0;
|
||||
#ifdef MSDOS
|
||||
if ((cr = index(buf, '\r')) != 0) *cr = 0;
|
||||
if ((cr = strchr(buf, '\r')) != 0) *cr = 0;
|
||||
#endif
|
||||
if (index(buf, '\t') != 0) (void) tabexpand(buf);
|
||||
if (strchr(buf, '\t') != 0) (void) tabexpand(buf);
|
||||
window->PutStr(ATR_NONE, buf);
|
||||
}
|
||||
window->Display(FALSE);
|
||||
@@ -4981,7 +4981,7 @@ char NetHackQtBind::qt_yn_function(const char *question, const char *choices, CH
|
||||
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';
|
||||
}
|
||||
@@ -4991,8 +4991,8 @@ char NetHackQtBind::qt_yn_function(const char *question, const char *choices, CH
|
||||
if (def) Sprintf(eos(message), " (%c)", 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));
|
||||
yn_esc_map = (strchr(choices, 'q') ? 'q' :
|
||||
(strchr(choices, 'n') ? 'n' : def));
|
||||
} else {
|
||||
Strcpy(message, question);
|
||||
}
|
||||
@@ -5024,7 +5024,7 @@ char NetHackQtBind::qt_yn_function(const char *question, const char *choices, CH
|
||||
char ch=NetHackQtBind::qt_nhgetch();
|
||||
if (ch=='\033') {
|
||||
result=yn_esc_map;
|
||||
} else if (choices && !index(choices,ch)) {
|
||||
} else if (choices && !strchr(choices,ch)) {
|
||||
if (def && (ch==' ' || ch=='\r' || ch=='\n')) {
|
||||
result=def;
|
||||
} else {
|
||||
|
||||
@@ -736,9 +736,9 @@ boolean complain;
|
||||
|
||||
datawin = Gem_create_nhwindow(NHW_TEXT);
|
||||
while (dlb_fgets(buf, BUFSZ, f)) {
|
||||
if ((cr = index(buf, '\n')) != 0)
|
||||
if ((cr = strchr(buf, '\n')) != 0)
|
||||
*cr = 0;
|
||||
if (index(buf, '\t') != 0)
|
||||
if (strchr(buf, '\t') != 0)
|
||||
(void) tabexpand(buf);
|
||||
Gem_putstr(datawin, 0, buf);
|
||||
}
|
||||
|
||||
@@ -1032,7 +1032,7 @@ gnome_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';
|
||||
}
|
||||
@@ -1044,13 +1044,13 @@ gnome_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);
|
||||
}
|
||||
|
||||
gnome_putstr(WIN_MESSAGE, ATR_BOLD, message);
|
||||
if (mainWnd != NULL && choices && !index(choices, ch)) {
|
||||
if (mainWnd != NULL && choices && !strchr(choices, ch)) {
|
||||
return (ghack_yes_no_dialog(question, choices, def));
|
||||
}
|
||||
|
||||
@@ -1059,7 +1059,7 @@ gnome_yn_function(const char *question, const char *choices, CHAR_P def)
|
||||
ch = gnome_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)) {
|
||||
|
||||
Reference in New Issue
Block a user