delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/06/14/09:44:49

Date: Mon, 14 Jun 1999 16:42:21 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Morten Welinder <terra AT diku DOT dk>, djgpp-workers AT delorie DOT com
Subject: Re: strtol
In-Reply-To: <Pine.SUN.3.91.990614101719.21962C-100000@is>
Message-ID: <Pine.SUN.3.91.990614164100.18221A-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019