summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Winter <allen.winter@kdab.com>2019-07-07 11:54:12 -0400
committerAllen Winter <allen.winter@kdab.com>2019-07-07 11:54:12 -0400
commit404fc0d9aedccedac9f8ed5454cb2a6683c45267 (patch)
tree223808d9a3bba038db666b00cc44a79395fa177f
parent8e72ee3212fb7ff6cc5c9314fdc7c0223321f08a (diff)
downloadlibical-git-icalrecur_iterator_prev.tar.gz
various minor improvements for iterating to previous occurenceicalrecur_iterator_prev
coding style, clang-analyzer, ReleaseNotes
-rw-r--r--ReleaseNotes.txt2
-rw-r--r--src/libical/icalrecur.c23
-rw-r--r--src/libical/icalrecur.h9
-rw-r--r--src/test/icalrecur_test.c1
4 files changed, 21 insertions, 14 deletions
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
index 190da77b..51638642 100644
--- a/ReleaseNotes.txt
+++ b/ReleaseNotes.txt
@@ -5,6 +5,7 @@ Version 3.1.0 (NOT RELEASED YET):
--------------------------------
* Requires CMake v3.11.0 or higher
* Improved FindICU (from the official CMake)
+ * Allow previous recurrence iteration
* All ical*_new_clone() functions have been deprecated in favour of ical*_clone()
* New publicly available functions:
+ icalrecurrencetype_encode_day
@@ -15,6 +16,7 @@ Version 3.1.0 (NOT RELEASED YET):
+ icalparameter_clone
+ icalvalue_clone
+ icalcluster_clone
+ + icalrecur_iterator_prev
* icaltzutil_get_zone_directory() can use the TZDIR environment to find system zoneinfo
* Deprecated functions:
+ caldat (replaced by internal function icaldat_int())
diff --git a/src/libical/icalrecur.c b/src/libical/icalrecur.c
index d28f7531..b0ee4254 100644
--- a/src/libical/icalrecur.c
+++ b/src/libical/icalrecur.c
@@ -2930,7 +2930,6 @@ static short daymask_find_prev_bit(icalrecur_iterator *impl)
// Are there more empty words leading? Skip them.
while (days_index > -ICAL_YEARDAYS_MASK_OFFSET) {
-
wordIdx--;
v = days[wordIdx];
@@ -2960,10 +2959,10 @@ static short daymask_find_prev_bit(icalrecur_iterator *impl)
mask <<= maskSize;
}
}
-
+
return days_index;
- }
-
+}
+
static int next_yearday(icalrecur_iterator *impl,
void (*next_period)(icalrecur_iterator *, int))
{
@@ -3014,7 +3013,7 @@ static int prev_yearday(icalrecur_iterator *impl,
/* Find previous year day that is set */
impl->days_index = daymask_find_prev_bit(impl);
- while (impl->days_index <= -ICAL_YEARDAYS_MASK_OFFSET) {
+ while (impl->days_index <= -ICAL_YEARDAYS_MASK_OFFSET) {
/* Decrement to and expand the previous period */
next_period(impl, -impl->rule.interval);
@@ -3438,20 +3437,20 @@ int icalrecur_iterator_set_range(icalrecur_iterator *impl,
if (icaltime_compare(from, impl->rule.until) > 0) {
/* If 'from' is after UNTIL, use UNTIL */
from = impl->rule.until;
- }
- else if (icaltime_compare(from, impl->dtstart) < 0) {
+ } else if (icaltime_compare(from, impl->dtstart) < 0) {
/* If 'from' is before START, we're done */
impl->last = from;
return 1;
}
- if (!__iterator_set_start(impl, from)) return 0;
+ if (!__iterator_set_start(impl, from))
+ return 0;
/* __iterator_set_start() may back us up earlier than 'from'
Iterate forward until we are later than 'from'.
*/
while (icaltime_compare(impl->last, from) < 0) {
- icalrecur_iterator_next(impl);
+ (void)icalrecur_iterator_next(impl);
}
/* Convert 'to' to same time zone as DTSTART */
@@ -3465,9 +3464,9 @@ int icalrecur_iterator_set_range(icalrecur_iterator *impl,
impl->istart = to;
impl->iend = from;
impl->days_index = 0;
- }
- else {
- if (!icalrecur_iterator_set_start(impl, from)) return 0;
+ } else {
+ if (!icalrecur_iterator_set_start(impl, from))
+ return 0;
icalrecur_iterator_set_end(impl, to);
}
diff --git a/src/libical/icalrecur.h b/src/libical/icalrecur.h
index 18f271da..3dde2a69 100644
--- a/src/libical/icalrecur.h
+++ b/src/libical/icalrecur.h
@@ -285,10 +285,15 @@ LIBICAL_ICAL_EXPORT int icalrecur_iterator_set_range(icalrecur_iterator *impl,
struct icaltimetype from,
struct icaltimetype to);
-/** Get the next occurrence from an iterator */
+/**
+ * Gets the next occurrence from an iterator
+ */
LIBICAL_ICAL_EXPORT struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *);
-/** Get the previous occurrence from an iterator */
+/**
+ * Gets the previous occurrence from an iterator
+ * @since 3.1
+ */
LIBICAL_ICAL_EXPORT struct icaltimetype icalrecur_iterator_prev(icalrecur_iterator *);
/** Free the iterator */
diff --git a/src/test/icalrecur_test.c b/src/test/icalrecur_test.c
index 42eb4b45..c2363561 100644
--- a/src/test/icalrecur_test.c
+++ b/src/test/icalrecur_test.c
@@ -625,6 +625,7 @@ int main(int argc, char *argv[])
fprintf(fp, " *** %s\n", icalerror_strerror(icalerrno));
} else {
struct icaltimetype start;
+ start = icaltime_null_time();
if (r->start_at) {
start = icaltime_from_string(r->start_at);