diff --git a/interface/wx/utils.h b/interface/wx/utils.h index 373ea8e090..f5a3b424c2 100644 --- a/interface/wx/utils.h +++ b/interface/wx/utils.h @@ -851,9 +851,10 @@ wxString wxGetOsDescription(); On systems where only the micro version can't be detected or doesn't make sense such as Windows, it will have a value of 0. - For Unix-like systems (@c wxOS_UNIX) the major and minor version integers will - contain the kernel major and minor version numbers (as returned by the - 'uname -r' command); e.g. "4" and "1" if the machine is using kernel 4.1.4. + For Unix-like systems (@c wxOS_UNIX) the major, minor, and micro version + integers will contain the kernel's major, minor, and micro version + numbers (as returned by the 'uname -r' command); e.g. "4", "1", and "4" if + the machine is using kernel 4.1.4. For OS X systems (@c wxOS_MAC) the major and minor version integers are the natural version numbers associated with the OS; e.g. "10", "11" and "2" if diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index fdde571959..88ae40c66a 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -1117,14 +1117,19 @@ wxLinuxDistributionInfo wxGetLinuxDistributionInfo() wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro) { // get OS version - int major, minor; + int major = -1, minor = -1, micro = -1; wxString release = wxGetCommandOutput(wxT("uname -r")); - if ( release.empty() || - wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor) != 2 ) + if ( !release.empty() ) { - // failed to get version string or unrecognized format - major = - minor = -1; + if ( wxSscanf(release.c_str(), wxT("%d.%d.%d"), &major, &minor, µ ) != 3 ) + { + micro = 0; + if ( wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor ) != 2 ) + { + // failed to get version string or unrecognized format + major = minor = micro = -1; + } + } } if ( verMaj ) @@ -1132,7 +1137,7 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro) if ( verMin ) *verMin = minor; if ( verMicro ) - *verMicro = (major == -1) ? -1 : 0; + *verMicro = micro; // try to understand which OS are we running wxString kernel = wxGetCommandOutput(wxT("uname -s"));