[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] start using c-ctype functions



Daniel Veillard <veillard redhat com> wrote:
>> +/* Convert C from hexadecimal character to integer.  */
>> +static int
>> +hextobin (unsigned char c)
>> +{
>> +  switch (c)
>> +    {
>> +    default: return c - '0';
>> +    case 'a': case 'A': return 10;
>> +    case 'b': case 'B': return 11;
>> +    case 'c': case 'C': return 12;
>> +    case 'd': case 'D': return 13;
>> +    case 'e': case 'E': return 14;
>> +    case 'f': case 'F': return 15;
>> +    }
>> +}
>
>   putting the default first feels strange to me, i guess it's the
> first time I see a switch that way.

BTW, I too found that odd.
It's copied verbatim from coreutils/src/echo.c ;-)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]