xstr(1) (BSD Compatibility Package) xstr(1)
NAME
xstr - extract strings from C programs to implement shared strings
SYNOPSIS
/usr/ucb/xstr [-v] [-c] [-l name] [file]
DESCRIPTION
xstr maintains a strings file into which strings in component parts of
a large program are hashed. The strings are replaced with references
to this common area. This serves to implement shared constant strings.
The
xstr -c file
command will extract the strings from the C source in file and replace
string references with expressions of the form (&xstr[number]). A
declaration of xstr is prepended to the file. The resulting C source
code is placed in the x.c file for compiling. The strings from the
file file are placed in the strings file if they are not there
already. Repeated strings and strings which are suffixes of existing
strings do not initiate changes in the database.
Once all components of a large program have been compiled, an xs.c
file can be created with
xstr
which defines the common xstr array. This xs.c file should then be
compiled and loaded with the rest of the program.
xstr does not touch the strings file unless new items are added. make
can therefore avoid remaking xs.o unless absolutely necessary.
xstr can also be used on a single file. The
xstr file
command creates x.c and xs.c files as before, without using or touch-
ing any strings file in the same directory.
It may be useful to run xstr after the C preprocessor if any macro
definitions yield strings or if there is conditional code which con-
tains strings. xstr reads from its standard input when the "-" argu-
ment is given instead of file. An appropriate command sequence for
running xstr after the C preprocessor is:
cc -E name.c | xstr -c -
cc -c x.c
mv x.o name.o
Page 1 Reliant UNIX 5.44 Printed 11/98
xstr(1) (BSD Compatibility Package) xstr(1)
OPTIONS
-v (verbose) The changes to the strings file are logged to
standard error.
-c Handles individual source files of a large program (similar
to cc -c file).
-l name The array bears the name name in x.c and xs.c instead of
xstr.
NOTES
If a string is a suffix of another string in the strings file, but the
shorter string is seen first by xstr, both strings will be placed in
the strings file, whereas just the longer one would suffice.
FILES
strings Strings file
x.c Massaged C source
xs.c C source for definition of array xstr
SEE ALSO
cc(1-ucb).
Page 2 Reliant UNIX 5.44 Printed 11/98