]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-sortpkgs.cc
fix off-by-one error and do not use magic constant of 100 when checking StackPost
[apt.git] / cmdline / apt-sortpkgs.cc
index 7b2a74aed2b0f38133734df88ec4fd88d3fe4b13..46989044e6cb49088fbd745afbfda24c15972439 100644 (file)
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include <config.h>
+
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/init.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/init.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/pkgsystem.h>
 
 
-#include <config.h>
-#include <apti18n.h>
-    
 #include <vector>
 #include <algorithm>
 
 #include <locale.h>
 #include <unistd.h>
 #include <vector>
 #include <algorithm>
 
 #include <locale.h>
 #include <unistd.h>
+
+#include <apti18n.h>
                                                                        /*}}}*/
 
 using namespace std;
 
                                                                        /*}}}*/
 
 using namespace std;
 
-struct PkgName
+struct PkgName                                                         /*{{{*/
 {
    string Name;
    string Ver;
 {
    string Name;
    string Ver;
@@ -55,7 +58,7 @@ struct PkgName
    bool operator >(const PkgName &x) const {return Compare3(x) > 0;};
    bool operator ==(const PkgName &x) const {return Compare3(x) == 0;};
 };
    bool operator >(const PkgName &x) const {return Compare3(x) > 0;};
    bool operator ==(const PkgName &x) const {return Compare3(x) == 0;};
 };
-
+                                                                       /*}}}*/
 // DoIt - Sort a single file                                           /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 // DoIt - Sort a single file                                           /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -106,7 +109,7 @@ bool DoIt(string InFile)
    
    // Emit
    unsigned char *Buffer = new unsigned char[Largest+1];
    
    // Emit
    unsigned char *Buffer = new unsigned char[Largest+1];
-   for (vector<PkgName>::iterator I = List.begin(); I != List.end(); I++)
+   for (vector<PkgName>::iterator I = List.begin(); I != List.end(); ++I)
    {
       // Read in the Record.
       if (Fd.Seek(I->Offset) == false || Fd.Read(Buffer,I->Length) == false)
    {
       // Read in the Record.
       if (Fd.Seek(I->Offset) == false || Fd.Read(Buffer,I->Length) == false)
@@ -141,7 +144,7 @@ bool DoIt(string InFile)
 /* */
 int ShowHelp()
 {
 /* */
 int ShowHelp()
 {
-   ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,VERSION,
+   ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
            COMMON_ARCH,__DATE__,__TIME__);
    if (_config->FindB("version") == true)
       return 0;
            COMMON_ARCH,__DATE__,__TIME__);
    if (_config->FindB("version") == true)
       return 0;
@@ -161,8 +164,7 @@ int ShowHelp()
    return 0;
 }
                                                                        /*}}}*/
    return 0;
 }
                                                                        /*}}}*/
-
-int main(int argc,const char *argv[])
+int main(int argc,const char *argv[])                                  /*{{{*/
 {
    CommandLine::Args Args[] = {
       {'h',"help","help",0},
 {
    CommandLine::Args Args[] = {
       {'h',"help","help",0},
@@ -206,3 +208,4 @@ int main(int argc,const char *argv[])
    
    return 0;   
 }
    
    return 0;   
 }
+                                                                       /*}}}*/