47ca65a
To: vim-dev@vim.org
47ca65a
Subject: Patch 7.2.121
47ca65a
Fcc: outbox
47ca65a
From: Bram Moolenaar <Bram@moolenaar.net>
47ca65a
Mime-Version: 1.0
47ca65a
Content-Type: text/plain; charset=ISO-8859-1
47ca65a
Content-Transfer-Encoding: 8bit
47ca65a
------------
47ca65a
47ca65a
Patch 7.2.121
47ca65a
Problem:    In gvim "!grep a *.c" spews out a lot of text that can't be
47ca65a
            stopped with CTRL-C.
47ca65a
Solution:   When looping to read and show text, do check for typed characters
47ca65a
            every two seconds.
47ca65a
Files:      src/os_unix.c
47ca65a
47ca65a
47ca65a
*** ../vim-7.2.120/src/os_unix.c	Wed Feb  4 14:18:44 2009
47ca65a
--- src/os_unix.c	Sun Feb 22 00:54:05 2009
47ca65a
***************
47ca65a
*** 4092,4097 ****
47ca65a
--- 4092,4100 ----
47ca65a
  		int	    fromshell_fd;
47ca65a
  		garray_T    ga;
47ca65a
  		int	    noread_cnt;
47ca65a
+ # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
47ca65a
+ 		struct timeval  start_tv;
47ca65a
+ # endif
47ca65a
  
47ca65a
  # ifdef FEAT_GUI
47ca65a
  		if (pty_master_fd >= 0)
47ca65a
***************
47ca65a
*** 4201,4207 ****
47ca65a
  		    ga_init2(&ga, 1, BUFLEN);
47ca65a
  
47ca65a
  		noread_cnt = 0;
47ca65a
! 
47ca65a
  		for (;;)
47ca65a
  		{
47ca65a
  		    /*
47ca65a
--- 4204,4212 ----
47ca65a
  		    ga_init2(&ga, 1, BUFLEN);
47ca65a
  
47ca65a
  		noread_cnt = 0;
47ca65a
! # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
47ca65a
! 		gettimeofday(&start_tv, NULL);
47ca65a
! # endif
47ca65a
  		for (;;)
47ca65a
  		{
47ca65a
  		    /*
47ca65a
***************
47ca65a
*** 4214,4238 ****
47ca65a
  		     * that a typed password is echoed for ssh or gpg command.
47ca65a
  		     * Don't get characters when the child has already
47ca65a
  		     * finished (wait_pid == 0).
47ca65a
- 		     * Don't get extra characters when we already have one.
47ca65a
  		     * Don't read characters unless we didn't get output for a
47ca65a
! 		     * while, avoids that ":r !ls" eats typeahead.
47ca65a
  		     */
47ca65a
  		    len = 0;
47ca65a
  		    if (!(options & SHELL_EXPAND)
47ca65a
  			    && ((options &
47ca65a
  					 (SHELL_READ|SHELL_WRITE|SHELL_COOKED))
47ca65a
  				      != (SHELL_READ|SHELL_WRITE|SHELL_COOKED)
47ca65a
! #ifdef FEAT_GUI
47ca65a
  						    || gui.in_use
47ca65a
! #endif
47ca65a
  						    )
47ca65a
  			    && wait_pid == 0
47ca65a
! 			    && (ta_len > 0
47ca65a
! 				|| (noread_cnt > 4
47ca65a
! 				    && (len = ui_inchar(ta_buf,
47ca65a
! 						       BUFLEN, 10L, 0)) > 0)))
47ca65a
  		    {
47ca65a
  			/*
47ca65a
  			 * For pipes:
47ca65a
  			 * Check for CTRL-C: send interrupt signal to child.
47ca65a
--- 4219,4252 ----
47ca65a
  		     * that a typed password is echoed for ssh or gpg command.
47ca65a
  		     * Don't get characters when the child has already
47ca65a
  		     * finished (wait_pid == 0).
47ca65a
  		     * Don't read characters unless we didn't get output for a
47ca65a
! 		     * while (noread_cnt > 4), avoids that ":r !ls" eats
47ca65a
! 		     * typeahead.
47ca65a
  		     */
47ca65a
  		    len = 0;
47ca65a
  		    if (!(options & SHELL_EXPAND)
47ca65a
  			    && ((options &
47ca65a
  					 (SHELL_READ|SHELL_WRITE|SHELL_COOKED))
47ca65a
  				      != (SHELL_READ|SHELL_WRITE|SHELL_COOKED)
47ca65a
! # ifdef FEAT_GUI
47ca65a
  						    || gui.in_use
47ca65a
! # endif
47ca65a
  						    )
47ca65a
  			    && wait_pid == 0
47ca65a
! 			    && (ta_len > 0 || noread_cnt > 4))
47ca65a
  		    {
47ca65a
+ 		      if (ta_len == 0)
47ca65a
+ 		      {
47ca65a
+ 			  /* Get extra characters when we don't have any.
47ca65a
+ 			   * Reset the counter and timer. */
47ca65a
+ 			  noread_cnt = 0;
47ca65a
+ # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
47ca65a
+ 			  gettimeofday(&start_tv, NULL);
47ca65a
+ # endif
47ca65a
+ 			  len = ui_inchar(ta_buf, BUFLEN, 10L, 0);
47ca65a
+ 		      }
47ca65a
+ 		      if (ta_len > 0 || len > 0)
47ca65a
+ 		      {
47ca65a
  			/*
47ca65a
  			 * For pipes:
47ca65a
  			 * Check for CTRL-C: send interrupt signal to child.
47ca65a
***************
47ca65a
*** 4334,4342 ****
47ca65a
  			    {
47ca65a
  				ta_len -= len;
47ca65a
  				mch_memmove(ta_buf, ta_buf + len, ta_len);
47ca65a
- 				noread_cnt = 0;
47ca65a
  			    }
47ca65a
  			}
47ca65a
  		    }
47ca65a
  
47ca65a
  		    if (got_int)
47ca65a
--- 4348,4356 ----
47ca65a
  			    {
47ca65a
  				ta_len -= len;
47ca65a
  				mch_memmove(ta_buf, ta_buf + len, ta_len);
47ca65a
  			    }
47ca65a
  			}
47ca65a
+ 		      }
47ca65a
  		    }
47ca65a
  
47ca65a
  		    if (got_int)
47ca65a
***************
47ca65a
*** 4444,4449 ****
47ca65a
--- 4458,4482 ----
47ca65a
  			out_flush();
47ca65a
  			if (got_int)
47ca65a
  			    break;
47ca65a
+ 
47ca65a
+ # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
47ca65a
+ 			{
47ca65a
+ 			    struct timeval  now_tv;
47ca65a
+ 			    long	    msec;
47ca65a
+ 
47ca65a
+ 			    /* Avoid that we keep looping here without
47ca65a
+ 			     * checking for a CTRL-C for a long time.  Don't
47ca65a
+ 			     * break out too often to avoid losing typeahead. */
47ca65a
+ 			    gettimeofday(&now_tv, NULL);
47ca65a
+ 			    msec = (now_tv.tv_sec - start_tv.tv_sec) * 1000L
47ca65a
+ 				+ (now_tv.tv_usec - start_tv.tv_usec) / 1000L;
47ca65a
+ 			    if (msec > 2000)
47ca65a
+ 			    {
47ca65a
+ 				noread_cnt = 5;
47ca65a
+ 				break;
47ca65a
+ 			    }
47ca65a
+ 			}
47ca65a
+ # endif
47ca65a
  		    }
47ca65a
  
47ca65a
  		    /* If we already detected the child has finished break the
47ca65a
*** ../vim-7.2.120/src/version.c	Sun Feb 22 02:36:36 2009
47ca65a
--- src/version.c	Sun Feb 22 02:48:03 2009
47ca65a
***************
47ca65a
*** 678,679 ****
47ca65a
--- 678,681 ----
47ca65a
  {   /* Add new patch number below this line */
47ca65a
+ /**/
47ca65a
+     121,
47ca65a
  /**/
47ca65a
47ca65a
-- 
47ca65a
hundred-and-one symptoms of being an internet addict:
47ca65a
111. You and your friends get together regularly on IRC, even though
47ca65a
     all of you live in the same city.
47ca65a
47ca65a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
47ca65a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
47ca65a
\\\        download, build and distribute -- http://www.A-A-P.org        ///
47ca65a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///