forked from OSchip/llvm-project
[lldb][NFC] Remove Args::StripSpaces
This just reimplemented llvm::StringRef::[r/l]trim(). llvm-svn: 371181
This commit is contained in:
parent
0d50c4e060
commit
7841e80e79
|
@ -251,10 +251,6 @@ public:
|
|||
// For re-setting or blanking out the list of arguments.
|
||||
void Clear();
|
||||
|
||||
static const char *StripSpaces(std::string &s, bool leading = true,
|
||||
bool trailing = true,
|
||||
bool return_null_if_empty = true);
|
||||
|
||||
static bool UInt64ValueIsValidForByteSize(uint64_t uval64,
|
||||
size_t total_byte_size) {
|
||||
if (total_byte_size > 8)
|
||||
|
|
|
@ -205,16 +205,13 @@ protected:
|
|||
}
|
||||
|
||||
// Split the raw command into var_name and value pair.
|
||||
llvm::StringRef raw_str(command);
|
||||
std::string var_value_string = raw_str.split(var_name).second.str();
|
||||
const char *var_value_cstr =
|
||||
Args::StripSpaces(var_value_string, true, false, false);
|
||||
llvm::StringRef var_value(command);
|
||||
var_value = var_value.split(var_name).second.ltrim();
|
||||
|
||||
Status error;
|
||||
if (m_options.m_global) {
|
||||
if (m_options.m_global)
|
||||
error = GetDebugger().SetPropertyValue(nullptr, eVarSetOperationAssign,
|
||||
var_name, var_value_cstr);
|
||||
}
|
||||
var_name, var_value);
|
||||
|
||||
if (error.Success()) {
|
||||
// FIXME this is the same issue as the one in commands script import
|
||||
|
@ -225,7 +222,7 @@ protected:
|
|||
ExecutionContext exe_ctx(m_exe_ctx);
|
||||
m_exe_ctx.Clear();
|
||||
error = GetDebugger().SetPropertyValue(&exe_ctx, eVarSetOperationAssign,
|
||||
var_name, var_value_cstr);
|
||||
var_name, var_value);
|
||||
}
|
||||
|
||||
if (error.Fail()) {
|
||||
|
@ -646,13 +643,11 @@ protected:
|
|||
}
|
||||
|
||||
// Split the raw command into var_name and value pair.
|
||||
llvm::StringRef raw_str(command);
|
||||
std::string var_value_string = raw_str.split(var_name).second.str();
|
||||
const char *var_value_cstr =
|
||||
Args::StripSpaces(var_value_string, true, true, false);
|
||||
llvm::StringRef var_value(command);
|
||||
var_value = var_value.split(var_name).second.trim();
|
||||
|
||||
Status error(GetDebugger().SetPropertyValue(
|
||||
&m_exe_ctx, eVarSetOperationRemove, var_name, var_value_cstr));
|
||||
&m_exe_ctx, eVarSetOperationRemove, var_name, var_value));
|
||||
if (error.Fail()) {
|
||||
result.AppendError(error.AsCString());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
|
@ -744,13 +739,11 @@ protected:
|
|||
}
|
||||
|
||||
// Split the raw command into var_name, index_value, and value triple.
|
||||
llvm::StringRef raw_str(command);
|
||||
std::string var_value_string = raw_str.split(var_name).second.str();
|
||||
const char *var_value_cstr =
|
||||
Args::StripSpaces(var_value_string, true, true, false);
|
||||
llvm::StringRef var_value(command);
|
||||
var_value = var_value.split(var_name).second.trim();
|
||||
|
||||
Status error(GetDebugger().SetPropertyValue(
|
||||
&m_exe_ctx, eVarSetOperationReplace, var_name, var_value_cstr));
|
||||
&m_exe_ctx, eVarSetOperationReplace, var_name, var_value));
|
||||
if (error.Fail()) {
|
||||
result.AppendError(error.AsCString());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
|
@ -848,13 +841,11 @@ protected:
|
|||
}
|
||||
|
||||
// Split the raw command into var_name, index_value, and value triple.
|
||||
llvm::StringRef raw_str(command);
|
||||
std::string var_value_string = raw_str.split(var_name).second.str();
|
||||
const char *var_value_cstr =
|
||||
Args::StripSpaces(var_value_string, true, true, false);
|
||||
llvm::StringRef var_value(command);
|
||||
var_value = var_value.split(var_name).second.trim();
|
||||
|
||||
Status error(GetDebugger().SetPropertyValue(
|
||||
&m_exe_ctx, eVarSetOperationInsertBefore, var_name, var_value_cstr));
|
||||
&m_exe_ctx, eVarSetOperationInsertBefore, var_name, var_value));
|
||||
if (error.Fail()) {
|
||||
result.AppendError(error.AsCString());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
|
@ -949,13 +940,11 @@ protected:
|
|||
}
|
||||
|
||||
// Split the raw command into var_name, index_value, and value triple.
|
||||
llvm::StringRef raw_str(command);
|
||||
std::string var_value_string = raw_str.split(var_name).second.str();
|
||||
const char *var_value_cstr =
|
||||
Args::StripSpaces(var_value_string, true, true, false);
|
||||
llvm::StringRef var_value(command);
|
||||
var_value = var_value.split(var_name).second.trim();
|
||||
|
||||
Status error(GetDebugger().SetPropertyValue(
|
||||
&m_exe_ctx, eVarSetOperationInsertAfter, var_name, var_value_cstr));
|
||||
&m_exe_ctx, eVarSetOperationInsertAfter, var_name, var_value));
|
||||
if (error.Fail()) {
|
||||
result.AppendError(error.AsCString());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
|
@ -1041,13 +1030,11 @@ protected:
|
|||
// character string later on.
|
||||
|
||||
// Split the raw command into var_name and value pair.
|
||||
llvm::StringRef raw_str(command);
|
||||
std::string var_value_string = raw_str.split(var_name).second.str();
|
||||
const char *var_value_cstr =
|
||||
Args::StripSpaces(var_value_string, true, true, false);
|
||||
llvm::StringRef var_value(command);
|
||||
var_value = var_value.split(var_name).second.trim();
|
||||
|
||||
Status error(GetDebugger().SetPropertyValue(
|
||||
&m_exe_ctx, eVarSetOperationAppend, var_name, var_value_cstr));
|
||||
&m_exe_ctx, eVarSetOperationAppend, var_name, var_value));
|
||||
if (error.Fail()) {
|
||||
result.AppendError(error.AsCString());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
|
|
|
@ -206,7 +206,7 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) {
|
|||
// Meta command
|
||||
// Strip the ':'
|
||||
code.erase(0, 1);
|
||||
if (Args::StripSpaces(code)) {
|
||||
if (!llvm::StringRef(code).trim().empty()) {
|
||||
// "lldb" was followed by arguments, so just execute the command dump
|
||||
// the results
|
||||
|
||||
|
|
|
@ -382,29 +382,6 @@ void Args::Clear() {
|
|||
m_argv.push_back(nullptr);
|
||||
}
|
||||
|
||||
const char *Args::StripSpaces(std::string &s, bool leading, bool trailing,
|
||||
bool return_null_if_empty) {
|
||||
static const char *k_white_space = " \t\v";
|
||||
if (!s.empty()) {
|
||||
if (leading) {
|
||||
size_t pos = s.find_first_not_of(k_white_space);
|
||||
if (pos == std::string::npos)
|
||||
s.clear();
|
||||
else if (pos > 0)
|
||||
s.erase(0, pos);
|
||||
}
|
||||
|
||||
if (trailing) {
|
||||
size_t rpos = s.find_last_not_of(k_white_space);
|
||||
if (rpos != std::string::npos && rpos + 1 < s.size())
|
||||
s.erase(rpos + 1);
|
||||
}
|
||||
}
|
||||
if (return_null_if_empty && s.empty())
|
||||
return nullptr;
|
||||
return s.c_str();
|
||||
}
|
||||
|
||||
const char *Args::GetShellSafeArgument(const FileSpec &shell,
|
||||
const char *unsafe_arg,
|
||||
std::string &safe_arg) {
|
||||
|
|
Loading…
Reference in New Issue