]> git.saurik.com Git - apt.git/commitdiff
Convert most callers of isspace() to isspace_ascii()
authorJulian Andres Klode <jak@debian.org>
Sat, 26 Dec 2015 23:51:59 +0000 (00:51 +0100)
committerJulian Andres Klode <jak@debian.org>
Sun, 27 Dec 2015 00:20:41 +0000 (01:20 +0100)
This converts all callers that read machine-generated data,
callers that might work with user input are not converted.

apt-pkg/contrib/strutl.cc
apt-pkg/deb/deblistparser.cc
apt-pkg/deb/debsrcrecords.cc
apt-pkg/deb/debsystem.cc
apt-pkg/tagfile.cc
methods/https.cc
methods/rred.cc
methods/server.cc

index 392412e52e2d8ca776b4d5c7fc0e35116bf5b69a..de049602f1143f43072569c49895075add5bf08c 100644 (file)
@@ -690,9 +690,9 @@ string LookupTag(const string &Message,const char *Tag,const char *Default)
         // Find the end of line and strip the leading/trailing spaces
         string::const_iterator J;
         I += Length + 1;
-        for (; isspace(*I) != 0 && I < Message.end(); ++I);
+        for (; isspace_ascii(*I) != 0 && I < Message.end(); ++I);
         for (J = I; *J != '\n' && J < Message.end(); ++J);
-        for (; J > I && isspace(J[-1]) != 0; --J);
+        for (; J > I && isspace_ascii(J[-1]) != 0; --J);
         
         return string(I,J);
       }
index bf9bc75ecffe3fe62fb3a96534ae803bd1db6e45..f3ab9d5d82be0213ede23bf5b19d77beadf885b7 100644 (file)
@@ -353,7 +353,7 @@ unsigned short debListParser::VersionHash()
       char *J = S;
       for (; Start != End; ++Start)
       {
-        if (isspace(*Start) != 0)
+        if (isspace_ascii(*Start) != 0)
            continue;
         *J++ = tolower_ascii(*Start);
 
@@ -543,11 +543,11 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
                                        bool const &ParseRestrictionsList)
 {
    // Strip off leading space
-   for (;Start != Stop && isspace(*Start) != 0; ++Start);
+   for (;Start != Stop && isspace_ascii(*Start) != 0; ++Start);
    
    // Parse off the package name
    const char *I = Start;
-   for (;I != Stop && isspace(*I) == 0 && *I != '(' && *I != ')' &&
+   for (;I != Stop && isspace_ascii(*I) == 0 && *I != '(' && *I != ')' &&
        *I != ',' && *I != '|' && *I != '[' && *I != ']' &&
        *I != '<' && *I != '>'; ++I);
    
@@ -573,19 +573,19 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
    }
 
    // Skip white space to the '('
-   for (;I != Stop && isspace(*I) != 0 ; I++);
+   for (;I != Stop && isspace_ascii(*I) != 0 ; I++);
    
    // Parse a version
    if (I != Stop && *I == '(')
    {
       // Skip the '('
-      for (I++; I != Stop && isspace(*I) != 0 ; I++);
+      for (I++; I != Stop && isspace_ascii(*I) != 0 ; I++);
       if (I + 3 >= Stop)
         return 0;
       I = ConvertRelation(I,Op);
       
       // Skip whitespace
-      for (;I != Stop && isspace(*I) != 0; I++);
+      for (;I != Stop && isspace_ascii(*I) != 0; I++);
       Start = I;
       I = (const char*) memchr(I, ')', Stop - I);
       if (I == NULL || Start == I)
@@ -593,7 +593,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
       
       // Skip trailing whitespace
       const char *End = I;
-      for (; End > Start && isspace(End[-1]); End--);
+      for (; End > Start && isspace_ascii(End[-1]); End--);
       
       Ver.assign(Start,End-Start);
       I++;
@@ -605,7 +605,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
    }
    
    // Skip whitespace
-   for (;I != Stop && isspace(*I) != 0; I++);
+   for (;I != Stop && isspace_ascii(*I) != 0; I++);
 
    if (ParseArchFlags == true)
    {
@@ -625,7 +625,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
         while (I != Stop)
         {
            // look for whitespace or ending ']'
-           for (;End != Stop && !isspace(*End) && *End != ']'; ++End);
+           for (;End != Stop && !isspace_ascii(*End) && *End != ']'; ++End);
 
            if (unlikely(End == Stop))
               return 0;
@@ -652,7 +652,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
            }
 
            I = End;
-           for (;I != Stop && isspace(*I) != 0; I++);
+           for (;I != Stop && isspace_ascii(*I) != 0; I++);
         }
 
         if (NegArch == true)
@@ -663,7 +663,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
       }
 
       // Skip whitespace
-      for (;I != Stop && isspace(*I) != 0; I++);
+      for (;I != Stop && isspace_ascii(*I) != 0; I++);
    }
 
    if (ParseRestrictionsList == true)
@@ -696,7 +696,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
            for (;End != Stop && *End != '>'; ++End);
            I = ++End;
            // skip whitespace
-           for (;I != Stop && isspace(*I) != 0; I++);
+           for (;I != Stop && isspace_ascii(*I) != 0; I++);
         } else {
            bool applies2 = true;
            // all the conditions inside a restriction list have to be
@@ -706,7 +706,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
            {
               // look for whitespace or ending '>'
               // End now points to the character after the current term
-              for (;End != Stop && !isspace(*End) && *End != '>'; ++End);
+              for (;End != Stop && !isspace_ascii(*End) && *End != '>'; ++End);
 
               if (unlikely(End == Stop))
                  return 0;
@@ -739,13 +739,13 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
               if (*End++ == '>') {
                  I = End;
                  // skip whitespace
-                 for (;I != Stop && isspace(*I) != 0; I++);
+                 for (;I != Stop && isspace_ascii(*I) != 0; I++);
                  break;
               }
 
               I = End;
               // skip whitespace
-              for (;I != Stop && isspace(*I) != 0; I++);
+              for (;I != Stop && isspace_ascii(*I) != 0; I++);
            }
            if (applies2) {
               applies1 = true;
@@ -764,7 +764,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
    if (I == Stop || *I == ',' || *I == '|')
    {
       if (I != Stop)
-        for (I++; I != Stop && isspace(*I) != 0; I++);
+        for (I++; I != Stop && isspace_ascii(*I) != 0; I++);
       return I;
    }
    
index 9404b64215fee4584d26b358b811d29871aa1324..cef7ad10edfd1f76ef7f49998ee63a6e6bcb0d1f 100644 (file)
@@ -48,7 +48,7 @@ const char **debSrcRecordParser::Binaries()
    const char *Start, *End;
    if (Sect.Find("Binary", Start, End) == false)
       return NULL;
-   for (; isspace(*Start) != 0; ++Start);
+   for (; isspace_ascii(*Start) != 0; ++Start);
    if (Start >= End)
       return NULL;
 
@@ -60,13 +60,13 @@ const char **debSrcRecordParser::Binaries()
    do {
       char* binStartNext = strchrnul(bin, ',');
       char* binEnd = binStartNext - 1;
-      for (; isspace(*binEnd) != 0; --binEnd)
+      for (; isspace_ascii(*binEnd) != 0; --binEnd)
         binEnd = 0;
       StaticBinList.push_back(bin);
       if (*binStartNext != ',')
         break;
       *binStartNext = '\0';
-      for (bin = binStartNext + 1; isspace(*bin) != 0; ++bin)
+      for (bin = binStartNext + 1; isspace_ascii(*bin) != 0; ++bin)
          ;
    } while (*bin != '\0');
    StaticBinList.push_back(NULL);
index dcd115b50723cef28110ae092811eb2d9ed44156..56ca8f4c6dd564d9e4d138f673bbe505066b8c72 100644 (file)
@@ -399,10 +399,10 @@ std::vector<std::string> debSystem::SupportedArchitectures()              /*{{{*/
         char* tok_saveptr;
         char* arch = strtok_r(buf, " ", &tok_saveptr);
         while (arch != NULL) {
-           for (; isspace(*arch) != 0; ++arch);
+           for (; isspace_ascii(*arch) != 0; ++arch);
            if (arch[0] != '\0') {
               char const* archend = arch;
-              for (; isspace(*archend) == 0 && *archend != '\0'; ++archend);
+              for (; isspace_ascii(*archend) == 0 && *archend != '\0'; ++archend);
               string a(arch, (archend - arch));
               if (std::find(archs.begin(), archs.end(), a) == archs.end())
                  archs.push_back(a);
index 2bef9b48b7dfc1c399d51e66220118900539f35b..668cfc3a42e71d250e9562e40d14cad9c8c17ccd 100644 (file)
@@ -353,7 +353,7 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength, bool const R
          return true;
 
       // Start a new index and add it to the hash
-      if (isspace(Stop[0]) == 0)
+      if (isspace_ascii(Stop[0]) == 0)
       {
         // store the last found tag
         if (lastTagData.EndTag != 0)
@@ -375,14 +375,14 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength, bool const R
         // find the end of the tag (which might or might not be the colon)
         char const * EndTag = Colon;
         --EndTag;
-        for (; EndTag > Stop && isspace(*EndTag) != 0; --EndTag)
+        for (; EndTag > Stop && isspace_ascii(*EndTag) != 0; --EndTag)
            ;
         ++EndTag;
         lastTagData.EndTag = EndTag - Section;
         lastTagHash = AlphaHash(Stop, EndTag - Stop);
         // find the beginning of the value
         Stop = Colon + 1;
-        for (; isspace(*Stop) != 0; ++Stop);
+        for (; isspace_ascii(*Stop) != 0; ++Stop);
         if (Stop >= End)
            return false;
         lastTagData.StartValue = Stop - Section;
@@ -484,7 +484,7 @@ bool pkgTagSection::Find(const char *Tag,const char *&Start,
    if (unlikely(Start > End))
       return _error->Error("Internal parsing error");
 
-   for (; isspace(End[-1]) != 0 && End > Start; --End);
+   for (; isspace_ascii(End[-1]) != 0 && End > Start; --End);
 
    return true;
 }
@@ -512,7 +512,7 @@ string pkgTagSection::FindRawS(const char *Tag) const
    if (unlikely(Start > End))
       return "";
 
-   for (; isspace(End[-1]) != 0 && End > Start; --End);
+   for (; isspace_ascii(End[-1]) != 0 && End > Start; --End);
 
    return std::string(Start, End - Start);
 }
@@ -672,7 +672,7 @@ pkgTagSection::Tag pkgTagSection::Tag::Rewrite(std::string const &Name, std::str
 }
 static bool WriteTag(FileFd &File, std::string Tag, std::string const &Value)
 {
-   if (Value.empty() || isspace(Value[0]) != 0)
+   if (Value.empty() || isspace_ascii(Value[0]) != 0)
       Tag.append(":");
    else
       Tag.append(": ");
@@ -826,7 +826,7 @@ bool TFRewrite(FILE *Output,pkgTagSection const &Tags,const char *Order[],
                Visited[J] |= 2;
                if (Rewrite[J].Rewrite != 0 && Rewrite[J].Rewrite[0] != 0)
                {
-                  if (isspace(Rewrite[J].Rewrite[0]))
+                  if (isspace_ascii(Rewrite[J].Rewrite[0]))
                      fprintf(Output,"%s:%s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
                   else
                      fprintf(Output,"%s: %s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
@@ -882,7 +882,7 @@ bool TFRewrite(FILE *Output,pkgTagSection const &Tags,const char *Order[],
            Visited[J] |= 2;
            if (Rewrite[J].Rewrite != 0 && Rewrite[J].Rewrite[0] != 0)
            {
-              if (isspace(Rewrite[J].Rewrite[0]))
+              if (isspace_ascii(Rewrite[J].Rewrite[0]))
                  fprintf(Output,"%s:%s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
               else
                  fprintf(Output,"%s: %s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
@@ -911,7 +911,7 @@ bool TFRewrite(FILE *Output,pkgTagSection const &Tags,const char *Order[],
       
       if (Rewrite[J].Rewrite != 0 && Rewrite[J].Rewrite[0] != 0)
       {
-        if (isspace(Rewrite[J].Rewrite[0]))
+        if (isspace_ascii(Rewrite[J].Rewrite[0]))
            fprintf(Output,"%s:%s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
         else
            fprintf(Output,"%s: %s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
index a99b1861b92134a8727c0ecda27d50a868f07d7d..ac6d355edae701e5c3f570fbd839d377b1af74bb 100644 (file)
@@ -52,7 +52,7 @@ HttpsMethod::parse_header(void *buffer, size_t size, size_t nmemb, void *userp)
    CURLUserPointer *me = static_cast<CURLUserPointer *>(userp);
    std::string line((char*) buffer, len);
    for (--len; len > 0; --len)
-      if (isspace(line[len]) == 0)
+      if (isspace_ascii(line[len]) == 0)
       {
         ++len;
         break;
index 351c1ebf998b597761e3707010a79c0357bdddd4..89d7069848811048f1fa1b7a7ba20791b6e08b4d 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <config.h>
 
+#include <apt-pkg/init.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/acquire-method.h>
@@ -692,6 +693,8 @@ int main(int argc, char **argv)
    bool test = false;
    Patch patch;
 
+   pkgInitConfig(*_config);
+
    if (argc <= 1) {
       RredMethod Mth;
       return Mth.Run();
index e89af2dfecd37140a50c046d8a69f8d147ca2e6c..d5188d4a31450a81248b7269b87b4edc24602a58 100644 (file)
@@ -114,7 +114,7 @@ bool ServerState::HeaderLine(string Line)
 
    // Parse off any trailing spaces between the : and the next word.
    string::size_type Pos2 = Pos;
-   while (Pos2 < Line.length() && isspace(Line[Pos2]) != 0)
+   while (Pos2 < Line.length() && isspace_ascii(Line[Pos2]) != 0)
       Pos2++;
 
    string Tag = string(Line,0,Pos);