From 91577d08988638929266667ee0e77c84f8af47c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20H=C3=A5llberg?= Date: Sat, 17 Jan 2009 00:49:41 +0100 Subject: bugfixed #capture together with multibyte output locales such as UTF-8 diff --git a/ChangeLog.old b/ChangeLog.old index c704f2c..45577ac 100644 --- a/ChangeLog.old +++ b/ChangeLog.old @@ -1,5 +1,7 @@ 2009-01-06 dain + * log.c: Bugfixed #capture together with multi-byte locales such + as UTF-8. * beam.c, tcp.c, tcp.h: Fixed IAC handling inside MPI messages. Still not done properly, but double IACs are converted to one ASCII 255, and message length is correctly computed. diff --git a/log.c b/log.c index 24deddc..f539330 100644 --- a/log.c +++ b/log.c @@ -207,11 +207,14 @@ void log_write __P3 (char *,str, int,len, int,newline) movie_last = now; do { - if ((next = memchr(str, '\n', len))) + if ((next = memchr(str, '\n', len))) { i = next - str; - else - i = len, last = 1; - + newline = 1; + } else { + i = len; + last = 1; + } + if (datasize) log_writeline(str, i, last && !newline ? PROMPT : LINE, diff); else { @@ -222,9 +225,13 @@ void log_write __P3 (char *,str, int,len, int,newline) fprintf(moviefile, "%s %.*s\n", names[last && !newline ? PROMPT : LINE], i, str); } - if (capturefile) - fprintf(capturefile, "%.*s%s", - i, str, last && !newline ? "" : "\n"); + if (capturefile) { + fwrite(str, 1, i, capturefile); + if (newline) { + const char nl[1] = "\n"; + fwrite(nl, 1, 1, capturefile); + } + } } diff = 0; if (next) { -- cgit v0.10.2