summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-07 13:16:58 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-07 13:16:58 -0700
commit2d5fcd953cd1632dece9d4202e477a5b2cc95663 (patch)
tree04708e458c3a407e8afb23a3eeb2a6da41f06d89
parentb6a1545715cdef21f6a2989436775e45bada14a9 (diff)
downloadtxr-2d5fcd953cd1632dece9d4202e477a5b2cc95663.tar.gz
txr-2d5fcd953cd1632dece9d4202e477a5b2cc95663.tar.bz2
txr-2d5fcd953cd1632dece9d4202e477a5b2cc95663.zip
Go into repl after processing txr file also.
* match.c (extract): Return match result as cons, rather than int termination status. * match.h (extract): Declaration updated. * txr.c (txr_main): Handle result cons. If repl mode is selected, pass bindings from car(result) to repl. Otherwise use match success indication in cdr(result) to determine termination status.
-rw-r--r--match.c11
-rw-r--r--match.h2
-rw-r--r--txr.c11
3 files changed, 16 insertions, 8 deletions
diff --git a/match.c b/match.c
index 62eeb50d..b4a2fd56 100644
--- a/match.c
+++ b/match.c
@@ -4051,15 +4051,16 @@ val include(val specline)
return v_load(&c);
}
-int extract(val spec, val files, val predefined_bindings)
+val extract(val spec, val files, val predefined_bindings)
{
- cons_bind (bindings, success, match_files(mf_all(spec, files,
- predefined_bindings,
- t, nil)));
+ val result = match_files(mf_all(spec, files, predefined_bindings,
+ t, nil));
+ cons_bind (bindings, success, result);
if (opt_print_bindings) {
if (bindings) {
bindings = nreverse(bindings);
+ rplaca(result, bindings);
dump_bindings(bindings);
}
@@ -4067,7 +4068,7 @@ int extract(val spec, val files, val predefined_bindings)
put_line(lit("false"), std_output);
}
- return success ? 0 : EXIT_FAILURE;
+ return result;
}
static void syms_init(void)
diff --git a/match.h b/match.h
index 2a56cf38..d8f075a3 100644
--- a/match.h
+++ b/match.h
@@ -31,5 +31,5 @@ val format_field(val string_or_list, val modifier, val filter, val eval_fun);
val match_filter(val name, val arg, val other_args);
val match_fun(val name, val args, val input, val files);
val include(val specline);
-int extract(val spec, val filenames, val bindings);
+val extract(val spec, val filenames, val bindings);
void match_init(void);
diff --git a/txr.c b/txr.c
index c2fef68f..b395b185 100644
--- a/txr.c
+++ b/txr.c
@@ -740,8 +740,15 @@ int txr_main(int argc, char **argv)
reg_var(intern(lit("self-path"), user_package), spec_file_str);
{
- int retval = extract(spec, arg_list, bindings);
- return parser.errors ? EXIT_FAILURE : retval;
+ val result = extract(spec, arg_list, bindings);
+ cons_bind (new_bindings, success, result);
+
+ if (enter_repl) {
+ bindings = new_bindings;
+ goto repl;
+ }
+
+ return (parser.errors || !success) ? EXIT_FAILURE : 0;
}
}