@@ -1093,14 +1093,33 @@ static tstring
1093
1093
preprocessDateTimePattern (const tstring_view& pattern, DailyRollingFileSchedule& schedule)
1094
1094
{
1095
1095
// Example: "yyyy-MM-dd HH:mm:ss,aux"
1096
+ // Example with space(s) between the ',' and 'aux': "yyyy-MM-dd HH:mm:ss, aux"
1096
1097
// Patterns from java.text.SimpleDateFormat not implemented here: Y, F, k, K, S, X
1097
1098
1098
1099
tostringstream result;
1099
1100
1100
- bool auxilary = (pattern.find (LOG4CPLUS_TEXT (" ,aux" )) == pattern.length ()-4 );
1101
+ size_t aux_len = 0 ;
1102
+ auto pattern_length = pattern.length ();
1103
+ if (pattern_length >= 4 && pattern.find (LOG4CPLUS_TEXT (" aux" ), pattern_length-3 ) == pattern_length-3 ) {
1104
+ auto const comma_pos = pattern.rfind (LOG4CPLUS_TEXT (" ," ));
1105
+ if (comma_pos != tstring_view::npos) {
1106
+ auto const comma_to_aux_len = pattern_length - 4 - comma_pos;
1107
+ if (comma_to_aux_len == 0 ) {
1108
+ aux_len = 4 ;
1109
+ }
1110
+ else if (comma_to_aux_len > 0 ) {
1111
+ auto const space_str = pattern.substr (comma_pos+1 , comma_to_aux_len);
1112
+ if (space_str == tstring (comma_to_aux_len, ' ' )) {
1113
+ aux_len = 4 + comma_to_aux_len;
1114
+ }
1115
+ }
1116
+ pattern_length -= aux_len;
1117
+ }
1118
+ }
1119
+
1101
1120
bool has_week = false , has_day = false , has_hour = false , has_minute = false ;
1102
1121
1103
- for (size_t i = 0 , pattern_length = pattern. length () ; i < pattern_length; )
1122
+ for (size_t i = 0 ; i < pattern_length; )
1104
1123
{
1105
1124
tchar c = pattern[i];
1106
1125
size_t end_pos = pattern.find_first_not_of (c, i);
@@ -1202,7 +1221,7 @@ preprocessDateTimePattern(const tstring_view& pattern, DailyRollingFileSchedule&
1202
1221
i += len;
1203
1222
}
1204
1223
1205
- if (!auxilary )
1224
+ if (aux_len == 0 )
1206
1225
{
1207
1226
if (has_minute)
1208
1227
schedule = MINUTELY;
0 commit comments