From c583c4afaaac539359fb513c3e6e010d9cd6f99d Mon Sep 17 00:00:00 2001 From: Vijay Kiran Kamuju Date: Fri, 11 Oct 2019 22:35:23 +0200 Subject: [PATCH] msvcrt: Implement %n and %t formats for strftime. Signed-off-by: Vijay Kiran Kamuju Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcrt/tests/time.c | 10 ++++++++++ dlls/msvcrt/time.c | 8 ++++++++ dlls/ucrtbase/tests/misc.c | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/dlls/msvcrt/tests/time.c b/dlls/msvcrt/tests/time.c index 7eea78367db..beba7963179 100644 --- a/dlls/msvcrt/tests/time.c +++ b/dlls/msvcrt/tests/time.c @@ -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); diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index 6108ad17cce..78f46029720 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -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; diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c index 0d865fdcb8a..9747d8b21ab 100644 --- a/dlls/ucrtbase/tests/misc.c +++ b/dlls/ucrtbase/tests/misc.c @@ -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)