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