From 2c0a39d7c6cb55823ab054f3cff62c5193ae4350 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sun, 12 Oct 2008 22:17:27 +0000 Subject: [PATCH] more changes in counter scope --- macosx/CreatorWindowController.m | 6 ++---- macosx/GroupsController.m | 13 +++++------- macosx/NSMenuAdditions.m | 3 +-- macosx/TorrentCell.m | 3 +-- macosx/TorrentTableView.m | 35 ++++++++++++-------------------- macosx/TrackerTableView.m | 6 +++--- 6 files changed, 25 insertions(+), 41 deletions(-) diff --git a/macosx/CreatorWindowController.m b/macosx/CreatorWindowController.m index 3e24a653c..41deefb06 100644 --- a/macosx/CreatorWindowController.m +++ b/macosx/CreatorWindowController.m @@ -125,8 +125,7 @@ } //remove potentially invalid addresses - NSInteger i; - for (i = [fTrackers count]-1; i >= 0; i--) + for (NSInteger i = [fTrackers count]-1; i >= 0; i--) { if (!tr_httpIsValidURL([[fTrackers objectAtIndex: i] UTF8String])) [fTrackers removeObjectAtIndex: i]; @@ -413,8 +412,7 @@ //parse non-empty tracker strings tr_tracker_info * trackerInfo = tr_new0(tr_tracker_info, [fTrackers count]); - NSUInteger i; - for (i = 0; i < [fTrackers count]; i++) + for (NSUInteger i = 0; i < [fTrackers count]; i++) trackerInfo[i].announce = (char *)[[fTrackers objectAtIndex: i] UTF8String]; //store values diff --git a/macosx/GroupsController.m b/macosx/GroupsController.m index 9fc8d18d9..d7e1b4658 100644 --- a/macosx/GroupsController.m +++ b/macosx/GroupsController.m @@ -115,8 +115,7 @@ GroupsController * fGroupsInstance = nil; { if (index != -1) { - int i; - for (i = 0; i < [fGroups count]; i++) + for (NSInteger i = 0; i < [fGroups count]; i++) if (index == [[[fGroups objectAtIndex: i] objectForKey: @"Index"] intValue]) return i; } @@ -170,7 +169,7 @@ GroupsController * fGroupsInstance = nil; - (void) addNewGroup { //find the lowest index - int index; + NSInteger index; for (index = 0; index < [fGroups count]; index++) { BOOL found = NO; @@ -197,8 +196,7 @@ GroupsController * fGroupsInstance = nil; - (void) removeGroupWithRowIndexes: (NSIndexSet *) rowIndexes { NSMutableIndexSet * indexes = [NSMutableIndexSet indexSet]; - int index; - for (index = [rowIndexes firstIndex]; index != NSNotFound; index = [rowIndexes indexGreaterThanIndex: index]) + for (NSInteger index = [rowIndexes firstIndex]; index != NSNotFound; index = [rowIndexes indexGreaterThanIndex: index]) [indexes addIndex: [[[fGroups objectAtIndex: index] objectForKey: @"Index"] intValue]]; [fGroups removeObjectsAtIndexes: rowIndexes]; @@ -218,8 +216,7 @@ GroupsController * fGroupsInstance = nil; NSArray * selectedGroups = [fGroups objectsAtIndexes: selectedIndexes]; //determine where to move them - int i, originalRow = newRow; - for (i = [indexes firstIndex]; i < originalRow && i != NSNotFound; i = [indexes indexGreaterThanIndex: i]) + for (NSInteger i = [indexes firstIndex], startRow = newRow; i < startRow && i != NSNotFound; i = [indexes indexGreaterThanIndex: i]) newRow--; //remove objects to reinsert @@ -227,7 +224,7 @@ GroupsController * fGroupsInstance = nil; [fGroups removeObjectsAtIndexes: indexes]; //insert objects at new location - for (i = 0; i < [movingGroups count]; i++) + for (NSInteger i = 0; i < [movingGroups count]; i++) [fGroups insertObject: [movingGroups objectAtIndex: i] atIndex: newRow + i]; [movingGroups release]; diff --git a/macosx/NSMenuAdditions.m b/macosx/NSMenuAdditions.m index feee20c11..f53e76201 100644 --- a/macosx/NSMenuAdditions.m +++ b/macosx/NSMenuAdditions.m @@ -31,8 +31,7 @@ int bottomIndex = bottom ? [self numberOfItems] : 0; NSMenuItem * item; - unsigned int i; - for (i = [indexes lastIndex]; i != NSNotFound; i = [indexes indexLessThanIndex: i]) + for (NSUInteger i = [indexes lastIndex]; i != NSNotFound; i = [indexes indexLessThanIndex: i]) { item = [[menu itemAtIndex: i] retain]; [menu removeItemAtIndex: i]; diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index 5b05a4986..4e77e56ac 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -683,8 +683,7 @@ NSIndexSet * previousFinishedIndexes = [torrent previousFinishedPieces]; NSMutableIndexSet * finishedIndexes = [NSMutableIndexSet indexSet]; - int i; - for (i = 0; i < pieceCount; i++) + for (NSInteger i = 0; i < pieceCount; i++) { NSColor * pieceColor; if (piecesPercent[i] == 1.0) diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 51de3ccc0..ccc61e87b 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -71,8 +71,7 @@ [self setOutlineTableColumn: groupColumn]; //remove all unnecessary columns - int i; - for (i = [[self tableColumns] count]-1; i >= 0; i--) + for (NSInteger i = [[self tableColumns] count]-1; i >= 0; i--) { NSTableColumn * column = [[self tableColumns] objectAtIndex: i]; if (column != groupColumn) @@ -255,9 +254,7 @@ return; NSPoint mouseLocation = [self convertPoint: [[self window] convertScreenToBase: [NSEvent mouseLocation]] fromView: nil]; - - NSUInteger row; - for (row = rows.location; row < NSMaxRange(rows); row++) + for (NSUInteger row = rows.location; row < NSMaxRange(rows); row++) { if (![[self itemAtRow: row] isKindOfClass: [Torrent class]]) continue; @@ -449,8 +446,8 @@ } else { - int i, group = [item groupIndex]; - for (i = 0; i < [self numberOfRows]; i++) + int group = [item groupIndex]; + for (NSInteger i = 0; i < [self numberOfRows]; i++) { if ([indexSet containsIndex: i]) continue; @@ -473,8 +470,7 @@ NSIndexSet * selectedIndexes = [self selectedRowIndexes]; NSMutableArray * values = [NSMutableArray arrayWithCapacity: [selectedIndexes count]]; - NSUInteger i; - for (i = [selectedIndexes firstIndex]; i != NSNotFound; i = [selectedIndexes indexGreaterThanIndex: i]) + for (NSUInteger i = [selectedIndexes firstIndex]; i != NSNotFound; i = [selectedIndexes indexGreaterThanIndex: i]) [values addObject: [self itemAtRow: i]]; return values; @@ -485,8 +481,7 @@ NSIndexSet * selectedIndexes = [self selectedRowIndexes]; NSMutableArray * torrents = [NSMutableArray arrayWithCapacity: [selectedIndexes count]]; //take a shot at guessing capacity - NSUInteger i; - for (i = [selectedIndexes firstIndex]; i != NSNotFound; i = [selectedIndexes indexGreaterThanIndex: i]) + for (NSUInteger i = [selectedIndexes firstIndex]; i != NSNotFound; i = [selectedIndexes indexGreaterThanIndex: i]) { id item = [self itemAtRow: i]; if ([item isKindOfClass: [Torrent class]]) @@ -608,8 +603,7 @@ [NSMenu popUpContextMenu: fActionMenu withEvent: newEvent forView: self]; - NSInteger i; - for (i = [fActionMenu numberOfItems]-1; i >= numberOfNonFileItems; i--) + for (NSInteger i = [fActionMenu numberOfItems]-1; i >= numberOfNonFileItems; i--) [fActionMenu removeItemAtIndex: i]; [fMenuTorrent release]; @@ -629,8 +623,7 @@ { const int speedLimitActionValue[] = { 0, 5, 10, 20, 30, 40, 50, 75, 100, 150, 200, 250, 500, 750, -1 }; - int i; - for (i = 0; speedLimitActionValue[i] != -1; i++) + for (NSInteger i = 0; speedLimitActionValue[i] != -1; i++) { item = [[NSMenuItem alloc] initWithTitle: [NSString stringWithFormat: NSLocalizedString(@"%d KB/s", "Action menu -> upload/download limit"), speedLimitActionValue[i]] action: @selector(setQuickLimit:) @@ -663,8 +656,7 @@ { const float ratioLimitActionValue[] = { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, -1.0 }; - int i; - for (i = 0; ratioLimitActionValue[i] != -1.0; i++) + for (NSInteger i = 0; ratioLimitActionValue[i] != -1.0; i++) { item = [[NSMenuItem alloc] initWithTitle: [NSString localizedStringWithFormat: @"%.2f", ratioLimitActionValue[i]] action: @selector(setQuickRatio:) keyEquivalent: @""]; @@ -708,14 +700,13 @@ NSRect visibleRect = clipRect; NSRange rows = [self rowsInRect: visibleRect]; BOOL start = YES; - int i; if (rows.length > 0) { //determine what the first row color should be if ([[self itemAtRow: rows.location] isKindOfClass: [Torrent class]]) { - for (i = rows.location-1; i>=0; i--) + for (NSInteger i = rows.location-1; i>=0; i--) { if (![[self itemAtRow: i] isKindOfClass: [Torrent class]]) break; @@ -728,6 +719,7 @@ rows.length--; } + NSInteger i; for (i = rows.location; i < NSMaxRange(rows); i++) { if (![[self itemAtRow: i] isKindOfClass: [Torrent class]]) @@ -752,7 +744,7 @@ int numberOfRects = ceil(visibleRect.size.height / height); visibleRect.size.height = height; - for (i=0; i 0) { @@ -58,7 +57,7 @@ { if (![[fTrackers objectAtIndex: rows.location] isKindOfClass: [NSNumber class]]) { - for (i = rows.location-1; i>=0; i--) + for (NSInteger i = rows.location-1; i>=0; i--) { if ([[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]]) break; @@ -72,6 +71,7 @@ } } + NSInteger i; for (i = rows.location; i < NSMaxRange(rows); i++) { if ([[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]] && onLeopard) @@ -96,7 +96,7 @@ int numberOfRects = ceil(visibleRect.size.height / height); visibleRect.size.height = height; - for (i=0; i