Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 40fc365

Browse files
author
Fraser J. Gordon
committed
Fix bug 11162
Date format string parsing has been made less strict in its processing, now collapsing one or more spaces together to allow a ' ' in a format string to match one or more input spaces. Additionally, spaces in the input after a formatting specifier was successfully matched are ignored. With these changes, both "10:41 PM" and "10:41PM" are accepted as valid times; previously, only the former was acceptable.
1 parent 004b06d commit 40fc365

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

engine/src/date.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,16 @@ static bool datetime_parse(const MCDateTimeLocale *p_locale, int4 p_century_cuto
445445
t_valid = true;
446446
break;
447447
}
448+
449+
// FG-2013-09-10 [[ Bug 11162 ]]
450+
// Trailing spaces after an accepted format specifier should be squashed
451+
if (t_valid && !t_skip)
452+
{
453+
while (p_format[1] != '\0' && isspace(p_format[1]))
454+
p_format++;
455+
while (t_input_length > 1 && isspace(t_input[1]))
456+
t_input++, t_input_length--;
457+
}
448458

449459
}
450460
else if (*p_format != *t_input)
@@ -474,6 +484,13 @@ static bool datetime_parse(const MCDateTimeLocale *p_locale, int4 p_century_cuto
474484
}
475485
else
476486
{
487+
// FG-2013-09-10 [[ Bug 11162 ]]
488+
// One or more spaces in the format string should accept any number of input spaces
489+
while (t_input_length > 0 && isspace(*t_input))
490+
t_input += 1, t_input_length -= 1;
491+
while (*p_format != '\0' && isspace(*p_format))
492+
p_format++;
493+
477494
if (t_input_length > 0)
478495
{
479496
t_input += 1;

0 commit comments

Comments
 (0)