Skip to content

Commit

Permalink
Fix regression
Browse files Browse the repository at this point in the history
  • Loading branch information
celinval committed Mar 23, 2022
1 parent f7410a5 commit 26fa72a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scripts/cbmc_json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,16 @@ def filepath(self):
# proofing.
return self.filename

# Reference to C files use relative paths, while rust uses absolute.
# Normalize both to be absolute first.
full_path = path.abspath(self.filename)
cwd = os.getcwd()
if path.commonpath([self.filename, cwd]) == cwd:
return path.relpath(self.filename)
if path.commonpath([full_path, cwd]) == cwd:
return path.relpath(full_path)

home_path = path.expanduser("~")
if path.commonpath([self.filename, home_path]) == home_path:
return "~/{}".format(path.relpath(self.filename, home_path))
if path.commonpath([full_path, home_path]) == home_path:
return "~/{}".format(path.relpath(full_path, home_path))

return self.filename

Expand Down

0 comments on commit 26fa72a

Please sign in to comment.