]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[libc] Add isprint()
authorMichael Brown <mcb30@ipxe.org>
Fri, 3 Jan 2014 01:21:52 +0000 (02:21 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 6 Jan 2014 00:46:20 +0000 (01:46 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/debug.c
src/include/ctype.h

index 627d5d9a11483c45938fc073bc1006b05db8b6f0..2161f9731dfe3c103ed5fac46c9249e2f7fb3353 100644 (file)
@@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <stdio.h>
 #include <stdint.h>
 #include <stdarg.h>
+#include <ctype.h>
 #include <ipxe/console.h>
 
 /**
@@ -96,9 +97,7 @@ static void dbg_hex_dump_da_row ( unsigned long dispaddr, const void *data,
                        continue;
                }
                byte = bytes[i];
-               if ( ( byte < 0x20 ) || ( byte >= 0x7f ) )
-                       byte = '.';
-               dbg_printf ( "%c", byte );
+               dbg_printf ( "%c", ( isprint ( byte ) ? byte : '.' ) );
        }
        dbg_printf ( "\n" );
 }
index 9f5127bf1cdf7ef49c54a12f4e6eb4e477dec579..e92ecb1c0b19fa958d14f9504f36c3a3fa432c20 100644 (file)
@@ -12,6 +12,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #define islower(c)     ((c) >= 'a' && (c) <= 'z')
 #define isupper(c)     ((c) >= 'A' && (c) <= 'Z')
 #define isxdigit(c)    (isdigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
+#define isprint(c)     ((c) >= ' ' && (c) <= '~' )
 
 static inline unsigned char tolower(unsigned char c)
 {