Raymond Toy pushed to branch issue-139-set-filename-encoding-to-utf8 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
-
7478e387
by Raymond Toy at 2022-12-08T07:04:12-08:00
-
8367cd33
by Raymond Toy at 2022-12-08T07:26:45-08:00
-
fde3634e
by Raymond Toy at 2022-12-08T07:31:53-08:00
-
354f94f5
by Raymond Toy at 2022-12-08T07:32:26-08:00
3 changed files:
Changes:
... | ... | @@ -47,13 +47,9 @@ function cleanup { |
47 | 47 | |
48 | 48 | trap cleanup EXIT
|
49 | 49 | |
50 | -# Set a known value for LANG here so that we can tests consistently.
|
|
51 | -# The most important part is that the codeset is UTF-8.
|
|
52 | -LANG=en_US.UTF-8
|
|
53 | - |
|
54 | 50 | if [ $# -eq 0 ]; then
|
55 | 51 | # No args so run all the tests
|
56 | - $LISP -noinit -load tests/run-tests.lisp -eval '(cmucl-test-runner:run-all-tests)'
|
|
52 | + $LISP -noinit -nositeinit -load tests/run-tests.lisp -eval '(cmucl-test-runner:run-all-tests)'
|
|
57 | 53 | else
|
58 | 54 | # Run selected files. Convert each file name to uppercase and append "-TESTS"
|
59 | 55 | result=""
|
... | ... | @@ -62,6 +58,6 @@ else |
62 | 58 | new=`echo $f | tr '[a-z]' '[A-Z]'`
|
63 | 59 | result="$result "\"$new-TESTS\"
|
64 | 60 | done
|
65 | - $LISP -noinit -load tests/run-tests.lisp -eval "(progn (cmucl-test-runner:load-test-files) (cmucl-test-runner:run-test $result))"
|
|
61 | + $LISP -noinit -nositeinit -load tests/run-tests.lisp -eval "(progn (cmucl-test-runner:load-test-files) (cmucl-test-runner:run-test $result))"
|
|
66 | 62 | fi
|
67 | 63 |
... | ... | @@ -145,26 +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 | - ;; If we know the format. This could be an alias to
|
|
156 | - ;; another format and so on, so use FIND-EXTERNAL-FORMAT
|
|
157 | - ;; to determine the final format and use that as the
|
|
158 | - ;; alias.
|
|
159 | - (let* ((codeset-format (intern codeset "KEYWORD"))
|
|
160 | - (final-format (stream::find-external-format codeset-format)))
|
|
161 | - (setf (gethash :locale stream::*external-format-aliases*)
|
|
162 | - (if final-format
|
|
163 | - (stream::ef-name final-format)
|
|
164 | - (progn
|
|
165 | - (warn "Unsupported external format; using :iso8859-1 instead: ~S"
|
|
166 | - codeset-format)
|
|
167 | - :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*))))
|
|
168 | 165 | (values))
|
169 | 166 | |
170 | 167 |
|
... | ... | @@ -285,8 +282,9 @@ |
285 | 282 | (intl::setlocale)
|
286 | 283 | ;; Set up :locale format
|
287 | 284 | (set-up-locale-external-format)
|
288 | - ;; Set terminal encodings to :locale
|
|
289 | - (set-system-external-format :locale)
|
|
285 | + ;; Set terminal encodings to :locale and filename encoding to :utf-8.
|
|
286 | + ;; (This needs more work on Darwin.)
|
|
287 | + (set-system-external-format :locale :utf-8)
|
|
290 | 288 | (ext::process-command-strings process-command-line)
|
291 | 289 | (setf *editor-lisp-p* nil)
|
292 | 290 | (macrolet ((find-switch (name)
|
... | ... | @@ -682,10 +682,7 @@ |
682 | 682 | ;; work and not return NIL.
|
683 | 683 | (assert-true (file-author "."))
|
684 | 684 | (assert-true (file-author "bin/build.sh"))
|
685 | - (let ((unix::*filename-encoding* :utf-8))
|
|
686 | - ;; Set filename encoding to utf-8 so that we can encode the
|
|
687 | - ;; filename properly.
|
|
688 | - (assert-true
|
|
685 | + (assert-true
|
|
689 | 686 | (file-author
|
690 | 687 | (merge-pathnames
|
691 | 688 | (concatenate 'string
|
... | ... | @@ -696,7 +693,7 @@ |
696 | 693 | '(#\Hangul_Syllable_An #\Hangul_Syllable_Nyeong #\Hangul_Syllable_Ha
|
697 | 694 | #\Hangul_Syllable_Sib #\Hangul_Syllable_Ni #\Hangul_Syllable_Gga)
|
698 | 695 | ".txt")
|
699 | - *test-path*)))))
|
|
696 | + *test-path*))))
|
|
700 | 697 | |
701 | 698 | (define-test issue.139-default-external-format
|
702 | 699 | (:tag :issues)
|
... | ... | @@ -709,9 +706,14 @@ |
709 | 706 | (assert-eq locale-format (stream-external-format sys:*stdout*))
|
710 | 707 | (assert-eq locale-format (stream-external-format sys:*stderr*))
|
711 | 708 | ;; sys:*tty* can either be an fd-stream or a two-way-stream.
|
712 | - ;; stream-external-format doesn't work for a two-way-stream.
|
|
713 | - (unless (typep sys:*tty* 'two-way-stream)
|
|
714 | - (assert-eq locale-format (stream-external-format sys:*tty*)))))
|
|
709 | + (etypecase sys:*tty*
|
|
710 | + (system:fd-stream
|
|
711 | + (assert-eq locale-format (stream-external-format sys:*tty*)))
|
|
712 | + (two-way-stream
|
|
713 | + (assert-eq locale-format
|
|
714 | + (stream-external-format (two-way-stream-input-stream sys:*tty*)))
|
|
715 | + (assert-eq locale-format
|
|
716 | + (stream-external-format (two-way-stream-output-stream sys:*tty*)))))))
|
|
715 | 717 | |
716 | 718 | (define-test issue.139-default-external-format-read-file
|
717 | 719 | (:tag :issues)
|