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:
committed by
Tobias Taschner
parent
b1a9c6e79e
commit
427750e744
@@ -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"));
|
||||
|
Reference in New Issue
Block a user