[cfe-dev] Broken "not" and platform file paths
John Thompson
john.thompson.jtsoftware at gmail.com
Tue Mar 29 11:59:07 PDT 2011
Hi,
How about this::
Index: lib/Support/Windows/Program.inc
===================================================================
--- lib/Support/Windows/Program.inc (revision 128469)
+++ lib/Support/Windows/Program.inc (working copy)
@@ -163,7 +163,11 @@
Data_ = 0;
}
- if (!path.canExecute()) {
+ Path platformPath(path);
+ if (strstr(platformPath.c_str(), ".exe") == NULL)
+ platformPath.appendSuffix("exe");
+
+ if (!platformPath.canExecute()) {
if (ErrMsg)
*ErrMsg = "program not executable";
return false;
@@ -276,7 +280,7 @@
fflush(stdout);
fflush(stderr);
- BOOL rc = CreateProcess(path.c_str(), command, NULL, NULL, TRUE, 0,
+ BOOL rc = CreateProcess(platformPath.c_str(), command, NULL, NULL, TRUE,
0,
envblock, NULL, &si, &pi);
DWORD err = GetLastError();
@@ -290,7 +294,7 @@
if (!rc) {
SetLastError(err);
MakeErrMsg(ErrMsg, std::string("Couldn't execute program '") +
- path.str() + "'");
+ platformPath.str() + "'");
return false;
}
Win32ProcessInfo* wpi = new Win32ProcessInfo;
Apparently, FindProgramByName doesn't need a file extension, as the
underlying SearchPath call doesn't need it.
-John
On Sun, Mar 27, 2011 at 10:47 PM, NAKAMURA Takumi <geek4civic at gmail.com>wrote:
> John,
>
> On Thu, Mar 17, 2011 at 3:40 AM, John Thompson
> <john.thompson.jtsoftware at gmail.com> wrote:
> > Index: utils/not/not.cpp
> > ===================================================================
> > --- utils/not/not.cpp (revision 127522)
> > +++ utils/not/not.cpp (working copy)
> > @@ -15,6 +15,11 @@
> > int main(int argc, const char **argv) {
> > sys::Path Program = sys::Program::FindProgramByName(argv[1]);
> >
> > +#if defined(_MSC_VER)
> > + if (strstr(Program.c_str(), ".exe") == NULL)
> > + Program.appendSuffix("exe");
> > +#endif
> > +
> > std::string ErrMsg;
> > int Result = sys::Program::ExecuteAndWait(Program, argv + 1, 0, 0, 0,
> 0,
> > &ErrMsg);
>
> I don't think it would be a right fix.
>
> - sys::Program::FindProgramByName() should canonicalize a pathname
> - sys::Program::ExecuteAndWait() should accept "x:/path/to/foo"
> (without .exe).
>
> Even if this patch were the right fix, I don't understand why this is
> MSC-specific. It might be _WIN32 not _MSC_VER.
>
> ...Takumi
>
--
John Thompson
John.Thompson.JTSoftware at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110329/0eccfe71/attachment.html>
More information about the cfe-dev
mailing list