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