From 886d36d65f3bcd30ddc23005e378c0fb4d295e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 8 Nov 2018 18:26:29 +0100 Subject: giscanner: Print relative filename paths when warning g-ir-scanner would cut away the 'common prefix' between the current working directory and the file about be warned about. This is problematic when using automatic jumping to warnings and errors, as it'd mean the editor can't find the relevant file. For example, if g-ir-scanner is run from 'build/', and a warning occurs on a file in 'src/file.c', the scanner would print the warning 'src/file.c:123: Warning: This and that'. Running this from e.g. meson would mean e.g. VIM would not find the correct file to jump to. Meanwhile, GCC, in the same setup, would print '../src/file.c:123: Warning: ...', as that is the relative path from where the scanner is ran, and e.g. VIM would behave in a correct way. --- giscanner/message.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'giscanner/message.py') diff --git a/giscanner/message.py b/giscanner/message.py index 02377896..f20578f3 100644 --- a/giscanner/message.py +++ b/giscanner/message.py @@ -80,11 +80,8 @@ class Position(object): self.column or -1) def format(self, cwd): - filename = os.path.realpath(self.filename) - cwd = os.path.realpath(cwd) - common_prefix = os.path.commonprefix((filename, cwd)) - if common_prefix: - filename = os.path.relpath(filename, common_prefix) + filename = os.path.relpath(os.path.realpath(self.filename), + os.path.realpath(cwd)) if self.column is not None: return '%s:%d:%d' % (filename, self.line, self.column) -- cgit v1.2.1