* remote.c (escape_buffer): New.

(putpkt_binary, read_frame, getpkt_or_notif_sane_1): Use it.  Make
	sure debug output printing a packet buffer goes through a single
	fprintf_unfiltered call.
	* utils.c (vfprintf_unfiltered): If outputting timestamps, end
	output with a newline if it wasn't going to already.
This commit is contained in:
Pedro Alves 2008-11-19 14:45:09 +00:00
parent c91e322a29
commit 6e5abd65ae
3 changed files with 84 additions and 19 deletions

View file

@ -2286,13 +2286,22 @@ vfprintf_unfiltered (struct ui_file *stream, const char *format, va_list args)
{
struct timeval tm;
char *timestamp;
int len, need_nl;
gettimeofday (&tm, NULL);
timestamp = xstrprintf ("%ld:%ld ", (long) tm.tv_sec, (long) tm.tv_usec);
len = strlen (linebuffer);
need_nl = (len > 0 && linebuffer[len - 1] != '\n');
timestamp = xstrprintf ("%ld:%ld %s%s",
(long) tm.tv_sec, (long) tm.tv_usec,
linebuffer,
need_nl ? "\n": "");
make_cleanup (xfree, timestamp);
fputs_unfiltered (timestamp, stream);
}
fputs_unfiltered (linebuffer, stream);
else
fputs_unfiltered (linebuffer, stream);
do_cleanups (old_cleanups);
}