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