aboutsummaryrefslogtreecommitdiffstats
path: root/ref-filter.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-09-19 13:51:43 -0700
committerJunio C Hamano <gitster@pobox.com>2016-09-19 13:51:43 -0700
commitc3befaeab9ebd0def9f03d434a52cf40614c65f9 (patch)
treeeaa41d9b527b3bdb4c8a6a78443a9277e1c5740f /ref-filter.c
parentMerge branch 'rs/compat-strdup' into maint (diff)
parentintroduce hex2chr() for converting two hexadecimal digits to a character (diff)
downloadgit-c3befaeab9ebd0def9f03d434a52cf40614c65f9.tar.gz
git-c3befaeab9ebd0def9f03d434a52cf40614c65f9.zip
Merge branch 'rs/hex2chr' into maint
Code cleanup. * rs/hex2chr: introduce hex2chr() for converting two hexadecimal digits to a character
Diffstat (limited to 'ref-filter.c')
-rw-r--r--ref-filter.c20
1 files changed, 1 insertions, 19 deletions
diff --git a/ref-filter.c b/ref-filter.c
index bc551a752c..9adbb8af3e 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1576,24 +1576,6 @@ void ref_array_sort(struct ref_sorting *sorting, struct ref_array *array)
qsort(array->items, array->nr, sizeof(struct ref_array_item *), compare_refs);
}
-static int hex1(char ch)
-{
- if ('0' <= ch && ch <= '9')
- return ch - '0';
- else if ('a' <= ch && ch <= 'f')
- return ch - 'a' + 10;
- else if ('A' <= ch && ch <= 'F')
- return ch - 'A' + 10;
- return -1;
-}
-static int hex2(const char *cp)
-{
- if (cp[0] && cp[1])
- return (hex1(cp[0]) << 4) | hex1(cp[1]);
- else
- return -1;
-}
-
static void append_literal(const char *cp, const char *ep, struct ref_formatting_state *state)
{
struct strbuf *s = &state->stack->output;
@@ -1603,7 +1585,7 @@ static void append_literal(const char *cp, const char *ep, struct ref_formatting
if (cp[1] == '%')
cp++;
else {
- int ch = hex2(cp + 1);
+ int ch = hex2chr(cp + 1);
if (0 <= ch) {
strbuf_addch(s, ch);
cp += 3;