Skip to content

Commit 0cfb29b

Browse files
committed
icalrecur code doc
1 parent ba9962a commit 0cfb29b

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/libical/icalrecur.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
How this code works:
1616
1717
Processing starts when the caller generates a new recurrence
18-
iterator via icalrecur_iterator_new(). This routine copies the
19-
recurrence rule into the iterator and extracts things like start and
18+
iterator via icalrecur_iterator_new(). This routine stores a
19+
reference to the recurrence rule and extracts things like start and
2020
end dates. Then, it checks if the rule is legal, using some logic
2121
from RFC5545 and some logic that probably should be in RFC5545.
2222
@@ -25,12 +25,14 @@
2525
and configures ICU4C to convert occurrences to/from non-Gregorian dates.
2626
2727
Then, icalrecur_iterator_new() re-writes some of the BY*
28-
arrays. This involves ( via a call to setup_defaults() ) :
28+
arrays (this happens within the iterator, the rule itselfs is
29+
treated immutable). This involves ( via a call to setup_defaults() ) :
2930
3031
1) For BY rule parts with no data ( ie BYSECOND was not specified )
31-
copy the corresponding time part from DTSTART into the BY array. (
32-
So impl->by_ptrs[ICAL_BY_SECOND] will then have one element if is
33-
originally had none ) This only happens if the BY* rule part data
32+
set up the corresponding time part from DTSTART in the corresponding
33+
impl->bydata. So impl->bydata[ICAL_BY_SECOND].by will then have one
34+
element if is originally had none ).
35+
This only happens if the BY* rule part data
3436
would expand the number of occurrences in the occurrence set. This
3537
lets the code ignore DTSTART later on and still use it to get the
3638
time parts that were not specified in any other way.
@@ -1171,7 +1173,7 @@ static void recur_iterator_set_static_single_by_value(icalrecur_iterator *impl,
11711173
by->by.size = 1;
11721174
by->by.data = &by->buffer_value;
11731175
by->by.data[0] = value;
1174-
}
1176+
}
11751177

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

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

2151-
impl->bydata[byrule].orig_data =
2152-
(short)(impl->rule->by[byrule].size > 0);
2153+
impl->bydata[byrule].orig_data =
2154+
(short)(impl->rule->by[byrule].size > 0);
21532155

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

22602262
while (this.year < 20000) {
2261-
icalrecurrence_iterator_by_data *bydata = &impl->bydata[ICAL_BY_MONTH];
2263+
icalrecurrence_iterator_by_data *bydata = &impl->bydata[ICAL_BY_MONTH];
22622264
for (bydata->index = 0;
22632265
bydata->index < bydata->by.size; bydata->index++) {
22642266
if (this.month == bydata->by.data[bydata->index])
@@ -2387,7 +2389,7 @@ static int prev_unit(icalrecur_iterator *impl,
23872389
void (*increment_unit)(icalrecur_iterator *, int),
23882390
void (*increment_super_unit)(icalrecur_iterator *, int))
23892391
{
2390-
icalrecurrence_iterator_by_data *bydata = &impl->bydata[by_unit];
2392+
icalrecurrence_iterator_by_data *bydata = &impl->bydata[by_unit];
23912393
int has_by_unit = (by_unit > ICAL_BYRULE_NO_CONTRACTION) &&
23922394
(bydata->by.size > 0);
23932395
int this_frequency = (impl->rule->freq == frequency);

0 commit comments

Comments
 (0)