diff options
Diffstat (limited to 'source/Utility/Args.cpp')
-rw-r--r-- | source/Utility/Args.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/source/Utility/Args.cpp b/source/Utility/Args.cpp index 3b5cf1715fb3..77b0d43254a1 100644 --- a/source/Utility/Args.cpp +++ b/source/Utility/Args.cpp @@ -1,9 +1,8 @@ //===-- Args.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -96,7 +95,7 @@ ParseSingleArgument(llvm::StringRef command) { bool arg_complete = false; do { // Skip over over regular characters and append them. - size_t regular = command.find_first_of(" \t\"'`\\"); + size_t regular = command.find_first_of(" \t\r\"'`\\"); arg += command.substr(0, regular); command = command.substr(regular); @@ -124,6 +123,7 @@ ParseSingleArgument(llvm::StringRef command) { case ' ': case '\t': + case '\r': // We are not inside any quotes, we just found a space after an argument. // We are done. arg_complete = true; @@ -166,9 +166,7 @@ Args::ArgEntry::ArgEntry(llvm::StringRef str, char quote) : quote(quote) { ref = llvm::StringRef(c_str(), size); } -//---------------------------------------------------------------------- // Args constructor -//---------------------------------------------------------------------- Args::Args(llvm::StringRef command) { SetCommandString(command); } Args::Args(const Args &rhs) { *this = rhs; } @@ -191,9 +189,7 @@ Args &Args::operator=(const Args &rhs) { return *this; } -//---------------------------------------------------------------------- // Destructor -//---------------------------------------------------------------------- Args::~Args() {} void Args::Dump(Stream &s, const char *label_name) const { @@ -546,7 +542,7 @@ void Args::EncodeEscapeSequences(const char *src, std::string &dst) { p += i - 1; unsigned long octal_value = ::strtoul(oct_str, nullptr, 8); if (octal_value <= UINT8_MAX) { - dst.append(1, (char)octal_value); + dst.append(1, static_cast<char>(octal_value)); } } break; @@ -566,7 +562,7 @@ void Args::EncodeEscapeSequences(const char *src, std::string &dst) { unsigned long hex_value = strtoul(hex_str, nullptr, 16); if (hex_value <= UINT8_MAX) - dst.append(1, (char)hex_value); + dst.append(1, static_cast<char>(hex_value)); } else { dst.append(1, 'x'); } @@ -641,14 +637,15 @@ std::string Args::EscapeLLDBCommandArgument(const std::string &arg, case '\0': chars_to_escape = " \t\\'\"`"; break; - case '\'': - chars_to_escape = ""; - break; case '"': chars_to_escape = "$\"`\\"; break; + case '`': + case '\'': + return arg; default: assert(false && "Unhandled quote character"); + return arg; } std::string res; |