summaryrefslogtreecommitdiffstats
path: root/urlmatch.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-10-15 18:34:05 -0400
committerJunio C Hamano <gitster@pobox.com>2014-10-16 10:10:36 -0700
commit50a71776ab14c63c72c86e3ce1529052bcb2634a (patch)
treec0027d319cbd238fbc20bf260e7d0d5bb37ac1b6 /urlmatch.c
parentfe1b22686f26bed3047294cc4552e50ce58fa954 (diff)
downloadgit-50a71776ab14c63c72c86e3ce1529052bcb2634a.tar.gz
git-50a71776ab14c63c72c86e3ce1529052bcb2634a.tar.xz
isxdigit: cast input to unsigned char
Otherwise, callers must do so or risk triggering warnings -Wchar-subscript (and rightfully so; a signed char might cause us to use a bogus negative index into the hexval_table). While we are dropping the now-unnecessary casts from the caller in urlmatch.c, we can get rid of similar casts in actually parsing the hex by using the hexval() helper, which implicitly casts to unsigned (but note that we cannot implement isxdigit in terms of hexval(), as it also casts its return value to unsigned). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'urlmatch.c')
-rw-r--r--urlmatch.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/urlmatch.c b/urlmatch.c
index 3d4c54b5c..618d21649 100644
--- a/urlmatch.c
+++ b/urlmatch.c
@@ -43,11 +43,11 @@ static int append_normalized_escapes(struct strbuf *buf,
from_len--;
if (ch == '%') {
if (from_len < 2 ||
- !isxdigit((unsigned char)from[0]) ||
- !isxdigit((unsigned char)from[1]))
+ !isxdigit(from[0]) ||
+ !isxdigit(from[1]))
return 0;
- ch = hexval_table[(unsigned char)*from++] << 4;
- ch |= hexval_table[(unsigned char)*from++];
+ ch = hexval(*from++) << 4;
+ ch |= hexval(*from++);
from_len -= 2;
was_esc = 1;
}