util: Migrated obfuscateText from text

This commit is contained in:
Paul Beckingham 2016-12-11 17:29:03 -05:00
parent b9f55997ae
commit 9ae171f57c
6 changed files with 36 additions and 35 deletions

View file

@ -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>

View file

@ -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>

View file

@ -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 ();
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -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
////////////////////////////////////////////////////////////////////////////////

View file

@ -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 ();
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -61,6 +61,7 @@ const std::vector <std::string> extractParents (
#endif
std::string osName ();
const std::string obfuscateText (const std::string&);
#endif
////////////////////////////////////////////////////////////////////////////////