Hello,

The wcsftime() function, as of the current uClibc master (commit
49a67cf67d5a7194214566bc730ee7e28d55bbe1), does not work, it seems to
not do anything. Unfortunately, since the function exists, autoconf
tests checking for the existence of the function conclude that the
function exist and try to use it.

This causes some issues with Python 3, which uses wcsftime() instead of
strftime() when wcsftime() is available, and therefore the strftime()
function of the datetime Python module does not work. See
https://bugs.busybox.net/show_bug.cgi?id=7646 that was reported against
Buildroot.

A quick test case, first with strftime (working) :

# cat test-strftime.c 

#include <locale.h>
#include <stdio.h>
#include <time.h>

int main (int argc, char *argv[])
{
   time_t currtime;
   struct tm *timer;
   char buffer[80];

   time( &currtime );
   timer = localtime( &currtime );

   printf("Locale is: %s\n", setlocale(LC_ALL, argv[1]));
   //   printf("Locale is: %s\n", setlocale(LC_CTYPE, "fr_FR.UTF-8"));
   strftime(buffer,80,"%c", timer );
   printf("Date is: %s\n", buffer);

   return(0);
}
# ./test-strftime fr_FR.UTF-8
Locale is: fr_FR.UTF-8
Date is: jeu. 13 nov. 2014 22:30:11 UTC
#

And then, a second test case, with wcsftime (broken) :

# cat test-wcsftime.c 

#include <wchar.h>
#include <time.h>

int main ()
{
  time_t rawtime;
  struct tm * timeinfo;
  wchar_t buffer [80];

  time ( &rawtime );
  timeinfo = localtime ( &rawtime );

  wcsftime (buffer,80,L"Now it's %I:%M%p.",timeinfo);
  wprintf (L"%ls\n",buffer);

  return 0;
}

# ./test-wcsftime
# 

Of course, the exact same program, when built and compiled against
glibc, produces the expected result:

$ ./test-wcsftime 
Now it's 11:32PM.

Note that when building uClibc, a warning about wcsftime_l appears:

In file included from libc/misc/time/wcsftime_l.c:9:0:
libc/misc/time/time.c: In function 'wcsftime_l':
libc/misc/time/time.c:2464:2: warning: #warning wcsftime always fails [-Wcpp]
 #warning wcsftime always fails
  ^

However, looking at the code, I really can't make any sense out of the
__UCLIBC_DO_XLOCALE stuff.

Best regards,

Thomas Petazzoni
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to