Date: Mon, 14 Jun 1999 16:42:21 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Morten Welinder , djgpp-workers AT delorie DOT com Subject: Re: strtol In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Precedence: bulk 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';