* Improved %c usage in our custom fprintf() implementation.

This commit is contained in:
Sam Hocevar 2007-01-17 15:31:40 +00:00 committed by sam
parent 0518c124e7
commit 383ef37246
2 changed files with 9 additions and 9 deletions

View File

@ -83,6 +83,12 @@ void _zz_debug(char const *format, ...)
char i = (char)(unsigned char)va_arg(args, int);
if(i >= 0x20 && i < 0x7f)
write(fd, &i, 1);
else if(i == '\n')
write(fd, "\\n", 2);
else if(i == '\t')
write(fd, "\\t", 2);
else if(i == '\r')
write(fd, "\\r", 2);
else
{
write(fd, "\\x", 2);

View File

@ -287,10 +287,7 @@ size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
ret = ORIG(fn)(stream); \
_zz_disabled = 0; \
FGETC_FUZZ \
if(ret >= 0x20 && ret <= 0x7f) \
debug("%s([%i]) = 0x%02x '%c'", __func__, fd, ret, (char)ret); \
else \
debug("%s([%i]) = 0x%02x", __func__, fd, ret); \
debug("%s([%i]) = '%c'", __func__, fd, ret); \
} while(0)
#undef getc /* can be a macro; we dont want that */
@ -393,10 +390,7 @@ int ungetc(int c, FILE *stream)
_zz_addpos(fd, 1); /* revert what we did */
#endif
if(ret >= 0x20 && ret <= 0x7f)
debug("%s(0x%02x, [%i]) = 0x%02x '%c'", __func__, c, fd, ret, ret);
else
debug("%s(0x%02x, [%i]) = 0x%02x", __func__, c, fd, ret);
debug("%s(0x%02x, [%i]) = '%c'", __func__, c, fd, ret);
return ret;
}
@ -466,7 +460,7 @@ int fclose(FILE *fp)
} \
} \
if(need_delim) \
debug("%s(%p, %p, 0x%02x, [%i]) = %li", __func__, \
debug("%s(%p, %p, '%c', [%i]) = %li", __func__, \
lineptr, n, delim, fd, (long int)ret); \
else \
debug("%s(%p, %p, [%i]) = %li", __func__, \