]> git.pld-linux.org Git - packages/vim.git/blame - 6.2.223
- initial import
[packages/vim.git] / 6.2.223
CommitLineData
05649561
AG
1To: vim-dev@vim.org
2Subject: Patch 6.2.223
3Fcc: outbox
4From: Bram Moolenaar <Bram@moolenaar.net>
5Mime-Version: 1.0
6Content-Type: text/plain; charset=ISO-8859-1
7Content-Transfer-Encoding: 8bit
8------------
9
10Patch 6.2.223
11Problem: Cscope: Avoid a hang when cscope waits for a response while Vim
12 waits for a prompt.
13 Error messages from Cscope mess up the display.
14Solution: Detect the hit-enter message and respond by sending a return
15 character to cscope. (Gary Johnson)
16 Use EMSG() and strerror() when possible. Replace perror() with
17 PERROR() everywhere, add emsg3().
18Files: src/diff.c, src/if_cscope.c, src/integration.c, src/message.c,
19 src/proto/message.pro, src/misc2.c, src/netbeans.c, src/vim.h
20
21
22*** ../vim-6.2.222/src/diff.c Sun Jan 18 20:58:01 2004
23--- src/diff.c Sun Feb 1 15:01:19 2004
24***************
25*** 130,136 ****
26 return;
27 }
28
29! EMSG2(_("E96: Can not diff more than %ld buffers"), DB_COUNT);
30 }
31
32 /*
33--- 130,136 ----
34 return;
35 }
36
37! EMSGN(_("E96: Can not diff more than %ld buffers"), DB_COUNT);
38 }
39
40 /*
41*** ../vim-6.2.222/src/if_cscope.c Wed Sep 10 21:35:55 2003
42--- src/if_cscope.c Sun Feb 1 15:23:43 2004
43***************
44*** 754,764 ****
45 err_save = dup(STDERR_FILENO);
46 #endif
47 if (dup2(to_cs[0], STDIN_FILENO) == -1)
48! perror("cs_create_connection 1");
49 if (dup2(from_cs[1], STDOUT_FILENO) == -1)
50! perror("cs_create_connection 2");
51 if (dup2(from_cs[1], STDERR_FILENO) == -1)
52! perror("cs_create_connection 3");
53
54 /* close unused */
55 #if defined(UNIX)
56--- 754,764 ----
57 err_save = dup(STDERR_FILENO);
58 #endif
59 if (dup2(to_cs[0], STDIN_FILENO) == -1)
60! PERROR("cs_create_connection 1");
61 if (dup2(from_cs[1], STDOUT_FILENO) == -1)
62! PERROR("cs_create_connection 2");
63 if (dup2(from_cs[1], STDERR_FILENO) == -1)
64! PERROR("cs_create_connection 3");
65
66 /* close unused */
67 #if defined(UNIX)
68***************
69*** 839,845 ****
70
71 #if defined(UNIX)
72 if (execl("/bin/sh", "sh", "-c", cmd, NULL) == -1)
73! perror(_("cs_create_connection exec failed"));
74
75 exit(127);
76 /* NOTREACHED */
77--- 839,845 ----
78
79 #if defined(UNIX)
80 if (execl("/bin/sh", "sh", "-c", cmd, NULL) == -1)
81! PERROR(_("cs_create_connection exec failed"));
82
83 exit(127);
84 /* NOTREACHED */
85***************
86*** 889,895 ****
87 # endif
88 if (ph == -1)
89 {
90! perror(_("cs_create_connection exec failed"));
91 (void)EMSG(_("E623: Could not spawn cscope process"));
92 goto err_closing;
93 }
94--- 889,895 ----
95 # endif
96 if (ph == -1)
97 {
98! PERROR(_("cs_create_connection exec failed"));
99 (void)EMSG(_("E623: Could not spawn cscope process"));
100 goto err_closing;
101 }
102***************
103*** 903,911 ****
104 * reopen as streams.
105 */
106 if ((csinfo[i].to_fp = fdopen(to_cs[1], "w")) == NULL)
107! perror(_("cs_create_connection: fdopen for to_fp failed"));
108 if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL)
109! perror(_("cs_create_connection: fdopen for fr_fp failed"));
110
111 #if defined(UNIX)
112 /* close unused */
113--- 903,911 ----
114 * reopen as streams.
115 */
116 if ((csinfo[i].to_fp = fdopen(to_cs[1], "w")) == NULL)
117! PERROR(_("cs_create_connection: fdopen for to_fp failed"));
118 if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL)
119! PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
120
121 #if defined(UNIX)
122 /* close unused */
123***************
124*** 1974,2027 ****
125 int ch;
126 char *buf = NULL; /* buffer for possible error message from cscope */
127 int bufpos = 0;
128! static char *cs_emsg = N_("E609: Cscope error: %s");
129! /* maximum allowed len for Cscope error message */
130! int maxlen = IOSIZE - strlen(_(cs_emsg));
131
132 for (;;)
133 {
134 while ((ch = getc(csinfo[i].fr_fp)) != EOF && ch != CSCOPE_PROMPT[0])
135! /* if verbose, have space and char is printable */
136! if (p_csverbose && bufpos < maxlen - 1 && vim_isprintc(ch))
137 {
138 if (buf == NULL) /* lazy buffer allocation */
139 buf = (char *)alloc(maxlen);
140!
141! if (buf != NULL) /* append character to a string */
142 {
143 buf[bufpos++] = ch;
144 buf[bufpos] = NUL;
145 }
146 }
147
148! if (ch == EOF)
149 {
150! perror("cs_read_prompt EOF(1)");
151! if (buf != NULL && buf[0] != NUL)
152! (void)EMSG2(_(cs_emsg), buf);
153! else if (p_csverbose)
154! cs_reading_emsg(i); /* don't have additional information */
155! cs_release_csp(i, TRUE);
156! vim_free(buf);
157! return CSCOPE_FAILURE;
158! }
159
160! ch = getc(csinfo[i].fr_fp);
161! if (ch == EOF)
162! perror("cs_read_prompt EOF(2)");
163! if (ch != CSCOPE_PROMPT[1])
164! continue;
165
166- ch = getc(csinfo[i].fr_fp);
167 if (ch == EOF)
168! perror("cs_read_prompt EOF(3)");
169! if (ch != CSCOPE_PROMPT[2])
170! continue;
171! break;
172 }
173 vim_free(buf);
174 return CSCOPE_SUCCESS;
175! } /* cs_read_prompt */
176
177
178 /*
179--- 1974,2053 ----
180 int ch;
181 char *buf = NULL; /* buffer for possible error message from cscope */
182 int bufpos = 0;
183! char *cs_emsg;
184! int maxlen;
185! static char *eprompt = "Press the RETURN key to continue:";
186! int epromptlen = strlen(eprompt);
187! int n;
188!
189! cs_emsg = _("E609: Cscope error: %s");
190! /* compute maximum allowed len for Cscope error message */
191! maxlen = (int)(IOSIZE - strlen(cs_emsg));
192
193 for (;;)
194 {
195 while ((ch = getc(csinfo[i].fr_fp)) != EOF && ch != CSCOPE_PROMPT[0])
196! /* if there is room and char is printable */
197! if (bufpos < maxlen - 1 && vim_isprintc(ch))
198 {
199 if (buf == NULL) /* lazy buffer allocation */
200 buf = (char *)alloc(maxlen);
201! if (buf != NULL)
202 {
203+ /* append character to the message */
204 buf[bufpos++] = ch;
205 buf[bufpos] = NUL;
206+ if (bufpos >= epromptlen
207+ && strcmp(&buf[bufpos - epromptlen], eprompt) == 0)
208+ {
209+ /* remove eprompt from buf */
210+ buf[bufpos - epromptlen] = NUL;
211+
212+ /* print message to user */
213+ (void)EMSG2(cs_emsg, buf);
214+
215+ /* send RETURN to cscope */
216+ (void)putc('\n', csinfo[i].to_fp);
217+ (void)fflush(csinfo[i].to_fp);
218+
219+ /* clear buf */
220+ bufpos = 0;
221+ buf[bufpos] = NUL;
222+ }
223 }
224 }
225
226! for (n = 0; n < (int)strlen(CSCOPE_PROMPT); ++n)
227 {
228! if (n > 0)
229! ch = getc(csinfo[i].fr_fp);
230! if (ch == EOF)
231! {
232! PERROR("cs_read_prompt EOF");
233! if (buf != NULL && buf[0] != NUL)
234! (void)EMSG2(cs_emsg, buf);
235! else if (p_csverbose)
236! cs_reading_emsg(i); /* don't have additional information */
237! cs_release_csp(i, TRUE);
238! vim_free(buf);
239! return CSCOPE_FAILURE;
240! }
241
242! if (ch != CSCOPE_PROMPT[n])
243! {
244! ch = EOF;
245! break;
246! }
247! }
248
249 if (ch == EOF)
250! continue; /* didn't find the prompt */
251! break; /* did find the prompt */
252 }
253+
254 vim_free(buf);
255 return CSCOPE_SUCCESS;
256! }
257
258
259 /*
260*** ../vim-6.2.222/src/integration.c Sun Jul 27 14:16:53 2003
261--- src/integration.c Sun Feb 1 15:20:40 2004
262***************
263*** 648,654 ****
264 port = atoi(address);
265
266 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
267! perror(NOCATGETS("workshop_connect"));
268 return;
269 }
270
271--- 648,654 ----
272 port = atoi(address);
273
274 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
275! PERROR(NOCATGETS("workshop_connect"));
276 return;
277 }
278
279***************
280*** 658,671 ****
281 server.sin_family = AF_INET;
282 server.sin_port = port;
283 if ((host = gethostbyname(NOCATGETS("localhost"))) == NULL) {
284! perror(NOCATGETS("gethostbyname"));
285 sd = -1;
286 return;
287 }
288 memcpy((char *)&server.sin_addr, host->h_addr, host->h_length);
289 #else
290 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
291! perror(NOCATGETS("workshop_connect"));
292 return;
293 }
294
295--- 658,671 ----
296 server.sin_family = AF_INET;
297 server.sin_port = port;
298 if ((host = gethostbyname(NOCATGETS("localhost"))) == NULL) {
299! PERROR(NOCATGETS("gethostbyname"));
300 sd = -1;
301 return;
302 }
303 memcpy((char *)&server.sin_addr, host->h_addr, host->h_length);
304 #else
305 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
306! PERROR(NOCATGETS("workshop_connect"));
307 return;
308 }
309
310***************
311*** 678,700 ****
312 close(sd);
313 #ifdef INET_SOCKETS
314 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
315! perror(NOCATGETS("workshop_connect"));
316 return;
317 }
318 #else
319 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
320! perror(NOCATGETS("workshop_connect"));
321 return;
322 }
323 #endif
324 if (connect(sd, (struct sockaddr *)&server,
325 sizeof(server))) {
326! perror(NOCATGETS("workshop_connect"));
327 return;
328 }
329
330 } else {
331! perror(NOCATGETS("workshop_connect"));
332 return;
333 }
334 }
335--- 678,700 ----
336 close(sd);
337 #ifdef INET_SOCKETS
338 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
339! PERROR(NOCATGETS("workshop_connect"));
340 return;
341 }
342 #else
343 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
344! PERROR(NOCATGETS("workshop_connect"));
345 return;
346 }
347 #endif
348 if (connect(sd, (struct sockaddr *)&server,
349 sizeof(server))) {
350! PERROR(NOCATGETS("workshop_connect"));
351 return;
352 }
353
354 } else {
355! PERROR(NOCATGETS("workshop_connect"));
356 return;
357 }
358 }
359*** ../vim-6.2.222/src/message.c Sun Jan 25 20:28:03 2004
360--- src/message.c Sun Feb 1 15:14:08 2004
361***************
362*** 554,563 ****
363--- 554,576 ----
364 return msg_attr(s, attr);
365 }
366
367+ /*
368+ * Print an error message with one "%s" and one string argument.
369+ */
370 int
371 emsg2(s, a1)
372 char_u *s, *a1;
373 {
374+ return emsg3(s, a1, NULL);
375+ }
376+
377+ /*
378+ * Print an error message with one or two "%s" and one or two string arguments.
379+ */
380+ int
381+ emsg3(s, a1, a2)
382+ char_u *s, *a1, *a2;
383+ {
384 if ((emsg_off > 0 && *p_debug == NUL)
385 #ifdef FEAT_EVAL
386 || emsg_skip > 0
387***************
388*** 568,582 ****
389 /* Check for NULL strings (just in case) */
390 if (a1 == NULL)
391 a1 = (char_u *)"[NULL]";
392! /* Check for very long strings (can happen with ":help ^A<CR>").
393! * Careful, the argument could actually be a long. */
394! if (STRLEN(s) + (strstr((char *)s, "%s") != NULL ? STRLEN(a1) : 20)
395! >= (size_t)IOSIZE)
396! a1 = (char_u *)_("[string too long]");
397! sprintf((char *)IObuff, (char *)s, (char *)a1);
398 return emsg(IObuff);
399 }
400
401 int
402 emsgn(s, n)
403 char_u *s;
404--- 581,600 ----
405 /* Check for NULL strings (just in case) */
406 if (a1 == NULL)
407 a1 = (char_u *)"[NULL]";
408! if (a2 == NULL)
409! a2 = (char_u *)"[NULL]";
410!
411! /* Check for very long strings (can happen with ":help ^A<CR>"). */
412! if (STRLEN(s) + STRLEN(a1) + STRLEN(a2) >= (size_t)IOSIZE)
413! a1 = a2 = (char_u *)_("[string too long]");
414!
415! sprintf((char *)IObuff, (char *)s, (char *)a1, (char *)a2);
416 return emsg(IObuff);
417 }
418
419+ /*
420+ * Print an error message with one "%ld" and one long int argument.
421+ */
422 int
423 emsgn(s, n)
424 char_u *s;
425*** ../vim-6.2.222/src/proto/message.pro Sun Jun 1 12:26:14 2003
426--- src/proto/message.pro Sun Feb 1 15:23:42 2004
427***************
428*** 6,11 ****
429--- 6,12 ----
430 void trunc_string __ARGS((char_u *s, char_u *buf, int room));
431 int emsg __ARGS((char_u *s));
432 int emsg2 __ARGS((char_u *s, char_u *a1));
433+ int emsg3 __ARGS((char_u *s, char_u *a1, char_u *a2));
434 int emsgn __ARGS((char_u *s, long n));
435 char_u *msg_trunc_attr __ARGS((char_u *s, int force, int attr));
436 char_u *msg_may_trunc __ARGS((int force, char_u *s));
437*** ../vim-6.2.222/src/misc2.c Sun Jan 18 20:58:01 2004
438--- src/misc2.c Sun Feb 1 15:26:21 2004
439***************
440*** 896,902 ****
441 {
442 /* Don't hide this message */
443 emsg_silent = 0;
444! EMSG2(_("E342: Out of memory! (allocating %lu bytes)"), size);
445 did_outofmem_msg = TRUE;
446 }
447 }
448--- 896,902 ----
449 {
450 /* Don't hide this message */
451 emsg_silent = 0;
452! EMSGN(_("E342: Out of memory! (allocating %lu bytes)"), size);
453 did_outofmem_msg = TRUE;
454 }
455 }
456*** ../vim-6.2.222/src/netbeans.c Fri Jan 30 21:03:16 2004
457--- src/netbeans.c Sun Feb 1 15:21:15 2004
458***************
459*** 272,278 ****
460
461 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
462 {
463! perror("socket() in netbeans_connect()");
464 return;
465 }
466
467--- 272,278 ----
468
469 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
470 {
471! PERROR("socket() in netbeans_connect()");
472 return;
473 }
474
475***************
476*** 289,295 ****
477 sd = open(hostname, O_RDONLY);
478 return;
479 }
480! perror("gethostbyname() in netbeans_connect()");
481 sd = -1;
482 return;
483 }
484--- 289,295 ----
485 sd = open(hostname, O_RDONLY);
486 return;
487 }
488! PERROR("gethostbyname() in netbeans_connect()");
489 sd = -1;
490 return;
491 }
492***************
493*** 297,303 ****
494 #else
495 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
496 {
497! perror("socket()");
498 return;
499 }
500
501--- 297,303 ----
502 #else
503 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
504 {
505! PERROR("socket()");
506 return;
507 }
508
509***************
510*** 314,326 ****
511 #ifdef INET_SOCKETS
512 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
513 {
514! perror("socket()#2 in netbeans_connect()");
515 return;
516 }
517 #else
518 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
519 {
520! perror("socket()#2 in netbeans_connect()");
521 return;
522 }
523 #endif
524--- 314,326 ----
525 #ifdef INET_SOCKETS
526 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
527 {
528! PERROR("socket()#2 in netbeans_connect()");
529 return;
530 }
531 #else
532 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
533 {
534! PERROR("socket()#2 in netbeans_connect()");
535 return;
536 }
537 #endif
538***************
539*** 343,349 ****
540 if (!success)
541 {
542 /* Get here when the server can't be found. */
543! perror(_("Cannot connect to Netbeans #2"));
544 getout(1);
545 }
546 }
547--- 343,349 ----
548 if (!success)
549 {
550 /* Get here when the server can't be found. */
551! PERROR(_("Cannot connect to Netbeans #2"));
552 getout(1);
553 }
554 }
555***************
556*** 351,357 ****
557 }
558 else
559 {
560! perror(_("Cannot connect to Netbeans"));
561 getout(1);
562 }
563 }
564--- 351,357 ----
565 }
566 else
567 {
568! PERROR(_("Cannot connect to Netbeans"));
569 getout(1);
570 }
571 }
572***************
573*** 630,636 ****
574 netbeans_disconnect();
575 nbdebug(("messageFromNetbeans: Error in read() from socket\n"));
576 if (len < 0)
577! perror(_("read from Netbeans socket"));
578 return; /* don't try to parse it */;
579 }
580
581--- 630,636 ----
582 netbeans_disconnect();
583 nbdebug(("messageFromNetbeans: Error in read() from socket\n"));
584 if (len < 0)
585! PERROR(_("read from Netbeans socket"));
586 return; /* don't try to parse it */;
587 }
588
589*** ../vim-6.2.222/src/vim.h Wed Nov 5 10:32:28 2003
590--- src/vim.h Sun Feb 1 15:17:21 2004
591***************
592*** 1242,1247 ****
593--- 1242,1255 ----
594 #define MSG_PUTS_LONG(s) msg_puts_long((char_u *)(s))
595 #define MSG_PUTS_LONG_ATTR(s, a) msg_puts_long_attr((char_u *)(s), (a))
596
597+ /* Prefer using emsg3(), because perror() may send the output to the wrong
598+ * destination and mess up the screen. */
599+ #ifdef HAVE_STRERROR
600+ # define PERROR(msg) (void)emsg3((char_u *)"%s: %s", (char_u *)msg, (char_u *)strerror(errno))
601+ #else
602+ # define PERROR(msg) perror(msg)
603+ #endif
604+
605 typedef long linenr_T; /* line number type */
606 typedef unsigned colnr_T; /* column number type */
607 typedef unsigned short disptick_T; /* display tick type */
608*** ../vim-6.2.222/src/version.c Mon Feb 2 10:03:01 2004
609--- src/version.c Mon Feb 2 12:47:46 2004
610***************
611*** 639,640 ****
612--- 639,642 ----
613 { /* Add new patch number below this line */
614+ /**/
615+ 223,
616 /**/
617
618--
619hundred-and-one symptoms of being an internet addict:
62025. You believe nothing looks sexier than a man in boxer shorts illuminated
621 only by a 17" inch svga monitor.
622
623 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
624/// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
625\\\ Project leader for A-A-P -- http://www.A-A-P.org ///
626 \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
This page took 0.104175 seconds and 4 git commands to generate.