]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
calendarspec: fix duplicate detection (#5310)
authorDoug Christman <douglaschristman@gmail.com>
Sun, 12 Feb 2017 05:39:17 +0000 (00:39 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 12 Feb 2017 05:39:17 +0000 (00:39 -0500)
a2eb5ea79c added a new field to `CalendarComponent`; update
`normalize_chain` to compare all fields when dropping duplicates

src/basic/calendarspec.c
src/test/test-calendarspec.c

index 3fa1c51ace0496d3f7646dfed54ec842e092e7b1..2323eb85556b24df4adc1a87a7337eb9e20ad5cb 100644 (file)
@@ -116,8 +116,7 @@ static void normalize_chain(CalendarComponent **c) {
 
         /* Drop non-unique entries */
         for (k = n-1; k > 0; k--) {
-                if (b[k-1]->start == next->start &&
-                    b[k-1]->repeat == next->repeat) {
+                if (component_compare(&b[k-1], &next) == 0) {
                         free(b[k-1]);
                         continue;
                 }
index 1f34a91b100d5f2cb2095009df53317727b4c083..f90b73aeaf31862e6540bd55c4daf6c65cb088d5 100644 (file)
@@ -192,6 +192,7 @@ int main(int argc, char* argv[]) {
         test_one("00..07-*-*", "2000..2007-*-* 00:00:00");
         test_one("*:20..39/5", "*-*-* *:20..35/5:00");
         test_one("00:00:20..40/1", "*-*-* 00:00:20..40");
+        test_one("*~03/1,03..05", "*-*~03/1,03..05 00:00:00");
 
         test_next("2016-03-27 03:17:00", "", 12345, 1459048620000000);
         test_next("2016-03-27 03:17:00", "CET", 12345, 1459041420000000);