Opened 6 years ago
Last modified 3 months ago
#14356 new bug
setlocale() doesn't working
Reported by: | miqlas | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | System/POSIX | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | #18407 | |
Platform: | x86-64 |
Description
Current mpv checks for the locale at start and if it isn't "C" it bails out. PAtching it's main to set the locale to "C" doesn1t working. I assume setlocale() doesn't works as expected.
More inf o here: https://github.com/haikuports/haikuports/pull/2892
This happens at least on 64 bit Haiku hrev52219, but i think every Haiku arch is affected.
Attachments (1)
Change History (8)
comment:1 by , 6 years ago
comment:2 by , 7 months ago
On beta4 64 bits, the following code (minor variation of https://en.cppreference.com/w/c/chrono/strftime, slightly modified to avoid a compiler error):
#include <locale.h> #include <stdio.h> #include <time.h> int main(void) { char buff[70]; struct tm my_time = { .tm_sec=20, // = 20 secs .tm_min=10, // = 10 minutes .tm_hour=8, // = 8 hours .tm_mday=9, // = 9th day .tm_mon=9, // = 10th month .tm_year=112, // = year 2012 }; if (strftime(buff, sizeof buff, "%A %c", &my_time)) puts(buff); else puts("strftime failed"); puts(setlocale(LC_TIME, "es_AR.utf8")); if (strftime(buff, sizeof buff, "%A %c", &my_time)) puts(buff); else puts("strftime failed"); puts(setlocale(LC_TIME, "C")); if (strftime(buff, sizeof buff, "%A %c", &my_time)) puts(buff); else puts("strftime failed"); }
Outputs:
> ./strftime Sunday Sun Oct 9 08:10:20 2012 es_AR.utf8 strftime failed POSIX Sunday Sun Oct 9 08:10:20 2012
So... setlocale()
*appears* to work, but if called with any locale other than "C", subsequent calls to strftime()
then fail. (tried with "LC_ALL", same thing).
comment:3 by , 7 months ago
comment:4 by , 7 months ago
Apparently, no, they don't:
strftime for 'de_DE.UTF-8' PROBLEM: strftime("%c") = "Samstag, 17. Juli 2010 um 18:26:09 GMT" (expected "Samstag, 17. Juli 2010 18:26:09 GMT") PROBLEM: strftime("%b") = "Juli" (expected "Jul") 2 problem(s) found!
I will attach the full output, as it list a bunch of "PROBLEM:".
comment:5 by , 7 months ago
Seems like using strftime() with %c
is failing for at least el_GR.utf8
and es_AR.utf8
on my tests (and also visible on the attached locale_test.output.txt
for gu_IN
, for those it returns 0.
comment:6 by , 7 months ago
FWIW, I had seen similar issues with %c
and non default locales in the past: https://dev.haiku-os.org/ticket/18471 (I've added a comment there with a slightly updated test case that shows the issue).
comment:7 by , 3 months ago
Blocking: | 18407 added |
---|
Should we mark this as beta-blocker?