Consider the attached file. The expected behavior is for it to return
four time the exact same set of messages. GNU strptime is guaranteed
to parse POSIX C-formatted strings even if the current locale is not
C. However that's not what I get:
[EMAIL PROTECTED] Desktop]$ gcc test.c -o test
[EMAIL PROTECTED] Desktop]$ ./test
DEBUG: Parsed as 00-00-00
DEBUG: Parsed as 23-05-108
DEBUG: Parsed as 23-05-108
DEBUG: Parsed as 23-05-108
The same was tested on other distros and gives four identical results
while on PLD the first one results in a parsing error.
--
Patryk Zawadzki
PLD Linux Distribution
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <locale.h>
int main()
{
char *date = "Mon Jun 23 14:01:57 +0000 2008";
struct tm tmp;
setlocale(LC_TIME, "pl_PL");
memset (&tmp, 0, sizeof (tmp));
strptime (date, "%a %b %d %T %z %Y", &tmp);
printf ("DEBUG: Parsed as %02d-%02d-%02d\n", tmp.tm_mday, tmp.tm_mon, tmp.tm_year);
memset (&tmp, 0, sizeof (tmp));
strptime (date, "Mon %b %d %T %z %Y", &tmp);
printf ("DEBUG: Parsed as %02d-%02d-%02d\n", tmp.tm_mday, tmp.tm_mon, tmp.tm_year);
setlocale(LC_TIME, "C");
memset (&tmp, 0, sizeof (tmp));
strptime (date, "%a %b %d %T %z %Y", &tmp);
printf ("DEBUG: Parsed as %02d-%02d-%02d\n", tmp.tm_mday, tmp.tm_mon, tmp.tm_year);
memset (&tmp, 0, sizeof (tmp));
strptime (date, "Mon %b %d %T %z %Y", &tmp);
printf ("DEBUG: Parsed as %02d-%02d-%02d\n", tmp.tm_mday, tmp.tm_mon, tmp.tm_year);
}
_______________________________________________
pld-devel-en mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-devel-en