]>
Commit | Line | Data |
---|---|---|
9512a71a AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.2.121 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.2.121 | |
11 | Problem: In gvim "!grep a *.c" spews out a lot of text that can't be | |
12 | stopped with CTRL-C. | |
13 | Solution: When looping to read and show text, do check for typed characters | |
14 | every two seconds. | |
15 | Files: src/os_unix.c | |
16 | ||
17 | ||
18 | *** ../vim-7.2.120/src/os_unix.c Wed Feb 4 14:18:44 2009 | |
19 | --- src/os_unix.c Sun Feb 22 00:54:05 2009 | |
20 | *************** | |
21 | *** 4092,4097 **** | |
22 | --- 4092,4100 ---- | |
23 | int fromshell_fd; | |
24 | garray_T ga; | |
25 | int noread_cnt; | |
26 | + # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) | |
27 | + struct timeval start_tv; | |
28 | + # endif | |
29 | ||
30 | # ifdef FEAT_GUI | |
31 | if (pty_master_fd >= 0) | |
32 | *************** | |
33 | *** 4201,4207 **** | |
34 | ga_init2(&ga, 1, BUFLEN); | |
35 | ||
36 | noread_cnt = 0; | |
37 | ! | |
38 | for (;;) | |
39 | { | |
40 | /* | |
41 | --- 4204,4212 ---- | |
42 | ga_init2(&ga, 1, BUFLEN); | |
43 | ||
44 | noread_cnt = 0; | |
45 | ! # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) | |
46 | ! gettimeofday(&start_tv, NULL); | |
47 | ! # endif | |
48 | for (;;) | |
49 | { | |
50 | /* | |
51 | *************** | |
52 | *** 4214,4238 **** | |
53 | * that a typed password is echoed for ssh or gpg command. | |
54 | * Don't get characters when the child has already | |
55 | * finished (wait_pid == 0). | |
56 | - * Don't get extra characters when we already have one. | |
57 | * Don't read characters unless we didn't get output for a | |
58 | ! * while, avoids that ":r !ls" eats typeahead. | |
59 | */ | |
60 | len = 0; | |
61 | if (!(options & SHELL_EXPAND) | |
62 | && ((options & | |
63 | (SHELL_READ|SHELL_WRITE|SHELL_COOKED)) | |
64 | != (SHELL_READ|SHELL_WRITE|SHELL_COOKED) | |
65 | ! #ifdef FEAT_GUI | |
66 | || gui.in_use | |
67 | ! #endif | |
68 | ) | |
69 | && wait_pid == 0 | |
70 | ! && (ta_len > 0 | |
71 | ! || (noread_cnt > 4 | |
72 | ! && (len = ui_inchar(ta_buf, | |
73 | ! BUFLEN, 10L, 0)) > 0))) | |
74 | { | |
75 | /* | |
76 | * For pipes: | |
77 | * Check for CTRL-C: send interrupt signal to child. | |
78 | --- 4219,4252 ---- | |
79 | * that a typed password is echoed for ssh or gpg command. | |
80 | * Don't get characters when the child has already | |
81 | * finished (wait_pid == 0). | |
82 | * Don't read characters unless we didn't get output for a | |
83 | ! * while (noread_cnt > 4), avoids that ":r !ls" eats | |
84 | ! * typeahead. | |
85 | */ | |
86 | len = 0; | |
87 | if (!(options & SHELL_EXPAND) | |
88 | && ((options & | |
89 | (SHELL_READ|SHELL_WRITE|SHELL_COOKED)) | |
90 | != (SHELL_READ|SHELL_WRITE|SHELL_COOKED) | |
91 | ! # ifdef FEAT_GUI | |
92 | || gui.in_use | |
93 | ! # endif | |
94 | ) | |
95 | && wait_pid == 0 | |
96 | ! && (ta_len > 0 || noread_cnt > 4)) | |
97 | { | |
98 | + if (ta_len == 0) | |
99 | + { | |
100 | + /* Get extra characters when we don't have any. | |
101 | + * Reset the counter and timer. */ | |
102 | + noread_cnt = 0; | |
103 | + # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) | |
104 | + gettimeofday(&start_tv, NULL); | |
105 | + # endif | |
106 | + len = ui_inchar(ta_buf, BUFLEN, 10L, 0); | |
107 | + } | |
108 | + if (ta_len > 0 || len > 0) | |
109 | + { | |
110 | /* | |
111 | * For pipes: | |
112 | * Check for CTRL-C: send interrupt signal to child. | |
113 | *************** | |
114 | *** 4334,4342 **** | |
115 | { | |
116 | ta_len -= len; | |
117 | mch_memmove(ta_buf, ta_buf + len, ta_len); | |
118 | - noread_cnt = 0; | |
119 | } | |
120 | } | |
121 | } | |
122 | ||
123 | if (got_int) | |
124 | --- 4348,4356 ---- | |
125 | { | |
126 | ta_len -= len; | |
127 | mch_memmove(ta_buf, ta_buf + len, ta_len); | |
128 | } | |
129 | } | |
130 | + } | |
131 | } | |
132 | ||
133 | if (got_int) | |
134 | *************** | |
135 | *** 4444,4449 **** | |
136 | --- 4458,4482 ---- | |
137 | out_flush(); | |
138 | if (got_int) | |
139 | break; | |
140 | + | |
141 | + # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) | |
142 | + { | |
143 | + struct timeval now_tv; | |
144 | + long msec; | |
145 | + | |
146 | + /* Avoid that we keep looping here without | |
147 | + * checking for a CTRL-C for a long time. Don't | |
148 | + * break out too often to avoid losing typeahead. */ | |
149 | + gettimeofday(&now_tv, NULL); | |
150 | + msec = (now_tv.tv_sec - start_tv.tv_sec) * 1000L | |
151 | + + (now_tv.tv_usec - start_tv.tv_usec) / 1000L; | |
152 | + if (msec > 2000) | |
153 | + { | |
154 | + noread_cnt = 5; | |
155 | + break; | |
156 | + } | |
157 | + } | |
158 | + # endif | |
159 | } | |
160 | ||
161 | /* If we already detected the child has finished break the | |
162 | *** ../vim-7.2.120/src/version.c Sun Feb 22 02:36:36 2009 | |
163 | --- src/version.c Sun Feb 22 02:48:03 2009 | |
164 | *************** | |
165 | *** 678,679 **** | |
166 | --- 678,681 ---- | |
167 | { /* Add new patch number below this line */ | |
168 | + /**/ | |
169 | + 121, | |
170 | /**/ | |
171 | ||
172 | -- | |
173 | hundred-and-one symptoms of being an internet addict: | |
174 | 111. You and your friends get together regularly on IRC, even though | |
175 | all of you live in the same city. | |
176 | ||
177 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
178 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
179 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
180 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |