Raymond Toy pushed to branch master at cmucl / cmucl

Commits:

4 changed files:

Changes:

  • src/code/extfmts.lisp
    ... ... @@ -370,8 +370,10 @@
    370 370
     		    #() '())))))
    
    371 371
     
    
    372 372
     (defun load-external-format-aliases ()
    
    373
    +  ;; Set filename encoding to NIL to bypass any encoding; it's not
    
    374
    +  ;; needed to open the aliases file.  NIL means the pathname string is passed as is where only the low 8 bits of the 
    
    373 375
       (let ((*package* (find-package "KEYWORD"))
    
    374
    -	(unix::*filename-encoding* :iso8859-1))
    
    376
    +	(unix::*filename-encoding* nil))
    
    375 377
         (with-open-file (stm "ext-formats:aliases" :if-does-not-exist nil
    
    376 378
     			 :external-format :iso8859-1)
    
    377 379
           (when stm
    
    ... ... @@ -486,11 +488,16 @@
    486 488
           (and (consp name) (find-external-format name))
    
    487 489
           (and (with-standard-io-syntax
    
    488 490
     	     ;; Use standard IO syntax so that changes by the user
    
    489
    -	     ;; don't mess up compiling the external format.
    
    490
    -	     (let ((*package* (find-package "STREAM"))
    
    491
    -		   (lisp::*enable-package-locked-errors* nil)
    
    492
    -		   (s (open (format nil "ext-formats:~(~A~).lisp" name)
    
    493
    -			    :if-does-not-exist nil :external-format :iso8859-1)))
    
    491
    +	     ;; don't mess up compiling the external format, but we
    
    492
    +	     ;; don't need to print readably.  Also, set filename
    
    493
    +	     ;; encoding to NIL because we don't need any special
    
    494
    +	     ;; encoding to open the format files.
    
    495
    +	     (let* ((*print-readably* nil)
    
    496
    +		    (unix::*filename-encoding* nil)
    
    497
    +		    (*package* (find-package "STREAM"))
    
    498
    +		    (lisp::*enable-package-locked-errors* nil)
    
    499
    +		    (s (open (format nil "ext-formats:~(~A~).lisp" name)
    
    500
    +			     :if-does-not-exist nil :external-format :iso8859-1)))
    
    494 501
     	       (when s
    
    495 502
     		 (null (nth-value 1 (ext:compile-from-stream s))))))
    
    496 503
                (gethash name *external-formats*))))
    

  • src/code/save.lisp
    ... ... @@ -164,7 +164,35 @@
    164 164
     		 *default-external-format*))))
    
    165 165
       (values))
    
    166 166
     
    
    167
    - 
    
    167
    +(defun decode-runtime-strings (locale file-locale)
    
    168
    +  ;; The C runtime can initialize the following strings from the
    
    169
    +  ;; command line or the environment.  We need to decode these into
    
    170
    +  ;; the utf-16 strings that Lisp uses.
    
    171
    +  (setf lisp-command-line-list
    
    172
    +	(mapcar #'(lambda (s)
    
    173
    +		    (stream:string-decode s locale))
    
    174
    +		lisp-command-line-list))
    
    175
    +  (setf lisp-environment-list
    
    176
    +	(mapcar #'(lambda (s)
    
    177
    +		    (stream:string-decode s locale))
    
    178
    +		lisp-environment-list))
    
    179
    +  ;; This needs more work..  *cmucl-lib* could be set from the the envvar
    
    180
    +  ;; "CMUCLLIB" or from the "-lib" command-line option, and thus
    
    181
    +  ;; should use the LOCALE to decode the string.
    
    182
    +  (when *cmucl-lib*
    
    183
    +    (setf *cmucl-lib*
    
    184
    +	  (stream:string-decode *cmucl-lib* file-locale)))
    
    185
    +  ;; This also needs more work since the core path could come from the
    
    186
    +  ;; "-core" command-line option and should thus use LOCALE to decode
    
    187
    +  ;; the string.  It could also come from the "CMUCLCORE" envvar.
    
    188
    +  (setf *cmucl-core-path*
    
    189
    +	(stream:string-decode *cmucl-core-path* file-locale))
    
    190
    +  ;; *unidata-path* defaults to a pathname object, but the user can
    
    191
    +  ;; specify a path, so we need to decode the string path if given.
    
    192
    +  (when (and *unidata-path* (stringp *unidata-path*))
    
    193
    +    (setf *unidata-path*
    
    194
    +	  (stream:string-decode *unidata-path* file-locale))))
    
    195
    +
    
    168 196
     (defun save-lisp (core-file-name &key
    
    169 197
     				 (purify t)
    
    170 198
     				 (root-structures ())
    
    ... ... @@ -278,12 +306,18 @@
    278 306
     	     ;; Load external format aliases now so we can aliases to
    
    279 307
     	     ;; specify the external format.
    
    280 308
     	     (stream::load-external-format-aliases)
    
    281
    -	     ;; Set the locale for lisp
    
    282
    -	     (intl::setlocale)
    
    283 309
     	     ;; Set up :locale format
    
    284 310
     	     (set-up-locale-external-format)
    
    285
    -	     ;; Set terminal encodings to :locale
    
    286
    -	     (set-system-external-format :locale)
    
    311
    +	     ;; Set terminal encodings to :locale and filename encoding to :utf-8.
    
    312
    +	     ;; (This needs more work on Darwin.)
    
    313
    +	     (set-system-external-format :locale :utf-8)
    
    314
    +	     (decode-runtime-strings :locale :utf-8)
    
    315
    +	     ;; Need to reinitialize the environment again because
    
    316
    +	     ;; we've possibly changed the environment variables and
    
    317
    +	     ;; pathnames.
    
    318
    +	     (environment-init)
    
    319
    +	     ;; Set the locale for lisp
    
    320
    +	     (intl::setlocale)
    
    287 321
     	     (ext::process-command-strings process-command-line)
    
    288 322
     	     (setf *editor-lisp-p* nil)
    
    289 323
     	     (macrolet ((find-switch (name)
    

  • src/code/unix.lisp
    ... ... @@ -25,7 +25,12 @@
    25 25
     ;; it must be set to :iso8859-1 (or left as NIL), making files with
    
    26 26
     ;; non-Latin-1 characters "mojibake", but otherwise they'll be inaccessible.
    
    27 27
     ;; Must be set to NIL initially to enable building Lisp!
    
    28
    -(defvar *filename-encoding* nil)
    
    28
    +(defvar *filename-encoding* nil
    
    29
    +  "The encoding to use for converting a namestring to a string that can
    
    30
    +  be used by the operations system.  It must be a valid
    
    31
    +  external-format name or NIL.  NIL means the string is passed as is
    
    32
    +  to the operating system.  The operating system will get the low 8
    
    33
    +  bits of each UTF-16 code unit of the string.")
    
    29 34
     
    
    30 35
     (eval-when (:compile-toplevel :load-toplevel :execute)
    
    31 36
       (defmacro %name->file (string)
    

  • tests/issues.lisp
    ... ... @@ -258,6 +258,13 @@
    258 258
     	(assert-equal (map 'list #'char-code out-string)
    
    259 259
     		      (map 'list #'char-code expected))))))
    
    260 260
     
    
    261
    +(define-test issue.25c-setup
    
    262
    +    (:tag :issues)
    
    263
    +  ;; Get the external format before running the test issue.25c.  See
    
    264
    +  ;; issue #161
    
    265
    +  ;; (https://gitlab.common-lisp.net/cmucl/cmucl/-/issues/161).
    
    266
    +  (assert-true (stream::find-external-format :utf16-be)))
    
    267
    +
    
    261 268
     (define-test issue.25c
    
    262 269
         (:tag :issues)
    
    263 270
       ;; Modified test to verify that each octet read from run-program is
    
    ... ... @@ -682,10 +689,7 @@
    682 689
       ;; work and not return NIL.
    
    683 690
       (assert-true (file-author "."))
    
    684 691
       (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
    
    692
    +  (assert-true
    
    689 693
        (file-author
    
    690 694
         (merge-pathnames 
    
    691 695
          (concatenate 'string
    
    ... ... @@ -696,7 +700,7 @@
    696 700
     		  '(#\Hangul_Syllable_An #\Hangul_Syllable_Nyeong #\Hangul_Syllable_Ha
    
    697 701
     		    #\Hangul_Syllable_Sib #\Hangul_Syllable_Ni #\Hangul_Syllable_Gga)
    
    698 702
     		  ".txt")
    
    699
    -     *test-path*)))))
    
    703
    +     *test-path*))))
    
    700 704
     
    
    701 705
     (define-test issue.139-default-external-format
    
    702 706
         (:tag :issues)