Removed escape_hash_filter::mPrevious, removed usage of boost::replace_all

new-script-api
Alexander Stillich 7 years ago committed by scrawl
parent 09aac22782
commit 52b3507a2b

@ -1,6 +1,6 @@
#include "escape.hpp" #include "escape.hpp"
#include <boost/algorithm/string/replace.hpp> #include <components/misc/stringops.hpp>
namespace Files namespace Files
{ {
@ -8,7 +8,7 @@ namespace Files
const int escape_hash_filter::sEscapeIdentifier = 'a'; const int escape_hash_filter::sEscapeIdentifier = 'a';
const int escape_hash_filter::sHashIdentifier = 'h'; const int escape_hash_filter::sHashIdentifier = 'h';
escape_hash_filter::escape_hash_filter() : mNext(), mPrevious(), mSeenNonWhitespace(false), mFinishLine(false) escape_hash_filter::escape_hash_filter() : mSeenNonWhitespace(false), mFinishLine(false)
{ {
} }
@ -26,9 +26,14 @@ namespace Files
std::string EscapeHashString::processString(const std::string & str) std::string EscapeHashString::processString(const std::string & str)
{ {
std::string temp = boost::replace_all_copy<std::string>(str, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sHashIdentifier, "#"); std::string temp = str;
auto format = std::string(1, (char)escape_hash_filter::sEscape);
boost::replace_all(temp, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sEscapeIdentifier, format); static const char hash[] = { escape_hash_filter::sEscape, escape_hash_filter::sHashIdentifier };
Misc::StringUtils::replaceAll(temp, hash, "#", 2, 1);
static const char escape[] = { escape_hash_filter::sEscape, escape_hash_filter::sEscapeIdentifier };
Misc::StringUtils::replaceAll(temp, escape, "@", 2, 1);
return temp; return temp;
} }

@ -30,7 +30,6 @@ namespace Files
private: private:
std::queue<int> mNext; std::queue<int> mNext;
int mPrevious;
bool mSeenNonWhitespace; bool mSeenNonWhitespace;
bool mFinishLine; bool mFinishLine;
@ -42,11 +41,9 @@ namespace Files
if (mNext.empty()) if (mNext.empty())
{ {
int character = boost::iostreams::get(src); int character = boost::iostreams::get(src);
bool record = true;
if (character == boost::iostreams::WOULD_BLOCK) if (character == boost::iostreams::WOULD_BLOCK)
{ {
mNext.push(character); mNext.push(character);
record = false;
} }
else if (character == EOF) else if (character == EOF)
{ {
@ -79,12 +76,6 @@ namespace Files
} }
} }
else if (character == sEscape) else if (character == sEscape)
{
mNext.push(sEscape);
mNext.push(sEscapeIdentifier);
record = false;
}
else if (mPrevious == sEscape)
{ {
mNext.push(sEscape); mNext.push(sEscape);
mNext.push(sEscapeIdentifier); mNext.push(sEscapeIdentifier);
@ -95,8 +86,6 @@ namespace Files
} }
if (!mSeenNonWhitespace && !isspace(character)) if (!mSeenNonWhitespace && !isspace(character))
mSeenNonWhitespace = true; mSeenNonWhitespace = true;
if (record)
mPrevious = character;
} }
int retval = mNext.front(); int retval = mNext.front();
mNext.pop(); mNext.pop();

Loading…
Cancel
Save