Skip to content

Commit 49286b3

Browse files
committed
unify_includes.pl:
* renamed from sort_includes.pl * don't destroy order just remove duplicate includes * run after astyle
1 parent d077a16 commit 49286b3

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

scripts/astyle.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ set -e
4545

4646
astyleit()
4747
{
48-
scripts/sort_includes.pl "$1"
49-
5048
$ASTYLE \
5149
--preserve-date \
5250
--indent-preprocessor \
@@ -65,6 +63,8 @@ astyleit()
6563
--pad=oper \
6664
--pad=paren-in \
6765
--unpad=paren "$1"
66+
67+
scripts/unify_includes.pl "$1"
6868
}
6969

7070
for f in "$@"; do
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/perl -i.sortinc -n
22
###########################################################################
3-
# sort_includes.pl
3+
# unify_includes.pl
44
# ---------------------
55
# begin : June 2015
66
# copyright : (C) 2015 by Juergen E. Fischer
@@ -20,39 +20,22 @@
2020
use strict;
2121
use warnings;
2222

23-
our %uis;
24-
our %sys;
25-
our %others;
26-
our $sorting;
23+
our %inc;
24+
our @inc;
2725

28-
BEGIN { $sorting = 0; }
29-
END { die "header files not empty" if keys %uis || keys %sys || keys %others; }
30-
31-
if(/^\s*#include/ ) {
32-
if(/"ui_/ ) {
33-
$uis{$_}=1;
34-
} elsif(/</) {
35-
$sys{$_}=1;
36-
} else {
37-
$others{$_}=1;
38-
}
39-
$sorting=1;
26+
END { die "header files not empty" if @inc; }
4027

28+
if( /^\s*#include/ ) {
29+
push @inc, $_ unless exists $inc{$_};
30+
$inc{$_}=1;
4131
next unless eof;
4232
}
4333

44-
if( $sorting ) {
45-
print foreach sort keys %uis;
46-
print foreach sort keys %sys;
47-
print foreach sort keys %others;
48-
49-
undef %uis;
50-
undef %sys;
51-
undef %others;
52-
34+
if( %inc ) {
35+
print foreach @inc;
36+
undef %inc;
37+
undef @inc;
5338
last if eof;
5439
}
5540

56-
$sorting=0;
57-
5841
print;

0 commit comments

Comments
 (0)