Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
352 B

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