Merge branch 'vim'
[MacVim/KaoriYa.git] / src / os_vms_mms.c
blob4da7b1ad410cf22b81700bf3845e0cf680a5ec79
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[])
8 FILE *fpi, *fpo;
9 char cmd[132], buf[BUFSIZ], *argp, *error_file, target[132], *mms;
10 int err = 0, err_line = 0;
12 mms = "mms";
13 argc--;
14 argv++;
15 while (argc-- > 0)
17 argp = *argv++;
18 if (*argp == '-')
20 switch (*++argp)
22 case 'm':
23 mms = ++argp;
24 break;
25 case 'e':
26 if (!*(error_file = ++argp))
28 error_file = *argv++;
29 argc--;
31 break;
32 default:
33 break;
36 else
38 if (*target)
39 strcat(target, " ");
40 strcat(target, argp);
43 vim_snprintf(cmd, sizeof(cmd), "%s/output=tmp:errors.vim_tmp %s",
44 mms, target);
45 system(cmd);
46 fpi = fopen("tmp:errors.vim_tmp", "r");
47 fpo = fopen(error_file, "w");
48 while (fgets(buf, BUFSIZ, fpi))
50 if (!memcmp(buf, "%CC-", 4))
52 err_line++;
53 buf[strlen(buf)-1] = '\0';
54 err++;
56 else
58 if (err_line)
60 if (strstr(buf, _("At line")))
62 err_line = 0;
63 fprintf(fpo, "@");
65 else
66 buf[strlen(buf)-1] = '\0';
69 fprintf(fpo, "%s", buf);
71 fclose(fpi);
72 fclose(fpo);
73 while (!delete("tmp:errors.vim_tmp"))
74 /*nop*/;
75 exit(err ? 44 : 1);
76 return(0);