summaryrefslogtreecommitdiff
path: root/Cydia.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2008-03-05 05:28:38 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2008-03-05 05:28:38 +0000
commit9b70dd6d4d4667392009208d741accef1372dc3c (patch)
tree9aba42fa9aad5c7a668737976945ceba450d479e /Cydia.mm
parent51a1ffdf1cb0e523178958270347e3207c237159 (diff)
Handle the case of a package with a NULL section.
Diffstat (limited to 'Cydia.mm')
-rw-r--r--Cydia.mm33
1 files changed, 23 insertions, 10 deletions
diff --git a/Cydia.mm b/Cydia.mm
index d221178..c643b34 100644
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -1067,7 +1067,8 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
}
- (NSString *) section {
- return [[NSString stringWithCString:iterator_.Section()] stringByReplacingCharacter:'_' withCharacter:' '];
+ const char *section = iterator_.Section();
+ return section == NULL ? nil : [[NSString stringWithCString:section] stringByReplacingCharacter:'_' withCharacter:' '];
}
- (Address *) maintainer {
@@ -1178,9 +1179,19 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
}
- (NSComparisonResult) compareBySectionAndName:(Package *)package {
- NSComparisonResult result = [[self section] compare:[package section]];
- if (result != NSOrderedSame)
- return result;
+ NSString *lhs = [self section];
+ NSString *rhs = [package section];
+
+ if (lhs == NULL && rhs != NULL)
+ return NSOrderedAscending;
+ else if (lhs != NULL && rhs == NULL)
+ return NSOrderedDescending;
+ else if (lhs != NULL && rhs != NULL) {
+ NSComparisonResult result = [lhs compare:rhs];
+ if (result != NSOrderedSame)
+ return result;
+ }
+
return [self compareByName:package];
}
@@ -1387,10 +1398,11 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
[cell setValue:(installed == nil ? @"n/a" : installed)];
} break;
- case 2:
+ case 2: {
[cell setTitle:@"Section"];
- [cell setValue:[package_ section]];
- break;
+ NSString *section([package_ section]);
+ [cell setValue:(section == nil ? @"n/a" : section)];
+ } break;
case 3:
[cell setTitle:@"Expanded Size"];
@@ -2329,7 +2341,8 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
[name_ setText:@"All Packages"];
[count_ setText:nil];
} else {
- [name_ setText:[section name]];
+ NSString *name = [section name];
+ [name_ setText:(name == nil ? @"(No Section)" : name)];
[count_ setText:[NSString stringWithFormat:@"%d", [section count]]];
}
}
@@ -2544,10 +2557,10 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
Package *package = [packages_ objectAtIndex:offset];
NSString *name = [package section];
- if (section == nil || ![[section name] isEqual:name]) {
+ if (section == nil || name != nil && ![[section name] isEqual:name]) {
section = [[[Section alloc] initWithName:name row:offset] autorelease];
- if ([name isEqualToString:section_])
+ if (name == nil || [name isEqualToString:section_])
nsection = section;
[sections addObject:section];
}