"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "apt-pkg/algorithms.cc" between
apt-2.1.20.tar.gz and apt-2.2.0.tar.gz

About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.

algorithms.cc  (apt-2.1.20):algorithms.cc  (apt-2.2.0)
skipping to change at line 37 skipping to change at line 37
#include <apt-pkg/pkgcache.h> #include <apt-pkg/pkgcache.h>
#include <apt-pkg/string_view.h> #include <apt-pkg/string_view.h>
#include <apt-pkg/strutl.h> #include <apt-pkg/strutl.h>
#include <apt-pkg/version.h> #include <apt-pkg/version.h>
#include <apt-pkg/prettyprinters.h> #include <apt-pkg/prettyprinters.h>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <regex>
#include <set> #include <set>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <string.h> #include <string.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <apti18n.h> #include <apti18n.h>
/*}}}*/ /*}}}*/
skipping to change at line 1588 skipping to change at line 1587
if (Debug) if (Debug)
std::clog << "Keeping latest kernel " << latest->first << std::endl; std::clog << "Keeping latest kernel " << latest->first << std::endl;
keep.insert(latest->first); keep.insert(latest->first);
} }
if (keep.size() < 3 && previous != version2unames.rend()) if (keep.size() < 3 && previous != version2unames.rend())
{ {
if (Debug) if (Debug)
std::clog << "Keeping previous kernel " << previous->first << std::endl; std::clog << "Keeping previous kernel " << previous->first << std::endl;
keep.insert(previous->first); keep.insert(previous->first);
} }
// Escape special characters '.' and '+' in version strings so we can build a
std::regex special("([\\.\\+])"); regular expression
auto escapeSpecial = [](std::string input) -> std::string {
for (size_t pos = 0; (pos = input.find_first_of(".+", pos)) != input.npos;
pos += 2) {
input.insert(pos, 1, '\\');
}
return input;
};
std::ostringstream ss; std::ostringstream ss;
for (auto &pattern : _config->FindVector("APT::VersionedKernelPackages")) for (auto &pattern : _config->FindVector("APT::VersionedKernelPackages"))
{ {
// Legacy compatibility: Always protected the booted uname and last instal led uname // Legacy compatibility: Always protected the booted uname and last instal led uname
if (not lastInstalledUname.empty()) if (not lastInstalledUname.empty())
ss << "|^" << pattern << "-" << std::regex_replace(lastInstalledUname, s pecial, "\\$1") << "$"; ss << "|^" << pattern << "-" << escapeSpecial(lastInstalledUname) << "$" ;
if (*uts.release) if (*uts.release)
ss << "|^" << pattern << "-" << std::regex_replace(uts.release, special, "\\$1") << "$"; ss << "|^" << pattern << "-" << escapeSpecial(uts.release) << "$";
for (auto const &kernel : version2unames) for (auto const &kernel : version2unames)
{ {
if (ReturnRemove ? keep.find(kernel.first) == keep.end() : keep.find(ker nel.first) != keep.end()) if (ReturnRemove ? keep.find(kernel.first) == keep.end() : keep.find(ker nel.first) != keep.end())
{ {
for (auto const &uname : kernel.second) for (auto const &uname : kernel.second)
ss << "|^" << pattern << "-" << std::regex_replace(uname, special, "\\$1") << "$"; ss << "|^" << pattern << "-" << escapeSpecial(uname) << "$";
} }
} }
} }
auto re_with_leading_or = ss.str(); auto re_with_leading_or = ss.str();
if (re_with_leading_or.empty()) if (re_with_leading_or.empty())
return ""; return "";
auto re = re_with_leading_or.substr(1); auto re = re_with_leading_or.substr(1);
 End of changes. 5 change blocks. 
6 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)