util: Migrated obfuscateText from text
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
#include <text.h>
|
#include <util.h>
|
||||||
#include <utf8.h>
|
#include <utf8.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
#include <text.h>
|
#include <util.h>
|
||||||
#include <utf8.h>
|
#include <utf8.h>
|
||||||
#include <main.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 ();
|
const char* optionalBlankLine ();
|
||||||
bool nontrivial (const std::string&);
|
bool nontrivial (const std::string&);
|
||||||
int strippedLength (const std::string&);
|
int strippedLength (const std::string&);
|
||||||
const std::string obfuscateText (const std::string&);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
33
src/util.cpp
33
src/util.cpp
@@ -54,6 +54,7 @@
|
|||||||
|
|
||||||
#include <Lexer.h>
|
#include <Lexer.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
|
#include <utf8.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <i18n.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
|
#endif
|
||||||
|
|
||||||
std::string osName ();
|
std::string osName ();
|
||||||
|
const std::string obfuscateText (const std::string&);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user