Extracted duplicate hexval().

This commit is contained in:
Daniel Beer 2011-06-06 12:40:50 +12:00
parent 620570691e
commit 39d9f9e499
4 changed files with 14 additions and 22 deletions

12
gdb.c
View File

@ -179,18 +179,6 @@ static void gdb_packet_end(struct gdb_data *data)
gdb_printf(data, "#%02x", c);
}
static int hexval(int c)
{
if (isdigit(c))
return c - '0';
if (isupper(c))
return c - 'A' + 10;
if (islower(c))
return c - 'a' + 10;
return 0;
}
static int gdb_send(struct gdb_data *data, const char *msg)
{
gdb_packet_start(data);

10
srec.c
View File

@ -45,16 +45,6 @@ int srec_check(FILE *in)
return 1;
}
static int hexval(int c)
{
if (isdigit(c))
return c - '0';
if (c >= 'A' && c <= 'F')
return c - 'A' + 10;
return c - 'a' + 10;
}
int srec_extract(FILE *in, binfile_imgcb_t cb, void *user_data)
{
char buf[128];

12
util.c
View File

@ -317,3 +317,15 @@ void debug_hexdump(const char *label, const uint8_t *data, int len)
offset += i;
}
}
int hexval(int c)
{
if (isdigit(c))
return c - '0';
if (isupper(c))
return c - 'A' + 10;
if (islower(c))
return c - 'a' + 10;
return 0;
}

2
util.h
View File

@ -57,4 +57,6 @@ static inline int ishex(int c)
return isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
}
int hexval(int c);
#endif