summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDenys Vlasenko2017-01-11 16:17:59 +0100
committerDenys Vlasenko2017-01-11 16:17:59 +0100
commit01ccdd1d3c5221789f1ac62ced12b7984d910705 (patch)
treea6eb44f24c1324ddf18bfcec57fd4c3735aa1245 /editors
parent8944c67b1f61ca6a51a485772d5d1e6a8ff3d83d (diff)
downloadbusybox-01ccdd1d3c5221789f1ac62ced12b7984d910705.zip
busybox-01ccdd1d3c5221789f1ac62ced12b7984d910705.tar.gz
libbb: consolidate the code to set termios unbuffered mode
function old new delta set_termios_to_raw - 116 +116 count_lines 72 74 +2 powertop_main 1458 1430 -28 top_main 943 914 -29 more_main 759 714 -45 fsck_minix_main 2969 2921 -48 conspy_main 1197 1135 -62 rawmode 99 36 -63 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/6 up/down: 118/-275) Total: -157 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r--editors/vi.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/editors/vi.c b/editors/vi.c
index b56b04b..1e5ef44 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -354,7 +354,7 @@ struct globals {
#if ENABLE_FEATURE_VI_USE_SIGNALS
sigjmp_buf restart; // catch_sig()
#endif
- struct termios term_orig, term_vi; // remember what the cooked mode was
+ struct termios term_orig; // remember what the cooked mode was
#if ENABLE_FEATURE_VI_COLON
char *initial_cmds[3]; // currently 2 entries, NULL terminated
#endif
@@ -462,7 +462,6 @@ struct globals {
#define context_end (G.context_end )
#define restart (G.restart )
#define term_orig (G.term_orig )
-#define term_vi (G.term_vi )
#define initial_cmds (G.initial_cmds )
#define readbuffer (G.readbuffer )
#define scr_out_buf (G.scr_out_buf )
@@ -2731,15 +2730,9 @@ static char *swap_context(char *p) // goto new context for '' command make this
//----- Set terminal attributes --------------------------------
static void rawmode(void)
{
- tcgetattr(0, &term_orig);
- term_vi = term_orig;
- term_vi.c_lflag &= (~ICANON & ~ECHO); // leave ISIG on - allow intr's
- term_vi.c_iflag &= (~IXON & ~ICRNL);
- term_vi.c_oflag &= (~ONLCR);
- term_vi.c_cc[VMIN] = 1;
- term_vi.c_cc[VTIME] = 0;
- erase_char = term_vi.c_cc[VERASE];
- tcsetattr_stdin_TCSANOW(&term_vi);
+ // no TERMIOS_CLEAR_ISIG: leave ISIG on - allow signals
+ set_termios_to_raw(STDIN_FILENO, &term_orig, TERMIOS_RAW_CRNL);
+ erase_char = term_orig.c_cc[VERASE];
}
static void cookmode(void)