diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-12-02 20:14:30 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-12-02 20:19:14 +0100 |
commit | 84bec65807220f69d1d439981bac044515b292b5 (patch) | |
tree | e5276de68365190f568cda095e3e899d5448da81 /src/mds-kbdc/parse-error.c | |
parent | mds-kbdc: files with syntax errors are not empty (diff) | |
download | mds-84bec65807220f69d1d439981bac044515b292b5.tar.gz mds-84bec65807220f69d1d439981bac044515b292b5.tar.bz2 mds-84bec65807220f69d1d439981bac044515b292b5.tar.xz |
mds-kbdc: use absolute and relative paths
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-kbdc/parse-error.c')
-rw-r--r-- | src/mds-kbdc/parse-error.c | 6 |
1 files changed, 5 insertions, 1 deletions
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 <stdlib.h> #include <alloca.h> #include <string.h> @@ -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) |