summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix/Program.inc
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-06-10 03:16:25 +0000
committerZachary Turner <zturner@google.com>2018-06-10 03:16:25 +0000
commit071a09053ad2e5cc6e7f9fcace738193528c07b5 (patch)
tree5d6cbdcca6b42edd6c6d31289e6a545fa760b854 /llvm/lib/Support/Unix/Program.inc
parent5e119768a1ecf9d6f8ad5b38de7497cc334b69d9 (diff)
downloadbcm5719-llvm-071a09053ad2e5cc6e7f9fcace738193528c07b5.tar.gz
bcm5719-llvm-071a09053ad2e5cc6e7f9fcace738193528c07b5.zip
Revert "Resubmit "[Support] Expose flattenWindowsCommandLine.""
This reverts commit 65243b6d19143cb7a03f68df0169dcb63e8b4632. Seems like it's not a flake. It might have something to do with the '*' character being in a command line. llvm-svn: 334356
Diffstat (limited to 'llvm/lib/Support/Unix/Program.inc')
-rw-r--r--llvm/lib/Support/Unix/Program.inc10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index be971555b82..04840bf4448 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -434,7 +434,7 @@ llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
}
bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program,
- ArrayRef<StringRef> Args) {
+ ArrayRef<const char *> Args) {
static long ArgMax = sysconf(_SC_ARG_MAX);
// POSIX requires that _POSIX_ARG_MAX is 4096, which is the lowest possible
// value for ARG_MAX on a POSIX compliant system.
@@ -456,16 +456,18 @@ bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program,
long HalfArgMax = EffectiveArgMax / 2;
size_t ArgLength = Program.size() + 1;
- for (StringRef Arg : Args) {
+ for (const char* Arg : Args) {
+ size_t length = strlen(Arg);
+
// Ensure that we do not exceed the MAX_ARG_STRLEN constant on Linux, which
// does not have a constant unlike what the man pages would have you
// believe. Since this limit is pretty high, perform the check
// unconditionally rather than trying to be aggressive and limiting it to
// Linux only.
- if (Arg.size() >= (32 * 4096))
+ if (length >= (32 * 4096))
return false;
- ArgLength += Arg.size() + 1;
+ ArgLength += length + 1;
if (ArgLength > size_t(HalfArgMax)) {
return false;
}
OpenPOWER on IntegriCloud