diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-04-29 09:01:46 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-29 09:01:46 -0400 |
| commit | 972bd3c4c24b06501c52127416afb763a066b8ad (patch) | |
| tree | e3874d4952ac557d5c323bb1e43be4584c100afc /source/core/unix | |
| parent | 541d1cab81d895c406fc33cb476e37ce8a6a9702 (diff) | |
Support for escaped paths in tools (#1823)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Split out StringEscapeUtil.
* Added StringEscapeUtil.
* Fix typo in unix quoting type.
* Small comment improvements.
* Try to fix linux linking issue.
* Fix typo.
* Attempt to fix linux link issue.
* Update VS proj even though nothing really changed.
* Fix another typo issue.
* Fix for windows issue.
Fixed bug.
* Make separate Utils for escaping.
* Fix typo.
* Split out into StringEscapeHandler.
* Windows shell does handle removing quotes (so remove code to remove them).
* Handle unescaping if not initiating using the shell.
* Slight improvement around shell like decoding.
* Simplify command extraction.
* Add shared-library category type.
* Fix bug in command extraction.
* Typo in transcendental category.
* Enable unit-test on in smoke test category.
* Make parsing failing output as a failing test.
* Fixes for transcendental tests. Disable tests that do not work.
* Changed category parsing.
* Removed the TestResult parameter from _gatherTestsForFile.
Made testsList only output.
* Remove testing if all tests were disabled.
* Fix typo.
* Disable path canonical test on linux because CI issue.
Diffstat (limited to 'source/core/unix')
| -rw-r--r-- | source/core/unix/slang-unix-process-util.cpp | 41 |
1 files changed, 7 insertions, 34 deletions
diff --git a/source/core/unix/slang-unix-process-util.cpp b/source/core/unix/slang-unix-process-util.cpp index 3f052b09d..a3b66af38 100644 --- a/source/core/unix/slang-unix-process-util.cpp +++ b/source/core/unix/slang-unix-process-util.cpp @@ -3,6 +3,7 @@ #include "../slang-common.h" #include "../slang-string-util.h" +#include "../slang-string-escape-util.h" #include <stdio.h> #include <stdlib.h> @@ -29,52 +30,25 @@ namespace Slang { #endif } -/* static */void ProcessUtil::appendCommandLineEscaped(const UnownedStringSlice& slice, StringBuilder& out) +/* static */StringEscapeHandler* ProcessUtil::getEscapeHandler() { - // TODO(JS): This escaping is not complete... ! - if (slice.indexOf(' ') >= 0 || slice.indexOf('"') >= 0) - { - out << "\""; - - const char* cur = slice.begin(); - const char* end = slice.end(); - - while (cur < end) - { - char c = *cur++; - switch (c) - { - case '\"': - { - // Escape quotes. - out << "\\\""; - break; - } - default: - out.append(c); - } - } - - out << "\""; - - return; - } - - out << slice; + return StringEscapeUtil::getHandler(StringEscapeUtil::Style::Space); } /* static */String ProcessUtil::getCommandLineString(const CommandLine& commandLine) { + auto escapeHandler = getEscapeHandler(); + // When outputting the command line we potentially need to escape the path to the // command and args - that aren't already explicitly marked as escaped. StringBuilder cmd; - appendCommandLineEscaped(commandLine.m_executable.getUnownedSlice(), cmd); + StringEscapeUtil::appendMaybeQuoted(escapeHandler, commandLine.m_executable.getUnownedSlice(), cmd); for (const auto& arg : commandLine.m_args) { cmd << " "; if (arg.type == CommandLine::ArgType::Unescaped) { - appendCommandLineEscaped(arg.value.getUnownedSlice(), cmd); + StringEscapeUtil::appendMaybeQuoted(escapeHandler, arg.value.getUnownedSlice(), cmd); } else { @@ -260,7 +234,6 @@ namespace Slang { return SLANG_FAIL; } - /* static */uint64_t ProcessUtil::getClockFrequency() { return 1000000000; |
