1XSTR(1) General Commands Manual XSTR(1)
2
3
4
6 xstr - extract strings from C programs to implement shared strings
7
9 xstr [ -c ] [ - ] [ file ]
10
12 Xstr maintains a file strings into which strings in component parts of
13 a large program are hashed. These strings are replaced with references
14 to this common area. This serves to implement shared constant strings,
15 most useful if they are also read-only.
16
17 The command
18
19 xstr -c name
20
21 will extract the strings from the C source in name, replacing string
22 references by expressions of the form (&xstr[number]) for some number.
23 An appropriate declaration of xstr is prepended to the file. The
24 resulting C text is placed in the file x.c, to then be compiled. The
25 strings from this file are placed in the strings data base if they are
26 not there already. Repeated strings and strings which are suffices of
27 existing strings do not cause changes to the data base.
28
29 After all components of a large program have been compiled a file xs.c
30 declaring the common xstr space can be created by a command of the form
31
32 xstr
33
34 This xs.c file should then be compiled and loaded with the rest of the
35 program. If possible, the array can be made read-only (shared) saving
36 space and swap overhead.
37
38 Xstr can also be used on a single file. A command
39
40 xstr name
41
42 creates files x.c and xs.c as before, without using or affecting any
43 strings file in the same directory.
44
45 It may be useful to run xstr after the C preprocessor if any macro def‐
46 initions yield strings or if there is conditional code which contains
47 strings which may not, in fact, be needed. Xstr reads from its stan‐
48 dard input when the argument `-' is given. An appropriate command
49 sequence for running xstr after the C preprocessor is:
50
51 cc -E name.c | xstr -c -
52 cc -c x.c
53 mv x.o name.o
54
55 Xstr does not touch the file strings unless new items are added, thus
56 make can avoid remaking xs.o unless truly necessary.
57
59 strings Data base of strings
60 x.c Massaged C source
61 xs.c C source for definition of array `xstr'
62 /tmp/xs* Temp file when `xstr name' doesn't touch strings
63
65 mkstr(1)
66
68 If a string is a suffix of another string in the data base, but the
69 shorter string is seen first by xstr both strings will be placed in the
70 data base, when just placing the longer one there will do.
71
72
73
743rd Berkeley Distribution May 7, 1986 XSTR(1)