[PATCH] D13536: Fixed sys::findProgramByName (Windows) to accept files with point in name

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 03:32:00 PDT 2015


grimar updated this revision to Diff 36841.
grimar added a comment.

Removed branch (review comment addressed).


http://reviews.llvm.org/D13536

Files:
  Program.inc

Index: Program.inc
===================================================================
--- Program.inc
+++ Program.inc
@@ -75,8 +75,15 @@
 
     do {
       U16Result.reserve(Len);
-      Len = ::SearchPathW(Path, c_str(U16Name),
-                          U16Ext.empty() ? nullptr : c_str(U16Ext),
+      // Lets attach the extension manually. That is needed for files
+      // with a point in name like aaa.bbb. SearchPathW will not add extension
+      // from its argument to such files because it thinks they already had one.
+      SmallVector<wchar_t, MAX_PATH> U16NameExt;
+      if (std::error_code EC =
+              windows::UTF8ToUTF16(Twine(Name + Ext).str(), U16NameExt))
+        return EC;
+
+      Len = ::SearchPathW(Path, c_str(U16NameExt), nullptr,
                           U16Result.capacity(), U16Result.data(), nullptr);
     } while (Len > U16Result.capacity());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13536.36841.patch
Type: text/x-patch
Size: 893 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151008/0eb444cf/attachment.bin>


More information about the llvm-commits mailing list