1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

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 file name, and when the form is not in a file.

* module/ice-9/psyntax-pp.scm: Regenerate.
This commit is contained in:
Mark H Weaver 2013-11-16 23:24:42 -05:00
parent 363df6cf10
commit 750ac8c592
2 changed files with 17 additions and 4 deletions

View file

@ -2974,7 +2974,14 @@
((read-file ((read-file
(lambda (fn dir k) (lambda (fn dir k)
(let ((p (open-input-file (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 file name only allowed when the include form is in a file"
x))))))
(let ((enc (file-encoding p))) (let ((enc (file-encoding p)))
(set-port-encoding! p (let ((t enc)) (if t t "UTF-8"))) (set-port-encoding! p (let ((t enc)) (if t t "UTF-8")))
(let f ((x (read p)) (result '())) (let f ((x (read p)) (result '()))

View file

@ -2952,9 +2952,15 @@
(define read-file (define read-file
(lambda (fn dir k) (lambda (fn dir k)
(let* ((p (open-input-file (let* ((p (open-input-file
(if (absolute-file-name? fn) (cond ((absolute-file-name? fn)
fn fn)
(in-vicinity dir fn)))) (dir
(in-vicinity dir fn))
(else
(syntax-violation
'include
"relative file name only allowed when the include form is in a file"
x)))))
(enc (file-encoding p))) (enc (file-encoding p)))
;; Choose the input encoding deterministically. ;; Choose the input encoding deterministically.