forked from mia/Aegisub
Fixed the loading of SRT files without a line break at the end.
Originally committed to SVN as r802.
This commit is contained in:
parent
21c8587d1c
commit
df4a8a3e27
1 changed files with 48 additions and 44 deletions
|
@ -103,8 +103,7 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
||||||
wxString curLine = file.ReadLineFromFile();
|
wxString curLine = file.ReadLineFromFile();
|
||||||
fileLine++;
|
fileLine++;
|
||||||
|
|
||||||
switch (mode) {
|
if (mode == 0) {
|
||||||
case 0:
|
|
||||||
// Checks if there is anything to read
|
// Checks if there is anything to read
|
||||||
if (curLine.IsEmpty()) continue;
|
if (curLine.IsEmpty()) continue;
|
||||||
|
|
||||||
|
@ -121,9 +120,9 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
||||||
}
|
}
|
||||||
line = new AssDialogue();
|
line = new AssDialogue();
|
||||||
mode = 1;
|
mode = 1;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case 1:
|
else if (mode == 1) {
|
||||||
// Read timestamps
|
// Read timestamps
|
||||||
if (curLine.substr(13,3) != _T("-->")) {
|
if (curLine.substr(13,3) != _T("-->")) {
|
||||||
Clear();
|
Clear();
|
||||||
|
@ -132,11 +131,21 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
||||||
line->Start.ParseSRT(curLine.substr(0,12));
|
line->Start.ParseSRT(curLine.substr(0,12));
|
||||||
line->End.ParseSRT(curLine.substr(17,12));
|
line->End.ParseSRT(curLine.substr(17,12));
|
||||||
mode = 2;
|
mode = 2;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case 2:
|
else if (mode == 2) {
|
||||||
// Checks if it's done
|
// Checks if it's done
|
||||||
if (curLine.IsEmpty() || !file.HasMoreLines()) {
|
bool eof = !file.HasMoreLines();
|
||||||
|
bool isDone = curLine.IsEmpty();
|
||||||
|
|
||||||
|
// Append text
|
||||||
|
if (!isDone) {
|
||||||
|
if (line->Text != _T("")) line->Text += _T("\\N");
|
||||||
|
line->Text += curLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Done
|
||||||
|
if (isDone || eof) {
|
||||||
mode = 0;
|
mode = 0;
|
||||||
linen++;
|
linen++;
|
||||||
line->group = _T("[Events]");
|
line->group = _T("[Events]");
|
||||||
|
@ -147,12 +156,7 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
||||||
line->StartMS = line->Start.GetMS();
|
line->StartMS = line->Start.GetMS();
|
||||||
Line->push_back(line);
|
Line->push_back(line);
|
||||||
lines++;
|
lines++;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
// Append text
|
|
||||||
if (line->Text != _T("")) line->Text += _T("\\N");
|
|
||||||
line->Text += curLine;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue