From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MGIkO-0002xc-VY for qemu-devel@nongnu.org; Mon, 15 Jun 2009 16:25:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MGIkK-0002r8-Ms for qemu-devel@nongnu.org; Mon, 15 Jun 2009 16:25:40 -0400 Received: from [199.232.76.173] (port=44222 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MGIkK-0002qt-Gc for qemu-devel@nongnu.org; Mon, 15 Jun 2009 16:25:36 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:55555) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MGIkJ-000100-Ve for qemu-devel@nongnu.org; Mon, 15 Jun 2009 16:25:36 -0400 Message-ID: <4A36AE3E.9020002@web.de> Date: Mon, 15 Jun 2009 22:25:34 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig88D774C814BDFF4F80CE1EE1" Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH 2/2] mux-term: Fix timestamp association List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig88D774C814BDFF4F80CE1EE1 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable So far a new timestamp was generated *after* a full line had been printed. Fix this. Signed-off-by: Jan Kiszka --- qemu-char.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index d82a64f..287e0cd 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -238,6 +238,7 @@ typedef struct { int prod[MAX_MUX]; int cons[MAX_MUX]; int timestamps; + int linestart; int64_t timestamps_start; } MuxDriver; =20 @@ -252,9 +253,8 @@ static int mux_chr_write(CharDriverState *chr, const = uint8_t *buf, int len) int i; =20 ret =3D 0; - for(i =3D 0; i < len; i++) { - ret +=3D d->drv->chr_write(d->drv, buf+i, 1); - if (buf[i] =3D=3D '\n') { + for (i =3D 0; i < len; i++) { + if (d->linestart) { char buf1[64]; int64_t ti; int secs; @@ -271,6 +271,11 @@ static int mux_chr_write(CharDriverState *chr, const= uint8_t *buf, int len) secs % 60, (int)(ti % 1000)); d->drv->chr_write(d->drv, (uint8_t *)buf1, strlen(buf1))= ; + d->linestart =3D 0; + } + ret +=3D d->drv->chr_write(d->drv, buf+i, 1); + if (buf[i] =3D=3D '\n') { + d->linestart =3D 1; } } } @@ -360,6 +365,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDri= ver *d, int ch) case 't': d->timestamps =3D !d->timestamps; d->timestamps_start =3D -1; + d->linestart =3D 0; break; } } else if (ch =3D=3D term_escape_char) { --------------enig88D774C814BDFF4F80CE1EE1 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAko2rj4ACgkQniDOoMHTA+mMbgCfazPROweNmGSTWYLLxpjMGwXd ZwgAn35J/4GMrxAjKplaFj+rz4fxk4d7 =6Q8f -----END PGP SIGNATURE----- --------------enig88D774C814BDFF4F80CE1EE1--