[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: include can't work
From: |
Mark H Weaver |
Subject: |
Re: include can't work |
Date: |
Sat, 16 Nov 2013 23:33:08 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Mark H Weaver <address@hidden> writes:
> Obviously the error message should be improved, but the upshot is this:
> if you want to use 'include' from the REPL, or from some other port with
> no associated filename, then you must pass it an absolute pathname.
Here's a patch to improve the error message.
I'll push it to stable-2.0 if there are no objections.
Thanks,
Mark
>From bd2db5da3210887d1a128f186851a780c0166b24 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <address@hidden>
Date: Sat, 16 Nov 2013 23:24:42 -0500
Subject: [PATCH] Improve error when 'include' form with relative path is not
in a file.
Reported by Nala Ginrut <address@hidden>.
* module/ice-9/psyntax.scm (include): Give a proper error message when
given a relative pathname, and when the form is not in a file.
* module/ice-9/psyntax-pp.scm: Regenerate.
---
module/ice-9/psyntax-pp.scm | 9 ++++++++-
module/ice-9/psyntax.scm | 12 +++++++++---
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/module/ice-9/psyntax-pp.scm b/module/ice-9/psyntax-pp.scm
index 254f701..3928bed 100644
--- a/module/ice-9/psyntax-pp.scm
+++ b/module/ice-9/psyntax-pp.scm
@@ -2974,7 +2974,14 @@
((read-file
(lambda (fn dir k)
(let ((p (open-input-file
- (if (absolute-file-name? fn) fn (in-vicinity dir
fn)))))
+ (if (absolute-file-name? fn)
+ fn
+ (if dir
+ (in-vicinity dir fn)
+ (syntax-violation
+ 'include
+ "relative pathname only allowed when the include
form is in a file"
+ x))))))
(let ((enc (file-encoding p)))
(set-port-encoding! p (let ((t enc)) (if t t "UTF-8")))
(let f ((x (read p)) (result '()))
diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm
index 576fc3f..84b2ef9 100644
--- a/module/ice-9/psyntax.scm
+++ b/module/ice-9/psyntax.scm
@@ -2952,9 +2952,15 @@
(define read-file
(lambda (fn dir k)
(let* ((p (open-input-file
- (if (absolute-file-name? fn)
- fn
- (in-vicinity dir fn))))
+ (cond ((absolute-file-name? fn)
+ fn)
+ (dir
+ (in-vicinity dir fn))
+ (else
+ (syntax-violation
+ 'include
+ "relative pathname only allowed when the include
form is in a file"
+ x)))))
(enc (file-encoding p)))
;; Choose the input encoding deterministically.
--
1.7.5.4
- include can't work, Nala Ginrut, 2013/11/15
- Re: include can't work, Mark H Weaver, 2013/11/16
- Re: include can't work,
Mark H Weaver <=
- Re: include can't work, Nala Ginrut, 2013/11/17
- Re: include can't work, Mark H Weaver, 2013/11/17
- Re: include can't work, Nala Ginrut, 2013/11/18
- Re: include can't work, Mark H Weaver, 2013/11/18
- Re: include can't work, Mark H Weaver, 2013/11/18
- Re: include can't work, Nala Ginrut, 2013/11/18