From: helge Date: Sat, 30 Jul 2005 16:41:41 +0000 (+0000) Subject: hardened against nil arguments X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7556ec9b995eecf3e0865375c4f6cb1406f49d15;p=scalable-opengroupware.org hardened against nil arguments git-svn-id: http://svn.opengroupware.org/SOGo/trunk@922 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/UI/SOGoUI/ChangeLog b/UI/SOGoUI/ChangeLog index 7c10b6e8..b7b1ba98 100644 --- a/UI/SOGoUI/ChangeLog +++ b/UI/SOGoUI/ChangeLog @@ -1,3 +1,7 @@ +2005-07-30 Helge Hess + + * SOGoDateFormatter.m: hardened against nil arguments (v0.9.35) + 2005-07-21 Marcus Mueller * UIxComponent.m: changed -userFolderPath to generate the path to the diff --git a/UI/SOGoUI/SOGoDateFormatter.m b/UI/SOGoUI/SOGoDateFormatter.m index e5cf1957..33124342 100644 --- a/UI/SOGoUI/SOGoDateFormatter.m +++ b/UI/SOGoUI/SOGoDateFormatter.m @@ -37,12 +37,11 @@ - (id)initWithLocale:(NSDictionary *)_locale { if ((self = [super init])) { self->locale = [_locale retain]; - if ([[self->locale objectForKey:@"NSLocaleCode"] isEqualToString:@"fr"]) { + + if ([[self->locale objectForKey:@"NSLocaleCode"] isEqualToString:@"fr"]) [self setFrenchDateFormat]; - } - else { + else [self setISODateFormat]; - } } return self; } @@ -100,22 +99,30 @@ /* Private API */ - (NSString *)isoDateFormatForDate:(NSCalendarDate *)_date { - return [NSString stringWithFormat:@"%04d-%02d-%02d", - [_date yearOfCommonEra], - [_date monthOfYear], - [_date dayOfMonth]]; + char buf[16]; + + if (_date == nil) return nil; + snprintf(buf, sizeof(buf), + "%04d-%02d-%02d", + [_date yearOfCommonEra], [_date monthOfYear], [_date dayOfMonth]); + return [NSString stringWithCString:buf]; } - (NSString *)frenchDateFormatForDate:(NSCalendarDate *)_date { - return [NSString stringWithFormat:@"%02d/%02d/%04d", - [_date dayOfMonth], - [_date monthOfYear], - [_date yearOfCommonEra]]; + char buf[16]; + + if (_date == nil) return nil; + snprintf(buf, sizeof(buf), + "%02d/%02d/%04d", + [_date dayOfMonth], [_date monthOfYear], [_date yearOfCommonEra]); + return [NSString stringWithCString:buf]; } - (NSString *)fullWeekdayNameAndDetailsForDate:(NSCalendarDate *)_date { NSMutableString *desc; + if (_date == nil) return nil; + desc = [NSMutableString stringWithCapacity:24]; [desc appendString:[self fullDayOfWeek:[_date dayOfWeek]]]; [desc appendString:@", "]; diff --git a/UI/SOGoUI/Version b/UI/SOGoUI/Version index 3a66b827..21352434 100644 --- a/UI/SOGoUI/Version +++ b/UI/SOGoUI/Version @@ -1,5 +1,5 @@ # version file -SUBMINOR_VERSION:=34 +SUBMINOR_VERSION:=35 # v0.9.18 requires NGExtensions v4.5.136