Patch 8.2.1513
Problem:    Cannot interrupt shell used for filename expansion. (Dominique
            Pellé)
Solution:   Do set tmode in mch_delay(). (closes #6770)
Files:      src/vim.h, src/os_unix.c, src/proto/os_unix.pro, src/term.c,
            src/channel.c, src/if_cscope.c, src/os_amiga.c, src/ui.c,
            src/proto/os_amiga.pro, src/os_win32.c, src/proto/os_win32.pro


*** ../vim-8.2.1512/src/vim.h   2020-08-13 22:47:20.369992748 +0200
--- src/vim.h   2020-08-23 13:53:46.709620357 +0200
***************
*** 2668,2671 ****
--- 2668,2675 ----
  #define READDIR_SORT_IC               2  // sort ignoring case (strcasecmp)
  #define READDIR_SORT_COLLATE  3  // sort according to collation (strcoll)
  
+ // Flags for mch_delay.
+ #define MCH_DELAY_IGNOREINPUT 1
+ #define MCH_DELAY_SETTMODE    2
+ 
  #endif // VIM__H
*** ../vim-8.2.1512/src/os_unix.c       2020-08-11 21:58:12.581968226 +0200
--- src/os_unix.c       2020-08-23 14:24:53.168389748 +0200
***************
*** 577,591 ****
  }
  #endif
  
      void
! mch_delay(long msec, int ignoreinput)
  {
      tmode_T   old_tmode;
  #ifdef FEAT_MZSCHEME
      long      total = msec; // remember original value
  #endif
  
!     if (ignoreinput)
      {
        // Go to cooked mode without echo, to allow SIGINT interrupting us
        // here.  But we don't want QUIT to kill us (CTRL-\ used in a
--- 577,595 ----
  }
  #endif
  
+ /*
+  * "flags": MCH_DELAY_IGNOREINPUT - don't read input
+  *        MCH_DELAY_SETTMODE - use settmode() even for short delays
+  */
      void
! mch_delay(long msec, int flags)
  {
      tmode_T   old_tmode;
  #ifdef FEAT_MZSCHEME
      long      total = msec; // remember original value
  #endif
  
!     if (flags & MCH_DELAY_IGNOREINPUT)
      {
        // Go to cooked mode without echo, to allow SIGINT interrupting us
        // here.  But we don't want QUIT to kill us (CTRL-\ used in a
***************
*** 593,599 ****
        // Only do this if sleeping for more than half a second.
        in_mch_delay = TRUE;
        old_tmode = mch_cur_tmode;
!       if (mch_cur_tmode == TMODE_RAW && msec > 500)
            settmode(TMODE_SLEEP);
  
        /*
--- 597,604 ----
        // Only do this if sleeping for more than half a second.
        in_mch_delay = TRUE;
        old_tmode = mch_cur_tmode;
!       if (mch_cur_tmode == TMODE_RAW
!                              && (msec > 500 || (flags & MCH_DELAY_SETTMODE)))
            settmode(TMODE_SLEEP);
  
        /*
***************
*** 636,645 ****
  
            tv.tv_sec = msec / 1000;
            tv.tv_usec = (msec % 1000) * 1000;
!           /*
!            * NOTE: Solaris 2.6 has a bug that makes select() hang here.  Get
!            * a patch from Sun to fix this.  Reported by Gunnar Pedersen.
!            */
            select(0, NULL, NULL, NULL, &tv);
        }
  #  endif // HAVE_SELECT
--- 641,648 ----
  
            tv.tv_sec = msec / 1000;
            tv.tv_usec = (msec % 1000) * 1000;
!           // NOTE: Solaris 2.6 has a bug that makes select() hang here.  Get
!           // a patch from Sun to fix this.  Reported by Gunnar Pedersen.
            select(0, NULL, NULL, NULL, &tv);
        }
  #  endif // HAVE_SELECT
***************
*** 650,656 ****
        while (total > 0);
  #endif
  
!       if (msec > 500)
            settmode(old_tmode);
        in_mch_delay = FALSE;
      }
--- 653,659 ----
        while (total > 0);
  #endif
  
!       if (msec > 500 || (flags & MCH_DELAY_SETTMODE))
            settmode(old_tmode);
        in_mch_delay = FALSE;
      }
***************
*** 1284,1290 ****
        long wait_time;
  
        for (wait_time = 0; !sigcont_received && wait_time <= 3L; wait_time++)
!           mch_delay(wait_time, FALSE);
      }
  # endif
      in_mch_suspend = FALSE;
--- 1287,1293 ----
        long wait_time;
  
        for (wait_time = 0; !sigcont_received && wait_time <= 3L; wait_time++)
!           mch_delay(wait_time, 0);
      }
  # endif
      in_mch_suspend = FALSE;
***************
*** 4170,4176 ****
        if (wait_pid == 0)
        {
            // Wait for 1 to 10 msec before trying again.
!           mch_delay(delay_msec, TRUE);
            if (++delay_msec > 10)
                delay_msec = 10;
            continue;
--- 4173,4179 ----
        if (wait_pid == 0)
        {
            // Wait for 1 to 10 msec before trying again.
!           mch_delay(delay_msec, MCH_DELAY_IGNOREINPUT | MCH_DELAY_SETTMODE);
            if (++delay_msec > 10)
                delay_msec = 10;
            continue;
***************
*** 5262,5267 ****
--- 5265,5273 ----
            {
                long delay_msec = 1;
  
+               out_str(T_CTE); // possibly disables modifyOtherKeys, so that
+                               // the system can recognize CTRL-C
+ 
                /*
                 * Similar to the loop above, but only handle X events, no
                 * I/O.
***************
*** 5295,5305 ****
                    clip_update();
  
                    // Wait for 1 to 10 msec. 1 is faster but gives the child
!                   // less time.
!                   mch_delay(delay_msec, TRUE);
                    if (++delay_msec > 10)
                        delay_msec = 10;
                }
            }
  # endif
  
--- 5301,5314 ----
                    clip_update();
  
                    // Wait for 1 to 10 msec. 1 is faster but gives the child
!                   // less time, gradually wait longer.
!                   mch_delay(delay_msec,
!                                  MCH_DELAY_IGNOREINPUT | MCH_DELAY_SETTMODE);
                    if (++delay_msec > 10)
                        delay_msec = 10;
                }
+ 
+               out_str(T_CTI); // possibly enables modifyOtherKeys again
            }
  # endif
  
***************
*** 6710,6716 ****
      // When running in the background, give it some time to create the temp
      // file, but don't wait for it to finish.
      if (ampersand)
!       mch_delay(10L, TRUE);
  
      extra_shell_arg = NULL;           // cleanup
      show_shell_mess = TRUE;
--- 6719,6725 ----
      // When running in the background, give it some time to create the temp
      // file, but don't wait for it to finish.
      if (ampersand)
!       mch_delay(10L, MCH_DELAY_IGNOREINPUT);
  
      extra_shell_arg = NULL;           // cleanup
      show_shell_mess = TRUE;
*** ../vim-8.2.1512/src/proto/os_unix.pro       2020-05-17 14:06:07.313201564 
+0200
--- src/proto/os_unix.pro       2020-08-23 14:03:57.623622291 +0200
***************
*** 5,11 ****
  int mch_char_avail(void);
  int mch_check_messages(void);
  long_u mch_total_mem(int special);
! void mch_delay(long msec, int ignoreinput);
  int mch_stackcheck(char *p);
  void mch_suspend(void);
  void mch_init(void);
--- 5,11 ----
  int mch_char_avail(void);
  int mch_check_messages(void);
  long_u mch_total_mem(int special);
! void mch_delay(long msec, int flags);
  int mch_stackcheck(char *p);
  void mch_suspend(void);
  void mch_init(void);
*** ../vim-8.2.1512/src/term.c  2020-08-04 20:17:28.491204565 +0200
--- src/term.c  2020-08-23 14:21:14.792940982 +0200
***************
*** 3598,3604 ****
            {
  # ifdef UNIX
                // Give the terminal a chance to respond.
!               mch_delay(100L, FALSE);
  # endif
  # ifdef TCIFLUSH
                // Discard data received but not read.
--- 3598,3604 ----
            {
  # ifdef UNIX
                // Give the terminal a chance to respond.
!               mch_delay(100L, 0);
  # endif
  # ifdef TCIFLUSH
                // Discard data received but not read.
*** ../vim-8.2.1512/src/channel.c       2020-08-17 21:40:59.096286452 +0200
--- src/channel.c       2020-08-23 13:58:38.232634198 +0200
***************
*** 904,910 ****
            *waittime -= elapsed_msec;
            if (waitnow > 0)
            {
!               mch_delay((long)waitnow, TRUE);
                ui_breakcheck();
                *waittime -= waitnow;
            }
--- 904,910 ----
            *waittime -= elapsed_msec;
            if (waitnow > 0)
            {
!               mch_delay((long)waitnow, MCH_DELAY_IGNOREINPUT);
                ui_breakcheck();
                *waittime -= waitnow;
            }
*** ../vim-8.2.1512/src/if_cscope.c     2020-07-11 22:14:54.314422214 +0200
--- src/if_cscope.c     2020-08-23 13:59:00.492561831 +0200
***************
*** 2243,2249 ****
            waitpid_errno = errno;
            if (pid != 0)
                break;  // break unless the process is still running
!           mch_delay(50L, FALSE); // sleep 50 ms
        }
  # endif
        /*
--- 2243,2249 ----
            waitpid_errno = errno;
            if (pid != 0)
                break;  // break unless the process is still running
!           mch_delay(50L, 0); // sleep 50 ms
        }
  # endif
        /*
***************
*** 2278,2284 ****
                        alive = FALSE; // cscope process no longer exists
                        break;
                    }
!                   mch_delay(50L, FALSE); // sleep 50ms
                }
            }
            if (alive)
--- 2278,2284 ----
                        alive = FALSE; // cscope process no longer exists
                        break;
                    }
!                   mch_delay(50L, 0); // sleep 50 ms
                }
            }
            if (alive)
*** ../vim-8.2.1512/src/os_amiga.c      2020-05-17 14:06:07.313201564 +0200
--- src/os_amiga.c      2020-08-23 14:00:33.548262637 +0200
***************
*** 222,231 ****
  
  /*
   * Waits a specified amount of time, or until input arrives if
!  * ignoreinput is FALSE.
   */
      void
! mch_delay(long msec, int ignoreinput)
  {
  #ifndef LATTICE               // SAS declares void Delay(ULONG)
      void          Delay(long);
--- 222,231 ----
  
  /*
   * Waits a specified amount of time, or until input arrives if
!  * flags does not have MCH_DELAY_IGNOREINPUT.
   */
      void
! mch_delay(long msec, int flags)
  {
  #ifndef LATTICE               // SAS declares void Delay(ULONG)
      void          Delay(long);
***************
*** 233,239 ****
  
      if (msec > 0)
      {
!       if (ignoreinput)
            Delay(msec / 20L);      // Delay works with 20 msec intervals
        else
            WaitForChar(raw_in, msec * 1000L);
--- 233,239 ----
  
      if (msec > 0)
      {
!       if (flags & MCH_DELAY_IGNOREINPUT)
            Delay(msec / 20L);      // Delay works with 20 msec intervals
        else
            WaitForChar(raw_in, msec * 1000L);
*** ../vim-8.2.1512/src/ui.c    2020-06-15 19:51:52.633404482 +0200
--- src/ui.c    2020-08-23 14:25:42.872261248 +0200
***************
*** 539,545 ****
        gui_wait_for_chars(msec, typebuf.tb_change_cnt);
      else
  #endif
!       mch_delay(msec, ignoreinput);
  }
  
  /*
--- 539,545 ----
        gui_wait_for_chars(msec, typebuf.tb_change_cnt);
      else
  #endif
!       mch_delay(msec, ignoreinput ? MCH_DELAY_IGNOREINPUT : 0);
  }
  
  /*
*** ../vim-8.2.1512/src/proto/os_amiga.pro      2020-05-17 14:06:07.313201564 
+0200
--- src/proto/os_amiga.pro      2020-08-23 14:04:52.323453604 +0200
***************
*** 5,11 ****
  int mch_inchar(char_u *buf, int maxlen, long time, int tb_change_cnt);
  int mch_char_avail(void);
  long_u mch_avail_mem(int special);
! void mch_delay(long msec, int ignoreinput);
  void mch_suspend(void);
  void mch_init(void);
  int mch_check_win(int argc, char **argv);
--- 5,11 ----
  int mch_inchar(char_u *buf, int maxlen, long time, int tb_change_cnt);
  int mch_char_avail(void);
  long_u mch_avail_mem(int special);
! void mch_delay(long msec, int flags);
  void mch_suspend(void);
  void mch_init(void);
  int mch_check_win(int argc, char **argv);
*** ../vim-8.2.1512/src/os_win32.c      2020-06-12 22:59:07.270097188 +0200
--- src/os_win32.c      2020-08-23 14:02:46.619842953 +0200
***************
*** 6739,6745 ****
      void
  mch_delay(
      long    msec,
!     int           ignoreinput UNUSED)
  {
  #if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)
      Sleep((int)msec);     // never wait for input
--- 6739,6745 ----
      void
  mch_delay(
      long    msec,
!     int           flags UNUSED)
  {
  #if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)
      Sleep((int)msec);     // never wait for input
***************
*** 6751,6757 ****
        return;
      }
  # endif
!     if (ignoreinput)
  # ifdef FEAT_MZSCHEME
        if (mzthreads_allowed() && p_mzq > 0 && msec > p_mzq)
        {
--- 6751,6757 ----
        return;
      }
  # endif
!     if (flags & MCH_DELAY_IGNOREINPUT)
  # ifdef FEAT_MZSCHEME
        if (mzthreads_allowed() && p_mzq > 0 && msec > p_mzq)
        {
*** ../vim-8.2.1512/src/proto/os_win32.pro      2020-05-30 17:49:21.755140563 
+0200
--- src/proto/os_win32.pro      2020-08-23 14:04:48.051466739 +0200
***************
*** 53,59 ****
  void mch_clear_job(job_T *job);
  void mch_set_normal_colors(void);
  void mch_write(char_u *s, int len);
! void mch_delay(long msec, int ignoreinput);
  int mch_remove(char_u *name);
  void mch_breakcheck(int force);
  long_u mch_total_mem(int special);
--- 53,59 ----
  void mch_clear_job(job_T *job);
  void mch_set_normal_colors(void);
  void mch_write(char_u *s, int len);
! void mch_delay(long msec, int flags);
  int mch_remove(char_u *name);
  void mch_breakcheck(int force);
  long_u mch_total_mem(int special);
*** ../vim-8.2.1512/src/version.c       2020-08-22 22:37:17.089141677 +0200
--- src/version.c       2020-08-23 14:26:09.260192650 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1513,
  /**/

-- 
God made the integers; all else is the work of Man.
                -- Kronecker

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202008231229.07NCT5xW968705%40masaka.moolenaar.net.

Raspunde prin e-mail lui