Skip to content
Snippets Groups Projects
Commit ed90e7e0 authored by Raymond Toy's avatar Raymond Toy
Browse files

Use stream::find-external-format to determine the formats

The `:locale` format can be set to an alias, which itself is an
alias.  We want to use the final underlying format so use
`stream::find-external-format` to do that and extract the name from
that to use as the alias for `:locate`.
parent 29bc9639
No related branches found
No related tags found
3 merge requests!113Address #158: Filename encoding for Darwin,!109Address #139: Set filename encoding to :utf-8,!108Address #139: Set terminal format to :locale
Pipeline #7524 passed
......@@ -152,13 +152,15 @@
(setf (gethash :locale stream::*external-format-aliases*)
*default-external-format*))
(t
(let ((codeset-format (intern codeset "KEYWORD")))
;; If we know the format, we can set the alias.
;; Otherwise, print a warning and use :iso8859-1 as the
;; If we know the format. This could be an alias to
;; another format and so on, so use FIND-EXTERNAL-FORMAT
;; to determine the final format and use that as the
;; alias.
(let* ((codeset-format (intern codeset "KEYWORD"))
(final-format (stream::find-external-format codeset-format)))
(setf (gethash :locale stream::*external-format-aliases*)
(if (stream::find-external-format codeset-format nil)
codeset-format
(if final-format
(stream::ef-name final-format)
(progn
(warn "Unsupported external format; using :iso8859-1 instead: ~S"
codeset-format)
......
......@@ -702,16 +702,16 @@
(:tag :issues)
(assert-eq :utf-8 stream:*default-external-format*)
;; Find the alias for :locale, and verify it exists and verify that
;; the system streams have that format. Use
(let ((locale-format (stream::find-external-format :locale)))
;; the system streams have that format.
(let ((locale-format (gethash :locale stream::*external-format-aliases*)))
(assert locale-format)
(assert-eq locale-format (stream::find-external-format (stream-external-format sys:*stdin*)))
(assert-eq locale-format (stream::find-external-format (stream-external-format sys:*stdout*)))
(assert-eq locale-format (stream::find-external-format (stream-external-format sys:*stderr*)))
(assert-eq locale-format (stream-external-format sys:*stdin*))
(assert-eq locale-format (stream-external-format sys:*stdout*))
(assert-eq locale-format (stream-external-format sys:*stderr*))
;; sys:*tty* can either be an fd-stream or a two-way-stream.
;; stream-external-format doesn't work for a two-way-stream.
(unless (typep sys:*tty* 'two-way-stream)
(assert-eq locale-format (stream::find-external-format (stream-external-format sys:*tty*))))))
(assert-eq locale-format (stream-external-format sys:*tty*)))))
(define-test issue.139-default-external-format-read-file
(:tag :issues)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment