summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2013-04-28 18:33:45 -0500
committerNicolas Williams <nico@cryptonector.com>2013-04-28 18:46:21 -0500
commit87e9c64003fdb13c629a3e0fbd3c6691a1967d7f (patch)
tree66fad4f19de10ac656998e3b6e7547a84d8f85cd /main.c
parent925ec3751f3b407c17412b0fa04a84fe39c1e0b7 (diff)
Remove globals/make jq_init/next/teardown() an API
Diffstat (limited to 'main.c')
-rw-r--r--main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/main.c b/main.c
index e18f6fdd..92aab150 100644
--- a/main.c
+++ b/main.c
@@ -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) {