Fixed bug which caused extra newlines to be added at the end of file.

Originally committed to SVN as r221.
This commit is contained in:
Rodrigo Braz Monteiro 2006-03-13 22:25:09 +00:00
parent cb2c5ed6e7
commit 8f8952293b
4 changed files with 16 additions and 6 deletions

View File

@ -66,6 +66,7 @@ Please visit http://aegisub.net to download latest version
- Removed video frame/subtitles time sync controls from the grid context menu. (AMZ)
- Timeline is now drawn below audio display. (AMZ)
- Dragging the timeline will now scroll audio display. (AMZ)
- Fixed bug which caused extra newlines to be added at the end of file. (AMZ)
= 1.09 beta - 2006.01.16 ===========================

View File

@ -110,8 +110,17 @@ void ASSSubtitleFormat::WriteFile(wxString _filename,wxString encoding) {
// Write lines
using std::list;
for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) {
if (ssa) file.WriteLineToFile((*cur)->GetSSAText());
else file.WriteLineToFile((*cur)->GetEntryData());
AssEntry *entry;
for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();) {
// Get entry
entry = *cur;
// Only add a line break if there is a next line
cur++;
bool lineBreak = cur != Line->end();
// Write line
if (ssa) file.WriteLineToFile(entry->GetSSAText(),lineBreak);
else file.WriteLineToFile(entry->GetEntryData(),lineBreak);
}
}

View File

@ -101,13 +101,13 @@ void TextFileWriter::Close() {
/////////////////
// Write to file
void TextFileWriter::WriteLineToFile(wxString line) {
void TextFileWriter::WriteLineToFile(wxString line,bool addLineBreak) {
// Make sure it's loaded
if (!open) Open();
// Add line break
wxString temp = line;
temp += _T("\r\n");
if (addLineBreak) temp += _T("\r\n");
// Add BOM if it's the first line and the target format is Unicode
if (IsFirst && IsUnicode) {

View File

@ -65,7 +65,7 @@ public:
TextFileWriter(wxString filename,wxString encoding=_T(""));
~TextFileWriter();
void WriteLineToFile(wxString line);
void WriteLineToFile(wxString line,bool addLineBreak=true);
};