fix(token): more patches

This commit is contained in:
NBonaparte 2016-11-20 22:44:35 -08:00
parent d66c16674c
commit c658d22925

View File

@ -26,7 +26,7 @@ namespace drawtypes {
} }
void label::replace_token(string token, string replacement) { void label::replace_token(string token, string replacement) {
if (m_text.find(token) == string::npos) if (m_text.find(token) == string::npos || m_token_iterator == m_token_bounds.end())
return; return;
m_tokenized = string_util::replace_all_bounded(m_tokenized, token, replacement, m_tokenized = string_util::replace_all_bounded(m_tokenized, token, replacement,
@ -77,13 +77,14 @@ namespace drawtypes {
name = string_util::ltrim(string_util::rtrim(name, '>'), '<'); name = string_util::ltrim(string_util::rtrim(name, '>'), '<');
string text; string text;
string line{text};
if (required) if (required)
text = conf.get<string>(section, name); text = conf.get<string>(section, name);
else else
text = conf.get<string>(section, name, def); text = conf.get<string>(section, name, def);
string line{text};
while ((start = line.find('%')) != string::npos && (end = line.find('%', start + 1)) != string::npos) { while ((start = line.find('%')) != string::npos && (end = line.find('%', start + 1)) != string::npos) {
auto token = line.substr(start, end); auto token = line.substr(start, end);