7
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <string.h>
|
|
4 #include <unixio.h>
|
|
5 #include "vim.h"
|
|
6 int main(int argc, char *argv[])
|
|
7 {
|
|
8 FILE *fpi, *fpo;
|
|
9 char cmd[132], buf[BUFSIZ], *argp, *error_file, target[132], *mms;
|
|
10 int err = 0, err_line = 0;
|
|
11
|
|
12 mms = "mms";
|
|
13 argc--;
|
|
14 argv++;
|
|
15 while (argc-- > 0)
|
|
16 {
|
|
17 argp = *argv++;
|
|
18 if (*argp == '-')
|
|
19 {
|
|
20 switch (*++argp)
|
|
21 {
|
|
22 case 'm':
|
|
23 mms = ++argp;
|
|
24 break;
|
|
25 case 'e':
|
|
26 if (!*(error_file = ++argp))
|
|
27 {
|
|
28 error_file = *argv++;
|
|
29 argc--;
|
|
30 }
|
|
31 break;
|
|
32 default:
|
|
33 break;
|
|
34 }
|
|
35 }
|
|
36 else
|
|
37 {
|
|
38 if (*target)
|
|
39 strcat(target, " ");
|
|
40 strcat(target, argp);
|
|
41 }
|
|
42 }
|
|
43 sprintf(cmd, "%s/output=tmp:errors.vim_tmp %s", mms, target);
|
|
44 system(cmd);
|
|
45 fpi = fopen("tmp:errors.vim_tmp", "r");
|
|
46 fpo = fopen(error_file, "w");
|
|
47 while (fgets(buf, BUFSIZ, fpi))
|
|
48 {
|
|
49 if (!memcmp(buf, "%CC-", 4))
|
|
50 {
|
|
51 err_line++;
|
|
52 buf[strlen(buf)-1] = '\0';
|
|
53 err++;
|
|
54 }
|
|
55 else
|
|
56 {
|
|
57 if (err_line)
|
|
58 {
|
|
59 if (strstr(buf, _("At line")))
|
|
60 {
|
|
61 err_line = 0;
|
|
62 fprintf(fpo, "@");
|
|
63 }
|
|
64 else
|
|
65 buf[strlen(buf)-1] = '\0';
|
|
66 }
|
|
67 }
|
|
68 fprintf(fpo, "%s", buf);
|
|
69 }
|
|
70 fclose(fpi);
|
|
71 fclose(fpo);
|
|
72 while (!delete("tmp:errors.vim_tmp"))
|
|
73 /*nop*/;
|
|
74 exit(err ? 44 : 1);
|
|
75 return(0);
|
|
76 }
|