From ddbf92b2eca29f97d82f4aa6eb213ed59f1e8217 Mon Sep 17 00:00:00 2001 From: Damon Chaplin Date: Mon, 30 Jul 2001 21:31:43 +0000 Subject: copy the TZID just in case the property we got it from gets modified. 2001-07-30 Damon Chaplin * src/libical/icalcomponent.c (icalcomponent_merge_vtimezone): copy the TZID just in case the property we got it from gets modified. (icalcomponent_rename_tzids_callback): break out of the loop if we have renamed the TZID parameter. Otherwise our tzid variable would be invalid. * scripts/mkderivedproperties.pl (fudge_data): changed this so we can set EXDATEs that are DATE values, by checking the is_date field. I'm not entirely sure this is the way it should be done. If it is, I'll also do this for other things like DTSTART/DTEND. * src/libical/icalrecur.c (icalrecurrencetype_as_string): handle UNTIL as a DATE value as well as a DATE-TIME. * src/libical/icalcomponent.c (icalcomponent_compare_vtimezones): fixed stupid error, getting TZID property from wrong VTIMEZONE. This would only have affected iTIP stuff, with VTIMEZONEs that don't use the '/' prefix (i.e. from Outlook). It probably just meant we kept multiple copies of the same VTIMEZONE. * src/libical/icaltimezone.c: removed some debugging messages. svn path=/trunk/; revision=11491 --- libical/src/libical/icalcomponent.c | 37 +++++++++++++++++++------------------ libical/src/libical/icalrecur.c | 6 +++++- libical/src/libical/icaltimezone.c | 3 +-- libical/src/libical/icalvalue.c | 1 - 4 files changed, 25 insertions(+), 22 deletions(-) (limited to 'libical/src') diff --git a/libical/src/libical/icalcomponent.c b/libical/src/libical/icalcomponent.c index a4f0ad7c7f..64b2e0d97f 100644 --- a/libical/src/libical/icalcomponent.c +++ b/libical/src/libical/icalcomponent.c @@ -563,16 +563,12 @@ icalcomponent_add_component (icalcomponent* parent, icalcomponent* child) icalerror_assert( (cimpl->parent ==0),"The child component has already been added to a parent component. Remove the component with icalcomponent_remove_component before calling icalcomponent_add_component"); - fprintf (stderr, "In icalcomponent_add_component\n"); - cimpl->parent = parent; pvl_push(impl->components,child); /* If the new component is a VTIMEZONE, add it to our array. */ if (cimpl->kind == ICAL_VTIMEZONE_COMPONENT) { - fprintf (stderr, " it is a VTIMEZONE component.\n"); - /* FIXME: Currently we are also creating this array when loading in a builtin VTIMEZONE, when we don't need it. */ if (!impl->timezones) @@ -582,9 +578,6 @@ icalcomponent_add_component (icalcomponent* parent, icalcomponent* child) /* Flag that we need to sort it before doing any binary searches. */ impl->timezones_sorted = 0; - - fprintf (stderr, " num timezones in array: %i\n", - impl->timezones->num_elements); } } @@ -1584,6 +1577,7 @@ static void icalcomponent_merge_vtimezone (icalcomponent *comp, { icalproperty *tzid_prop; const char *tzid; + char *tzid_copy; icaltimezone *existing_vtimezone; /* Get the TZID of the VTIMEZONE. */ @@ -1614,14 +1608,22 @@ static void icalcomponent_merge_vtimezone (icalcomponent *comp, /* Now we have two VTIMEZONEs with the same TZID (which isn't a globally unique one), so we compare the VTIMEZONE components to see if they are - the same. If they are, we don't need to do anything. */ - if (icalcomponent_compare_vtimezones (existing_vtimezone, vtimezone)) + the same. If they are, we don't need to do anything. We make a copy of + the tzid, since the parameter may get modified in these calls. */ + tzid_copy = strdup (tzid); + if (!tzid_copy) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); return; - /* FIXME: Handle possible NEWFAILED error. */ + } - /* Now we have two different VTIMEZONEs with the same TZID. */ - icalcomponent_handle_conflicting_vtimezones (comp, vtimezone, tzid_prop, - tzid, tzids_to_rename); + if (!icalcomponent_compare_vtimezones (existing_vtimezone, vtimezone)) { + /* FIXME: Handle possible NEWFAILED error. */ + + /* Now we have two different VTIMEZONEs with the same TZID. */ + icalcomponent_handle_conflicting_vtimezones (comp, vtimezone, tzid_prop, + tzid_copy, tzids_to_rename); + } + free (tzid_copy); } @@ -1745,8 +1747,10 @@ static void icalcomponent_rename_tzids_callback(icalparameter *param, void *data /* Step through the rename table to see if the current TZID matches any of the ones we want to rename. */ for (i = 0; i < rename_table->num_elements - 1; i += 2) { - if (!strcmp (tzid, icalarray_element_at (rename_table, i))) + if (!strcmp (tzid, icalarray_element_at (rename_table, i))) { icalparameter_set_tzid (param, icalarray_element_at (rename_table, i + 1)); + break; + } } } @@ -1813,13 +1817,10 @@ icaltimezone* icalcomponent_get_timezone(icalcomponent* comp, const char *tzid) lower = middle = 0; upper = impl->timezones->num_elements; - fprintf (stderr, "In icalcomponent_get_timezone (%i): %s\n", upper, tzid); - while (lower < upper) { middle = (lower + upper) >> 1; zone = icalarray_element_at (impl->timezones, middle); zone_tzid = icaltimezone_get_tzid (zone); - fprintf (stderr, " comparing with: %s\n", zone_tzid); cmp = strcmp (tzid, zone_tzid); if (cmp == 0) return zone; @@ -1871,7 +1872,7 @@ static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1, return -1; /* Get the TZID property of the second VTIMEZONE. */ - prop2 = icalcomponent_get_first_property (vtimezone1, ICAL_TZID_PROPERTY); + prop2 = icalcomponent_get_first_property (vtimezone2, ICAL_TZID_PROPERTY); if (!prop2) return -1; diff --git a/libical/src/libical/icalrecur.c b/libical/src/libical/icalrecur.c index 99ebf022f6..d998cd0e39 100644 --- a/libical/src/libical/icalrecur.c +++ b/libical/src/libical/icalrecur.c @@ -459,6 +459,7 @@ struct { char* str;size_t offset; short limit; } recurmap[] = }; /* A private routine in icalvalue.c */ +void print_date_to_string(char* str, struct icaltimetype *data); void print_datetime_to_string(char* str, struct icaltimetype *data); char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur) @@ -483,7 +484,10 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur) if(recur->until.year != 0){ temp[0] = 0; - print_datetime_to_string(temp,&(recur->until)); + if (recur->until.is_date) + print_date_to_string(temp,&(recur->until)); + else + print_datetime_to_string(temp,&(recur->until)); icalmemory_append_string(&str,&str_p,&buf_sz,";UNTIL="); icalmemory_append_string(&str,&str_p,&buf_sz, temp); diff --git a/libical/src/libical/icaltimezone.c b/libical/src/libical/icaltimezone.c index 3837888173..5afb7449f2 100644 --- a/libical/src/libical/icaltimezone.c +++ b/libical/src/libical/icaltimezone.c @@ -1305,7 +1305,6 @@ icaltimezone_get_builtin_timezone (const char *location) middle = (lower + upper) >> 1; zone = icalarray_element_at (builtin_timezones, middle); zone_location = icaltimezone_get_location (zone); - fprintf (stderr, " comparing with: %s\n", zone_location); cmp = strcmp (location, zone_location); if (cmp == 0) return zone; @@ -1315,7 +1314,7 @@ icaltimezone_get_builtin_timezone (const char *location) lower = middle + 1; } - fprintf (stderr, " not found\n"); + fprintf (stderr, " ***** not found\n"); return NULL; } diff --git a/libical/src/libical/icalvalue.c b/libical/src/libical/icalvalue.c index e7054bb80d..8c5c1303ea 100644 --- a/libical/src/libical/icalvalue.c +++ b/libical/src/libical/icalvalue.c @@ -805,7 +805,6 @@ void print_datetime_to_string(char* str, struct icaltimetype *data) print_date_to_string(str,data); strcat(str,"T"); print_time_to_string(str,data); - } const char* icalvalue_datetime_as_ical_string(icalvalue* value) { -- cgit v1.2.3