From d3c042fc605737643c265a7f86fc7a77c88f629e Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 30 Dec 2007 01:59:53 +0000 Subject: libbb: introduce fputc_printable (from ed) netstat: print control chars as ^C etc vi: style fixlet function old new delta fputc_printable - 100 +100 unix_do_one 451 487 +36 printLines 258 190 -68 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 136/-68) Total: 68 bytes --- include/libbb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/libbb.h b/include/libbb.h index 1da37edb2..f35f85c33 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -426,6 +426,11 @@ char *safe_strncpy(char *dst, const char *src, size_t size); * But potentially slow, don't use in one-billion-times loops */ int bb_putchar(int ch); char *xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); +/* Prints unprintable chars ch as ^C or M-c to file + * (M-c is used only if ch is ORed with PRINTABLE_META), + * else it is printed as-is (except for ch = 0x9b) */ +enum { PRINTABLE_META = 0x100 }; +void fputc_printable(int ch, FILE *file); // gcc-4.1.1 still isn't good enough at optimizing it // (+200 bytes compared to macro) //static ALWAYS_INLINE -- cgit v1.2.3