-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy patherrlog.c
135 lines (127 loc) · 2.91 KB
/
errlog.c
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
/* Routines for parsing an error log */
/* Copyright (c) 1981,1980 James Gosling */
#include "buffer.h"
#include "window.h"
#include "keyboard.h"
#include <sys/param.h>
char *malloc();
struct err { /* a single error message */
struct marker *e_mess; /* points to the error message */
struct marker *e_text; /* points to the position in the text
where the compiler thinks the error
is */
struct err *e_next; /* the next error in the chain */
};
static struct err
*errors, /* the list of all error messages */
*ThisErr; /* the current error */
/* delete the error list */
DelErl () {
register struct err *e;
while (errors) {
e = errors;
DestMark (e -> e_mess);
DestMark (e -> e_text);
errors = e -> e_next;
}
}
/* Parse error messages from the current buffer from character pos to limit */
ParseErb (pos, limit)
register pos; {
register struct buffer *erb = bf_cur;
char old_fn[MAXPATHLEN];
int old_ln = -1;
DelErl ();
for (;;) {
register ln = 0;
char fn[MAXPATHLEN];
register fnend;
register char *p,
c;
int fnl = 0,
quoted = 0,
bol;
SetBfp (erb);
pos = search (", line ", 1, pos, 0);
if (pos <= 0 || pos >= limit) {
ThisErr = 0;
return errors != 0;
}
fnend = pos - 8;
while (pos <= NumCharacters && (c = CharAt (pos)) >= '0' && c <= '9'){
pos++;
ln = ln * 10 + c - '0';
}
if (ln == 0)
continue;
if (CharAt (fnend) == '"')
quoted++, fnend--;
while (fnend >= 1) {
c = CharAt (fnend);
if (quoted) {
if (c == '"') {
fnend++;
break;
}
}
else
if (c <= ' ') {
fnend++;
break;
}
fnl++;
if(fnend<=1) break;
fnend--;
}
if (fnl == 0)
continue;
for (p = fn; --fnl >= 0; fnend++)
*p++ = CharAt (fnend);
*p++ = 0;
if (old_ln == ln && strcmp (old_fn, fn)==0)
continue;
old_ln = ln;
strcpy (old_fn, fn);
bol = ScanBf ('\n', fnend, -1);
if (!VisitFile (fn, 0, 0))
continue;
if (errors) {
ThisErr -> e_next
= (struct err *) malloc (sizeof (struct err));
ThisErr = ThisErr -> e_next;
}
else
errors = ThisErr
= (struct err *) malloc (sizeof (struct err));
ThisErr -> e_next = 0;
ThisErr -> e_mess = NewMark ();
ThisErr -> e_text = NewMark ();
SetMark (ThisErr -> e_mess, erb, bol);
SetMark (ThisErr -> e_text, bf_cur, ScanBf ('\n', 1, ln - 1));
}
}
/* move to the next error message in the log */
NextErr () {
register n;
if (!errors) {
error ("No errors!");
return 0;
}
if (ThisErr == 0)
ThisErr = errors;
else {
ThisErr = ThisErr -> e_next;
if (ThisErr == 0) {
error ("No more errors...");
return 0;
}
}
n = ToMark (ThisErr -> e_mess);
WindowOn (bf_cur);
SetDot (n);
SetMark (wn_cur -> w_start, bf_cur, dot);
n = ToMark (ThisErr -> e_text);
WindowOn (bf_cur);
SetDot (n);
return 1;
}