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