Re: C locale sort in src/tools/make_ctags

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: ntufar(at)pisem(dot)net, "'Bruce Momjian'" <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: C locale sort in src/tools/make_ctags
Date: 2004-02-02 15:06:03
Message-ID: 9387.1075734363@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> Nicolai Tufar wrote:
>> Don't do it! I just tried it with only LC_ALL and it did not
>> work. Same "tags file is not sorted" error message from vi.

> On second look, the patch is completely wrong anyway, because it does
> not export the variables; it depends on the user having exported them
> beforehand.

I saw that, but it seemed a non-problem to me: if the variables have not
been exported then they won't affect the sort program anyway.

I tried to reproduce Nicolai's statement about LC_ALL not being
sufficient, but AFAICT Fedora Core 1 handles this as expected:

$ cat /etc/redhat-release
Fedora Core release 1 (Yarrow)
$ LANG=en_US LC_ALL=en_GB locale
LANG=en_US
LC_CTYPE="en_GB"
LC_NUMERIC="en_GB"
LC_TIME="en_GB"
LC_COLLATE="en_GB"
LC_MONETARY="en_GB"
LC_MESSAGES="en_GB"
LC_PAPER="en_GB"
LC_NAME="en_GB"
LC_ADDRESS="en_GB"
LC_TELEPHONE="en_GB"
LC_MEASUREMENT="en_GB"
LC_IDENTIFICATION="en_GB"
LC_ALL=en_GB
$ cat zzz
abc DEF
ABC DEF
$ LANG=C sort zzz
ABC DEF
abc DEF
$ LANG=en_US sort zzz
abc DEF
ABC DEF
$ LANG=en_US LC_ALL=C sort zzz
ABC DEF
abc DEF

What I suspect is that Nicolai's environment supplies an explicit value
for LC_COLLATE, overriding both LC_ALL and LANG. If we want to be
bulletproof against that, then none of the proposals in this thread are
correct, and the correct patch is

+ LC_COLLATE=C
+ export LC_COLLATE

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message David Fetter 2004-02-02 15:12:23 Re: Patch for psql startup clarity
Previous Message Peter Eisentraut 2004-02-02 14:21:42 Re: CATALOG/NOCATALOG for new users