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