mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-07-17 00:59:32 +03:00
shared/calendarspec: fix printing of second ranges which start with 0
0..3 is not the same as 0..infinity, we need to check both ends of the range. This logic was added in3215e35c40
, and back then the field was called .value. .stop was added later and apparently wasn't taken into account here. (cherry picked from commit3aff2ae9d5
)
This commit is contained in:
@ -304,7 +304,7 @@ static void format_chain(FILE *f, int space, const CalendarComponent *c, bool us
|
||||
return;
|
||||
}
|
||||
|
||||
if (usec && c->start == 0 && c->repeat == USEC_PER_SEC && !c->next) {
|
||||
if (usec && c->start == 0 && c->stop < 0 && c->repeat == USEC_PER_SEC && !c->next) {
|
||||
fputc('*', f);
|
||||
return;
|
||||
}
|
||||
|
@ -157,6 +157,8 @@ TEST(calendar_spec_one) {
|
||||
test_one("00:00:1.0..3.8", "*-*-* 00:00:01..03");
|
||||
test_one("00:00:01..03", "*-*-* 00:00:01..03");
|
||||
test_one("00:00:01/2,02..03", "*-*-* 00:00:01/2,02..03");
|
||||
test_one("*:4,30:0..3", "*-*-* *:04,30:00..03");
|
||||
test_one("*:4,30:0/1", "*-*-* *:04,30:*");
|
||||
test_one("*-*~1 Utc", "*-*~01 00:00:00 UTC");
|
||||
test_one("*-*~05,3 ", "*-*~03,05 00:00:00");
|
||||
test_one("*-*~* 00:00:00", "*-*-* 00:00:00");
|
||||
@ -247,6 +249,9 @@ TEST(calendar_spec_from_string) {
|
||||
assert_se(calendar_spec_from_string("00:00:2300", &c) < 0);
|
||||
assert_se(calendar_spec_from_string("00:00:18446744073709551615", &c) < 0);
|
||||
assert_se(calendar_spec_from_string("@88588582097858858", &c) == -ERANGE);
|
||||
assert_se(calendar_spec_from_string("*:4,30:*,5", &c) == -EINVAL);
|
||||
assert_se(calendar_spec_from_string("*:4,30:5,*", &c) == -EINVAL);
|
||||
assert_se(calendar_spec_from_string("*:4,30:*\n", &c) == -EINVAL);
|
||||
}
|
||||
|
||||
DEFINE_TEST_MAIN(LOG_INFO);
|
||||
|
Reference in New Issue
Block a user