1XSTR(1) 386BSD Reference Manual XSTR(1) 2 3NNAAMMEE 4 xxssttrr - extract strings from C programs to implement shared strings 5 6SSYYNNOOPPSSIISS 7 xxssttrr [--cc] [--] [_f_i_l_e] 8 9DDEESSCCRRIIPPTTIIOONN 10 XXssttrr maintains a file _s_t_r_i_n_g_s into which strings in component parts of a 11 large program are hashed. These strings are replaced with references to 12 this common area. This serves to implement shared constant strings, most 13 useful if they are also read-only. 14 15 Available options: 16 17 -- XXssttrr reads from the standard input. 18 19 --cc XXssttrr will extract the strings from the C source _f_i_l_e or the 20 standard input (--), replacing string references by expressions of 21 the form (&xstr[number]) for some number. An appropriate 22 declaration of xxssttrr is prepended to the file. The resulting C 23 text is placed in the file _x._c, to then be compiled. The strings 24 from this file are placed in the _s_t_r_i_n_g_s data base if they are 25 not there already. Repeated strings and strings which are 26 suffices of existing strings do not cause changes to the data 27 base. 28 29 After all components of a large program have been compiled a file _x_s._c 30 declaring the common xxssttrr space can be created by a command of the form 31 32 xstr 33 34 The file _x_s._c should then be compiled and loaded with the rest of the 35 program. If possible, the array can be made read-only (shared) saving 36 space and swap overhead. 37 38 XXssttrr can also be used on a single file. A command 39 40 xstr name 41 42 creates files _x._c and _x_s._c as before, without using or affecting any 43 _s_t_r_i_n_g_s file in the same directory. 44 45 It may be useful to run xxssttrr after the C preprocessor if any macro 46 definitions yield strings or if there is conditional code which contains 47 strings which may not, in fact, be needed. An appropriate command 48 sequence for running xxssttrr after the C preprocessor is: 49 50 cc -E name.c | xstr -c - 51 cc -c x.c 52 mv x.o name.o 53 54 XXssttrr does not touch the file _s_t_r_i_n_g_s unless new items are added, thus 55 make(1) can avoid remaking _x_s._o unless truly necessary. 56 57FFIILLEESS 58 strings Data base of strings 59 x.c Massaged C source 60 xs.c C source for definition of array `xstr' 61 /tmp/xs* Temp file when `xstr name' doesn't touch _s_t_r_i_n_g_s 62 63SSEEEE AALLSSOO 64 mkstr(1) 65 66BBUUGGSS 67 If a string is a suffix of another string in the data base, but the 68 shorter string is seen first by xxssttrr both strings will be placed in the 69 data base, when just placing the longer one there will do. 70 71HHIISSTTOORRYY 72 The xxssttrr command appeared in 3.0BSD. 73 743rd Berkeley Distribution April 24, 1991 2 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133