Trim whitespace from all of the style fields when parsing. Closes #1565.

This commit is contained in:
Thomas Goyne 2013-01-01 21:00:06 -08:00
parent b1cd2db023
commit 451de69e54
1 changed files with 4 additions and 4 deletions

View File

@ -79,10 +79,10 @@ class parser {
std::vector<string_range> tkns; std::vector<string_range> tkns;
size_t tkn_idx; size_t tkn_idx;
string_range& next_tok() { string_range next_tok() {
if (tkn_idx >= tkns.size()) if (tkn_idx >= tkns.size())
throw SubtitleFormatParseError("Malformed style: not enough fields", 0); throw SubtitleFormatParseError("Malformed style: not enough fields", 0);
return tkns[tkn_idx++]; return trim_copy(tkns[tkn_idx++]);
} }
public: public:
@ -102,12 +102,12 @@ public:
} }
std::string next_str() { std::string next_str() {
auto tkn = trim_copy(next_tok()); auto tkn = next_tok();
return std::string(begin(tkn), end(tkn)); return std::string(begin(tkn), end(tkn));
} }
agi::Color next_color() { agi::Color next_color() {
auto &tkn = next_tok(); auto tkn = next_tok();
return std::string(begin(tkn), end(tkn)); return std::string(begin(tkn), end(tkn));
} }