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