mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Lexer: Added ::dequote
This commit is contained in:
parent
a2e45b9297
commit
8b159d7225
2 changed files with 20 additions and 0 deletions
|
@ -329,6 +329,25 @@ bool Lexer::isPunctuation (int c)
|
|||
! isAlpha (c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Assumes that quotes is a string containing a non-trivial set of quote
|
||||
// characters.
|
||||
std::string Lexer::dequote (const std::string& input, const std::string& quotes)
|
||||
{
|
||||
if (input.length ())
|
||||
{
|
||||
int quote = input[0];
|
||||
if (quotes.find (quote) != std::string::npos)
|
||||
{
|
||||
size_t len = input.length ();
|
||||
if (quote == input[len - 1])
|
||||
return input.substr (1, len - 2);
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Lexer::isEOS () const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue