Strip \r when outputting to stdout on Windows as Windows writes the \r on \n itself.

This commit is contained in:
Moritz Bunkus 2005-08-16 17:14:54 +00:00
parent 837a4bf7bb
commit c6744290e7
3 changed files with 28 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2005-08-16 Moritz Bunkus <moritz@bunkus.org>
* mkvtoolnix: bug fix: On Windows the command line output was
terminated with CR CR NL instead of just CR NL.
2005-08-13 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: bug fix: The Quicktime/MP4 reader wasn't skipping

View File

@ -1333,7 +1333,7 @@ mxmsg(int level,
mm_stdio->puts(prefix);
output = from_utf8(cc_stdio, mxvsprintf(new_fmt.c_str(), ap));
mm_stdio->write(output.c_str(), output.length());
mm_stdio->puts(output);
mm_stdio->flush();
}

View File

@ -484,21 +484,21 @@ mm_io_c::setFilePointer2(int64 offset, seek_mode mode) {
size_t
mm_io_c::puts(const string &s) {
int i;
size_t bytes_written;
const char *cs;
string output, h;
cs = s.c_str();
bytes_written = 0;
for (i = 0; cs[i] != 0; i++)
if (cs[i] != '\r') {
#if defined(SYS_WINDOWS)
if ('\n' == cs[i])
bytes_written += write("\r", 1);
output += "\r";
#endif
bytes_written += write(&cs[i], 1);
}
output += cs[i];
} else if ('\n' != cs[i + 1])
output += "\r";
return bytes_written;
return write(output.c_str(), output.length());
}
uint32_t
@ -1160,7 +1160,23 @@ mm_stdio_c::read(void *buffer,
size_t
mm_stdio_c::write(const void *buffer,
size_t size) {
#if defined(SYS_WINDOWS)
int i, bytes_written;
const char *s;
bytes_written = 0;
s = (const char *)buffer;
for (i = 0; i < size; ++i)
if (('\r' != s[i]) ||
(((i + 1) < size) && ('\n' != s[i + 1])))
bytes_written += fwrite(&s[i], 1, 1, stdout);
return bytes_written;
#else // defined(SYS_WINDOWS)
return fwrite(buffer, 1, size, stdout);
#endif // defined(SYS_WINDOWS)
}
void