Remove globals/make jq_init/next/teardown() an API
This commit is contained in:
1 parent
925ec3751f
commit
87e9c64003
4 files changed
+159
-146
No files matched your search
@@ -63,9 +63,10 @@ static int options = 0;
|
||||
static struct bytecode* bc;
|
||||
|
||||
static void process(jv value) {
|
||||
jq_init(bc, value);
|
||||
jq_state *jq = NULL;
|
||||
jq_init(bc, value, &jq);
|
||||
jv result;
|
||||
while (jv_is_valid(result = jq_next())) {
|
||||
while (jv_is_valid(result = jq_next(jq))) {
|
||||
if ((options & RAW_OUTPUT) && jv_get_kind(result) == JV_KIND_STRING) {
|
||||
fwrite(jv_string_value(result), 1, jv_string_length(jv_copy(result)), stdout);
|
||||
jv_free(result);
|
||||
@@ -85,7 +86,7 @@ static void process(jv value) {
|
||||
printf("\n");
|
||||
}
|
||||
jv_free(result);
|
||||
jq_teardown();
|
||||
jq_teardown(&jq);
|
||||
}
|
||||
|
||||
static jv slurp_file(const char* filename) {
|
||||
|
||||
Reference in new issue
Block a user