mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 00:57:19 +02:00
util: Migrated obfuscateText from text
This commit is contained in:
parent
9f36fdfe65
commit
a7d90fa1fa
6 changed files with 36 additions and 35 deletions
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 ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue