Skip to content

Commit 3a943d7

Browse files
committed
regen/HeaderParser.pm: Put all non-word flags at end
This generalizes the previous code to make sure all non-word flags are sorted after the word ones. Previously it checked for just '#' All but '#' not being in column 1 is just for aesthetics. If '#' were in column 1 it would be a preprocessor directive that likely would fail to compile.
1 parent 1c52cc1 commit 3a943d7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

regen/HeaderParser.pm

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -749,12 +749,16 @@ sub tidy_embed_fnc_entry {
749749
# Split into fields
750750
my ($flags, $ret, $name, @args)= split /\s*\|\s*/, $line;
751751

752-
# Sort and remove duplicate flags
752+
# Sort and remove duplicate flags. Alpha flags are sorted first
753753
my %flag_seen;
754-
$flags = join "", grep !$flag_seen{$_}++, sort split //, $flags;
755-
if ($flags =~ s/^#//) {
756-
$flags .= "#";
757-
}
754+
$flags = join "", grep !$flag_seen{$_}++,
755+
sort {
756+
my $a_is_word = $a =~ /\w/;
757+
my $b_is_word = $b =~ /\w/;
758+
return $a cmp $b if $a_is_word == $b_is_word;
759+
return -1 if $a_is_word;
760+
return 1;
761+
} split //, $flags;
758762

759763
if ($flags eq "#") { # Could be an attempt at a conditional
760764
die "Not allowed to use only '#' for flags"

0 commit comments

Comments
 (0)