summaryrefslogtreecommitdiff
path: root/rename-macro.pl
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2009-08-06 16:10:05 +0100
committerReuben Thomas <rrt@sc3d.org>2009-08-06 16:10:05 +0100
commitd3b46a2812b06379545a647ad63a6b3c09bc04a2 (patch)
treee6fe03ff81fc786ad8c9844e1dbb7a2aa81b2bab /rename-macro.pl
parentfeb9ee950b592fc11af7948aefb009e6d5944098 (diff)
downloadautoconf-archive-d3b46a2812b06379545a647ad63a6b3c09bc04a2.tar.gz
Fix typo and make error messages consistent.
Diffstat (limited to 'rename-macro.pl')
-rwxr-xr-xrename-macro.pl43
1 files changed, 43 insertions, 0 deletions
diff --git a/rename-macro.pl b/rename-macro.pl
new file mode 100755
index 0000000..78dcfa2
--- /dev/null
+++ b/rename-macro.pl
@@ -0,0 +1,43 @@
+#! /usr/bin/env perl
+# rename-macro
+# Rename an autoconf-archive macro, obsoleting the old name
+# Usage: rename-macro PREFIX FROM TO
+# If there is no prefix to remove, make the prefix some
+# string that does not occur in the files being modified.
+
+
+use strict;
+use warnings;
+
+my ($prefix, $old, $new) = @ARGV;
+
+my $old_name = uc($old);
+$old_name =~ s/\..*$//;
+
+my $new_name = uc($new);
+$new_name =~ s/\..*$//;
+
+my $insertion = <<END;
+# OBSOLETE MACRO
+#
+# Renamed to $new_name
+#
+END
+chomp $insertion;
+
+open IN, $old or die "could not read $old\n";
+my $text = do { local $/, <IN> };
+
+my $new_text = $text;
+$new_text =~ s/$old_name/$new_name/g;
+$new_text =~ s/$prefix/AX_/g;
+open OUTFILE, ">$new" or die "could not read $new";
+print OUTFILE $new_text;
+
+my $old_text = $text;
+$old_text =~ s/^\# SYNOPSIS/"$insertion\n\# SYNOPSIS"/me;
+$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";