Monotone-Parent: f88d99a5bcea75c289e4a86001d1d294d3dadb9e
Monotone-Revision: b2d085794edde254007a3097e654f621a7c9a284 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-03-24T15:27:25 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
2f93cdd60b
commit
f5941aa62f
|
@ -1,3 +1,7 @@
|
|||
2009-03-24 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* VSStringFormatter.[hm]: removed useless module.
|
||||
|
||||
2007-08-27 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* VSSaxDriver.m ([VSSaxDriver
|
||||
|
|
|
@ -14,8 +14,7 @@ versitCardsSaxDriver_PCH_FILE = common.h
|
|||
|
||||
versitCardsSaxDriver_OBJC_FILES = \
|
||||
VSSaxDriver.m \
|
||||
VSCardSaxDriver.m \
|
||||
VSStringFormatter.m \
|
||||
VSCardSaxDriver.m
|
||||
|
||||
versitCardsSaxDriver_RESOURCE_FILES = bundle-info.plist
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
are not expected in a sax handler... this is all wrong. */
|
||||
|
||||
#import "VSSaxDriver.h"
|
||||
#import "VSStringFormatter.h"
|
||||
#import <SaxObjC/SaxException.h>
|
||||
#import <NGExtensions/NGQuotedPrintableCoding.h>
|
||||
#import <NGCards/NSString+NGCards.h>
|
||||
|
@ -164,8 +163,6 @@ static NSCharacterSet *colonAndSemicolonCharSet = nil;
|
|||
static NSCharacterSet *colonSemicolonAndDquoteCharSet = nil;
|
||||
static NSCharacterSet *whitespaceCharSet = nil;
|
||||
|
||||
static VSStringFormatter *stringFormatter = nil;
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
static BOOL didInit = NO;
|
||||
|
@ -190,8 +187,6 @@ static VSStringFormatter *stringFormatter = nil;
|
|||
[[NSCharacterSet characterSetWithCharactersInString: @":;\""] retain];
|
||||
whitespaceCharSet =
|
||||
[[NSCharacterSet whitespaceCharacterSet] retain];
|
||||
|
||||
stringFormatter = [VSStringFormatter sharedFormatter];
|
||||
}
|
||||
|
||||
- (id) init {
|
||||
|
@ -382,7 +377,6 @@ static VSStringFormatter *stringFormatter = nil;
|
|||
|
||||
*attr_ = attrName;
|
||||
*value_ = [attrValue unescapedFromCard];
|
||||
// *value_ = [stringFormatter stringByUnescapingRFC2445Text: attrValue];
|
||||
}
|
||||
|
||||
- (SaxAttributes *) _mapAttrs: (NSArray *) _attrs
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2004-2005 OpenGroupware.org
|
||||
|
||||
This file is part of versitCardsSaxDriver, written for the OpenGroupware.org
|
||||
project (OGo).
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __VSStringFormatter_H_
|
||||
#define __VSStringFormatter_H_
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface VSStringFormatter : NSObject
|
||||
{
|
||||
}
|
||||
|
||||
+ (id)sharedFormatter;
|
||||
- (NSString *)stringByUnescapingRFC2445Text:(NSString *)_s;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __VSStringFormatter_H_ */
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2004-2005 OpenGroupware.org
|
||||
|
||||
This file is part of versitCardsSaxDriver, written for the OpenGroupware.org
|
||||
project (OGo).
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "VSStringFormatter.h"
|
||||
#include "common.h"
|
||||
|
||||
@implementation VSStringFormatter
|
||||
|
||||
static NSCharacterSet *escSet = nil;
|
||||
|
||||
+ (void)initialize {
|
||||
static BOOL didInit = NO;
|
||||
|
||||
if(didInit)
|
||||
return;
|
||||
|
||||
didInit = YES;
|
||||
escSet = [[NSCharacterSet characterSetWithCharactersInString:@"\\"] retain];
|
||||
}
|
||||
|
||||
+ (id)sharedFormatter {
|
||||
static id sharedInstance = nil;
|
||||
if(!sharedInstance) {
|
||||
sharedInstance = [[self alloc] init];
|
||||
}
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (NSString *)stringByUnescapingRFC2445Text:(NSString *)_s {
|
||||
NSMutableString *safeString;
|
||||
unsigned length;
|
||||
NSRange prevRange, escRange;
|
||||
NSRange todoRange;
|
||||
BOOL needsEscaping;
|
||||
|
||||
length = [_s length];
|
||||
prevRange = NSMakeRange(0, length);
|
||||
escRange = [_s rangeOfCharacterFromSet:escSet options:0 range:prevRange];
|
||||
|
||||
needsEscaping = escRange.length > 0 ? YES : NO;
|
||||
if (!needsEscaping)
|
||||
return _s; /* cheap */
|
||||
|
||||
safeString = [NSMutableString stringWithCapacity:length];
|
||||
|
||||
do {
|
||||
prevRange.length = escRange.location - prevRange.location;
|
||||
if (prevRange.length > 0)
|
||||
[safeString appendString:[_s substringWithRange:prevRange]];
|
||||
|
||||
/* test edge case */
|
||||
if(NSMaxRange(escRange) < length) {
|
||||
unichar c = [_s characterAtIndex:escRange.location + 1];
|
||||
if(c == 'n' || c == 'N') {
|
||||
[safeString appendString:@"\n"];
|
||||
escRange.length += 1; /* skip the 'n' */
|
||||
}
|
||||
}
|
||||
|
||||
prevRange.location = NSMaxRange(escRange);
|
||||
todoRange.location = prevRange.location;
|
||||
todoRange.length = length - prevRange.location;
|
||||
escRange = [_s rangeOfCharacterFromSet:escSet
|
||||
options:0
|
||||
range:todoRange];
|
||||
}
|
||||
while(escRange.length > 0);
|
||||
|
||||
if (todoRange.length > 0)
|
||||
[safeString appendString:[_s substringWithRange:todoRange]];
|
||||
|
||||
return safeString;
|
||||
}
|
||||
|
||||
@end /* VSStringFormatter */
|
Loading…
Reference in New Issue