(_IO_new_file_fopen): Recognize new mode specifier 'm' to enable mmap I/O.
[glibc.git] / time / tst-ftime_l.c
blob6ebc973febaab5d3f9c1a793b21cd52d27d6079b
1 #include <locale.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <time.h>
6 #include <wchar.h>
9 int
10 main (void)
12 locale_t l;
13 struct tm tm;
14 char buf[1000];
15 wchar_t wbuf[1000];
16 int result = 0;
18 l = newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL);
19 if (l == NULL)
21 puts ("newlocale failed");
22 exit (1);
25 memset (&tm, '\0', sizeof (tm));
27 tm.tm_year = 102;
28 tm.tm_mon = 2;
29 tm.tm_mday = 1;
31 if (strftime (buf, sizeof (buf), "%e %^B %Y", &tm) == 0)
33 puts ("initial strftime failed");
34 exit (1);
36 if (strcmp (buf, " 1 MARCH 2002") != 0)
38 printf ("initial strftime: expected \"%s\", got \"%s\"\n",
39 " 1 MARCH 2002", buf);
40 result = 1;
42 else
43 printf ("got \"%s\"\n", buf);
45 /* Now using the extended locale model. */
46 if (strftime_l (buf, sizeof (buf), "%e %^B %Y", &tm, l) == 0)
48 puts ("strftime_l failed");
49 result = 1;
51 else if (strcmp (buf, " 1 M\xc4RZ 2002") != 0)
53 printf ("strftime_l: expected \"%s\", got \"%s\"\n",
54 " 1 M\xc4RZ 2002", buf);
55 result = 1;
57 else
59 setlocale (LC_ALL, "de_DE.ISO-8859-1");
60 printf ("got \"%s\"\n", buf);
61 setlocale (LC_ALL, "C");
64 /* And the wide character version. */
65 if (wcsftime_l (wbuf, sizeof (wbuf) / sizeof (wbuf[0]), L"%e %^B %Y", &tm, l)
66 == 0)
68 puts ("wcsftime_l failed");
69 result = 1;
71 else if (wcscmp (wbuf, L" 1 M\x00c4RZ 2002") != 0)
73 printf ("wcsftime_l: expected \"%ls\", got \"%ls\"\n",
74 L" 1 M\x00c4RZ 2002", wbuf);
75 result = 1;
77 else
79 setlocale (LC_ALL, "de_DE.ISO-8859-1");
80 printf ("got \"%ls\"\n", wbuf);
81 setlocale (LC_ALL, "C");
84 return result;