From 6543d06edf95f7e1e788740930a9a6593465004b Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 26 Sep 2001 23:10:08 +0000 Subject: Fix the libical-related part of Ximian bug #7892. 2001-09-26 Federico Mena Quintero Fix the libical-related part of Ximian bug #7892. * src/libical/icalduration.c (icaldurationtype_as_ical_string): The correct string for zero seconds is "PT0S", not "PTS0". Also handle "negative zero" durations. * src/libical/icalvalue.c (icalvalue_new_from_string_with_error): Use icalerrno to see if the duration string is invalid. We cannot use icaldurationtype_is_null_duration() because a duration of zero *is* valid, not an error (icalduration_type_from_string() returns a zero duration on parse error, too). svn path=/trunk/; revision=13172 --- libical/src/libical/icalduration.c | 4 ++-- libical/src/libical/icalduration.h | 2 +- libical/src/libical/icalvalue.c | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'libical/src') diff --git a/libical/src/libical/icalduration.c b/libical/src/libical/icalduration.c index 18a74396f5..250cd6e3d6 100644 --- a/libical/src/libical/icalduration.c +++ b/libical/src/libical/icalduration.c @@ -250,7 +250,7 @@ char* icaldurationtype_as_ical_string(struct icaldurationtype d) } } else { - icalmemory_append_string(&buf, &buf_ptr, &buf_size, "PTS0"); + icalmemory_append_string(&buf, &buf_ptr, &buf_size, d.is_neg ? "-PT0S" : "PT0S"); } output_line = icalmemory_tmp_copy(buf); @@ -274,7 +274,7 @@ int icaldurationtype_as_int(struct icaldurationtype dur) * (dur.is_neg==1? -1 : 1) ) ; } -struct icaldurationtype icaldurationtype_null_duration() +struct icaldurationtype icaldurationtype_null_duration(void) { struct icaldurationtype d; diff --git a/libical/src/libical/icalduration.h b/libical/src/libical/icalduration.h index dd6e311f47..0450a081d3 100644 --- a/libical/src/libical/icalduration.h +++ b/libical/src/libical/icalduration.h @@ -45,7 +45,7 @@ struct icaldurationtype icaldurationtype_from_int(int t); struct icaldurationtype icaldurationtype_from_string(const char*); int icaldurationtype_as_int(struct icaldurationtype duration); char* icaldurationtype_as_ical_string(struct icaldurationtype d); -struct icaldurationtype icaldurationtype_null_duration(); +struct icaldurationtype icaldurationtype_null_duration(void); int icaldurationtype_is_null_duration(struct icaldurationtype d); struct icaltimetype icaltime_add(struct icaltimetype t, diff --git a/libical/src/libical/icalvalue.c b/libical/src/libical/icalvalue.c index 7414c7c173..b7852c3216 100644 --- a/libical/src/libical/icalvalue.c +++ b/libical/src/libical/icalvalue.c @@ -436,12 +436,11 @@ icalvalue_new_from_string_with_error(icalvalue_kind kind,const char* str,icalpro case ICAL_DURATION_VALUE: { struct icaldurationtype dur = icaldurationtype_from_string(str); - - if(icaldurationtype_is_null_duration(dur)){ - value = 0; - } else { + + if (icalerrno == ICAL_MALFORMEDDATA_ERROR) + value = 0; + else value = icalvalue_new_duration(dur); - } break; } -- cgit v1.2.3