Subject: | Patch to output #includes in deterministic order |
Since hash retrieval randomization in Perl v5.18, Encode generated files such as CN/CN.xs have their header files #included in random order. This would hardly seem to matter, but it does for one reason, and that is that it sometimes is useful to compare two versions of Perl build directory structures to see what is different between them. For example, I use this on occasion to try to figure what what could be causing a bug, when other approaches have failed.
The random ordering of these header #includes shows up in the compare as differences, which distracts from finding the actual meaningful differences.
So please consider applying the attached patch the next time you release a new Encode version
Subject: | 0002-Deterministically-order-includes-in-generated-files.patch |
From 1234b752237dd3d3da43e3ff0a782a2155213371 Mon Sep 17 00:00:00 2001
From: Karl Williamson <public@khwilliamson.com>
Date: Tue, 16 Jul 2013 11:25:54 -0600
Subject: [PATCH 2/2] Deterministically order #includes in generated files
This causes the #include files in generated files such as TW/TW.xs
to always be in the same order. This makes it easier to find the
meaningful differences when comparing two versions of what Encode
generates.
---
cpan/Encode/Byte/Makefile.PL | 4 ++--
cpan/Encode/CN/Makefile.PL | 4 ++--
cpan/Encode/EBCDIC/Makefile.PL | 4 ++--
cpan/Encode/Encode/Makefile_PL.e2x | 10 +++++-----
cpan/Encode/JP/Makefile.PL | 4 ++--
cpan/Encode/KR/Makefile.PL | 4 ++--
cpan/Encode/Symbol/Makefile.PL | 4 ++--
cpan/Encode/TW/Makefile.PL | 4 ++--
8 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/cpan/Encode/Byte/Makefile.PL b/cpan/Encode/Byte/Makefile.PL
index 60caf38..e368ac8 100644
--- a/cpan/Encode/Byte/Makefile.PL
+++ b/cpan/Encode/Byte/Makefile.PL
@@ -108,7 +108,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -137,7 +137,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git a/cpan/Encode/CN/Makefile.PL b/cpan/Encode/CN/Makefile.PL
index 6d54404..323b47e 100644
--- a/cpan/Encode/CN/Makefile.PL
+++ b/cpan/Encode/CN/Makefile.PL
@@ -84,7 +84,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -113,7 +113,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git a/cpan/Encode/EBCDIC/Makefile.PL b/cpan/Encode/EBCDIC/Makefile.PL
index 0e2a13c..1c78c6a 100644
--- a/cpan/Encode/EBCDIC/Makefile.PL
+++ b/cpan/Encode/EBCDIC/Makefile.PL
@@ -65,7 +65,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -94,7 +94,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git a/cpan/Encode/Encode/Makefile_PL.e2x b/cpan/Encode/Encode/Makefile_PL.e2x
index ece5883..9fe60ef 100644
--- a/cpan/Encode/Encode/Makefile_PL.e2x
+++ b/cpan/Encode/Encode/Makefile_PL.e2x
@@ -83,7 +83,7 @@ sub post_initialize
if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$name\.c\b/;
# $self->{'H'} = [$self->catfile($self->updir,'encode.h')];
my %xs;
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
push (@{$self->{'C'}},"$table.c");
# Do NOT add $table.h etc. to H_FILES unless we own up as to how they
# get built.
@@ -101,7 +101,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -130,7 +130,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
@@ -144,14 +144,14 @@ sub postamble
my $dir = "."; # $self->catdir('Encode');
my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
$str .= "$name.c : $name.xs ";
- foreach my $table (keys %tables)
+ foreach my $table (sort keys %tables)
{
$str .= " $table.c";
}
$str .= "\n\n";
$str .= "$name\$(OBJ_EXT) : $name.c\n\n";
- foreach my $table (keys %tables)
+ foreach my $table (sort keys %tables)
{
my $numlines = 1;
my $lengthsofar = length($str);
diff --git a/cpan/Encode/JP/Makefile.PL b/cpan/Encode/JP/Makefile.PL
index a75685e..c6a725f 100644
--- a/cpan/Encode/JP/Makefile.PL
+++ b/cpan/Encode/JP/Makefile.PL
@@ -84,7 +84,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -113,7 +113,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git a/cpan/Encode/KR/Makefile.PL b/cpan/Encode/KR/Makefile.PL
index e95d039..49c0319 100644
--- a/cpan/Encode/KR/Makefile.PL
+++ b/cpan/Encode/KR/Makefile.PL
@@ -82,7 +82,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -111,7 +111,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git a/cpan/Encode/Symbol/Makefile.PL b/cpan/Encode/Symbol/Makefile.PL
index 23ca1f4..2c94aab 100644
--- a/cpan/Encode/Symbol/Makefile.PL
+++ b/cpan/Encode/Symbol/Makefile.PL
@@ -70,7 +70,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -99,7 +99,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git a/cpan/Encode/TW/Makefile.PL b/cpan/Encode/TW/Makefile.PL
index 99c94bf..f90861f 100644
--- a/cpan/Encode/TW/Makefile.PL
+++ b/cpan/Encode/TW/Makefile.PL
@@ -80,7 +80,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -109,7 +109,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
--
1.8.1.3