Sort the enums (tokens) in a stable manner for consistency in include files.

This commit is contained in:
Nigel Stewart 2014-07-26 09:14:36 +10:00
parent cf67153325
commit 3739be33b0
2 changed files with 39 additions and 3 deletions

View File

@ -142,7 +142,25 @@ sub output_tokens($$)
{
local $, = "\n";
print "\n";
print map { &{$fnc}($_, $tbl->{$_}) } sort { hex ${$tbl}{$a} <=> hex ${$tbl}{$b} } keys %{$tbl};
print map { &{$fnc}($_, $tbl->{$_}) } sort {
if (${$tbl}{$a} eq ${$tbl}{$b}) {
$a cmp $b
} else {
if (${$tbl}{$a} =~ /_/) {
if (${$tbl}{$b} =~ /_/) {
$a cmp $b
} else {
-1
}
} else {
if (${$tbl}{$b} =~ /_/) {
1
} else {
hex ${$tbl}{$a} <=> hex ${$tbl}{$b}
}
}
}
} keys %{$tbl};
print "\n";
} else {
print STDERR "no keys in table!\n";

View File

@ -336,8 +336,26 @@ foreach my $spec (sort @speclist)
my $prefix = $ext;
$prefix =~ s/^(.+?)(_.+)$/$1/;
foreach my $token (sort { hex ${$tokens}{$a} <=> hex ${$tokens}{$b} } keys %{$tokens})
{
foreach my $token (sort {
if (${$tokens}{$a} eq ${$tokens}{$b}) {
$a cmp $b
} else {
if (${$tokens}{$a} =~ /_/) {
if (${$tokens}{$b} =~ /_/) {
$a cmp $b
} else {
-1
}
} else {
if (${$tokens}{$b} =~ /_/) {
1
} else {
hex ${$tokens}{$a} <=> hex ${$tokens}{$b}
}
}
}
} keys %{$tokens})
{
if ($token =~ /^$prefix\_.*/i)
{
print EXT "\t" . $token . " " . ${\%{$tokens}}{$token} . "\n";