[Libreoffice-commits] core.git: vcl/unx

Gleb Popov (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 23 00:10:01 UTC 2020


 vcl/unx/generic/app/geninst.cxx |   24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

New commits:
commit b883dd8a32b1b58910272ec4791aeb241914932e
Author:     Gleb Popov <6yearold at gmail.com>
AuthorDate: Thu Oct 22 19:33:41 2020 +0400
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri Oct 23 02:09:17 2020 +0200

    Implement SalGenericInstance::getOSVersion() for FreeBSD.
    
    Change-Id: I01f565bdfc3c46a94485a62cd0f249ce2002fe21
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104689
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Jenkins

diff --git a/vcl/unx/generic/app/geninst.cxx b/vcl/unx/generic/app/geninst.cxx
index b6611631b50d..c385ab57d587 100644
--- a/vcl/unx/generic/app/geninst.cxx
+++ b/vcl/unx/generic/app/geninst.cxx
@@ -22,6 +22,9 @@
 #if defined(LINUX)
 #  include <stdio.h>
 #endif
+#if defined(__FreeBSD__)
+#  include <sys/utsname.h>
+#endif
 
 #include <config_features.h>
 #if HAVE_FEATURE_OPENGL
@@ -50,7 +53,6 @@ OUString SalGenericInstance::getOSVersion()
 {
     OUString aKernelVer = "unknown";
 
-// not so generic, but at least shared between all unix backend
 #if defined(LINUX)
     FILE* pVersion = fopen( "/proc/version", "r" );
     if ( pVersion )
@@ -70,8 +72,26 @@ OUString SalGenericInstance::getOSVersion()
         }
         fclose( pVersion );
     }
-#endif
     return aKernelVer;
+#elif defined(__FreeBSD__)
+    struct utsname stName;
+    if ( uname( &stName ) != 0 )
+        return aKernelVer;
+
+    sal_Int32 nDots = 0;
+    sal_Int32 nIndex = 0;
+    aKernelVer = OUString::createFromAscii( stName.release );
+    while ( nIndex++ < aKernelVer.getLength() )
+    {
+        const char c = stName.release[ nIndex ];
+        if ( c == ' ' || c == '-' || ( c == '.' && nDots++ > 0 ) )
+            break;
+    }
+    return OUString::createFromAscii( stName.sysname ) + " " +
+        aKernelVer.copy( 0, nIndex );
+#else
+    return aKernelVer;
+#endif
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list