aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-04-16 10:24:48 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-04-16 10:24:48 +0200
commit058a153b6970660f3c284ac259986ae87507df9a (patch)
treea43cce5c5cdfd826aa15955bb53b8dbcceec0a6b
parentc72499584abbf32b3757024bb0cd53f23d5d0d72 (diff)
downloadbusybox-w32-058a153b6970660f3c284ac259986ae87507df9a.tar.gz
busybox-w32-058a153b6970660f3c284ac259986ae87507df9a.tar.bz2
busybox-w32-058a153b6970660f3c284ac259986ae87507df9a.zip
less: fix fallout from "use common routine to set raw termios"
Testcase: (sleep 10; ls) | busybox less [...] ~ LICENSE ~ Makefile ~ Makefile.custom ~ Makefile.flags [...] less did not want this part: + /* dont convert NL to CR+NL on output */ + newterm->c_oflag &= ~(ONLCR); function old new delta get_termios_and_make_raw 108 115 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/libbb.h8
-rw-r--r--libbb/xfuncs.c13
-rw-r--r--miscutils/less.c2
3 files changed, 15 insertions, 8 deletions
diff --git a/include/libbb.h b/include/libbb.h
index c7bf33ef8..646c58bf2 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1597,9 +1597,11 @@ int get_terminal_width_height(int fd, unsigned *width, unsigned *height) FAST_FU
1597int get_terminal_width(int fd) FAST_FUNC; 1597int get_terminal_width(int fd) FAST_FUNC;
1598 1598
1599int tcsetattr_stdin_TCSANOW(const struct termios *tp) FAST_FUNC; 1599int tcsetattr_stdin_TCSANOW(const struct termios *tp) FAST_FUNC;
1600#define TERMIOS_CLEAR_ISIG (1 << 0) 1600#define TERMIOS_CLEAR_ISIG (1 << 0)
1601#define TERMIOS_RAW_CRNL (1 << 1) 1601#define TERMIOS_RAW_CRNL_INPUT (1 << 1)
1602#define TERMIOS_RAW_INPUT (1 << 2) 1602#define TERMIOS_RAW_CRNL_OUTPUT (1 << 2)
1603#define TERMIOS_RAW_CRNL (TERMIOS_RAW_CRNL_INPUT|TERMIOS_RAW_CRNL_OUTPUT)
1604#define TERMIOS_RAW_INPUT (1 << 3)
1603int get_termios_and_make_raw(int fd, struct termios *newterm, struct termios *oldterm, int flags) FAST_FUNC; 1605int get_termios_and_make_raw(int fd, struct termios *newterm, struct termios *oldterm, int flags) FAST_FUNC;
1604int set_termios_to_raw(int fd, struct termios *oldterm, int flags) FAST_FUNC; 1606int set_termios_to_raw(int fd, struct termios *oldterm, int flags) FAST_FUNC;
1605 1607
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index e8c027f17..b4d512bd6 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -330,7 +330,6 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t
330 newterm->c_cc[VMIN] = 1; 330 newterm->c_cc[VMIN] = 1;
331 /* no timeout (reads block forever) */ 331 /* no timeout (reads block forever) */
332 newterm->c_cc[VTIME] = 0; 332 newterm->c_cc[VTIME] = 0;
333 if (flags & TERMIOS_RAW_CRNL) {
334/* IXON, IXOFF, and IXANY: 333/* IXON, IXOFF, and IXANY:
335 * IXOFF=1: sw flow control is enabled on input queue: 334 * IXOFF=1: sw flow control is enabled on input queue:
336 * tty transmits a STOP char when input queue is close to full 335 * tty transmits a STOP char when input queue is close to full
@@ -340,9 +339,12 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t
340 * and resume sending if START is received, or if any char 339 * and resume sending if START is received, or if any char
341 * is received and IXANY=1. 340 * is received and IXANY=1.
342 */ 341 */
342 if (flags & TERMIOS_RAW_CRNL_INPUT) {
343 /* IXON=0: XON/XOFF chars are treated as normal chars (why we do this?) */ 343 /* IXON=0: XON/XOFF chars are treated as normal chars (why we do this?) */
344 /* dont convert CR to NL on input */ 344 /* dont convert CR to NL on input */
345 newterm->c_iflag &= ~(IXON | ICRNL); 345 newterm->c_iflag &= ~(IXON | ICRNL);
346 }
347 if (flags & TERMIOS_RAW_CRNL_OUTPUT) {
346 /* dont convert NL to CR+NL on output */ 348 /* dont convert NL to CR+NL on output */
347 newterm->c_oflag &= ~(ONLCR); 349 newterm->c_oflag &= ~(ONLCR);
348 /* Maybe clear more c_oflag bits? Usually, only OPOST and ONLCR are set. 350 /* Maybe clear more c_oflag bits? Usually, only OPOST and ONLCR are set.
@@ -363,9 +365,12 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t
363#ifndef IXANY 365#ifndef IXANY
364# define IXANY 0 366# define IXANY 0
365#endif 367#endif
366 /* IXOFF=0: disable sending XON/XOFF if input buf is full */ 368 /* IXOFF=0: disable sending XON/XOFF if input buf is full
367 /* IXON=0: input XON/XOFF chars are not special */ 369 * IXON=0: input XON/XOFF chars are not special
368 /* dont convert anything on input */ 370 * BRKINT=0: dont send SIGINT on break
371 * IMAXBEL=0: dont echo BEL on input line too long
372 * INLCR,ICRNL,IUCLC: dont convert anything on input
373 */
369 newterm->c_iflag &= ~(IXOFF|IXON|IXANY|BRKINT|INLCR|ICRNL|IUCLC|IMAXBEL); 374 newterm->c_iflag &= ~(IXOFF|IXON|IXANY|BRKINT|INLCR|ICRNL|IUCLC|IMAXBEL);
370 } 375 }
371 return r; 376 return r;
diff --git a/miscutils/less.c b/miscutils/less.c
index 6029b6809..938d9842f 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -1891,7 +1891,7 @@ int less_main(int argc, char **argv)
1891 G.kbd_fd_orig_flags = ndelay_on(tty_fd); 1891 G.kbd_fd_orig_flags = ndelay_on(tty_fd);
1892 kbd_fd = tty_fd; /* save in a global */ 1892 kbd_fd = tty_fd; /* save in a global */
1893 1893
1894 get_termios_and_make_raw(tty_fd, &term_less, &term_orig, TERMIOS_RAW_CRNL); 1894 get_termios_and_make_raw(tty_fd, &term_less, &term_orig, TERMIOS_RAW_CRNL_INPUT);
1895 1895
1896 IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(tty_fd, &width, &max_displayed_line); 1896 IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(tty_fd, &width, &max_displayed_line);
1897 /* 20: two tabstops + 4 */ 1897 /* 20: two tabstops + 4 */