Browse Source

[libc] Add isprint()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
a4e8ef72ab
2 changed files with 3 additions and 3 deletions
  1. 2
    3
      src/core/debug.c
  2. 1
    0
      src/include/ctype.h

+ 2
- 3
src/core/debug.c View File

22
 #include <stdio.h>
22
 #include <stdio.h>
23
 #include <stdint.h>
23
 #include <stdint.h>
24
 #include <stdarg.h>
24
 #include <stdarg.h>
25
+#include <ctype.h>
25
 #include <ipxe/console.h>
26
 #include <ipxe/console.h>
26
 
27
 
27
 /**
28
 /**
96
 			continue;
97
 			continue;
97
 		}
98
 		}
98
 		byte = bytes[i];
99
 		byte = bytes[i];
99
-		if ( ( byte < 0x20 ) || ( byte >= 0x7f ) )
100
-			byte = '.';
101
-		dbg_printf ( "%c", byte );
100
+		dbg_printf ( "%c", ( isprint ( byte ) ? byte : '.' ) );
102
 	}
101
 	}
103
 	dbg_printf ( "\n" );
102
 	dbg_printf ( "\n" );
104
 }
103
 }

+ 1
- 0
src/include/ctype.h View File

12
 #define islower(c)	((c) >= 'a' && (c) <= 'z')
12
 #define islower(c)	((c) >= 'a' && (c) <= 'z')
13
 #define isupper(c)	((c) >= 'A' && (c) <= 'Z')
13
 #define isupper(c)	((c) >= 'A' && (c) <= 'Z')
14
 #define isxdigit(c)	(isdigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
14
 #define isxdigit(c)	(isdigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
15
+#define isprint(c)	((c) >= ' ' && (c) <= '~' )
15
 
16
 
16
 static inline unsigned char tolower(unsigned char c)
17
 static inline unsigned char tolower(unsigned char c)
17
 {
18
 {

Loading…
Cancel
Save