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