1
0
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:
Nicolas Williams
2014-12-30 01:02:56 -06:00
parent 6981b46338
commit b67bad82cb

View File

@@ -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) {