[cfe-commits] r99053 - /cfe/trunk/lib/Driver/Compilation.cpp
Daniel Dunbar
daniel at zuster.org
Sat Mar 20 01:01:53 PDT 2010
Author: ddunbar
Date: Sat Mar 20 03:01:53 2010
New Revision: 99053
URL: http://llvm.org/viewvc/llvm-project?rev=99053&view=rev
Log:
Driver: Fix -### to quote shell special characters, following gcc.
Modified:
cfe/trunk/lib/Driver/Compilation.cpp
Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=99053&r1=99052&r2=99053&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Sat Mar 20 03:01:53 2010
@@ -61,10 +61,21 @@
OS << " \"" << C->getExecutable() << '"';
for (ArgStringList::const_iterator it = C->getArguments().begin(),
ie = C->getArguments().end(); it != ie; ++it) {
- if (Quote)
- OS << " \"" << *it << '"';
- else
- OS << ' ' << *it;
+ OS << ' ';
+ if (!Quote) {
+ OS << *it;
+ continue;
+ }
+
+ // Quote the argument and escape shell special characters; this isn't
+ // really complete but is good enough.
+ OS << '"';
+ for (const char *s = *it; *s; ++s) {
+ if (*s == '"' || *s == '\\' || *s == '$')
+ OS << '\\';
+ OS << *s;
+ }
+ OS << '"';
}
OS << Terminator;
} else if (const PipedJob *PJ = dyn_cast<PipedJob>(&J)) {
More information about the cfe-commits
mailing list