[libcxx-commits] [PATCH] D120317: [libcxx] [test] Fix get/put long_double_ru_RU on Glibc, FreeBSD and Windows
Martin Storsjö via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 4 00:28:01 PST 2022
mstorsjo added a comment.
In D120317#3359301 <https://reviews.llvm.org/D120317#3359301>, @uabelho wrote:
>> Alternatively, even better, can you provide the output of this test program:
>>
>> #include <locale.h>
>> #include <stdio.h>
>>
>> int main(int argc, char **argv) {
>> const char *locale = "ru_RU.UTF-8";
>> if (argc > 1)
>> locale = argv[1];
>> if (!setlocale(LC_ALL, locale)) {
>> printf("setlocale(%s) failed\n", locale);
>> return 1;
>> }
>> struct lconv *lconv = localeconv();
>> printf("mon_thousands_sep: \"%s\",", lconv->mon_thousands_sep);
>> for (const char *c = lconv->mon_thousands_sep; *c; c++)
>> printf(" %02x", (unsigned char)*c);
>> printf("\n");
>> printf("thousands_sep: \"%s\",", lconv->thousands_sep);
>> for (const char *c = lconv->thousands_sep; *c; c++)
>> printf(" %02x", (unsigned char)*c);
>> printf("\n");
>> printf("int_curr_symbol: \"%s\"\n", lconv->int_curr_symbol);
>> printf("currency_symbol: \"%s\",", lconv->currency_symbol);
>> for (const char *c = lconv->currency_symbol; *c; c++)
>> printf(" %02x", (unsigned char)*c);
>> printf("\n");
>> printf("decimal_point: \"%s\",", lconv->decimal_point);
>> for (const char *c = lconv->decimal_point; *c; c++)
>> printf(" %02x", (unsigned char)*c);
>> printf("\n");
>> printf("mon_decimal_point: \"%s\",", lconv->mon_decimal_point);
>> for (const char *c = lconv->mon_decimal_point; *c; c++)
>> printf(" %02x", (unsigned char)*c);
>> printf("\n");
>> printf("negative_sign: \"%s\"\n", lconv->negative_sign);
>> printf("positive_sign: \"%s\"\n", lconv->positive_sign);
>> printf("n_sign_posn: %d\n", lconv->n_sign_posn);
>> printf("p_sign_posn: %d\n", lconv->p_sign_posn);
>> #ifndef _WIN32
>> printf("int_n_sign_posn: %d\n", lconv->int_n_sign_posn);
>> printf("int_p_sign_posn: %d\n", lconv->int_p_sign_posn);
>> #endif
>> return 0;
>> }
>
> Yep
>
> mon_thousands_sep: " ", c2 a0
> thousands_sep: " ", c2 a0
> int_curr_symbol: "RUB "
> currency_symbol: "руб", d1 80 d1 83 d0 b1
> decimal_point: ",", 2c
> mon_decimal_point: ".", 2e
> negative_sign: "-"
> positive_sign: ""
> n_sign_posn: 1
> p_sign_posn: 1
> int_n_sign_posn: 1
> int_p_sign_posn: 1
Thanks! I get this:
mon_thousands_sep: " ", e2 80 af
thousands_sep: " ", e2 80 af
int_curr_symbol: "RUB "
currency_symbol: "₽", e2 82 bd
decimal_point: ",", 2c
mon_decimal_point: ",", 2c
negative_sign: "-"
positive_sign: ""
n_sign_posn: 1
p_sign_posn: 1
int_n_sign_posn: 1
int_p_sign_posn: 1
What glibc version do you have? As you're on RHEL, I would expect an older one (mine is on Ubuntu 20.04, with glibc 2.31). There seems to be differences in most fields, in particular in `mon_decimal_point` here. We already have some conditionals due to the fact that `currency_symbol` differs for ru_RU.UTF-8 in various glibc versions (apparently with the new form appearing in 2.24), but we never had any glibc conditionals for the differing `mon_decimal_point`. As that probably would require quite intrusive changes to the test, I guess it's probably best to make the test bail out on such older versions (as it just has been XFAILed forever on that platform before anyway).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120317/new/
https://reviews.llvm.org/D120317
More information about the libcxx-commits
mailing list