[PATCH 14/20] bootwrapper: Add strtoull().

Scott Wood scottwood at freescale.com
Wed Aug 22 02:20:45 EST 2007


David Gibson wrote:
>>+/* Not currently supported: leading whitespace, sign, 0x prefix, zero base */
>>+unsigned long long int strtoull(const char *ptr, char **end, int base)
>>+{
>>+	unsigned long long ret = 0;
>>+
>>+	while (*ptr) {
>>+		int digit;
>>+
>>+		if (*ptr >= '0' && *ptr <= '9')
>>+			digit = *ptr - '0';
>>+		else if (*ptr >= 'A' && *ptr <= 'Z')
>>+			digit = *ptr - 'A' + 10;
>>+		else if (*ptr >= 'a' && *ptr <= 'z')
>>+			digit = *ptr - 'a' + 10;
>>+		else
>>+			break;
> 
> 
> Hrm... I note this has no sort of error checking if the string has
> digits which don't fit in the given base.

Oops.  I'll fix that.

-Scott



More information about the Linuxppc-dev mailing list