From 4e0e3bf35d0fac7fe0cdb36ff5f1050a8ec9da8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 7 Dec 2004 16:10:03 +0000 Subject: [PATCH] Some cosmetics. The string for unknown types no longer tries to print unprintable characters, but replaces them with '.'; when there is more than one unprintable character in the type code, it will show the hexcode instead. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10367 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/bin/listattr.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/apps/bin/listattr.cpp b/src/apps/bin/listattr.cpp index baa342b33d..3dd2268b39 100644 --- a/src/apps/bin/listattr.cpp +++ b/src/apps/bin/listattr.cpp @@ -58,9 +58,23 @@ get_type(type_code type) return "Icon"; default: - sprintf(buffer, "'%c%c%c%c'", - uint8(type >> 24), uint8(type >> 16), uint8(type >> 8), uint8(type)); + { + int32 missed = 0, shift = 24; + uint8 value[4]; + for (int32 i = 0; i < 4; i++, shift -= 8) { + value[i] = uint8(type >> shift); + if (value[i] < ' ' || value[i] > 127) { + value[i] = '.'; + missed++; + } + } + + if (missed < 2) + sprintf(buffer, "'%c%c%c%c'", value[0], value[1], value[2], value[3]); + else + sprintf(buffer, "0x%08lx", type); return buffer; + } } } @@ -91,7 +105,7 @@ main(int argc, char *argv[]) return 0; } - printf("file %s\n", argv[i]); + printf("File: %s\n", argv[i]); printf(" Type Size Name\n"); printf("----------- --------- -------------------------------\n");