| 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) %G% |
| 7 | .\" |
| 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 |
| 32 | consists of the specified |
| 33 | .Ar prefix |
| 34 | and the original name. |
| 35 | A typical usage of |
| 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 |
| 42 | files in the current directory to be placed in the file |
| 43 | .Ar pistrings |
| 44 | and restructured copies of the sources to be placed in |
| 45 | files whose names are prefixed with |
| 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("' |
| 62 | in the input stream. |
| 63 | Each time it occurs, the C string starting at the |
| 64 | .Sq \&"\& |
| 65 | is stored |
| 66 | in the message file followed by a null character and a new-line character; |
| 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 | |
| 74 | error(a1, a2, a3, a4) |
| 75 | \&{ |
| 76 | char buf[256]; |
| 77 | |
| 78 | if (efil < 0) { |
| 79 | efil = open(efilname, 0); |
| 80 | if (efil < 0) { |
| 81 | oops: |
| 82 | perror(efilname); |
| 83 | exit 1 ; |
| 84 | } |
| 85 | } |
| 86 | if (lseek(efil, (long) a1, 0) \ read(efil, buf, 256) <= 0) |
| 87 | goto oops; |
| 88 | printf(buf, a2, a3, a4); |
| 89 | } |
| 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. |