aboutsummaryrefslogtreecommitdiffstats
path: root/libical
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-09-27 07:10:08 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-09-27 07:10:08 +0800
commit6543d06edf95f7e1e788740930a9a6593465004b (patch)
tree1efc9b2257ba9086b1e4910222afd33ab3b61e38 /libical
parent62c86e7472d3e4c13726bb6b3c735f1fc47b0151 (diff)
downloadgsoc2013-evolution-6543d06edf95f7e1e788740930a9a6593465004b.tar.gz
gsoc2013-evolution-6543d06edf95f7e1e788740930a9a6593465004b.tar.zst
gsoc2013-evolution-6543d06edf95f7e1e788740930a9a6593465004b.zip
Fix the libical-related part of Ximian bug #7892.
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). svn path=/trunk/; revision=13172
Diffstat (limited to 'libical')
-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;
}