summaryrefslogtreecommitdiff
path: root/rename-macro.pl
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2009-08-06 18:09:22 +0100
committerReuben Thomas <rrt@sc3d.org>2009-08-06 18:09:22 +0100
commit81176a2db59b9f55dc171ea36000be225dc8aa83 (patch)
treedc503183d41f9e1963dfa807773905fbcfc4521e /rename-macro.pl
parent523e5f24006ff4c3528adf0a866573e7b74bbaa5 (diff)
downloadautoconf-archive-81176a2db59b9f55dc171ea36000be225dc8aa83.tar.gz
Add explicit NEW_PREFIX argument to cope with more complex renames.
Diffstat (limited to 'rename-macro.pl')
-rwxr-xr-xrename-macro.pl22
1 files changed, 11 insertions, 11 deletions
diff --git a/rename-macro.pl b/rename-macro.pl
index faff4ee..4eadbe0 100755
--- a/rename-macro.pl
+++ b/rename-macro.pl
@@ -1,7 +1,7 @@
#! /usr/bin/env perl
# rename-macro
# Rename an autoconf-archive macro, obsoleting the old name
-# Usage: rename-macro PREFIX FROM TO
+# Usage: rename-macro OLD_PREFIX NEW_PREFIX FROM TO
# If there is no prefix to remove, make the prefix some
# string that does not occur in the files being modified.
@@ -9,16 +9,16 @@
use strict;
use warnings;
-my ($prefix, $old, $new) = @ARGV;
+my ($old_prefix, $new_prefix, $old_file, $new_file) = @ARGV;
# Extract names from file names
-my $old_name = $old;
+my $old_name = $old_file;
$old_name =~ s/\..*$//;
-my $new_name = $new;
+my $new_name = $new_file;
$new_name =~ s/\..*$//;
# Read file
-open IN, $old or die "could not read $old\n";
+open IN, $old_file or die "could not read $old_file\n";
my $text = do { local $/, <IN> };
# Make new macro
@@ -26,12 +26,12 @@ my $new_text = $text;
$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";
+$new_text =~ s/$old_prefix/$new_prefix/g; # Change other references to prefix (upper case)
+my $lc_old_prefix = lc($old_prefix);
+$new_text =~ s/$lc_old_prefix/lc($new_prefix)/ge; # Change other references to prefix (lower case)
+open OUTFILE, ">$new_file" or die "could not read $new_file";
print OUTFILE $new_text;
-system "git add $new";
+system "git add $new_file";
# Obsolete the old macro
my $insertion = <<END;
@@ -43,5 +43,5 @@ END
chomp $insertion;
my $old_text = $text;
$old_text =~ s/^\# SYNOPSIS/"$insertion\n\# SYNOPSIS"/me;
-open OUTFILE, ">$old" or die "could not write $old";
+open OUTFILE, ">$old_file" or die "could not write $old_file";
print OUTFILE $old_text;