Make hexval() available to others.
builtin-mailinfo.c has its own hexval implementaiton but it can share the table-lookup one recently implemented in sha1_file.c Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
62e27f273d
commit
e49521b56d
@ -451,17 +451,6 @@ static int read_one_header_line(char *line, int sz, FILE *in)
|
||||
return ofs;
|
||||
}
|
||||
|
||||
static unsigned hexval(int c)
|
||||
{
|
||||
if (c >= '0' && c <= '9')
|
||||
return c - '0';
|
||||
if (c >= 'a' && c <= 'f')
|
||||
return c - 'a' + 10;
|
||||
if (c >= 'A' && c <= 'F')
|
||||
return c - 'A' + 10;
|
||||
return ~0;
|
||||
}
|
||||
|
||||
static int decode_q_segment(char *in, char *ot, char *ep, int rfc2047)
|
||||
{
|
||||
int c;
|
||||
|
6
cache.h
6
cache.h
@ -278,6 +278,12 @@ enum object_type {
|
||||
OBJ_BAD,
|
||||
};
|
||||
|
||||
extern signed char hexval_table[256];
|
||||
static inline unsigned int hexval(unsigned int c)
|
||||
{
|
||||
return hexval_table[c];
|
||||
}
|
||||
|
||||
/* Convert to/from hex/sha1 representation */
|
||||
#define MINIMUM_ABBREV 4
|
||||
#define DEFAULT_ABBREV 7
|
||||
|
@ -26,9 +26,7 @@ const unsigned char null_sha1[20];
|
||||
|
||||
static unsigned int sha1_file_open_flag = O_NOATIME;
|
||||
|
||||
static inline unsigned int hexval(unsigned int c)
|
||||
{
|
||||
static signed char val[256] = {
|
||||
signed char hexval_table[256] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, /* 00-07 */
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, /* 08-0f */
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, /* 10-17 */
|
||||
@ -62,8 +60,6 @@ static inline unsigned int hexval(unsigned int c)
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, /* f0-f7 */
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, /* f8-ff */
|
||||
};
|
||||
return val[c];
|
||||
}
|
||||
|
||||
int get_sha1_hex(const char *hex, unsigned char *sha1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user