aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-07-25 00:06:41 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-07-25 00:06:41 +0200
commit451add4f23c14459734e05104ea0bc5ed4de39ee (patch)
tree644c8ca77f1d6052ca089bda2f22c9a9ae17f601
parent2e9b5510d687e5418bea85c3b04ad1e1fa797b6f (diff)
downloadbusybox-w32-451add4f23c14459734e05104ea0bc5ed4de39ee.tar.gz
busybox-w32-451add4f23c14459734e05104ea0bc5ed4de39ee.tar.bz2
busybox-w32-451add4f23c14459734e05104ea0bc5ed4de39ee.zip
lineedit: mostly revert recent wrong logic in "ask terminal" code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/lineedit.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index a62ab6d29..6df556f4e 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -149,7 +149,6 @@ struct lineedit_statics {
149 CHAR_T delbuf[DELBUFSIZ]; /* a place to store deleted characters */ 149 CHAR_T delbuf[DELBUFSIZ]; /* a place to store deleted characters */
150#endif 150#endif
151#if ENABLE_FEATURE_EDITING_ASK_TERMINAL 151#if ENABLE_FEATURE_EDITING_ASK_TERMINAL
152 smallint unknown_width;
153 smallint sent_ESC_br6n; 152 smallint sent_ESC_br6n;
154#endif 153#endif
155 154
@@ -1611,16 +1610,14 @@ static void ask_terminal(void)
1611 * poll([{fd=0, events=POLLIN}], 1, 4294967295) = 1 ([{fd=0, revents=POLLIN}]) 1610 * poll([{fd=0, events=POLLIN}], 1, 4294967295) = 1 ([{fd=0, revents=POLLIN}])
1612 * read(0, "\n", 1) = 1 <-- oh crap, user's input got in first 1611 * read(0, "\n", 1) = 1 <-- oh crap, user's input got in first
1613 */ 1612 */
1614 if (S.unknown_width) { /* only if window size is not known */ 1613 struct pollfd pfd;
1615 struct pollfd pfd; 1614
1616 1615 pfd.fd = STDIN_FILENO;
1617 pfd.fd = STDIN_FILENO; 1616 pfd.events = POLLIN;
1618 pfd.events = POLLIN; 1617 if (safe_poll(&pfd, 1, 0) == 0) {
1619 if (safe_poll(&pfd, 1, 0) == 0) { 1618 S.sent_ESC_br6n = 1;
1620 S.sent_ESC_br6n = 1; 1619 fputs("\033" "[6n", stdout);
1621 fputs("\033" "[6n", stdout); 1620 fflush_all(); /* make terminal see it ASAP! */
1622 fflush_all(); /* make terminal see it ASAP! */
1623 }
1624 } 1621 }
1625} 1622}
1626#else 1623#else
@@ -1768,7 +1765,7 @@ static void win_changed(int nsig)
1768{ 1765{
1769 int sv_errno = errno; 1766 int sv_errno = errno;
1770 unsigned width; 1767 unsigned width;
1771 IF_FEATURE_EDITING_ASK_TERMINAL(S.unknown_width =) get_terminal_width_height(0, &width, NULL); 1768 get_terminal_width_height(0, &width, NULL);
1772 cmdedit_setwidth(width, nsig /* - just a yes/no flag */); 1769 cmdedit_setwidth(width, nsig /* - just a yes/no flag */);
1773 if (nsig == SIGWINCH) 1770 if (nsig == SIGWINCH)
1774 signal(SIGWINCH, win_changed); /* rearm ourself */ 1771 signal(SIGWINCH, win_changed); /* rearm ourself */