Output text lines with new lines according to the OS (\r\n on Windows, \n on all other systems).

This commit is contained in:
Moritz Bunkus 2005-05-05 14:51:30 +00:00
parent 8cca15fa07
commit e8cdd29702
5 changed files with 17 additions and 10 deletions

View File

@ -1,5 +1,9 @@
2005-05-05 Moritz Bunkus <moritz@bunkus.org> 2005-05-05 Moritz Bunkus <moritz@bunkus.org>
* mkvextract: bug fix: Use the native newline style when
extracting text subtitles (\r\n on Windows and \n on all other
systems).
* mkvextract: bug fix: SSA/ASS text was missing in the output if * mkvextract: bug fix: SSA/ASS text was missing in the output if
the "Format=" line contained newlines at the end of the the "Format=" line contained newlines at the end of the
CodecPrivate data (e.g. our old Mew Mew sample file). CodecPrivate data (e.g. our old Mew Mew sample file).

View File

@ -482,7 +482,7 @@ mm_io_c::setFilePointer2(int64 offset, seek_mode mode) {
} }
size_t size_t
mm_io_c::puts_unl(const string &s) { mm_io_c::puts(const string &s) {
int i; int i;
size_t bytes_written; size_t bytes_written;
const char *cs; const char *cs;
@ -490,8 +490,13 @@ mm_io_c::puts_unl(const string &s) {
cs = s.c_str(); cs = s.c_str();
bytes_written = 0; bytes_written = 0;
for (i = 0; cs[i] != 0; i++) for (i = 0; cs[i] != 0; i++)
if (cs[i] != '\r') if (cs[i] != '\r') {
#if defined(SYS_WINDOWS)
if ('\n' == cs[i])
bytes_written += write("\r", 1);
#endif
bytes_written += write(&cs[i], 1); bytes_written += write(&cs[i], 1);
}
return bytes_written; return bytes_written;
} }

View File

@ -69,7 +69,7 @@ public:
virtual string getline(); virtual string getline();
virtual bool getline2(string &s); virtual bool getline2(string &s);
virtual size_t puts_unl(const string &s); virtual size_t puts(const string &s);
virtual bool write_bom(const string &charset); virtual bool write_bom(const string &charset);
virtual int getch(); virtual int getch();

View File

@ -76,7 +76,7 @@ xtr_srt_c::handle_block(KaxBlock &block,
end / 1000 / 60 / 60, (end / 1000 / 60) % 60, end / 1000 / 60 / 60, (end / 1000 / 60) % 60,
(end / 1000) % 60, end % 1000, (end / 1000) % 60, end % 1000,
from_utf8(conv, text).c_str()); from_utf8(conv, text).c_str());
out->puts_unl(buffer); out->puts(buffer);
delete []text; delete []text;
} }
@ -169,7 +169,7 @@ xtr_ssa_c::create_file(xtr_base_c *_master,
ssa_format[pos1] = downcase(ssa_format[pos1]); ssa_format[pos1] = downcase(ssa_format[pos1]);
sconv = from_utf8(conv, sconv); sconv = from_utf8(conv, sconv);
out->puts_unl(sconv); out->puts(sconv);
} }
void void
@ -275,6 +275,6 @@ xtr_ssa_c::finish_file() {
// write them. // write them.
sort(lines.begin(), lines.end()); sort(lines.begin(), lines.end());
for (i = 0; i < lines.size(); i++) for (i = 0; i < lines.size(); i++)
out->puts_unl(lines[i].line.c_str()); out->puts(lines[i].line.c_str());
} }

View File

@ -1170,10 +1170,8 @@ ogm_reader_c::handle_stream_comments() {
try { try {
out = new mm_mem_io_c(NULL, 0, 1000); out = new mm_mem_io_c(NULL, 0, 1000);
out->write_bom("UTF-8"); out->write_bom("UTF-8");
for (j = 0; j < chapters.size(); j++) { for (j = 0; j < chapters.size(); j++)
out->puts_unl(to_utf8(cch, chapters[j])); out->puts(to_utf8(cch, chapters[j]) + string("\n"));
out->puts_unl("\n");
}
out->set_file_name(ti.fname); out->set_file_name(ti.fname);
kax_chapters = parse_chapters(new mm_text_io_c(out)); kax_chapters = parse_chapters(new mm_text_io_c(out));
} catch (...) { } catch (...) {