tag 670569 +patch thanks Hi Enrico,
attached you find my patch. Apart from fixing the long description it also introduces and accessor method for pkgCache from apt::Apt. The implementation for the fix of the long description heavily borrows from libapt. Note that it is a quick fix and it significantly lengthens the time it takes to create package records (thereby slowing down packagesearch quite a bit for large result sets). In future, it will probably be useful to handle the long description differently and lazily initialize it (each PackageRecord has to contain a pointer to the pkgCache for this). I would appreciate it, if you could upload a new version of libept before the freeze. Best regards Ben
diff -ru libept-1.0.6.2/ept/apt/apt.cc libept-1.0.6.1/ept/apt/apt.cc
--- libept-1.0.6.2/ept/apt/apt.cc 2012-06-10 16:29:21.000000000 +0200
+++ libept-1.0.6.1/ept/apt/apt.cc 2012-01-24 14:00:25.000000000 +0100
@@ -624,55 +624,15 @@
delete[] buffer;
return std::string();
}
-
- // Get a pointer to start of Description field
- const char *DescP = (char*)strstr((char*)buffer, "Description:");
- // put in everything until description
- std::stringstream result;
- result.write(buffer, DescP - buffer);
-
-
- // Show the right description
- pkgRecords Recs(impl->cache());
- pkgCache::DescIterator Desc = vi.TranslatedDescription();
- pkgRecords::Parser &P = Recs.Lookup(Desc.FileList());
- // TODO currently the language code is not added here
- // this would break the packagerecord parsing algorithm, should be implemented
- // in the future though
- //result << "Description" << ( (strcmp(Desc.LanguageCode(),"") != 0) ? "-" : "" ) << Desc.LanguageCode() << ": " << P.LongDesc();
- result << "Description: " << P.LongDesc();
-
-
- // Find the first field after the description (if there is any)
- for(DescP++;DescP != &buffer[vi.FileList()->Size];DescP++)
- {
- if(*DescP == '\n' && *(DescP+1) != ' ')
- {
- // write the rest of the buffer
- const char *end=&buffer[vi.FileList()->Size];
- result.write(DescP,end-DescP);
- break;
- }
- }
- // write a final newline (after the description)
- result<<endl;
-
-
+ std::string res(buffer, vfi->Size);
delete[] buffer;
- return result.str();
+ return res;
}
}
return std::string();
}
-
-const pkgCache* Apt::aptPkgCache() const
-{
- return impl->m_cache;
-}
-
-
void Apt::checkCacheUpdates()
{
if (impl->m_open_timestamp < timestamp())
diff -ru libept-1.0.6.2/ept/apt/apt.h libept-1.0.6.1/ept/apt/apt.h
--- libept-1.0.6.2/ept/apt/apt.h 2012-06-10 16:29:21.000000000 +0200
+++ libept-1.0.6.1/ept/apt/apt.h 2012-01-24 14:00:25.000000000 +0100
@@ -29,8 +29,6 @@
#include <iterator>
-class pkgCache;
-
namespace ept {
namespace apt {
@@ -200,7 +198,6 @@
Apt();
~Apt();
-
iterator begin() const;
iterator end() const;
@@ -260,11 +257,6 @@
/// Get the raw package record for the given Version
std::string rawRecord(const Version& ver) const;
- /// Returns the pointer to the internal libapt pkgCache object used.
- const pkgCache* aptPkgCache() const;
-
-
-
/// Timestamp of when the apt index was last modified
time_t timestamp();
signature.asc
Description: This is a digitally signed message part

