From owner-freebsd-arch Sat Jan 26 23:37:29 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mail.acns.ab.ca (mail.acns.ab.ca [142.179.151.95]) by hub.freebsd.org (Postfix) with ESMTP id 73A9E37B400; Sat, 26 Jan 2002 23:37:25 -0800 (PST) Received: from colnta.acns.ab.ca (colnta.acns.ab.ca [192.168.1.2]) by mail.acns.ab.ca (8.11.6/8.11.3) with ESMTP id g0R7bJV12661; Sun, 27 Jan 2002 00:37:19 -0700 (MST) (envelope-from davidc@colnta.acns.ab.ca) Received: (from davidc@localhost) by colnta.acns.ab.ca (8.11.6/8.11.3) id g0R7bJV40281; Sun, 27 Jan 2002 00:37:19 -0700 (MST) (envelope-from davidc) Date: Sun, 27 Jan 2002 00:37:19 -0700 From: Chad David To: "Andrey A. Chernov" Cc: "Brian F. Feldman" , Bruce Evans , arch@FreeBSD.ORG Subject: Re: strtod() Message-ID: <20020127003719.A38420@colnta.acns.ab.ca> Mail-Followup-To: "Andrey A. Chernov" , "Brian F. Feldman" , Bruce Evans , arch@FreeBSD.ORG References: <20020126162924.A7726@colnta.acns.ab.ca> <200201270453.g0R4rwi92912@green.bikeshed.org> <20020127070421.GA13415@nagual.pp.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="jI8keyz6grp/JLjh" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020127070421.GA13415@nagual.pp.ru>; from ache@nagual.pp.ru on Sun, Jan 27, 2002 at 10:04:23AM +0300 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 --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