Skip to content

Commit 7b31468

Browse files
committed
RegEx fix for Clang
For some reason Clang toolset doesn't like boost::regex. No time to investigate, switching to std::regex instead
1 parent 695a9a8 commit 7b31468

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Release/src/utilities/asyncrt_utils.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ using namespace Windows::Storage::Streams;
3333
#if !defined(_MS_WINDOWS)
3434
#include <boost/date_time/posix_time/posix_time.hpp>
3535
#include <boost/date_time/posix_time/posix_time_io.hpp>
36+
#ifdef __APPLE__
3637
// GCC 4.8 does not support regex, use boost. TODO: switch to std::regex in GCC 4.9
38+
// Clang already supports std::regex
3739
#include <boost/regex.hpp>
40+
#endif
3841
using namespace boost::locale::conv;
3942
#endif
4043

4144
#ifdef __APPLE__
4245
#include <CoreFoundation/CoreFoundation.h>
46+
#include <regex>
4347
#endif
4448

4549
using namespace web;
@@ -800,16 +804,28 @@ datetime __cdecl datetime::from_string(const utility::string_t& dateString, date
800804
}
801805
else
802806
{
807+
#ifdef __APPLE__
808+
// Try to extract the fractional second from the timestamp
809+
std::regex r_frac_second("(.+)(\\.\\d+)(Z$)");
810+
std::smatch m;
811+
if(std::regex_search(input,m,r_frac_second))
812+
{
813+
auto frac = m[2].str(); // this is the fractional second
814+
ufrac_second = timeticks_from_second(frac);
815+
input = m[1].str() + m[3].str();
816+
}
817+
#else
818+
std::regex r_frac_second2("(.+)(\\.\\d+)(Z$)");
803819
// Try to extract the fractional second from the timestamp
804820
boost::regex r_frac_second("(.+)(\\.\\d+)(Z$)");
805821
boost::smatch m;
806-
807822
if(boost::regex_search(input,m,r_frac_second))
808823
{
809824
auto frac = m[2].str(); // this is the fractional second
810825
ufrac_second = timeticks_from_second(frac);
811826
input = m[1].str() + m[3].str();
812827
}
828+
#endif
813829

814830
auto result = strptime(input.data(), "%Y-%m-%dT%H:%M:%SZ", &output);
815831

@@ -845,7 +861,7 @@ datetime __cdecl datetime::from_string(const utility::string_t& dateString, date
845861

846862
struct timeval tv = timeval();
847863
tv.tv_sec = time;
848-
tv.tv_usec = (__suseconds_t)ufrac_second;
864+
tv.tv_usec = (unsigned int)ufrac_second;
849865
return timeval_to_datetime(tv);
850866
#endif
851867
}

0 commit comments

Comments
 (0)