Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ xstr.bsd(1) — Domain/IX SR9.5

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

mkstr(1)

XSTR(1)

NAME

xstr − extract strings from C programs to implement shared strings

USAGE

xstr [ −c ] [ − ] [ file ]

DESCRIPTION

Xstr maintains a file 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, which are most useful if they are also read-only. 

The following command extracts the strings from the C source in name, replacing string references by expressions of the form (&xstr[number]) for some number:

xstr −c name

An appropriate declaration of xstr is prepended to the file.  The resulting C text is placed in the file x.c, to then be compiled.  The strings from this file are placed in the strings database if they are not there already.  Repeated strings and strings that are suffixes of existing strings do not cause changes to the database. 

After all components of a large program have been compiled, a file xs.c declaring the common xstr space can be created by using the xstr command without any arguments.  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. 

Xstr can also be used on a single file.  The command below creates files x.c and xs.c as before, without using or affecting any strings file in the same directory:

xstr name

It may be useful to run xstr after the C preprocessor if any macro definitions yield strings, or if there is conditional code that contains strings which may not, in fact, be needed.  Xstr reads from its standard input when a single dash (−) is given as an argument.  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

Xstr does not touch the file strings unless new items are added.  Thus, make(1) avoids remaking xs.o unless truly necessary. 

CAUTIONS

When running xstr in a pipeline after the C preprocessor, some preprocessor error messages may be converted into references to strings in the strings database. 

FILES

stringsdatabase of strings
x.cmassaged C source
xs.cC source for definition of array xstr
/tmp/xs*temporary file when xstr name does not touch strings

RELATED INFORMATION

mkstr(1). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026