Detect micro version for Unix-like systems in wxGetOsVersion

Check the result of running uname -r for a micro version and use it if
available, otherwise return a micro version of 0.
This commit is contained in:
Dimitri Schoolwerth
2015-06-24 06:45:56 +04:00
committed by Tobias Taschner
parent b1a9c6e79e
commit 427750e744
2 changed files with 16 additions and 10 deletions

View File

@@ -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, &micro ) != 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"));