Skip to content
Snippets Groups Projects
Commit 20a8517c authored by Andre Maroneze's avatar Andre Maroneze Committed by Allan Blanchard
Browse files

[frama-c-script] better error handling for list-files command

parent 4b12982f
No related branches found
No related tags found
No related merge requests found
......@@ -80,13 +80,17 @@ print("")
files_defining_main = set()
re_main = re.compile(r"(int|void)\s+main\s*\([^)]*\)\s*\{")
for fname, file_for_fcmake in files:
assert os.path.exists(fname), "file does not exist: %s" % fname
with open(fname, "r") as content_file:
content = content_file.read()
res = re.search(re_main, content)
if res is not None:
files_defining_main.add(file_for_fcmake)
for fname, file_for_fcmake in sorted(files):
try:
with open(fname, "r") as content_file:
content = content_file.read()
res = re.search(re_main, content)
if res is not None:
files_defining_main.add(file_for_fcmake)
except OSError:
print(
f"warning: could not read file '{fname}', mentioned in '{arg}'. Skipping check of 'main' function."
)
if files_defining_main != []:
print("")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment