diff --git a/ChangeLog b/ChangeLog index 582b7ec0f..689feffa3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2005-05-05 Moritz Bunkus + * 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 the "Format=" line contained newlines at the end of the CodecPrivate data (e.g. our old Mew Mew sample file). diff --git a/src/common/mm_io.cpp b/src/common/mm_io.cpp index 22b2bfdc8..459b584d4 100644 --- a/src/common/mm_io.cpp +++ b/src/common/mm_io.cpp @@ -482,7 +482,7 @@ mm_io_c::setFilePointer2(int64 offset, seek_mode mode) { } size_t -mm_io_c::puts_unl(const string &s) { +mm_io_c::puts(const string &s) { int i; size_t bytes_written; const char *cs; @@ -490,8 +490,13 @@ mm_io_c::puts_unl(const string &s) { cs = s.c_str(); bytes_written = 0; 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); + } return bytes_written; } diff --git a/src/common/mm_io.h b/src/common/mm_io.h index 06326518c..b07908872 100644 --- a/src/common/mm_io.h +++ b/src/common/mm_io.h @@ -69,7 +69,7 @@ public: virtual string getline(); 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 int getch(); diff --git a/src/extract/xtr_textsubs.cpp b/src/extract/xtr_textsubs.cpp index 57e0f2037..e9e28436d 100644 --- a/src/extract/xtr_textsubs.cpp +++ b/src/extract/xtr_textsubs.cpp @@ -76,7 +76,7 @@ xtr_srt_c::handle_block(KaxBlock &block, end / 1000 / 60 / 60, (end / 1000 / 60) % 60, (end / 1000) % 60, end % 1000, from_utf8(conv, text).c_str()); - out->puts_unl(buffer); + out->puts(buffer); delete []text; } @@ -169,7 +169,7 @@ xtr_ssa_c::create_file(xtr_base_c *_master, ssa_format[pos1] = downcase(ssa_format[pos1]); sconv = from_utf8(conv, sconv); - out->puts_unl(sconv); + out->puts(sconv); } void @@ -275,6 +275,6 @@ xtr_ssa_c::finish_file() { // write them. sort(lines.begin(), lines.end()); for (i = 0; i < lines.size(); i++) - out->puts_unl(lines[i].line.c_str()); + out->puts(lines[i].line.c_str()); } diff --git a/src/input/r_ogm.cpp b/src/input/r_ogm.cpp index e01bc65a5..05fd5ea7a 100644 --- a/src/input/r_ogm.cpp +++ b/src/input/r_ogm.cpp @@ -1170,10 +1170,8 @@ ogm_reader_c::handle_stream_comments() { try { out = new mm_mem_io_c(NULL, 0, 1000); out->write_bom("UTF-8"); - for (j = 0; j < chapters.size(); j++) { - out->puts_unl(to_utf8(cch, chapters[j])); - out->puts_unl("\n"); - } + for (j = 0; j < chapters.size(); j++) + out->puts(to_utf8(cch, chapters[j]) + string("\n")); out->set_file_name(ti.fname); kax_chapters = parse_chapters(new mm_text_io_c(out)); } catch (...) {