mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
util: Migrated obfuscateText from text
This commit is contained in:
parent
b9f55997ae
commit
9ae171f57c
6 changed files with 36 additions and 35 deletions
|
@ -29,7 +29,7 @@
|
|||
#include <numeric>
|
||||
#include <Context.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <utf8.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <ViewText.h>
|
||||
#include <Context.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <utf8.h>
|
||||
#include <main.h>
|
||||
|
||||
|
|
32
src/text.cpp
32
src/text.cpp
|
@ -92,35 +92,3 @@ int strippedLength (const std::string& input)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string obfuscateText (const std::string& input)
|
||||
{
|
||||
std::stringstream output;
|
||||
std::string::size_type i = 0;
|
||||
int character;
|
||||
bool inside = false;
|
||||
|
||||
while ((character = utf8_next_char (input, i)))
|
||||
{
|
||||
if (inside)
|
||||
{
|
||||
output << (char) character;
|
||||
|
||||
if (character == 'm')
|
||||
inside = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (character == 033)
|
||||
inside = true;
|
||||
|
||||
if (inside || character == ' ')
|
||||
output << (char) character;
|
||||
else
|
||||
output << 'x';
|
||||
}
|
||||
}
|
||||
|
||||
return output.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
const char* optionalBlankLine ();
|
||||
bool nontrivial (const std::string&);
|
||||
int strippedLength (const std::string&);
|
||||
const std::string obfuscateText (const std::string&);
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
33
src/util.cpp
33
src/util.cpp
|
@ -54,6 +54,7 @@
|
|||
|
||||
#include <Lexer.h>
|
||||
#include <text.h>
|
||||
#include <utf8.h>
|
||||
#include <main.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
@ -283,3 +284,35 @@ std::string osName ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string obfuscateText (const std::string& input)
|
||||
{
|
||||
std::stringstream output;
|
||||
std::string::size_type i = 0;
|
||||
int character;
|
||||
bool inside = false;
|
||||
|
||||
while ((character = utf8_next_char (input, i)))
|
||||
{
|
||||
if (inside)
|
||||
{
|
||||
output << (char) character;
|
||||
|
||||
if (character == 'm')
|
||||
inside = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (character == 033)
|
||||
inside = true;
|
||||
|
||||
if (inside || character == ' ')
|
||||
output << (char) character;
|
||||
else
|
||||
output << 'x';
|
||||
}
|
||||
}
|
||||
|
||||
return output.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -61,6 +61,7 @@ const std::vector <std::string> extractParents (
|
|||
#endif
|
||||
|
||||
std::string osName ();
|
||||
const std::string obfuscateText (const std::string&);
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue