]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/tt: check for non-printable chars for raw/export format
authorKarel Zak <kzak@redhat.com>
Thu, 26 Apr 2012 07:28:44 +0000 (09:28 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 26 Apr 2012 07:28:44 +0000 (09:28 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/tt.c

index 2d5b16b52616d6d35dc9b5e48eb088d33884715e..1d69a34c4240bd58c85e92da96a47c6ab605b17f 100644 (file)
--- 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);