Commit | Line | Data |
---|---|---|
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 | |
21 | creates files containing error messages extracted from C source, | |
22 | and restructures the same C source, to utilize the created error message | |
23 | file. | |
24 | The intent of | |
25 | .Nm mkstr | |
26 | was to reduce the size of large programs and | |
f91fd86d CL |
27 | reduce swapping (see |
28 | .Sx BUGS | |
29 | section below). | |
5325ced3 CL |
30 | .Pp |
31 | .Nm Mkstr | |
32 | processes each of the specified | |
33 | .Ar files , | |
34 | placing a restructured version of the input in a file whose name | |
b763ca03 | 35 | consists of the specified |
5325ced3 | 36 | .Ar prefix |
b763ca03 KM |
37 | and the original name. |
38 | A typical usage of | |
5325ced3 CL |
39 | .Nm mkstr |
40 | is | |
f91fd86d CL |
41 | .Bd -literal -offset indent |
42 | mkstr pistrings xx *.c | |
43 | .Ed | |
5325ced3 CL |
44 | .Pp |
45 | This command causes all the error messages from the C source | |
b763ca03 | 46 | files in the current directory to be placed in the file |
5325ced3 CL |
47 | .Ar pistrings |
48 | and restructured copies of the sources to be placed in | |
b763ca03 | 49 | files whose names are prefixed with |
f91fd86d | 50 | .Ar \&xx . |
5325ced3 CL |
51 | .Pp |
52 | Options: | |
f91fd86d CL |
53 | .Bl -tag -width indent |
54 | .It Fl | |
5325ced3 CL |
55 | Error messages are placed at the end of the specified |
56 | message file for recompiling part of a large | |
57 | .Nm mkstr | |
58 | ed | |
59 | program. | |
f91fd86d | 60 | .El |
5325ced3 CL |
61 | .Pp |
62 | .Nm mkstr | |
63 | finds error messages in the source by | |
64 | searching for the string | |
65 | .Li \&`error("' | |
b763ca03 | 66 | in the input stream. |
5325ced3 CL |
67 | Each time it occurs, the C string starting at the |
68 | .Sq \&"\& | |
69 | is stored | |
b763ca03 | 70 | in the message file followed by a null character and a new-line character; |
5325ced3 CL |
71 | The new source is restructured with |
72 | .Xr lseek 2 | |
73 | pointers into the error message file for retrieval. | |
f91fd86d | 74 | .Bd -literal -offset indent |
5325ced3 CL |
75 | char efilname = "/usr/lib/pi_strings"; |
76 | int efil = -1; | |
77 | ||
b763ca03 | 78 | error(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 |
85 | oops: |
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 |
100 | appeared in |
101 | .Bx 3.0 . | |
5325ced3 CL |
102 | .Sh BUGS |
103 | .Nm mkstr | |
104 | was intended for the limited architecture of the PDP 11 family. | |
f91fd86d CL |
105 | Very few programs actually use it. The pascal interpreter, |
106 | .Xr \&pi 1 | |
5325ced3 | 107 | and the editor, |
f91fd86d | 108 | .Xr \&ex 1 |
5325ced3 CL |
109 | are two programs that are built this way. |
110 | It is not an efficient method, the error messages | |
111 | should be stored in the program text. |