Skip to content

Commit

Permalink
- Fixed a lot of NS(U)Integer issues which caused potential 64-bit in…
Browse files Browse the repository at this point in the history
…compatibility
  • Loading branch information
nikita-zhuk committed Jun 4, 2011
1 parent 2cc83ab commit a4aa3b9
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 36 deletions.
4 changes: 2 additions & 2 deletions FoundationAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ - (NSArray *)arrayByMakingObjectsPerformSelector:(SEL)aSelector withObject:anObj
- (NSArray *)arrayByMakingObjectsPerformSelector:(SEL)aSelector withObject:anObject
withObject:anObject2
{
unsigned i, count = [self count];
NSUInteger i, count = [self count];
NSMutableArray *array = [NSMutableArray arrayWithCapacity:count];

for(i=0; i<count; i++)
Expand Down Expand Up @@ -223,7 +223,7 @@ - (BOOL)regularFileExistsAtPath:(NSString *)path

- (NSString *)findFile:(NSString *)filename inSearchPath:(NSArray *)paths
{
int i, count = [paths count];
NSInteger i, count = [paths count];

for (i=0; i<count; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions MiscMerge/MiscMergeCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ - (BOOL)eatKeyWord:(NSString *)aKeyWord fromScanner:(NSScanner *)scanner
isOptional:(BOOL)optional
{
NSCharacterSet *letterSet = [NSCharacterSet letterCharacterSet];
int origLocation = [scanner scanLocation];
NSUInteger origLocation = [scanner scanLocation];
BOOL isAlphaKeyword = [aKeyWord length] > 0 && [letterSet characterIsMember:[aKeyWord characterAtIndex:0]];
BOOL wasCaseSensitive = [scanner caseSensitive];
BOOL foundKeyword;
Expand All @@ -124,7 +124,7 @@ - (BOOL)eatKeyWord:(NSString *)aKeyWord fromScanner:(NSScanner *)scanner
if (foundKeyword && isAlphaKeyword)
{
NSString *string = [scanner string];
int currLocation = [scanner scanLocation];
NSUInteger currLocation = [scanner scanLocation];

/* If we're at the end of the string, or the next char is not a letter, we're good. Otherwise abort. */
if (currLocation < [string length] &&
Expand Down
6 changes: 3 additions & 3 deletions MiscMerge/MiscMergeEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ - (void)removeContextObject:(id)anObject
[contextStack removeObjectIdenticalTo:anObject];

if ( anObject == localSymbols ) {
int i;
NSInteger i;

localSymbols = nil;

Expand Down Expand Up @@ -569,7 +569,7 @@ - (MiscMergeCommandExitType)executeCommandBlock:(MiscMergeCommandBlock *)block
{
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
NSArray *commandArray = [block commandArray];
int i, count = [commandArray count];
NSInteger i, count = [commandArray count];
MiscMergeCommandExitType exitCode = MiscMergeCommandExitNormal;
/*
* Maintain the execution stack. This stack isn't being used at the
Expand Down Expand Up @@ -603,7 +603,7 @@ - (MiscMergeCommandExitType)executeCommandBlock:(MiscMergeCommandBlock *)block
"*/
- (id)valueForField:(NSString *)fieldName quoted:(int)quoted
{
int i;
NSInteger i;
id value = nil;
id prevValue = nil;
id returnValue = nil;
Expand Down
2 changes: 1 addition & 1 deletion MiscMerge/MiscMergeExpression.m
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ - (NSString *)nameDescription

- (NSString *)description
{
int index, count = [expressions count];
NSInteger index, count = [expressions count];
NSMutableString *string = [NSMutableString stringWithFormat:@"%@(", [self nameDescription]];

for ( index = 0; index < count; index++ ) {
Expand Down
4 changes: 2 additions & 2 deletions MiscMerge/MiscMergeFunctions.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ Class MMCommonAnscestorClass(id obj1, id obj2)
else {
NSCharacterSet *whitespaceSet = [NSCharacterSet whitespaceCharacterSet];
NSCharacterSet *newlineSet = [NSCharacterSet newlineCharacterSet];
int start = 0, end = [string length]-1;
int i;
NSInteger start = 0, end = [string length]-1;
NSInteger i;

for ( i = 0; i <= end; i++ ) {
unichar character = [string characterAtIndex:i];
Expand Down
6 changes: 3 additions & 3 deletions MiscMerge/NSScanner+MiscMerge.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ - (BOOL)scanString:(NSString *)aString
"*/
- (NSRange)remainingRange
{
unsigned location = [self scanLocation];
NSUInteger location = [self scanLocation];
return NSMakeRange(location, [[self string] length] - location);
}

Expand Down Expand Up @@ -84,7 +84,7 @@ - (void)skipPastSkipCharacters

- (BOOL)scanCharacter:(unichar)targetCharacter
{
unsigned scanLocation = [self scanLocation];
NSUInteger scanLocation = [self scanLocation];
NSString *myString = [self string];

[self skipPastSkipCharacters];
Expand All @@ -104,7 +104,7 @@ - (BOOL)scanCharacter:(unichar)targetCharacter

- (unichar)peekNextCharacter
{
unsigned scanLocation;
NSUInteger scanLocation;
NSString *myString;

[self skipPastSkipCharacters];
Expand Down
2 changes: 1 addition & 1 deletion MiscMerge/NSString+MiscAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ enum
/*" "Letter" manipulation "*/
- (NSString *)letterAtIndex:(unsigned)anIndex;
- (NSString *)firstLetter;
- (unsigned)letterCount;
- (NSUInteger)letterCount;

/*" Getting "words" "*/
- (NSArray *)wordArray;
Expand Down
26 changes: 13 additions & 13 deletions MiscMerge/NSString+MiscAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ - (NSString *)firstLetter
return [self letterAtIndex:0];
}

- (unsigned)letterCount
- (NSUInteger)letterCount
{
unsigned count = 0;
unsigned selfLength = [self length];
unsigned currIndex = 0;
NSUInteger count = 0;
NSUInteger selfLength = [self length];
NSUInteger currIndex = 0;
NSRange letterRange;

while (currIndex < selfLength)
Expand Down Expand Up @@ -227,7 +227,7 @@ - (NSString *)firstWord
}

static NSRange _nextSearchRange(NSString *string, unsigned mask,
NSRange *foundRange, unsigned lastIndex, unsigned firstIndex)
NSRange *foundRange, NSUInteger lastIndex, NSUInteger firstIndex)
{
/*
* The char range stuff is if we want to use
Expand All @@ -241,7 +241,7 @@ static NSRange _nextSearchRange(NSString *string, unsigned mask,

if (mask & NSBackwardsSearch)
{
unsigned endLocation;
NSUInteger endLocation;

if (mask & MiscOverlappingSearch)
{
Expand Down Expand Up @@ -282,7 +282,7 @@ static NSRange _nextSearchRange(NSString *string, unsigned mask,
NSRange foundRange;
NSRange betweenRange;
unsigned searchOptions = (mask & (NSCaseInsensitiveSearch|NSLiteralSearch));
unsigned selfLength = [self length];
NSUInteger selfLength = [self length];
NSMutableString *newString = [NSMutableString stringWithCapacity:selfLength];

mask &= ~NSBackwardsSearch;
Expand Down Expand Up @@ -347,7 +347,7 @@ static NSRange _nextSearchRange(NSString *string, unsigned mask,

if ([scanner scanCharactersFromSet:aSet intoString:&betweenString])
{
int i, count = [betweenString length];
NSInteger i, count = [betweenString length];
// int i, count = [betweenString letterCount];

for (i=0;i<count;i++)
Expand Down Expand Up @@ -376,7 +376,7 @@ static NSRange _nextSearchRange(NSString *string, unsigned mask,
if ([scanner scanCharactersFromSet:aSet intoString:&betweenString])
{
// int i, count = [betweenString length];
int i, count = [betweenString letterCount];
NSInteger i, count = [betweenString letterCount];

for (i=0;i<count;i++)
[stringArray addObject:replaceString];
Expand All @@ -403,7 +403,7 @@ - (unsigned)numOfString:(NSString *)aString range:(NSRange)range

- (unsigned)numOfString:(NSString *)aString options:(unsigned)mask range:(NSRange)range
{
unsigned lastIndex = NSMaxRange(range);
NSUInteger lastIndex = NSMaxRange(range);
unsigned stringCount = 0;
unsigned searchOptions = (mask & (NSCaseInsensitiveSearch|NSLiteralSearch));
NSRange searchRange;
Expand Down Expand Up @@ -441,7 +441,7 @@ - (NSRange)rangeOfString:(NSString *)aString occurrenceNum:(int)n range:(NSRange
- (NSRange)rangeOfString:(NSString *)aString options:(unsigned)mask
occurrenceNum:(int)n range:(NSRange)range
{
unsigned lastIndex = NSMaxRange(range);
NSUInteger lastIndex = NSMaxRange(range);
unsigned count = 0;
unsigned searchOptions = (mask & (~NSAnchoredSearch));
NSRange searchRange;
Expand All @@ -467,7 +467,7 @@ - (unsigned)numOfCharactersFromSet:(NSCharacterSet *)aSet

- (unsigned)numOfCharactersFromSet:(NSCharacterSet *)aSet range:(NSRange)range
{
unsigned lastIndex = NSMaxRange(range);
NSUInteger lastIndex = NSMaxRange(range);
NSRange searchRange = {range.location, lastIndex};
NSRange foundRange;
unsigned characterCount = 0;
Expand All @@ -487,7 +487,7 @@ - (unsigned)numOfCharactersFromSet:(NSCharacterSet *)aSet range:(NSRange)range

- (NSArray *)componentsSeparatedByCharactersFromSet:(NSCharacterSet *)aSet
{
unsigned selfLength = [self length];
NSUInteger selfLength = [self length];
NSRange searchRange = {0, selfLength};
NSRange betweenRange = {0, 0};
NSRange foundRange;
Expand Down
2 changes: 1 addition & 1 deletion MiscMerge/_MiscMergeCallCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger
{
NSString *symbolName = [NSString stringWithFormat:@"_MiscMergeProcedure%@", procedureName];
_MiscMergeProcedureCommand *procCommand = [[aMerger userInfo] objectForKey:symbolName];
int i, count = [argumentArray count];
NSInteger i, count = [argumentArray count];
NSMutableArray *realArgArray = [NSMutableArray arrayWithCapacity:count];

if (procCommand == nil)
Expand Down
6 changes: 3 additions & 3 deletions MiscMerge/_MiscMergeProcedureCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger
/* The *real* execute; messaged from the call command */
- (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger arguments:(NSArray *)passedArgArray
{
int argumentIndex = 0, argumentCount = [argumentArray count];
int passedIndex = 0, passedCount = [passedArgArray count];
int addToArgIndex = 0;
NSInteger argumentIndex = 0, argumentCount = [argumentArray count];
NSInteger passedIndex = 0, passedCount = [passedArgArray count];
NSInteger addToArgIndex = 0;
NSMutableDictionary *procedureContext = [NSMutableDictionary dictionary];

for ( ; passedIndex < passedCount; passedIndex++ ) {
Expand Down
8 changes: 4 additions & 4 deletions ddcli/DDGetoptLongParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ - (void) handleArgumentNotRecognized: (NSString *) option

@implementation DDGetoptLongParser

+ (DDGetoptLongParser *) optionsWithTarget: (id) target;
+ (DDGetoptLongParser *) optionsWithTarget: (id) target
{
return [[[self alloc] initWithTarget: target] autorelease];
}

- (id) initWithTarget: (id) target;
- (id) initWithTarget: (id) target
{
self = [super init];
if (self == nil)
Expand Down Expand Up @@ -170,7 +170,7 @@ - (NSArray *) parseOptions;
- (NSArray *) parseOptionsWithArguments: (NSArray *) arguments
command: (NSString *) command;
{
int argc = [arguments count];
NSUInteger argc = [arguments count];
char ** argv = alloca(sizeof(char *) * argc);
int i;
for (i = 0; i < argc; i++)
Expand All @@ -193,7 +193,7 @@ - (NSArray *) parseOptionsWithArguments: (NSArray *) arguments
opterr = 1;

int longOptionIndex = -1;
while ((ch = mGetoptFunction(argc, argv, optionString, options, &longOptionIndex)) != -1)
while ((ch = mGetoptFunction((int)argc, argv, optionString, options, &longOptionIndex)) != -1)
{
NSString * last_argv = [NSString stringWithUTF8String: argv[optind-1]];
if (ch == ':')
Expand Down
2 changes: 1 addition & 1 deletion mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ - (BOOL)hasTransformableAttributeType {
@implementation NSString (camelCaseString)
- (NSString*)camelCaseString {
NSArray *lowerCasedWordArray = [[self wordArray] arrayByMakingObjectsPerformSelector:@selector(lowercaseString)];
unsigned wordIndex = 1, wordCount = [lowerCasedWordArray count];
NSUInteger wordIndex = 1, wordCount = [lowerCasedWordArray count];
NSMutableArray *camelCasedWordArray = [NSMutableArray arrayWithCapacity:wordCount];
if (wordCount)
[camelCasedWordArray addObject:[lowerCasedWordArray objectAtIndex:0]];
Expand Down
2 changes: 2 additions & 0 deletions mogenerator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = mogenerator_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INSTALL_PATH = "$(HOME)/bin";
PRODUCT_NAME = mogenerator;
WARNING_CFLAGS = "-Wall";
Expand All @@ -446,6 +447,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = mogenerator_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INSTALL_PATH = "$(HOME)/bin";
PRODUCT_NAME = mogenerator;
WARNING_CFLAGS = "-Wall";
Expand Down

0 comments on commit a4aa3b9

Please sign in to comment.