mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-12 15:37:35 +02:00
Erroring when trailing data given to no-arg options.
This commit is contained in:
parent
c5fccbd0ae
commit
7e9ffa3c12
1 changed files with 8 additions and 0 deletions
8
main.c
8
main.c
|
@ -368,6 +368,11 @@ static void do_init_context (sexp* ctx, sexp* env, sexp_uint_t heap_size,
|
||||||
*env = sexp_context_env(*ctx);
|
*env = sexp_context_env(*ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define handle_noarg() if (argv[i][2] != '\0') { \
|
||||||
|
fprintf(stderr, "option %c doesn't take any argument but got: %s\n", argv[i][1], argv[i]); \
|
||||||
|
exit_failure(); \
|
||||||
|
}
|
||||||
|
|
||||||
#define init_context() if (! ctx) do { \
|
#define init_context() if (! ctx) do { \
|
||||||
do_init_context(&ctx, &env, heap_size, heap_max_size, fold_case); \
|
do_init_context(&ctx, &env, heap_size, heap_max_size, fold_case); \
|
||||||
sexp_gc_preserve4(ctx, tmp, sym, args, env); \
|
sexp_gc_preserve4(ctx, tmp, sym, args, env); \
|
||||||
|
@ -457,6 +462,7 @@ void run_main (int argc, char **argv) {
|
||||||
mods_loaded = 1;
|
mods_loaded = 1;
|
||||||
if (! init_loaded++)
|
if (! init_loaded++)
|
||||||
sexp_load_standard_ports(ctx, env, stdin, stdout, stderr, 0);
|
sexp_load_standard_ports(ctx, env, stdin, stdout, stderr, 0);
|
||||||
|
handle_noarg();
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
argv[i--] = (char*)"-xchibi";
|
argv[i--] = (char*)"-xchibi";
|
||||||
|
@ -532,6 +538,7 @@ void run_main (int argc, char **argv) {
|
||||||
fold_case = 1;
|
fold_case = 1;
|
||||||
init_context();
|
init_context();
|
||||||
sexp_global(ctx, SEXP_G_FOLD_CASE_P) = SEXP_TRUE;
|
sexp_global(ctx, SEXP_G_FOLD_CASE_P) = SEXP_TRUE;
|
||||||
|
handle_noarg();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case 'R':
|
case 'R':
|
||||||
|
@ -543,6 +550,7 @@ void run_main (int argc, char **argv) {
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
init_context(); sexp_global(ctx, SEXP_G_STRICT_P) = SEXP_TRUE;
|
init_context(); sexp_global(ctx, SEXP_G_STRICT_P) = SEXP_TRUE;
|
||||||
|
handle_noarg();
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
mods_loaded = 1;
|
mods_loaded = 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue