[Driver] Fix recognizing newer OpenSUSE versions

Fix recognizing newer OpenSUSE versions that combine the two version
components into 'VERSION = x.y'. The check was written against an older
version that kept those two split as VERSION and PATCHLEVEL.

Differential Revision: https://reviews.llvm.org/D26850

llvm-svn: 288061
This commit is contained in:
Michal Gorny 2016-11-28 21:11:18 +00:00
parent 67e199eb32
commit 047e099a2e
1 changed files with 5 additions and 2 deletions

View File

@ -108,11 +108,14 @@ static Distro::DistroType DetectDistro(vfs::FileSystem &VFS) {
if (!Line.trim().startswith("VERSION"))
continue;
std::pair<StringRef, StringRef> SplitLine = Line.split('=');
// Old versions have split VERSION and PATCHLEVEL
// Newer versions use VERSION = x.y
std::pair<StringRef, StringRef> SplitVer = SplitLine.second.trim().split('.');
int Version;
// OpenSUSE/SLES 10 and older are not supported and not compatible
// with our rules, so just treat them as Distro::UnknownDistro.
if (!SplitLine.second.trim().getAsInteger(10, Version) &&
Version > 10)
if (!SplitVer.first.getAsInteger(10, Version) && Version > 10)
return Distro::OpenSUSE;
return Distro::UnknownDistro;
}