diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-30 23:07:32 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-30 23:07:32 -0700 |
commit | 1bf965ceb66aa0ebc0404df306b6563253af9f1a (patch) | |
tree | f825d9b58a109e689714caebe1077deef954be4f /parser.c | |
parent | c91af9a17b0533c6df846ff712e7ade306c7b38a (diff) | |
download | txr-1bf965ceb66aa0ebc0404df306b6563253af9f1a.tar.gz txr-1bf965ceb66aa0ebc0404df306b6563253af9f1a.tar.bz2 txr-1bf965ceb66aa0ebc0404df306b6563253af9f1a.zip |
Refactoring hash bang support; hash bang null hack.
The hash bang mechanism is handled in one place,
and disentangled from all parsing logic.
It is also endowed with special powers.
* eval.c (load): Pass one less argument to read_eval_stream.
* match.c (v_load): Likewise.
* parser.c (read_eval_stream): hash_bang_support Boolean
argument removed. Hash bang logic removed.
(load_rcfile): Pass only two arguments to read_eval_stream.
* parser.h (read_eval_stream): Declaration updated.
* txr.c (remove_hash_bang_line): Function removed.
(check_hash_bang): New static function.
(txr_main): Recognize the script file name while still
inside the argument processing loop. Open the file,
and check for a hash bang line, doing the special
processing which can generate more arguments from material
after a null byte in the hash bang line. The parse_stream
variable is now initialized to nil and doubles as a Boolean
indicating whether a stream has been opened. After the
loop, we remove the script file from the arguments, if we
have an open stream and the spec_file_str matches.
read_eval_stream is called only with two arguments.
* txr.1: Revised existing documentation and described
new features.
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 14 |
1 files changed, 2 insertions, 12 deletions
@@ -577,21 +577,11 @@ val iread(val source_in, val error_stream, val error_return_val, name_in, lineno); } -val read_eval_stream(val stream, val error_stream, val hash_bang_support) +val read_eval_stream(val stream, val error_stream) { val error_val = gensym(nil); val name = stream_get_prop(stream, name_k); - if (hash_bang_support) { - val firstline = get_line(stream); - - if (firstline && !match_str(firstline, lit("#!"), nil)) { - val flwnl = scat(nil, firstline, lit("\n"), nao); - val string_stream = make_string_byte_input_stream(flwnl); - stream = make_catenated_stream(list(string_stream, stream, nao)); - } - } - for (;;) { val form = lisp_parse(stream, error_stream, error_val, name, colon_k); val parser = get_parser(stream); @@ -639,7 +629,7 @@ static void load_rcfile(val name) } else { val saved_dyn_env = set_dyn_env(make_env(nil, nil, dyn_env)); env_vbind(dyn_env, load_path_s, resolved_name); - read_eval_stream(stream, std_output, nil); + read_eval_stream(stream, std_output); dyn_env = saved_dyn_env; } } |