From owner-freebsd-arch Sun Jan 27 12:24:50 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 41ACE37B404; Sun, 27 Jan 2002 12:24:46 -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 g0RKOeV14738; Sun, 27 Jan 2002 13:24:40 -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 g0RKOe062103; Sun, 27 Jan 2002 13:24:40 -0700 (MST) (envelope-from davidc) Date: Sun, 27 Jan 2002 13:24:40 -0700 From: Chad David To: Terry Lambert Cc: "Andrey A. Chernov" , "Brian F. Feldman" , Bruce Evans , arch@FreeBSD.ORG Subject: Re: strtod() Message-ID: <20020127132439.C42735@colnta.acns.ab.ca> Mail-Followup-To: Terry Lambert , "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> <20020127003719.A38420@colnta.acns.ab.ca> <3C53DB0B.6547EB76@mindspring.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3C53DB0B.6547EB76@mindspring.com>; from tlambert2@mindspring.com on Sun, Jan 27, 2002 at 02:48:43AM -0800 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 Sun, Jan 27, 2002 at 02:48:43AM -0800, Terry Lambert wrote: > Chad David wrote: > > 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. > > Good catch! > > > The attached patch fixes this case, and probably others. Comments? > > Uh, working around the problem this way adds overhead to a > lot of places where it wasn't before. How about just > initializing the shortcut completely? > > Worse comes to worse, call localeconv() in a .init by abusing > the G++ linker set that gets run to construct virtual base > clases and template classes the first time. This will not work, as somebody will eventually change the locale, which could cause this to happen again (once) for some unlucky function. Even strtod() (which is where I first noticed this) will only fail the first time. Saving and restoring errno does seem like a hack to me, but I'm not sure how to fix this so bad locales do not break functions (ie strtod()) in none obvious ways. -- 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message