Browse Source

IOS-2794 Block parameter for if it's the last

componentsSeparatedByCString
IOS-2794
Dirk Zimmermann 1 year ago
parent
commit
e981d0f7de
3 changed files with 10 additions and 5 deletions
  1. +2
    -1
      PantomimeFramework/PantomimeFramework/NSData+Extensions.h
  2. +3
    -1
      pantomime-lib/Framework/Pantomime/CWIMAPFolder.m
  3. +5
    -3
      pantomime-lib/Framework/Pantomime/NSData+Extensions.m

+ 2
- 1
PantomimeFramework/PantomimeFramework/NSData+Extensions.h View File

@ -261,8 +261,9 @@
- (NSArray *) componentsSeparatedByCString: (const char *) theCString;
/// Like `componentsSeparatedByCString`, but calls the given block with each result and the current count.
/// The block will be invoked for every component, together with its count and a boolean denoting if it's the last element.
- (void)componentsSeparatedByCString:(const char *)theCString
block:(void (^)(NSData *, NSUInteger))block;
block:(void (^)(NSData *, NSUInteger, BOOL isLast))block;
/*!
@method asciiString


+ 3
- 1
pantomime-lib/Framework/Pantomime/CWIMAPFolder.m View File

@ -773,7 +773,9 @@
NSMutableData *aMutableData = [[NSMutableData alloc] initWithCapacity: [theMessage length]];
// We now replace all \n by \r\n
[theMessage componentsSeparatedByCString:"\n" block:^(NSData *aLine, NSUInteger count) {
[theMessage componentsSeparatedByCString:"\n" block:^(NSData *aLine,
NSUInteger count,
BOOL isLast) {
// We skip dumb headers
if ([aLine hasCPrefix: "From "]) {
return;


+ 5
- 3
pantomime-lib/Framework/Pantomime/NSData+Extensions.m View File

@ -777,7 +777,7 @@ static const char *hexDigit = "0123456789ABCDEF";
}
- (void)componentsSeparatedByCString:(const char *)theCString
block:(void (^)(NSData *, NSUInteger))block
block:(void (^)(NSData *, NSUInteger, BOOL isLast))block
{
NSUInteger len = [self length];
NSRange r1 = NSMakeRange(0,len);
@ -789,7 +789,9 @@ static const char *hexDigit = "0123456789ABCDEF";
NSUInteger count = 0;
while (r2.length) {
block([self subdataWithRange: NSMakeRange(r1.location, r2.location - r1.location)], count);
block([self subdataWithRange: NSMakeRange(r1.location, r2.location - r1.location)],
count,
NO);
count++;
r1.location = r2.location + r2.length;
r1.length = len - r1.location;
@ -797,7 +799,7 @@ static const char *hexDigit = "0123456789ABCDEF";
r2 = [self rangeOfCString: theCString options: 0 range: r1];
}
block([self subdataWithRange: NSMakeRange(r1.location, len - r1.location)], count);
block([self subdataWithRange: NSMakeRange(r1.location, len - r1.location)], count, YES);
}
//


Loading…
Cancel
Save