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