Raymond Toy pushed to branch master at cmucl / cmucl

Commits:

5 changed files:

Changes:

  • src/code/intl.lisp
    ... ... @@ -520,10 +520,7 @@
    520 520
     
    
    521 521
     (defun setlocale (&optional locale)
    
    522 522
       (setf *locale* (or locale
    
    523
    -		     (getenv "LANGUAGE")
    
    524
    -		     (getenv "LC_ALL")
    
    525
    -		     (getenv "LC_MESSAGES")
    
    526
    -		     (getenv "LANG")
    
    523
    +		     (unix::unix-get-lc-messages)
    
    527 524
     		     *locale*)))
    
    528 525
     
    
    529 526
     (defmacro textdomain (domain)
    

  • src/code/unix.lisp
    ... ... @@ -2899,3 +2899,19 @@
    2899 2899
       (alien:alien-funcall
    
    2900 2900
        (alien:extern-alien "os_setlocale"
    
    2901 2901
     		       (function c-call:int))))
    
    2902
    +
    
    2903
    +(defun unix-get-lc-messages ()
    
    2904
    +  _N"Get LC_MESSAGES from the current locale.  If we can't, return
    
    2905
    +  NIL.  A call to UNIX-SETLOCALE must have been done previously before
    
    2906
    +  calling this so that the correct locale is returned."
    
    2907
    +  (with-alien ((buf (array c-call:char 256)))
    
    2908
    +    (let ((result
    
    2909
    +	    (alien-funcall
    
    2910
    +	     (extern-alien "os_get_lc_messages"
    
    2911
    +			   (function c-call:int
    
    2912
    +				     (* c-call:char)
    
    2913
    +				     c-call:int))
    
    2914
    +	     (cast buf (* c-call:char))
    
    2915
    +	     256)))
    
    2916
    +      (when (zerop result)
    
    2917
    +	(cast buf c-call:c-string)))))

  • src/general-info/release-21e.md
    ... ... @@ -60,6 +60,7 @@ public domain.
    60 60
         * ~~#134~~ Handle the case of `(expt complex complex-rational)`
    
    61 61
         * ~~#136~~ `ensure-directories-exist` should return the given pathspec
    
    62 62
         * #139 `*default-external-format*` defaults to `:utf-8`
    
    63
    +    * ~~#141~~ Disallow locales that are pathnames to a localedef file
    
    63 64
         * ~~#142~~ `(random 0)` signals incorrect error
    
    64 65
         * ~~#147~~ `stream-line-column` method missing for `fundamental-character-output-stream`
    
    65 66
         * ~~#149~~ Call setlocale(3C) on startup
    

  • src/i18n/locale/cmucl-unix.pot
    ... ... @@ -1428,3 +1428,10 @@ msgstr ""
    1428 1428
     msgid "Call setlocale(3c) with fixed args.  Returns 0 on success."
    
    1429 1429
     msgstr ""
    
    1430 1430
     
    
    1431
    +#: src/code/unix.lisp
    
    1432
    +msgid ""
    
    1433
    +"Get LC_MESSAGES from the current locale.  If we can't, return\n"
    
    1434
    +"  NIL.  A call to UNIX-SETLOCALE must have been done previously before\n"
    
    1435
    +"  calling this so that the correct locale is returned."
    
    1436
    +msgstr ""
    
    1437
    +

  • src/lisp/os-common.c
    ... ... @@ -783,3 +783,16 @@ os_setlocale(void)
    783 783
         /* Return 0 if setlocale suceeded; otherwise -1. */
    
    784 784
         return result != NULL ? 0 : -1;
    
    785 785
     }
    
    786
    +
    
    787
    +int
    
    788
    +os_get_lc_messages(char *buf, int len)
    
    789
    +{
    
    790
    +    char *locale = setlocale(LC_MESSAGES, NULL);
    
    791
    +    if (locale) {
    
    792
    +        strncpy(buf, locale, len - 1);
    
    793
    +        buf[len - 1] = '\0';
    
    794
    +    }
    
    795
    +
    
    796
    +    /* Return -1 if setlocale failed. */
    
    797
    +    return locale ? 0 : -1;
    
    798
    +}