Commit 560ac90b authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcr100: Use LC_TIME code page when converting strftime data.

parent 0201aa3b
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <locale.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <sys/timeb.h> #include <sys/timeb.h>
...@@ -1437,6 +1438,7 @@ static size_t strftime_helper(char *str, size_t max, const char *format, ...@@ -1437,6 +1438,7 @@ static size_t strftime_helper(char *str, size_t max, const char *format,
#else #else
wchar_t *s, *fmt; wchar_t *s, *fmt;
size_t len; size_t len;
int cp;
TRACE("(%p %Iu %s %p %p %p)\n", str, max, format, mstm, time_data, loc); TRACE("(%p %Iu %s %p %p %p)\n", str, max, format, mstm, time_data, loc);
...@@ -1445,15 +1447,27 @@ static size_t strftime_helper(char *str, size_t max, const char *format, ...@@ -1445,15 +1447,27 @@ static size_t strftime_helper(char *str, size_t max, const char *format,
*str = 0; *str = 0;
if (!MSVCRT_CHECK_PMT(format != NULL)) return 0; if (!MSVCRT_CHECK_PMT(format != NULL)) return 0;
len = _mbstowcs_l( NULL, format, 0, loc ) + 1; cp = (loc ? loc->locinfo : get_locinfo())->lc_id[LC_TIME].wCodePage;
if (!len || !(fmt = malloc( len*sizeof(wchar_t) ))) return 0;
_mbstowcs_l(fmt, format, len, loc); len = MultiByteToWideChar( cp, 0, format, -1, NULL, 0 );
if (!len)
{
*_errno() = EILSEQ;
return 0;
}
fmt = malloc( len*sizeof(wchar_t) );
if (!fmt) return 0;
MultiByteToWideChar( cp, 0, format, -1, fmt, len );
if ((s = malloc( max*sizeof(wchar_t) ))) if ((s = malloc( max*sizeof(wchar_t) )))
{ {
len = strftime_impl( s, max, fmt, mstm, time_data, loc ); len = strftime_impl( s, max, fmt, mstm, time_data, loc );
if (len) if (len)
len = _wcstombs_l( str, s, max, loc ); {
len = WideCharToMultiByte( cp, 0, s, -1, str, max, NULL, NULL );
if (len) len--;
else *_errno() = EILSEQ;
}
free( s ); free( s );
} }
else len = 0; else len = 0;
...@@ -1478,7 +1492,7 @@ size_t CDECL _strftime_l( char *str, size_t max, const char *format, ...@@ -1478,7 +1492,7 @@ size_t CDECL _strftime_l( char *str, size_t max, const char *format,
* _Strftime (MSVCRT.@) * _Strftime (MSVCRT.@)
*/ */
size_t CDECL _Strftime(char *str, size_t max, const char *format, size_t CDECL _Strftime(char *str, size_t max, const char *format,
const struct tm *mstm, __lc_time_data *time_data) const struct tm *mstm, void *time_data)
{ {
return strftime_helper(str, max, format, mstm, time_data, NULL); return strftime_helper(str, max, format, mstm, time_data, NULL);
} }
......
...@@ -1112,6 +1112,15 @@ static void test_strftime(void) ...@@ -1112,6 +1112,15 @@ static void test_strftime(void)
ok(ret == 8, "ret = %d\n", ret); ok(ret == 8, "ret = %d\n", ret);
ok(!strcmp(buf, "00:00:00"), "buf = \"%s\", expected \"%s\"\n", buf, "00:00:00"); ok(!strcmp(buf, "00:00:00"), "buf = \"%s\", expected \"%s\"\n", buf, "00:00:00");
setlocale(LC_ALL, "C"); setlocale(LC_ALL, "C");
if(!setlocale(LC_TIME, "Japanese_Japan.932")) {
win_skip("Japanese_Japan.932 locale not available\n");
return;
}
ret = strftime(buf, sizeof(buf), "%a", &epoch);
ok(ret == 2 || broken(ret == 1), "ret = %d\n", ret);
ok(!strcmp(buf, "\x96\xd8"), "buf = %s, expected \"\\x96\\xd8\"\n", wine_dbgstr_an(buf, 2));
setlocale(LC_ALL, "C");
} }
static LONG* get_failures_counter(HANDLE *map) static LONG* get_failures_counter(HANDLE *map)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment