Skip to content

Commit

Permalink
icalrecur code doc
Browse files Browse the repository at this point in the history
  • Loading branch information
minichma committed Sep 30, 2024
1 parent 3495de6 commit cbfa746
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/libical/icalrecur.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
How this code works:
Processing starts when the caller generates a new recurrence
iterator via icalrecur_iterator_new(). This routine copies the
recurrence rule into the iterator and extracts things like start and
iterator via icalrecur_iterator_new(). This routine stores a
reference to the recurrence rule and extracts things like start and
end dates. Then, it checks if the rule is legal, using some logic
from RFC5545 and some logic that probably should be in RFC5545.
Expand All @@ -25,12 +25,14 @@
and configures ICU4C to convert occurrences to/from non-Gregorian dates.
Then, icalrecur_iterator_new() re-writes some of the BY*
arrays. This involves ( via a call to setup_defaults() ) :
arrays (this happens within the iterator, the rule itselfs is
treated immutable). This involves ( via a call to setup_defaults() ) :
1) For BY rule parts with no data ( ie BYSECOND was not specified )
copy the corresponding time part from DTSTART into the BY array. (
So impl->by_ptrs[ICAL_BY_SECOND] will then have one element if is
originally had none ) This only happens if the BY* rule part data
set up the corresponding time part from DTSTART in the corresponding
impl->bydata. So impl->bydata[ICAL_BY_SECOND].by will then have one
element if is originally had none ).
This only happens if the BY* rule part data
would expand the number of occurrences in the occurrence set. This
lets the code ignore DTSTART later on and still use it to get the
time parts that were not specified in any other way.
Expand Down Expand Up @@ -1171,7 +1173,7 @@ static void recur_iterator_set_static_single_by_value(icalrecur_iterator *impl,
by->by.size = 1;
by->by.data = &by->buffer_value;
by->by.data[0] = value;
}
}

static void setup_defaults(icalrecur_iterator *impl,
icalrecurrencetype_byrule byrule, int deftime)
Expand Down Expand Up @@ -2143,15 +2145,15 @@ icalrecur_iterator *icalrecur_iterator_new(struct icalrecurrencetype *rule,
for (byrule = 0; byrule < ICAL_BY_NUM_PARTS; byrule++) {
impl->bydata[byrule].by = impl->rule->by[byrule];

/* Note which by rules had data in them when the iterator was
created. We can't use the actual by_x arrays, because the
empty ones will be given default values later in this
routine. The orig_data array will be used later in has_by_data */
/* Note which by rules had data in them when the iterator was
created. We can't use the actual by_x arrays, because the
empty ones will be given default values later in this
routine. The orig_data array will be used later in has_by_data */

impl->bydata[byrule].orig_data =
(short)(impl->rule->by[byrule].size > 0);
impl->bydata[byrule].orig_data =
(short)(impl->rule->by[byrule].size > 0);

/* Check if the recurrence rule is legal */
/* Check if the recurrence rule is legal */
if (expand_map[freq].map[byrule] == ILLEGAL &&
has_by_data(impl, byrule)) {
ical_invalid_rrule_handling rruleHandlingSetting =
Expand Down Expand Up @@ -2258,7 +2260,7 @@ static void increment_month(icalrecur_iterator *impl, int inc)
struct icaltimetype this = occurrence_as_icaltime(impl, 0);

while (this.year < 20000) {
icalrecurrence_iterator_by_data *bydata = &impl->bydata[ICAL_BY_MONTH];
icalrecurrence_iterator_by_data *bydata = &impl->bydata[ICAL_BY_MONTH];
for (bydata->index = 0;
bydata->index < bydata->by.size; bydata->index++) {
if (this.month == bydata->by.data[bydata->index])
Expand Down Expand Up @@ -2387,7 +2389,7 @@ static int prev_unit(icalrecur_iterator *impl,
void (*increment_unit)(icalrecur_iterator *, int),
void (*increment_super_unit)(icalrecur_iterator *, int))
{
icalrecurrence_iterator_by_data *bydata = &impl->bydata[by_unit];
icalrecurrence_iterator_by_data *bydata = &impl->bydata[by_unit];
int has_by_unit = (by_unit > ICAL_BYRULE_NO_CONTRACTION) &&
(bydata->by.size > 0);
int this_frequency = (impl->rule->freq == frequency);
Expand Down

0 comments on commit cbfa746

Please sign in to comment.