Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

64bit integer fix warning #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions PinYin4Objc/Classes/PinyinFormatter.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#import "NSString+PinYin4Cocoa.h"

@interface PinyinFormatter ()
+(NSInteger)getNumericValue:(unichar)c;
+(NSInteger)indexOfChar:(int*) table ch:(unichar)c;
+(int)getNumericValue:(unichar)c;
+(int)indexOfChar:(int*) table ch:(unichar)c;
@end

@implementation PinyinFormatter
Expand Down Expand Up @@ -88,10 +88,10 @@ + (NSString *)convertToneNumber2ToneMarkWithNSString:(NSString *)pinyinStr {
NSString *allUnmarkedVowelStr = @"aeiouv";
NSString *allMarkedVowelStr = @"āáăàaēéĕèeīíĭìiōóŏòoūúŭùuǖǘǚǜü";
if ([lowerCasePinyinStr matchesPatternRegexPattern:@"[a-z]*[1-5]"]) {
int tuneNumber = [PinyinFormatter getNumericValue:[lowerCasePinyinStr characterAtIndex:lowerCasePinyinStr.length -1]];
int indexOfA = [lowerCasePinyinStr indexOf:charA];
int indexOfE = [lowerCasePinyinStr indexOf:charE];
int ouIndex = [lowerCasePinyinStr indexOfString:ouStr];
int tuneNumber = [PinyinFormatter getNumericValue:[lowerCasePinyinStr characterAtIndex:lowerCasePinyinStr.length -1]];
int indexOfA = (int)[lowerCasePinyinStr indexOf:charA];
int indexOfE = (int)[lowerCasePinyinStr indexOf:charE];
int ouIndex = (int)[lowerCasePinyinStr indexOfString:ouStr];
if (-1 != indexOfA) {
indexOfUnmarkedVowel = indexOfA;
unmarkedVowel = charA;
Expand All @@ -105,7 +105,7 @@ + (NSString *)convertToneNumber2ToneMarkWithNSString:(NSString *)pinyinStr {
unmarkedVowel = [ouStr characterAtIndex:0];
}
else {
for (int i = [lowerCasePinyinStr length] - 1; i >= 0; i--) {
for (int i = (int)[lowerCasePinyinStr length] - 1; i >= 0; i--) {
if ([[NSString valueOfChar:[lowerCasePinyinStr characterAtIndex:i]] matchesPatternRegexPattern:@"[aeiouv]"]) {
indexOfUnmarkedVowel = i;
unmarkedVowel = [lowerCasePinyinStr characterAtIndex:i];
Expand All @@ -114,7 +114,7 @@ + (NSString *)convertToneNumber2ToneMarkWithNSString:(NSString *)pinyinStr {
}
}
if ((defautlCharValue != unmarkedVowel) && (defautlIndexValue != indexOfUnmarkedVowel)) {
int rowIndex = [allUnmarkedVowelStr indexOf:unmarkedVowel];
int rowIndex = (int)[allUnmarkedVowelStr indexOf:unmarkedVowel];
int columnIndex = tuneNumber - 1;
int vowelLocation = rowIndex * 5 + columnIndex;
unichar markedVowel = [allMarkedVowelStr characterAtIndex:vowelLocation];
Expand All @@ -137,7 +137,7 @@ + (NSString *)convertToneNumber2ToneMarkWithNSString:(NSString *)pinyinStr {
}
}

+(NSInteger)getNumericValue:(unichar)c
+(int)getNumericValue:(unichar)c
{
if (c < 128) {
// Optimized for ASCII
Expand Down Expand Up @@ -168,7 +168,7 @@ +(NSInteger)getNumericValue:(unichar)c

}

+(NSInteger)indexOfChar:(int*) table ch:(unichar)c{
+(int)indexOfChar:(int*) table ch:(unichar)c{
NSInteger len=sizeof(table)/sizeof(table[0]);
for (int i = 0; i < len; i++) {
if (table[i] == (int) c) {
Expand Down