[PATCH] D13046: [mach-o] Support Windows line endings for -filelist parameter.

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 22:59:48 PDT 2015


ikudrin created this revision.
ikudrin added a subscriber: llvm-commits.
ikudrin added a project: lld.

On Windows, text files have "\r\n" line ensings, so the trailing '\r' should be removed after splitting an input file by '\n'.

http://reviews.llvm.org/D13046

Files:
  lld/trunk/lib/Driver/DarwinLdDriver.cpp

Index: lld/trunk/lib/Driver/DarwinLdDriver.cpp
===================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp
@@ -232,7 +232,8 @@
   while (!buffer.empty()) {
     // Split off each line in the file.
     std::pair<StringRef, StringRef> lineAndRest = buffer.split('\n');
-    StringRef line = lineAndRest.first;
+    // On Windows, line endings can be "\r\n", not just "\n".
+    StringRef line = lineAndRest.first.rtrim("\r");
     StringRef path;
     if (!dirName.empty()) {
       // If there is a <dir> then prepend dir to each line.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13046.35345.patch
Type: text/x-patch
Size: 632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150922/3ec3a960/attachment.bin>


More information about the llvm-commits mailing list