From 930a75074eff7f1d3c91b3a244d47066247d7cd5 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 8 Jan 2023 23:04:40 +0100 Subject: Print warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libfonts_get_default_font.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libfonts_get_default_font.c') diff --git a/libfonts_get_default_font.c b/libfonts_get_default_font.c index 69d2729..e0ad9ab 100644 --- a/libfonts_get_default_font.c +++ b/libfonts_get_default_font.c @@ -25,6 +25,7 @@ getn(char **outp, const char *file_part1, size_t file_part1_len, const char *fil char *line, *buf = NULL; size_t size = 0, off = 0, avail = 0; char *value; + size_t lineno = 0; *outp = NULL; @@ -60,7 +61,7 @@ open_again: case ENODEV: case ENOTDIR: case ENXIO: - /* TODO print warning using `ctx` */ + warning(ctx, errno, "libfonts_get_default_font", "failed to open %s:", path); goto out; default: goto out; @@ -83,6 +84,7 @@ open_again: if (!len) break; line[len -= 1] = '\0'; + lineno++; while (isblank(*line)) { line++; @@ -96,13 +98,13 @@ open_again: value = libfonts_confsplit__(line); if (!value) { - /* TODO warning */ + warning(ctx, 0, "libfonts_get_default_font", "bad line in %s at line %zu", path, lineno); continue; } if (!strcmp(line, name)) { if (*outp) { - /* TODO warning */ + warning(ctx, 0, "libfonts_get_default_font", "duplicate definition in %s at line %zu", path, lineno); free(*outp); *outp = NULL; } @@ -110,7 +112,7 @@ open_again: if (!*outp) goto fail; } else if (strcmp(line, "sans-serif") && strcmp(line, "serif") && strcmp(line, "monospace")) { - /* TODO warning */ + warning(ctx, 0, "libfonts_get_default_font", "bad font class in %s at line %zu: %s", path, lineno, line); } } -- cgit v1.2.3-70-g09d2