diff options
author | Matt Fleming <matt.fleming@intel.com> | 2012-12-03 13:27:11 +0000 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2012-12-03 13:28:11 +0000 |
commit | 0163d235652d2cc8f0564da7470983ee450a8a91 (patch) | |
tree | 204f3d7e0fed093e1a87c8e774e8ce48887dcc14 | |
parent | 351219ed65d89e439f491196f4eb1119e532fced (diff) | |
download | syslinux-0163d235652d2cc8f0564da7470983ee450a8a91.tar.gz syslinux-0163d235652d2cc8f0564da7470983ee450a8a91.tar.xz syslinux-0163d235652d2cc8f0564da7470983ee450a8a91.zip |
stdio: Fix unhexchar() for hex digits > 9
There was a typographical error in commit 9f51b69d7c050 ("core:
Reimplement lots asm code in C") which re-wrote the asm implementation
of unhexchar() in C. We should be adding 10, not subtracting to get
the equivalent decimal integer. Also be explicit about the sign of
'data' and 'num'.
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r-- | com32/include/stdio.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/com32/include/stdio.h b/com32/include/stdio.h index 902a0e80..813a0edc 100644 --- a/com32/include/stdio.h +++ b/com32/include/stdio.h @@ -124,9 +124,9 @@ __extern int rename(const char *, const char *); * * Returns 0 if 'data' was converted succesfully, -1 otherwise. */ -static inline int unhexchar(char *data) +static inline int unhexchar(unsigned char *data) { - char num = *data; + unsigned char num = *data; if (num >= '0' && num <= '9') { *data = num - '0'; @@ -134,7 +134,7 @@ static inline int unhexchar(char *data) } else { num |= 0x20; /* upper case -> lower case */ if (num >= 'a' && num <= 'f') { - *data = num - 'a' - 10; + *data = num - 'a' + 10; return 0; } } |