+2004-10-14 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * v4.3.123
+
+ * FdExt.subproj/NSString+Escaping.m, NGExtensions/NSString+Escaping.h:
+ new category and protocol to do generic escaping. The category is
+ Unicode safe and optimized for performance.
+
+ * FdExt.subproj/NSString+misc.m, NGExtensions/NSString+misc.h: moved
+ -stringByApplyingCEscaping to new NSString+Escaping.
+
2004-10-11 Matthew Joyce <mjoyce@aboveit.nl>
* FdExt.subproj/NSCalendarDate+misc.m: fixed -isAfternoon (all dates
NSSet+enumerator.m \
NSString+Ext.m \
NSString+Encoding.m \
+ NSString+Escaping.m \
NSString+Formatting.m \
NSString+misc.m \
NSString+HTMLEscaping.m \
--- /dev/null
+/*
+ Copyright (C) 2000-2004 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo 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.
+
+ OGo 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 OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+// $Id$
+
+
+#include <NGExtensions/NSString+Escaping.h>
+#include "common.h"
+
+@implementation NSString (Escaping)
+
+- (NSString *)stringByApplyingCEscaping {
+ // Unicode!
+ const char *cstr;
+ char *buffer;
+ register int pos = 0;
+
+ cstr = [self cString];
+ buffer = malloc([self cStringLength] * 2 + 1);
+
+ while (*cstr) {
+ switch (*cstr) {
+ case '\n':
+ buffer[pos] = '\\'; pos++;
+ buffer[pos] = 'n';
+ break;
+ case '\r':
+ buffer[pos] = '\\'; pos++;
+ buffer[pos] = 'r';
+ break;
+ case '\t':
+ buffer[pos] = '\\'; pos++;
+ buffer[pos] = 't';
+ break;
+
+ default:
+ buffer[pos] = *cstr;
+ 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
+}
+
+- (NSString *)stringByEscapingCharactersFromSet:(NSCharacterSet *)_escSet
+ usingStringEscaping:(<NGStringEscaping>)_esc
+{
+ NSMutableString *safeString;
+ unsigned length;
+ NSRange prevRange, escRange;
+ BOOL needsEscaping;
+
+ length = [self length];
+ prevRange = NSMakeRange(0, length);
+ escRange = [self rangeOfCharacterFromSet:_escSet options:0 range:prevRange];
+
+ needsEscaping = escRange.length > 0 ? YES : NO;
+ if (!needsEscaping) {
+ return self; /* cheap */
+ }
+
+ safeString = [NSMutableString stringWithCapacity:length];
+ if (needsEscaping) {
+ NSRange todoRange;
+
+ length = prevRange.length;
+ do {
+ NSString *s;
+
+ prevRange.length = escRange.location - prevRange.location;
+ if (prevRange.length > 0)
+ [safeString appendString:[self substringWithRange:prevRange]];
+ s = [_esc stringByEscapingString:[self substringWithRange:escRange]];
+ if (s)
+ [safeString appendString:s];
+
+ prevRange.location = NSMaxRange(escRange);
+ todoRange.location = prevRange.location;
+ todoRange.length = length - prevRange.location;
+ escRange = [self rangeOfCharacterFromSet:_escSet
+ options:0
+ range:todoRange];
+ }
+ while(escRange.length > 0);
+ if(todoRange.length > 0) {
+ [safeString appendString:[self substringWithRange:todoRange]];
+ }
+ }
+ return safeString;
+}
+
+@end
@implementation NSString(misc)
-- (NSString *)stringByApplyingCEscaping {
- // Unicode!
- const char *cstr;
- char *buffer;
- register int pos = 0;
-
- cstr = [self cString];
- buffer = malloc([self cStringLength] * 2 + 1);
-
- while (*cstr) {
- switch (*cstr) {
- case '\n':
- buffer[pos] = '\\'; pos++;
- buffer[pos] = 'n';
- break;
- case '\r':
- buffer[pos] = '\\'; pos++;
- buffer[pos] = 'r';
- break;
- case '\t':
- buffer[pos] = '\\'; pos++;
- buffer[pos] = 't';
- break;
-
- default:
- buffer[pos] = *cstr;
- 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
-}
- (NSSet *)bindingVariables
{
unsigned len, pos = 0;
NSString+German.h \
NSString+Formatting.h \
NSString+Encoding.h \
+ NSString+Escaping.h \
NSString+misc.h \
NSURL+misc.h \
NGPropertyListParser.h \
settings = {
};
};
+ AD665E37071F00AF00EC5911 = {
+ fileEncoding = 5;
+ indentWidth = 2;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = "NSString+Escaping.h";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ AD665E38071F00AF00EC5911 = {
+ fileEncoding = 5;
+ indentWidth = 2;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = "NSString+Escaping.m";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ AD665E39071F00AF00EC5911 = {
+ fileRef = AD665E37071F00AF00EC5911;
+ isa = PBXBuildFile;
+ settings = {
+ ATTRIBUTES = (
+ Public,
+ );
+ };
+ };
+ AD665E3A071F00AF00EC5911 = {
+ fileRef = AD665E38071F00AF00EC5911;
+ isa = PBXBuildFile;
+ settings = {
+ COMPILER_FLAGS = "-I..";
+ };
+ };
ADD45B5E06FEF017004BBD65 = {
fileEncoding = 5;
indentWidth = 2;
ADD65C6506DA3394007161CA = {
children = (
ADD65C4B06DA336E007161CA,
+ AD665E38071F00AF00EC5911,
ADD65C4C06DA336E007161CA,
ADD65C4D06DA336E007161CA,
ADD65C4E06DA336E007161CA,
ADD65DE206DA3830007161CA,
ADD65DE306DA3830007161CA,
ADD65DE406DA3830007161CA,
+ AD665E39071F00AF00EC5911,
ADD65DE506DA3830007161CA,
ADD65DE606DA3830007161CA,
ADD65DE706DA3830007161CA,
ADD65F3306DA397E007161CA,
ADD45B6106FEF017004BBD65,
AD4BF6EC070314EE006FB665,
+ AD665E3A071F00AF00EC5911,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
);
buildSettings = {
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 4.3.120;
+ DYLIB_CURRENT_VERSION = 4.3.123;
FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks";
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
};
ADD65D6106DA382F007161CA = {
children = (
+ ADD65D7D06DA382F007161CA,
+ ADD65D7E06DA382F007161CA,
ADD65DF506DA38CA007161CA,
ADD65DEF06DA3877007161CA,
ADD65DEC06DA3848007161CA,
ADD65D7906DA382F007161CA,
ADD65D7B06DA382F007161CA,
ADD65D7C06DA382F007161CA,
- ADD65D7D06DA382F007161CA,
- ADD65D7E06DA382F007161CA,
ADD65D7F06DA382F007161CA,
ADD65D8006DA382F007161CA,
ADD65D8106DA382F007161CA,
ADD65D9E06DA3830007161CA,
ADD65D9F06DA3830007161CA,
ADD65DA006DA3830007161CA,
+ AD665E37071F00AF00EC5911,
ADD65DA106DA3830007161CA,
ADD65DA206DA3830007161CA,
ADD65DA306DA3830007161CA,
#include <NGExtensions/NSSet+enumerator.h>
#include <NGExtensions/NSString+Formatting.h>
#include <NGExtensions/NSString+Encoding.h>
+#include <NGExtensions/NSString+Escaping.h>
#include <NGExtensions/NSString+misc.h>
#include <NGExtensions/NGObjectMacros.h>
--- /dev/null
+/*
+ Copyright (C) 2000-2004 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo 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.
+
+ OGo 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 OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+// $Id$
+
+
+#ifndef __NGExtensions_NSString_Escaping_H__
+#define __NGExtensions_NSString_Escaping_H__
+
+#import <Foundation/NSString.h>
+
+@protocol NGStringEscaping < NSObject >
+- (NSString *)stringByEscapingString:(NSString *)_s;
+@end
+
+@interface NSString (Escaping)
+
+- (NSString *)stringByApplyingCEscaping;
+
+- (NSString *)stringByEscapingCharactersFromSet:(NSCharacterSet *)_set
+ usingStringEscaping:(<NGStringEscaping>)_esc;
+@end
+
+#endif /* __NGExtensions_NSString_Escaping_H__ */
@interface NSString(misc)
-- (NSString *)stringByApplyingCEscaping;
-
/*
Replaces keys, which enclosed in '$', with values from _bindings. The values
are retrieved using the '-valueForStringBinding:' method which per default
# version
-SUBMINOR_VERSION:=122
+SUBMINOR_VERSION:=123
# v4.3.115 requires libFoundation v1.0.59
# v4.2.72 requires libEOControl v4.2.39