src/lib/ppc405lib/strtox.c
// Parse a character as a radix-base digit.  Return the value of the digit or
// -1 if it is not a legal digit for the radix.
Parse a character as a radix-base digit.  Return the value of the digit or
1 if it is not a legal digit for the radix.
Parse a character as a radix - base digit . Return the value of the digit or 1 if it is not a legal digit for the radix .
static int
parse_digit(char c, int radix)
{
    if (isdigit(c)) {
        if ((c - '0') < radix) {
            return c - '0';
        } else {
            return -1;
        }
    } else if (radix <= 10) {
        return -1;
    } else {
        if (islower(c)) {
            if ((c - 'a') < (radix - 10)) {
                return c - 'a' + 10;
            } else {
                return -1;
            }
        } else if (isupper(c)) {
            if ((c - 'A') < (radix - 10)) {
                return c - 'A' + 10;
            } else {
                return -1;
            }
        } else {
            return -1;
        }
    }
}
static int parse_digit ( char c , int radix ) { if ( isdigit ( c ) ) { if ( ( c - ' ' ) < radix ) { return c - ' ' ; } else { return -1 ; } } else if ( radix <= 10 ) { return -1 ; } else { if ( islower ( c ) ) { if ( ( c - ' ' ) < ( radix - 10 ) ) { return c - ' ' + 10 ; } else { return -1 ; } } else if ( isupper ( c ) ) { if ( ( c - ' ' ) < ( radix - 10 ) ) { return c - ' ' + 10 ; } else { return -1 ; } } else { return -1 ; } } }
Parse a character as a radix-base digit.
Parse a character as a radix - base digit .