2 # -----------------------------------------------------------------------------
6 die "$0: must be run from top-level directory.\n"
7 unless (-r
"configure.ac" &&
15 if ($ARGV[0] =~ /^--doit/) {
16 # Nothing -- this is now the default
17 } elsif ($ARGV[0] =~ /^--test/) {
25 my $oldname = $ARGV[0];
26 my $newname = $ARGV[1];
27 if (defined ($oldname) && !defined ($newname)) {
29 if ($oldname =~ /^_?[A-Z].*[a-z]/) {
30 $newname =~ s/(_*)/$1Gnm/;
31 } elsif ($oldname =~ /^[a-z0-9_]+$/) {
32 $newname =~ s/(_*)/$1gnm_/;
33 } elsif ($oldname =~ /^[A-Z0-9_]+$/) {
34 $newname =~ s/(_*)/$1GNM_/;
37 die "Usage $0 oldname newname\n" unless $oldname && $newname;
38 die "$0: oldname and newname must be different\n" if $oldname eq $newname;
40 my @files = &find_files
();
43 &do_files
(\
@files, 1);
46 print STDERR
"Renaming $oldname to $newname\n";
47 &do_files
(\
@files, 0);
50 # -----------------------------------------------------------------------------
57 'gnumeric-config.h' => 1,
59 'src/dialogs/embedded-ui.c' => 1,
63 open (*FIL
, "find . '(' -name '*.[chy]' -type f -print ')' -o " .
64 "'(' -type d '(' -name intl -o -name macros -o -name .git -o -name win32 ')' -prune ')' |") or
65 die "$0: Cannot run find command.\n";
70 next if $generated{$_};
79 # -----------------------------------------------------------------------------
82 my ($pfiles,$test) = @_;
84 foreach my $filename (@
$pfiles) {
88 # print STDERR "Scanning $filename...\n";
89 my $newfilename = "$filename.new";
91 open (*SRC
, "<$filename") || die "$0: Cannot read $filename: $!\n";
93 open (*DST
, ">$newfilename") || die "$0: Cannot write $newfilename: $!\n";
100 foreach my $line (<SRC
>) {
101 my $linecopy = $line;
102 $line =~ s/\b$oldname\b/$newname/g;
103 $line =~ s/\b$newname\b/$oldname/g;
104 if ($line ne $linecopy) {
106 die "$0: Rename clash in $filename, line $lineno: $linecopy <-> $line\n";
111 foreach my $line (<SRC
>) {
112 $didit = 1 if $line =~ s/\b$oldname\b/$newname/g;
121 rename $newfilename, $filename;
129 # -----------------------------------------------------------------------------