mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI2: Support escaped utf-8 characters
This commit is contained in:
parent
0523ada9fc
commit
c119b6d1de
1 changed files with 16 additions and 7 deletions
23
src/CLI2.cpp
23
src/CLI2.cpp
|
@ -36,6 +36,8 @@
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
#include <CmdCustom.h>
|
#include <CmdCustom.h>
|
||||||
#include <CmdTimesheet.h>
|
#include <CmdTimesheet.h>
|
||||||
|
#include <utf8.h>
|
||||||
|
|
||||||
|
|
||||||
// Overridden by rc.abbreviation.minimum.
|
// Overridden by rc.abbreviation.minimum.
|
||||||
int CLI2::minimumMatchLength = 3;
|
int CLI2::minimumMatchLength = 3;
|
||||||
|
@ -413,24 +415,31 @@ void CLI2::lexArguments ()
|
||||||
_args.push_back (a);
|
_args.push_back (a);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process muktiple-token arguments.
|
// Process multiple-token arguments.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string quote = "'";
|
std::string quote = "'";
|
||||||
|
|
||||||
// Escape unescaped single quotes
|
// Escape unescaped single quotes
|
||||||
std::string escaped = "";
|
std::string escaped = "";
|
||||||
|
std::string::size_type cursor = 0;
|
||||||
|
|
||||||
bool nextEscaped = false;
|
bool nextEscaped = false;
|
||||||
for(auto c : _original_args[i].attribute ("raw")) {
|
|
||||||
if(!nextEscaped && (c == '\\')) {
|
while (int num = utf8_next_char (_original_args[i].attribute ("raw"), cursor))
|
||||||
|
{
|
||||||
|
std::string character = utf8_character (num);
|
||||||
|
if (!nextEscaped && (character == "\\"))
|
||||||
nextEscaped = true;
|
nextEscaped = true;
|
||||||
} else {
|
else {
|
||||||
if(c == '\'' && !nextEscaped) escaped += "\\";
|
if (character == "\'" && !nextEscaped)
|
||||||
|
escaped += "\\";
|
||||||
nextEscaped = false;
|
nextEscaped = false;
|
||||||
}
|
}
|
||||||
escaped += c;
|
escaped += character;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string::size_type cursor = 0;
|
cursor = 0;
|
||||||
std::string word;
|
std::string word;
|
||||||
if (Lexer::readWord (quote + escaped + quote, quote, cursor, word))
|
if (Lexer::readWord (quote + escaped + quote, quote, cursor, word))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue