|
7 | 7 |
|
8 | 8 | #include <njs_main.h> |
9 | 9 |
|
10 | | -#ifndef NJS_FUZZER_TARGET |
| 10 | +#if (!defined NJS_FUZZER_TARGET && defined NJS_HAVE_READLINE) |
11 | 11 |
|
12 | 12 | #include <locale.h> |
13 | 13 | #if (NJS_HAVE_EDITLINE) |
@@ -101,10 +101,13 @@ static njs_int_t njs_process_script(njs_opts_t *opts, |
101 | 101 | static njs_int_t njs_options_parse(njs_opts_t *opts, int argc, char **argv); |
102 | 102 | static void njs_options_free(njs_opts_t *opts); |
103 | 103 | static njs_int_t njs_process_file(njs_opts_t *opts, njs_vm_opt_t *vm_options); |
| 104 | + |
| 105 | +#ifdef NJS_HAVE_READLINE |
104 | 106 | static njs_int_t njs_interactive_shell(njs_opts_t *opts, |
105 | 107 | njs_vm_opt_t *vm_options); |
106 | 108 | static njs_int_t njs_editline_init(void); |
107 | 109 | static char *njs_completion_generator(const char *text, int state); |
| 110 | +#endif |
108 | 111 |
|
109 | 112 | #endif |
110 | 113 |
|
@@ -282,10 +285,16 @@ main(int argc, char **argv) |
282 | 285 | vm_options.ast = opts.ast; |
283 | 286 | vm_options.unhandled_rejection = opts.unhandled_rejection; |
284 | 287 |
|
| 288 | +#ifdef NJS_HAVE_READLINE |
| 289 | + |
285 | 290 | if (opts.interactive) { |
286 | 291 | ret = njs_interactive_shell(&opts, &vm_options); |
287 | 292 |
|
288 | | - } else if (opts.command) { |
| 293 | + } else |
| 294 | + |
| 295 | +#endif |
| 296 | + |
| 297 | + if (opts.command) { |
289 | 298 | vm = njs_create_vm(&opts, &vm_options); |
290 | 299 | if (vm != NULL) { |
291 | 300 | command.start = (u_char *) opts.command; |
@@ -314,9 +323,14 @@ njs_options_parse(njs_opts_t *opts, int argc, char **argv) |
314 | 323 | njs_uint_t n; |
315 | 324 |
|
316 | 325 | static const char help[] = |
317 | | - "Interactive njs shell.\n" |
| 326 | + "njs [options] [-c string | script.js | -] [script args]\n" |
318 | 327 | "\n" |
319 | | - "njs [options] [-c string | script.js | -] [script args]" |
| 328 | + "Interactive shell: " |
| 329 | +#ifdef NJS_HAVE_READLINE |
| 330 | + "enabled\n" |
| 331 | +#else |
| 332 | + "disabled\n" |
| 333 | +#endif |
320 | 334 | "\n" |
321 | 335 | "Options:\n" |
322 | 336 | " -a print AST.\n" |
@@ -914,7 +928,7 @@ njs_process_script(njs_opts_t *opts, njs_console_t *console, |
914 | 928 | } |
915 | 929 |
|
916 | 930 |
|
917 | | -#ifndef NJS_FUZZER_TARGET |
| 931 | +#if (!defined NJS_FUZZER_TARGET && defined NJS_HAVE_READLINE) |
918 | 932 |
|
919 | 933 | static njs_int_t |
920 | 934 | njs_interactive_shell(njs_opts_t *opts, njs_vm_opt_t *vm_options) |
|
0 commit comments