From 15d3beecdd227c08df600336dff9ecd2d5979136 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sat, 9 May 2015 22:25:30 -0300 Subject: fixing gcc stupidity --- Makefile.am | 2 +- src/file.c | 11 +++++++++++ src/file.h | 3 +++ src/loader.c | 2 +- tests/check_loader.c | 6 +++--- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 3a29f17..9302a7e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -123,7 +123,7 @@ tests_check_loader_CFLAGS = \ tests_check_loader_LDFLAGS = \ -no-install \ -Wl,--wrap=blogc_file_get_contents \ - -Wl,--wrap=fprintf \ + -Wl,--wrap=blogc_fprintf \ $(NULL) tests_check_loader_LDADD = \ diff --git a/src/file.c b/src/file.c index 7648340..5839949 100644 --- a/src/file.c +++ b/src/file.c @@ -48,3 +48,14 @@ blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err) fclose(fp); return b_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/file.h b/src/file.h index 5abdba7..5ff8dd0 100644 --- a/src/file.h +++ b/src/file.h @@ -9,11 +9,14 @@ #ifndef _FILE_H #define _FILE_H +#include +#include #include "utils/utils.h" #include "error.h" #define BLOGC_FILE_CHUNK_SIZE 1024 char* blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err); +int blogc_fprintf(FILE *stream, const char *format, ...); #endif /* _FILE_H */ diff --git a/src/loader.c b/src/loader.c index f868aeb..bcab0d6 100644 --- a/src/loader.c +++ b/src/loader.c @@ -138,7 +138,7 @@ blogc_source_parse_from_files(b_trie_t *conf, b_slist_t *l, blogc_error_t **err) } if (with_date > 0 && with_date < b_slist_length(l)) // fatal error, maybe? - fprintf(stderr, + 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"); diff --git a/tests/check_loader.c b/tests/check_loader.c index d478871..64d8ec8 100644 --- a/tests/check_loader.c +++ b/tests/check_loader.c @@ -67,7 +67,7 @@ __wrap_blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **er int -__wrap_fprintf(FILE *stream, const char *format, ...) +__wrap_blogc_fprintf(FILE *stream, const char *format, ...) { assert_true(stream == mock_type(FILE*)); assert_string_equal(format, mock_type(const char*)); @@ -179,8 +179,8 @@ test_source_parse_from_files(void **state) static void test_source_parse_from_files_without_all_dates(void **state) { - will_return(__wrap_fprintf, stderr); - will_return(__wrap_fprintf, + will_return(__wrap_blogc_fprintf, stderr); + will_return(__wrap_blogc_fprintf, "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"); -- cgit v1.2.3-18-g5258