Mail Archives: djgpp-workers/1999/06/14/09:44:49
On Mon, 14 Jun 1999, I wrote:
> On Sun, 13 Jun 1999, Morten Welinder wrote:
>
> > It's subtle. If s is a "char *" or "signed char *" and c is an int,
> > then after "c = *s;", c is -27. isdigit is only defined in the
> > range -1 to 255. (EOF is -1.)
>
> Right.
Does the following seem okay? It works for me.
*** strtol.c 1994/12/26 20:35:04 1.1
--- strtol.c 1999/06/14 13:40:47
***************
*** 21,27 ****
*/
do {
c = *s++;
! } while (isspace(c));
if (c == '-')
{
neg = 1;
--- 21,27 ----
*/
do {
c = *s++;
! } while (isspace(c & 0xff));
if (c == '-')
{
neg = 1;
***************
*** 59,65 ****
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base;
! for (acc = 0, any = 0;; c = *s++)
{
if (isdigit(c))
c -= '0';
--- 59,65 ----
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base;
! for (acc = 0, any = 0;; c = *s++, c &= 0xff)
{
if (isdigit(c))
c -= '0';
- Raw text -