Date: Sun, 27 Jan 2002 00:37:19 -0700 From: Chad David <davidc@acns.ab.ca> To: "Andrey A. Chernov" <ache@nagual.pp.ru> Cc: "Brian F. Feldman" <green@FreeBSD.ORG>, Bruce Evans <bde@zeta.org.au>, arch@FreeBSD.ORG Subject: Re: strtod() Message-ID: <20020127003719.A38420@colnta.acns.ab.ca> In-Reply-To: <20020127070421.GA13415@nagual.pp.ru>; from ache@nagual.pp.ru on Sun, Jan 27, 2002 at 10:04:23AM %2B0300 References: <20020126162924.A7726@colnta.acns.ab.ca> <200201270453.g0R4rwi92912@green.bikeshed.org> <20020127070421.GA13415@nagual.pp.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
--jI8keyz6grp/JLjh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Jan 27, 2002 at 10:04:23AM +0300, Andrey A. Chernov wrote: > On Sat, Jan 26, 2002 at 23:53:58 -0500, Brian F. Feldman wrote: > > > > 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. > > Yes, it must save/restore errno and modify it only if error (in strtod's > meaning) happens. I just noticed that if you call printf() (or anything that will call localeconv()) before you call strtod() etc. it works as it should. It is the first call to localeconv() that causes errno to be updated when it calls strtol(). After that localeconv() takes a short cut. So it isn't really strtod()'s problem, but localeconv()'s. The attached patch fixes this case, and probably others. Comments? -- Chad David davidc@acns.ab.ca www.FreeBSD.org davidc@freebsd.org ACNS Inc. Calgary, Alberta Canada Fourthly, The constant breeders, beside the gain of eight shillings sterling per annum by the sale of their children, will be rid of the charge of maintaining them after the first year. - Johnathan Swift --jI8keyz6grp/JLjh Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="localeconv.patch" Index: localeconv.c =================================================================== RCS file: /mnt1/ncvs/src/lib/libc/locale/localeconv.c,v retrieving revision 1.3 diff -u -d -r1.3 localeconv.c --- localeconv.c 10 Feb 2001 02:00:56 -0000 1.3 +++ localeconv.c 27 Jan 2002 07:28:51 -0000 @@ -49,9 +49,16 @@ int __mlocale_changed = 1; int __nlocale_changed = 1; +extern int errno; /* required in cnv() */ + static char cnv(char *str) { - return (char)strtol(str, NULL, 0); + int save_errno = errno; + char ret; + + ret = (char)strtol(str, NULL, 0); + errno = save_errno; + return (ret); } /* --jI8keyz6grp/JLjh-- 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?20020127003719.A38420>