|
|
@ -1,6 +1,13 @@
|
|
|
|
#include "scan.h"
|
|
|
|
#include "scan.h"
|
|
|
|
|
|
|
|
|
|
|
|
int scan_fromhex(unsigned char c) {
|
|
|
|
int scan_fromhex(unsigned char c) {
|
|
|
|
|
|
|
|
c-='0';
|
|
|
|
|
|
|
|
if (c<=9) return c;
|
|
|
|
|
|
|
|
c&=~0x20;
|
|
|
|
|
|
|
|
c-='A'-'0';
|
|
|
|
|
|
|
|
if (c<6) return c+10;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* more readable but creates worse code:
|
|
|
|
if (c>='0' && c<='9')
|
|
|
|
if (c>='0' && c<='9')
|
|
|
|
return c-'0';
|
|
|
|
return c-'0';
|
|
|
|
else if (c>='A' && c<='F')
|
|
|
|
else if (c>='A' && c<='F')
|
|
|
@ -8,5 +15,6 @@ int scan_fromhex(unsigned char c) {
|
|
|
|
else if (c>='a' && c<='f')
|
|
|
|
else if (c>='a' && c<='f')
|
|
|
|
return c-'a'+10;
|
|
|
|
return c-'a'+10;
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|