OSDN Git Service

Rename cygWFMO to cygwait throughout and use the magic of polymorphism to "wait
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / sortdin
1 #!/usr/bin/perl
2
3 my %data = ();
4 my %code = ();
5
6 my @out = ();
7
8 my $fn = $ARGV[0];
9
10 while (<>) {
11     push(@out, $_);
12     /^\s*exports/i and last;
13 }
14
15 while (<>) {
16     my $key;
17     $arr = /\sDATA\s*$/o ? \%data : \%code;
18     $_ =~ s/^\s+//;
19     my $key = (split(' ', $_))[0];
20     substr($key, 0, 1) = '' while $key =~ /^_/o;
21     chomp $key;
22     $arr->{$key}->{$_} = 1;
23 }
24
25 for my $k (sort keys %data) {
26     push(@out, sort {$b cmp $a} keys %{$data{$k}});
27 }
28
29 for my $k (sort keys %code) {
30     push(@out, sort {$b cmp $a} keys %{$code{$k}});
31 }
32
33 open(R, '>', $fn);
34 print R @out;
35 close R;