瀏覽代碼

tell every method in ftparchive/ that const& is sexy

David Kalnischkies 16 年之前
父節點
當前提交
9209ec4701

+ 9 - 9
ftparchive/cachedb.cc

@@ -26,7 +26,7 @@
 // CacheDB::ReadyDB - Ready the DB2					/*{{{*/
 // CacheDB::ReadyDB - Ready the DB2					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This opens the DB2 file for caching package information */
 /* This opens the DB2 file for caching package information */
-bool CacheDB::ReadyDB(string DB)
+bool CacheDB::ReadyDB(string const &DB)
 {
 {
    int err;
    int err;
 
 
@@ -160,9 +160,9 @@ bool CacheDB::GetCurStat()
 									/*}}}*/
 									/*}}}*/
 // CacheDB::GetFileInfo - Get all the info about the file		/*{{{*/
 // CacheDB::GetFileInfo - Get all the info about the file		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
-bool CacheDB::GetFileInfo(string FileName, bool DoControl, bool DoContents,
-				bool GenContentsOnly, 
-				bool DoMD5, bool DoSHA1, bool DoSHA256, bool const &checkMtime)
+bool CacheDB::GetFileInfo(string const &FileName, bool const &DoControl, bool const &DoContents,
+				bool const &GenContentsOnly, bool const &DoMD5, bool const &DoSHA1,
+				bool const &DoSHA256, bool const &checkMtime)
 {
 {
 	this->FileName = FileName;
 	this->FileName = FileName;
 
 
@@ -251,7 +251,7 @@ bool CacheDB::LoadControl()
 // CacheDB::LoadContents - Load the File Listing			/*{{{*/
 // CacheDB::LoadContents - Load the File Listing			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool CacheDB::LoadContents(bool GenOnly)
+bool CacheDB::LoadContents(bool const &GenOnly)
 {
 {
    // Try to read the control information out of the DB.
    // Try to read the control information out of the DB.
    if ((CurStat.Flags & FlContents) == FlContents)
    if ((CurStat.Flags & FlContents) == FlContents)
@@ -301,7 +301,7 @@ static string bytes2hex(uint8_t *bytes, size_t length) {
    return string(space);
    return string(space);
 }
 }
 
 
-static inline unsigned char xdig2num(char dig) {
+static inline unsigned char xdig2num(char const &dig) {
    if (isdigit(dig)) return dig - '0';
    if (isdigit(dig)) return dig - '0';
    if ('a' <= dig && dig <= 'f') return dig - 'a' + 10;
    if ('a' <= dig && dig <= 'f') return dig - 'a' + 10;
    if ('A' <= dig && dig <= 'F') return dig - 'A' + 10;
    if ('A' <= dig && dig <= 'F') return dig - 'A' + 10;
@@ -322,7 +322,7 @@ static void hex2bytes(uint8_t *bytes, const char *hex, int length) {
 // CacheDB::GetMD5 - Get the MD5 hash					/*{{{*/
 // CacheDB::GetMD5 - Get the MD5 hash					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool CacheDB::GetMD5(bool GenOnly)
+bool CacheDB::GetMD5(bool const &GenOnly)
 {
 {
    // Try to read the control information out of the DB.
    // Try to read the control information out of the DB.
    if ((CurStat.Flags & FlMD5) == FlMD5)
    if ((CurStat.Flags & FlMD5) == FlMD5)
@@ -353,7 +353,7 @@ bool CacheDB::GetMD5(bool GenOnly)
 // CacheDB::GetSHA1 - Get the SHA1 hash					/*{{{*/
 // CacheDB::GetSHA1 - Get the SHA1 hash					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool CacheDB::GetSHA1(bool GenOnly)
+bool CacheDB::GetSHA1(bool const &GenOnly)
 {
 {
    // Try to read the control information out of the DB.
    // Try to read the control information out of the DB.
    if ((CurStat.Flags & FlSHA1) == FlSHA1)
    if ((CurStat.Flags & FlSHA1) == FlSHA1)
@@ -384,7 +384,7 @@ bool CacheDB::GetSHA1(bool GenOnly)
 // CacheDB::GetSHA256 - Get the SHA256 hash				/*{{{*/
 // CacheDB::GetSHA256 - Get the SHA256 hash				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool CacheDB::GetSHA256(bool GenOnly)
+bool CacheDB::GetSHA256(bool const &GenOnly)
 {
 {
    // Try to read the control information out of the DB.
    // Try to read the control information out of the DB.
    if ((CurStat.Flags & FlSHA256) == FlSHA256)
    if ((CurStat.Flags & FlSHA256) == FlSHA256)

+ 10 - 10
ftparchive/cachedb.h

@@ -49,7 +49,7 @@ class CacheDB
    {
    {
       return Dbp->get(Dbp,0,&Key,&Data,0) == 0;
       return Dbp->get(Dbp,0,&Key,&Data,0) == 0;
    };
    };
-   inline bool Put(const void *In,unsigned long Length) 
+   inline bool Put(const void *In,unsigned long const &Length) 
    {
    {
       if (ReadOnly == true)
       if (ReadOnly == true)
 	 return true;
 	 return true;
@@ -66,10 +66,10 @@ class CacheDB
    bool GetFileStat(bool const &doStat = false);
    bool GetFileStat(bool const &doStat = false);
    bool GetCurStat();
    bool GetCurStat();
    bool LoadControl();
    bool LoadControl();
-   bool LoadContents(bool GenOnly);
-   bool GetMD5(bool GenOnly);
-   bool GetSHA1(bool GenOnly);
-   bool GetSHA256(bool GenOnly);
+   bool LoadContents(bool const &GenOnly);
+   bool GetMD5(bool const &GenOnly);
+   bool GetSHA1(bool const &GenOnly);
+   bool GetSHA256(bool const &GenOnly);
    
    
    // Stat info stored in the DB, Fixed types since it is written to disk.
    // Stat info stored in the DB, Fixed types since it is written to disk.
    enum FlagList {FlControl = (1<<0),FlMD5=(1<<1),FlContents=(1<<2),
    enum FlagList {FlControl = (1<<0),FlMD5=(1<<1),FlContents=(1<<2),
@@ -117,20 +117,20 @@ class CacheDB
       Stats() : Bytes(0), MD5Bytes(0), SHA1Bytes(0), SHA256Bytes(0), Packages(0), Misses(0), DeLinkBytes(0) {};
       Stats() : Bytes(0), MD5Bytes(0), SHA1Bytes(0), SHA256Bytes(0), Packages(0), Misses(0), DeLinkBytes(0) {};
    } Stats;
    } Stats;
    
    
-   bool ReadyDB(string DB);
+   bool ReadyDB(string const &DB);
    inline bool DBFailed() {return Dbp != 0 && DBLoaded == false;};
    inline bool DBFailed() {return Dbp != 0 && DBLoaded == false;};
    inline bool Loaded() {return DBLoaded == true;};
    inline bool Loaded() {return DBLoaded == true;};
    
    
    inline off_t GetFileSize(void) {return CurStat.FileSize;}
    inline off_t GetFileSize(void) {return CurStat.FileSize;}
    
    
-   bool SetFile(string FileName,struct stat St,FileFd *Fd);
-   bool GetFileInfo(string FileName, bool DoControl, bool DoContents,
-		   bool GenContentsOnly, bool DoMD5, bool DoSHA1, bool DoSHA256, bool const &checkMtime = false);
+   bool SetFile(string const &FileName,struct stat St,FileFd *Fd);
+   bool GetFileInfo(string const &FileName, bool const &DoControl, bool const &DoContents, bool const &GenContentsOnly,
+		    bool const &DoMD5, bool const &DoSHA1, bool const &DoSHA256, bool const &checkMtime = false);
    bool Finish();   
    bool Finish();   
    
    
    bool Clean();
    bool Clean();
    
    
-   CacheDB(string DB) : Dbp(0), Fd(NULL), DebFile(0) {ReadyDB(DB);};
+   CacheDB(string const &DB) : Dbp(0), Fd(NULL), DebFile(0) {ReadyDB(DB);};
    ~CacheDB() {ReadyDB(string()); delete DebFile;};
    ~CacheDB() {ReadyDB(string()); delete DebFile;};
 };
 };
     
     

+ 1 - 1
ftparchive/contents.cc

@@ -399,7 +399,7 @@ bool ContentsExtract::TakeContents(const void *NewData,unsigned long Length)
 // ContentsExtract::Add - Read the contents data into the sorter	/*{{{*/
 // ContentsExtract::Add - Read the contents data into the sorter	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-void ContentsExtract::Add(GenContents &Contents,string Package)
+void ContentsExtract::Add(GenContents &Contents,string const &Package)
 {
 {
    const char *Start = Data;
    const char *Start = Data;
    char *Pkg = Contents.Mystrdup(Package.c_str());
    char *Pkg = Contents.Mystrdup(Package.c_str());

+ 1 - 1
ftparchive/contents.h

@@ -80,7 +80,7 @@ class ContentsExtract : public pkgDirStream
    virtual bool DoItem(Item &Itm,int &Fd);      
    virtual bool DoItem(Item &Itm,int &Fd);      
    void Reset() {CurSize = 0;};
    void Reset() {CurSize = 0;};
    bool TakeContents(const void *Data,unsigned long Length);
    bool TakeContents(const void *Data,unsigned long Length);
-   void Add(GenContents &Contents,string Package);
+   void Add(GenContents &Contents,string const &Package);
    
    
    ContentsExtract() : Data(0), MaxSize(0), CurSize(0) {};
    ContentsExtract() : Data(0), MaxSize(0), CurSize(0) {};
    virtual ~ContentsExtract() {delete [] Data;};
    virtual ~ContentsExtract() {delete [] Data;};

+ 7 - 7
ftparchive/multicompress.cc

@@ -40,14 +40,14 @@ const MultiCompress::CompType MultiCompress::Compressors[] =
 // MultiCompress::MultiCompress - Constructor				/*{{{*/
 // MultiCompress::MultiCompress - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* Setup the file outputs, compression modes and fork the writer child */
 /* Setup the file outputs, compression modes and fork the writer child */
-MultiCompress::MultiCompress(string Output,string Compress,
-			     mode_t Permissions,bool Write)
+MultiCompress::MultiCompress(string const &Output,string const &Compress,
+			     mode_t const &Permissions,bool const &Write) :
+			Permissions(Permissions)
 {
 {
    Outputs = 0;
    Outputs = 0;
    Outputter = -1;
    Outputter = -1;
    Input = 0;
    Input = 0;
    UpdateMTime = 0;
    UpdateMTime = 0;
-   this->Permissions = Permissions;
    
    
    /* Parse the compression string, a space separated lists of compresison
    /* Parse the compression string, a space separated lists of compresison
       types */
       types */
@@ -126,7 +126,7 @@ MultiCompress::~MultiCompress()
 /* This checks each compressed file to make sure it exists and returns
 /* This checks each compressed file to make sure it exists and returns
    stat information for a random file from the collection. False means
    stat information for a random file from the collection. False means
    one or more of the files is missing. */
    one or more of the files is missing. */
-bool MultiCompress::GetStat(string Output,string Compress,struct stat &St)
+bool MultiCompress::GetStat(string const &Output,string const &Compress,struct stat &St)
 {
 {
    /* Parse the compression string, a space separated lists of compresison
    /* Parse the compression string, a space separated lists of compresison
       types */
       types */
@@ -268,8 +268,8 @@ bool MultiCompress::Finalize(unsigned long &OutSize)
 /* This opens the compressor, either in compress mode or decompress 
 /* This opens the compressor, either in compress mode or decompress 
    mode. FileFd is always the compressor input/output file, 
    mode. FileFd is always the compressor input/output file, 
    OutFd is the created pipe, Input for Compress, Output for Decompress. */
    OutFd is the created pipe, Input for Compress, Output for Decompress. */
-bool MultiCompress::OpenCompress(const CompType *Prog,pid_t &Pid,int FileFd,
-				 int &OutFd,bool Comp)
+bool MultiCompress::OpenCompress(const CompType *Prog,pid_t &Pid,int const &FileFd,
+				 int &OutFd,bool const &Comp)
 {
 {
    Pid = -1;
    Pid = -1;
    
    
@@ -369,7 +369,7 @@ bool MultiCompress::CloseOld(int Fd,pid_t Proc)
    computes the MD5 of the raw data. After this the raw data in the 
    computes the MD5 of the raw data. After this the raw data in the 
    original files is compared to see if this data is new. If the data
    original files is compared to see if this data is new. If the data
    is new then the temp files are renamed, otherwise they are erased. */
    is new then the temp files are renamed, otherwise they are erased. */
-bool MultiCompress::Child(int FD)
+bool MultiCompress::Child(int const &FD)
 {
 {
    // Start the compression children.
    // Start the compression children.
    for (Files *I = Outputs; I != 0; I = I->Next)
    for (Files *I = Outputs; I != 0; I = I->Next)

+ 6 - 6
ftparchive/multicompress.h

@@ -53,9 +53,9 @@ class MultiCompress
    mode_t Permissions;
    mode_t Permissions;
    static const CompType Compressors[];
    static const CompType Compressors[];
 
 
-   bool OpenCompress(const CompType *Prog,pid_t &Pid,int FileFd,
-		     int &OutFd,bool Comp);
-   bool Child(int Fd);
+   bool OpenCompress(const CompType *Prog,pid_t &Pid,int const &FileFd,
+		     int &OutFd,bool const &Comp);
+   bool Child(int const &Fd);
    bool Start();
    bool Start();
    bool Die();
    bool Die();
    
    
@@ -68,10 +68,10 @@ class MultiCompress
    bool Finalize(unsigned long &OutSize);
    bool Finalize(unsigned long &OutSize);
    bool OpenOld(int &Fd,pid_t &Proc);
    bool OpenOld(int &Fd,pid_t &Proc);
    bool CloseOld(int Fd,pid_t Proc);
    bool CloseOld(int Fd,pid_t Proc);
-   static bool GetStat(string Output,string Compress,struct stat &St);
+   static bool GetStat(string const &Output,string const &Compress,struct stat &St);
    
    
-   MultiCompress(string Output,string Compress,mode_t Permissions,
-		 bool Write = true);
+   MultiCompress(string const &Output,string const &Compress,
+		 mode_t const &Permissions, bool const &Write = true);
    ~MultiCompress();
    ~MultiCompress();
 };
 };
 
 

+ 8 - 8
ftparchive/override.cc

@@ -24,7 +24,7 @@
 // Override::ReadOverride - Read the override file			/*{{{*/
 // Override::ReadOverride - Read the override file			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This parses the override file and reads it into the map */
 /* 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)
    if (File.empty() == true)
       return true;
       return true;
@@ -132,7 +132,7 @@ bool Override::ReadOverride(string File,bool Source)
 // Override::ReadExtraOverride - Read the extra override file		/*{{{*/
 // Override::ReadExtraOverride - Read the extra override file		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This parses the extra override file and reads it into the map */
 /* 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)
    if (File.empty() == true)
       return true;
       return true;
@@ -209,9 +209,9 @@ bool Override::ReadExtraOverride(string File,bool Source)
 /* Returns a override item for the given package and the given architecture.
 /* Returns a override item for the given package and the given architecture.
  * Treats "all" special
  * 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);
    map<string,Item>::iterator J = Mapping.find(Package + "/" + Architecture);
 
 
    if (I == Mapping.end() && J == Mapping.end())
    if (I == Mapping.end() && J == Mapping.end())
@@ -230,7 +230,7 @@ Override::Item* Override::GetItem(string Package, string Architecture)
 	 if (R->Priority != "") result->Priority = R->Priority;
 	 if (R->Priority != "") result->Priority = R->Priority;
 	 if (R->OldMaint != "") result->OldMaint = R->OldMaint;
 	 if (R->OldMaint != "") result->OldMaint = R->OldMaint;
 	 if (R->NewMaint != "") result->NewMaint = R->NewMaint;
 	 if (R->NewMaint != "") result->NewMaint = R->NewMaint;
-	 for (map<string,string>::iterator foI = R->FieldOverride.begin();
+	 for (map<string,string>::const_iterator foI = R->FieldOverride.begin();
 	      foI != R->FieldOverride.end(); foI++)
 	      foI != R->FieldOverride.end(); foI++)
          {
          {
 	    result->FieldOverride[foI->first] = foI->second;
 	    result->FieldOverride[foI->first] = foI->second;
@@ -247,7 +247,7 @@ Override::Item* Override::GetItem(string Package, string Architecture)
    there is a rule but it does not match then the empty string is returned,
    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
    also if there was no rewrite rule the empty string is returned. Failed
    indicates if there was some kind of problem while rewriting. */
    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;
    Failed = false;
    
    
@@ -262,10 +262,10 @@ string Override::Item::SwapMaint(string Orig,bool &Failed)
       override file. Thus it persists.*/
       override file. Thus it persists.*/
 #if 1
 #if 1
    // Break OldMaint up into little bits on double slash boundaries.
    // Break OldMaint up into little bits on double slash boundaries.
-   string::iterator End = OldMaint.begin();
+   string::const_iterator End = OldMaint.begin();
    while (1)
    while (1)
    {
    {
-      string::iterator Start = End;      
+      string::const_iterator Start = End;      
       for (; End < OldMaint.end() &&
       for (; End < OldMaint.end() &&
 	   (End + 3 >= OldMaint.end() || End[0] != ' ' || 
 	   (End + 3 >= OldMaint.end() || End[0] != ' ' || 
 	    End[1] != '/' || End[2] != '/'); End++);
 	    End[1] != '/' || End[2] != '/'); End++);

+ 5 - 5
ftparchive/override.h

@@ -31,20 +31,20 @@ class Override
       string NewMaint;
       string NewMaint;
 
 
       map<string,string> FieldOverride;
       map<string,string> FieldOverride;
-      string SwapMaint(string Orig,bool &Failed);
+      string SwapMaint(string const &Orig,bool &Failed);
       ~Item() {};
       ~Item() {};
    };
    };
    
    
    map<string,Item> Mapping;
    map<string,Item> Mapping;
    
    
-   inline Item *GetItem(string Package) 
+   inline Item *GetItem(string const &Package) 
    {
    {
       return GetItem(Package, "");
       return GetItem(Package, "");
    }
    }
-   Item *GetItem(string Package, string Architecture);
+   Item *GetItem(string const &Package, string const &Architecture);
    
    
-   bool ReadOverride(string File,bool Source = false);
-   bool ReadExtraOverride(string File,bool Source = false);
+   bool ReadOverride(string const &File,bool const &Source = false);
+   bool ReadExtraOverride(string const &File,bool const &Source = false);
 };
 };
 
 
 #endif
 #endif

+ 22 - 22
ftparchive/writer.cc

@@ -89,7 +89,7 @@ int FTWScanner::ScannerFTW(const char *File,const struct stat *sb,int Flag)
 // FTWScanner::ScannerFile - File Scanner				/*{{{*/
 // FTWScanner::ScannerFile - File Scanner				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-int FTWScanner::ScannerFile(const char *File, bool ReadLink)
+int FTWScanner::ScannerFile(const char *File, bool const &ReadLink)
 {
 {
    const char *LastComponent = strrchr(File, '/');
    const char *LastComponent = strrchr(File, '/');
    if (LastComponent == NULL)
    if (LastComponent == NULL)
@@ -97,7 +97,7 @@ int FTWScanner::ScannerFile(const char *File, bool ReadLink)
    else
    else
       LastComponent++;
       LastComponent++;
 
 
-   vector<string>::iterator I;
+   vector<string>::const_iterator I;
    for(I = Owner->Patterns.begin(); I != Owner->Patterns.end(); ++I)
    for(I = Owner->Patterns.begin(); I != Owner->Patterns.end(); ++I)
    {
    {
       if (fnmatch((*I).c_str(), LastComponent, 0) == 0)
       if (fnmatch((*I).c_str(), LastComponent, 0) == 0)
@@ -127,7 +127,7 @@ int FTWScanner::ScannerFile(const char *File, bool ReadLink)
       {
       {
 	 Owner->NewLine(1);
 	 Owner->NewLine(1);
 	 
 	 
-	 bool Type = _error->PopMessage(Err);
+	 bool const Type = _error->PopMessage(Err);
 	 if (Type == true)
 	 if (Type == true)
 	    cerr << _("E: ") << Err << endl;
 	    cerr << _("E: ") << Err << endl;
 	 else
 	 else
@@ -148,7 +148,7 @@ int FTWScanner::ScannerFile(const char *File, bool ReadLink)
 // FTWScanner::RecursiveScan - Just scan a directory tree		/*{{{*/
 // FTWScanner::RecursiveScan - Just scan a directory tree		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool FTWScanner::RecursiveScan(string Dir)
+bool FTWScanner::RecursiveScan(string const &Dir)
 {
 {
    /* If noprefix is set then jam the scan root in, so we don't generate
    /* If noprefix is set then jam the scan root in, so we don't generate
       link followed paths out of control */
       link followed paths out of control */
@@ -161,7 +161,7 @@ bool FTWScanner::RecursiveScan(string Dir)
    
    
    // Do recursive directory searching
    // Do recursive directory searching
    Owner = this;
    Owner = this;
-   int Res = ftw(Dir.c_str(),ScannerFTW,30);
+   int const Res = ftw(Dir.c_str(),ScannerFTW,30);
    
    
    // Error treewalking?
    // Error treewalking?
    if (Res != 0)
    if (Res != 0)
@@ -178,7 +178,7 @@ bool FTWScanner::RecursiveScan(string Dir)
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This is an alternative to using FTW to locate files, it reads the list
 /* This is an alternative to using FTW to locate files, it reads the list
    of files from another file. */
    of files from another file. */
-bool FTWScanner::LoadFileList(string Dir,string File)
+bool FTWScanner::LoadFileList(string const &Dir, string const &File)
 {
 {
    /* If noprefix is set then jam the scan root in, so we don't generate
    /* If noprefix is set then jam the scan root in, so we don't generate
       link followed paths out of control */
       link followed paths out of control */
@@ -236,7 +236,7 @@ bool FTWScanner::LoadFileList(string Dir,string File)
 /* */
 /* */
 bool FTWScanner::Delink(string &FileName,const char *OriginalPath,
 bool FTWScanner::Delink(string &FileName,const char *OriginalPath,
 			unsigned long &DeLinkBytes,
 			unsigned long &DeLinkBytes,
-			off_t FileSize)
+			off_t const &FileSize)
 {
 {
    // See if this isn't an internaly prefix'd file name.
    // See if this isn't an internaly prefix'd file name.
    if (InternalPrefix.empty() == false &&
    if (InternalPrefix.empty() == false &&
@@ -293,8 +293,8 @@ bool FTWScanner::Delink(string &FileName,const char *OriginalPath,
 // PackagesWriter::PackagesWriter - Constructor				/*{{{*/
 // PackagesWriter::PackagesWriter - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-PackagesWriter::PackagesWriter(string DB,string Overrides,string ExtOverrides,
-			       string aArch) :
+PackagesWriter::PackagesWriter(string const &DB,string const &Overrides,string const &ExtOverrides,
+			       string const &aArch) :
    Db(DB),Stats(Db.Stats), Arch(aArch)
    Db(DB),Stats(Db.Stats), Arch(aArch)
 {
 {
    Output = stdout;
    Output = stdout;
@@ -329,7 +329,7 @@ PackagesWriter::PackagesWriter(string DB,string Overrides,string ExtOverrides,
 // FTWScanner::SetExts - Set extensions to support                      /*{{{*/
 // FTWScanner::SetExts - Set extensions to support                      /*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool FTWScanner::SetExts(string Vals)
+bool FTWScanner::SetExts(string const &Vals)
 {
 {
    ClearPatterns();
    ClearPatterns();
    string::size_type Start = 0;
    string::size_type Start = 0;
@@ -476,7 +476,7 @@ bool PackagesWriter::DoPackage(string FileName)
       SetTFRewriteData(Changes[End++], "Suggests", OptionalStr.c_str());
       SetTFRewriteData(Changes[End++], "Suggests", OptionalStr.c_str());
    }
    }
 
 
-   for (map<string,string>::iterator I = OverItem->FieldOverride.begin(); 
+   for (map<string,string>::const_iterator I = OverItem->FieldOverride.begin(); 
         I != OverItem->FieldOverride.end(); I++) 
         I != OverItem->FieldOverride.end(); I++) 
       SetTFRewriteData(Changes[End++],I->first.c_str(),I->second.c_str());
       SetTFRewriteData(Changes[End++],I->first.c_str(),I->second.c_str());
 
 
@@ -494,8 +494,8 @@ bool PackagesWriter::DoPackage(string FileName)
 // SourcesWriter::SourcesWriter - Constructor				/*{{{*/
 // SourcesWriter::SourcesWriter - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-SourcesWriter::SourcesWriter(string BOverrides,string SOverrides,
-			     string ExtOverrides)
+SourcesWriter::SourcesWriter(string const &BOverrides,string const &SOverrides,
+			     string const &ExtOverrides)
 {
 {
    Output = stdout;
    Output = stdout;
    AddPattern("*.dsc");
    AddPattern("*.dsc");
@@ -720,7 +720,7 @@ bool SourcesWriter::DoPackage(string FileName)
    if (NewMaint.empty() == false)
    if (NewMaint.empty() == false)
       SetTFRewriteData(Changes[End++], "Maintainer", NewMaint.c_str());
       SetTFRewriteData(Changes[End++], "Maintainer", NewMaint.c_str());
    
    
-   for (map<string,string>::iterator I = SOverItem->FieldOverride.begin(); 
+   for (map<string,string>::const_iterator I = SOverItem->FieldOverride.begin(); 
         I != SOverItem->FieldOverride.end(); I++) 
         I != SOverItem->FieldOverride.end(); I++) 
       SetTFRewriteData(Changes[End++],I->first.c_str(),I->second.c_str());
       SetTFRewriteData(Changes[End++],I->first.c_str(),I->second.c_str());
 
 
@@ -740,7 +740,7 @@ bool SourcesWriter::DoPackage(string FileName)
 // ContentsWriter::ContentsWriter - Constructor				/*{{{*/
 // ContentsWriter::ContentsWriter - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-ContentsWriter::ContentsWriter(string DB) : 
+ContentsWriter::ContentsWriter(string const &DB) : 
 		    Db(DB), Stats(Db.Stats)
 		    Db(DB), Stats(Db.Stats)
 
 
 {
 {
@@ -752,7 +752,7 @@ ContentsWriter::ContentsWriter(string DB) :
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* If Package is the empty string the control record will be parsed to
 /* If Package is the empty string the control record will be parsed to
    determine what the package name is. */
    determine what the package name is. */
-bool ContentsWriter::DoPackage(string FileName,string Package)
+bool ContentsWriter::DoPackage(string FileName, string Package)
 {
 {
    if (!Db.GetFileInfo(FileName, Package.empty(), true, false, false, false, false, false))
    if (!Db.GetFileInfo(FileName, Package.empty(), true, false, false, false, false, false))
    {
    {
@@ -773,7 +773,7 @@ bool ContentsWriter::DoPackage(string FileName,string Package)
 // ContentsWriter::ReadFromPkgs - Read from a packages file		/*{{{*/
 // ContentsWriter::ReadFromPkgs - Read from a packages file		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool ContentsWriter::ReadFromPkgs(string PkgFile,string PkgCompress)
+bool ContentsWriter::ReadFromPkgs(string const &PkgFile,string const &PkgCompress)
 {
 {
    MultiCompress Pkgs(PkgFile,PkgCompress,0,false);
    MultiCompress Pkgs(PkgFile,PkgCompress,0,false);
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
@@ -828,7 +828,7 @@ bool ContentsWriter::ReadFromPkgs(string PkgFile,string PkgCompress)
 // ReleaseWriter::ReleaseWriter - Constructor				/*{{{*/
 // ReleaseWriter::ReleaseWriter - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-ReleaseWriter::ReleaseWriter(string DB)
+ReleaseWriter::ReleaseWriter(string const &DB)
 {
 {
    AddPattern("Packages");
    AddPattern("Packages");
    AddPattern("Packages.gz");
    AddPattern("Packages.gz");
@@ -842,7 +842,7 @@ ReleaseWriter::ReleaseWriter(string DB)
    AddPattern("md5sum.txt");
    AddPattern("md5sum.txt");
 
 
    Output = stdout;
    Output = stdout;
-   time_t now = time(NULL);
+   time_t const now = time(NULL);
    char datestr[128];
    char datestr[128];
    if (strftime(datestr, sizeof(datestr), "%a, %d %b %Y %H:%M:%S UTC",
    if (strftime(datestr, sizeof(datestr), "%a, %d %b %Y %H:%M:%S UTC",
                 gmtime(&now)) == 0)
                 gmtime(&now)) == 0)
@@ -929,7 +929,7 @@ bool ReleaseWriter::DoPackage(string FileName)
 void ReleaseWriter::Finish()
 void ReleaseWriter::Finish()
 {
 {
    fprintf(Output, "MD5Sum:\n");
    fprintf(Output, "MD5Sum:\n");
-   for(map<string,struct CheckSum>::iterator I = CheckSums.begin();
+   for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
        I != CheckSums.end();
        I != CheckSums.end();
        ++I)
        ++I)
    {
    {
@@ -940,7 +940,7 @@ void ReleaseWriter::Finish()
    }
    }
 
 
    fprintf(Output, "SHA1:\n");
    fprintf(Output, "SHA1:\n");
-   for(map<string,struct CheckSum>::iterator I = CheckSums.begin();
+   for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
        I != CheckSums.end();
        I != CheckSums.end();
        ++I)
        ++I)
    {
    {
@@ -951,7 +951,7 @@ void ReleaseWriter::Finish()
    }
    }
 
 
    fprintf(Output, "SHA256:\n");
    fprintf(Output, "SHA256:\n");
-   for(map<string,struct CheckSum>::iterator I = CheckSums.begin();
+   for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
        I != CheckSums.end();
        I != CheckSums.end();
        ++I)
        ++I)
    {
    {

+ 17 - 17
ftparchive/writer.h

@@ -43,12 +43,12 @@ class FTWScanner
    
    
    static FTWScanner *Owner;
    static FTWScanner *Owner;
    static int ScannerFTW(const char *File,const struct stat *sb,int Flag);
    static int ScannerFTW(const char *File,const struct stat *sb,int Flag);
-   static int ScannerFile(const char *File, bool ReadLink);
+   static int ScannerFile(const char *File, bool const &ReadLink);
 
 
    bool Delink(string &FileName,const char *OriginalPath,
    bool Delink(string &FileName,const char *OriginalPath,
-	       unsigned long &Bytes,off_t FileSize);
+	       unsigned long &Bytes,off_t const &FileSize);
 
 
-   inline void NewLine(unsigned Priority)
+   inline void NewLine(unsigned const &Priority)
    {
    {
       if (ErrorPrinted == false && Quiet <= Priority)
       if (ErrorPrinted == false && Quiet <= Priority)
       {
       {
@@ -63,11 +63,11 @@ class FTWScanner
    string InternalPrefix;
    string InternalPrefix;
 
 
    virtual bool DoPackage(string FileName) = 0;
    virtual bool DoPackage(string FileName) = 0;
-   bool RecursiveScan(string Dir);
-   bool LoadFileList(string BaseDir,string File);
+   bool RecursiveScan(string const &Dir);
+   bool LoadFileList(string const &BaseDir,string const &File);
    void ClearPatterns() { Patterns.clear(); };
    void ClearPatterns() { Patterns.clear(); };
-   void AddPattern(string Pattern) { Patterns.push_back(Pattern); };
-   bool SetExts(string Vals);
+   void AddPattern(string const &Pattern) { Patterns.push_back(Pattern); };
+   bool SetExts(string const &Vals);
       
       
    FTWScanner();
    FTWScanner();
    virtual ~FTWScanner() {delete [] RealPath;};
    virtual ~FTWScanner() {delete [] RealPath;};
@@ -96,13 +96,13 @@ class PackagesWriter : public FTWScanner
    struct CacheDB::Stats &Stats;
    struct CacheDB::Stats &Stats;
    string Arch;
    string Arch;
 
 
-   inline bool ReadOverride(string File) {return Over.ReadOverride(File);};
-   inline bool ReadExtraOverride(string File) 
+   inline bool ReadOverride(string const &File) {return Over.ReadOverride(File);};
+   inline bool ReadExtraOverride(string const &File) 
       {return Over.ReadExtraOverride(File);};
       {return Over.ReadExtraOverride(File);};
    virtual bool DoPackage(string FileName);
    virtual bool DoPackage(string FileName);
 
 
-   PackagesWriter(string DB,string Overrides,string ExtOverrides=string(),
-		  string Arch=string());
+   PackagesWriter(string const &DB,string const &Overrides,string const &ExtOverrides=string(),
+		  string const &Arch=string());
    virtual ~PackagesWriter() {};
    virtual ~PackagesWriter() {};
 };
 };
 
 
@@ -122,12 +122,12 @@ class ContentsWriter : public FTWScanner
    bool DoPackage(string FileName,string Package);
    bool DoPackage(string FileName,string Package);
    virtual bool DoPackage(string FileName) 
    virtual bool DoPackage(string FileName) 
              {return DoPackage(FileName,string());};
              {return DoPackage(FileName,string());};
-   bool ReadFromPkgs(string PkgFile,string PkgCompress);
+   bool ReadFromPkgs(string const &PkgFile,string const &PkgCompress);
 
 
    void Finish() {Gen.Print(Output);};
    void Finish() {Gen.Print(Output);};
-   inline bool ReadyDB(string DB) {return Db.ReadyDB(DB);};
+   inline bool ReadyDB(string const &DB) {return Db.ReadyDB(DB);};
    
    
-   ContentsWriter(string DB);
+   ContentsWriter(string const &DB);
    virtual ~ContentsWriter() {};
    virtual ~ContentsWriter() {};
 };
 };
 
 
@@ -150,15 +150,15 @@ class SourcesWriter : public FTWScanner
 
 
    virtual bool DoPackage(string FileName);
    virtual bool DoPackage(string FileName);
 
 
-   SourcesWriter(string BOverrides,string SOverrides,
-		 string ExtOverrides=string());
+   SourcesWriter(string const &BOverrides,string const &SOverrides,
+		 string const &ExtOverrides=string());
    virtual ~SourcesWriter() {free(Buffer);};
    virtual ~SourcesWriter() {free(Buffer);};
 };
 };
 
 
 class ReleaseWriter : public FTWScanner
 class ReleaseWriter : public FTWScanner
 {
 {
 public:
 public:
-   ReleaseWriter(string DB);
+   ReleaseWriter(string const &DB);
    virtual bool DoPackage(string FileName);
    virtual bool DoPackage(string FileName);
    void Finish();
    void Finish();