Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
ca6d205e
Kaydet (Commit)
ca6d205e
authored
Ara 15, 2017
tarafından
Noel Grandin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
improve the find-unused-typedefs script
Change-Id: If4ab3bf8759c194e6005091d6df6a3a11cd633b7
üst
f388d1db
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
28 deletions
+21
-28
find-unused-defines.py
bin/find-unused-defines.py
+1
-0
find-unused-typedefs.py
bin/find-unused-typedefs.py
+20
-3
find-unused-typedefs.sh
bin/find-unused-typedefs.sh
+0
-25
No files found.
bin/find-unused-defines.py
Dosyayı görüntüle @
ca6d205e
...
@@ -97,6 +97,7 @@ def in_exclusion_set( a ):
...
@@ -97,6 +97,7 @@ def in_exclusion_set( a ):
return
True
;
return
True
;
return
False
;
return
False
;
# find defines, excluding the externals folder
a
=
subprocess
.
Popen
(
"git grep -hP '^#define
\
s+
\
w+
\
s+' --
\"
[!e][!x][!t]*
\"
| sort -u"
,
stdout
=
subprocess
.
PIPE
,
shell
=
True
)
a
=
subprocess
.
Popen
(
"git grep -hP '^#define
\
s+
\
w+
\
s+' --
\"
[!e][!x][!t]*
\"
| sort -u"
,
stdout
=
subprocess
.
PIPE
,
shell
=
True
)
with
a
.
stdout
as
txt
:
with
a
.
stdout
as
txt
:
...
...
bin/find-unused-typedefs.py
Dosyayı görüntüle @
ca6d205e
...
@@ -2,8 +2,11 @@
...
@@ -2,8 +2,11 @@
import
subprocess
import
subprocess
a
=
subprocess
.
Popen
(
"git grep -P '^typedef
\
s+.+
\
s+
\
w+;' --
\"
[!e][!x][!t]*
\"
"
,
stdout
=
subprocess
.
PIPE
,
shell
=
True
)
# find typedefs, excluding the externals folder
a
=
subprocess
.
Popen
(
"git grep -P 'typedef
\
s+.+
\
s+
\
w+;' --
\"
[!e][!x][!t]*
\"
"
,
stdout
=
subprocess
.
PIPE
,
shell
=
True
)
# parse out the typedef names
typedefSet
=
set
()
with
a
.
stdout
as
txt
:
with
a
.
stdout
as
txt
:
for
line
in
txt
:
for
line
in
txt
:
idx2
=
line
.
rfind
(
";"
)
idx2
=
line
.
rfind
(
";"
)
...
@@ -12,6 +15,20 @@ with a.stdout as txt:
...
@@ -12,6 +15,20 @@ with a.stdout as txt:
if
typedefName
.
startswith
(
"*"
):
if
typedefName
.
startswith
(
"*"
):
typedefName
=
typedefName
[
1
:]
typedefName
=
typedefName
[
1
:]
# ignore anything less than 5 characters, it's probably a parsing error
# ignore anything less than 5 characters, it's probably a parsing error
if
len
(
typedefName
)
>
4
:
if
len
(
typedefName
)
<
5
:
continue
print
typedefName
typedefSet
.
add
(
typedefName
)
for
typedefName
in
sorted
(
typedefSet
):
print
(
"checking: "
+
typedefName
)
a
=
subprocess
.
Popen
([
"git"
,
"grep"
,
"-wn"
,
typedefName
],
stdout
=
subprocess
.
PIPE
)
foundLine2
=
""
cnt
=
0
with
a
.
stdout
as
txt2
:
for
line2
in
txt2
:
cnt
=
cnt
+
1
foundLine2
+=
line2
if
cnt
==
1
:
print
(
"remove: "
+
foundLine2
)
elif
cnt
==
2
:
print
(
"inline: "
+
foundLine2
)
bin/find-unused-typedefs.sh
deleted
100755 → 0
Dosyayı görüntüle @
f388d1db
#
# This is a pretty brute-force approach. It takes several hours to run on a top-spec MacbookAir.
# It also produces some false positives, so it requires careful examination and testing of the results.
#
# Algorithm Summary:
# First we find all #defines,
# then we search for each of them in turn,
# and if we find only one instance of a #define, we print it out.
#
# Algorithm Detail:
# (1) find #defines, excluding the externals folder
# (2) extract just the constant name from the search results
# (3) trim blank lines
# (4) sort the results, mostly so I have an idea how far along the process is
# (5) for each result:
# (6) grep for the constant
# (7) use awk to check if only one match for a given constant was found
# (8) if so, generate a sed command to remove the #define
#
bin/find-unused-typedefs.py
\
|
sort
-u
\
| xargs
-Ixxx
-n
1
-P
8 sh
-c
\
'( git grep -w xxx | awk -f bin/find-unused-defines.awk -v p1=xxx ) && echo xxx 1>&2'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment