mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug Fix - Task::determineVersion
- Fixed determineVersion details. - Strips \n from EOL before attempting parse.
This commit is contained in:
parent
62f240aad4
commit
4470c3b88c
1 changed files with 22 additions and 14 deletions
36
src/Task.cpp
36
src/Task.cpp
|
@ -64,14 +64,20 @@ Task& Task::operator= (const Task& other)
|
|||
// try a legacy parse (F3, FF2). Note that FF1 is no longer supported.
|
||||
Task::Task (const std::string& input)
|
||||
{
|
||||
std::string copy;
|
||||
if (input[input.length () - 1] == '\n')
|
||||
copy = input.substr (0, input.length () - 1);
|
||||
else
|
||||
copy = input;
|
||||
|
||||
try
|
||||
{
|
||||
Record::parse (input);
|
||||
Record::parse (copy);
|
||||
}
|
||||
|
||||
catch (std::string& e)
|
||||
{
|
||||
legacyParse (input);
|
||||
legacyParse (copy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -520,26 +526,28 @@ int Task::determineVersion (const std::string& line)
|
|||
return 2;
|
||||
}
|
||||
|
||||
// Version 4 looks like:
|
||||
//
|
||||
// [name:"value" ...]
|
||||
//
|
||||
// Scan for [, ] and :".
|
||||
else if (line[0] == '[' &&
|
||||
line[line.length () - 1] == ']' &&
|
||||
line.find ("uuid:\"") != std::string::npos)
|
||||
return 4;
|
||||
|
||||
// Version 1 looks like:
|
||||
//
|
||||
// [tags] [attributes] description\n
|
||||
// X [tags] [attributes] description\n
|
||||
//
|
||||
// Scan for the first character being either the bracket or X.
|
||||
else if ((line[0] == '[' && line[line.length () - 1] != ']') ||
|
||||
line.find ("X [") == 0)
|
||||
else if (line.find ("X [") == 0 ||
|
||||
line.find ("uuid") == std::string::npos ||
|
||||
(line[0] == '[' &&
|
||||
line.substr (line.length () - 1, 1) != "]"))
|
||||
return 1;
|
||||
|
||||
// Version 4 looks like:
|
||||
//
|
||||
// [name:"value" ...]
|
||||
//
|
||||
// Scan for [, ] and :".
|
||||
if (line[0] == '[' &&
|
||||
line[line.length () - 1] == ']' &&
|
||||
line.find (":\"") != std::string::npos)
|
||||
return 4;
|
||||
|
||||
// Version 5?
|
||||
//
|
||||
// Fortunately, with the hindsight that will come with version 5, the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue