Updated Danish translation from Claus Hindsgaul <claus_...
[apt.git] / cmdline / indexcopy.cc
index 389d3c5473f3abb442a9de54c5f2b58412ff1ae8..3ce12a94b2f5cea08bc56f90b3670bedf0b6bbd2 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: indexcopy.cc,v 1.6 2001/02/20 07:03:17 jgg Exp $
+// $Id: indexcopy.cc,v 1.10 2002/03/26 07:38:58 jgg Exp $
 /* ######################################################################
 
    Index Copying - Aid for copying and verifying the index files
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/tagfile.h>
 
-#include <iostream.h>
+#include <iostream>
 #include <unistd.h>
 #include <sys/stat.h>
 #include <stdio.h>
                                                                        /*}}}*/
 
+using namespace std;
+
 // IndexCopy::CopyPackages - Copy the package files from the CD                /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -94,7 +96,8 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List)
            SetCloseExec(STDOUT_FILENO,false);
            
            const char *Args[3];
-           Args[0] = _config->Find("Dir::bin::gzip","gzip").c_str();
+           string Tmp =  _config->Find("Dir::bin::gzip","gzip");
+           Args[0] = Tmp.c_str();
            Args[1] = "-d";
            Args[2] = 0;
            execvp(Args[0],(char **)Args);
@@ -113,8 +116,8 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List)
       
       // Open the output file
       char S[400];
-      sprintf(S,"cdrom:[%s]/%s%s",Name.c_str(),(*I).c_str() + CDROM.length(),
-             GetFileName());
+      snprintf(S,sizeof(S),"cdrom:[%s]/%s%s",Name.c_str(),
+              (*I).c_str() + CDROM.length(),GetFileName());
       string TargetF = _config->FindDir("Dir::State::lists") + "partial/";
       TargetF += URItoFileName(S);
       if (_config->FindB("APT::CDROM::NoAct",false) == true)
@@ -229,7 +232,8 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List)
            return _error->Errno("rename","Failed to rename");
 
         // Copy the release file
-        sprintf(S,"cdrom:[%s]/%sRelease",Name.c_str(),(*I).c_str() + CDROM.length());
+        snprintf(S,sizeof(S),"cdrom:[%s]/%sRelease",Name.c_str(),
+                 (*I).c_str() + CDROM.length());
         string TargetF = _config->FindDir("Dir::State::lists") + "partial/";
         TargetF += URItoFileName(S);
         if (FileExists(*I + "Release") == true)
@@ -276,8 +280,8 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List)
    cout << '.' << endl;
    
    if (Packages == 0)
-      return _error->Warning("No valid records were found.");
-   
+      _error->Warning("No valid records were found.");
+
    if (NotFound + WrongSize > 10)
       cout << "Alot of entries were discarded, something may be wrong." << endl;
 
@@ -381,7 +385,7 @@ bool IndexCopy::ReconstructChop(unsigned long &Chop,string Dir,string File)
 void IndexCopy::ConvertToSourceList(string CD,string &Path)
 {
    char S[300];
-   sprintf(S,"binary-%s",_config->Find("Apt::Architecture").c_str());
+   snprintf(S,sizeof(S),"binary-%s",_config->Find("Apt::Architecture").c_str());
    
    // Strip the cdrom base path
    Path = string(Path,CD.length());
@@ -393,7 +397,7 @@ void IndexCopy::ConvertToSourceList(string CD,string &Path)
       return;
    
    // Not a dists type.
-   if (stringcmp(Path.begin(),Path.begin()+strlen("dists/"),"dists/") != 0)
+   if (stringcmp(Path.c_str(),Path.c_str()+strlen("dists/"),"dists/") != 0)
       return;
       
    // Isolate the dist