Skip to content
Myr

Move options to main and pass it to process

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Robert Aboukhalil · committed by Nico Williams · parent 4c25cf3 · Browse files · 1 file+4 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−10 removed

  • other:+4 added−10 removed

1 file+4 added−10 removed

modified:src/main.c+4 added-10 removed
144 unmodified lines
145 RUN_TESTS = 32768,146 /* debugging only */147 DUMP_DISASM = 65536,148};149static int options = 0;149150enum {151 JQ_OK = 0,152 JQ_OK_NULL_KIND = -1, /* exit 0 if --exit-status is not set*/
19 unmodified lines
172 return p;173 return n+1;174}175177static int process(jq_state *jq, jv value, int flags, int dumpopts) {176static int process(jq_state *jq, jv value, int flags, int dumpopts, int options) {177 int ret = JQ_OK_NO_OUTPUT; // No valid results && -e -> exit(4)178 jq_start(jq, value, flags);179 jv result;180 while (jv_is_valid(result = jq_next(jq))) {
98 unmodified lines
279 int parser_flags = 0;280 int nfiles = 0;281 int last_result = -1; /* -1 = no result, 0=null or false, 1=true */282 int badwrite;283 int options = 0;284 jv ARGS = jv_array(); /* positional arguments */285 jv program_arguments = jv_object(); /* named arguments */286287#ifdef WIN32
3 unmodified lines
291 _setmode(fileno(stdout), _O_TEXT | _O_U8TEXT);292 _setmode(fileno(stderr), _O_TEXT | _O_U8TEXT);293#endif294295#ifdef __EMSCRIPTEN__296 /* When compiling to WebAssembly with Emscripten, reset options to ensure we can297 call main() multiple times without reinitializing the WebAssembly module. */298 options = 0;299#endif300295 if (argc) progname = argv[0];296297 jq = jq_init();298 if (jq == NULL) {
388 unmodified lines
687 if (nfiles == 0)688 jq_util_input_add_input(input_state, "-");689690 if (options & PROVIDE_NULL) {697 ret = process(jq, jv_null(), jq_flags, dumpopts);691 ret = process(jq, jv_null(), jq_flags, dumpopts, options);692 } else {693 jv value;694 while (jq_util_input_errors(input_state) == 0 &&695 (jv_is_valid((value = jq_util_input_next_input(input_state))) || jv_invalid_has_msg(jv_copy(value)))) {696 if (jv_is_valid(value)) {703 ret = process(jq, value, jq_flags, dumpopts);697 ret = process(jq, value, jq_flags, dumpopts, options);698 if (ret <= 0 && ret != JQ_OK_NO_OUTPUT)699 last_result = (ret != JQ_OK_NULL_KIND);700 if (jq_halted(jq))701 break;
44 unmodified lines