From b67bad82cbf71da211e82ade7ae4c87f02b1df98 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Tue, 30 Dec 2014 01:02:56 -0600 Subject: [PATCH] Allow resetting of jq err callback This will be useful for the upcoming test-erroneous-programs improvement to --run-tests, so we can switch between the default error reporting method (print to stderr) to a method internal to --run-tests, and back. The idea is that when testing programs that are expected to compile (and link), it'd be nice if errors continue going to stderr, while when testing programs that must fail to compile (or link), the error has to be captured so it can be compared to the error expected by the test. --- execute.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/execute.c b/execute.c index 91c426e..67a1629 100644 --- a/execute.c +++ b/execute.c @@ -854,9 +854,13 @@ jq_state *jq_init(void) { } void jq_set_error_cb(jq_state *jq, jq_err_cb cb, void *data) { - assert(cb != NULL); - jq->err_cb = cb; - jq->err_cb_data = data; + if (cb == NULL) { + jq->err_cb = default_err_cb; + jq->err_cb_data = stderr; + } else { + jq->err_cb = cb; + jq->err_cb_data = data; + } } void jq_get_error_cb(jq_state *jq, jq_err_cb *cb, void **data) { -- 2.40.0