mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Text
- Removed splitq function and tests, migrated code over to the new Lexer::split.
This commit is contained in:
parent
611812007a
commit
386bcea60e
5 changed files with 5 additions and 29 deletions
|
@ -29,6 +29,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <Alias.h>
|
#include <Alias.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Lexer.h>
|
||||||
#include <Tree.h>
|
#include <Tree.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ void Alias::resolve (Tree* tree)
|
||||||
something = true;
|
something = true;
|
||||||
|
|
||||||
std::vector <std::string> words;
|
std::vector <std::string> words;
|
||||||
splitq (words, context.aliases[raw], ' ');
|
Lexer::split (words, context.aliases[raw]);
|
||||||
|
|
||||||
std::vector <std::string>::iterator word;
|
std::vector <std::string>::iterator word;
|
||||||
for (word = words.begin (); word != words.end (); ++word)
|
for (word = words.begin (); word != words.end (); ++word)
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Lexer.h>
|
||||||
#include <ViewTask.h>
|
#include <ViewTask.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
|
@ -83,7 +84,7 @@ int CmdCustom::execute (std::string& output)
|
||||||
|
|
||||||
// Prepend the argument list with those from the report filter.
|
// Prepend the argument list with those from the report filter.
|
||||||
std::vector <std::string> filterArgs;
|
std::vector <std::string> filterArgs;
|
||||||
splitq (filterArgs, reportFilter, ' ');
|
Lexer::split (filterArgs, reportFilter);
|
||||||
std::vector <std::string>::reverse_iterator arg;
|
std::vector <std::string>::reverse_iterator arg;
|
||||||
for (arg = filterArgs.rbegin (); arg != filterArgs.rend (); ++ arg)
|
for (arg = filterArgs.rbegin (); arg != filterArgs.rend (); ++ arg)
|
||||||
{
|
{
|
||||||
|
|
15
src/text.cpp
15
src/text.cpp
|
@ -63,21 +63,6 @@ void wrapText (
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// UTF-8
|
// UTF-8
|
||||||
//
|
|
||||||
// Splits on unicode whitespace, removeѕ quotes.
|
|
||||||
void splitq (std::vector <std::string>& results, const std::string& input)
|
|
||||||
{
|
|
||||||
results.clear ();
|
|
||||||
|
|
||||||
std::string token;
|
|
||||||
Lexer::Type type;
|
|
||||||
Lexer lex (input);
|
|
||||||
while (lex.token (token, type))
|
|
||||||
results.push_back (token);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// TODO Obsolete this call.
|
|
||||||
void splitq (
|
void splitq (
|
||||||
std::vector<std::string>& results,
|
std::vector<std::string>& results,
|
||||||
const std::string& input,
|
const std::string& input,
|
||||||
|
|
|
@ -39,7 +39,6 @@ std::string unquoteText (const std::string&);
|
||||||
int longestWord (const std::string&);
|
int longestWord (const std::string&);
|
||||||
int longestLine (const std::string&);
|
int longestLine (const std::string&);
|
||||||
bool extractLine (std::string&, const std::string&, int, bool, unsigned int&);
|
bool extractLine (std::string&, const std::string&, int, bool, unsigned int&);
|
||||||
void splitq (std::vector<std::string>&, const std::string&);
|
|
||||||
void splitq (std::vector<std::string>&, const std::string&, const char);
|
void splitq (std::vector<std::string>&, const std::string&, const char);
|
||||||
void split (std::vector<std::string>&, const std::string&, const char);
|
void split (std::vector<std::string>&, const std::string&, const char);
|
||||||
void split (std::vector<std::string>&, const std::string&, const std::string&);
|
void split (std::vector<std::string>&, const std::string&, const std::string&);
|
||||||
|
|
|
@ -37,7 +37,7 @@ Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
UnitTest t (270);
|
UnitTest t (264);
|
||||||
|
|
||||||
// Ensure environment has no influence.
|
// Ensure environment has no influence.
|
||||||
unsetenv ("TASKDATA");
|
unsetenv ("TASKDATA");
|
||||||
|
@ -183,16 +183,6 @@ int main (int argc, char** argv)
|
||||||
t.is (items[4], "five six seven", "splitq 'one \\'two\\' \\'\\' \\'three four\\' \"five six seven\" eight'nine ten' -> [4] 'five six seven'");
|
t.is (items[4], "five six seven", "splitq 'one \\'two\\' \\'\\' \\'three four\\' \"five six seven\" eight'nine ten' -> [4] 'five six seven'");
|
||||||
t.is (items[5], "eight'nine ten'", "splitq 'one \\'two\\' \\'\\' \\'three four\\' \"five six seven\" eight'nine ten' -> [4] 'eight\\'nine ten\\''");
|
t.is (items[5], "eight'nine ten'", "splitq 'one \\'two\\' \\'\\' \\'three four\\' \"five six seven\" eight'nine ten' -> [4] 'eight\\'nine ten\\''");
|
||||||
|
|
||||||
// void splitq (std::vector<std::string>&, const std::string&);
|
|
||||||
unsplit = " ( A or B ) ";
|
|
||||||
splitq (items, unsplit);
|
|
||||||
t.is (items.size (), (size_t) 5, "splitq ' ( A or B ) '");
|
|
||||||
t.is (items[0], "(", "splitq ' ( A or B ) ' -> [0] '('");
|
|
||||||
t.is (items[1], "A", "splitq ' ( A or B ) ' -> [1] 'A'");
|
|
||||||
t.is (items[2], "or", "splitq ' ( A or B ) ' -> [2] 'or'");
|
|
||||||
t.is (items[3], "B", "splitq ' ( A or B ) ' -> [3] 'B'");
|
|
||||||
t.is (items[4], ")", "splitq ' ( A or B ) ' -> [4] ')'");
|
|
||||||
|
|
||||||
// void join (std::string& result, const std::string& separator, const std::vector<std::string>& items)
|
// void join (std::string& result, const std::string& separator, const std::vector<std::string>& items)
|
||||||
std::vector <std::string> unjoined;
|
std::vector <std::string> unjoined;
|
||||||
std::string joined;
|
std::string joined;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue