This is done to allow reuse of the functin in last(1). Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- include/carefulputc.h | 4 ++-- term-utils/wall.c | 2 +- term-utils/write.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/carefulputc.h b/include/carefulputc.h index 2d857eb..d4d0ee4 100644 --- a/include/carefulputc.h +++ b/include/carefulputc.h @@ -10,7 +10,7 @@ #define iso8859x_iscntrl(c) \ (((c) & 0x7f) < 0x20 || (c) == 0x7f) -static inline int carefulputc(int c, FILE *fp) { +static inline int carefulputc(int c, FILE *fp, const char fail) { int ret; if (c == '\007' || c == '\t' || c == '\r' || c == '\n' || @@ -19,7 +19,7 @@ static inline int carefulputc(int c, FILE *fp) { else if ((c & 0x80) || !isprint(c^0x40)) ret = fprintf(fp, "\\%3o", (unsigned char) c); else { - ret = putc('^', fp); + ret = putc(fail, fp); if (ret != EOF) ret = putc(c^0x40, fp); } diff --git a/term-utils/wall.c b/term-utils/wall.c index f094073..2d87e47 100644 --- a/term-utils/wall.c +++ b/term-utils/wall.c @@ -286,7 +286,7 @@ static char *makemsg(char *fname, char **mvec, int mvecsz, cnt = 0; } if (ch != '\n') - carefulputc(ch, fp); + carefulputc(ch, fp, '^'); } } } diff --git a/term-utils/write.c b/term-utils/write.c index 83937d3..cb3b044 100644 --- a/term-utils/write.c +++ b/term-utils/write.c @@ -372,7 +372,7 @@ void wr_fputs(char *s) { char c; -#define PUTC(c) if (carefulputc(c, stdout) == EOF) \ +#define PUTC(c) if (carefulputc(c, stdout, '^') == EOF) \ err(EXIT_FAILURE, _("carefulputc failed")); while (*s) { c = *s++; -- 1.8.3.4 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html