erichkeane created this revision.

The config-*triple* file handling isn't tolerant of leading/trailing 
whitespace, making it not terribly obvious when a single extraneous 
tab/space/etc will cause the override to be ignored.  This patch simply trims 
the lines to ensure that it is tolerant of whitespace.


https://reviews.llvm.org/D31996

Files:
  lib/Driver/ToolChains/Gnu.cpp


Index: lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2173,10 +2173,11 @@
     SmallVector<StringRef, 2> Lines;
     File.get()->getBuffer().split(Lines, "\n");
     for (StringRef Line : Lines) {
+      StringRef TrimLine = Line.trim();
       // CURRENT=triple-version
-      if (Line.consume_front("CURRENT=")) {
+      if (TrimLine.consume_front("CURRENT=")) {
         const std::pair<StringRef, StringRef> ActiveVersion =
-          Line.rsplit('-');
+          TrimLine.rsplit('-');
         // Note: Strictly speaking, we should be reading
         // /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
         // contain anything new or especially useful to us.


Index: lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2173,10 +2173,11 @@
     SmallVector<StringRef, 2> Lines;
     File.get()->getBuffer().split(Lines, "\n");
     for (StringRef Line : Lines) {
+      StringRef TrimLine = Line.trim();
       // CURRENT=triple-version
-      if (Line.consume_front("CURRENT=")) {
+      if (TrimLine.consume_front("CURRENT=")) {
         const std::pair<StringRef, StringRef> ActiveVersion =
-          Line.rsplit('-');
+          TrimLine.rsplit('-');
         // Note: Strictly speaking, we should be reading
         // /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
         // contain anything new or especially useful to us.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to