diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-09-12 15:34:36 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-09-12 15:34:36 -0700 |
commit | e4ec05ed93bede22b0d79ab58997f0fc170929e9 (patch) | |
tree | f2e445694b466952e89b616977832a641432db9b /cache.h | |
parent | 27853a85edce65afd73c8bb0ca7adf0a4468def3 (diff) | |
parent | d23309733a5b2a9e1adc304ee50c5a5ed7a087c2 (diff) | |
download | git-e4ec05ed93bede22b0d79ab58997f0fc170929e9.tar.gz git-e4ec05ed93bede22b0d79ab58997f0fc170929e9.tar.xz |
Merge branch 'rs/hex2chr'
* rs/hex2chr:
introduce hex2chr() for converting two hexadecimal digits to a character
Diffstat (limited to 'cache.h')
-rw-r--r-- | cache.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -1156,6 +1156,16 @@ static inline unsigned int hexval(unsigned char c) return hexval_table[c]; } +/* + * Convert two consecutive hexadecimal digits into a char. Return a + * negative value on error. Don't run over the end of short strings. + */ +static inline int hex2chr(const char *s) +{ + int val = hexval(s[0]); + return (val < 0) ? val : (val << 4) | hexval(s[1]); +} + /* Convert to/from hex/sha1 representation */ #define MINIMUM_ABBREV minimum_abbrev #define DEFAULT_ABBREV default_abbrev |