Bladeren bron

[libc] Add isprint()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 jaren geleden
bovenliggende
commit
a4e8ef72ab
2 gewijzigde bestanden met toevoegingen van 3 en 3 verwijderingen
  1. 2
    3
      src/core/debug.c
  2. 1
    0
      src/include/ctype.h

+ 2
- 3
src/core/debug.c Bestand weergeven

@@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
22 22
 #include <stdio.h>
23 23
 #include <stdint.h>
24 24
 #include <stdarg.h>
25
+#include <ctype.h>
25 26
 #include <ipxe/console.h>
26 27
 
27 28
 /**
@@ -96,9 +97,7 @@ static void dbg_hex_dump_da_row ( unsigned long dispaddr, const void *data,
96 97
 			continue;
97 98
 		}
98 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 102
 	dbg_printf ( "\n" );
104 103
 }

+ 1
- 0
src/include/ctype.h Bestand weergeven

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

Laden…
Annuleren
Opslaan