From owner-freebsd-hackers Sat Sep 28 21:51:43 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id VAA26838 for hackers-outgoing; Sat, 28 Sep 1996 21:51:43 -0700 (PDT) Received: from irz301.inf.tu-dresden.de (irz301.inf.tu-dresden.de [141.76.1.11]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id VAA26792 for ; Sat, 28 Sep 1996 21:51:32 -0700 (PDT) Received: from sax.sax.de (sax.sax.de [193.175.26.33]) by irz301.inf.tu-dresden.de (8.6.12/8.6.12-s1) with ESMTP id GAA20977; Sun, 29 Sep 1996 06:51:24 +0200 Received: (from uucp@localhost) by sax.sax.de (8.6.12/8.6.12-s1) with UUCP id GAA22721; Sun, 29 Sep 1996 06:51:24 +0200 Received: (from j@localhost) by uriah.heep.sax.de (8.7.5/8.6.9) id GAA05650; Sun, 29 Sep 1996 06:37:35 +0200 (MET DST) From: J Wunsch Message-Id: <199609290437.GAA05650@uriah.heep.sax.de> Subject: Re: setlocale question To: freebsd-hackers@freebsd.org (FreeBSD hackers) Date: Sun, 29 Sep 1996 06:37:35 +0200 (MET DST) Cc: imp@village.org (Warner Losh) Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) In-Reply-To: <199609282135.PAA29387@rover.village.org> from Warner Losh at "Sep 28, 96 03:35:14 pm" X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E X-Mailer: ELM [version 2.4ME+ PL17 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk As Warner Losh wrote: > setlocale(LC_ALL, ""); > > I was wondering if that was needed, and if so why? I thought that > libc already did the moral equivalent of the semeantics of this before > passing control to main. The man page wasn't clear to me why this > would be needed. It's not the same. All programs ought to start in the "C" locale. The above adjusts all parts of the locale to the current environment's locale settings, however. This is a _huge_ difference. For example, IBM once apparently wrote the above into all of their programs in AIX, including the C compiler. The result was that the C compiler in a German language locale did no longer grok the valid initialization: double pi = 3.1415926; since the LC_NUMERIC part of the German locale uses a comma instead of a decimal point. :-O Yes, cat seems to require a setlocale(), though setlocale(LC_CTYPE, ""); is probably sufficient. It is needed in case the -v option is specified. -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)