mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 06:39:17 +02:00
Fixing bug when using -x with a language which doesn't have
interaction-environment. We need to set this in the underlying core environment first. Fixes issue #193.
This commit is contained in:
parent
ca6f2e07cf
commit
d85cff247e
2 changed files with 5 additions and 3 deletions
2
eval.c
2
eval.c
|
@ -2130,6 +2130,8 @@ void sexp_set_parameter (sexp ctx, sexp env, sexp name, sexp value) {
|
|||
sexp_opcode_data(param) = sexp_cons(ctx, name, value);
|
||||
else
|
||||
sexp_cdr(sexp_opcode_data(param)) = value;
|
||||
} else {
|
||||
sexp_warn(ctx, "can't set non-parameter: ", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
6
main.c
6
main.c
|
@ -183,7 +183,7 @@ static void repl (sexp ctx, sexp env) {
|
|||
out = sexp_param_ref(ctx, env, sexp_global(ctx, SEXP_G_CUR_OUT_SYMBOL));
|
||||
err = sexp_param_ref(ctx, env, sexp_global(ctx, SEXP_G_CUR_ERR_SYMBOL));
|
||||
if (!(sexp_iportp(in) && sexp_oportp(out) && sexp_oportp(err))) {
|
||||
fprintf(stderr, "No standing I/O ports found, aborting. Maybe a bad -x language?\n");
|
||||
fprintf(stderr, "No standard I/O ports found, aborting. Maybe a bad -x language?\n");
|
||||
exit_failure();
|
||||
}
|
||||
sexp_port_sourcep(in) = 1;
|
||||
|
@ -370,8 +370,8 @@ void run_main (int argc, char **argv) {
|
|||
tmp = check_exception(ctx, sexp_eval_string(ctx, impmod, -1, (c=='x' ? sexp_global(ctx, SEXP_G_META_ENV) : env)));
|
||||
free(impmod);
|
||||
if (c == 'x') {
|
||||
sexp_set_parameter(ctx, env, sexp_global(ctx, SEXP_G_INTERACTION_ENV_SYMBOL), tmp);
|
||||
sexp_context_env(ctx) = env = tmp;
|
||||
sexp_set_parameter(ctx, env, sexp_global(ctx, SEXP_G_INTERACTION_ENV_SYMBOL), env);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
@ -475,7 +475,7 @@ void run_main (int argc, char **argv) {
|
|||
args = sexp_cons(ctx, tmp=sexp_c_string(ctx,argv[j],-1), args);
|
||||
if (i >= argc || no_script)
|
||||
args = sexp_cons(ctx, tmp=sexp_c_string(ctx,argv[0],-1), args);
|
||||
sexp_set_parameter(ctx, env, sym=sexp_intern(ctx, sexp_argv_symbol, -1), args);
|
||||
sexp_set_parameter(ctx, sexp_global(ctx, SEXP_G_META_ENV), sym=sexp_intern(ctx, sexp_argv_symbol, -1), args);
|
||||
if (i >= argc && main_symbol == NULL) {
|
||||
/* no script or main, run interactively */
|
||||
repl(ctx, env);
|
||||
|
|
Loading…
Add table
Reference in a new issue