From: Karel Zak Date: Thu, 26 Apr 2012 07:28:44 +0000 (+0200) Subject: lib/tt: check for non-printable chars for raw/export format X-Git-Tag: v2.22-rc1~478 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f6efe5024c9c47c0c88a928be63cc31e27c1cab3;p=thirdparty%2Futil-linux.git lib/tt: check for non-printable chars for raw/export format Signed-off-by: Karel Zak --- diff --git a/lib/tt.c b/lib/tt.c index 2d5b16b526..1d69a34c42 100644 --- a/lib/tt.c +++ b/lib/tt.c @@ -559,8 +559,8 @@ static void fputs_quoted(const char *data, FILE *out) fputc('"', out); for (p = data; p && *p; p++) { - if ((unsigned char) *p == 0x22) - fputs("\\x22", out); + if ((unsigned char) *p == 0x22 || !isprint((unsigned char) *p)) + fprintf(out, "\\x%02x", *p); else fputc(*p, out); } @@ -572,7 +572,7 @@ static void fputs_nonblank(const char *data, FILE *out) const char *p; for (p = data; p && *p; p++) { - if (isblank((unsigned char) *p)) + if (isblank((unsigned char) *p) || !isprint((unsigned char) *p)) fprintf(out, "\\x%02x", *p); else fputc(*p, out);