]> granicus.if.org Git - clang/commitdiff
[Driver] Fix recognizing newer OpenSUSE versions
authorMichal Gorny <mgorny@gentoo.org>
Mon, 28 Nov 2016 21:11:18 +0000 (21:11 +0000)
committerMichal Gorny <mgorny@gentoo.org>
Mon, 28 Nov 2016 21:11:18 +0000 (21:11 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@288061 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Distro.cpp

index 7a12643405de5b3c6f42217f02cd042f926d3609..d305b179449f284b672b42e05c1bb17f8d9a88f5 100644 (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;
     }