News for hackers. Stuff that matters.
Re:Glibc: [0-9] matches ¼ ١ 2 〣 and others, but not 9 (and o... by zlynx on Wednesday July 18, 2018 @02:02PM (#17560641)
I guess we should all just force-set our C programs to the C locale.
Re:Glibc: [0-9] matches ¼ ١ 2 〣 and others, but not 9 (and o... by kazinator on Thursday July 19, 2018 @07:31PM (#17571279)
> I guess we should all just force-set our C programs to the C locale.

Ah, but you are in luck: this is not required!

A C program begins execution in the "C" locale, regardless of the environment variables.

The locale variables do not affect a C program until it calls the "fuck this program function" called setlocale, with LC_ALL, and "". The empty string argument means "use the environment variable".

The problem is that many modern utilities in GNU/Linux land all make this setlocale call, in order to support internationalization. So then they are affected by whatever hell breaks loose.

Your own program is safe, if neither it, nor a third party library, calls setlocale, then your strcmp and isalpha and whatever else behave in good old naive manner.

Re:Glibc: [0-9] matches ¼ ١ 2 〣 and others, but not 9 (and o... by patrec on Wednesday July 18, 2018 @05:13PM (#17562109)
This works till you want at least minimal UTF-8 support, such as when you're working with actual English text as opposed to human-readable computerese.
Re:Glibc: [0-9] matches ¼ ١ 2 〣 and others, but not 9 (and o... by kazinator on Thursday July 19, 2018 @07:26PM (#17571249)
Sticking to the "C" locale will work even if you want UTF-8 support. You just roll your own UTF-8 support.

I built the TXR language entirely without any of the harmful garbage that is the ISO C/POSIX localization. It handles UTF-8 just fine.

The C localization stuff was developed too early, at a time when nobody had any real experience with localization. Before Unicode, before the Internet.

Before threads! How the do you set it up so that one thread runs in one locale and another in another? That's important if a global server is servicing two different requests simultaneously from users in two different locales. The idiotic C locale stuff relies on global variables.

You set some magic variables and, poof; numerous functions in your entire image change their behavior, whether they are working with internationalized data or not.

The setlocale function might as well be called fuck_my_program_please.

Re:Glibc: [0-9] matches ¼ ١ 2 〣 and others, but not 9 (and o... by rwmj on Wednesday July 18, 2018 @02:46PM (#17561027)
In all the scripted tests we write, one of the first lines will be:

    export LANG=C
A similar construct is also used in most places where we call sort (except where we're actually sorting strings of text that will be read by an end user), eg:

    <some source of data> | LANG=C sort
Re:Glibc: [0-9] matches ¼ ١ 2 〣 and others, but not 9 (and o... by jwilk on Wednesday July 18, 2018 @06:39PM (#17562619)
Setting LANG=C is not sufficient, because LANG can be overridden by various LC_* variables.

You should set LC_ALL=C instead.

Re:Glibc: [0-9] matches ¼ ١ 2 〣 and others, but not 9 (and o... by usr1106 on Thursday July 19, 2018 @01:39PM (#17568665)
LC_COLLATE is the critical category according to the bug report. No need to set anything else.
Re:Glibc: [0-9] matches ¼ ١ 2 〣 and others, but not 9 (and o... by jwilk on Thursday July 19, 2018 @07:16PM (#17571195)
It's not enough if LC_ALL is already set in environment, sice that would override LC_COLLATE.

So just set LC_ALL and be done with it. It's bulletproof.