BSD 3 development
[unix-history] / usr / man / man1 / xstr.1
CommitLineData
1b2273c1
BJ
1.TH XSTR 1 2/24/79
2.UC
3.SH NAME
4xstr \- extract strings from C programs to implement shared strings
5.SH SYNOPSIS
6.B xstr
7[
8.B \-c
9] [
10.B \-
11] [
12file
13]
14.SH DESCRIPTION
15.I Xstr
16maintains a file
17.I strings
18into which strings in component parts of a large program are hashed.
19These strings are replaced with references to this common area.
20This serves to implement shared constant strings, most useful if they
21are also read-only.
22.PP
23The command
24.PP
25.DT
26 \fBxstr \-c\fR name
27.PP
28will extract the strings from the C source in name, replacing
29string references by expressions of the form (&xstr[number])
30for some number.
31An approporiate declaration of
32.I xstr
33is prepended to the file.
34The resulting C text is placed in the file
35.I x.c,
36to then be compiled.
37The strings from this file are placed in the
38.I strings
39data base if they are not there already.
40Repeated strings and strings which are suffices of existing strings
41do not cause changes to the data base.
42.PP
43After all components of a large program have been compiled a file
44.I xs.c
45declaring the common
46.I xstr
47space can be created by a command of the form
48.PP
49.DT
50 \fBxstr\fR
51.PP
52This
53.I xs.c
54file should then be compiled and loaded with the rest
55of the program.
56If possible, the array can be made read-only (shared) saving
57space and swap overhead.
58.PP
59.I Xstr
60can also be used on a single file.
61A command
62.PP
63.DT
64 \fBxstr\fR name
65.PP
66creates files
67.I x.c
68and
69.I xs.c
70as before, without using or affecting any
71.I strings
72file in the same directory.
73.PP
74It may be useful to run
75.I xstr
76after the C preprocessor if any macro definitions yield strings
77or if there is conditional code which contains strings
78which may not, in fact, be needed.
79.I Xstr
80reads from its standard input when the argument `\-' is given.
81An appropriate command sequence for running
82.I xstr
83after the C preprocessor is:
84.PP
85.nf
86.DT
87 \fBcc \-E\fR name.c | \fBxstr \-c\fR \-
88 \fBcc \-c\fR x.c
89 \fBmv\fR x.o name.o
90.fi
91.PP
92.I Xstr
93does not touch the file
94.I strings
95unless new items are added, thus
96.I make
97can avoid remaking
98.I xs.o
99unless truly necessary.
100.SH FILES
101.DT
102strings Data base of strings
103.br
104x.c Massaged C source
105.br
106xs.c C source for definition of array `xstr'
107.br
108/tmp/xs* Temp file when `xstr name' doesn't touch
109.I strings
110.SH "SEE ALSO"
111mkstr(1)
112.SH AUTHOR
113William Joy
114.SH BUGS
115If a string is a suffix of another string in the data base,
116but the shorter string is seen first by
117.I xstr
118both strings will be placed in the data base, when just
119placing the longer one there will do.