fix typo (mkostemp->mkstemp)
[ntk/apt.git] / ftparchive / override.cc
index b8b9484..1288ff1 100644 (file)
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "override.h"
-#endif
+#include <config.h>
 
-#include "override.h"
-    
-#include <apti18n.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/error.h>
 
 #include <stdio.h>
-    
+
 #include "override.h"
+
+#include <apti18n.h>
                                                                        /*}}}*/
 
 // Override::ReadOverride - Read the override file                     /*{{{*/
 // ---------------------------------------------------------------------
 /* This parses the override file and reads it into the map */
-bool Override::ReadOverride(string File,bool Source)
+bool Override::ReadOverride(string const &File,bool const &Source)
 {
    if (File.empty() == true)
       return true;
@@ -38,7 +35,7 @@ bool Override::ReadOverride(string File,bool Source)
       return _error->Errno("fopen",_("Unable to open %s"),File.c_str());
    
    char Line[500];
-   unsigned long Counter = 0;
+   unsigned long long Counter = 0;
    while (fgets(Line,sizeof(Line),F) != 0)
    {
       Counter++;
@@ -52,7 +49,7 @@ bool Override::ReadOverride(string File,bool Source)
       // Strip space leading up to the package name, skip blank lines
       char *Pkg = Line;
       for (; isspace(*Pkg) && *Pkg != 0;Pkg++);
-      if (Pkg == 0)
+      if (*Pkg == 0)
         continue;
 
       // Find the package and zero..
@@ -61,7 +58,7 @@ bool Override::ReadOverride(string File,bool Source)
       for (; isspace(*End) == 0 && *End != 0; End++);
       if (*End == 0)
       {
-        _error->Warning(_("Malformed override %s line %lu #1"),File.c_str(),
+        _error->Warning(_("Malformed override %s line %llu #1"),File.c_str(),
                         Counter);
         continue;
       }      
@@ -75,7 +72,7 @@ bool Override::ReadOverride(string File,bool Source)
         for (; isspace(*End) == 0 && *End != 0; End++);
         if (*End == 0)
         {
-           _error->Warning(_("Malformed override %s line %lu #2"),File.c_str(),
+           _error->Warning(_("Malformed override %s line %llu #2"),File.c_str(),
                            Counter);
            continue;
         }
@@ -89,7 +86,7 @@ bool Override::ReadOverride(string File,bool Source)
       for (; isspace(*End) == 0 && *End != 0; End++);
       if (*End == 0)
       {
-        _error->Warning(_("Malformed override %s line %lu #3"),File.c_str(),
+        _error->Warning(_("Malformed override %s line %llu #3"),File.c_str(),
                         Counter);
         continue;
       }      
@@ -136,7 +133,7 @@ bool Override::ReadOverride(string File,bool Source)
 // Override::ReadExtraOverride - Read the extra override file          /*{{{*/
 // ---------------------------------------------------------------------
 /* This parses the extra override file and reads it into the map */
-bool Override::ReadExtraOverride(string File,bool Source)
+bool Override::ReadExtraOverride(string const &File,bool const &Source)
 {
    if (File.empty() == true)
       return true;
@@ -146,7 +143,7 @@ bool Override::ReadExtraOverride(string File,bool Source)
       return _error->Errno("fopen",_("Unable to open %s"),File.c_str());
   
    char Line[500];
-   unsigned long Counter = 0;
+   unsigned long long Counter = 0;
    while (fgets(Line,sizeof(Line),F) != 0)
    {
       Counter++;
@@ -167,7 +164,7 @@ bool Override::ReadExtraOverride(string File,bool Source)
       for (; isspace(*End) == 0 && *End != 0; End++);
       if (*End == 0)
       {
-        _error->Warning(_("Malformed override %s line %lu #1"),File.c_str(),
+        _error->Warning(_("Malformed override %s line %llu #1"),File.c_str(),
                         Counter);
         continue;
       }      
@@ -179,7 +176,7 @@ bool Override::ReadExtraOverride(string File,bool Source)
       for (; isspace(*End) == 0 && *End != 0; End++);
       if (*End == 0)
       {
-        _error->Warning(_("Malformed override %s line %lu #2"),File.c_str(),
+        _error->Warning(_("Malformed override %s line %llu #2"),File.c_str(),
                         Counter);
         continue;
       }
@@ -192,7 +189,7 @@ bool Override::ReadExtraOverride(string File,bool Source)
       for (; isspace(*(End-1)) && End > Value; End--);
       if (End == Value)
       {
-        _error->Warning(_("Malformed override %s line %lu #3"),File.c_str(),
+        _error->Warning(_("Malformed override %s line %llu #3"),File.c_str(),
                         Counter);
         continue;
       }      
@@ -213,9 +210,9 @@ bool Override::ReadExtraOverride(string File,bool Source)
 /* Returns a override item for the given package and the given architecture.
  * Treats "all" special
  */
-Override::Item* Override::GetItem(string Package, string Architecture)
+Override::Item* Override::GetItem(string const &Package, string const &Architecture)
 {
-   map<string,Item>::iterator I = Mapping.find(Package);
+   map<string,Item>::const_iterator I = Mapping.find(Package);
    map<string,Item>::iterator J = Mapping.find(Package + "/" + Architecture);
 
    if (I == Mapping.end() && J == Mapping.end())
@@ -234,8 +231,8 @@ Override::Item* Override::GetItem(string Package, string Architecture)
         if (R->Priority != "") result->Priority = R->Priority;
         if (R->OldMaint != "") result->OldMaint = R->OldMaint;
         if (R->NewMaint != "") result->NewMaint = R->NewMaint;
-        for (map<string,string>::iterator foI = R->FieldOverride.begin();
-             foI != R->FieldOverride.end(); foI++)
+        for (map<string,string>::const_iterator foI = R->FieldOverride.begin();
+             foI != R->FieldOverride.end(); ++foI)
          {
            result->FieldOverride[foI->first] = foI->second;
         }
@@ -251,7 +248,7 @@ Override::Item* Override::GetItem(string Package, string Architecture)
    there is a rule but it does not match then the empty string is returned,
    also if there was no rewrite rule the empty string is returned. Failed
    indicates if there was some kind of problem while rewriting. */
-string Override::Item::SwapMaint(string Orig,bool &Failed)
+string Override::Item::SwapMaint(string const &Orig,bool &Failed)
 {
    Failed = false;
    
@@ -266,13 +263,13 @@ string Override::Item::SwapMaint(string Orig,bool &Failed)
       override file. Thus it persists.*/
 #if 1
    // Break OldMaint up into little bits on double slash boundaries.
-   string::iterator End = OldMaint.begin();
+   string::const_iterator End = OldMaint.begin();
    while (1)
    {
-      string::iterator Start = End;      
+      string::const_iterator Start = End;      
       for (; End < OldMaint.end() &&
           (End + 3 >= OldMaint.end() || End[0] != ' ' || 
-           End[1] != '/' || End[2] != '/'); End++);
+           End[1] != '/' || End[2] != '/'); ++End);
       if (stringcasecmp(Start,End,Orig.begin(),Orig.end()) == 0)
         return NewMaint;
       
@@ -280,7 +277,7 @@ string Override::Item::SwapMaint(string Orig,bool &Failed)
         break;
 
       // Skip the divider and white space
-      for (; End < OldMaint.end() && (*End == '/' || *End == ' '); End++);
+      for (; End < OldMaint.end() && (*End == '/' || *End == ' '); ++End);
    }
 #else
    if (stringcasecmp(OldMaint.begin(),OldMaint.end(),Orig.begin(),Orig.end()) == 0)