summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-08-01 11:57:03 +0200
committerPatrick Steinhardt <ps@pks.im>2019-08-01 11:57:03 +0200
commit27b8b31e2955ec264a9b748c8e5328e2c8e04419 (patch)
tree6c89bb67b190ceaf93cb82024cd8c817b96846db
parentc8e63812c5f2402bab4f74f68d46843d7d94123c (diff)
downloadlibgit2-27b8b31e2955ec264a9b748c8e5328e2c8e04419.tar.gz
parse: remove use of variadic macros which are not C89 compliant
The macro `git_parse_error` is implemented in a variadic way so that it's possible to pass printf-style parameters. Unfortunately, variadic macros are not defined by C89 and thus we cannot use that functionality. But as we have implemented `git_error_vset` in the previous commit, we can now just use that instead. Convert `git_parse_error` to a variadic function and use `git_error_vset` to fix the compliance violation. While at it, move the function to "patch_parse.c".
-rw-r--r--src/parse.h3
-rw-r--r--src/patch_parse.c12
2 files changed, 12 insertions, 3 deletions
diff --git a/src/parse.h b/src/parse.h
index 42a2aff1a..188ac281c 100644
--- a/src/parse.h
+++ b/src/parse.h
@@ -28,9 +28,6 @@ typedef struct {
int git_parse_ctx_init(git_parse_ctx *ctx, const char *content, size_t content_len);
void git_parse_ctx_clear(git_parse_ctx *ctx);
-#define git_parse_err(...) \
- ( git_error_set(GIT_ERROR_PATCH, __VA_ARGS__), -1 )
-
#define git_parse_ctx_contains_s(ctx, str) \
git_parse_ctx_contains(ctx, str, sizeof(str) - 1)
diff --git a/src/patch_parse.c b/src/patch_parse.c
index 29dc8b818..84953ee14 100644
--- a/src/patch_parse.c
+++ b/src/patch_parse.c
@@ -33,6 +33,18 @@ typedef struct {
char *old_prefix, *new_prefix;
} git_patch_parsed;
+static int git_parse_err(const char *fmt, ...) GIT_FORMAT_PRINTF(1, 2);
+static int git_parse_err(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ git_error_vset(GIT_ERROR_PATCH, fmt, ap);
+ va_end(ap);
+
+ return -1;
+}
+
static size_t header_path_len(git_patch_parse_ctx *ctx)
{
bool inquote = 0;