aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libical/ChangeLog14
-rw-r--r--libical/src/libical/icalduration.c4
-rw-r--r--libical/src/libical/icalduration.h2
-rw-r--r--libical/src/libical/icalvalue.c9
4 files changed, 21 insertions, 8 deletions
diff --git a/libical/ChangeLog b/libical/ChangeLog
index bb1cb362f0..41d6d84ad0 100644
--- a/libical/ChangeLog
+++ b/libical/ChangeLog
@@ -1,3 +1,17 @@
+2001-09-26 Federico Mena Quintero <federico@ximian.com>
+
+ 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).
+
2001-09-19 Larry Ewing <lewing@ximian.com>
* src/libical/icalperiod.c (icalperiodtype_from_string): free the
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;
}