mirror of https://github.com/odrling/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
|
@ -103,8 +103,7 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
|||
wxString curLine = file.ReadLineFromFile();
|
||||
fileLine++;
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
if (mode == 0) {
|
||||
// Checks if there is anything to read
|
||||
if (curLine.IsEmpty()) continue;
|
||||
|
||||
|
@ -121,9 +120,9 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
|||
}
|
||||
line = new AssDialogue();
|
||||
mode = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
else if (mode == 1) {
|
||||
// Read timestamps
|
||||
if (curLine.substr(13,3) != _T("-->")) {
|
||||
Clear();
|
||||
|
@ -132,11 +131,21 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
|||
line->Start.ParseSRT(curLine.substr(0,12));
|
||||
line->End.ParseSRT(curLine.substr(17,12));
|
||||
mode = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
else if (mode == 2) {
|
||||
// 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;
|
||||
linen++;
|
||||
line->group = _T("[Events]");
|
||||
|
@ -147,12 +156,7 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
|||
line->StartMS = line->Start.GetMS();
|
||||
Line->push_back(line);
|
||||
lines++;
|
||||
break;
|
||||
}
|
||||
// Append text
|
||||
if (line->Text != _T("")) line->Text += _T("\\N");
|
||||
line->Text += curLine;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue