This is an automated email from the ASF dual-hosted git repository.

szaszm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git

commit 716631500ef2b2d758721b53f4839def83d3a7e5
Author: Martin Zink <[email protected]>
AuthorDate: Wed May 31 15:37:20 2023 +0200

    MINIFICPP-2119 fix CronTests error with classic locale
    
    Closes #1579
    Signed-off-by: Marton Szasz <[email protected]>
---
 libminifi/src/utils/Cron.cpp | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libminifi/src/utils/Cron.cpp b/libminifi/src/utils/Cron.cpp
index 9961669a2..677423a00 100644
--- a/libminifi/src/utils/Cron.cpp
+++ b/libminifi/src/utils/Cron.cpp
@@ -49,15 +49,17 @@ namespace {
 // Due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78714
 // the month parsing with '%b' and the weekday parsing with '%a' is 
case-sensitive in gcc11
 // This has been fixed in gcc12.2
-std::stringstream getCaseInsensitiveStream(const std::string& str) {
+std::stringstream getCaseInsensitiveCStream(const std::string& str) {
 #if defined(__GNUC__) && (__GNUC__ < 12 || (__GNUC__ == 12 && __GNUC_MINOR__ < 
2))
   auto patched_str = StringUtils::toLower(str);
   if (!patched_str.empty())
     patched_str[0] = static_cast<char>(std::toupper(static_cast<unsigned 
char>(patched_str[0])));
-  return std::stringstream{patched_str};
+  auto stream = std::stringstream{patched_str};
 #else
-  return std::stringstream{str};
+  auto stream = std::stringstream{str};
 #endif
+  stream.imbue(std::locale::classic());
+  return stream;
 }
 
 
@@ -114,9 +116,8 @@ day parse<day>(const std::string& day_str) {
 
 template <>
 month parse<month>(const std::string& month_str) {
-  std::stringstream stream = getCaseInsensitiveStream(month_str);
+  std::stringstream stream = getCaseInsensitiveCStream(month_str);
 
-  stream.imbue(std::locale("en_US.UTF-8"));
   month parsed_month{};
   if (month_str.size() > 2) {
     from_stream(stream, "%b", parsed_month);
@@ -133,7 +134,7 @@ month parse<month>(const std::string& month_str) {
 
 template <>
 weekday parse<weekday>(const std::string& weekday_str) {
-  std::stringstream stream = getCaseInsensitiveStream(weekday_str);
+  std::stringstream stream = getCaseInsensitiveCStream(weekday_str);
 
   if (weekday_str.size() > 2) {
     weekday parsed_weekday{};

Reply via email to