git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] use isxdigit() for checking if a character is a hexadecimal digit

From
René Scharfe <l.s.r@web.de>
Date
Mar 9, 2015, 22:46 UTC
Message-ID
<54FE22DE.8090007@web.de>

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>
---
 sha1_name.c | 2 +-
 transport.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sha1_name.c b/sha1_name.c
index 95f9f8f..6d10f05 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -757,7 +757,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.
 			 */
diff --git a/transport.c b/transport.c
index 0694a7c..00f39d9 100644
--- a/transport.c
+++ b/transport.c
@@ -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')
-- 
2.3.1
Message 1 of 1 in “use isxdigit() for checking if a character is a hexadecimal digit”
  1. use isxdigit() for checking if a character is a hexadecimal digitRené Scharfe, Mar 9, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.