FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
android_kernel_asus_tf201/scripts/checkincludes.pl at master · AndroidRoot/android_kernel_asus_tf201 · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
AndroidRoot
/
android_kernel_asus_tf201
Public
Notifications
You must be signed in to change notification settings
Fork
17
Star
5
Code
Issues
1
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
android_kernel_asus_tf201
/
scripts
/
checkincludes.pl
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
89 lines (77 loc) · 1.77 KB
Breadcrumbs
android_kernel_asus_tf201
/
scripts
/
checkincludes.pl
Copy path
File metadata and controls
executable file
·
89 lines (77 loc) · 1.77 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#
!/usr/bin/perl
#
#
checkincludes: find/remove files included more than once
#
#
Copyright abandoned, 2000, Niels Kristian Bech Jensen <nkbj@image.dk>.
#
Copyright 2009 Luis R. Rodriguez <mcgrof@gmail.com>
#
#
This script checks for duplicate includes. It also has support
#
to remove them in place. Note that this will not take into
#
consideration macros so you should run this only if you know
#
you do have real dups and do not have them under #ifdef's. You
#
could also just review the results.
use
strict;
sub
usage
{
print
"
Usage: checkincludes.pl [-r]
\n
"
;
print
"
By default we just warn of duplicates
\n
"
;
print
"
To remove duplicated includes in place use -r
\n
"
;
exit
1;
}
my
$remove
= 0;
if
(
$#ARGV
< 0) {
usage();
}
if
(
$#ARGV
>= 1) {
if
(
$ARGV
[0] =~
/
^-
/
) {
if
(
$ARGV
[0]
eq
"
-r
"
) {
$remove
= 1;
shift
;
}
else
{
usage();
}
}
}
foreach
my
$file
(
@ARGV
) {
open
(
my
$f
,
'
<
'
,
$file
)
or
die
"
Cannot open
$file
:
$!
.
\n
"
;
my
%includedfiles
= ();
my
@file_lines
= ();
while
(<
$f
>) {
if
(
m
/
^
\s
*#
\s
*include
\s
*
[<"]
(
\S
*)
[>"]
/
o
) {
++
$includedfiles
{
$1
};
}
push
(
@file_lines
,
$_
);
}
close
(
$f
);
if
(!
$remove
) {
foreach
my
$filename
(
keys
%includedfiles
) {
if
(
$includedfiles
{
$filename
} > 1) {
print
"
$file
:
$filename
is included more than once.
\n
"
;
}
}
next
;
}
open
(
$f
,
'
>
'
,
$file
)
or
die
(
"
Cannot write to
$file
:
$!
"
);
my
$dups
= 0;
foreach
(
@file_lines
) {
if
(
m
/
^
\s
*#
\s
*include
\s
*
[<"]
(
\S
*)
[>"]
/
o
) {
foreach
my
$filename
(
keys
%includedfiles
) {
if
(
$1
eq
$filename
) {
if
(
$includedfiles
{
$filename
} > 1) {
$includedfiles
{
$filename
}--;
$dups
++;
}
else
{
print
{
$f
}
$_
;
}
}
}
}
else
{
print
{
$f
}
$_
;
}
}
if
(
$dups
> 0) {
print
"
$file
: removed
$dups
duplicate includes
\n
"
;
}
close
(
$f
);
}
Back
|
FazBrowse Home
|
New Git URL