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>
The code should be able to keep track about previous content and print
JSON objects separator automatically.
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch add support to format multi-line cells (columns with
SCOLS_FL_WRAP) to arrays in JSON output.
For example mountpoints[] in lsblk output:
Normal output:
$ lsblk -oNAME,FSTYPE,TYPE,MOUNTPOINTS /dev/sdc1
NAME FSTYPE TYPE MOUNTPOINTS
sdc1 btrfs part /mnt/A
/mnt/test
/mnt/B
JSON output:
$ lsblk -J -oNAME,FSTYPE,TYPE,MOUNTPOINTS /dev/sdc1
{
"blockdevices": [
{
"name": "sdc1",
"fstype": "btrfs",
"type": "part",
"mountpoints": [
"/mnt/A",
"/mnt/test",
"/mnt/B"
]
}
]
}
Signed-off-by: Karel Zak <kzak@redhat.com>