diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 2001-12-07 16:33:47 +0000 | 
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 2001-12-07 16:33:47 +0000 | 
| commit | f34b139cda7501c64f60f699c87a263197d3dd90 (patch) | |
| tree | 0ee33353ca59b5c4ce8509619edbc992775dbc25 /lib | |
| parent | 6cbb6156c3103066f1cbe21d8962068e71bee5a1 (diff) | |
Notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/stdlib/strtoimax.c | 22 | ||||
| -rw-r--r-- | lib/libc/stdlib/strtol.c | 22 | ||||
| -rw-r--r-- | lib/libc/stdlib/strtoll.c | 22 | ||||
| -rw-r--r-- | lib/libc/stdlib/strtoul.c | 22 | ||||
| -rw-r--r-- | lib/libc/stdlib/strtoull.c | 22 | ||||
| -rw-r--r-- | lib/libc/stdlib/strtoumax.c | 22 | 
6 files changed, 72 insertions, 60 deletions
| diff --git a/lib/libc/stdlib/strtoimax.c b/lib/libc/stdlib/strtoimax.c index 958e72ae2b43..00c252cbf0d9 100644 --- a/lib/libc/stdlib/strtoimax.c +++ b/lib/libc/stdlib/strtoimax.c @@ -56,9 +56,9 @@ strtoimax(nptr, endptr, base)  {  	const char *s;  	uintmax_t acc; -	unsigned char c; +	char c;  	uintmax_t cutoff; -	int neg, any, cutlim, n; +	int neg, any, cutlim;  	/*  	 * Skip white space and pick up leading +/- sign if any. @@ -68,7 +68,7 @@ strtoimax(nptr, endptr, base)  	s = nptr;  	do {  		c = *s++; -	} while (isspace(c)); +	} while (isspace((unsigned char)c));  	if (c == '-') {  		neg = 1;  		c = *s++; @@ -112,20 +112,22 @@ strtoimax(nptr, endptr, base)  	cutlim = cutoff % base;  	cutoff /= base;  	for ( ; ; c = *s++) { -		if (isxdigit(c)) -			n = digittoint(c); -		else if (isalpha(c)) -			n = (char)c - (isupper(c) ? 'A' - 10 : 'a' - 10); +		if (c >= '0' && c <= '9') +			c -= '0'; +		else if (c >= 'A' && c <= 'Z') +			c -= 'A' - 10; +		else if (c >= 'a' && c <= 'z') +			c -= 'a' - 10;  		else  			break; -		if (n < 0 || n >= base) +		if (c >= base)  			break; -		if (any < 0 || acc > cutoff || (acc == cutoff && n > cutlim)) +		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))  			any = -1;  		else {  			any = 1;  			acc *= base; -			acc += n; +			acc += c;  		}  	}  	if (any < 0) { diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c index 449f3c595019..622f1d8a408f 100644 --- a/lib/libc/stdlib/strtol.c +++ b/lib/libc/stdlib/strtol.c @@ -57,9 +57,9 @@ strtol(nptr, endptr, base)  {  	const char *s;  	unsigned long acc; -	unsigned char c; +	char c;  	unsigned long cutoff; -	int neg, any, cutlim, n; +	int neg, any, cutlim;  	/*  	 * Skip white space and pick up leading +/- sign if any. @@ -69,7 +69,7 @@ strtol(nptr, endptr, base)  	s = nptr;  	do {  		c = *s++; -	} while (isspace(c)); +	} while (isspace((unsigned char)c));  	if (c == '-') {  		neg = 1;  		c = *s++; @@ -112,20 +112,22 @@ strtol(nptr, endptr, base)  	cutlim = cutoff % base;  	cutoff /= base;  	for ( ; ; c = *s++) { -		if (isxdigit(c)) -			n = digittoint(c); -		else if (isalpha(c)) -			n = (char)c - (isupper(c) ? 'A' - 10 : 'a' - 10); +		if (c >= '0' && c <= '9') +			c -= '0'; +		else if (c >= 'A' && c <= 'Z') +			c -= 'A' - 10; +		else if (c >= 'a' && c <= 'z') +			c -= 'a' - 10;  		else  			break; -		if (n < 0 || n >= base) +		if (c >= base)  			break; -		if (any < 0 || acc > cutoff || (acc == cutoff && n > cutlim)) +		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))  			any = -1;  		else {  			any = 1;  			acc *= base; -			acc += n; +			acc += c;  		}  	}  	if (any < 0) { diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c index 75131faa5ea6..552a59bb8163 100644 --- a/lib/libc/stdlib/strtoll.c +++ b/lib/libc/stdlib/strtoll.c @@ -56,9 +56,9 @@ strtoll(nptr, endptr, base)  {  	const char *s;  	unsigned long long acc; -	unsigned char c; +	char c;  	unsigned long long cutoff; -	int neg, any, cutlim, n; +	int neg, any, cutlim;  	/*  	 * Skip white space and pick up leading +/- sign if any. @@ -68,7 +68,7 @@ strtoll(nptr, endptr, base)  	s = nptr;  	do {  		c = *s++; -	} while (isspace(c)); +	} while (isspace((unsigned char)c));  	if (c == '-') {  		neg = 1;  		c = *s++; @@ -112,20 +112,22 @@ strtoll(nptr, endptr, base)  	cutlim = cutoff % base;  	cutoff /= base;  	for ( ; ; c = *s++) { -		if (isxdigit(c)) -			n = digittoint(c); -		else if (isalpha(c)) -			n = (char)c - (isupper(c) ? 'A' - 10 : 'a' - 10); +		if (c >= '0' && c <= '9') +			c -= '0'; +		else if (c >= 'A' && c <= 'Z') +			c -= 'A' - 10; +		else if (c >= 'a' && c <= 'z') +			c -= 'a' - 10;  		else  			break; -		if (n < 0 || n >= base) +		if (c >= base)  			break; -		if (any < 0 || acc > cutoff || (acc == cutoff && n > cutlim)) +		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))  			any = -1;  		else {  			any = 1;  			acc *= base; -			acc += n; +			acc += c;  		}  	}  	if (any < 0) { diff --git a/lib/libc/stdlib/strtoul.c b/lib/libc/stdlib/strtoul.c index 1fd800a04a63..487f8c03c9b1 100644 --- a/lib/libc/stdlib/strtoul.c +++ b/lib/libc/stdlib/strtoul.c @@ -56,9 +56,9 @@ strtoul(nptr, endptr, base)  {  	const char *s;  	unsigned long acc; -	unsigned char c; +	char c;  	unsigned long cutoff; -	int neg, any, cutlim, n; +	int neg, any, cutlim;  	/*  	 * See strtol for comments as to the logic used. @@ -66,7 +66,7 @@ strtoul(nptr, endptr, base)  	s = nptr;  	do {  		c = *s++; -	} while (isspace(c)); +	} while (isspace((unsigned char)c));  	if (c == '-') {  		neg = 1;  		c = *s++; @@ -90,20 +90,22 @@ strtoul(nptr, endptr, base)  	cutoff = ULONG_MAX / base;  	cutlim = ULONG_MAX % base;  	for ( ; ; c = *s++) { -		if (isxdigit(c)) -			n = digittoint(c); -		else if (isalpha(c)) -			n = (char)c - (isupper(c) ? 'A' - 10 : 'a' - 10); +		if (c >= '0' && c <= '9') +			c -= '0'; +		else if (c >= 'A' && c <= 'Z') +			c -= 'A' - 10; +		else if (c >= 'a' && c <= 'z') +			c -= 'a' - 10;  		else  			break; -		if (n < 0 || n >= base) +		if (c >= base)  			break; -		if (any < 0 || acc > cutoff || (acc == cutoff && n > cutlim)) +		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))  			any = -1;  		else {  			any = 1;  			acc *= base; -			acc += n; +			acc += c;  		}  	}  	if (any < 0) { diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c index d9e3e4fd8cfb..09bd8b4683d0 100644 --- a/lib/libc/stdlib/strtoull.c +++ b/lib/libc/stdlib/strtoull.c @@ -56,9 +56,9 @@ strtoull(nptr, endptr, base)  {  	const char *s;  	unsigned long long acc; -	unsigned char c; +	char c;  	unsigned long long cutoff; -	int neg, any, cutlim, n; +	int neg, any, cutlim;  	/*  	 * See strtoq for comments as to the logic used. @@ -66,7 +66,7 @@ strtoull(nptr, endptr, base)  	s = nptr;  	do {  		c = *s++; -	} while (isspace(c)); +	} while (isspace((unsigned char)c));  	if (c == '-') {  		neg = 1;  		c = *s++; @@ -90,20 +90,22 @@ strtoull(nptr, endptr, base)  	cutoff = ULLONG_MAX / base;  	cutlim = ULLONG_MAX % base;  	for ( ; ; c = *s++) { -		if (isxdigit(c)) -			n = digittoint(c); -		else if (isalpha(c)) -			n = (char)c - (isupper(c) ? 'A' - 10 : 'a' - 10); +		if (c >= '0' && c <= '9') +			c -= '0'; +		else if (c >= 'A' && c <= 'Z') +			c -= 'A' - 10; +		else if (c >= 'a' && c <= 'z') +			c -= 'a' - 10;  		else  			break; -		if (n < 0 || n >= base) +		if (c >= base)  			break; -		if (any < 0 || acc > cutoff || (acc == cutoff && n > cutlim)) +		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))  			any = -1;  		else {  			any = 1;  			acc *= base; -			acc += n; +			acc += c;  		}  	}  	if (any < 0) { diff --git a/lib/libc/stdlib/strtoumax.c b/lib/libc/stdlib/strtoumax.c index a2da67878f3b..3d34c3bc8e00 100644 --- a/lib/libc/stdlib/strtoumax.c +++ b/lib/libc/stdlib/strtoumax.c @@ -56,9 +56,9 @@ strtoumax(nptr, endptr, base)  {  	const char *s;  	uintmax_t acc; -	unsigned char c; +	char c;  	uintmax_t cutoff; -	int neg, any, cutlim, n; +	int neg, any, cutlim;  	/*  	 * See strtoimax for comments as to the logic used. @@ -66,7 +66,7 @@ strtoumax(nptr, endptr, base)  	s = nptr;  	do {  		c = *s++; -	} while (isspace(c)); +	} while (isspace((unsigned char)c));  	if (c == '-') {  		neg = 1;  		c = *s++; @@ -90,20 +90,22 @@ strtoumax(nptr, endptr, base)  	cutoff = UINTMAX_MAX / base;  	cutlim = UINTMAX_MAX % base;  	for ( ; ; c = *s++) { -		if (isxdigit(c)) -			n = digittoint(c); -		else if (isalpha(c)) -			n = (char)c - (isupper(c) ? 'A' - 10 : 'a' - 10); +		if (c >= '0' && c <= '9') +			c -= '0'; +		else if (c >= 'A' && c <= 'Z') +			c -= 'A' - 10; +		else if (c >= 'a' && c <= 'z') +			c -= 'a' - 10;  		else  			break; -		if (n < 0 || n >= base) +		if (c >= base)  			break; -		if (any < 0 || acc > cutoff || (acc == cutoff && n > cutlim)) +		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))  			any = -1;  		else {  			any = 1;  			acc *= base; -			acc += n; +			acc += c;  		}  	}  	if (any < 0) { | 
