4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / usr.bin / mkstr / mkstr.1
CommitLineData
0ff46e36
KB
1.\" Copyright (c) 1980, 1990, 1993
2.\" The Regents of the University of California. All rights reserved.
b763ca03 3.\"
f91fd86d 4.\" %sccs.include.redist.roff%
b763ca03 5.\"
0ff46e36 6.\" @(#)mkstr.1 8.1 (Berkeley) %G%
ef1f0408 7.\"
5325ced3
CL
8.Dd
9.Dt MKSTR 1
f91fd86d 10.Os
5325ced3
CL
11.Sh NAME
12.Nm mkstr
13.Nd create an error message file by massaging C source
14.Sh SYNOPSIS
15.Nm mkstr
16.Op Fl
17.Ar messagefile
18.Ar prefix file ...
19.Sh DESCRIPTION
20.Nm Mkstr
21creates files containing error messages extracted from C source,
22and restructures the same C source, to utilize the created error message
23file.
24The intent of
25.Nm mkstr
26was to reduce the size of large programs and
f91fd86d
CL
27reduce swapping (see
28.Sx BUGS
29section below).
5325ced3
CL
30.Pp
31.Nm Mkstr
32processes each of the specified
33.Ar files ,
34placing a restructured version of the input in a file whose name
b763ca03 35consists of the specified
5325ced3 36.Ar prefix
b763ca03
KM
37and the original name.
38A typical usage of
5325ced3
CL
39.Nm mkstr
40is
f91fd86d
CL
41.Bd -literal -offset indent
42mkstr pistrings xx *.c
43.Ed
5325ced3
CL
44.Pp
45This command causes all the error messages from the C source
b763ca03 46files in the current directory to be placed in the file
5325ced3
CL
47.Ar pistrings
48and restructured copies of the sources to be placed in
b763ca03 49files whose names are prefixed with
f91fd86d 50.Ar \&xx .
5325ced3
CL
51.Pp
52Options:
f91fd86d
CL
53.Bl -tag -width indent
54.It Fl
5325ced3
CL
55Error messages are placed at the end of the specified
56message file for recompiling part of a large
57.Nm mkstr
58ed
59program.
f91fd86d 60.El
5325ced3
CL
61.Pp
62.Nm mkstr
63finds error messages in the source by
64searching for the string
65.Li \&`error("'
b763ca03 66in the input stream.
5325ced3
CL
67Each time it occurs, the C string starting at the
68.Sq \&"\&
69is stored
b763ca03 70in the message file followed by a null character and a new-line character;
5325ced3
CL
71The new source is restructured with
72.Xr lseek 2
73pointers into the error message file for retrieval.
f91fd86d 74.Bd -literal -offset indent
5325ced3
CL
75char efilname = "/usr/lib/pi_strings";
76int efil = -1;
77
b763ca03 78error(a1, a2, a3, a4)
5325ced3
CL
79\&{
80 char buf[256];
b763ca03 81
5325ced3 82 if (efil < 0) {
b763ca03 83 efil = open(efilname, 0);
5325ced3 84 if (efil < 0) {
b763ca03
KM
85oops:
86 perror(efilname);
5325ced3 87 exit 1 ;
b763ca03
KM
88 }
89 }
5325ced3
CL
90 if (lseek(efil, (long) a1, 0) \ read(efil, buf, 256) <= 0)
91 goto oops;
b763ca03
KM
92 printf(buf, a2, a3, a4);
93}
f91fd86d 94.Ed
5325ced3
CL
95.Sh SEE ALSO
96.Xr lseek 2 ,
97.Xr xstr 1
98.Sh HISTORY
99.Nm Mkstr
f91fd86d
CL
100appeared in
101.Bx 3.0 .
5325ced3
CL
102.Sh BUGS
103.Nm mkstr
104was intended for the limited architecture of the PDP 11 family.
f91fd86d
CL
105Very few programs actually use it. The pascal interpreter,
106.Xr \&pi 1
5325ced3 107and the editor,
f91fd86d 108.Xr \&ex 1
5325ced3
CL
109are two programs that are built this way.
110It is not an efficient method, the error messages
111should be stored in the program text.