Thread strftime stuerzt ab (17 answers)
Opened by betterworld at 2008-04-22 03:58

betterworld
 2008-04-22 03:58
#108669 #108669
User since
2003-08-21
2613 Artikel
ModeratorIn

user image
Hallo,

folgendes Programm stuerzt bei mir ab. Abstuerzen bedeutet hier ewig laufen. Laut strace moechte es offenbar sein restliches Leben damit verbringen, wiederholt /etc/localtime zu staten. Habe es auf Debian und Gentoo mit Perl 5.8.8 probiert.
Code: (dl )
1
2
3
use POSIX qw(locale_h strftime);
setlocale( LC_ALL, "de_DE.ISO8859-1" );
print strftime( "%p", localtime( time + 40000 ) );


Mit einer en_US-locale stuerzt es nicht ab, sondern gibt "PM" aus. Mit der deutschen locale eben gar nichts. Ist das gut?

Da strftime eigentlich aus der libc kommt, habe ich ein C-Programm probiert, was eigentlich dasselbe tun sollte, und es stuerzt nicht ab (gibt aber nichts aus):
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <time.h>
#include <stdio.h>
#include <locale.h>

int
main (void)
{
setlocale(LC_ALL, "de_DE.ISO8859-1");
time_t tt = time(NULL);
struct tm *t = localtime(&tt);
char s[100];
strftime(s, 100, "%p", t);
printf("%s\n", s);
return 0;
}

View full thread strftime stuerzt ab