Raymond Toy pushed to branch issue-139-use-lang-to-set-external-format at cmucl / cmucl
Commits:
2ef57042 by Raymond Toy at 2022-10-02T17:29:25-07:00
Update pot file
- - - - -
1 changed file:
- src/i18n/locale/cmucl.pot
Changes:
=====================================
src/i18n/locale/cmucl.pot
=====================================
@@ -6714,6 +6714,14 @@ msgid ""
"This is true if and only if the lisp was started with the -edit switch."
msgstr ""
+#: src/code/save.lisp
+msgid ""
+"Set up encodings based on the value of the LANG envvar. The\n"
+" codeset from LANG will be used to set *DEFAULT-EXTERNAL-FORMAT* and\n"
+" sets the terminal and file name encoding to the specified codeset.\n"
+" If Quiet is non-NIL, then messages will be suppressed."
+msgstr ""
+
#: src/code/save.lisp
msgid ""
"Saves a CMU Common Lisp core image in the file of the specified name. The\n"
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/2ef570428f0fb5ffb73f05a…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/2ef570428f0fb5ffb73f05a…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-139-use-lang-to-set-external-format at cmucl / cmucl
Commits:
48c9afad by Raymond Toy at 2022-10-01T16:24:35-07:00
Recognize LC_ALL and LC_MESSAGES for setting encodings
We look for LC_ALL and LC_MESSAGES (in that order) for encodings. The
fallback is LANG.
We also recognize C and POSIX which mean ISO8859-1 encodings.
Finally, if LANG and friends starts with a "/" for a path, we ignore
the setting and just use the default encodings.
- - - - -
1 changed file:
- src/code/save.lisp
Changes:
=====================================
src/code/save.lisp
=====================================
@@ -147,23 +147,50 @@
codeset from LANG will be used to set *DEFAULT-EXTERNAL-FORMAT* and
sets the terminal and file name encoding to the specified codeset.
If Quiet is non-NIL, then messages will be suppressed."
- (let ((lang (unix:unix-getenv "LANG")))
+ ;; Find the envvar that will tell us what encoding to use.
+ ;;
+ ;; See https://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html
+ ;;
+ (let* ((lang (or (unix:unix-getenv "LC_ALL")
+ (unix:unix-getenv "LC_MESSAGES")
+ (unix:unix-getenv "LANG")))
+ (length (length lang)))
+ ;; If LANG isn't set, we don't need to do anything and just use
+ ;; the builtin defaults.
(when lang
- ;; Simple parsing of LANG.
- (let ((dot (position #\. lang))
- (at (or (position #\@ lang) nil)))
- (when dot
- (let* ((codeset (subseq lang (1+ dot) at))
- (format (intern codeset "KEYWORD")))
- (cond ((stream::find-external-format format nil)
- (unless quiet
- (write-string "Default external format and filename encoding: ")
- (princ format)
- (terpri))
- (setf *default-external-format* format)
- (set-system-external-format format format))
- (t
- (warn "Unknown or unsupported external format: ~S" codeset)))))))))
+ (cond
+ ((or (string-equal "C" lang :end2 (min 1 length))
+ (string-equal "POSIX" lang :end2 (min 5 length)))
+ ;; If the lang is "C" or "POSIX", ignoring anything after
+ ;; that, we need to set the format accordingly.
+ (setf *default-external-format* :iso8859-1)
+ (set-system-external-format :iso8859-1 nil))
+ ((string-equal "/" lang :end2 (min 1 length))
+ ;; Also, we don't handle the case where the locale starts
+ ;; with a slash which means a pathname to a file created by
+ ;; the localdef utility. So use our defaults for that case
+ ;; as well.
+ (setf *default-external-format* :iso8859-1)
+ (set-system-external-format :iso8859-1 nil))
+ (t
+ ;; Simple parsing of LANG. We assume it looks like
+ ;; "language[_territory][.codeset]". We're only interested
+ ;; in the codeset, if given. Some LC_ vars also have an
+ ;; optional @modifier after the codeset; we ignore that too.
+ (let ((dot (position #\. lang))
+ (at (or (position #\@ lang) nil)))
+ (when dot
+ (let* ((codeset (subseq lang (1+ dot) at))
+ (format (intern codeset "KEYWORD")))
+ (cond ((stream::find-external-format format nil)
+ (unless quiet
+ (write-string "Default external format and filename encoding: ")
+ (princ format)
+ (terpri))
+ (setf *default-external-format* format)
+ (set-system-external-format format format))
+ (t
+ (warn "Unknown or unsupported external format: ~S" codeset)))))))))))
(defun save-lisp (core-file-name &key
(purify t)
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/48c9afadb56bc3d3da9c0bb…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/48c9afadb56bc3d3da9c0bb…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-132-ansi-test-rename-files at cmucl / cmucl
Commits:
189b1940 by Raymond Toy at 2022-09-27T16:20:25-07:00
Rename NEW-FILE-NAME arg back to NEW-NAME
This was an oversight from when I was doing some experiments on what
to return from RENAME-FILE.
- - - - -
1 changed file:
- src/code/filesys.lisp
Changes:
=====================================
src/code/filesys.lisp
=====================================
@@ -940,7 +940,7 @@
;;; Rename-File -- Public
;;;
-(defun rename-file (file new-file-name)
+(defun rename-file (file new-name)
"Rename File to have the specified New-Name. If file is a stream
open to a file, then the associated file is renamed.
@@ -953,7 +953,7 @@
;; First, merge NEW-FILE-NAME with *DEFAULT-PATHNAME-DEFAULTS* to
;; fill in the missing components and then merge again with
;; the FILE to get any missing components from FILE.
- (new-name (merge-pathnames (merge-pathnames new-file-name)
+ (new-name (merge-pathnames (merge-pathnames new-name)
file))
(new-namestring (unix-namestring new-name nil)))
(unless new-namestring
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/189b194089db3484d554ebb…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/189b194089db3484d554ebb…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-140-stream-element-type-two-way-stream at cmucl / cmucl
Commits:
334be4e0 by Raymond Toy at 2022-09-27T14:53:35-07:00
Update release notes for issue #140.
- - - - -
1 changed file:
- src/general-info/release-21e.md
Changes:
=====================================
src/general-info/release-21e.md
=====================================
@@ -52,6 +52,7 @@ public domain.
* ~~#122~~ gcc 11 can't build cmucl
* ~~#127~~ Linux unix-getpwuid segfaults when given non-existent uid.
* ~~#128~~ `QUIT` accepts an exit code
+ * ~~#140~~ External format of `two-way-stream` returns the common format of the input and output streams if possible; otherwise, return `:default`.
* Other changes:
* Improvements to the PCL implementation of CLOS:
* Changes to building procedure:
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/334be4e0666f767ce56332c…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/334be4e0666f767ce56332c…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-139a-default-external-format-utf8 at cmucl / cmucl
Commits:
86b4483e by Raymond Toy at 2022-09-23T16:46:25-07:00
*tty* format can be either :utf-8 or :default
`*tty*` can either be an fd-stream of a two-way-stream. If the
former, the format is `:utf-8`; if the latter, `:default`. Update
test accordingly.
- - - - -
1 changed file:
- tests/issues.lisp
Changes:
=====================================
tests/issues.lisp
=====================================
@@ -587,7 +587,11 @@
(assert-eql :utf-8 (stream-external-format sys:*stdin*))
(assert-eql :utf-8 (stream-external-format sys:*stdout*))
(assert-eql :utf-8 (stream-external-format sys:*stderr*))
- (assert-eql :utf-8 (stream-external-format sys:*tty*))
+ ;; *tty* can either be an fd-stream, in which case the format is
+ ;; utf8, or a two-way-stream, in which case it is :default.
+ (if (typep sys:*tty* 'two-way-stream)
+ (assert-eql :default (stream-external-format sys:*tty*))
+ (assert-eql :utf-8 (stream-external-format sys:*tty*)))
;; Check that printing to *standard-output* is correctly encoded.
(dribble "test-format.txt")
;; Print a Greek lower-case alpha character
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/86b4483e870dc7f5bd512fd…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/86b4483e870dc7f5bd512fd…
You're receiving this email because of your account on gitlab.common-lisp.net.