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