This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[SCRIPT] subst-free-xfree for free() -> xfree() substitutions
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [SCRIPT] subst-free-xfree for free() -> xfree() substitutions
- From: Kevin Buettner <kevinb at cygnus dot com>
- Date: Thu, 30 Nov 2000 02:17:53 -0700
Below is the modified script that I used to make the changes in
part 2 of the free() -> xfree() patch recently posted.
--- subst-free-xfree ---
#!/usr/bin/perl -w
use File::Find;
use FileHandle;
use IPC::Open3;
use English;
my ($root) = @ARGV;
if (!defined($root)) {
die "Usage: $0 root\n";
}
@ARGV = ();
find(
sub {
if ($_ eq 'testsuite' || $_ eq 'gdbserver' || (-d && /-share$/)) {
$File::Find::prune = 1;
} elsif (-f && -T && /\.c$/ && $_ ne "gnu-regex.c") {
push @ARGV, $File::Find::name;
}
},
$root
);
$INPLACE_EDIT = '';
undef $/; # slurp entire files
while (<>) {
# Turn calls to free into calls to xfree
s/\bfree # free
\s # one space
\( # left paren
( # plus, optionally, a cast consisting of
\( # a left paren, plus either
( PTR # PTR,
| char\s*\*) # or char *
\) # followed by a right paren
\s* # and any number of spaces
)?
/xfree (/gx;
# Fix occurrences of free in make_cleanup calls
s/\bmake_cleanup \(free,/make_cleanup (xfree,/g;
# Fix occurrences of free in other calls where free appears as a
# final parameter.
s/\bfree\)/xfree)/g;
print;
}
--- end subst-free-xfree ---