X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftv%2Fstrcalc.c;h=50aaf56896fe0a58115b19d22fc6cb4843b15d41;hb=0d61f4e9a295d71deca66e1580273e484e7f0f9f;hp=d57f0f168aa04a130b8913dfe485cb99d9838236;hpb=c496fb7a06926c15967ea635fd95a9c78e74d6bc;p=libfirm diff --git a/ir/tv/strcalc.c b/ir/tv/strcalc.c index d57f0f168..50aaf5689 100644 --- a/ir/tv/strcalc.c +++ b/ir/tv/strcalc.c @@ -817,15 +817,7 @@ void sign_extend(void *buffer, ir_mode *mode) * The C-standard does theoretically allow otherwise. */ static inline void check_ascii(void) { - assert('1'-'0' == 1 - && '2'-'0' == 2 - && '3'-'0' == 3 - && '4'-'0' == 4 - && '5'-'0' == 5 - && '6'-'0' == 6 - && '7'-'0' == 7 - && '8'-'0' == 8 - && '9'-'0' == 9); + /* C standard guarantees that '0'-'9' is a range */ assert('b'-'a' == 1 && 'c'-'a' == 2 && 'd'-'a' == 3 @@ -865,10 +857,10 @@ int sc_val_from_str(char sign, unsigned base, const char *str, unsigned v; if (c >= '0' && c <= '9') v = c - '0'; - else if (c >= 'A' && c <= 'Z') - v = c - 'A'; - else if (c >= 'a' && c <= 'z') - v = c - 'z'; + else if (c >= 'A' && c <= 'F') + v = c - 'A' + 10; + else if (c >= 'a' && c <= 'f') + v = c - 'a' + 10; else return 0;