Changing type of "c" to unsigned did not fix the problem --- a signed
char is sign extended before it is assigned to an unsigned int. This fix, which has been tested with a different testcase, adds casts to signed chars which results in proper behavior.
This commit is contained in:
parent
83481cc8e8
commit
2d903c854c
|
@ -56,7 +56,7 @@ strtoq(nptr, endptr, base)
|
|||
{
|
||||
register const char *s;
|
||||
register quad_t acc, cutoff;
|
||||
register unsigned int c;
|
||||
register int c;
|
||||
register int neg, any, cutlim;
|
||||
|
||||
/*
|
||||
|
@ -66,7 +66,7 @@ strtoq(nptr, endptr, base)
|
|||
*/
|
||||
s = nptr;
|
||||
do {
|
||||
c = *s++;
|
||||
c = (unsigned char) *s++;
|
||||
} while (isspace(c));
|
||||
if (c == '-') {
|
||||
neg = 1;
|
||||
|
@ -113,7 +113,7 @@ strtoq(nptr, endptr, base)
|
|||
}
|
||||
cutlim = -cutlim;
|
||||
}
|
||||
for (acc = 0, any = 0;; c = *s++) {
|
||||
for (acc = 0, any = 0;; c = (unsigned char) *s++) {
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
|
|
|
@ -56,7 +56,7 @@ strtouq(nptr, endptr, base)
|
|||
{
|
||||
register const char *s;
|
||||
register u_quad_t acc, cutoff;
|
||||
register unsigned int c;
|
||||
register int c;
|
||||
register int neg, any, cutlim;
|
||||
|
||||
/*
|
||||
|
@ -64,7 +64,7 @@ strtouq(nptr, endptr, base)
|
|||
*/
|
||||
s = nptr;
|
||||
do {
|
||||
c = *s++;
|
||||
c = (unsigned char) *s++;
|
||||
} while (isspace(c));
|
||||
if (c == '-') {
|
||||
neg = 1;
|
||||
|
@ -85,7 +85,7 @@ strtouq(nptr, endptr, base)
|
|||
|
||||
cutoff = UQUAD_MAX / (u_quad_t)base;
|
||||
cutlim = UQUAD_MAX % (u_quad_t)base;
|
||||
for (acc = 0, any = 0;; c = *s++) {
|
||||
for (acc = 0, any = 0;; c = (unsigned char) *s++) {
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
|
|
Loading…
Reference in New Issue