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.
}
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) {