From: Mark H Weaver <mhw@netris.org>
To: Nala Ginrut <nalaginrut@gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: include can't work
Date: Sat, 16 Nov 2013 23:33:08 -0500 [thread overview]
Message-ID: <87fvqv8x6j.fsf@netris.org> (raw)
In-Reply-To: <87txfb90m2.fsf@netris.org> (Mark H. Weaver's message of "Sat, 16 Nov 2013 22:19:01 -0500")
[-- Attachment #1: Type: text/plain, Size: 384 bytes --]
Mark H Weaver <mhw@netris.org> 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Improve error when 'include' form with relative path is not in a file --]
[-- Type: text/x-patch, Size: 2462 bytes --]
From bd2db5da3210887d1a128f186851a780c0166b24 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
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 <nalaginrut@gmail.com>.
* 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
next prev parent reply other threads:[~2013-11-17 4:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-15 7:40 include can't work Nala Ginrut
2013-11-17 3:19 ` Mark H Weaver
2013-11-17 4:33 ` Mark H Weaver [this message]
2013-11-17 21:09 ` Ludovic Courtès
2013-11-18 6:14 ` Mark H Weaver
2013-11-17 8:24 ` Nala Ginrut
2013-11-17 10:09 ` Mark H Weaver
2013-11-18 7:55 ` Nala Ginrut
2013-11-18 18:13 ` Mark H Weaver
2013-11-18 18:15 ` Mark H Weaver
2013-11-19 3:06 ` Nala Ginrut
[not found] <mailman.171.1384534862.25052.guile-devel@gnu.org>
2013-11-15 17:12 ` Daniel Llorens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fvqv8x6j.fsf@netris.org \
--to=mhw@netris.org \
--cc=guile-devel@gnu.org \
--cc=nalaginrut@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).