Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

Edited Issue: datetime - dev14 swscanf_s doesn't fill the month [311]

$
0
0
This makes the following two test cases fail in datetime.cpp: parsing_dateandtime_basic and parsing_dateandtime_extended.

Quickly debugging the problem is swscanf_s is not filling in the month correctly, causing the failure. This can be seen stepping through in asyncrt_utils.cpp around line 835. Something must have changed in the CRT or maybe there has been a regression. Needs more investigation, for now the two tests are disabled on dev14.

```
SYSTEMTIME sysTime = {0};

std::wstring month(3, L'\0');
std::wstring unused(3, L'\0');

const wchar_t * formatString = L"%3c, %2d %3c %4d %2d:%2d:%2d %3c";
auto n = swscanf_s(dateString.c_str(), formatString,
unused.data(), unused.size(),
&sysTime.wDay,
month.data(), month.size(),
&sysTime.wYear,
&sysTime.wHour,
&sysTime.wMinute,
&sysTime.wSecond,
unused.data(), unused.size());

if (n == 8)
{
std::wstring monthnames[12] = {L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"};
auto loc = std::find_if(monthnames, monthnames+12, [&month](const std::wstring& m) { return m == month;});

if (loc != monthnames+12)
{
sysTime.wMonth = (short) ((loc - monthnames) + 1);
if (system_type_to_datetime(&sysTime, ufrac_second, &result))
{
return result;
}
}
}
```



Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>