mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +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:
parent
363df6cf10
commit
750ac8c592
2 changed files with 17 additions and 4 deletions
|
@ -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 file name 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 '()))
|
||||
|
|
|
@ -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 file name only allowed when the include form is in a file"
|
||||
x)))))
|
||||
(enc (file-encoding p)))
|
||||
|
||||
;; Choose the input encoding deterministically.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue