I just committed a global change to the 21.2 branch. If you have
large outstanding changes (I'm thinking of things like UTF-2000), it
might be easier to convert your own workspace using the same script I
wrote, _before_ trying to merge. For this merge, backing up your
CVS workspace might also be a good idea.
# Requires a very recent version of perl, that supports
# `lookbehind'. 5.005_03 works.
find -name '*.[ch]' | xargs global-replace
's/(^|(?<=[^A-Za-z0-9_]))CONST((?=[^A-Za-z0-9_])|$)/const/g'
: #-*- Perl -*-
# Copyright (C) 1999 Martin Buchholz
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with XEmacs; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
eval 'exec perl -w -S $0 ${1+"$@"}'
if 0;
use strict;
use FileHandle;
use Carp;
(my $myName = $0) =~ s@.*/@@; my $usage="
Usage: $myName PERLEXPR FILE...
Typical usage is like this:
find . -name '*.[ch]' -print | xargs $0 's/\bCONST\b/const/g'\n";
die $usage unless @ARGV > 1;
my $code = shift;
die $usage if grep (-d || ! -w, @ARGV);
sub SafeOpen {
open ((my $fh = new FileHandle), $_[0]);
confess "Can't open $_[0]: $!" if ! defined $fh;
return $fh;
}
sub WriteStringToFile {
my $fh = SafeOpen ("> $_[0]");
print $fh $_[1] or confess "$_[0]: $!\n";
close $fh or confess "$_[0]: $!\n";
}
foreach my $file (@ARGV) {
my $changed_p = 0;
my $fh = SafeOpen $file;
my $new_contents = "";
while (<$fh>) {
my $save_line = $_;
eval $code;
$changed_p = 1 if $save_line ne $_;
$new_contents .= $_;
}
WriteStringToFile ($file, $new_contents) if $changed_p;
}
Martin
Show replies by date