summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko2010-07-18 22:53:06 +0200
committerDenys Vlasenko2010-07-18 22:53:06 +0200
commit55241fa2e0a623c6f3f3f9c6e430d72bc10858bc (patch)
treefc8334e2cfd277eb237c1d35f902f2ebda19addb /libbb
parentb9e35dc15dbf8aa22dbc260d121ad8f7a34017de (diff)
downloadbusybox-55241fa2e0a623c6f3f3f9c6e430d72bc10858bc.zip
busybox-55241fa2e0a623c6f3f3f9c6e430d72bc10858bc.tar.gz
lineedit: limit ASK_TERMINAL to the case when we can't find out the width
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/lineedit.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 3905b8c..a62ab6d 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -149,6 +149,7 @@ struct lineedit_statics {
CHAR_T delbuf[DELBUFSIZ]; /* a place to store deleted characters */
#endif
#if ENABLE_FEATURE_EDITING_ASK_TERMINAL
+ smallint unknown_width;
smallint sent_ESC_br6n;
#endif
@@ -1610,14 +1611,16 @@ static void ask_terminal(void)
* poll([{fd=0, events=POLLIN}], 1, 4294967295) = 1 ([{fd=0, revents=POLLIN}])
* read(0, "\n", 1) = 1 <-- oh crap, user's input got in first
*/
- struct pollfd pfd;
-
- pfd.fd = STDIN_FILENO;
- pfd.events = POLLIN;
- if (safe_poll(&pfd, 1, 0) == 0) {
- S.sent_ESC_br6n = 1;
- fputs("\033" "[6n", stdout);
- fflush_all(); /* make terminal see it ASAP! */
+ if (S.unknown_width) { /* only if window size is not known */
+ struct pollfd pfd;
+
+ pfd.fd = STDIN_FILENO;
+ pfd.events = POLLIN;
+ if (safe_poll(&pfd, 1, 0) == 0) {
+ S.sent_ESC_br6n = 1;
+ fputs("\033" "[6n", stdout);
+ fflush_all(); /* make terminal see it ASAP! */
+ }
}
}
#else
@@ -1763,11 +1766,13 @@ static void cmdedit_setwidth(unsigned w, int redraw_flg)
static void win_changed(int nsig)
{
+ int sv_errno = errno;
unsigned width;
- get_terminal_width_height(0, &width, NULL);
+ IF_FEATURE_EDITING_ASK_TERMINAL(S.unknown_width =) get_terminal_width_height(0, &width, NULL);
cmdedit_setwidth(width, nsig /* - just a yes/no flag */);
if (nsig == SIGWINCH)
signal(SIGWINCH, win_changed); /* rearm ourself */
+ errno = sv_errno;
}
static int lineedit_read_key(char *read_key_buffer)