summaryrefslogtreecommitdiff
path: root/Porting
diff options
context:
space:
mode:
authorH.Merijn Brand <h.m.brand@xs4all.nl>2005-05-25 18:41:52 +0000
committerH.Merijn Brand <h.m.brand@xs4all.nl>2005-05-25 18:41:52 +0000
commit253687a919e6d27d683ed5f25d04adf06f590fe5 (patch)
treef4a7765ea9b24c1c55be25b8d1551c064e64a677 /Porting
parent0bff533ca2a343dc64973f34f3c611670d92fff1 (diff)
downloadperl-253687a919e6d27d683ed5f25d04adf06f590fe5.tar.gz
Reordering config_h.SH after metaconfig now semi automated
This will save me *a lot* of manual work p4raw-id: //depot/perl@24576
Diffstat (limited to 'Porting')
-rwxr-xr-xPorting/config_h.pl56
1 files changed, 56 insertions, 0 deletions
diff --git a/Porting/config_h.pl b/Porting/config_h.pl
new file mode 100755
index 0000000000..2543b34ae1
--- /dev/null
+++ b/Porting/config_h.pl
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+
+# This script reorders config_h.SH after metaconfig
+# Changing metaconfig is too complicated
+#
+# Copyright (C) 2005-2005 by H.Merijn Brand (m)'05 [25-05-2005]
+#
+# You may distribute under the terms of either the GNU General Public
+# License or the Artistic License, as specified in the README file.
+
+use strict;
+use warnings;
+
+my ($cSH, $ch, @ch, %ch) = ("config_h.SH");
+open $ch, "<$cSH" or die "Cannot open $cSH: $!\n";
+{ local $/ = "\n\n";
+ @ch = <$ch>;
+ close $ch;
+ }
+
+sub ch_index ()
+{
+ %ch = ();
+ foreach my $ch (0 .. $#ch) {
+ while ($ch[$ch] =~ m{^/\* ([A-Z]\w+)}gm) {
+ $ch{$1} = $ch;
+ }
+ }
+ } # ch_index
+
+my %dep = (
+ # This symbol must be defined BEFORE ...
+ LONGSIZE => [ qw( BYTEORDER ) ],
+ MULTIARCH => [ qw( BYTEORDER MEM_ALIGNBYTES ) ],
+ HAS_QUAD => [ qw( I64TYPE ) ],
+ );
+
+my $changed;
+do {
+ $changed = 0;
+ foreach my $sym (keys %dep) {
+ ch_index;
+ foreach my $dep (@{$dep{$sym}}) {
+ print STDERR "Check if $sym\t($ch{$sym}) precedes $dep\t($ch{$dep})\n";
+ $ch{$sym} < $ch{$dep} and next;
+ my $ch = splice @ch, $ch{$sym}, 1;
+ splice @ch, $ch{$dep}, 0, $ch;
+ $changed++;
+ ch_index;
+ }
+ }
+ } while ($changed);
+
+open $ch, "> $cSH" or die "Cannot write $cSH: $!\n";
+print $ch @ch;
+close $ch;