* Change debug's %c so that it automatically escapes binary characters.

This commit is contained in:
Sam Hocevar
2007-01-09 16:14:31 +00:00
committed by sam
parent 24f3d04a30
commit 4017fc9b93

View File

@@ -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')
{