Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
-
1af83384
by Raymond Toy at 2022-12-08T14:57:43+00:00
-
6fc2e38e
by Raymond Toy at 2022-12-08T14:57:45+00:00
3 changed files:
Changes:
... | ... | @@ -2397,10 +2397,10 @@ |
2397 | 2397 | (setf *available-buffers* nil)
|
2398 | 2398 | (setf *stdin*
|
2399 | 2399 | (make-fd-stream 0 :name "Standard Input" :input t :buffering :line
|
2400 | - :external-format :iso8859-1))
|
|
2400 | + :external-format :utf-8))
|
|
2401 | 2401 | (setf *stdout*
|
2402 | 2402 | (make-fd-stream 1 :name "Standard Output" :output t :buffering :line
|
2403 | - :external-format :iso8859-1))
|
|
2403 | + :external-format :utf-8))
|
|
2404 | 2404 | (setf *stderr*
|
2405 | 2405 | (make-fd-stream 2 :name "Standard Error" :output t :buffering :line
|
2406 | 2406 | :external-format :iso8859-1))
|
... | ... | @@ -2410,7 +2410,7 @@ |
2410 | 2410 | (if tty
|
2411 | 2411 | (make-fd-stream tty :name "the Terminal" :input t :output t
|
2412 | 2412 | :buffering :line :auto-close t
|
2413 | - :external-format :iso8859-1)
|
|
2413 | + :external-format :utf-8)
|
|
2414 | 2414 | (make-two-way-stream *stdin* *stdout*))))
|
2415 | 2415 | nil)
|
2416 | 2416 |
... | ... | @@ -145,24 +145,23 @@ |
145 | 145 | (defun set-up-locale-external-format ()
|
146 | 146 | "Add external format alias for :locale to the format specified by
|
147 | 147 | the locale as set by setlocale(3C)."
|
148 | - (let ((codeset (unix::unix-get-locale-codeset)))
|
|
148 | + (let ((codeset (unix::unix-get-locale-codeset))
|
|
149 | + (external-format nil))
|
|
149 | 150 | (cond ((zerop (length codeset))
|
150 | - ;; Codeset was the empty string, so just set :locale to
|
|
151 | - ;; alias to the default external format.
|
|
151 | + (setq external-format *default-external-format*))
|
|
152 | + (t
|
|
153 | + (let ((name (intern codeset "KEYWORD")))
|
|
154 | + (setq external-format
|
|
155 | + (stream::ef-name (stream::find-external-format name nil))))))
|
|
156 | + (cond (external-format
|
|
152 | 157 | (setf (gethash :locale stream::*external-format-aliases*)
|
153 | - *default-external-format*))
|
|
158 | + external-format))
|
|
154 | 159 | (t
|
155 | - (let ((codeset-format (intern codeset "KEYWORD")))
|
|
156 | - ;; If we know the format, we can set the alias.
|
|
157 | - ;; Otherwise, print a warning and use :iso8859-1 as the
|
|
158 | - ;; alias.
|
|
159 | - (setf (gethash :locale stream::*external-format-aliases*)
|
|
160 | - (if (stream::find-external-format codeset-format nil)
|
|
161 | - codeset-format
|
|
162 | - (progn
|
|
163 | - (warn "Unsupported external format; using :iso8859-1 instead: ~S"
|
|
164 | - codeset-format)
|
|
165 | - :iso8859-1)))))))
|
|
160 | + (warn "No external format found for codeset \"~S\"; using ~S instead"
|
|
161 | + codeset
|
|
162 | + *default-external-format*)
|
|
163 | + (setf (gethash :locale stream::*external-format-aliases*)
|
|
164 | + *default-external-format*))))
|
|
166 | 165 | (values))
|
167 | 166 | |
168 | 167 |
|
... | ... | @@ -283,6 +282,8 @@ |
283 | 282 | (intl::setlocale)
|
284 | 283 | ;; Set up :locale format
|
285 | 284 | (set-up-locale-external-format)
|
285 | + ;; Set terminal encodings to :locale
|
|
286 | + (set-system-external-format :locale)
|
|
286 | 287 | (ext::process-command-strings process-command-line)
|
287 | 288 | (setf *editor-lisp-p* nil)
|
288 | 289 | (macrolet ((find-switch (name)
|
... | ... | @@ -700,7 +700,23 @@ |
700 | 700 | |
701 | 701 | (define-test issue.139-default-external-format
|
702 | 702 | (:tag :issues)
|
703 | - (assert-eq :utf-8 stream:*default-external-format*))
|
|
703 | + (assert-eq :utf-8 stream:*default-external-format*)
|
|
704 | + ;; Find the alias for :locale, and verify it exists and verify that
|
|
705 | + ;; the system streams have that format.
|
|
706 | + (let ((locale-format (gethash :locale stream::*external-format-aliases*)))
|
|
707 | + (assert locale-format)
|
|
708 | + (assert-eq locale-format (stream-external-format sys:*stdin*))
|
|
709 | + (assert-eq locale-format (stream-external-format sys:*stdout*))
|
|
710 | + (assert-eq locale-format (stream-external-format sys:*stderr*))
|
|
711 | + ;; sys:*tty* can either be an fd-stream or a two-way-stream.
|
|
712 | + (etypecase sys:*tty*
|
|
713 | + (system:fd-stream
|
|
714 | + (assert-eq locale-format (stream-external-format sys:*tty*)))
|
|
715 | + (two-way-stream
|
|
716 | + (assert-eq locale-format
|
|
717 | + (stream-external-format (two-way-stream-input-stream sys:*tty*)))
|
|
718 | + (assert-eq locale-format
|
|
719 | + (stream-external-format (two-way-stream-output-stream sys:*tty*)))))))
|
|
704 | 720 | |
705 | 721 | (define-test issue.139-default-external-format-read-file
|
706 | 722 | (:tag :issues)
|