]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib/jsonwrt: don't use ctype.h for ASCII chars
authorKarel Zak <kzak@redhat.com>
Thu, 6 May 2021 14:35:50 +0000 (16:35 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 6 May 2021 14:35:50 +0000 (16:35 +0200)
commit64a89adaa16461bd58730c1408b30aa7244b4f66
tree6be6a0aeb8ffdfd10ea8fba84b239981657e6979
parent3a07505a397c9d31cde6c2812b3800227442f7c0
lib/jsonwrt: don't use ctype.h for ASCII chars

tolower() does not work "as expected" for tr_TR.UTF-8 (Turkish).
Fortunately, we need to convert only objects and variables names in
JSON output, and this is always old good ASCII.

Anyway, for more details:

$ cat a.c
#include <ctype.h>
#include <stdio.h>
#include <locale.h>

int main(void)
{
int in, out;

setlocale(LC_ALL, "");

in ='I';
out = tolower(in);

printf("%1$c [%1$d] --> %2$c [%2$d]\n", in, out);
return 0;
}

$ make a
cc     a.c   -o a

$ LANG=en_US.utf8 ./a
I [73] --> i [105]

$ LANG=tr_TR.UTF-8 ./a
I [73] --> I [73]

Fixes: https://github.com/karelzak/util-linux/issues/1302
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/jsonwrt.c