Mercurial > hg > th-libs
changeset 503:12dbe0102d72
Fix a stupid bug in th_get_hex_triplet().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 26 Dec 2019 06:33:35 +0200 |
parents | ebf89497305a |
children | 3a0864eb358f |
files | th_string.c |
diffstat | 1 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/th_string.c Thu Dec 26 05:49:49 2019 +0200 +++ b/th_string.c Thu Dec 26 06:33:35 2019 +0200 @@ -984,30 +984,30 @@ int len; *value = 0; - for (len = 0; *p && len < 6; p++, len++) + for (len = 0; *p && len < 6 * 2; p++, len++) { if (*p >= '0' && *p <= '9') { - (*value) *= 16; - (*value) += (*p - '0'); + (*value) <<= 4; + (*value) |= (*p - '0'); } else if (*p >= 'A' && *p <= 'F') { - (*value) *= 16; - (*value) += (*p - 'A') + 10; + (*value) <<= 4; + (*value) |= (*p - 'A') + 10; } else if (*p >= 'a' && *p <= 'f') { - (*value) *= 16; - (*value) += (*p - 'a') + 10; + (*value) <<= 4; + (*value) |= (*p - 'a') + 10; } else return FALSE; } - return (len == 6); + return (len == 6 * 2); }