Fixed gw_hex2bin: problems calling char_val.
If we want tu use a compact implementation, we should use static inline uint8 char_val(uint8 X) { return (uint) (X >= '0' && X <= '9' ? X-'0' : X >= 'A' && X <= 'Z' ? X-'A'+10 : X-'a'+10); }
This commit is contained in:
@ -703,8 +703,13 @@ int gw_hex2bin(uint8_t *out, const char *in, unsigned int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (in < in_end) {
|
while (in < in_end) {
|
||||||
register char tmp_ptr = char_val(*in++);
|
register unsigned char b1 = char_val(*in);
|
||||||
*out++= (tmp_ptr << 4) | char_val(*in++);
|
uint8_t b2 = 0;
|
||||||
|
in++;
|
||||||
|
b2 = (b1 << 4) | char_val(*in);
|
||||||
|
*out++ = b2;
|
||||||
|
|
||||||
|
in++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user