+2008-02-09 Helge Hess <helge.hess@opengroupware.org>
+
+ * v4.7.197
+
+ * FdExt.subproj/NSString+misc.m: rewrote -bindingVariables and
+ stringByReplacingVariablesWithBindings:stringForUnknownBindings:
+ to use unichar (needs testing, might be buggy)
+
+ * NGQuotedPrintableCoding.m: rewritten to use -dataUsingEncoding:
+ methods instead of working on -cString buffers (Note: encoding
+ selection is dubious)
+
+ * FdExt.subproj/NSString+Escaping.m: rewrote -stringByApplyingCEscaping
+ to work on unichars
+
+ * added EOExt.subproj/EOGlobalID+Ext.m category to streamline KVC on
+ non-lF environments
+
2007-12-03 Helge Hess <me@helgehess.eu>
* NGExtensions/NSString+Formatting.h: replaced usage of deprecated
--- /dev/null
+/*
+ Copyright (C) 2008 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#import <EOControl/EOGlobalID.h>
+
+@implementation EOGlobalID(SOPEExt)
+
+#if !LIB_FOUNDATION_LIBRARY
+
+- (id)valueForUndefinedKey:(NSString *)_key {
+ NSLog(@"WARNING: tried to access undefined KVC key '%@' on GID object: %@",
+ _key, self);
+ return nil;
+}
+
+#endif
+
+@end /* EOGlobalID(SOPEExt) */
EOSortOrdering+plist.m \
EOTrueQualifier.m \
NSArray+EOGrouping.m \
+ EOGlobalID+Ext.m \
ADDITIONAL_INCLUDE_DIRS += -I. -I.. -I../NGExtensions/ \
-I../FdExt.subproj/ \
/*
- Copyright (C) 2000-2005 SKYRIX Software AG
+ Copyright (C) 2000-2008 SKYRIX Software AG
+ Copyright (C) 2008 Helge Hess
This file is part of SOPE.
- (NSString *)stringByApplyingCEscaping {
// Unicode!
- const char *cstr;
- char *buffer;
- register int pos = 0;
+ unichar *src;
+ unichar *buffer;
+ int pos = 0;
+ NSString *s;
- cstr = [self cString];
- buffer = malloc([self cStringLength] * 2 + 1);
+ if ((pos = [self length]) == 0)
+ return @"";
+
+ src = malloc(sizeof(unichar) * (pos + 2));
+ [self getCharacters:src];
+ src[pos] = 0; // zero-terminate
+
+ buffer = malloc(sizeof(unichar) * ((pos * 2) + 1));
- while (*cstr) {
- switch (*cstr) {
+ for (pos = 0; *src != 0; pos++, src++) {
+ switch (*src) {
case '\n':
buffer[pos] = '\\'; pos++;
buffer[pos] = 'n';
break;
default:
- buffer[pos] = *cstr;
+ buffer[pos] = *src;
break;
}
- cstr++;
- pos++;
}
buffer[pos] = '\0';
-#if NeXT_Foundation_LIBRARY || GNUSTEP_BASE_LIBRARY
- {
- NSString *s;
-
- s = buffer ? [NSString stringWithCString:buffer] : nil;
- if (buffer) free(buffer);
- return s;
- }
-#else
- return [NSString stringWithCStringNoCopy:buffer freeWhenDone:YES];
-#endif
+ s = [NSString stringWithCharacters:buffer length:pos];
+ free(buffer); buffer = NULL;
+ free(src); src = NULL;
+ return s;
}
- (NSString *)stringByEscapingCharactersFromSet:(NSCharacterSet *)_escSet
@end /* NSString(lfNSURLUtilities) */
+
#if !LIB_FOUNDATION_LIBRARY
@implementation NSString(KVCCompatibility)
/*
- Copyright (C) 2000-2006 SKYRIX Software AG
- Copyright (C) 2006 Helge Hess
+ Copyright (C) 2000-2008 SKYRIX Software AG
+ Copyright (C) 2006-2008 Helge Hess
This file is part of SOPE.
- (NSSet *)bindingVariables
{
unsigned len, pos = 0;
- const char *buf = NULL;
+ unichar *wbuf = NULL;
NSMutableSet *result = nil;
-
- result = [NSMutableSet set];
- len = [self cStringLength];
- buf = [self cString];
+
+ result = [NSMutableSet setWithCapacity:16];
+ len = [self length];
+ wbuf = malloc(sizeof(unichar) * (len + 4));
+ [self getCharacters:wbuf];
while (pos < len) {
unsigned startPos;
if (pos + 1 == len) { /* last entry */
- if (buf[pos] == '$') { /* found $ without end-char */
+ if (wbuf[pos] == '$') { /* found $ without end-char */
[[[NSStringVariableBindingException alloc]
initWithFormat:@"did not find end of variable for string %@", self]
raise];
}
break;
}
- if (buf[pos] != '$') {
+ if (wbuf[pos] != '$') {
pos++;
continue;
}
- if (buf[pos + 1] == '$') { /* found $$ --> ignore*/
+ if (wbuf[pos + 1] == '$') { /* found $$ --> ignore*/
pos += 2;
continue;
}
startPos = pos;
- pos += 2; /* buf[pos + 1] != '$' */
+ pos += 2; /* wbuf[pos + 1] != '$' */
while (pos < len) {
- if (buf[pos] != '$')
+ if (wbuf[pos] != '$')
pos++;
else
break;
}
if (pos == len) { /* end of string was reached */
[[[NSStringVariableBindingException alloc]
- initWithFormat:@"didn`t find end of "
- @"variable for string %@", self]
- raise];
+ initWithFormat:@"did not find end of variable for string %@", self]
+ raise];
}
else {
- NSString *key = nil;
-
+ NSString *key = nil;
+
key = [[NSString alloc]
- initWithCStringNoCopy:(char*)buf + startPos + 1
- length:pos - startPos - 1
- freeWhenDone:NO];
+ initWithCharacters:(unichar *)wbuf + startPos + 1
+ length:(pos - startPos - 1)];
[result addObject:key];
[key release];
}
pos++;
}
+ if (wbuf != NULL) { free(wbuf); wbuf = NULL; }
+
return [[result copy] autorelease];
}
stringForUnknownBindings:(NSString *)_unknown
{
unsigned len, pos = 0;
- const char *buf = NULL;
+ unichar *wbuf = NULL;
NSMutableString *str = nil;
str = [self mutableCopy];
- len = [str cStringLength];
- buf = [str cString];
+ len = [str length];
+ wbuf = malloc(sizeof(unichar) * (len + 4));
+ [self getCharacters:wbuf];
while (pos < len) {
if (pos + 1 == len) { /* last entry */
- if (buf[pos] == '$') { /* found $ without end-char */
+ if (wbuf[pos] == '$') { /* found $ without end-char */
[[[NSStringVariableBindingException alloc]
initWithFormat:@"did not find end of variable for string %@", self]
raise];
}
break;
}
- if (buf[pos] == '$') {
- if (buf[pos + 1] == '$') { /* found $$ --> $ */
+ if (wbuf[pos] == '$') {
+ if (wbuf[pos + 1] == '$') { /* found $$ --> $ */
[str deleteCharactersInRange:NSMakeRange(pos, 1)];
- buf = [str cString];
- len = [str cStringLength];
+
+ if (wbuf != NULL) { free(wbuf); wbuf = NULL; }
+ len = [str length];
+ wbuf = malloc(sizeof(unichar) * (len + 4));
+ [str getCharacters:wbuf];
}
else {
unsigned startPos = pos;
- pos += 2; /* buf[pos + 1] != '$' */
+ pos += 2; /* wbuf[pos + 1] != '$' */
while (pos < len) {
- if (buf[pos] != '$')
+ if (wbuf[pos] != '$')
pos++;
else
break;
NSString *value;
key = [[NSString alloc]
- initWithCStringNoCopy:(char*)buf + startPos + 1
- length:pos - startPos - 1
- freeWhenDone:NO];
+ initWithCharacters:(wbuf + startPos + 1)
+ length:(pos - startPos - 1)];
if ((value = [_bindings valueForStringBinding:key]) == nil) {
if (_unknown == nil) {
value = _unknown;
}
[key release]; key = nil;
+
[str replaceCharactersInRange:
NSMakeRange(startPos, pos - startPos + 1)
withString:value];
- buf = [str cString];
- len = [str cStringLength];
+
+ if (wbuf != NULL) { free(wbuf); wbuf = NULL; }
+ len = [str length];
+ wbuf = malloc(sizeof(unichar) * (len + 4));
+ [str getCharacters:wbuf];
+
pos = startPos - 1 + [value length];
}
}
}
pos++;
}
+ if (wbuf != NULL) { free(wbuf); wbuf = NULL; }
{
id tmp = str;
str = [str copy];
/*
- Copyright (C) 2000-2006 SKYRIX Software AG
- Copyright (C) 2006 Helge Hess
+ Copyright (C) 2000-2008 SKYRIX Software AG
+ Copyright (C) 2006-2008 Helge Hess
This file is part of SOPE.
@implementation NSString(QuotedPrintableCoding)
- (NSString *)stringByDecodingQuotedPrintable {
- NSData *data;
- unsigned len;
+ NSData *data;
- if ((len = [self cStringLength]) > 0) {
- void *buf;
- buf = malloc(len + 10);
- [self getCString:buf];
- data = [NSData dataWithBytes:buf length:len];
- if (buf != NULL) free(buf);
- }
- else
- data = [NSData data];
+ data = ([self length] > 0)
+ ? [self dataUsingEncoding:NSASCIIStringEncoding]
+ : [NSData data];
data = [data dataByDecodingQuotedPrintable];
-
+
// TODO: should we default to some specific charset instead? (either
// Latin1 or UTF-8
+ // or the charset of the receiver?
return [NSString stringWithCString:[data bytes] length:[data length]];
}
- (NSString *)stringByEncodingQuotedPrintable {
NSData *data;
- unsigned len;
- if ((len = [self cStringLength])) {
- void *buf;
- buf = malloc(len + 10);
- [self getCString:buf];
- data = [NSData dataWithBytes:buf length:len];
- free(buf);
- }
- else
- data = [NSData data];
+ // TBD: which encoding to use?
+ data = ([self length] > 0)
+ ? [self dataUsingEncoding:[NSString defaultCStringEncoding]]
+ : [NSData data];
data = [data dataByEncodingQuotedPrintable];
- return [NSString stringWithCString:[data bytes] length:[data length]];
+ return [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]
+ autorelease];
}
@end /* NSString(QuotedPrintableCoding) */
# version
-SUBMINOR_VERSION:=196
+SUBMINOR_VERSION:=197
# v4.3.115 requires libFoundation v1.0.59
# v4.2.72 requires libEOControl v4.2.39