]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/orderlist.cc
Support tabs in sources.list files
[apt.git] / apt-pkg / orderlist.cc
index 86d2a94786ddeaff02d9ca0502fd954d24264f03..1e0640422533633b6d262bc34463df2bc5c01d39 100644 (file)
 #include <apt-pkg/orderlist.h>
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/orderlist.h>
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/error.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/sptr.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcache.h>
 
 
+#include <stdlib.h>
+#include <string.h>
 #include <iostream>
                                                                        /*}}}*/
 
 #include <iostream>
                                                                        /*}}}*/
 
@@ -82,7 +84,7 @@ pkgOrderList *pkgOrderList::Me = 0;
 // OrderList::pkgOrderList - Constructor                               /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 // OrderList::pkgOrderList - Constructor                               /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-pkgOrderList::pkgOrderList(pkgDepCache *pCache) : Cache(*pCache),
+pkgOrderList::pkgOrderList(pkgDepCache *pCache) : d(NULL), Cache(*pCache),
                                                  Primary(NULL), Secondary(NULL),
                                                  RevDepends(NULL), Remove(NULL),
                                                  AfterEnd(NULL), FileList(NULL),
                                                  Primary(NULL), Secondary(NULL),
                                                  RevDepends(NULL), Remove(NULL),
                                                  AfterEnd(NULL), FileList(NULL),
@@ -138,9 +140,9 @@ bool pkgOrderList::DoRun()
 {   
    // Temp list
    unsigned long Size = Cache.Head().PackageCount;
 {   
    // Temp list
    unsigned long Size = Cache.Head().PackageCount;
-   SPtrArray<Package *> NList = new Package *[Size];
-   SPtrArray<Package *> AfterList = new Package *[Size];
-   AfterEnd = AfterList;
+   std::unique_ptr<Package *[]> NList(new Package *[Size]);
+   std::unique_ptr<Package *[]> AfterList(new Package *[Size]);
+   AfterEnd = AfterList.get();
    
    Depth = 0;
    WipeFlags(Added | AddPending | Loop | InList);
    
    Depth = 0;
    WipeFlags(Added | AddPending | Loop | InList);
@@ -150,7 +152,7 @@ bool pkgOrderList::DoRun()
 
    // Rebuild the main list into the temp list.
    iterator OldEnd = End;
 
    // Rebuild the main list into the temp list.
    iterator OldEnd = End;
-   End = NList;
+   End = NList.get();
    for (iterator I = List; I != OldEnd; ++I)
       if (VisitNode(PkgIterator(Cache,*I), "DoRun") == false)
       {
    for (iterator I = List; I != OldEnd; ++I)
       if (VisitNode(PkgIterator(Cache,*I), "DoRun") == false)
       {
@@ -159,12 +161,12 @@ bool pkgOrderList::DoRun()
       }
    
    // Copy the after list to the end of the main list
       }
    
    // Copy the after list to the end of the main list
-   for (Package **I = AfterList; I != AfterEnd; I++)
+   for (Package **I = AfterList.get(); I != AfterEnd; I++)
       *End++ = *I;
    
    // Swap the main list to the new list
    delete [] List;
       *End++ = *I;
    
    // Swap the main list to the new list
    delete [] List;
-   List = NList.UnGuard();
+   List = NList.release();
    return true;
 }
                                                                        /*}}}*/
    return true;
 }
                                                                        /*}}}*/
@@ -301,9 +303,8 @@ bool pkgOrderList::OrderConfigure()
 /* Higher scores order earlier */
 int pkgOrderList::Score(PkgIterator Pkg)
 {
 /* Higher scores order earlier */
 int pkgOrderList::Score(PkgIterator Pkg)
 {
-   static int const ScoreDelete = _config->FindI("OrderList::Score::Delete", 500);
-
-   // Removal is always done first
+   // Removals should be done after we dealt with essentials
+   static int const ScoreDelete = _config->FindI("OrderList::Score::Delete", 100);
    if (Cache[Pkg].Delete() == true)
       return ScoreDelete;
 
    if (Cache[Pkg].Delete() == true)
       return ScoreDelete;
 
@@ -509,8 +510,8 @@ bool pkgOrderList::VisitRProvides(DepFunc F,VerIterator Ver)
    against it! */
 bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
 {
    against it! */
 bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
 {
-   SPtrArray<Version *> List = D.AllTargets();
-   for (Version **I = List; *I != 0; ++I)
+   std::unique_ptr<Version *[]> List(D.AllTargets());
+   for (Version **I = List.get(); *I != 0; ++I)
    {
       VerIterator Ver(Cache,*I);
       PkgIterator Pkg = Ver.ParentPkg();
    {
       VerIterator Ver(Cache,*I);
       PkgIterator Pkg = Ver.ParentPkg();
@@ -538,7 +539,7 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
    }
    if (D.IsNegative() == false)
       return true;
    }
    if (D.IsNegative() == false)
       return true;
-   for (Version **I = List; *I != 0; ++I)
+   for (Version **I = List.get(); *I != 0; ++I)
    {
       VerIterator Ver(Cache,*I);
       PkgIterator Pkg = Ver.ParentPkg();
    {
       VerIterator Ver(Cache,*I);
       PkgIterator Pkg = Ver.ParentPkg();
@@ -567,10 +568,10 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
 // ---------------------------------------------------------------------
 /* This is the core ordering routine. It calls the set dependency
    consideration functions which then potentialy call this again. Finite
 // ---------------------------------------------------------------------
 /* This is the core ordering routine. It calls the set dependency
    consideration functions which then potentialy call this again. Finite
-   depth is achived through the colouring mechinism. */
+   depth is achieved through the colouring mechinism. */
 bool pkgOrderList::VisitNode(PkgIterator Pkg, char const* from)
 {
 bool pkgOrderList::VisitNode(PkgIterator Pkg, char const* from)
 {
-   // Looping or irrelevent.
+   // Looping or irrelevant.
    // This should probably trancend not installed packages
    if (Pkg.end() == true || IsFlag(Pkg,Added) == true || 
        IsFlag(Pkg,AddPending) == true || IsFlag(Pkg,InList) == false)
    // This should probably trancend not installed packages
    if (Pkg.end() == true || IsFlag(Pkg,Added) == true || 
        IsFlag(Pkg,AddPending) == true || IsFlag(Pkg,InList) == false)
@@ -825,7 +826,7 @@ bool pkgOrderList::DepUnPackPre(DepIterator D)
    The forwards depends loop is designed to bring the packages dependents
    close to the package. This helps reduce deconfigure time. 
    
    The forwards depends loop is designed to bring the packages dependents
    close to the package. This helps reduce deconfigure time. 
    
-   Loops are irrelevent to this. */
+   Loops are irrelevant to this. */
 bool pkgOrderList::DepUnPackDep(DepIterator D)
 {
    
 bool pkgOrderList::DepUnPackDep(DepIterator D)
 {
    
@@ -841,7 +842,7 @@ bool pkgOrderList::DepUnPackDep(DepIterator D)
                D.ParentPkg().CurrentVer() != D.ParentVer())
               continue;
 
                D.ParentPkg().CurrentVer() != D.ParentVer())
               continue;
 
-           // The dep will not break so it is irrelevent.
+           // The dep will not break so it is irrelevant.
            if (CheckDep(D) == true)
               continue;
            
            if (CheckDep(D) == true)
               continue;
            
@@ -1072,9 +1073,9 @@ void pkgOrderList::WipeFlags(unsigned long F)
    this fails to produce a suitable result. */
 bool pkgOrderList::CheckDep(DepIterator D)
 {
    this fails to produce a suitable result. */
 bool pkgOrderList::CheckDep(DepIterator D)
 {
-   SPtrArray<Version *> List = D.AllTargets();
+   std::unique_ptr<Version *[]> List(D.AllTargets());
    bool Hit = false;
    bool Hit = false;
-   for (Version **I = List; *I != 0; I++)
+   for (Version **I = List.get(); *I != 0; I++)
    {
       VerIterator Ver(Cache,*I);
       PkgIterator Pkg = Ver.ParentPkg();
    {
       VerIterator Ver(Cache,*I);
       PkgIterator Pkg = Ver.ParentPkg();