From owner-freebsd-arch Sat Jan 26 20:54:11 2002 Delivered-To: freebsd-arch@freebsd.org Received: from green.bikeshed.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 915A337B402; Sat, 26 Jan 2002 20:54:03 -0800 (PST) Received: from localhost (green@localhost) by green.bikeshed.org (8.11.6/8.11.6) with ESMTP id g0R4rwi92912; Sat, 26 Jan 2002 23:53:58 -0500 (EST) (envelope-from green@green.bikeshed.org) Message-Id: <200201270453.g0R4rwi92912@green.bikeshed.org> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: Chad David Cc: Bruce Evans , arch@FreeBSD.ORG Subject: Re: strtod() In-Reply-To: Message from Chad David of "Sat, 26 Jan 2002 16:29:24 MST." <20020126162924.A7726@colnta.acns.ab.ca> From: "Brian F. Feldman" Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 26 Jan 2002 23:53:58 -0500 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 Chad David wrote: > > > 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. > > > > > > Am I making any sense? > > > > Not "as long as the return value" is anything! Why should the function be > > changing errno if it hasn't generated an error? These are particularly > > difficult functions to use in the first place, and they really shouldn't be > > made more-so by gratuitously changing errno. It's not hard to save errno, > > either, in the library call... > > I'm not sure if you are agreeing with me, or disagreeing with me :). > > When 0.0 is returned and errno == EINVAL a lot of code assumes there was > an error, but current always returns with errno == EINVAL, which breaks > this code when "0.0" is converted.. The problem is that 0.0 could be the right return value, but if errno was EINVAL before calling strtod(), the caller makes a mistake in assuming "retval == 0.0 && errno == EINVAL means failure". > If you are suggesting that strtod() etc. should save errno on entry and > then reset it on return (unless it wants to return its own error) then I > think I agree with that. If strtod() wants to use errno internally, that's fine, but I personally really expect it to not modify errno without also intending to return an error; that's why saving at entry and restoring at exit is my preference for these functions. -- Brian Fundakowski Feldman \'[ FreeBSD ]''''''''''\ <> green@FreeBSD.org <> bfeldman@tislabs.com \ The Power to Serve! \ Opinions expressed are my own. \,,,,,,,,,,,,,,,,,,,,,,\ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message