Creates an error message file.
mkstr [ - ] MessageFile Prefix File ...
The mkstr command creates a file of error messages that can be removed from a single C source file or from multiple source files. Its use can reduce the size of programs that contain many error diagnostics and reduce system overhead in running such programs, because error messages are then not constantly swapped in and out of the source files.
The mkstr command processes each file specified by the File parameter, placing a massaged version of the file in a file having the name specified by the Prefix parameter followed by the original name.
To process the error messages in the source to the file specified by the MessageFile parameter, the mkstr command keys on the string `error("' in the input stream. The string, starting at the '"' (two double quotation marks), is placed in the message file and followed by a null character and a new-line character. The null character terminates the message so it can be easily used when retrieved. The new-line character makes it possible to see the contents of the error message file by using the cat command.
The massaged copy of the input file then contains an lseek pointer into the file, which can be used to retrieve the message to its appropriate source file, as shown in the following example:
char efilname[] = "/usr/lib/pistrings"; int efil = -1; error(a1, a2, a3, a4) { char buf[256]; if (efil < 0) { efil = open(efilname, 0); if (efil < 0) { oops: perror(efilname); exit(1); } } if (lseek(efil,(long) a1,0) <0|| read(efil,buf, 256) <= 0) goto oops; printf(buf, a2, a3, a4); }
- | The optional - (minus sign) causes the error messages to be placed at the end of the MessageFile for recompiling part of a large mkstr program. |
mkstr pistrings xx *.c
mkstr - pistrings xx newfile.c
/usr/ccs/bin/mkstr | Contains the mkstr command. |
The cat command, xstr command.
The lseek subroutine.