Raymond Toy pushed to branch issue-120-software-type-in-c at cmucl / cmucl

Commits:

4 changed files:

Changes:

  • src/code/misc.lisp
    ... ... @@ -199,9 +199,7 @@
    199 199
     			  (alien:extern-alien "os_software_type"
    
    200 200
     					      (function (alien:* c-call:c-string)))))
    
    201 201
     		   (unless (zerop (sap-int (alien:alien-sap software-type)))
    
    202
    -		     (alien:cast software-type c-call:c-string)))
    
    203
    -	      (when software-type
    
    204
    -		(alien:free-alien software-type))))))
    
    202
    +		     (alien:cast software-type c-call:c-string)))))))
    
    205 203
       *software-type*)
    
    206 204
     
    
    207 205
     (defvar *software-version* nil
    
    ... ... @@ -219,9 +217,7 @@
    219 217
     			  (alien:extern-alien "os_software_version"
    
    220 218
     					      (function (alien:* c-call:c-string)))))
    
    221 219
     		   (unless (zerop (sap-int (alien:alien-sap version)))
    
    222
    -		     (alien:cast version c-call:c-string)))
    
    223
    -	      (when version
    
    224
    -		(alien:free-alien version)))))
    
    220
    +		     (alien:cast version c-call:c-string))))))
    
    225 221
         *software-version*))
    
    226 222
     
    
    227 223
     (defvar *short-site-name* (intl:gettext "Unknown")
    

  • src/i18n/locale/cmucl-linux-os.pot
    ... ... @@ -15,10 +15,6 @@ msgstr ""
    15 15
     "Content-Type: text/plain; charset=UTF-8\n"
    
    16 16
     "Content-Transfer-Encoding: 8bit\n"
    
    17 17
     
    
    18
    -#: src/code/linux-os.lisp
    
    19
    -msgid "Returns a string describing version of the supporting software."
    
    20
    -msgstr ""
    
    21
    -
    
    22 18
     #: src/code/linux-os.lisp
    
    23 19
     msgid "Unix system call getrusage failed: ~A."
    
    24 20
     msgstr ""
    

  • src/i18n/locale/cmucl.pot
    ... ... @@ -5605,14 +5605,14 @@ msgid ""
    5605 5605
     "  NIL if no such character exists."
    
    5606 5606
     msgstr ""
    
    5607 5607
     
    
    5608
    -#: src/code/misc.lisp
    
    5608
    +#: src/code/misc-doc.lisp src/code/misc.lisp
    
    5609 5609
     msgid ""
    
    5610 5610
     "Returns the documentation string of Doc-Type for X, or NIL if\n"
    
    5611 5611
     "  none exists.  System doc-types are VARIABLE, FUNCTION, STRUCTURE, TYPE,\n"
    
    5612 5612
     "  SETF, and T."
    
    5613 5613
     msgstr ""
    
    5614 5614
     
    
    5615
    -#: src/code/misc.lisp
    
    5615
    +#: src/code/misc-doc.lisp src/code/misc.lisp
    
    5616 5616
     msgid "~S is not the name of a structure type."
    
    5617 5617
     msgstr ""
    
    5618 5618
     
    
    ... ... @@ -5643,13 +5643,21 @@ msgid "Returns a string giving the name of the local machine."
    5643 5643
     msgstr ""
    
    5644 5644
     
    
    5645 5645
     #: src/code/misc.lisp
    
    5646
    -msgid "The value of SOFTWARE-TYPE.  Set in FOO-os.lisp."
    
    5646
    +msgid "The value of SOFTWARE-TYPE."
    
    5647 5647
     msgstr ""
    
    5648 5648
     
    
    5649 5649
     #: src/code/misc.lisp
    
    5650 5650
     msgid "Returns a string describing the supporting software."
    
    5651 5651
     msgstr ""
    
    5652 5652
     
    
    5653
    +#: src/code/misc.lisp
    
    5654
    +msgid "Version string for supporting software"
    
    5655
    +msgstr ""
    
    5656
    +
    
    5657
    +#: src/code/misc.lisp
    
    5658
    +msgid "Returns a string describing version of the supporting software."
    
    5659
    +msgstr ""
    
    5660
    +
    
    5653 5661
     #: src/code/misc.lisp
    
    5654 5662
     msgid "The value of SHORT-SITE-NAME.  Set in library:site-init.lisp."
    
    5655 5663
     msgstr ""
    

  • src/lisp/os-common.c
    ... ... @@ -817,43 +817,47 @@ os_get_locale_codeset()
    817 817
     #endif 
    
    818 818
     
    
    819 819
     char*
    
    820
    -os_software_version()
    
    820
    +os_software_version(void)
    
    821 821
     {
    
    822
    -    int status;
    
    823 822
         struct utsname uts;
    
    824
    -    char *version = NULL;
    
    823
    +    /*
    
    824
    +     * Buffer large enough to hold the release and version that's used
    
    825
    +     * for Linux and Solaris.
    
    826
    +     */
    
    827
    +    static char result[sizeof(uts.release) + sizeof(uts.version)]; 
    
    828
    +
    
    829
    +    int status;
    
    825 830
     
    
    826 831
         status = uname(&uts);
    
    827
    -    if (status == 0) {
    
    828
    -        int version_length;
    
    832
    +    if (status != 0) {
    
    833
    +        return NULL;
    
    834
    +    }
    
    835
    +    
    
    829 836
     #if defined(UNAME_RELEASE_AND_VERSION)
    
    830
    -        version_length = strlen(uts.release) + strlen(uts.version) + 2;
    
    831
    -        version = malloc(version_length);
    
    832
    -        if (version) {
    
    833
    -            strcpy(version, uts.release);
    
    834
    -            strcat(version, " ");
    
    835
    -            strcat(version, uts.version);
    
    836
    -        }
    
    837
    +    strcpy(result, uts.release);
    
    838
    +    strcat(result, " ");
    
    839
    +    strcat(result, uts.version);
    
    837 840
     #else
    
    838
    -        version = strdup(uts.version);
    
    841
    +    strcpy(result, uts.version);
    
    839 842
     #endif
    
    840
    -    }
    
    841 843
     
    
    842
    -    return version;
    
    844
    +    return result;
    
    843 845
     }
    
    844 846
     #undef UNAME_RELEASE_AND_VERSION
    
    845 847
     
    
    846 848
     char*
    
    847
    -os_software_type()
    
    849
    +os_software_type(void)
    
    848 850
     {
    
    849 851
         int status;
    
    850 852
         struct utsname uts;
    
    851
    -    char *os_name = NULL;
    
    853
    +    static char os_name[sizeof(uts.sysname)];
    
    852 854
         
    
    853 855
         status = uname(&uts);
    
    854
    -    if (status == 0) {
    
    855
    -        os_name = strdup(uts.sysname);
    
    856
    +    if (status != 0) {
    
    857
    +        return NULL;
    
    856 858
         }
    
    859
    +    
    
    860
    +    strcpy(os_name, uts.sysname);
    
    857 861
     
    
    858 862
         return os_name;
    
    859 863
     }