summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-09-19 20:51:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-19 20:51:43 (GMT)
commitc3befaeab9ebd0def9f03d434a52cf40614c65f9 (patch)
treeeaa41d9b527b3bdb4c8a6a78443a9277e1c5740f /pretty.c
parent815a73f7143214510fae6e8a2f2077b2e8694509 (diff)
parentd23309733a5b2a9e1adc304ee50c5a5ed7a087c2 (diff)
downloadgit-c3befaeab9ebd0def9f03d434a52cf40614c65f9.zip
git-c3befaeab9ebd0def9f03d434a52cf40614c65f9.tar.gz
git-c3befaeab9ebd0def9f03d434a52cf40614c65f9.tar.bz2
Merge branch 'rs/hex2chr' into maint
Code cleanup. * rs/hex2chr: introduce hex2chr() for converting two hexadecimal digits to a character
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/pretty.c b/pretty.c
index 9609afb..9788bd8 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1065,7 +1065,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
const struct commit *commit = c->commit;
const char *msg = c->message;
struct commit_list *p;
- int h1, h2;
+ int ch;
/* these are independent of the commit */
switch (placeholder[0]) {
@@ -1089,14 +1089,11 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
return 1;
case 'x':
/* %x00 == NUL, %x0a == LF, etc. */
- if (0 <= (h1 = hexval_table[0xff & placeholder[1]]) &&
- h1 <= 16 &&
- 0 <= (h2 = hexval_table[0xff & placeholder[2]]) &&
- h2 <= 16) {
- strbuf_addch(sb, (h1<<4)|h2);
- return 3;
- } else
+ ch = hex2chr(placeholder + 1);
+ if (ch < 0)
return 0;
+ strbuf_addch(sb, ch);
+ return 3;
case 'w':
if (placeholder[1] == '(') {
unsigned long width = 0, indent1 = 0, indent2 = 0;