mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 10:07:19 +02:00
Use str_replace from libshared
This commit is contained in:
parent
a95205357c
commit
663c6575ce
2 changed files with 2 additions and 20 deletions
|
@ -172,23 +172,6 @@ std::vector <std::string> CmdEdit::findValues (
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
std::string CmdEdit::replaceString (
|
|
||||||
std::string text,
|
|
||||||
const std::string& search,
|
|
||||||
const std::string& replacement)
|
|
||||||
{
|
|
||||||
std::string::size_type found = 0;
|
|
||||||
|
|
||||||
while ((found = text.find (search, found)) != std::string::npos)
|
|
||||||
{
|
|
||||||
text.replace (found, search.length (), replacement);
|
|
||||||
found += replacement.length ();
|
|
||||||
}
|
|
||||||
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string CmdEdit::formatDate (
|
std::string CmdEdit::formatDate (
|
||||||
Task& task,
|
Task& task,
|
||||||
|
@ -272,7 +255,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat)
|
||||||
{
|
{
|
||||||
Datetime dt (strtol (anno.first.substr (11).c_str (), nullptr, 10));
|
Datetime dt (strtol (anno.first.substr (11).c_str (), nullptr, 10));
|
||||||
before << " Annotation: " << dt.toString (dateformat)
|
before << " Annotation: " << dt.toString (dateformat)
|
||||||
<< " -- " << replaceString (anno.second, "\n", ANNOTATION_EDIT_MARKER) << '\n';
|
<< " -- " << str_replace (anno.second, "\n", ANNOTATION_EDIT_MARKER) << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
Datetime now;
|
Datetime now;
|
||||||
|
@ -637,7 +620,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||||
|
|
||||||
if (eol != std::string::npos)
|
if (eol != std::string::npos)
|
||||||
{
|
{
|
||||||
auto value = Lexer::trim (replaceString (after.substr (found, eol - found), ANNOTATION_EDIT_MARKER, "\n"), "\t ");
|
auto value = Lexer::trim (str_replace (after.substr (found, eol - found), ANNOTATION_EDIT_MARKER, "\n"), "\t ");
|
||||||
auto gap = value.find (" -- ");
|
auto gap = value.find (" -- ");
|
||||||
if (gap != std::string::npos)
|
if (gap != std::string::npos)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,7 +41,6 @@ private:
|
||||||
std::string findValue (const std::string&, const std::string&);
|
std::string findValue (const std::string&, const std::string&);
|
||||||
std::string findMultilineValue (const std::string&, const std::string&, const std::string&);
|
std::string findMultilineValue (const std::string&, const std::string&, const std::string&);
|
||||||
std::vector <std::string> findValues (const std::string&, const std::string&);
|
std::vector <std::string> findValues (const std::string&, const std::string&);
|
||||||
std::string replaceString (std::string text, const std::string& search, const std::string& replacement);
|
|
||||||
std::string formatDate (Task&, const std::string&, const std::string&);
|
std::string formatDate (Task&, const std::string&, const std::string&);
|
||||||
std::string formatDuration (Task&, const std::string&);
|
std::string formatDuration (Task&, const std::string&);
|
||||||
std::string formatTask (Task, const std::string&);
|
std::string formatTask (Task, const std::string&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue