Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Y01 Test Failure
- X-seq: zsh-workers 48191
- From: Jun T <takimoto-j@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Y01 Test Failure
- Date: Fri, 19 Mar 2021 19:42:38 +0900
- Archived-at: <https://zsh.org/workers/48191>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-03/9F54A3AC-47E4-4238-8C5C-F97F3DD8D7B9%40kba.biglobe.ne.jp>
- In-reply-to: <CAHYJk3SB+-hqexEfnTgvJKLU22n1gF_pEmrg=6X2zSDGswYzBQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CACeGjnU2+n53_7chT3gGLY155r52gwuNSmtT64CkRAOK4cUd_A@mail.gmail.com> <CAH+w=7YBb_7kNDuxxOy3pOGSpLe_dPrKwziwC8SrF7BP95epCA@mail.gmail.com> <4E909F26-B880-4EEE-9EE2-5C444BC8A9CF@kba.biglobe.ne.jp> <CAHYJk3SB+-hqexEfnTgvJKLU22n1gF_pEmrg=6X2zSDGswYzBQ@mail.gmail.com>
> 2021/03/19 17:27, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> Is this happening even with LC_COLLATE=C, or did we not bother setting
> that for this specific test?
LC_ALL is set to en_US.UTF-8 at the start of Y01completion.ztst.
I've been thinking that comparison of all-ASCII strings is the same
in C and UTF-8 locales. But it turned out that strcoll() behaves quite
*strangely* under en_US.UTf-8 on Linux.
If I run the following C-code:
#include <stdio.h>
#include <string.h>
#include <locale.h>
int main() {
char* s[] = { "h", "i", "j" };
setlocale(LC_COLLATE, "");
for(int i=0; i<3; ++i) {
printf("'%s' - '<INSERT>' = %d\n", s[i], strcoll(s[i], "<INSERT>"));
}
return 0;
}
% export LC_COLLATE=C
% ./a.out
'h' - '<INSERT>' = 44
'i' - '<INSERT>' = 45
'j' - '<INSERT>' = 46
% export LC_COLLATE=en_US.UTF-8
% ./a.out
'h' - '<INSERT>' = -11
'i' - '<INSERT>' = -1
'j' - '<INSERT>' = 1
% export LC_COLLATE=ja_JP.UTF-8
% ./a.out
'h' - '<INSERT>' = 44
'i' - '<INSERT>' = 45
'j' - '<INSERT>' = 46
I can't understand the behavior under en_US.UTF-8 locale.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author