mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
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.
This commit is contained in:
10
execute.c
10
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) {
|
||||
|
Reference in New Issue
Block a user