]> git.saurik.com Git - cydia.git/blobdiff - Cydia.mm
We don't like the SWF debugging.
[cydia.git] / Cydia.mm
index 266415a36bdb32883b4ada5ddd305535265dfda9..c40a0d27d118be750bbde57800cbbd9ddb8c76cb 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -1138,11 +1138,15 @@ NSString *SizeString(double size) {
     return [NSString stringWithFormat:@"%s%.1f %s", (negative ? "-" : ""), size, powers_[power]];
 }
 
-NSString *StripVersion(const char *version) {
+static _finline CFStringRef CFCString(const char *value) {
+    return CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const uint8_t *>(value), strlen(value), kCFStringEncodingUTF8, NO, kCFAllocatorNull);
+}
+
+CFStringRef StripVersion(const char *version) {
     const char *colon(strchr(version, ':'));
     if (colon != NULL)
         version = colon + 1;
-    return [NSString stringWithUTF8String:version];
+    return CFCString(version);
 }
 
 NSString *LocalizeSection(NSString *section) {
@@ -1691,7 +1695,7 @@ typedef std::map< unsigned long, _H<Source> > SourceMap;
     Address *author$_;
 
     CYString support_;
-    NSArray *tags_;
+    NSMutableArray *tags_;
     NSString *role_;
 
     NSArray *relationships_;
@@ -2007,7 +2011,7 @@ struct PackageNameOrdering :
 
         _profile(Package$parse$Tagline)
             const char *start, *end;
-            if (parser->Find("Description", start, end)) {
+            if (parser->ShortDesc(start, end)) {
                 const char *stop(reinterpret_cast<const char *>(memchr(start, '\n', end - start)));
                 if (stop == NULL)
                     stop = end;
@@ -2038,14 +2042,14 @@ struct PackageNameOrdering :
         database_ = database;
 
         _profile(Package$initWithVersion$Latest)
-            latest_ = [StripVersion(version_.VerStr()) retain];
+            latest_ = (NSString *) StripVersion(version_.VerStr());
         _end
 
         pkgCache::VerIterator current;
         _profile(Package$initWithVersion$Versions)
             current = iterator_.CurrentVer();
             if (!current.end())
-                installed_ = [StripVersion(current.VerStr()) retain];
+                installed_ = (NSString *) StripVersion(current.VerStr());
 
             if (!version_.end())
                 file_ = version_.FileList();
@@ -2057,6 +2061,7 @@ struct PackageNameOrdering :
 
         _profile(Package$initWithVersion$Name)
             id_.set(pool_, iterator_.Name());
+            name_.set(pool, iterator_.Display());
         _end
 
         if (!file_.end()) {
@@ -2068,15 +2073,18 @@ struct PackageNameOrdering :
             _end
         }
 
-        /* XXX: get the damned Name */
-
         _profile(Package$initWithVersion$Tags)
-            if (tags_ != nil)
-                for (NSString *tag in tags_)
-                    if ([tag hasPrefix:@"role::"]) {
-                        role_ = [[tag substringFromIndex:6] retain];
-                        break;
-                    }
+            pkgCache::TagIterator tag(iterator_.TagList());
+            if (!tag.end()) {
+                tags_ = [[NSMutableArray alloc] initWithCapacity:8];
+                do {
+                    const char *name(tag.Name());
+                    [tags_ addObject:(NSString *)CFCString(name)];
+                    if (role_ == nil && strncmp(name, "role::", 6) == 0)
+                        role_ = (NSString *) CFCString(name + 6);
+                    ++tag;
+                } while (!tag.end());
+            }
         _end
 
         bool changed(false);
@@ -2086,7 +2094,7 @@ struct PackageNameOrdering :
             metadata_ = [Packages_ objectForKey:key];
 
             if (metadata_ == nil) {
-                firstSeen_ = [now_ retain];
+                firstSeen_ = now_;
 
                 metadata_ = [[NSMutableDictionary dictionaryWithObjectsAndKeys:
                     firstSeen_, @"FirstSeen",
@@ -3101,6 +3109,9 @@ static NSArray *Finishes_;
         ++era_;
     }
 
+    [packages_ removeAllObjects];
+    sources_.clear();
+
     _error->Discard();
 
     delete list_;
@@ -3117,6 +3128,11 @@ static NSArray *Finishes_;
     delete policy_;
     policy_ = NULL;
 
+    if (now_ != nil) {
+        [now_ release];
+        now_ = nil;
+    }
+
     cache_.Close();
 
     apr_pool_clear(pool_);
@@ -3171,7 +3187,6 @@ static NSArray *Finishes_;
 
     _trace();
 
-    sources_.clear();
     for (pkgSourceList::const_iterator source = list_->begin(); source != list_->end(); ++source) {
         std::vector<pkgIndexFile *> *indices = (*source)->GetIndexFiles();
         for (std::vector<pkgIndexFile *>::const_iterator index = indices->begin(); index != indices->end(); ++index)
@@ -3191,8 +3206,6 @@ static NSArray *Finishes_;
         [packages_ release];
         packages_ = nil;*/
 
-        [packages_ removeAllObjects];
-
         _trace();
 
         for (pkgCache::PkgIterator iterator = cache_->PkgBegin(); !iterator.end(); ++iterator)