* 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
const char *ss_proto, *ss_state, *ss_type;
char ss_flags[32];
- /* TODO: currently we stop at first NUL byte. Is it a problem? */
-
if (nr == 0)
return 0; /* skip header */
- *strchrnul(line, '\n') = '\0';
-
/* 2.6.15 may report lines like "... @/tmp/fam-user-^@^@^@^@^@^@^@..."
* Other users report long lines filled by NUL bytes.
* (those ^@ are NUL bytes too). We see them as empty lines. */
strcat(ss_flags, "N ");
strcat(ss_flags, "]");
- printf("%-5s %-6ld %-11s %-10s %-13s %6lu %s\n",
- ss_proto, refcnt, ss_flags, ss_type, ss_state, inode,
- line + path_ofs);
+ printf("%-5s %-6ld %-11s %-10s %-13s %6lu ",
+ ss_proto, refcnt, ss_flags, ss_type, ss_state, inode
+ );
+
+ /* TODO: currently we stop at first NUL byte. Is it a problem? */
+ line += path_ofs;
+ *strchrnul(line, '\n') = '\0';
+ while (*line)
+ fputc_printable(*line++, stdout);
+ bb_putchar('\n');
return 0;
}