mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Code Cleanup
- Removed obsolete text.cpp splitq funciton, which is superceded by Lexer::split.
This commit is contained in:
parent
b0b176827e
commit
d99f40eaad
3 changed files with 1 additions and 54 deletions
41
src/text.cpp
41
src/text.cpp
|
@ -61,47 +61,6 @@ void wrapText (
|
||||||
lines.push_back (line);
|
lines.push_back (line);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// UTF-8
|
|
||||||
void splitq (
|
|
||||||
std::vector<std::string>& results,
|
|
||||||
const std::string& input,
|
|
||||||
const char delimiter)
|
|
||||||
{
|
|
||||||
results.clear ();
|
|
||||||
|
|
||||||
std::string::size_type start = 0;
|
|
||||||
std::string::size_type i = 0;
|
|
||||||
std::string word;
|
|
||||||
bool in_quote = false;
|
|
||||||
char quote;
|
|
||||||
|
|
||||||
while (utf8_next_char (input, i))
|
|
||||||
{
|
|
||||||
if (in_quote)
|
|
||||||
{
|
|
||||||
if (input[i] == quote)
|
|
||||||
in_quote = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (input[i] == delimiter)
|
|
||||||
{
|
|
||||||
results.push_back (unquoteText (input.substr (start, i - start)));
|
|
||||||
start = i + 1;
|
|
||||||
}
|
|
||||||
else if (input[i] == '\'' ||
|
|
||||||
input[i] == '"')
|
|
||||||
{
|
|
||||||
quote = input[i];
|
|
||||||
in_quote = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
results.push_back (unquoteText (input.substr (start)));
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void split (
|
void split (
|
||||||
std::vector<std::string>& results,
|
std::vector<std::string>& results,
|
||||||
|
|
|
@ -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&, 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&);
|
||||||
void split_minimal (std::vector<std::string>&, const std::string&, const char);
|
void split_minimal (std::vector<std::string>&, const std::string&, const char);
|
||||||
|
|
|
@ -37,7 +37,7 @@ Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
UnitTest t (264);
|
UnitTest t (257);
|
||||||
|
|
||||||
// Ensure environment has no influence.
|
// Ensure environment has no influence.
|
||||||
unsetenv ("TASKDATA");
|
unsetenv ("TASKDATA");
|
||||||
|
@ -172,17 +172,6 @@ int main (int argc, char** argv)
|
||||||
t.is (items[1], "two", "split 'one\\ntwo\\nthree' -> [1] 'two'");
|
t.is (items[1], "two", "split 'one\\ntwo\\nthree' -> [1] 'two'");
|
||||||
t.is (items[2], "three", "split 'one\\ntwo\\nthree' -> [2] 'three'");
|
t.is (items[2], "three", "split 'one\\ntwo\\nthree' -> [2] 'three'");
|
||||||
|
|
||||||
// void splitq (std::vector<std::string>&, const std::string&, const char);
|
|
||||||
unsplit = "one 'two' '' 'three four' \"five six seven\" eight'nine ten'";
|
|
||||||
splitq (items, unsplit, ' ');
|
|
||||||
t.is (items.size () , (size_t) 6, "splitq 'one \\'two\\' \\'\\' \\'three four\\' \"five six seven\" eight'nine ten'");
|
|
||||||
t.is (items[0], "one", "splitq 'one \\'two\\' \\'\\' \\'three four\\' \"five six seven\" eight'nine ten' -> [0] 'one'");
|
|
||||||
t.is (items[1], "two", "splitq 'one \\'two\\' \\'\\' \\'three four\\' \"five six seven\" eight'nine ten' -> [1] 'two'");
|
|
||||||
t.is (items[2], "", "splitq 'one \\'two\\' \\'\\' \\'three four\\' \"five six seven\" eight'nine ten' -> [2] ''");
|
|
||||||
t.is (items[3], "three four", "splitq 'one \\'two\\' \\'\\' \\'three four\\' \"five six seven\" eight'nine ten' -> [3] 'three four'");
|
|
||||||
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\\''");
|
|
||||||
|
|
||||||
// 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