diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/KeyChain.m | 34 | ||||
-rw-r--r-- | Source/SPDataCellFormatter.m | 17 | ||||
-rw-r--r-- | Source/SPTableData.m | 7 | ||||
-rw-r--r-- | Source/TableDump.m | 30 | ||||
-rw-r--r-- | Source/TableSource.m | 4 |
5 files changed, 52 insertions, 40 deletions
diff --git a/Source/KeyChain.m b/Source/KeyChain.m index 23ead937..93364175 100644 --- a/Source/KeyChain.m +++ b/Source/KeyChain.m @@ -39,12 +39,12 @@ if (![self passwordExistsForName:name account:account]) { status = SecKeychainAddGenericPassword( NULL, // default keychain - [name cStringLength], // length of service name - [name cString], // service name - [account cStringLength], // length of account name - [account cString], // account name - [password cStringLength], // length of password - [password cString], // pointer to password data + strlen([name UTF8String]), // length of service name + [name UTF8String], // service name + strlen([account UTF8String]), // length of account name + [account UTF8String], // account name + strlen([password UTF8String]), // length of password + [password UTF8String], // pointer to password data NULL // the item reference ); @@ -61,17 +61,17 @@ { OSStatus status; - void *passwordData = nil; - UInt32 passwordLength = nil; - SecKeychainItemRef itemRef = nil; + void *passwordData; + UInt32 passwordLength; + SecKeychainItemRef itemRef; NSString *password = @""; status = SecKeychainFindGenericPassword( NULL, // default keychain - [name cStringLength], // length of service name - [name cString], // service name - [account cStringLength], // length of account name - [account cString], // account name + strlen([name UTF8String]), // length of service name + [name UTF8String], // service name + strlen([account UTF8String]), // length of account name + [account UTF8String], // account name &passwordLength, // length of password &passwordData, // pointer to password data &itemRef // the item reference @@ -102,10 +102,10 @@ if ([self passwordExistsForName:name account:account]) { status = SecKeychainFindGenericPassword( NULL, // default keychain - [name cStringLength], // length of service name - [name cString], // service name - [account cStringLength], // length of account name - [account cString], // account name + strlen([name UTF8String]), // length of service name + [name UTF8String], // service name + strlen([account UTF8String]), // length of account name + [account UTF8String], // account name nil, // length of password nil, // pointer to password data &itemRef // the item reference diff --git a/Source/SPDataCellFormatter.m b/Source/SPDataCellFormatter.m index 4f005c23..ae03a441 100644 --- a/Source/SPDataCellFormatter.m +++ b/Source/SPDataCellFormatter.m @@ -40,6 +40,8 @@ } #endif + + - (NSString *)stringForObjectValue:(id)anObject { @@ -72,16 +74,25 @@ - (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error { - // No limit set + // No limit set if (textLimit == 0) return YES; + // A single character over the length of the string - likely typed. Prevent the change. + if ([partialString length] == textLimit + 1) { + NSBeep(); + return NO; + } + + // If the string is considerably longer than the limit, likely pasted. Accept but truncate. if ([partialString length] > textLimit) { NSBeep(); - newString = [NSString stringWithCharacters:partialString length:textLimit]; + *newString = [NSString stringWithString:[partialString substringToIndex:textLimit]]; + return NO; } - return ([partialString length] <= textLimit); + // Length inside limit. + return YES; } @end diff --git a/Source/SPTableData.m b/Source/SPTableData.m index aff7b456..1ff4917c 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -459,11 +459,12 @@ /* * Retrieve the status of a table as a dictionary and add it to the local cache for reuse. */ -- (BOOL) updateStatusInformationForCurrentTable +- (BOOL)updateStatusInformationForCurrentTable { - // Catch unselected tables and return nil - if ([[tableListInstance tableName] isEqualToString:@""] || ![tableListInstance tableName]) return nil; + // Catch unselected tables and return false + if ([[tableListInstance tableName] isEqualToString:@""] || ![tableListInstance tableName]) + return FALSE; // When views are selected, populate the table with a default dictionary - all values, including comment, return no // meaningful information for views so we may as well skip the query. diff --git a/Source/TableDump.m b/Source/TableDump.m index 5236c07d..a53caa7b 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -374,7 +374,7 @@ NSString *fileType = [[importFormatPopup selectedItem] title]; //load file into string dumpFile = [SPSQLParser stringWithContentsOfFile:filename - encoding:[CMMCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] cString]] + encoding:[CMMCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]] error:errorStr]; if ( !dumpFile ) { @@ -986,7 +986,7 @@ withNumericColumns:(NSArray *)tableColumnNumericStatus silently:(BOOL)silently; { - NSStringEncoding tableEncoding = [CMMCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] cString]]; + NSStringEncoding tableEncoding = [CMMCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]]; NSMutableString *csvCell = [NSMutableString string]; NSMutableArray *csvRow = [NSMutableArray array]; NSMutableString *csvString = [NSMutableString string]; @@ -1204,7 +1204,7 @@ NSMutableString *tempString = [NSMutableString string]; NSMutableArray *linesArray = [NSMutableArray array]; BOOL isEscaped, br; - int fieldCount = nil; + int fieldCount = 0; int x,i,j; //repare tabs and line ends @@ -1338,7 +1338,7 @@ */ - (BOOL)writeXmlForArray:(NSArray *)array orQueryResult:(CMMCPResult *)queryResult toFileHandle:(NSFileHandle *)fileHandle tableName:(NSString *)table withHeader:(BOOL)header silently:(BOOL)silently { - NSStringEncoding tableEncoding = [CMMCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] cString]]; + NSStringEncoding tableEncoding = [CMMCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]]; NSMutableArray *xmlTags = [NSMutableArray array]; NSMutableArray *xmlRow = [NSMutableArray array]; NSMutableString *xmlString = [NSMutableString string]; @@ -1681,19 +1681,19 @@ BOOL isEscaped = NO; BOOL br = NO; unsigned i, j, start; - char enc = nil; - char esc = nil; - char ter = nil; + char *enc = nil; + char *esc = nil; + char *ter = nil; //we take only first character by now (too complicated otherwise) if ( [enclosed length] ) { - enc = [enclosed characterAtIndex:0]; + *enc = [enclosed characterAtIndex:0]; } if ( [escaped length] ) { - esc = [escaped characterAtIndex:0]; + *esc = [escaped characterAtIndex:0]; } if ( [terminated length] ) { - ter = [terminated characterAtIndex:0]; + *ter = [terminated characterAtIndex:0]; } start = 0; @@ -1706,12 +1706,12 @@ if ( i >= [string length] ) { //end of string -> no second enclose character found br = YES; - } else if ( [string characterAtIndex:i] == enc ) { + } else if ( [string characterAtIndex:i] == *enc ) { //second enclose-character found //enclose-character escaped? isEscaped = NO; j = 1; - while ( (i-j>0) && ([string characterAtIndex:(i-j)] == esc) ) { + while ( (i-j>0) && ([string characterAtIndex:(i-j)] == *esc) ) { isEscaped = !isEscaped; j++; } @@ -1723,13 +1723,13 @@ if ( !br ) i++; } - } else if ( [string characterAtIndex:i] == ter ) { + } else if ( [string characterAtIndex:i] == *ter ) { //terminated-character found if ( [enclosed isEqualToString:@""] ) { //check if terminated character is escaped isEscaped = NO; j = 1; - while ( (i-j>0) && ([string characterAtIndex:(i-j)] == esc) ) { + while ( (i-j>0) && ([string characterAtIndex:(i-j)] == *esc) ) { isEscaped = !isEscaped; j++; } @@ -1743,7 +1743,7 @@ [tempArray addObject:[string substringWithRange:NSMakeRange(start,(i-start))]]; start = i + 1; } - } else if ( [string characterAtIndex:i] == enc ) { + } else if ( [string characterAtIndex:i] == *enc ) { //enclosed-character found inString = YES; } diff --git a/Source/TableSource.m b/Source/TableSource.m index 33d3777b..7d642bf2 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -134,8 +134,8 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab for ( i = 0 ; i < [possibleValues count] ; i++ ) { [possibleValue setString:[possibleValues objectAtIndex:i]]; - [possibleValue replaceOccurrencesOfString:@"''" withString:@"'" options:nil range:NSMakeRange(0,[possibleValue length])]; - [possibleValue replaceOccurrencesOfString:@"\\\\" withString:@"\\" options:nil range:NSMakeRange(0,[possibleValue length])]; + [possibleValue replaceOccurrencesOfString:@"''" withString:@"'" options:NSLiteralSearch range:NSMakeRange(0,[possibleValue length])]; + [possibleValue replaceOccurrencesOfString:@"\\\\" withString:@"\\" options:NSLiteralSearch range:NSMakeRange(0,[possibleValue length])]; [possibleValues replaceObjectAtIndex:i withObject:[NSString stringWithString:possibleValue]]; } |