From bd238bfd7c443fd974f5b7edd6c1abc0349bfa78 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Thu, 7 May 2020 21:39:23 +0200 Subject: Fix recurrence rule expansion with ordered weekday When the order of a weekday in BYDAY rule expansion (like -5SA or 5SU for monthly or 55WE for yearly) exceeds the number of available weekdays in the period (month or year), rule expansion with negative order could result in a floating point exception. The reason: the modified frequency might become zero. Solution. Check order against number of available weekdays and terminate expansion early whenever possible (also for positive orders). Signed-off-by: Lars Henriksen Signed-off-by: Lukas Fleischer --- test/recur-009.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/recur-009.sh') diff --git a/test/recur-009.sh b/test/recur-009.sh index 6ee302d..2558b4c 100755 --- a/test/recur-009.sh +++ b/test/recur-009.sh @@ -6,6 +6,13 @@ if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/rfc5545" \ -Q --from 1/1/1996 --to 12/31/2007 --filter-type recur + echo "" + echo "Floating point exception?" + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/rfc5545" \ + -Q --day 8/1/2020 --filter-type recur && + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/rfc5545" \ + -Q --day 11/1/2020 --filter-type recur && + echo "No Floating point exception on November 1, 2020" elif [ "$1" = 'expected' ]; then cat < 10:11 + negative ordered weekday may not exist +No Floating point exception on November 1, 2020 EOD else ./run-test "$0" -- cgit v1.2.3-54-g00ecf