[llvm-commits] [PATCH] FileCheck.cpp: made match regex '$' for DOSish \r\n

NAKAMURA Takumi geek4civic at gmail.com
Sun Oct 3 23:59:01 PDT 2010


Some tests have CHECK: {{foobar$}} to cause mismatch failure on mingw.

I took the way to eliminate \r on MemoryBuffer.
Is there any better way?

...Takumi
-------------- next part --------------
diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp
index cd76d44..2077e09 100644
--- a/utils/FileCheck/FileCheck.cpp
+++ b/utils/FileCheck/FileCheck.cpp
@@ -446,6 +446,11 @@ static MemoryBuffer *CanonicalizeInputFile(MemoryBuffer *MB) {
 
   for (const char *Ptr = MB->getBufferStart(), *End = MB->getBufferEnd();
        Ptr != End; ++Ptr) {
+    // Eliminate trailing dosish \r.
+    if (Ptr <= End - 2 && Ptr[0] == '\r' && Ptr[1] == '\n') {
+      continue;
+    }
+
     // If C is not a horizontal whitespace, skip it.
     if (*Ptr != ' ' && *Ptr != '\t') {
       NewFile.push_back(*Ptr);


More information about the llvm-commits mailing list