xstr(1) xstr(1)NAME xstr - reports strings from C programs to implement shared strings SYNOPSIS xstr [-] [-c] [file] ARGUMENTS - Causes xstr to read from its standard input. -c Extracts the strings from the C source program into file, replacing string references by expressions of the form (&xstr [number])for some number. An appropriate declaration of xstr is prefixed to file. The resulting C text is placed in the file x.c, to then be compiled. The strings from file are placed in the strings data base if they are not already there. Repeated strings and strings which are suffices of existing strings do not cause changes to the data base. file Specifies the name of the file that the strings will be extracted from. DESCRIPTION xstr maintains a file called strings into which strings in component parts of a large program are hashed. These strings are replaced with references to this common area. This serves to implement shared constant strings, most useful if they are also read-only. After all components of a large program have been compiled, a file xs.c declaring the common xstr space can be created by a command of the form xstr This xs.c file should then be compiled and loaded with the rest of the program. If possible, the array can be made read-only (shared) saving space and swap overhead. It may be useful to run xstr after the C preprocessor if any macro definitions yield strings or if there is conditional code which contains strings which may not, in fact, be needed. January 1992 1
xstr(1) xstr(1)EXAMPLES An appropriate command sequence for running xstr after the C preprocessor is: cc -E file.c | xstr -c - cc -c x.c mv x.o file.o The xstr program does not touch the file strings unless new items are added, thus make can avoid remaking xs.o unless truly necessary. The xstr program can also be used on a single file. A command xstr file creates files x.c and xs.c as before, without using or affecting any strings file in the same directory. STATUS MESSAGES AND VALUES If a string is a suffix of another string in the data base, but the shorter string is seen first by xstr both strings will be placed in the data base, when just placing the longer one there will do. FILES /usr/bin/xstr Executable file strings Data base of strings x.c Massaged C source file xs.c C source file for definition of array xstr /tmp/xs* Temporary file when ``xstr file''doesn't touch strings SEE ALSO mkstr(1), strings(1) 2 January 1992