summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/RegularExpression.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-12-19 03:41:24 +0000
committerGreg Clayton <gclayton@apple.com>2010-12-19 03:41:24 +0000
commit6ad07dd9e91c69f748e8aa41f6c48b0a3d3f03c0 (patch)
treefec686dfc493a7b7510421ee1049e882bf8eb128 /lldb/source/Core/RegularExpression.cpp
parent9a2d4e04c71e87e0dedf6f4b865f4c639989afb9 (diff)
downloadbcm5719-llvm-6ad07dd9e91c69f748e8aa41f6c48b0a3d3f03c0.tar.gz
bcm5719-llvm-6ad07dd9e91c69f748e8aa41f6c48b0a3d3f03c0.zip
Improved our argument parsing abilities to be able to handle stuff more like
a shell would interpret it. A few examples that we now handle correctly INPUT: "Hello "world OUTPUT: "Hello World" INPUT: "Hello "' World' OUTPUT: "Hello World" INPUT: Hello" World" OUTPUT: "Hello World" This broke the setting of dictionary values for the "settings set" command for things like: (lldb) settings set target.process.env-vars ["MY_ENV_VAR"]=YES since we would drop the quotes. I fixed the user settings controller to use a regular expression so it can accept any of the following inputs for dictionary setting: settings set target.process.env-vars ["MY_ENV_VAR"]=YES settings set target.process.env-vars [MY_ENV_VAR]=YES settings set target.process.env-vars MY_ENV_VAR=YES We might want to eventually drop the first two syntaxes, but I won't make that decision right now. This allows more natural setting of the envirorment variables: settings set target.process.env-vars MY_ENV_VAR=YES ABC=DEF CWD=/tmp llvm-svn: 122166
Diffstat (limited to 'lldb/source/Core/RegularExpression.cpp')
-rw-r--r--lldb/source/Core/RegularExpression.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/lldb/source/Core/RegularExpression.cpp b/lldb/source/Core/RegularExpression.cpp
index 45ed9cc6374..7848931e392 100644
--- a/lldb/source/Core/RegularExpression.cpp
+++ b/lldb/source/Core/RegularExpression.cpp
@@ -100,7 +100,7 @@ RegularExpression::Execute(const char* s, size_t num_matches, int execute_flags)
match_result = ::regexec (&m_preg,
s,
m_matches.size(),
- &m_matches.front(),
+ &m_matches[0],
execute_flags);
}
return match_result == 0;
@@ -111,9 +111,18 @@ RegularExpression::GetMatchAtIndex (const char* s, uint32_t idx, std::string& ma
{
if (idx <= m_preg.re_nsub && idx < m_matches.size())
{
- match_str.assign (s + m_matches[idx].rm_so,
- m_matches[idx].rm_eo - m_matches[idx].rm_so);
- return true;
+ if (m_matches[idx].rm_eo == m_matches[idx].rm_so)
+ {
+ // Matched the empty string...
+ match_str.clear();
+ return true;
+ }
+ else if (m_matches[idx].rm_eo > m_matches[idx].rm_so)
+ {
+ match_str.assign (s + m_matches[idx].rm_so,
+ m_matches[idx].rm_eo - m_matches[idx].rm_so);
+ return true;
+ }
}
return false;
}
OpenPOWER on IntegriCloud