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