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:
jtc 1996-07-20 01:03:54 +00:00
parent 83481cc8e8
commit 2d903c854c
2 changed files with 6 additions and 6 deletions

View File

@ -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))

View File

@ -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))