xref: /netbsd-src/usr.bin/error/error.1 (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1.\"	$NetBSD: error.1,v 1.14 2010/04/05 21:18:20 joerg Exp $
2.\"
3.\" Copyright (c) 1980, 1990, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"	@(#)error.1	8.1 (Berkeley) 6/6/93
31.\"
32.Dd June 6, 1993
33.Dt ERROR 1
34.Os
35.Sh NAME
36.Nm error
37.Nd analyze and disperse compiler error messages
38.Sh SYNOPSIS
39.Nm
40.Op Fl n
41.Op Fl s
42.Op Fl q
43.Op Fl v
44.Op Fl t Ar suffixlist
45.Op Fl I Ar ignorefile
46.Op name
47.Sh DESCRIPTION
48.Nm
49analyzes and optionally disperses the diagnostic error messages
50produced by a number of compilers and language processors to the source
51file and line where the errors occurred.  It can replace the painful,
52traditional methods of scribbling abbreviations of errors on paper, and
53permits error messages and source code to be viewed simultaneously
54without machinations of multiple windows in a screen editor.
55.Pp
56Options are:
57.Bl -tag -width Ds
58.It Fl n
59Do
60.Em not
61touch any files; all error messages are sent to the
62standard output.
63.It Fl q
64The user is
65.Ar queried
66whether s/he wants to touch the file.
67A ``y'' or ``n'' to the question is necessary to continue.
68Absence of the
69.Fl q
70option implies that all referenced files
71(except those referring to discarded error messages)
72are to be touched.
73.It Fl v
74After all files have been touched,
75overlay the visual editor
76.Xr \&vi 1
77with it set up to edit all files touched,
78and positioned in the first touched file at the first error.
79If
80.Xr \&vi 1
81can't be found, try
82.Xr \&ex 1
83or
84.Xr \&ed 1
85from standard places.
86.It Fl t
87Take the following argument as a suffix list.
88Files whose suffixes do not appear in the suffix list are not touched.
89The suffix list is dot separated, and ``*'' wildcards work.
90Thus the suffix list:
91.Pp
92.Dl ".c.y.foo*.h"
93.Pp
94allows
95.Nm
96to touch files ending with ``.c'', ``.y'', ``.foo*'' and ``.h''.
97.It Fl s
98Print out
99.Em statistics
100regarding the error categorization.
101Not too useful.
102.El
103.Pp
104.Nm
105looks at the error messages,
106either from the specified file
107.Ar name
108or from the standard input,
109and attempts to determine which
110language processor produced each error message,
111determines the source file and line number to which the error message refers,
112determines if the error message is to be ignored or not,
113and inserts the (possibly slightly modified) error message into
114the source file as a comment on the line preceding to which the
115line the error message refers.
116Error messages which can't be categorized by language processor
117or content are not inserted into any file,
118but are sent to the standard output.
119.Nm
120touches source files only after all input has been read.
121.Pp
122.Nm
123is intended to be run
124with its standard input
125connected via a pipe to the error message source.
126Some language processors put error messages on their standard error file;
127others put their messages on the standard output.
128Hence, both error sources should be piped together into
129.Nm .
130For example, when using the
131.Xr csh 1
132syntax,
133.Pp
134.Dl make \-s lint \&| error \-q \-v
135.Pp
136will analyze all the error messages produced
137by whatever programs
138.Xr make 1
139runs when making lint.
140.Pp
141.Nm
142knows about the error messages produced by:
143.Xr make 1 ,
144.Xr \&cc 1 ,
145.Xr cpp 1 ,
146.Ic ccom ,
147.Xr \&as 1 ,
148.Xr \&ld 1 ,
149.Xr lint 1 ,
150.Ic \&pi ,
151.Ic \&pc ,
152.Xr f77 1 ,
153and
154.Em DEC Western Research Modula\-2 .
155.Nm
156knows a standard format for error messages produced by
157the language processors,
158so is sensitive to changes in these formats.
159For all languages except
160.Em Pascal ,
161error messages are restricted to be on one line.
162Some error messages refer to more than one line in more than
163one files;
164.Nm
165will duplicate the error message and insert it at
166all of the places referenced.
167.Pp
168.Nm
169will do one of six things with error messages.
170.Bl -tag -width synchronize
171.It Em synchronize
172Some language processors produce short errors describing
173which file it is processing.
174.Nm
175uses these to determine the file name for languages that
176don't include the file name in each error message.
177These synchronization messages are consumed entirely by
178.Nm .
179.It Em discard
180Error messages from
181.Xr lint 1
182that refer to one of the two
183.Xr lint 1
184libraries,
185.Pa /usr/libdata/lint/llib-lc
186and
187.Pa /usr/libdata/lint/llib-port
188are discarded,
189to prevent accidentally touching these libraries.
190Again, these error messages are consumed entirely by
191.Nm .
192.It Em nullify
193Error messages from
194.Xr lint 1
195can be nullified if they refer to a specific function,
196which is known to generate diagnostics which are not interesting.
197Nullified error messages are not inserted into the source file,
198but are written to the standard output.
199The names of functions to ignore are taken from
200either the file named
201.Pa .errorrc
202in the user's home directory,
203or from the file named by the
204.Fl I
205option.
206If the file does not exist,
207no error messages are nullified.
208If the file does exist, there must be one function
209name per line.
210.It Em not file specific
211Error messages that can't be intuited are grouped together,
212and written to the standard output before any files are touched.
213They will not be inserted into any source file.
214.It Em file specific
215Error message that refer to a specific file,
216but to no specific line,
217are written to the standard output when
218that file is touched.
219.It Em true errors
220Error messages that can be intuited are candidates for
221insertion into the file to which they refer.
222.El
223.Pp
224Only true error messages are candidates for inserting into
225the file they refer to.
226Other error messages are consumed entirely by
227.Nm
228or are written to the standard output.
229.Nm
230inserts the error messages into the source file on the line
231preceding the line the language processor found in error.
232Each error message is turned into a one line comment for the
233language,
234and is internally flagged
235with the string ``###'' at
236the beginning of the error,
237and ``%%%'' at the end of the error.
238This makes pattern searching for errors easier with an editor,
239and allows the messages to be easily removed.
240In addition, each error message contains the source line number
241for the line the message refers to.
242A reasonably formatted source program can be recompiled
243with the error messages still in it,
244without having the error messages themselves cause future errors.
245For poorly formatted source programs in free format languages,
246such as C or Pascal,
247it is possible to insert a comment into another comment,
248which can wreak havoc with a future compilation.
249To avoid this, programs with comments and source
250on the same line should be formatted
251so that language statements appear before comments.
252.Pp
253.Nm
254catches interrupt and terminate signals,
255and if in the insertion phase,
256will orderly terminate what it is doing.
257.Sh FILES
258.Bl -tag -width ~/.errorrc -compact
259.It Pa ~/.errorrc
260function names to ignore for
261.Xr lint 1
262error messages
263.It Pa /dev/tty
264user's teletype
265.El
266.Sh HISTORY
267The
268.Nm
269command
270appeared in
271.Bx 4.0 .
272.Sh AUTHORS
273.An Robert Henry
274.Sh BUGS
275Opens the teletype directly to do user querying.
276.Pp
277Source files with links make a new copy of the file with
278only one link to it.
279.Pp
280Changing a language processor's format of error messages
281may cause
282.Nm
283to not understand the error message.
284.Pp
285.Nm ,
286since it is purely mechanical,
287will not filter out subsequent errors caused by `floodgating'
288initiated by one syntactically trivial error.
289Humans are still much better at discarding these related errors.
290.Pp
291Pascal error messages belong after the lines affected
292(error puts them before).  The alignment of the `\e' marking
293the point of error is also disturbed by
294.Nm .
295.Pp
296.Nm
297was designed for work on
298.Tn CRT Ns 's
299at reasonably high speed.
300It is less pleasant on slow speed terminals, and has never been
301used on hardcopy terminals.
302