summaryrefslogtreecommitdiff
path: root/rename-macro.pl
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2009-08-06 17:33:25 +0100
committerReuben Thomas <rrt@sc3d.org>2009-08-06 17:33:25 +0100
commitf75360c2cce8640b07760b888b39bd12392104cb (patch)
tree3ecc1028b365d1b3e7c721e656335f6cd1224114 /rename-macro.pl
parenta4eac68154d7fc2eed1c590cbfc0051512fee63a (diff)
downloadautoconf-archive-f75360c2cce8640b07760b888b39bd12392104cb.tar.gz
Fix more occurrences of the prefix, clarify the code.
Diffstat (limited to 'rename-macro.pl')
-rwxr-xr-xrename-macro.pl35
1 files changed, 20 insertions, 15 deletions
diff --git a/rename-macro.pl b/rename-macro.pl
index 1af6a86..faff4ee 100755
--- a/rename-macro.pl
+++ b/rename-macro.pl
@@ -11,32 +11,37 @@ use warnings;
my ($prefix, $old, $new) = @ARGV;
-my $old_name = uc($old);
+# Extract names from file names
+my $old_name = $old;
$old_name =~ s/\..*$//;
-
-my $new_name = uc($new);
+my $new_name = $new;
$new_name =~ s/\..*$//;
-my $insertion = <<END;
-# OBSOLETE MACRO
-#
-# Renamed to $new_name
-#
-END
-chomp $insertion;
-
+# Read file
open IN, $old or die "could not read $old\n";
my $text = do { local $/, <IN> };
+# Make new macro
my $new_text = $text;
-$new_text =~ s/$old_name/$new_name/g;
-$new_text =~ s/$prefix/AX_/g;
+$new_text =~ s/$old_name/$new_name/g; # Change name (lower case)
+my $uc_old_name = uc($old_name);
+$new_text =~ s/$uc_old_name/uc($new_name)/ge; # Change name (upper case)
+$new_text =~ s/$prefix/AX_/g; # Change other references to prefix (upper case)
+my $lc_prefix = lc($prefix);
+$new_text =~ s/$lc_prefix/ax_/g; # Change other references to prefix (lower case)
open OUTFILE, ">$new" or die "could not read $new";
print OUTFILE $new_text;
+system "git add $new";
+# Obsolete the old macro
+my $insertion = <<END;
+# OBSOLETE MACRO
+#
+# Renamed to $new_name
+#
+END
+chomp $insertion;
my $old_text = $text;
$old_text =~ s/^\# SYNOPSIS/"$insertion\n\# SYNOPSIS"/me;
open OUTFILE, ">$old" or die "could not write $old";
print OUTFILE $old_text;
-
-system "git add $new";