diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-01 12:29:27 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-01 12:29:27 +0200 |
commit | c3193104049186bd28203801e8fd7d9d4ff2b547 (patch) | |
tree | 6b50dc58d15ab4f33767d1239740a761833e8d53 | |
parent | 6ed94aa9b25fc1824de2e74eebf8b75aefe99b75 (diff) | |
download | busybox-w32-c3193104049186bd28203801e8fd7d9d4ff2b547.tar.gz busybox-w32-c3193104049186bd28203801e8fd7d9d4ff2b547.tar.bz2 busybox-w32-c3193104049186bd28203801e8fd7d9d4ff2b547.zip |
vi: fix ^Z not always working as intended
function old new delta
tstp_handler 64 71 +7
text_yank 54 56 +2
vi_main 280 272 -8
do_cmd 4705 4696 -9
colon 2861 2852 -9
cont_handler 66 - -66
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/3 up/down: 9/-92) Total: -83 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/vi.c | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/editors/vi.c b/editors/vi.c index a11e06040..9bdee5928 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -330,9 +330,6 @@ struct globals { | |||
330 | int lmc_len; // length of last_modifying_cmd | 330 | int lmc_len; // length of last_modifying_cmd |
331 | char *ioq, *ioq_start; // pointer to string for get_one_char to "read" | 331 | char *ioq, *ioq_start; // pointer to string for get_one_char to "read" |
332 | #endif | 332 | #endif |
333 | #if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME | ||
334 | int my_pid; | ||
335 | #endif | ||
336 | #if ENABLE_FEATURE_VI_SEARCH | 333 | #if ENABLE_FEATURE_VI_SEARCH |
337 | char *last_search_pattern; // last pattern from a '/' or '?' search | 334 | char *last_search_pattern; // last pattern from a '/' or '?' search |
338 | #endif | 335 | #endif |
@@ -449,7 +446,6 @@ struct globals { | |||
449 | #define lmc_len (G.lmc_len ) | 446 | #define lmc_len (G.lmc_len ) |
450 | #define ioq (G.ioq ) | 447 | #define ioq (G.ioq ) |
451 | #define ioq_start (G.ioq_start ) | 448 | #define ioq_start (G.ioq_start ) |
452 | #define my_pid (G.my_pid ) | ||
453 | #define last_search_pattern (G.last_search_pattern) | 449 | #define last_search_pattern (G.last_search_pattern) |
454 | 450 | ||
455 | #define edit_file__cur_line (G.edit_file__cur_line) | 451 | #define edit_file__cur_line (G.edit_file__cur_line) |
@@ -634,11 +630,8 @@ int vi_main(int argc, char **argv) | |||
634 | #endif | 630 | #endif |
635 | #endif | 631 | #endif |
636 | 632 | ||
637 | #if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME | ||
638 | my_pid = getpid(); | ||
639 | #endif | ||
640 | #if ENABLE_FEATURE_VI_CRASHME | 633 | #if ENABLE_FEATURE_VI_CRASHME |
641 | srand((long) my_pid); | 634 | srand((long) getpid()); |
642 | #endif | 635 | #endif |
643 | #ifdef NO_SUCH_APPLET_YET | 636 | #ifdef NO_SUCH_APPLET_YET |
644 | // if we aren't "vi", we are "view" | 637 | // if we aren't "vi", we are "view" |
@@ -2770,31 +2763,30 @@ static void winch_handler(int sig UNUSED_PARAM) | |||
2770 | redraw(TRUE); // re-draw the screen | 2763 | redraw(TRUE); // re-draw the screen |
2771 | errno = save_errno; | 2764 | errno = save_errno; |
2772 | } | 2765 | } |
2773 | static void cont_handler(int sig UNUSED_PARAM) | ||
2774 | { | ||
2775 | int save_errno = errno; | ||
2776 | rawmode(); // terminal to "raw" | ||
2777 | last_status_cksum = 0; // force status update | ||
2778 | redraw(TRUE); // re-draw the screen | ||
2779 | |||
2780 | signal(SIGTSTP, tstp_handler); | ||
2781 | signal(SIGCONT, SIG_DFL); | ||
2782 | //kill(my_pid, SIGCONT); // huh? why? we are already "continued"... | ||
2783 | errno = save_errno; | ||
2784 | } | ||
2785 | static void tstp_handler(int sig UNUSED_PARAM) | 2766 | static void tstp_handler(int sig UNUSED_PARAM) |
2786 | { | 2767 | { |
2787 | int save_errno = errno; | 2768 | int save_errno = errno; |
2769 | |||
2770 | // ioctl inside cookmode() was seen to generate SIGTTOU, | ||
2771 | // stopping us too early. Prevent that: | ||
2772 | signal(SIGTTOU, SIG_IGN); | ||
2773 | |||
2788 | go_bottom_and_clear_to_eol(); | 2774 | go_bottom_and_clear_to_eol(); |
2789 | cookmode(); // terminal to "cooked" | 2775 | cookmode(); // terminal to "cooked" |
2790 | 2776 | ||
2791 | signal(SIGCONT, cont_handler); | 2777 | // stop now |
2792 | signal(SIGTSTP, SIG_DFL); | 2778 | //signal(SIGTSTP, SIG_DFL); |
2793 | kill(my_pid, SIGTSTP); | 2779 | //raise(SIGTSTP); |
2780 | raise(SIGSTOP); // avoid "dance" with TSTP handler - use SIGSTOP instead | ||
2781 | //signal(SIGTSTP, tstp_handler); | ||
2782 | |||
2783 | // we have been "continued" with SIGCONT, restore screen and termios | ||
2784 | rawmode(); // terminal to "raw" | ||
2785 | last_status_cksum = 0; // force status update | ||
2786 | redraw(TRUE); // re-draw the screen | ||
2787 | |||
2794 | errno = save_errno; | 2788 | errno = save_errno; |
2795 | } | 2789 | } |
2796 | |||
2797 | //----- Come here when we get a signal --------------------------- | ||
2798 | static void int_handler(int sig) | 2790 | static void int_handler(int sig) |
2799 | { | 2791 | { |
2800 | signal(SIGINT, int_handler); | 2792 | signal(SIGINT, int_handler); |