From owner-freebsd-arch Sun Jan 27 14:54:17 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id B3F4537B416 for ; Sun, 27 Jan 2002 14:54:11 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id JAA27691; Mon, 28 Jan 2002 09:54:06 +1100 Date: Mon, 28 Jan 2002 09:55:59 +1100 (EST) From: Bruce Evans X-X-Sender: To: Chad David Cc: Subject: Re: strtod() In-Reply-To: <20020126142734.A7139@colnta.acns.ab.ca> Message-ID: <20020128094055.U39729-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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