]> git.saurik.com Git - cydia.git/commitdiff
Only copy Package::id_ from APT if it is mixed case.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 30 Nov 2010 13:35:31 +0000 (05:35 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 1 Dec 2010 09:46:25 +0000 (01:46 -0800)
MobileCydia.mm

index 40176ccd460f3fa443f9be636e0e696ce3e0712a..d558ad83a90b282d91c222746984b5f8d214f585 100644 (file)
@@ -766,23 +766,24 @@ class CYString {
             cache_ = reinterpret_cast<CFStringRef>(CFRetain(rhs.cache_));
     }
 
             cache_ = reinterpret_cast<CFStringRef>(CFRetain(rhs.cache_));
     }
 
+    void copy(apr_pool_t *pool) {
+        char *temp(reinterpret_cast<char *>(apr_palloc(pool, size_ + 1)));
+        memcpy(temp, data_, size_);
+        temp[size_] = '\0';
+        data_ = temp;
+    }
+
     void set(apr_pool_t *pool, const char *data, size_t size) {
         if (size == 0)
             clear();
         else {
             clear_();
 
     void set(apr_pool_t *pool, const char *data, size_t size) {
         if (size == 0)
             clear();
         else {
             clear_();
 
-            if (pool == NULL)
-                data_ = const_cast<char *>(data);
-            else {
-                char *temp(reinterpret_cast<char *>(apr_palloc(pool, size + 1)));
-                memcpy(temp, data, size);
-                temp[size] = '\0';
-
-                data_ = temp;
-            }
-
+            data_ = const_cast<char *>(data);
             size_ = size;
             size_ = size;
+
+            if (pool != NULL)
+                copy(pool);
         }
     }
 
         }
     }
 
@@ -2218,15 +2219,21 @@ struct PackageNameOrdering :
         _end
 
         _profile(Package$initWithVersion$Name)
         _end
 
         _profile(Package$initWithVersion$Name)
-            id_.set(pool_, iterator_.Name());
+            id_.set(NULL, iterator_.Name());
             name_.set(NULL, iterator_.Display());
         _end
 
         _profile(Package$initWithVersion$lowercaseString)
             name_.set(NULL, iterator_.Display());
         _end
 
         _profile(Package$initWithVersion$lowercaseString)
+            // XXX: do not use tolower() as this is not locale-specific? :(
             char *data(id_.data());
             for (size_t i(0), e(id_.size()); i != e; ++i)
             char *data(id_.data());
             for (size_t i(0), e(id_.size()); i != e; ++i)
-                // XXX: do not use tolower() as this is not locale-specific? :(
-                data[i] |= 0x20;
+                if ((data[i] & 0x20) == 0) {
+                    id_.copy(pool);
+                    data = id_.data();
+                    for (; i != e; ++i)
+                        data[i] |= 0x20;
+                    break;
+                }
         _end
 
         _profile(Package$initWithVersion$Tags)
         _end
 
         _profile(Package$initWithVersion$Tags)