SkyContactImportUploadPage.m (opengroupware-5.5rc2) | : | SkyContactImportUploadPage.m (opengroupware-5.5rc3) | ||
---|---|---|---|---|
skipping to change at line 201 | skipping to change at line 201 | |||
NSArray **columnKeys, | NSArray **columnKeys, | |||
unsigned options) | unsigned options) | |||
{ | { | |||
unsigned pos = 0; | unsigned pos = 0; | |||
BOOL reachedNewLine = NO; | BOOL reachedNewLine = NO; | |||
NSMutableArray *lines = [NSMutableArray array]; | NSMutableArray *lines = [NSMutableArray array]; | |||
NSMutableDictionary *line = | NSMutableDictionary *line = | |||
[NSMutableDictionary dictionaryWithCapacity:16]; | [NSMutableDictionary dictionaryWithCapacity:16]; | |||
NSString *value; | NSString *value; | |||
NSMutableArray *columns = [NSMutableArray array]; | NSMutableArray *columns = [NSMutableArray array]; | |||
unsigned valuesPerLine = 0; | NSUInteger valuesPerLine = 0; | |||
unsigned lineCnt = 1; | NSUInteger lineCnt = 1; | |||
unsigned valueIdx = 0; | NSUInteger valueIdx = 0; | |||
*columnKeys = columns; | *columnKeys = columns; | |||
while (pos < length) { | while (pos < length) { | |||
value = parseValue(buffer, &pos, length, separator, &reachedNewLine, | value = parseValue(buffer, &pos, length, separator, &reachedNewLine, | |||
options); | options); | |||
if (value == nil) { | if (value == nil) { | |||
if (stopOnError) { | if (stopOnError) { | |||
setLastError(__PRETTY_FUNCTION__, | setLastError(__PRETTY_FUNCTION__, | |||
[NSString stringWithFormat: | [NSString stringWithFormat: | |||
@"error occured in line %d: %@", | @"error occured in line %"PRIuPTR": %@", | |||
lineCnt, lastError]); | lineCnt, lastError]); | |||
return nil; | return nil; | |||
} | } | |||
value = @""; | value = @""; | |||
} | } | |||
while ([columns count] <= valueIdx) | while ([columns count] <= valueIdx) | |||
[columns addObject:[NSString stringWithFormat:@"column%d", | [columns addObject:[NSString stringWithFormat:@"column%"PRIuPTR, | |||
[columns count]]]; | [columns count]]]; | |||
[line setObject:value forKey:[columns objectAtIndex:valueIdx]]; | [line setObject:value forKey:[columns objectAtIndex:valueIdx]]; | |||
valueIdx++; | valueIdx++; | |||
if (reachedNewLine) { | if (reachedNewLine) { | |||
if (!valuesPerLine) | if (!valuesPerLine) | |||
valuesPerLine = [line count]; | valuesPerLine = [line count]; | |||
else if (valuesPerLine > [line count]) { | else if (valuesPerLine > [line count]) { | |||
while (valuesPerLine > [line count]) | while (valuesPerLine > [line count]) | |||
[line setObject:@"" forKey:[columns objectAtIndex:[line count]]]; | [line setObject:@"" forKey:[columns objectAtIndex:[line count]]]; | |||
} | } | |||
else if (valuesPerLine != [line count]) { | else if (valuesPerLine != [line count]) { | |||
setLastError(__PRETTY_FUNCTION__, | setLastError(__PRETTY_FUNCTION__, | |||
[NSString stringWithFormat: | [NSString stringWithFormat: | |||
@"got differen value count in line %d: " | @"got differen value count in line %"PRIuPTR": " | |||
@"first:%d current:%d", | @"first:%"PRIuPTR" current:%"PRIuPTR, | |||
lineCnt, | lineCnt, | |||
valuesPerLine, [line count]]); | valuesPerLine, [line count]]); | |||
if (stopOnError) { | if (stopOnError) { | |||
setLastError(__PRETTY_FUNCTION__, | setLastError(__PRETTY_FUNCTION__, | |||
[NSString stringWithFormat: | [NSString stringWithFormat: | |||
@"error occured in line %d: %@", | @"error occured in line %"PRIuPTR": %@", | |||
lineCnt, lastError]); | lineCnt, lastError]); | |||
return nil; | return nil; | |||
} | } | |||
} | } | |||
// ignore empty lines | // ignore empty lines | |||
if ([line count]) [lines addObject:line]; | if ([line count]) [lines addObject:line]; | |||
// start a new line | // start a new line | |||
line = [NSMutableDictionary dictionaryWithCapacity:valueIdx]; | line = [NSMutableDictionary dictionaryWithCapacity:valueIdx]; | |||
lineCnt++; | lineCnt++; | |||
reachedNewLine = NO; | reachedNewLine = NO; | |||
skipping to change at line 268 | skipping to change at line 268 | |||
if ([line count] > 0) { | if ([line count] > 0) { | |||
if (!valuesPerLine) | if (!valuesPerLine) | |||
valuesPerLine = [line count]; | valuesPerLine = [line count]; | |||
else if (valuesPerLine > [line count]) { | else if (valuesPerLine > [line count]) { | |||
while (valuesPerLine > [line count]) | while (valuesPerLine > [line count]) | |||
[line setObject:@"" forKey:[columns objectAtIndex:[line count]]]; | [line setObject:@"" forKey:[columns objectAtIndex:[line count]]]; | |||
} | } | |||
else if (valuesPerLine != [line count]) { | else if (valuesPerLine != [line count]) { | |||
setLastError(__PRETTY_FUNCTION__, | setLastError(__PRETTY_FUNCTION__, | |||
[NSString stringWithFormat: | [NSString stringWithFormat: | |||
@"got differen value count in line %d: " | @"got differen value count in line %"PRIuPTR": " | |||
@"first:%d current:%d", lineCnt, | @"first:%"PRIuPTR" current:%"PRIuPTR, lineCnt, | |||
valuesPerLine, [line count]]); | valuesPerLine, [line count]]); | |||
if (stopOnError) { | if (stopOnError) { | |||
setLastError(__PRETTY_FUNCTION__, | setLastError(__PRETTY_FUNCTION__, | |||
[NSString stringWithFormat: | [NSString stringWithFormat: | |||
@"error occured in line %d: %@", | @"error occured in line %"PRIuPTR": %@", | |||
lineCnt, lastError]); | lineCnt, lastError]); | |||
return nil; | return nil; | |||
} | } | |||
} | } | |||
[lines addObject:line]; | [lines addObject:line]; | |||
} | } | |||
return lines; | return lines; | |||
} | } | |||
static id _emptyMappingDummy = nil; | static id _emptyMappingDummy = nil; | |||
End of changes. 7 change blocks. | ||||
11 lines changed or deleted | 11 lines changed or added |