msvcrt: Implement %n and %t formats for strftime.

Signed-off-by: Vijay Kiran Kamuju <infyquest@gmail.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Vijay Kiran Kamuju 2019-10-11 22:35:23 +02:00 committed by Alexandre Julliard
parent 90e520b418
commit c583c4afaa
3 changed files with 26 additions and 0 deletions

View File

@ -633,11 +633,21 @@ static void test_strftime(void)
ok(retA == 0, "expected 0, got %ld\n", retA);
ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
errno = 0xdeadbeef;
retA = p_strftime(bufA, 256, "%n", gmt_tm);
ok(retA == 0, "expected 0, got %ld\n", retA);
ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
errno = 0xdeadbeef;
retA = p_strftime(bufA, 256, "%R", gmt_tm);
ok(retA == 0, "expected 0, got %ld\n", retA);
ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
errno = 0xdeadbeef;
retA = p_strftime(bufA, 256, "%t", gmt_tm);
ok(retA == 0, "expected 0, got %ld\n", retA);
ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
errno = 0xdeadbeef;
retA = p_strftime(bufA, 256, "%T", gmt_tm);
ok(retA == 0, "expected 0, got %ld\n", retA);

View File

@ -1225,6 +1225,11 @@ static MSVCRT_size_t strftime_helper(char *str, MSVCRT_size_t max, const char *f
if(!strftime_int(str, &ret, max, mstm->tm_min, alternate ? 0 : 2, 0, 59))
return 0;
break;
#if _MSVCR_VER>=140
case 'n':
str[ret++] = '\n';
break;
#endif
case 'p':
if(mstm->tm_hour<0 || mstm->tm_hour>23)
goto einval_error;
@ -1247,6 +1252,9 @@ static MSVCRT_size_t strftime_helper(char *str, MSVCRT_size_t max, const char *f
return 0;
break;
#if _MSVCR_VER>=140
case 't':
str[ret++] = '\t';
break;
case 'T':
if(!strftime_int(str, &ret, max, mstm->tm_hour, alternate ? 0 : 2, 0, 23))
return 0;

View File

@ -942,6 +942,14 @@ static void test_strftime(void)
retA = p_strftime(bufA, sizeof(bufA), "%h", &epoch);
ok(retA == 3, "expected 3, got %d\n", (int)retA);
ok(!strcmp(bufA, "Jan"), "got %s\n", bufA);
retA = p_strftime(bufA, sizeof(bufA), "%n", &epoch);
ok(retA == 1, "expected 1, got %d\n", (int)retA);
ok(!strcmp(bufA, "\n"), "got %s\n", bufA);
retA = p_strftime(bufA, sizeof(bufA), "%t", &epoch);
ok(retA == 1, "expected 1, got %d\n", (int)retA);
ok(!strcmp(bufA, "\t"), "got %s\n", bufA);
}
static LONG* get_failures_counter(HANDLE *map)