From a7d90fa1fa29d8054bc9770766ad0cde89b6e689 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 11 Dec 2016 17:29:03 -0500 Subject: [PATCH] util: Migrated obfuscateText from text --- src/ViewTask.cpp | 2 +- src/ViewText.cpp | 2 +- src/text.cpp | 32 -------------------------------- src/text.h | 1 - src/util.cpp | 33 +++++++++++++++++++++++++++++++++ src/util.h | 1 + 6 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/ViewTask.cpp b/src/ViewTask.cpp index 4c2f9bff1..37e82e40f 100644 --- a/src/ViewTask.cpp +++ b/src/ViewTask.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ViewText.cpp b/src/ViewText.cpp index c1d8455d8..98dc225ba 100644 --- a/src/ViewText.cpp +++ b/src/ViewText.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/text.cpp b/src/text.cpp index 1709e6a84..c1a4ffb0f 100644 --- a/src/text.cpp +++ b/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 (); -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/text.h b/src/text.h index de92b5263..3154a9ff6 100644 --- a/src/text.h +++ b/src/text.h @@ -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 //////////////////////////////////////////////////////////////////////////////// diff --git a/src/util.cpp b/src/util.cpp index 50fc940cd..b718b07f6 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -54,6 +54,7 @@ #include #include +#include #include #include @@ -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 (); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/util.h b/src/util.h index 404c0a1b9..766e8ce73 100644 --- a/src/util.h +++ b/src/util.h @@ -61,6 +61,7 @@ const std::vector extractParents ( #endif std::string osName (); +const std::string obfuscateText (const std::string&); #endif ////////////////////////////////////////////////////////////////////////////////