libbb: factor out hex2bin() for infiniband address parser

function                                             old     new   delta
hex2bin                                                -     149    +149
in_ib                                                172      27    -145

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2010-04-04 15:29:32 +02:00
parent c03602baa4
commit 4836331924
4 changed files with 46 additions and 49 deletions

View File

@ -282,8 +282,10 @@ static char *gethdr(char *buf, size_t bufsiz, FILE *fp /*, int *istrunc*/)
return NULL;
/* convert the header name to lower case */
for (s = buf; isalnum(*s) || *s == '-' || *s == '.'; ++s)
*s = tolower(*s);
for (s = buf; isalnum(*s) || *s == '-' || *s == '.'; ++s) {
/* tolower for "A-Z", no-op for "0-9a-z-." */
*s = (*s | 0x20);
}
/* verify we are at the end of the header name */
if (*s != ':')