Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Jan 2002 09:55:59 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Chad David <davidc@acns.ab.ca>
Cc:        <arch@FreeBSD.ORG>
Subject:   Re: strtod()
Message-ID:  <20020128094055.U39729-100000@gamplex.bde.org>
In-Reply-To: <20020126142734.A7139@colnta.acns.ab.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 26 Jan 2002, Chad David wrote:

> On Sun, Jan 27, 2002 at 07:44:20AM +1100, Bruce Evans wrote:
> > On Thu, 24 Jan 2002, Chad David wrote:
> >
> > > On current (as of today) strtod() sets errno to EINVAL even when no error
> > > ...
> > > Note that on stable errno does not get set to EINVAL.
> >
> > I think you mean strtol().  strtod() hasn't changed significantly since
> > RELENG_4.  The integer strto*() functions now set it in the following
>
> Depending on what you mean by "you mean strtol()"?  strtol() is being called
> indirectly by strtod() via localeconv(), and it is failing (since around
> 1.3 or localeconv.c).

Oops.  I didn't notice this because my version of strtol() doesn't set
errno to EINVAL since I don't like that change.  It is a POSIX.1-2001
extension, so portable programs can't depend on it; in practice it mainly
exposes the brokenness of broken code like FreeBSD's cnv().

More in a reply to later mail...

> > %%%
> > 	errno = 0;
> > 	num = strtouq(val, &expr, 0);
> > 	if (errno != 0)				/* Overflow or underflow. */
> > 		err(1, "%s", oper);
> >
> > 	if (expr == val)			/* No valid digits. */
> > 		errx(1, "%s: illegal numeric value", oper);
> > %%%
> > [... This is broken because the "No valid digits" case may, and now
> >      does set errno.
>
> Code like this is what I'm dealing with.  My point is that if you set
> errno == 0, and then after the function it is != 0, an error DID occur,
> as long as the return value == 0.0 or HUGE_VAL I guess.

For the strto*() family, yes (not for functions that aren't specified to
set errno), except you can trust errno if it is set (if the implementation
is not broken).

More in a reply to later mail...

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020128094055.U39729-100000>