aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-01-11 16:17:59 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2017-01-11 16:17:59 +0100
commit01ccdd1d3c5221789f1ac62ced12b7984d910705 (patch)
treea6eb44f24c1324ddf18bfcec57fd4c3735aa1245 /editors
parent8944c67b1f61ca6a51a485772d5d1e6a8ff3d83d (diff)
downloadbusybox-w32-01ccdd1d3c5221789f1ac62ced12b7984d910705.tar.gz
busybox-w32-01ccdd1d3c5221789f1ac62ced12b7984d910705.tar.bz2
busybox-w32-01ccdd1d3c5221789f1ac62ced12b7984d910705.zip
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 b56b04bdd..1e5ef44fb 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -354,7 +354,7 @@ struct globals {
354#if ENABLE_FEATURE_VI_USE_SIGNALS 354#if ENABLE_FEATURE_VI_USE_SIGNALS
355 sigjmp_buf restart; // catch_sig() 355 sigjmp_buf restart; // catch_sig()
356#endif 356#endif
357 struct termios term_orig, term_vi; // remember what the cooked mode was 357 struct termios term_orig; // remember what the cooked mode was
358#if ENABLE_FEATURE_VI_COLON 358#if ENABLE_FEATURE_VI_COLON
359 char *initial_cmds[3]; // currently 2 entries, NULL terminated 359 char *initial_cmds[3]; // currently 2 entries, NULL terminated
360#endif 360#endif
@@ -462,7 +462,6 @@ struct globals {
462#define context_end (G.context_end ) 462#define context_end (G.context_end )
463#define restart (G.restart ) 463#define restart (G.restart )
464#define term_orig (G.term_orig ) 464#define term_orig (G.term_orig )
465#define term_vi (G.term_vi )
466#define initial_cmds (G.initial_cmds ) 465#define initial_cmds (G.initial_cmds )
467#define readbuffer (G.readbuffer ) 466#define readbuffer (G.readbuffer )
468#define scr_out_buf (G.scr_out_buf ) 467#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
2731//----- Set terminal attributes -------------------------------- 2730//----- Set terminal attributes --------------------------------
2732static void rawmode(void) 2731static void rawmode(void)
2733{ 2732{
2734 tcgetattr(0, &term_orig); 2733 // no TERMIOS_CLEAR_ISIG: leave ISIG on - allow signals
2735 term_vi = term_orig; 2734 set_termios_to_raw(STDIN_FILENO, &term_orig, TERMIOS_RAW_CRNL);
2736 term_vi.c_lflag &= (~ICANON & ~ECHO); // leave ISIG on - allow intr's 2735 erase_char = term_orig.c_cc[VERASE];
2737 term_vi.c_iflag &= (~IXON & ~ICRNL);
2738 term_vi.c_oflag &= (~ONLCR);
2739 term_vi.c_cc[VMIN] = 1;
2740 term_vi.c_cc[VTIME] = 0;
2741 erase_char = term_vi.c_cc[VERASE];
2742 tcsetattr_stdin_TCSANOW(&term_vi);
2743} 2736}
2744 2737
2745static void cookmode(void) 2738static void cookmode(void)