3 # Copyright (C) 2012-2013 Red Hat, Inc.
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library. If not, see
17 # <http://www.gnu.org/licenses/>.
22 die "syntax: $0 SRCDIR SYMFILE..." unless int(@ARGV) >= 2;
26 my $lastgroup = undef;
27 foreach my $symfile (@ARGV) {
28 open SYMFILE
, $symfile or die "cannot read $symfile: $!";
37 if (/^#\s*((\w+\/)*(\w
+\
.h
))\s
*$/) {
43 &check_sorting
(\
@group, $symfile, $line, $groupfile);
55 &check_sorting
(\
@group, $symfile, $line, $groupfile);
64 my $groupfile = shift;
66 my @group = @
{$group};
67 my @sorted = sort { lc $a cmp lc $b } @group;
72 # Check that groups are in order and groupfile exists
73 if (defined $lastgroup && lc $lastgroup ge lc $groupfile) {
74 print "Symbol block at $symfile:$line: block not sorted\n";
75 print "Move $groupfile block before $lastgroup block\n";
79 if (! -e
"$srcdir/$groupfile") {
80 print "Symbol block at $symfile:$line: $groupfile not found\n";
84 $lastgroup = $groupfile;
86 # Check that symbols within a group are in order
87 for (my $i = 0 ; $i <= $#sorted ; $i++) {
88 if ($sorted[$i] ne $group[$i]) {
89 $first = $i unless defined $first;
95 @group = splice @group, $first, ($last-$first+1);
96 @sorted = splice @sorted, $first, ($last-$first+1);
97 print "Symbol block at $symfile:$line: symbols not sorted\n";
98 print map { " " . $_ . "\n" } @group;
99 print "Correct ordering\n";
100 print map { " " . $_ . "\n" } @sorted;