Skip to content

Commit

Permalink
use isxdigit() for checking if a character is a hexadecimal digit
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Mar 10, 2015
1 parent 282616c commit 6f75d45
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sha1_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 6f75d45

Please sign in to comment.