summaryrefslogtreecommitdiffstats
path: root/vi/vim-7.2/7.2.121
blob: ea5306f705b89acc23b3b9547df4da6fac079ea7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
To: vim-dev@vim.org
Subject: Patch 7.2.121
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.121
Problem:    In gvim "!grep a *.c" spews out a lot of text that can't be
            stopped with CTRL-C.
Solution:   When looping to read and show text, do check for typed characters
            every two seconds.
Files:      src/os_unix.c


*** ../vim-7.2.120/src/os_unix.c	Wed Feb  4 14:18:44 2009
--- src/os_unix.c	Sun Feb 22 00:54:05 2009
***************
*** 4092,4097 ****
--- 4092,4100 ----
  		int	    fromshell_fd;
  		garray_T    ga;
  		int	    noread_cnt;
+ # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
+ 		struct timeval  start_tv;
+ # endif
  
  # ifdef FEAT_GUI
  		if (pty_master_fd >= 0)
***************
*** 4201,4207 ****
  		    ga_init2(&ga, 1, BUFLEN);
  
  		noread_cnt = 0;
! 
  		for (;;)
  		{
  		    /*
--- 4204,4212 ----
  		    ga_init2(&ga, 1, BUFLEN);
  
  		noread_cnt = 0;
! # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
! 		gettimeofday(&start_tv, NULL);
! # endif
  		for (;;)
  		{
  		    /*
***************
*** 4214,4238 ****
  		     * that a typed password is echoed for ssh or gpg command.
  		     * Don't get characters when the child has already
  		     * finished (wait_pid == 0).
- 		     * Don't get extra characters when we already have one.
  		     * Don't read characters unless we didn't get output for a
! 		     * while, avoids that ":r !ls" eats typeahead.
  		     */
  		    len = 0;
  		    if (!(options & SHELL_EXPAND)
  			    && ((options &
  					 (SHELL_READ|SHELL_WRITE|SHELL_COOKED))
  				      != (SHELL_READ|SHELL_WRITE|SHELL_COOKED)
! #ifdef FEAT_GUI
  						    || gui.in_use
! #endif
  						    )
  			    && wait_pid == 0
! 			    && (ta_len > 0
! 				|| (noread_cnt > 4
! 				    && (len = ui_inchar(ta_buf,
! 						       BUFLEN, 10L, 0)) > 0)))
  		    {
  			/*
  			 * For pipes:
  			 * Check for CTRL-C: send interrupt signal to child.
--- 4219,4252 ----
  		     * that a typed password is echoed for ssh or gpg command.
  		     * Don't get characters when the child has already
  		     * finished (wait_pid == 0).
  		     * Don't read characters unless we didn't get output for a
! 		     * while (noread_cnt > 4), avoids that ":r !ls" eats
! 		     * typeahead.
  		     */
  		    len = 0;
  		    if (!(options & SHELL_EXPAND)
  			    && ((options &
  					 (SHELL_READ|SHELL_WRITE|SHELL_COOKED))
  				      != (SHELL_READ|SHELL_WRITE|SHELL_COOKED)
! # ifdef FEAT_GUI
  						    || gui.in_use
! # endif
  						    )
  			    && wait_pid == 0
! 			    && (ta_len > 0 || noread_cnt > 4))
  		    {
+ 		      if (ta_len == 0)
+ 		      {
+ 			  /* Get extra characters when we don't have any.
+ 			   * Reset the counter and timer. */
+ 			  noread_cnt = 0;
+ # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
+ 			  gettimeofday(&start_tv, NULL);
+ # endif
+ 			  len = ui_inchar(ta_buf, BUFLEN, 10L, 0);
+ 		      }
+ 		      if (ta_len > 0 || len > 0)
+ 		      {
  			/*
  			 * For pipes:
  			 * Check for CTRL-C: send interrupt signal to child.
***************
*** 4334,4342 ****
  			    {
  				ta_len -= len;
  				mch_memmove(ta_buf, ta_buf + len, ta_len);
- 				noread_cnt = 0;
  			    }
  			}
  		    }
  
  		    if (got_int)
--- 4348,4356 ----
  			    {
  				ta_len -= len;
  				mch_memmove(ta_buf, ta_buf + len, ta_len);
  			    }
  			}
+ 		      }
  		    }
  
  		    if (got_int)
***************
*** 4444,4449 ****
--- 4458,4482 ----
  			out_flush();
  			if (got_int)
  			    break;
+ 
+ # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
+ 			{
+ 			    struct timeval  now_tv;
+ 			    long	    msec;
+ 
+ 			    /* Avoid that we keep looping here without
+ 			     * checking for a CTRL-C for a long time.  Don't
+ 			     * break out too often to avoid losing typeahead. */
+ 			    gettimeofday(&now_tv, NULL);
+ 			    msec = (now_tv.tv_sec - start_tv.tv_sec) * 1000L
+ 				+ (now_tv.tv_usec - start_tv.tv_usec) / 1000L;
+ 			    if (msec > 2000)
+ 			    {
+ 				noread_cnt = 5;
+ 				break;
+ 			    }
+ 			}
+ # endif
  		    }
  
  		    /* If we already detected the child has finished break the
*** ../vim-7.2.120/src/version.c	Sun Feb 22 02:36:36 2009
--- src/version.c	Sun Feb 22 02:48:03 2009
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     121,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
111. You and your friends get together regularly on IRC, even though
     all of you live in the same city.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///