mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-19 18:20:22 +02:00
Do not scan for coding declarations in open-file.
* libguile/fports.c (scm_open_file): Do not scan for coding declarations. Replace 'use_encoding' local variable with 'binary'. Update documentation string. * module/ice-9/psyntax.scm (include): Add the same file-encoding logic that's used in compile-file and scm_primitive_load. * module/ice-9/psyntax-pp.scm: Regenerate. * doc/ref/api-io.texi (File Ports): Update docs. * test-suite/tests/ports.test: Change "open-file HONORS file coding declarations" test to "open-file IGNORES file coding declaration". * test-suite/tests/coding.test (scan-coding): Use 'file-encoding' to scan for the encoding, since 'open-input-file' no longer does so.
This commit is contained in:
parent
bc3901092d
commit
9a334eb3ab
6 changed files with 40 additions and 44 deletions
|
@ -2975,10 +2975,12 @@
|
|||
(lambda (fn dir k)
|
||||
(let ((p (open-input-file
|
||||
(if (absolute-file-name? fn) fn (in-vicinity dir fn)))))
|
||||
(let f ((x (read p)) (result '()))
|
||||
(if (eof-object? x)
|
||||
(begin (close-input-port p) (reverse result))
|
||||
(f (read p) (cons (datum->syntax k x) result))))))))
|
||||
(let ((enc (file-encoding p)))
|
||||
(set-port-encoding! p (let ((t enc)) (if t t "UTF-8")))
|
||||
(let f ((x (read p)) (result '()))
|
||||
(if (eof-object? x)
|
||||
(begin (close-input-port p) (reverse result))
|
||||
(f (read p) (cons (datum->syntax k x) result)))))))))
|
||||
(let ((src (syntax-source x)))
|
||||
(let ((file (if src (assq-ref src 'filename) #f)))
|
||||
(let ((dir (if (string? file) (dirname file) #f)))
|
||||
|
|
|
@ -2945,10 +2945,15 @@
|
|||
(lambda (x)
|
||||
(define read-file
|
||||
(lambda (fn dir k)
|
||||
(let ((p (open-input-file
|
||||
(if (absolute-file-name? fn)
|
||||
fn
|
||||
(in-vicinity dir fn)))))
|
||||
(let* ((p (open-input-file
|
||||
(if (absolute-file-name? fn)
|
||||
fn
|
||||
(in-vicinity dir fn))))
|
||||
(enc (file-encoding p)))
|
||||
|
||||
;; Choose the input encoding deterministically.
|
||||
(set-port-encoding! p (or enc "UTF-8"))
|
||||
|
||||
(let f ((x (read p))
|
||||
(result '()))
|
||||
(if (eof-object? x)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue