yn_function (trunk only)
Explicitly truncate the query prompt string to QBUFSZ-1 characters. For tty and Amiga, no longer include the choices and default within that length limit; use a bigger buffer to hold them along with the prompt. [See cvs log for doc/window.doc for more details.]
This commit is contained in:
+8
-5
@@ -1094,7 +1094,7 @@ char def;
|
|||||||
register char q;
|
register char q;
|
||||||
char rtmp[40];
|
char rtmp[40];
|
||||||
boolean digit_ok, allow_num;
|
boolean digit_ok, allow_num;
|
||||||
char prompt[QBUFSZ];
|
char prompt[BUFSZ];
|
||||||
register struct amii_WinDesc *cw;
|
register struct amii_WinDesc *cw;
|
||||||
|
|
||||||
if( cw = amii_wins[ WIN_MESSAGE ] )
|
if( cw = amii_wins[ WIN_MESSAGE ] )
|
||||||
@@ -1102,13 +1102,16 @@ char def;
|
|||||||
if (resp) {
|
if (resp) {
|
||||||
char *rb, respbuf[QBUFSZ];
|
char *rb, respbuf[QBUFSZ];
|
||||||
|
|
||||||
allow_num = (index(resp, '#') != 0);
|
allow_num = (index(resp, '#') != 0);
|
||||||
Strcpy(respbuf, resp);
|
Strcpy(respbuf, resp);
|
||||||
/* any acceptable responses that follow <esc> aren't displayed */
|
/* any acceptable responses that follow <esc> aren't displayed */
|
||||||
if ((rb = index(respbuf, '\033')) != 0) *rb = '\0';
|
if ((rb = index(respbuf, '\033')) != 0) *rb = '\0';
|
||||||
Sprintf(prompt, "%s [%s] ", query, respbuf);
|
(void)strncpy(prompt, query, QBUFSZ-1);
|
||||||
if (def) Sprintf(eos(prompt), "(%c) ", def);
|
prompt[QBUFSZ-1] = '\0';
|
||||||
pline("%s", prompt);
|
Sprintf(eos(prompt), " [%s]", respbuf);
|
||||||
|
if (def) Sprintf(eos(prompt), " (%c)", def);
|
||||||
|
Strcat(prompt, " ");
|
||||||
|
pline("%s", prompt);
|
||||||
} else {
|
} else {
|
||||||
amii_putstr(WIN_MESSAGE, 0, query);
|
amii_putstr(WIN_MESSAGE, 0, query);
|
||||||
cursor_on(WIN_MESSAGE);
|
cursor_on(WIN_MESSAGE);
|
||||||
|
|||||||
+5
-2
@@ -1392,8 +1392,11 @@ char mswin_yn_function(const char *question, const char *choices,
|
|||||||
/* anything beyond <esc> is hidden */
|
/* anything beyond <esc> is hidden */
|
||||||
*cb = '\0';
|
*cb = '\0';
|
||||||
}
|
}
|
||||||
sprintf(message, "%s [%s] ", question, choicebuf);
|
(void)strncpy(message, question, QBUFSZ-1);
|
||||||
if (def) sprintf(eos(message), "(%c) ", def);
|
message[QBUFSZ-1] = '\0';
|
||||||
|
sprintf(eos(message), " [%s]", choicebuf);
|
||||||
|
if (def) sprintf(eos(message), " (%c)", def);
|
||||||
|
Strcat(message, " ");
|
||||||
/* escape maps to 'q' or 'n' or default, in that order */
|
/* escape maps to 'q' or 'n' or default, in that order */
|
||||||
yn_esc_map = (index(choices, 'q') ? 'q' :
|
yn_esc_map = (index(choices, 'q') ? 'q' :
|
||||||
(index(choices, 'n') ? 'n' : def));
|
(index(choices, 'n') ? 'n' : def));
|
||||||
|
|||||||
+5
-2
@@ -4963,8 +4963,11 @@ char NetHackQtBind::qt_yn_function(const char *question, const char *choices, CH
|
|||||||
// anything beyond <esc> is hidden
|
// anything beyond <esc> is hidden
|
||||||
*cb = '\0';
|
*cb = '\0';
|
||||||
}
|
}
|
||||||
Sprintf(message, "%s [%s] ", question, choicebuf);
|
(void)strncpy(message, question, QBUFSZ-1);
|
||||||
if (def) Sprintf(eos(message), "(%c) ", def);
|
message[QBUFSZ-1] = '\0';
|
||||||
|
Sprintf(eos(message), " [%s]", choicebuf);
|
||||||
|
if (def) Sprintf(eos(message), " (%c)", def);
|
||||||
|
Strcat(message, " ");
|
||||||
// escape maps to 'q' or 'n' or default, in that order
|
// escape maps to 'q' or 'n' or default, in that order
|
||||||
yn_esc_map = (index(choices, 'q') ? 'q' :
|
yn_esc_map = (index(choices, 'q') ? 'q' :
|
||||||
(index(choices, 'n') ? 'n' : def));
|
(index(choices, 'n') ? 'n' : def));
|
||||||
|
|||||||
+11
-7
@@ -1669,7 +1669,7 @@ X11_yn_function(ques, choices, def)
|
|||||||
char def;
|
char def;
|
||||||
{
|
{
|
||||||
static Boolean need_to_init = True;
|
static Boolean need_to_init = True;
|
||||||
char buf[QBUFSZ];
|
char buf[BUFSZ];
|
||||||
Arg args[4];
|
Arg args[4];
|
||||||
Cardinal num_args;
|
Cardinal num_args;
|
||||||
|
|
||||||
@@ -1692,19 +1692,23 @@ X11_yn_function(ques, choices, def)
|
|||||||
Strcpy(choicebuf, choices); /* anything beyond <esc> is hidden */
|
Strcpy(choicebuf, choices); /* anything beyond <esc> is hidden */
|
||||||
if ((cb = index(choicebuf, '\033')) != 0) *cb = '\0';
|
if ((cb = index(choicebuf, '\033')) != 0) *cb = '\0';
|
||||||
/* ques [choices] (def) */
|
/* ques [choices] (def) */
|
||||||
if ((int)(1 + strlen(ques) + 2 + strlen(choicebuf) + 4) >= QBUFSZ)
|
if ((int)(1 + strlen(ques) + 2 + strlen(choicebuf) + 4) >= BUFSZ)
|
||||||
panic("yn_function: question too long");
|
panic("X11_yn_function: question too long");
|
||||||
Sprintf(buf, "%s [%s] ", ques, choicebuf);
|
(void)strncpy(buf, ques, QBUFSZ-1);
|
||||||
if (def) Sprintf(eos(buf), "(%c) ", def);
|
buf[QBUFSZ-1] = '\0';
|
||||||
|
Sprintf(eos(buf), " [%s]", choicebuf);
|
||||||
|
if (def) Sprintf(eos(buf), " (%c)", def);
|
||||||
|
Strcat(buf, " ");
|
||||||
|
|
||||||
/* escape maps to 'q' or 'n' or default, in that order */
|
/* escape maps to 'q' or 'n' or default, in that order */
|
||||||
yn_esc_map = (index(choices, 'q') ? 'q' :
|
yn_esc_map = (index(choices, 'q') ? 'q' :
|
||||||
(index(choices, 'n') ? 'n' :
|
(index(choices, 'n') ? 'n' :
|
||||||
def));
|
def));
|
||||||
} else {
|
} else {
|
||||||
if ((int)(1 + strlen(ques)) >= QBUFSZ)
|
if ((int)(1 + strlen(ques) + 1) >= BUFSZ)
|
||||||
panic("yn_function: question too long");
|
panic("X11_yn_function: question too long");
|
||||||
Strcpy(buf, ques);
|
Strcpy(buf, ques);
|
||||||
|
Strcat(buf, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!appResources.slow && need_to_init) {
|
if (!appResources.slow && need_to_init) {
|
||||||
|
|||||||
+5
-2
@@ -1050,8 +1050,11 @@ char gnome_yn_function(const char *question, const char *choices,
|
|||||||
/* anything beyond <esc> is hidden */
|
/* anything beyond <esc> is hidden */
|
||||||
*cb = '\0';
|
*cb = '\0';
|
||||||
}
|
}
|
||||||
sprintf(message, "%s [%s] ", question, choicebuf);
|
(void)strncpy(message, question, QBUFSZ-1);
|
||||||
if (def) sprintf(eos(message), "(%c) ", def);
|
message[QBUFSZ-1] = '\0';
|
||||||
|
sprintf(eos(message), " [%s]", choicebuf);
|
||||||
|
if (def) sprintf(eos(message), " (%c)", def);
|
||||||
|
Strcat(message, " ");
|
||||||
/* escape maps to 'q' or 'n' or default, in that order */
|
/* escape maps to 'q' or 'n' or default, in that order */
|
||||||
yn_esc_map = (index(choices, 'q') ? 'q' :
|
yn_esc_map = (index(choices, 'q') ? 'q' :
|
||||||
(index(choices, 'n') ? 'n' : def));
|
(index(choices, 'n') ? 'n' : def));
|
||||||
|
|||||||
+9
-4
@@ -425,9 +425,9 @@ char def;
|
|||||||
boolean digit_ok, allow_num;
|
boolean digit_ok, allow_num;
|
||||||
struct WinDesc *cw = wins[WIN_MESSAGE];
|
struct WinDesc *cw = wins[WIN_MESSAGE];
|
||||||
boolean doprev = 0;
|
boolean doprev = 0;
|
||||||
char prompt[QBUFSZ];
|
char prompt[BUFSZ];
|
||||||
#ifdef UNICODE_WIDEWINPORT
|
#ifdef UNICODE_WIDEWINPORT
|
||||||
nhwchar wprompt[QBUFSZ];
|
nhwchar wprompt[BUFSZ];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP)) more();
|
if(ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP)) more();
|
||||||
@@ -441,8 +441,13 @@ char def;
|
|||||||
Strcpy(respbuf, resp);
|
Strcpy(respbuf, resp);
|
||||||
/* any acceptable responses that follow <esc> aren't displayed */
|
/* any acceptable responses that follow <esc> aren't displayed */
|
||||||
if ((rb = index(respbuf, '\033')) != 0) *rb = '\0';
|
if ((rb = index(respbuf, '\033')) != 0) *rb = '\0';
|
||||||
Sprintf(prompt, "%s [%s] ", query, respbuf);
|
(void)strncpy(prompt, query, QBUFSZ-1);
|
||||||
if (def) Sprintf(eos(prompt), "(%c) ", def);
|
prompt[QBUFSZ-1] = '\0';
|
||||||
|
Sprintf(eos(prompt), " [%s]", respbuf);
|
||||||
|
if (def) Sprintf(eos(prompt), " (%c)", def);
|
||||||
|
/* not pline("%s ", prompt);
|
||||||
|
trailing space is wanted here in case of reprompt */
|
||||||
|
Strcat(prompt, " ");
|
||||||
pline("%s", prompt);
|
pline("%s", prompt);
|
||||||
} else {
|
} else {
|
||||||
pline("%s ", query);
|
pline("%s ", query);
|
||||||
|
|||||||
+5
-2
@@ -1447,8 +1447,11 @@ char mswin_yn_function(const char *question, const char *choices,
|
|||||||
/* anything beyond <esc> is hidden */
|
/* anything beyond <esc> is hidden */
|
||||||
*cb = '\0';
|
*cb = '\0';
|
||||||
}
|
}
|
||||||
sprintf(message, "%s [%s] ", question, choicebuf);
|
(void)strncpy(message, question, QBUFSZ-1);
|
||||||
if (def) sprintf(eos(message), "(%c) ", def);
|
message[QBUFSZ-1] = '\0';
|
||||||
|
sprintf(eos(message), " [%s]", choicebuf);
|
||||||
|
if (def) sprintf(eos(message), " (%c)", def);
|
||||||
|
Strcat(message, " ");
|
||||||
/* escape maps to 'q' or 'n' or default, in that order */
|
/* escape maps to 'q' or 'n' or default, in that order */
|
||||||
yn_esc_map = (index(choices, 'q') ? 'q' :
|
yn_esc_map = (index(choices, 'q') ? 'q' :
|
||||||
(index(choices, 'n') ? 'n' : def));
|
(index(choices, 'n') ? 'n' : def));
|
||||||
|
|||||||
Reference in New Issue
Block a user