Annotation of src/usr.bin/mkstr/mkstr.1, Revision 1.1.1.1
1.1 deraadt 1: .\" $NetBSD: mkstr.1,v 1.3 1995/09/28 06:22:19 tls 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. All advertising materials mentioning features or use of this software
15: .\" must display the following acknowledgement:
16: .\" This product includes software developed by the University of
17: .\" California, Berkeley and its contributors.
18: .\" 4. Neither the name of the University nor the names of its contributors
19: .\" may be used to endorse or promote products derived from this software
20: .\" without specific prior written permission.
21: .\"
22: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32: .\" SUCH DAMAGE.
33: .\"
34: .\" @(#)mkstr.1 8.1 (Berkeley) 6/6/93
35: .\"
36: .Dd June 6, 1993
37: .Dt MKSTR 1
38: .Os
39: .Sh NAME
40: .Nm mkstr
41: .Nd create an error message file by massaging C source
42: .Sh SYNOPSIS
43: .Nm mkstr
44: .Op Fl
45: .Ar messagefile
46: .Ar prefix file ...
47: .Sh DESCRIPTION
48: .Nm Mkstr
49: creates files containing error messages extracted from C source,
50: and restructures the same C source, to utilize the created error message
51: file.
52: The intent of
53: .Nm mkstr
54: was to reduce the size of large programs and
55: reduce swapping (see
56: .Sx BUGS
57: section below).
58: .Pp
59: .Nm Mkstr
60: processes each of the specified
61: .Ar files ,
62: placing a restructured version of the input in a file whose name
63: consists of the specified
64: .Ar prefix
65: and the original name.
66: A typical usage of
67: .Nm mkstr
68: is
69: .Bd -literal -offset indent
70: mkstr pistrings xx *.c
71: .Ed
72: .Pp
73: This command causes all the error messages from the C source
74: files in the current directory to be placed in the file
75: .Ar pistrings
76: and restructured copies of the sources to be placed in
77: files whose names are prefixed with
78: .Ar \&xx .
79: .Pp
80: Options:
81: .Bl -tag -width indent
82: .It Fl
83: Error messages are placed at the end of the specified
84: message file for recompiling part of a large
85: .Nm mkstr
86: ed
87: program.
88: .El
89: .Pp
90: .Nm mkstr
91: finds error messages in the source by
92: searching for the string
93: .Li \&`error("'
94: in the input stream.
95: Each time it occurs, the C string starting at the
96: .Sq \&"\&
97: is stored
98: in the message file followed by a null character and a new-line character;
99: The new source is restructured with
100: .Xr lseek 2
101: pointers into the error message file for retrieval.
102: .Bd -literal -offset indent
103: char efilname = "/usr/lib/pi_strings";
104: int efil = -1;
105:
106: error(a1, a2, a3, a4)
107: \&{
108: char buf[256];
109:
110: if (efil < 0) {
111: efil = open(efilname, 0);
112: if (efil < 0) {
113: oops:
114: perror(efilname);
115: exit 1 ;
116: }
117: }
118: if (lseek(efil, (long) a1, 0) \ read(efil, buf, 256) <= 0)
119: goto oops;
120: printf(buf, a2, a3, a4);
121: }
122: .Ed
123: .Sh SEE ALSO
124: .Xr lseek 2 ,
125: .Xr xstr 1
126: .Sh HISTORY
127: .Nm Mkstr
128: appeared in
129: .Bx 3.0 .
130: .Sh BUGS
131: .Nm mkstr
132: was intended for the limited architecture of the PDP 11 family.
133: Very few programs actually use it. The pascal interpreter,
134: .Xr \&pi 1
135: and the editor,
136: .Xr \&ex 1
137: are two programs that are built this way.
138: It is not an efficient method, the error messages
139: should be stored in the program text.