From bd2db5da3210887d1a128f186851a780c0166b24 Mon Sep 17 00:00:00 2001 From: Mark H Weaver 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 . * 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