"Fossies" - the Fresh Open Source Software Archive 
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 This is a list of all the changes to replace since 1.00 was released:
2
3 replace 2.24 (October 2004)
4 ============
5
6 * Corrected a comparison of two size_t's that were underflowing and causing
7 a crash due to unallocated memory being accessed during string replacements
8 in text files.
9 * One of the tests in the new test suite assumed that the user's PATH contained
10 ".", which often isn't the case (particularly for root). This has been fixed.
11 * The "-A" option is deprecated in this release. It will either change its
12 functionality (unlikely) or be removed (more likely) in a future release
13 and hence should not be used any more. The reason for this is that it's
14 too "dangerous" (can potentially damage binary files) and the current code
15 isn't easily changed to make it less risky.
16
17 replace 2.23 (September 2004)
18 ============
19
20 * Added a new -d parameter to specify which (temporary) directory
21 modified files are written to (falls back to $TMPDIR or /tmp if -d
22 isn't supplied).
23 * If a text file has only one line and that line has no linefeed (\n)
24 terminator, then that single line is now correctly read in and parsed
25 (it used to be incorrectly ignored in previous releases).
26 * If a text file has a string replaced in a line which has no linefeed
27 terminator (by definition, this must be the last line in the file of course),
28 then a linefeed is no longer added to the end of that replaced line.
29 * Avoid crash if -A is supplied and a binary file containing null bytes (ASCII
30 code 0) is specified. This will *still* corrupt the output file, so a
31 second warning about the -A option (i.e. don't use it unless you're
32 certain all files are text files) was added to the man page as well.
33 * If fdopen() fails during the creation of a temporary file, that file
34 is now correctly closed and deleted.
35 * Keep a global track of the name of the current temporary file (or ""
36 to mean no temporary file active).
37 * The tidy_up routine (run on program exit) will now remove the current
38 temporary file if one is active.
39 * Trap signals (e.g. SIGINT) and run the tidy_up routine. This finally means
40 that, unlike "rival" string replacement programs, CTRL-C will no longer
41 leave a temporary file behind.
42 * A new test suite has been written - "gmake test" now runs a shell script
43 that puts the built replace binary through its paces. A more verbose
44 version can be run with "gmake verbosetest".
45 * Ran the code through "splint" (Linux lint) and fixed the warnings.
46 * Updated FEATURES file to allow for GNU sed 4.X (a couple of marks extra
47 for that compared to 3.X) and also added MySQL's replace (yes, there's a
48 binary name-clash there with this program and I've told MySQL about that...).
49
50 replace 2.22 (May 2004)
51 ============
52
53 * Support for signed long long added (including use of %lld for output of
54 such 8-byte integers) - falls back to signed long if signed long long
55 isn't available.
56 * Double-quoted source and destination files if mv binary used to rename
57 files in the rename_files() routine. This should allow files with spaces
58 in their name to be correctly renamed.
59 * Compiled with flags to support 64-bit file offsets/large files.
60 * Documented -P option in "replace -?" output.
61 * Fixed old and new string comparison when -h is used - memcmp() instead
62 of strcmp() is needed of course because the hex strings can contain
63 binary 0 in the middle of them, which thwarts strcmp().
64 * Minor changes to fix +w1 warnings with HP-UX 11.23's paranoid HP ANSI C
65 compiler (most +w1 warnings now come from HP-UX's own system header
66 files...<sigh>).
67 * Added note about shell special characters such as brackets in the man
68 page (i.e. you need to single or double quote params if they include
69 any special char).
70 * Confirmed that replace builds with a K&R-only C compiler ("cc_bundled"
71 that comes as standard with HP-UX 11.00) as well as an ANSI C compiler.
72
73 replace 2.21 (March 2004)
74 ============
75
76 * Fixed incorrect assumption that a char was an unsigned byte (it's
77 actually a signed byte) - this was causing binary replacements to crash
78 on occasions.
79 * Switched to using mkstemp() instead of tmpnam().
80 * Added .xhtml and .shtml extensions to those picked up by the -w flag.
81 * Makefile now requires GNU make and will auto-detect Linux or HP-UX flags
82 as necessary.
83
84 replace 2.20 (June 2001)
85 ============
86
87 * New auto.c source file added the auto-detection of binary files (turned
88 on by default). At long last, a mixture of binary and text files can be
89 supplied on the command line and replace will use the first 256 bytes
90 of each file to determine if the file is text or binary automatically.
91 Note that other string replacement programs such as sed or rpl actually
92 corrupt binaries when they are run with different-sized old and new
93 strings (by shifting all the data, making the binary fail to run),
94 whereas the replace command avoids this.
95 * New FEATURES file to provide a feature-by-feature comparison chart between
96 sed, rpl and replace. Guess who wins ? :-)
97 * Added new "-A" option to force replace to think all supplied files are
98 text files (i.e. it turns off the new auto-detection code and reverts to
99 the default text file replacement mode of previous releases). It's probably
100 not a good idea to use this option, because there is a risk of corrupting
101 any binaries that are specified.
102 * Added new "-P" option to pre-pad any new replacement string with leading
103 spaces (as opposed to -p, which pads with trailing spaces).
104 * Verbose mode (-v) now has two levels - a single -v only displays a summary
105 about files that had replacements performed on them. Two -v's (e.g. -vv)
106 reverts to the older behaviour of showing all the replacements that take
107 place and providing an overall summary. This means that replacing
108 a large number of files (especially with -r) and using a single -v won't
109 swamp the screen with output. -i and -n now also "double up" and increment
110 the verbosity level to match the number of times they are specified.
111 * If the directory containing a file to be modified was read-only, then
112 the update of the file used to fail silently. This has been fixed - a
113 warning message is sent to stderr now.
114 * Missing break statement in the '-T' option parsing caused problems on
115 some systems - it's now been fixed.
116 * The old string to be replaced can now be null (i.e. ""), but only when
117 doing replacements in text files of course. It replaces blank lines with
118 the new string specified.
119 * Zero-length files are now detected and skipped with an appropriate warning
120 (you can't do replacements on totally empty files, because there's not
121 even a blank line to replace !).
122 * Now use a function instead of a macro to copy characters into the new line
123 buffer when doing replacements on text files. This reduces the overall
124 code size by not replicating the same macro code 8 times.
125
126 replace 2.10 (June 2001)
127 ============
128
129 * Added new "-T" option to retain the original timestamp of modified files
130 (I don't think this should be the default, because the changed timestamp
131 gives you a clue if the file has been modified or not, especially if you
132 use -f and don't have a backup to compare it with).
133 * Added new "-L" option to follow soft-links supplied on the command-line
134 before doing replacements (potential soft-link loops and relative soft-links
135 containing ".." are both coped with). The default is now to ignore such
136 soft-links and issue a warning (which is actually a bug fix compared to
137 previous behaviour when replace came across a soft-link).
138 * Any filename parameter that isn't a directory (-r or -w needed),
139 file or soft-link (-L needed) is now ignored with an appropriate warning.
140 This prevents "sillies" like FIFOs and device files being supplied.
141 * You can now optionally specify directories to recurse down when -r
142 is supplied (if none are stated, the current directory is recursed).
143 You can still mix files and directories on the command line with -r of
144 course (like the way you can with "rm").
145 * Added prototypes if an ANSI C compiler is used, which finally removed all
146 HP ANSI C compiler warnings with the +w1 flag (so that's now been added
147 to the flags for that compiler). Prototypes that cover calls from multiple
148 source files have been moved into replace.h, whilst if only one source
149 file calls a prototyped routine, it's put in the source file.
150 * Added .asp, .js, .css, .xml, .jsp, .php, .php3, .php4 and .pl to the
151 list of extensions detected by the "-w" option.
152 * The -x suffix checking is now case-insensitive.
153 * Display "6" through to "9" as words ("six" through to "nine") in verbose
154 messages in addition to the 0-5 that the previous version displayed as words.
155 * Verbose mode now displays "...binary file..." or "...text file..." messages
156 depending on whether -b was specified or not.
157 * Verbose mode now displays "line y, column x" output when replacing, which is
158 a little better than "pos: x, line: y".
159 * Added use of ferror() to check for read/write/close errors when accessing
160 files. Any file with such an error will not be updated and will be skipped.
161 If stdin/stdout operations have an error, the program is aborted.
162 * Fixed bug that wasn't closing original text file when "replace -n" was used.
163 * All warning messages now have a "WARNING:" string at the start (most already
164 did, but some didn't).
165 * All malloc() routines are now checked for failure and the program will abort
166 if it can't allocate memory at any time.
167 * Used lint to tidy up ultra-pedantic cross-source warnings.
168
169 replace 2.01 (February 2000)
170 ============
171
172 * No memory was malloc()'ed when the first line of a file was blank (should
173 have malloc()'ed 1 byte), so when a zero-terminator was stored for the
174 replaced string, the code would crash intermittently. This has been fixed.
175 * New Web site for replace: http://replace.richardlloyd.org.uk/
176
177 replace 2.00 (November 1999)
178 ============
179
180 * New binary.c source file to cope with binary-related code.
181 * New init.c source file containing initialisation routines.
182 * New text.c source file containing text-related code.
183 * Variables now global and moved into replace.h.
184 * Added "-b" to signify that all input files are in binary format and should
185 have binary replacements rather the default line-based string replacements.
186 * Added "-h" to specify the replacement binary strings in hex.
187 * Added "-m" to indicate the maximum number of lines in a file that
188 should have replacements.
189 * Added "-t" option to state the maximum number of times a string can
190 be replaced in any single line of a file.
191 * Added "-z" option (to be used with -b) to zero-terminate strings that are
192 shorter when replacing such strings in binaries (by default it doesn't).
193 * Memory for file buffers is now dynamically allocated, so there's no
194 more nasty string truncation of very long lines any more.
195 * All functions now have at least one comment.
196 * Added ident string so that "what replace" reports the version info.
197 * Sizes of the original and replaced files are now output in verbose mode.
198 * Fixed problem with GNU getopt() re-ordering the minus options (causing
199 -a not to be parsed properly). I added a "+" as the first char of the
200 getopt() options param and this cured the problem.
201 * Man page, usage output and getopt() qualifiers all now sync with each
202 other (unlike the previous release).
203 * Added some useful examples to the man page.
204 * Syntax message now uses argv[0] (and auto-adjusting option indentation) to
205 display the binary name.
206 * Now tested on HP-UX 10.20, HP-UX 11.00, Solaris 2.6 and Linux.
207 * Announced to www.freshmeat.net for the first time (since no-one seems to
208 know of the existence of "replace" !).
209
210 replace 1.10 (October 1999)
211 ============
212
213 * Added a "-i" option to interactively prompt the end-user.
214 * Added "-n" to just show what strings would be replaced without actually
215 replacing them.
216 * Added a "-r" option to recurse the current directory.
217 * The "-u backupsuffix" option now allows the user to choose their own
218 backup suffix (the default of .cln might seem strange to some people).
219 * Added "-w" option to allow easy string replacement of an entire Web tree's
220 HTML documents.
221 * Added a "-x suffix" option to combine with -r in only replacing strings
222 in files that end in the specified suffix.
223 * Increased maximum string length before truncation from 1023 to 4095 chars.
224 * Added a "make test" rule.
225 * Added a "make gcc" rule for my own convenience rather than anyone else's :-)
226 * Supplying no params at all now displays the Usage message.
227 * Various other small improvements to the code (nothing user-visible).
228 * Deleted text2html and text2html.1 - not worth including (there are much,
229 much better text to HTML converters out there - this was one was very
230 crude).
231 * Deleted patchlevel.h and merged its content (yep, one line with the
232 version number in it) into replace.h. Never saw the point of patchlevel.h
233 myself - I only did it because a few other packages pointlessly used it.
234
235 replace 1.03 (June 1998)
236 ============
237
238 * Updated files now retain their original permissions, ownership and group
239 where possible. The datestamp is modified of course though because the file
240 contents have been changed.
241
242 replace 1.02 (April 1996)
243 ============
244
245 * Added "-c startcol" to start string replacements from a particular column.
246 * Check for line length after replacements and truncate it if it exceeds
247 1023 characters.
248 * Bug fix to case-matching routine.
249 * Bug fix to "-a" checking.
250 * Picked up program name from argv[0] and used in error messages.
251 * Added verbose-mode message to indicate start column and line for the
252 replacements.
253 * Don't display syntax guff unless "replace -?" or a bad replace qualifier
254 used.
255 * Added a text2html.1 man page.
256 * Separated definitions and includes into replace.h.
257 * Slight modification of Makefile to install into /opt/replace tree for
258 PD archive 10.X package [no changes to any other source files for the 10.X
259 source package of replace 1.02].
260
261 replace 1.01 (1995 ?)
262 ============
263
264 * Added "-a old_str new_str" to finally bury the ghost of sed once and for all.
265 * Added "text2html" script to show off the new -a option :-)
266 * Fixed a bug w.r.t. the temporary file not getting deleted.
267 * Kept "make lint" happy.
268 * Added "patchlevel.h" complete with version number.
269
270 replace 1.00 (1994)
271 ============
272
273 * Initial release - probably the first ever string-replacing program that could
274 keep the (possibly mixed) case of the original string when replacing it with
275 a new string. This is a very useful thing - after all, not everything is all
276 in lower or upper case...it can be mixed too. This was always a major
277 frustration for me when using sed (apart from the dreadful sed syntax of
278 course).