use isxdigit() for checking if a character is a hexadecimal digit
authorRené Scharfe <l.s.r@web.de>
Mon, 9 Mar 2015 22:46:54 +0000 (23:46 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Mar 2015 22:44:41 +0000 (15:44 -0700)
Use the standard function isxdigit() to make the intent clearer and
avoid using magic constants.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_name.c
transport.c

index c2c938c..dc85aaf 100644 (file)
@@ -749,7 +749,7 @@ static int get_describe_name(const char *name, int len, unsigned char *sha1)
 
        for (cp = name + len - 1; name + 2 <= cp; cp--) {
                char ch = *cp;
-               if (hexval(ch) & ~0377) {
+               if (!isxdigit(ch)) {
                        /* We must be looking at g in "SOMETHING-g"
                         * for it to be describe output.
                         */
index 325f03e..7ac0df2 100644 (file)
@@ -117,7 +117,7 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
                        return;
                }
 
-               if (hexval(buffer[0]) > 0xf)
+               if (!isxdigit(buffer[0]))
                        continue;
                len = strlen(buffer);
                if (len && buffer[len - 1] == '\n')