From 3739be33b026df7de070fc08ed48366b6dafa236 Mon Sep 17 00:00:00 2001 From: Nigel Stewart Date: Sat, 26 Jul 2014 09:14:36 +1000 Subject: [PATCH] Sort the enums (tokens) in a stable manner for consistency in include files. --- auto/bin/make.pl | 20 +++++++++++++++++++- auto/bin/parse_spec.pl | 22 ++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/auto/bin/make.pl b/auto/bin/make.pl index f382263..83bb774 100755 --- a/auto/bin/make.pl +++ b/auto/bin/make.pl @@ -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"; diff --git a/auto/bin/parse_spec.pl b/auto/bin/parse_spec.pl index 7e64ddb..3a9daa0 100755 --- a/auto/bin/parse_spec.pl +++ b/auto/bin/parse_spec.pl @@ -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";