diff --git a/AutoCorrectItem.m b/AutoCorrectItem.m index 034c401..3342c0b 100644 --- a/AutoCorrectItem.m +++ b/AutoCorrectItem.m @@ -49,4 +49,10 @@ -(BOOL)validateWith:(id *)ioValue error:(NSError * __autoreleasing *)outError { return YES; } +-(void)dealloc { + [replace release]; + [with release]; + [super dealloc]; +} + @end diff --git a/AvroKeyboard.xcodeproj/project.pbxproj b/AvroKeyboard.xcodeproj/project.pbxproj index a414887..8a59123 100644 --- a/AvroKeyboard.xcodeproj/project.pbxproj +++ b/AvroKeyboard.xcodeproj/project.pbxproj @@ -308,10 +308,10 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0500; + LastUpgradeCheck = 0800; TargetAttributes = { 8D1107260486CEB800E47090 = { - DevelopmentTeam = 22LN73JVY9; + DevelopmentTeam = 8FVM4CE4C6; }; }; }; @@ -464,7 +464,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - DEVELOPMENT_TEAM = 22LN73JVY9; + DEVELOPMENT_TEAM = 8FVM4CE4C6; GCC_DYNAMIC_NO_PIC = NO; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; @@ -472,6 +472,7 @@ INFOPLIST_FILE = Info.plist; INSTALL_PATH = "\"$(LOCAL_LIBRARY_DIR)/Input Methods/\""; MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = com.omicronlab.inputmethod.AvroKeyboard; PRODUCT_NAME = "Avro Keyboard"; PROVISIONING_PROFILE = ""; WRAPPER_EXTENSION = app; @@ -487,13 +488,14 @@ CODE_SIGN_IDENTITY = "Developer ID Application"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = 22LN73JVY9; + DEVELOPMENT_TEAM = 8FVM4CE4C6; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_MODEL_TUNING = G5; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = com.omicronlab.inputmethod.AvroKeyboard; PRODUCT_NAME = "Avro Keyboard"; PROVISIONING_PROFILE = ""; WRAPPER_EXTENSION = app; @@ -503,7 +505,24 @@ C01FCF4F08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = NO; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = NO; ONLY_ACTIVE_ARCH = YES; }; @@ -512,7 +531,23 @@ C01FCF5008A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = NO; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = NO; }; name = Release; diff --git a/AvroKeyboardController.h b/AvroKeyboardController.h index 187cae6..4b16791 100644 --- a/AvroKeyboardController.h +++ b/AvroKeyboardController.h @@ -15,7 +15,7 @@ int _prevSelected; NSMutableString* _composedBuffer; // _composedBuffer contains text that the input method has converted NSMutableArray* _currentCandidates; - int _selectedCandidateIndex; + NSInteger _selectedCandidateIndex; NSString* _prefix; // Converted Prefix NSString* _term; // Original Non-Converted Term NSString* _suffix; // Converted Suffix @@ -30,4 +30,4 @@ //They are all simple wrappers around basic NSString methods. - (void)commitText:(NSString*)string; -@end \ No newline at end of file +@end diff --git a/AvroParser.h b/AvroParser.h index d72d513..82cc463 100644 --- a/AvroParser.h +++ b/AvroParser.h @@ -13,7 +13,7 @@ NSString* _number; NSString* _casesensitive; NSArray* _patterns; - int _maxPatternLength; + NSInteger _maxPatternLength; } + (AvroParser *)sharedInstance; diff --git a/AvroParser.m b/AvroParser.m index eb836b5..c813173 100644 --- a/AvroParser.m +++ b/AvroParser.m @@ -93,19 +93,19 @@ - (NSString*)parse:(NSString *)string { NSString * fixed = [self fix:string]; NSMutableString* output = [[NSMutableString alloc] initWithCapacity:0]; - int len = [fixed length], cur; + NSInteger len = [fixed length], cur; for(cur = 0; cur < len; ++cur) { - int start = cur, end; + NSInteger start = cur, end; BOOL matched = FALSE; - int chunkLen; + NSInteger chunkLen; for(chunkLen = _maxPatternLength; chunkLen > 0; --chunkLen) { end = start + chunkLen; if(end <= len) { NSString* chunk = [fixed substringWithRange:NSMakeRange(start, chunkLen)]; // Binary Search - int left = 0, right = [_patterns count] - 1, mid; + NSInteger left = 0, right = [_patterns count] - 1, mid; while(right >= left) { mid = (right + left) / 2; NSDictionary* pattern = [_patterns objectAtIndex:mid]; @@ -115,7 +115,7 @@ - (NSString*)parse:(NSString *)string { for(NSDictionary* rule in rules) { BOOL replace = TRUE; - int chk = 0; + NSInteger chk = 0; NSArray* matches = [rule objectForKey:@"matches"]; for(NSDictionary* match in matches) { NSString* value = [match objectForKey:@"value"]; @@ -191,7 +191,7 @@ - (NSString*)parse:(NSString *)string { } // Exact else if([scope isEqualToString:@"exact"]) { - int s, e; + NSInteger s, e; if([type isEqualToString:@"suffix"]) { s = end; e = end + [value length]; @@ -201,7 +201,7 @@ - (NSString*)parse:(NSString *)string { s = start - [value length]; e = start; } - if(![self isExact:value heystack:fixed start:s end:e not:isNegative]) { + if(![self isExact:value heystack:fixed start:(int)s end:(int)e not:isNegative]) { replace = FALSE; break; } @@ -248,41 +248,30 @@ - (NSString*)parse:(NSString *)string { return output; } -- (BOOL)isVowel:(unichar)c { +- (BOOL)inString:(NSString*) str c:(unichar) c { // Making it lowercase for checking c = [self smallCap:c]; - int i, len = [_vowel length]; + NSInteger i, len = [str length]; for (i = 0; i < len; ++i) { - if ([_vowel characterAtIndex:i] == c) { + if ([str characterAtIndex:i] == c) { return TRUE; } } return FALSE; + +} + +- (BOOL)isVowel:(unichar)c { + return [self inString:_vowel c:c]; } - (BOOL)isConsonant:(unichar)c { - // Making it lowercase for checking - c = [self smallCap:c]; - int i, len = [_consonant length]; - for (i = 0; i < len; ++i) { - if ([_consonant characterAtIndex:i] == c) { - return TRUE; - } - } - return FALSE; + return [self inString:_consonant c:c]; //return [consonant rangeOfString:c options:NSCaseInsensitiveSearch].location != NSNotFound; } - (BOOL)isNumber:(unichar)c { - // Making it lowercase for checking - c = [self smallCap:c]; - int i, len = [_number length]; - for (i = 0; i < len; ++i) { - if ([_number characterAtIndex:i] == c) { - return TRUE; - } - } - return FALSE; + return [self inString:_number c:c]; } - (BOOL)isPunctuation:(unichar)c { @@ -290,15 +279,7 @@ - (BOOL)isPunctuation:(unichar)c { } - (BOOL)isCaseSensitive:(unichar)c { - // Making it lowercase for checking - c = [self smallCap:c]; - int i, len = [_casesensitive length]; - for (i = 0; i < len; ++i) { - if ([_casesensitive characterAtIndex:i] == c) { - return TRUE; - } - } - return FALSE; + return [self inString:_casesensitive c:c]; } - (BOOL)isExact:(NSString*) needle heystack:(NSString*)heystack start:(int)start end:(int)end not:(BOOL)not { @@ -317,7 +298,7 @@ - (unichar)smallCap:(unichar) letter { - (NSString*)fix:(NSString *)string { NSMutableString* fixed = [[NSMutableString alloc] initWithCapacity:0]; - int i, len = [string length]; + NSInteger i, len = [string length]; for (i = 0; i < len; ++i) { unichar c = [string characterAtIndex:i]; if (![self isCaseSensitive:c]) { diff --git a/Info.plist b/Info.plist index e222dc0..c5e4065 100644 --- a/Info.plist +++ b/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable Avro Keyboard CFBundleIdentifier - com.omicronlab.inputmethod.AvroKeyboard + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/NSString+Levenshtein.m b/NSString+Levenshtein.m index 8714c93..24a6986 100644 --- a/NSString+Levenshtein.m +++ b/NSString+Levenshtein.m @@ -29,8 +29,8 @@ -(int) computeLevenshteinDistanceWithString:(NSString *) string int i,j,k; // indexes int cost, distance; - int n = [self length]; - int m = [string length]; + int n = (int)[self length]; + int m = (int)[string length]; if( n!=0 && m!=0 ){ diff --git a/PreferencesController.h b/PreferencesController.h index 1dfb073..70f845e 100644 --- a/PreferencesController.h +++ b/PreferencesController.h @@ -15,7 +15,7 @@ IBOutlet NSTextView* _aboutContent; IBOutlet NSArrayController* _autoCorrectController; - int _currentViewTag; + NSInteger _currentViewTag; NSMutableArray* _autoCorrectItemsArray; } diff --git a/PreferencesController.m b/PreferencesController.m index a7ddaf8..dfa7913 100644 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -60,7 +60,7 @@ - (NSRect)newFrameForNewContentView:(NSView*)view { return frame; } -- (NSView*)viewForTag:(int)tag { +- (NSView*)viewForTag:(NSInteger)tag { NSView* view = nil; switch (tag) { case 0: @@ -84,7 +84,7 @@ - (BOOL)validateToolbarItem:(NSToolbarItem *)item { } - (IBAction)switchView:(id)sender { - int tag = [sender tag]; + NSInteger tag = [sender tag]; NSView* view = [self viewForTag:tag]; NSView* previousView = [self viewForTag:_currentViewTag]; _currentViewTag = tag; diff --git a/RegexParser.h b/RegexParser.h index 5064c00..0283f38 100644 --- a/RegexParser.h +++ b/RegexParser.h @@ -12,7 +12,7 @@ NSString* _consonant; NSString* _casesensitive; NSArray* _patterns; - int _maxPatternLength; + NSInteger _maxPatternLength; } + (RegexParser *)sharedInstance; diff --git a/RegexParser.m b/RegexParser.m index 279dfa0..1247c02 100644 --- a/RegexParser.m +++ b/RegexParser.m @@ -92,19 +92,19 @@ - (NSString*)parse:(NSString *)string { NSString* fixed = [self clean:string]; NSMutableString* output = [[NSMutableString alloc] initWithCapacity:0]; - int len = [fixed length], cur; + NSInteger len = [fixed length], cur; for(cur = 0; cur < len; ++cur) { - int start = cur, end; + NSInteger start = cur, end; BOOL matched = FALSE; - int chunkLen; + NSInteger chunkLen; for(chunkLen = _maxPatternLength; chunkLen > 0; --chunkLen) { end = start + chunkLen; if(end <= len) { NSString* chunk = [fixed substringWithRange:NSMakeRange(start, chunkLen)]; // Binary Search - int left = 0, right = [_patterns count] - 1, mid; + NSInteger left = 0, right = [_patterns count] - 1, mid; while(right >= left) { mid = (right + left) / 2; NSDictionary* pattern = [_patterns objectAtIndex:mid]; @@ -114,7 +114,7 @@ - (NSString*)parse:(NSString *)string { for(NSDictionary* rule in rules) { BOOL replace = TRUE; - int chk = 0; + NSInteger chk = 0; NSArray* matches = [rule objectForKey:@"matches"]; for(NSDictionary* match in matches) { NSString* value = [match objectForKey:@"value"]; @@ -175,7 +175,7 @@ - (NSString*)parse:(NSString *)string { } // Exact else if([scope isEqualToString:@"exact"]) { - int s, e; + NSInteger s, e; if([type isEqualToString:@"suffix"]) { s = end; e = end + [value length]; @@ -185,7 +185,7 @@ - (NSString*)parse:(NSString *)string { s = start - [value length]; e = start; } - if(![self isExact:value heystack:fixed start:s end:e not:isNegative]) { + if(![self isExact:value heystack:fixed start:(int)s end:(int)e not:isNegative]) { replace = FALSE; break; } @@ -237,7 +237,7 @@ - (NSString*)parse:(NSString *)string { - (BOOL)isVowel:(unichar)c { // Making it lowercase for checking c = [self smallCap:c]; - int i, len = [_vowel length]; + NSInteger i, len = [_vowel length]; for (i = 0; i < len; ++i) { if ([_vowel characterAtIndex:i] == c) { return TRUE; @@ -249,7 +249,7 @@ - (BOOL)isVowel:(unichar)c { - (BOOL)isConsonant:(unichar)c { // Making it lowercase for checking c = [self smallCap:c]; - int i, len = [_consonant length]; + NSInteger i, len = [_consonant length]; for (i = 0; i < len; ++i) { if ([_consonant characterAtIndex:i] == c) { return TRUE; @@ -265,7 +265,7 @@ - (BOOL)isPunctuation:(unichar)c { - (BOOL)isCaseSensitive:(unichar)c { // Making it lowercase for checking c = [self smallCap:c]; - int i, len = [_casesensitive length]; + NSInteger i, len = [_casesensitive length]; for (i = 0; i < len; ++i) { if ([_casesensitive characterAtIndex:i] == c) { return TRUE; @@ -289,7 +289,7 @@ - (unichar)smallCap:(unichar) letter { - (NSString*)clean:(NSString *)string { NSMutableString* fixed = [[NSMutableString alloc] initWithCapacity:0]; - int i, len = [string length]; + NSInteger i, len = [string length]; for (i = 0; i < len; ++i) { unichar c = [string characterAtIndex:i]; if (![self isCaseSensitive:c]) { diff --git a/Suggestion.m b/Suggestion.m index 53a9b5b..ae981e0 100644 --- a/Suggestion.m +++ b/Suggestion.m @@ -112,7 +112,7 @@ - (NSMutableArray*)getList:(NSString*)term { } // Suggestions with Suffix - int i; + NSInteger i; BOOL alreadySelected = FALSE; [[CacheManager sharedInstance] removeAllBase]; for (i = [term length]-1; i > 0; --i) { @@ -134,7 +134,7 @@ - (NSMutableArray*)getList:(NSString*)term { } NSString* word; // Again saving humanity cause I'm Superman, no I'm not drunk or on weed :D - int cutPos = [item length] - 1; + NSInteger cutPos = [item length] - 1; NSString* itemRMC = [item substringFromIndex:cutPos]; // RMC is Right Most Character NSString* suffixLMC = [suffix substringToIndex:1]; // LMC is Left Most Character