diff options
author | Kaz Kyheku <kaz@kylheku.com> | 2020-01-31 06:06:39 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-01-31 06:06:39 -0800 |
commit | b0ebc5943d7de0e76e3e908fb2d543f34396b69f (patch) | |
tree | 0392694052e11387e864ec2421ddd4e3a2f2c9d2 /stream.c | |
parent | eeb8ac7f7bcb3ba950a927a4123e277d1130b862 (diff) | |
download | txr-b0ebc5943d7de0e76e3e908fb2d543f34396b69f.tar.gz txr-b0ebc5943d7de0e76e3e908fb2d543f34396b69f.tar.bz2 txr-b0ebc5943d7de0e76e3e908fb2d543f34396b69f.zip |
open-files: add mode string argument.
The open-files and open-files* functions are missing a mode
string argument, which makes it impossible to, say, open all
of the files in "rb" mode on a platform where that matters.
* stream.c (open_files, open_files_star): Take mode as a third
optional parameter. If it is present, then pass it to
open_file.
* txr.1: Document mode string parameter for the two functions.
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -4503,23 +4503,31 @@ val rename_path(val from, val to) return t; } -static val open_files(val file_list, val substitute_stream) +static val open_files(val file_list, val substitute_stream, val mode) { substitute_stream = default_null_arg(substitute_stream); + mode = default_null_arg(mode); if (nilp(file_list) && substitute_stream) { return substitute_stream; + } else if (mode) { + return make_catenated_stream(mapcar(curry_12_1(func_n2o(open_file, 1), + mode), file_list)); } else { return make_catenated_stream(mapcar(func_n2o(open_file, 1), file_list)); } } -static val open_files_star(val file_list, val substitute_stream) +static val open_files_star(val file_list, val substitute_stream, val mode) { substitute_stream = default_null_arg(substitute_stream); + mode = default_null_arg(mode); if (nilp(file_list) && substitute_stream) { return substitute_stream; + } else if (mode) { + return make_catenated_stream(lazy_mapcar(curry_12_1(func_n2o(open_file, 1), + mode), file_list)); } else { return make_catenated_stream(lazy_mapcar(func_n2o(open_file, 1), file_list)); } @@ -4875,8 +4883,8 @@ void stream_init(void) reg_fun(intern(lit("run"), user_package), func_n2o(run, 1)); reg_fun(intern(lit("remove-path"), user_package), func_n2o(remove_path, 1)); reg_fun(intern(lit("rename-path"), user_package), func_n2(rename_path)); - reg_fun(intern(lit("open-files"), user_package), func_n2o(open_files, 1)); - reg_fun(intern(lit("open-files*"), user_package), func_n2o(open_files_star, 1)); + reg_fun(intern(lit("open-files"), user_package), func_n3o(open_files, 1)); + reg_fun(intern(lit("open-files*"), user_package), func_n3o(open_files_star, 1)); reg_fun(intern(lit("abs-path-p"), user_package), func_n1(abs_path_p)); reg_fun(intern(lit("pure-rel-path-p"), user_package), func_n1(pure_rel_path_p)); reg_fun(intern(lit("base-name"), user_package), func_n2o(base_name, 1)); |