delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/06/13/10:30:02

Date: Sun, 13 Jun 1999 16:29:41 +0200 (METDST)
Message-Id: <199906131429.QAA09339@tyr.diku.dk>
From: Morten Welinder <terra AT diku DOT dk>
To: eliz AT is DOT elta DOT co DOT il
CC: djgpp-workers AT delorie DOT com
In-reply-to: <Pine.SUN.3.91.990613114948.17906f-100000@is> (message from Eli
Zaretskii on Sun, 13 Jun 1999 11:51:05 +0300 (IDT))
Subject: Re: strtol
References: <Pine DOT SUN DOT 3 DOT 91 DOT 990613114948 DOT 17906f-100000 AT is>
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

   > As far as I can tell, in src/libc/ansi/stdlib/strtol.c, strtol is
   > sending signed chars to isspace, isupper, and isdigit.  The effect of
   > that is undefined.

   I'm not sure I follow.  strtol sends an int to ctype function, not a 
   signed char.  Where exactly is the problem?

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

In include/inlines/ctype.ha you can see that isfoo(baz) just does
"(__bar[(int)(baz) + 1] & ...)" so sending a number less than -1 is
not good.

While I am at it.  My Solaris manual says that tolower/toupper are
defined for all ints, so toupper(123456789) returns 123456789.

Morten

- Raw text -


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