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