From e217a3a425ba72e8b6ce395e1ecd411fbe58e916 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 26 Feb 2019 11:59:38 +0100 Subject: pkgSrcRecords::Parser: Fold Files2() into Files() This is possible now with the API break. Cleaner code, woohoo. --- apt-private/private-source.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-private') diff --git a/apt-private/private-source.cc b/apt-private/private-source.cc index c8a48a74a..48c9d8094 100644 --- a/apt-private/private-source.cc +++ b/apt-private/private-source.cc @@ -383,14 +383,14 @@ bool DoSource(CommandLine &CmdL) } // Back track - std::vector Lst; - if (Last->Files2(Lst) == false) { + std::vector Lst; + if (Last->Files(Lst) == false) { return false; } DscFile curDsc; // Load them into the fetcher - for (std::vector::const_iterator I = Lst.begin(); + for (std::vector::const_iterator I = Lst.begin(); I != Lst.end(); ++I) { // Try to guess what sort of file it is we are getting. -- cgit v1.2.3-70-g09d2 From eba6aa6b49bf23d1ece40389b3d2959f5d125f50 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 26 Feb 2019 12:04:55 +0100 Subject: clean: Fold pkgArchiveCleaner2 into pkgArchiveCleaner --- apt-pkg/clean.cc | 19 +------------------ apt-pkg/clean.h | 16 ++++------------ apt-private/private-download.cc | 2 +- debian/libapt-pkg6.0.symbols | 2 -- 4 files changed, 6 insertions(+), 33 deletions(-) (limited to 'apt-private') diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index f335554a3..9dd56e609 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -43,17 +43,9 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache) if (FileExists(Dir) == false) return true; - auto const withoutChangingDir = dynamic_cast(this); int const dirfd = open(Dir.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC); if (dirfd == -1) return _error->Errno("open",_("Unable to read %s"),Dir.c_str()); - std::string CWD; - if (withoutChangingDir == nullptr) - { - CWD = SafeGetCWD(); - if (fchdir(dirfd) != 0) - return _error->Errno("fchdir",_("Unable to change to %s"),Dir.c_str()); - } DIR * const D = fdopendir(dirfd); if (D == nullptr) return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str()); @@ -131,18 +123,9 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache) continue; } - if (withoutChangingDir == nullptr) - { - APT_IGNORE_DEPRECATED_PUSH - Erase(Dir->d_name, Pkg, Ver, St); - APT_IGNORE_DEPRECATED_POP - } - else - withoutChangingDir->Erase(dirfd, Dir->d_name, Pkg, Ver, St); + Erase(dirfd, Dir->d_name, Pkg, Ver, St); } closedir(D); - if (withoutChangingDir == nullptr && chdir(CWD.c_str()) != 0) - return _error->Errno("chdir", _("Unable to change to %s"),Dir.c_str()); return true; } /*}}}*/ diff --git a/apt-pkg/clean.h b/apt-pkg/clean.h index d6490a0c5..a64e6a935 100644 --- a/apt-pkg/clean.h +++ b/apt-pkg/clean.h @@ -25,8 +25,9 @@ class pkgArchiveCleaner void * const d; protected: - - APT_DEPRECATED_MSG("Use pkgArchiveCleaner2 to avoid CWD expectations and chdir") virtual void Erase(const char * /*File*/,std::string /*Pkg*/,std::string /*Ver*/,struct stat & /*St*/) {}; + virtual void Erase(int const dirfd, char const * const File, + std::string const &Pkg,std::string const &Ver, + struct stat const &St) = 0; public: @@ -35,15 +36,6 @@ class pkgArchiveCleaner pkgArchiveCleaner(); virtual ~pkgArchiveCleaner(); }; -// TODO: merge classes and "erase" the old way -class pkgArchiveCleaner2: public pkgArchiveCleaner -{ - friend class pkgArchiveCleaner; -protected: - using pkgArchiveCleaner::Erase; - virtual void Erase(int const dirfd, char const * const File, - std::string const &Pkg,std::string const &Ver, - struct stat const &St) = 0; -}; + #endif diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc index 2c12676ea..16d11255b 100644 --- a/apt-private/private-download.cc +++ b/apt-private/private-download.cc @@ -339,7 +339,7 @@ bool DoClean(CommandLine &) // --------------------------------------------------------------------- /* This is similar to clean but it only purges things that cannot be downloaded, that is old versions of cached packages. */ - class LogCleaner : public pkgArchiveCleaner2 + class LogCleaner : public pkgArchiveCleaner { protected: virtual void Erase(int const dirfd, char const * const File, std::string const &Pkg, std::string const &Ver,struct stat const &St) APT_OVERRIDE diff --git a/debian/libapt-pkg6.0.symbols b/debian/libapt-pkg6.0.symbols index ee7bd1401..dcb29981b 100644 --- a/debian/libapt-pkg6.0.symbols +++ b/debian/libapt-pkg6.0.symbols @@ -1498,9 +1498,7 @@ libapt-pkg.so.6.0 libapt-pkg6.0 #MINVER# (c++)"pkgAcquireStatus::ReleaseInfoChanges(metaIndex const*, metaIndex const*, std::vector >&&)@APTPKG_6.0" 1.5~beta2~ (c++)"RemoveFileAt(char const*, int, std::__cxx11::basic_string, std::allocator > const&)@APTPKG_6.0" 1.5~beta2~ (c++)"typeinfo for pkgAcquireStatus2@APTPKG_6.0" 1.5~beta2~ - (c++)"typeinfo for pkgArchiveCleaner2@APTPKG_6.0" 1.5~beta2~ (c++)"typeinfo name for pkgAcquireStatus2@APTPKG_6.0" 1.5~beta2~ - (c++)"typeinfo name for pkgArchiveCleaner2@APTPKG_6.0" 1.5~beta2~ (c++|optional=std)"void std::vector >::emplace_back(pkgAcquireStatus::ReleaseInfoChange&&)@APTPKG_6.0" 1.5~beta2~ (c++)"vtable for pkgAcquireStatus2@APTPKG_6.0" 1.5~beta2~ (c++)"pkgAcqMethod::FetchItem::Proxy[abi:cxx11]()@APTPKG_6.0" 1.6~alpha1~ -- cgit v1.2.3-70-g09d2 From 91e1f7d49830289d8e9d3fdd7ebbe7544a9838b8 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 26 Feb 2019 12:42:42 +0100 Subject: acquire: Fold pkgAcquireStatus2 into pkgAcquireStatus Clean up the code, make it neat, lalala --- apt-pkg/acquire.cc | 11 ++--------- apt-pkg/acquire.h | 14 +------------- apt-private/acqprogress.cc | 6 +++--- apt-private/acqprogress.h | 2 +- debian/libapt-pkg6.0.symbols | 6 ------ 5 files changed, 7 insertions(+), 32 deletions(-) (limited to 'apt-private') diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 541785b03..fc256b39e 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -1444,9 +1444,8 @@ void pkgAcquireStatus::Fetched(unsigned long long Size,unsigned long long Resume /*}}}*/ bool pkgAcquireStatus::ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector &&Changes)/*{{{*/ { - auto const virt = dynamic_cast(this); - if (virt != nullptr) - return virt->ReleaseInfoChanges(LastRelease, CurrentRelease, std::move(Changes)); + (void) LastRelease; + (void) CurrentRelease; return ReleaseInfoChangesAsGlobalErrors(std::move(Changes)); } /*}}}*/ @@ -1464,12 +1463,6 @@ bool pkgAcquireStatus::ReleaseInfoChangesAsGlobalErrors(std::vector &&Changes) -{ - return ReleaseInfoChangesAsGlobalErrors(std::move(Changes)); -} -pkgAcquireStatus2::pkgAcquireStatus2() : pkgAcquireStatus() {} -pkgAcquireStatus2::~pkgAcquireStatus2() {} pkgAcquire::UriIterator::UriIterator(pkgAcquire::Queue *Q) : d(NULL), CurQ(Q), CurItem(0) diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 1cf4da5bf..0b7b34d54 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -819,17 +819,13 @@ class pkgAcquireStatus * success it will print for each change the message attached to it via GlobalError either as an * error (if DefaultAction == false) or as a notice otherwise. * - * \b Note: To keep ABI compatibility for now this method isn't marked as - * virtual, but you can derive your class from #pkgAcquireStatus2 which has it - * marked as virtual. TODO on next ABI break: merge both classes. - * * @param LastRelease can be used to extract further information from the previous Release file * @param CurrentRelease can be used to extract further information from the current Release file * @param Changes is an array of changes alongside explanatory messages * which should be presented in some way to the user. * @return \b true if all changes are accepted by user, otherwise or if user can't be asked \b false */ - bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector &&Changes); + virtual bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector &&Changes); APT_HIDDEN static bool ReleaseInfoChangesAsGlobalErrors(std::vector &&Changes); /** \brief Invoked when an item is confirmed to be up-to-date. @@ -871,14 +867,6 @@ class pkgAcquireStatus /** \brief Initialize all counters to 0 and the time to the current time. */ pkgAcquireStatus(); virtual ~pkgAcquireStatus(); -}; -class pkgAcquireStatus2: public pkgAcquireStatus -{ -public: - virtual bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector &&Changes); - - pkgAcquireStatus2(); - virtual ~pkgAcquireStatus2(); }; /*}}}*/ /** @} */ diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc index a788ec98b..6cf200f5b 100644 --- a/apt-private/acqprogress.cc +++ b/apt-private/acqprogress.cc @@ -33,7 +33,7 @@ // --------------------------------------------------------------------- /* */ AcqTextStatus::AcqTextStatus(std::ostream &out, unsigned int &ScreenWidth,unsigned int const Quiet) : - pkgAcquireStatus2(), out(out), ScreenWidth(ScreenWidth), LastLineLength(0), ID(0), Quiet(Quiet) + pkgAcquireStatus(), out(out), ScreenWidth(ScreenWidth), LastLineLength(0), ID(0), Quiet(Quiet) { // testcases use it to disable pulses without disabling other user messages if (Quiet == 0 && _config->FindB("quiet::NoUpdate", false) == true) @@ -335,10 +335,10 @@ bool AcqTextStatus::ReleaseInfoChanges(metaIndex const * const L, metaIndex cons { if (Quiet >= 2 || isatty(STDOUT_FILENO) != 1 || isatty(STDIN_FILENO) != 1 || _config->FindB("APT::Get::Update::InteractiveReleaseInfoChanges", false) == false) - return pkgAcquireStatus2::ReleaseInfoChanges(nullptr, nullptr, std::move(Changes)); + return pkgAcquireStatus::ReleaseInfoChanges(nullptr, nullptr, std::move(Changes)); _error->PushToStack(); - auto const confirmed = pkgAcquireStatus2::ReleaseInfoChanges(L, N, std::move(Changes)); + auto const confirmed = pkgAcquireStatus::ReleaseInfoChanges(L, N, std::move(Changes)); if (confirmed == true) { _error->MergeWithStack(); diff --git a/apt-private/acqprogress.h b/apt-private/acqprogress.h index c8c211689..87b957e4b 100644 --- a/apt-private/acqprogress.h +++ b/apt-private/acqprogress.h @@ -15,7 +15,7 @@ #include #include -class APT_PUBLIC AcqTextStatus : public pkgAcquireStatus2 +class APT_PUBLIC AcqTextStatus : public pkgAcquireStatus { std::ostream &out; unsigned int &ScreenWidth; diff --git a/debian/libapt-pkg6.0.symbols b/debian/libapt-pkg6.0.symbols index a483f317e..f2107e24e 100644 --- a/debian/libapt-pkg6.0.symbols +++ b/debian/libapt-pkg6.0.symbols @@ -1484,15 +1484,9 @@ libapt-pkg.so.6.0 libapt-pkg6.0 #MINVER# (c++)"metaIndex::GetReleaseNotes[abi:cxx11]() const@APTPKG_6.0" 1.5~beta2~ (c++)"metaIndex::GetVersion[abi:cxx11]() const@APTPKG_6.0" 1.5~beta2~ (c++)"metaIndex::HasSupportForComponent(std::__cxx11::basic_string, std::allocator > const&) const@APTPKG_6.0" 1.5~beta2~ - (c++)"pkgAcquireStatus2::~pkgAcquireStatus2()@APTPKG_6.0" 1.5~beta2~ - (c++)"pkgAcquireStatus2::pkgAcquireStatus2()@APTPKG_6.0" 1.5~beta2~ - (c++)"pkgAcquireStatus2::ReleaseInfoChanges(metaIndex const*, metaIndex const*, std::vector >&&)@APTPKG_6.0" 1.5~beta2~ (c++)"pkgAcquireStatus::ReleaseInfoChanges(metaIndex const*, metaIndex const*, std::vector >&&)@APTPKG_6.0" 1.5~beta2~ (c++)"RemoveFileAt(char const*, int, std::__cxx11::basic_string, std::allocator > const&)@APTPKG_6.0" 1.5~beta2~ - (c++)"typeinfo for pkgAcquireStatus2@APTPKG_6.0" 1.5~beta2~ - (c++)"typeinfo name for pkgAcquireStatus2@APTPKG_6.0" 1.5~beta2~ (c++|optional=std)"void std::vector >::emplace_back(pkgAcquireStatus::ReleaseInfoChange&&)@APTPKG_6.0" 1.5~beta2~ - (c++)"vtable for pkgAcquireStatus2@APTPKG_6.0" 1.5~beta2~ (c++)"pkgAcqMethod::FetchItem::Proxy[abi:cxx11]()@APTPKG_6.0" 1.6~alpha1~ (c++)"pkgSystem::IsLocked()@APTPKG_6.0" 1.7.0~alpha3~ (c++)"pkgSystem::LockInner()@APTPKG_6.0" 1.7.0~alpha3~ -- cgit v1.2.3-70-g09d2 From 29465ea9555a453ca733280955505de8bfcce935 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 26 Feb 2019 13:21:07 +0100 Subject: sptr: Remove deprecated smart pointer classes Please use the standard C++ variants instead. --- apt-pkg/contrib/fileutl.cc | 1 - apt-pkg/contrib/sptr.h | 74 ------------------------------------------ apt-private/private-install.cc | 1 - cmdline/apt-cache.cc | 1 - cmdline/apt-get.cc | 1 - 5 files changed, 78 deletions(-) delete mode 100644 apt-pkg/contrib/sptr.h (limited to 'apt-private') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 0c0cb05ea..860739f68 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/apt-pkg/contrib/sptr.h b/apt-pkg/contrib/sptr.h deleted file mode 100644 index 77806d94d..000000000 --- a/apt-pkg/contrib/sptr.h +++ /dev/null @@ -1,74 +0,0 @@ -// -*- mode: cpp; mode: fold -*- -// Description /*{{{*/ -/* ###################################################################### - - Trivial non-ref counted 'smart pointer' - - This is really only good to eliminate - { - delete Foo; - return; - } - - Blocks from functions. - - I think G++ has become good enough that doing this won't have much - code size implications. - - ##################################################################### */ - /*}}}*/ -#ifndef SMART_POINTER_H -#define SMART_POINTER_H -#include - -template -class APT_DEPRECATED_MSG("use std::unique_ptr instead") SPtr -{ - public: - T *Ptr; - - inline T *operator ->() {return Ptr;}; - inline T &operator *() {return *Ptr;}; - inline operator T *() {return Ptr;}; - inline operator void *() {return Ptr;}; - inline T *UnGuard() {T *Tmp = Ptr; Ptr = 0; return Tmp;}; - inline void operator =(T *N) {Ptr = N;}; - inline bool operator ==(T *lhs) const {return Ptr == lhs;}; - inline bool operator !=(T *lhs) const {return Ptr != lhs;}; - inline T*Get() {return Ptr;}; - - inline SPtr(T *Ptr) : Ptr(Ptr) {}; - inline SPtr() : Ptr(0) {}; - inline ~SPtr() {delete Ptr;}; -}; - -template -class APT_DEPRECATED_MSG("use std::unique_ptr instead") SPtrArray -{ - public: - T *Ptr; - - //inline T &operator *() {return *Ptr;}; - inline operator T *() {return Ptr;}; - inline operator void *() {return Ptr;}; - inline T *UnGuard() {T *Tmp = Ptr; Ptr = 0; return Tmp;}; - //inline T &operator [](signed long I) {return Ptr[I];}; - inline void operator =(T *N) {Ptr = N;}; - inline bool operator ==(T *lhs) const {return Ptr == lhs;}; - inline bool operator !=(T *lhs) const {return Ptr != lhs;}; - inline T *Get() {return Ptr;}; - - inline SPtrArray(T *Ptr) : Ptr(Ptr) {}; - inline SPtrArray() : Ptr(0) {}; -#if __GNUC__ >= 4 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations" - // gcc warns about this, but we can do nothing here… -#endif - inline ~SPtrArray() {delete [] Ptr;}; -#if __GNUC__ >= 4 - #pragma GCC diagnostic pop -#endif -}; - -#endif diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 40543d995..a5a88c99d 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -18,7 +18,6 @@ #include #include #include -#include #include #include diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 3c0e477b1..ce7400fc7 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index da18d2d19..fe6e22d81 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3-70-g09d2 From 476d999847adf35ec35fd9c9b9233ac8b8aa1a17 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 26 Feb 2019 13:54:32 +0100 Subject: apt-private: Remove unused InitLocale() variant --- apt-private/private-main.cc | 1 - apt-private/private-main.h | 1 - 2 files changed, 2 deletions(-) (limited to 'apt-private') diff --git a/apt-private/private-main.cc b/apt-private/private-main.cc index 47b1a0921..e9f65bd83 100644 --- a/apt-private/private-main.cc +++ b/apt-private/private-main.cc @@ -44,7 +44,6 @@ void InitLocale(APT_CMD const binary) /*{{{*/ break; } } -void InitLocale() {} /*}}}*/ void InitSignals() /*{{{*/ { diff --git a/apt-private/private-main.h b/apt-private/private-main.h index 0d60797ed..4dcb2716a 100644 --- a/apt-private/private-main.h +++ b/apt-private/private-main.h @@ -8,7 +8,6 @@ class CommandLine; void InitLocale(APT_CMD const binary); -APT_PUBLIC APT_DEPRECATED_MSG("Is a no-op now") void InitLocale(); APT_PUBLIC void InitSignals(); APT_PUBLIC void CheckIfSimulateMode(CommandLine &CmdL); APT_PUBLIC void CheckIfCalledByScript(int argc, const char *argv[]); -- cgit v1.2.3-70-g09d2