mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-17 12:18:08 +00:00
black
This commit is contained in:
@ -52,7 +52,7 @@ 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"):
|
||||||
@ -75,20 +75,41 @@ def custom_format(filename):
|
|||||||
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,7 +118,8 @@ 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:
|
||||||
@ -120,4 +142,3 @@ for filename in args:
|
|||||||
f.write(code)
|
f.write(code)
|
||||||
else:
|
else:
|
||||||
print(code)
|
print(code)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user