Commit | Line | Data |
---|---|---|
7bfc2099 WJ |
1 | .\" Copyright (c) 1980 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms, with or without | |
5 | .\" modification, are permitted provided that the following conditions | |
6 | .\" are met: | |
7 | .\" 1. Redistributions of source code must retain the above copyright | |
8 | .\" notice, this list of conditions and the following disclaimer. | |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer in the | |
11 | .\" documentation and/or other materials provided with the distribution. | |
12 | .\" 3. All advertising materials mentioning features or use of this software | |
13 | .\" must display the following acknowledgement: | |
14 | .\" This product includes software developed by the University of | |
15 | .\" California, Berkeley and its contributors. | |
16 | .\" 4. Neither the name of the University nor the names of its contributors | |
17 | .\" may be used to endorse or promote products derived from this software | |
18 | .\" without specific prior written permission. | |
19 | .\" | |
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | .\" SUCH DAMAGE. | |
31 | .\" | |
32 | .\" @(#)xstr.1 6.4 (Berkeley) 4/24/91 | |
33 | .\" | |
34 | .Dd April 24, 1991 | |
35 | .Dt XSTR 1 | |
36 | .Os BSD 3 | |
37 | .Sh NAME | |
38 | .Nm xstr | |
39 | .Nd "extract strings from C programs to implement shared strings" | |
40 | .Sh SYNOPSIS | |
41 | .Nm xstr | |
42 | .Op Fl c | |
43 | .Op Fl | |
44 | .Op Ar file | |
45 | .Sh DESCRIPTION | |
46 | .Nm Xstr | |
47 | maintains a file | |
48 | .Pa strings | |
49 | into which strings in component parts of a large program are hashed. | |
50 | These strings are replaced with references to this common area. | |
51 | This serves to implement shared constant strings, most useful if they | |
52 | are also read-only. | |
53 | .Pp | |
54 | Available options: | |
55 | .Bl -tag -width Ds | |
56 | .It Fl | |
57 | .Nm Xstr | |
58 | reads from the standard input. | |
59 | .It Fl c | |
60 | .Nm Xstr | |
61 | will extract the strings from the C source | |
62 | .Ar file | |
63 | or the standard input | |
64 | .Pq Fl , | |
65 | replacing | |
66 | string references by expressions of the form (&xstr[number]) | |
67 | for some number. | |
68 | An appropriate declaration of | |
69 | .Nm xstr | |
70 | is prepended to the file. | |
71 | The resulting C text is placed in the file | |
72 | .Pa x.c , | |
73 | to then be compiled. | |
74 | The strings from this file are placed in the | |
75 | .Pa strings | |
76 | data base if they are not there already. | |
77 | Repeated strings and strings which are suffices of existing strings | |
78 | do not cause changes to the data base. | |
79 | .El | |
80 | .Pp | |
81 | After all components of a large program have been compiled a file | |
82 | .Pa xs.c | |
83 | declaring the common | |
84 | .Nm xstr | |
85 | space can be created by a command of the form | |
86 | .Bd -literal -offset indent | |
87 | xstr | |
88 | .Ed | |
89 | .Pp | |
90 | The file | |
91 | .Pa xs.c | |
92 | should then be compiled and loaded with the rest | |
93 | of the program. | |
94 | If possible, the array can be made read-only (shared) saving | |
95 | space and swap overhead. | |
96 | .Pp | |
97 | .Nm Xstr | |
98 | can also be used on a single file. | |
99 | A command | |
100 | .Bd -literal -offset indent | |
101 | xstr name | |
102 | .Ed | |
103 | .Pp | |
104 | creates files | |
105 | .Pa x.c | |
106 | and | |
107 | .Pa xs.c | |
108 | as before, without using or affecting any | |
109 | .Pa strings | |
110 | file in the same directory. | |
111 | .Pp | |
112 | It may be useful to run | |
113 | .Nm xstr | |
114 | after the C preprocessor if any macro definitions yield strings | |
115 | or if there is conditional code which contains strings | |
116 | which may not, in fact, be needed. | |
117 | An appropriate command sequence for running | |
118 | .Nm xstr | |
119 | after the C preprocessor is: | |
120 | .Pp | |
121 | .Bd -literal -offset indent -compact | |
122 | cc \-E name.c | xstr \-c \- | |
123 | cc \-c x.c | |
124 | mv x.o name.o | |
125 | .Ed | |
126 | .Pp | |
127 | .Nm Xstr | |
128 | does not touch the file | |
129 | .Pa strings | |
130 | unless new items are added, thus | |
131 | .Xr make 1 | |
132 | can avoid remaking | |
133 | .Pa xs.o | |
134 | unless truly necessary. | |
135 | .Sh FILES | |
136 | .Bl -tag -width /tmp/xsxx* -compact | |
137 | .It Pa strings | |
138 | Data base of strings | |
139 | .It Pa x.c | |
140 | Massaged C source | |
141 | .It Pa xs.c | |
142 | C source for definition of array `xstr' | |
143 | .It Pa /tmp/xs* | |
144 | Temp file when `xstr name' doesn't touch | |
145 | .Pa strings | |
146 | .El | |
147 | .Sh SEE ALSO | |
148 | .Xr mkstr 1 | |
149 | .Sh BUGS | |
150 | If a string is a suffix of another string in the data base, | |
151 | but the shorter string is seen first by | |
152 | .Nm xstr | |
153 | both strings will be placed in the data base, when just | |
154 | placing the longer one there will do. | |
155 | .Sh HISTORY | |
156 | The | |
157 | .Nm | |
158 | command appeared in | |
159 | .Bx 3.0 . |