Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AFLplusplus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ulf Kargén
AFLplusplus
Commits
5c4c49d9
Commit
5c4c49d9
authored
4 years ago
by
Dominik Maier
Browse files
Options
Downloads
Patches
Plain Diff
black
parent
cebde1f9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.custom-format.py
+42
-21
42 additions, 21 deletions
.custom-format.py
with
42 additions
and
21 deletions
.custom-format.py
+
42
−
21
View file @
5c4c49d9
...
@@ -33,13 +33,13 @@ if CLANG_FORMAT_BIN is None:
...
@@ -33,13 +33,13 @@ if CLANG_FORMAT_BIN is None:
o
,
_
=
p
.
communicate
()
o
,
_
=
p
.
communicate
()
o
=
str
(
o
,
"
utf-8
"
)
o
=
str
(
o
,
"
utf-8
"
)
o
=
re
.
sub
(
r
"
.*ersion
"
,
""
,
o
)
o
=
re
.
sub
(
r
"
.*ersion
"
,
""
,
o
)
#o = o[len("clang-format version "):].strip()
#
o = o[len("clang-format version "):].strip()
o
=
o
[:
o
.
find
(
"
.
"
)]
o
=
o
[:
o
.
find
(
"
.
"
)]
o
=
int
(
o
)
o
=
int
(
o
)
except
:
except
:
print
(
"
clang-format-11 is needed. Aborted.
"
)
print
(
"
clang-format-11 is needed. Aborted.
"
)
exit
(
1
)
exit
(
1
)
#if o < 7:
#
if o < 7:
# if subprocess.call(['which', 'clang-format-7'], stdout=subprocess.PIPE) == 0:
# if subprocess.call(['which', 'clang-format-7'], stdout=subprocess.PIPE) == 0:
# CLANG_FORMAT_BIN = 'clang-format-7'
# CLANG_FORMAT_BIN = 'clang-format-7'
# elif subprocess.call(['which', 'clang-format-8'], stdout=subprocess.PIPE) == 0:
# elif subprocess.call(['which', 'clang-format-8'], stdout=subprocess.PIPE) == 0:
...
@@ -52,8 +52,8 @@ if CLANG_FORMAT_BIN is None:
...
@@ -52,8 +52,8 @@ if CLANG_FORMAT_BIN is None:
# print ("clang-format 7 or above is needed. Aborted.")
# print ("clang-format 7 or above is needed. Aborted.")
# exit(1)
# exit(1)
else
:
else
:
CLANG_FORMAT_BIN
=
'
clang-format-11
'
CLANG_FORMAT_BIN
=
"
clang-format-11
"
COLUMN_LIMIT
=
80
COLUMN_LIMIT
=
80
for
line
in
fmt
.
split
(
"
\n
"
):
for
line
in
fmt
.
split
(
"
\n
"
):
line
=
line
.
split
(
"
:
"
)
line
=
line
.
split
(
"
:
"
)
...
@@ -69,26 +69,47 @@ def custom_format(filename):
...
@@ -69,26 +69,47 @@ def custom_format(filename):
in_define
=
False
in_define
=
False
last_line
=
None
last_line
=
None
out
=
""
out
=
""
for
line
in
src
.
split
(
"
\n
"
):
for
line
in
src
.
split
(
"
\n
"
):
if
line
.
lstrip
().
startswith
(
"
#
"
):
if
line
.
lstrip
().
startswith
(
"
#
"
):
if
line
[
line
.
find
(
"
#
"
)
+
1
:].
lstrip
().
startswith
(
"
define
"
):
if
line
[
line
.
find
(
"
#
"
)
+
1
:].
lstrip
().
startswith
(
"
define
"
):
in_define
=
True
in_define
=
True
if
"
/*
"
in
line
and
not
line
.
strip
().
startswith
(
"
/*
"
)
and
line
.
endswith
(
"
*/
"
)
and
len
(
line
)
<
(
COLUMN_LIMIT
-
2
):
if
(
"
/*
"
in
line
and
not
line
.
strip
().
startswith
(
"
/*
"
)
and
line
.
endswith
(
"
*/
"
)
and
len
(
line
)
<
(
COLUMN_LIMIT
-
2
)
):
cmt_start
=
line
.
rfind
(
"
/*
"
)
cmt_start
=
line
.
rfind
(
"
/*
"
)
line
=
line
[:
cmt_start
]
+
"
"
*
(
COLUMN_LIMIT
-
2
-
len
(
line
))
+
line
[
cmt_start
:]
line
=
(
line
[:
cmt_start
]
+
"
"
*
(
COLUMN_LIMIT
-
2
-
len
(
line
))
+
line
[
cmt_start
:]
)
define_padding
=
0
define_padding
=
0
if
last_line
is
not
None
and
in_define
and
last_line
.
endswith
(
"
\\
"
):
if
last_line
is
not
None
and
in_define
and
last_line
.
endswith
(
"
\\
"
):
last_line
=
last_line
[:
-
1
]
last_line
=
last_line
[:
-
1
]
define_padding
=
max
(
0
,
len
(
last_line
[
last_line
.
rfind
(
"
\n
"
)
+
1
:]))
define_padding
=
max
(
0
,
len
(
last_line
[
last_line
.
rfind
(
"
\n
"
)
+
1
:]))
if
last_line
is
not
None
and
last_line
.
strip
().
endswith
(
"
{
"
)
and
line
.
strip
()
!=
""
:
if
(
last_line
is
not
None
and
last_line
.
strip
().
endswith
(
"
{
"
)
and
line
.
strip
()
!=
""
):
line
=
(
"
"
*
define_padding
+
"
\\
"
if
in_define
else
""
)
+
"
\n
"
+
line
line
=
(
"
"
*
define_padding
+
"
\\
"
if
in_define
else
""
)
+
"
\n
"
+
line
elif
last_line
is
not
None
and
last_line
.
strip
().
startswith
(
"
}
"
)
and
line
.
strip
()
!=
""
:
elif
(
last_line
is
not
None
and
last_line
.
strip
().
startswith
(
"
}
"
)
and
line
.
strip
()
!=
""
):
line
=
(
"
"
*
define_padding
+
"
\\
"
if
in_define
else
""
)
+
"
\n
"
+
line
line
=
(
"
"
*
define_padding
+
"
\\
"
if
in_define
else
""
)
+
"
\n
"
+
line
elif
line
.
strip
().
startswith
(
"
}
"
)
and
last_line
is
not
None
and
last_line
.
strip
()
!=
""
:
elif
(
line
.
strip
().
startswith
(
"
}
"
)
and
last_line
is
not
None
and
last_line
.
strip
()
!=
""
):
line
=
(
"
"
*
define_padding
+
"
\\
"
if
in_define
else
""
)
+
"
\n
"
+
line
line
=
(
"
"
*
define_padding
+
"
\\
"
if
in_define
else
""
)
+
"
\n
"
+
line
if
not
line
.
endswith
(
"
\\
"
):
if
not
line
.
endswith
(
"
\\
"
):
...
@@ -97,14 +118,15 @@ def custom_format(filename):
...
@@ -97,14 +118,15 @@ def custom_format(filename):
out
+=
line
+
"
\n
"
out
+=
line
+
"
\n
"
last_line
=
line
last_line
=
line
return
(
out
)
return
out
args
=
sys
.
argv
[
1
:]
args
=
sys
.
argv
[
1
:]
if
len
(
args
)
==
0
:
if
len
(
args
)
==
0
:
print
(
"
Usage: ./format.py [-i] <filename>
"
)
print
(
"
Usage: ./format.py [-i] <filename>
"
)
print
()
print
()
print
(
"
The -i option, if specified, let the script to modify in-place
"
)
print
(
"
The -i option, if specified, let the script to modify in-place
"
)
print
(
"
the source files. By default the results are written to stdout.
"
)
print
(
"
the source files. By default the results are written to stdout.
"
)
print
()
print
()
exit
(
1
)
exit
(
1
)
...
@@ -120,4 +142,3 @@ for filename in args:
...
@@ -120,4 +142,3 @@ for filename in args:
f
.
write
(
code
)
f
.
write
(
code
)
else
:
else
:
print
(
code
)
print
(
code
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment