3 ms·
I know isspace() and the rest of ctype.h date to V7; I was wondering about locales specifically. I'm not aware of any pre-C89 implementation of anything similar
by kps 3y ago
I know isspace() and the rest of ctype.h date to V7; I was wondering about locales specifically. I'm not aware of any pre-C89 implementation of anything similar to that, so I'm wondering whether X3J11 adopted it from some system I've never heard of, or created it themselves. C89 was supposed to ‘codify common existing practice’, but internationalization politics may have overridden that.
- wahern 3y agoThis doesn't answer the question, but FWIW the earliest reference I could find to setlocale or related is from a 1986 journal article, Programmer's Journal, Volume 4, page 45: > In order to preserve the existing, large body of code, it was decided to place the burden of having a non-USA/ENGLISH environment only on those users who needed it. This will be done by making the C program startup environment default to a native "locale" of USA. Users wanting something else will need to call the setlocale function to set their locale to some other implementation-defined environment. See https://books.google.com/books?id=XV4qAAAAMAAJ&focus=searchwithinvolume&q=setlocale https://books.google.com/books?id=XV4qAAAAMAAJ&focus=searchw... So either the 1985 draft already had setlocale, or it must have been added shortly thereafter. However, Microsoft's 1986 reference manual doesn't mention setlocale, despite the introduction saying it was based on the draft standard. See https://www.os2museum.com/files/docs/msc40/ms-c-4.0-rtlref-1986.pdf https://www.os2museum.com/files/docs/msc40/ms-c-4.0-rtlref-1... IEEE Std 1003.1-1988 (i.e. POSIX), approved 1988, already copied setlocale from ANSI C, presumably based on a draft as ANSI C wasn't ratified until 1989. See https://nvlpubs.nist.gov/nistpubs/Legacy/FIPS/fipspub151-1.pdf https://nvlpubs.nist.gov/nistpubs/Legacy/FIPS/fipspub151-1.p... I can't find any implementation before Version 10 Unix from 1989, followed by BSD4.4-Net/2 from 1991. See https://minnie.tuhs.org/cgi-bin/utree.pl https://minnie.tuhs.org/cgi-bin/utree.pl. Unfortunately none of the early committee notes or minutes seem to be available online. Hopefully someone in the know (possibly an original committee member) is lurking on HN and can fill-in the gaps. EDIT: I found a post by Doug Gwyn in comp.lang.c from November 1986 explaining setlocale: Path: utzoo!mnetor!seismo!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: sizeof(char) Message-ID: <5359@brl-smoke.ARPA> Date: Wed, 12-Nov-86 21:04:19 EST Article-I.D.: brl-smok.5359 Posted: Wed Nov 12 21:04:19 1986 Date-Received: Wed, 12-Nov-86 23:55:53 EST References: <4617@brl-smoke.ARPA> <657@dg_rtp.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 61 In article <9181@sun.uucp> guy@sun.uucp (Guy Harris) writes: >If it is indeed the case that there is more than one way of sorting text in, >say, Oriental languages, then either 1) "setlocale" is a poor name, because >it takes into account more than just the locale, or 2) it is a poor routine, >because it doesn't take into account more than just the locale. The name is short for "set locale-specific information", which reflects the main motivation for the function. There were several suggestions for the name, but we couldn't find one that we liked better, other than contractions of "set environment", which had to be rejected for the obvious reason. Actually, it WAS intended that setlocale() indeed mean "change or query the program's entire LOCALE or portions thereof", where the term "locale" was to be defined in section 1.5. However, something appears to have gone awry in the process of making this last-minute addition to the draft proposed standard document, since there are two sentences in the description of setlocale (section 4.4.1.1) that say almost the same thing using different words, and section 1.5 defines "locale-specific behavior" but not "locale". The general term "locale" is intended in the context of X3J11 to refer to a complete, orthogonal set of selections of conventions for items that are allowed to affect program operation based on nationality, culture, or language. Thus "locale" is not synonymous with "location". NB: I pasted only the first half of that post; the most relevant part.
- kps 3y agoThanks! I started working at a C compiler shop near the end of the '80s, and I don't recall knowing that this had been under way for so long already. (Though, we did freestanding targets, often with no conventional I/O, so locales would have been the last thing on our minds.) It would be nice if the X3J11 internal documents ended up in an online archive, given their historical importance.