Made the SRT parser a bit less strict.

* This allows to parse some SRTs that previously failed.
* Use the more expressive BString::IsEmpty() instead of Length() > 0.
This commit is contained in:
Axel Dörfler 2011-12-22 22:22:25 +01:00
parent 61084e53b5
commit 82a05afe30

View File

@ -45,6 +45,9 @@ SubTitlesSRT::SubTitlesSRT(BFile* file, const char* name)
switch (state) {
case EXPECT_SEQUENCE_NUMBER:
{
if (line.IsEmpty())
continue;
line.Trim();
int32 sequenceNumber = atoi(line.String());
if (sequenceNumber != lastSequenceNumber + 1) {
@ -106,7 +109,7 @@ SubTitlesSRT::SubTitlesSRT(BFile* file, const char* name)
}
case EXPECT_TEXT:
if (line.Length() == 0) {
if (line.IsEmpty()) {
int32 index = _IndexFor(subTitle.startTime);
SubTitle* clone = new(std::nothrow) SubTitle(subTitle);
if (clone == NULL || !fSubTitles.AddItem(clone, index)) {