From 9dd0fcbeaed19c362ed2d1071d2ea967572b67f4 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Fri, 9 Sep 2016 03:21:14 +0200 Subject: file: do not call fprintf directly --- src/blogc/file.c | 11 ----------- src/blogc/file.h | 2 -- src/blogc/loader.c | 13 +++++++------ 3 files changed, 7 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/blogc/file.c b/src/blogc/file.c index 71598b8..518c665 100644 --- a/src/blogc/file.c +++ b/src/blogc/file.c @@ -68,14 +68,3 @@ blogc_file_get_contents(const char *path, size_t *len, bc_error_t **err) return bc_string_free(str, false); } - - -int -blogc_fprintf(FILE *stream, const char *format, ...) -{ - va_list ap; - va_start(ap, format); - int rv = vfprintf(stream, format, ap); - va_end(ap); - return rv; -} diff --git a/src/blogc/file.h b/src/blogc/file.h index 8213573..6a0e094 100644 --- a/src/blogc/file.h +++ b/src/blogc/file.h @@ -10,12 +10,10 @@ #define _FILE_H #include -#include #include "../common/error.h" #define BLOGC_FILE_CHUNK_SIZE 1024 char* blogc_file_get_contents(const char *path, size_t *len, bc_error_t **err); -int blogc_fprintf(FILE *stream, const char *format, ...); #endif /* _FILE_H */ diff --git a/src/blogc/loader.c b/src/blogc/loader.c index e8de75d..754723b 100644 --- a/src/blogc/loader.c +++ b/src/blogc/loader.c @@ -166,12 +166,13 @@ blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err) rv = bc_slist_append(rv, s); } - if (with_date > 0 && with_date < bc_slist_length(rv)) - // fatal error, maybe? - blogc_fprintf(stderr, - "blogc: warning: 'DATE' variable provided for at least one source " - "file, but not for all source files. This means that you may get " - "wrong values for 'DATE_FIRST' and 'DATE_LAST' variables.\n"); + if (with_date > 0 && with_date < bc_slist_length(rv)) { + *err = bc_error_new_printf(BLOGC_ERROR_LOADER, + "'DATE' variable provided for at least one source file, but not " + "for all source files. It must be provided for all files.\n"); + bc_slist_free_full(rv, (bc_free_func_t) bc_trie_free); + rv = NULL; + } bool first = true; for (bc_slist_t *tmp = rv; tmp != NULL; tmp = tmp->next) { -- cgit v1.2.3-18-g5258