summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2010-11-30 05:35:31 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2010-12-01 01:46:25 -0800
commit9781428743d8ad07f073423d451286548af7ec7f (patch)
treef6788ae34b486a5a98ac60774aa6c115f48ca51e
parent36047c66a6ce539b368cfbc352c165b3118b2e60 (diff)
Only copy Package::id_ from APT if it is mixed case.
-rw-r--r--MobileCydia.mm33
1 files changed, 20 insertions, 13 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 40176cc..d558ad8 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -766,23 +766,24 @@ class CYString {
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_();
- 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;
+
+ if (pool != NULL)
+ copy(pool);
}
}
@@ -2218,15 +2219,21 @@ struct PackageNameOrdering :
_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)
+ // 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)
- // 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)