fix ot::read_comments when handling empty lines

This commit is contained in:
Frédéric Mangano-Tarumi 2018-11-24 11:12:22 -05:00
parent 26411d3843
commit bfa46273b9
2 changed files with 5 additions and 2 deletions

View File

@ -159,7 +159,7 @@ std::list<std::string> ot::read_comments(FILE* input)
{
std::list<std::string> comments;
auto raw_tags = std::make_unique<char[]>(16383);
size_t raw_len = fread(raw_tags.get(), 1, 16382, stdin);
size_t raw_len = fread(raw_tags.get(), 1, 16382, input);
if (raw_len == 16382)
fputs("warning: truncating comment to 16 KiB\n", stderr);
raw_tags[raw_len] = '\0';
@ -169,8 +169,10 @@ std::list<std::string> ot::read_comments(FILE* input)
for (size_t i = 0; i <= raw_len; ++i) {
if (raw_tags[i] == '\n' || raw_tags[i] == '\0') {
raw_tags[i] = '\0';
if (field_len == 0)
if (field_len == 0) {
cursor = raw_tags.get() + i + 1;
continue;
}
if (caught_eq)
comments.emplace_back(cursor);
else

View File

@ -152,6 +152,7 @@ EOF
is_deeply(opustags(qw(out.opus --set-all -a A=B -s X=Z -d OK), {in => <<'END_IN'}), [<<'END_OUT', '', 0], 'set all');
OK=yes again
ARTIST=七面鳥
A=A
X=Y
END_IN