summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-03-31 07:24:43 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-03-31 07:24:43 -0700
commit2e894651f9955fabc905e8a517ba33b69c0e2593 (patch)
tree160345fb0bc07c420b28fd3f89878a36d2ae34c7 /parser.c
parentbae5a63ed738cae08c056bdfa272130029fa7ca5 (diff)
downloadtxr-2e894651f9955fabc905e8a517ba33b69c0e2593.tar.gz
txr-2e894651f9955fabc905e8a517ba33b69c0e2593.tar.bz2
txr-2e894651f9955fabc905e8a517ba33b69c0e2593.zip
loading: bugfix: try specified path before suffixes.
This is a partial revert of the May 1, 2019 commit 065dde19dfbe50e91e313e5b3ccc033cfbe47f74, titled "loading: try unsuffixed files directly last". Test cases added in prior commit now pass. * parser.c (open_txr_file); Like before the 2019 commit, we try the exact path that is specified first. Only if that is not found do we try adding suffixes to a file which has no recognizable suffix. This does mean that (load "foo") will probe the filesystem twice in order to find "foo.tl" or "foo.tlo" there is no obvious way around that that doesn't cause a problem. * txr.1: Update documentation that is outdated, incomplete, incorrect, or that is has become incorrect because of this fix.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/parser.c b/parser.c
index ee2ab6df..dbb7e481 100644
--- a/parser.c
+++ b/parser.c
@@ -534,6 +534,33 @@ void open_txr_file(val spec_file, val *txr_lisp_p, val *name, val *stream,
val spec_file_try = nil;
FILE *in = 0;
+ {
+ spec_file_try = spec_file;
+ errno = 0;
+ in = w_fopen(c_str(spec_file_try, self), L"r");
+ if (in != 0) {
+ switch (suffix) {
+ case tl:
+ *txr_lisp_p = t;
+ break;
+ case tlo:
+ *txr_lisp_p = chr('o');
+ break;
+ case txr:
+ *txr_lisp_p = nil;
+ break;
+ default:
+ break;
+ }
+ goto found;
+ } else {
+#ifdef ENOENT
+ if (errno != ENOENT)
+ goto except;
+#endif
+ }
+ }
+
if (suffix == none && !*txr_lisp_p) {
spec_file_try = scat(lit("."), spec_file, lit("txr"), nao);
if ((in = w_fopen(c_str(spec_file_try, nil), L"r")) != 0)
@@ -571,27 +598,6 @@ void open_txr_file(val spec_file, val *txr_lisp_p, val *name, val *stream,
}
}
- {
- spec_file_try = spec_file;
- errno = 0;
- in = w_fopen(c_str(spec_file_try, self), L"r");
- if (in != 0) {
- switch (suffix) {
- case tl:
- *txr_lisp_p = t;
- break;
- case tlo:
- *txr_lisp_p = chr('o');
- break;
- case txr:
- *txr_lisp_p = nil;
- break;
- default:
- break;
- }
- }
- }
-
if (in == 0) {
#ifdef ENOENT
except: