From 4017fc9b93c27829d5272ddea328f2dfeab77776 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 9 Jan 2007 16:14:31 +0000 Subject: [PATCH] * Change debug's %c so that it automatically escapes binary characters. --- src/debug.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/debug.c b/src/debug.c index f46d729..d54af46 100644 --- a/src/debug.c +++ b/src/debug.c @@ -81,7 +81,14 @@ void _zz_debug(char const *format, ...) if(*f == 'c') { char i = (char)(unsigned char)va_arg(args, int); - write(fd, &i, 1); + if(i >= 0x20 && i < 0x7f) + write(fd, &i, 1); + else + { + write(fd, "\\x", 2); + write(fd, hex2char + ((i & 0xf0) >> 4), 1); + write(fd, hex2char + (i & 0x0f), 1); + } } else if(*f == 'i') {