From: helge Date: Wed, 21 Nov 2007 20:29:59 +0000 (+0000) Subject: fixed a unicode issue X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77c5ad80274f71eccb43d185254c110f7a4759a3;p=sope fixed a unicode issue git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1549 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-ldap/NGLdap/ChangeLog b/sope-ldap/NGLdap/ChangeLog index e3d281dd..67dec7e4 100644 --- a/sope-ldap/NGLdap/ChangeLog +++ b/sope-ldap/NGLdap/ChangeLog @@ -1,3 +1,8 @@ +2007-11-21 Helge Hess + + * NSString+DN.m: removed cString based space-stripping function and + replaced it with the method from NGExtensions (v4.7.32) + 2007-07-23 Helge Hess * changed API to use NSTimeInterval, added missing getter methods diff --git a/sope-ldap/NGLdap/NSString+DN.m b/sope-ldap/NGLdap/NSString+DN.m index 4f4816fd..adaeb99c 100644 --- a/sope-ldap/NGLdap/NSString+DN.m +++ b/sope-ldap/NGLdap/NSString+DN.m @@ -1,5 +1,6 @@ /* - Copyright (C) 2000-2005 SKYRIX Software AG + Copyright (C) 2000-2007 SKYRIX Software AG + Copyright (C) 2007 Helge Hess This file is part of SOPE. @@ -20,64 +21,26 @@ */ #include "NSString+DN.h" +#include #include "common.h" static NSString *dnSeparator = @","; -static NSString *_stripSpaces(NSString *s) { - NSString *result = nil; - char *cstr, *tmp; - unsigned len, clen; - - if ([s rangeOfString:@" "].length == 0) - return s; - - len = [s cStringLength]; - cstr = malloc(len + 1); - [s getCString:cstr]; - - tmp = cstr; - clen = len; - - /* strip leading spaces */ - while ((*tmp == ' ') && (*tmp != '\0')) { - tmp++; - clen--; - } - - /* strip trailing spaces */ - while (clen > 0) { - if (tmp[clen - 1] != ' ') - break; - clen--; - } - tmp[clen] = '\0'; - - result = [NSString stringWithCString:tmp length:clen]; - if (cstr) - free(cstr); - return result; -} - static NSArray *cleanDNComponents(NSArray *_components) { unsigned i, count; id *cs; - count = [_components count]; - - if (count == 0) + if ((count = [_components count]) == 0) return nil; cs = calloc(count, sizeof(id)); - for (i = 0; i < count; i++) { - NSString *rdn; - - rdn = [_components objectAtIndex:i]; - cs[i] = _stripSpaces(rdn); - } + + for (i = 0; i < count; i++) + cs[i] = [[_components objectAtIndex:i] stringByTrimmingWhiteSpaces]; + _components = [NSArray arrayWithObjects:cs count:count]; - if (cs) free(cs); - + if (cs != NULL) { free(cs); cs = NULL; } + return _components; } @@ -94,10 +57,9 @@ static NSArray *cleanDNComponents(NSArray *_components) { - (NSString *)stringByAppendingDNComponent:(NSString *)_component { NSString *s; - s = _stripSpaces(self); - if (![s isNotEmpty]) + if (![(s = [self stringByTrimmingWhiteSpaces]) isNotEmpty]) return _component; - + s = [dnSeparator stringByAppendingString:self]; return [_component stringByAppendingString:s]; } @@ -108,7 +70,8 @@ static NSArray *cleanDNComponents(NSArray *_components) { r = [self rangeOfString:dnSeparator]; if (r.length == 0) return nil; - return _stripSpaces([self substringFromIndex:(r.location + r.length)]); + return [[self substringFromIndex:(r.location + r.length)] + stringByTrimmingWhiteSpaces]; } - (NSString *)lastDNComponent { @@ -117,7 +80,7 @@ static NSArray *cleanDNComponents(NSArray *_components) { r = [self rangeOfString:dnSeparator]; if (r.length == 0) return nil; - return _stripSpaces([self substringToIndex:r.location]); + return [[self substringToIndex:r.location] stringByTrimmingWhiteSpaces]; } - (const char *)ldapRepresentation { diff --git a/sope-ldap/NGLdap/Version b/sope-ldap/NGLdap/Version index b764ae62..799512bc 100644 --- a/sope-ldap/NGLdap/Version +++ b/sope-ldap/NGLdap/Version @@ -2,4 +2,4 @@ MAJOR_VERSION=4 MINOR_VERSION=7 -SUBMINOR_VERSION:=31 +SUBMINOR_VERSION:=32