diff options
author | Chris Kuethe <chris.kuethe@gmail.com> | 2007-03-27 06:14:39 +0000 |
---|---|---|
committer | Chris Kuethe <chris.kuethe@gmail.com> | 2007-03-27 06:14:39 +0000 |
commit | 13c3eb1ca0fd303a9dc88d70a6f80b356c421818 (patch) | |
tree | dfb33a2332f27c02176ca9b66769aa825f96ddbd /hex.c | |
parent | f80e73829dc3a71f2fda25636fbb0a360214c8a7 (diff) | |
download | gpsd-13c3eb1ca0fd303a9dc88d70a6f80b356c421818.tar.gz |
too much thinking about regexes i think. hex use a-f, not a-z.
Diffstat (limited to 'hex.c')
-rw-r--r-- | hex.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -54,18 +54,18 @@ int hex2bin(char *s) a = s[0] & 0xff; b = s[1] & 0xff; - if ((a >= 'a') && (a <= 'z')) + if ((a >= 'a') && (a <= 'f')) a = a + 10 - 'a'; - else if ((a >= 'A') && (a <= 'Z')) + else if ((a >= 'A') && (a <= 'F')) a = a + 10 - 'A'; else if ((a >= '0') && (a <= '9')) a -= '0'; else return -1; - if ((b >= 'a') && (b <= 'z')) + if ((b >= 'a') && (b <= 'f')) b = b + 10 - 'a'; - else if ((b >= 'A') && (b <= 'Z')) + else if ((b >= 'A') && (b <= 'F')) b = b + 10 - 'A'; else if ((b >= '0') && (b <= '9')) b -= '0'; |