From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA12539; Mon, 14 Jun 2004 11:55:06 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA12811 for ; Mon, 14 Jun 2004 11:55:05 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i5E9siEV020468; Mon, 14 Jun 2004 11:54:45 +0200 Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA12483; Mon, 14 Jun 2004 11:54:44 +0200 (MET DST) Date: Mon, 14 Jun 2004 11:54:44 +0200 From: Xavier Leroy To: Evgeny Chukreev Cc: caml-list@inria.fr Subject: Re: [Caml-list] string_of_float -> float_of_string locale dependency bug Message-ID: <20040614115444.A14769@pauillac.inria.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from sjah@land.ru on Sun, Jun 13, 2004 at 08:30:12PM +0700 X-Miltered: at nez-perce with ID 40CD75E4.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 locale:01 bug:01 koi:01 usr:01 3.07:01 camomile:01 camomile:01 3.07:01 runtime:01 locale:01 setlocale:01 setlocale:01 invalidate:01 api:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Hello! > > /tmp% echo $LANG > ru_RU.KOI8-R > > /tmp% ocaml -I /usr/local/lib/ocaml/3.07/camomile/ bigarray.cma camomile.cma > Objective Caml version 3.07+2 > > # float_of_string "0,";; > - : float = 0. > # string_of_float 0,;; > Syntax error > # string_of_float 0.;; > Fatal error: exception Failure("float_of_string") Do you have the same error if you don't load camomile.cma? From a quick test here, I believe not. The Caml runtime system does depend on the LC_NUMERIC locale begin set to its default value "C", but it ensures that this is the case by never calling setlocale(LC_ALL, "") nor setlocale(LC_NUMERIC, ""). Third-party libraries can invalidate this invariant by calling e.g. setlocale(LC_ALL, ""). Two possibilities: - The library doesn't really need LC_ALL, e.g. it would be enough to set LC_CTYPE or LC_COLLATE and leave LC_NUMERIC unchanged. In this case, the library should be fixed. - The library really needs to set LC_NUMERIC, in which case it's impossible to use that library with the Caml toplevel. The C library API for internationalization is largely broken, and as you can see there is nothing we can do to work around the fact that the current locale is a global variable for the whole program. - Xavier Leroy ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners