From 84bec65807220f69d1d439981bac044515b292b5 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 2 Dec 2014 20:14:30 +0100 Subject: mds-kbdc: use absolute and relative paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-kbdc/parse-error.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/mds-kbdc/parse-error.c') diff --git a/src/mds-kbdc/parse-error.c b/src/mds-kbdc/parse-error.c index 92e5ab0..f7db9ad 100644 --- a/src/mds-kbdc/parse-error.c +++ b/src/mds-kbdc/parse-error.c @@ -17,6 +17,8 @@ */ #include "parse-error.h" +#include "paths.h" + #include #include #include @@ -34,6 +36,7 @@ static void print(const mds_kbdc_parse_error_t* restrict this, FILE* restrict ou { size_t i, n, start = 0, end = 0; const char* restrict code = this->code; + char* restrict path = relpath(this->pathname, NULL); /* Convert bytes count to character count for the code position. */ for (i = 0, n = this->start; i < n; i++) @@ -45,7 +48,8 @@ static void print(const mds_kbdc_parse_error_t* restrict this, FILE* restrict ou end += start; /* Print error information. */ - fprintf(output, "\033[01m%s\033[21m:", this->pathname); /* TODO should be relative to the current dir */ + fprintf(output, "\033[01m%s\033[21m:", path ? path : this->pathname); + free(path); if (this->error_is_in_file) fprintf(output, "%zu:%zu–%zu:", this->line + 1, start, end); switch (this->severity) -- cgit v1.2.3-70-g09d2