]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/deblistparser.cc
FildFd: Introduce a Flush() function and call it from Close()
[apt.git] / apt-pkg / deb / deblistparser.cc
index bf9bc75ecffe3fe62fb3a96534ae803bd1db6e45..874a94e24de1869e6bd9fd2860e4298ab59c66f8 100644 (file)
@@ -284,8 +284,10 @@ MD5SumValue debListParser::Description_md5()
    }
    else if (likely(value.size() == 32))
    {
-      if (likely(value.find_first_not_of("0123456789abcdefABCDEF") == string::npos))
-        return MD5SumValue(value);
+      MD5SumValue sumvalue;
+      if (sumvalue.Set(value))
+        return sumvalue;
+
       _error->Error("Malformed Description-md5 line; includes invalid character '%s'", value.c_str());
       return MD5SumValue();
    }
@@ -353,7 +355,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 +545,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);
    
@@ -562,8 +564,8 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
    Package.assign(Start,I - Start);
 
    // We don't want to confuse library users which can't handle MultiArch
-   string const arch = _config->Find("APT::Architecture");
    if (StripMultiArch == true) {
+      string const arch = _config->Find("APT::Architecture");
       size_t const found = Package.rfind(':');
       if (found != string::npos &&
          (strcmp(Package.c_str() + found, ":any") == 0 ||
@@ -573,19 +575,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 +595,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,10 +607,11 @@ 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)
+   if (unlikely(ParseArchFlags == true))
    {
+      string const arch = _config->Find("APT::Architecture");
       APT::CacheFilter::PackageArchitectureMatchesSpecification matchesArch(arch, false);
 
       // Parse an architecture
@@ -625,7 +628,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 +655,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,10 +666,10 @@ 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)
+   if (unlikely(ParseRestrictionsList == true))
    {
       // Parse a restrictions formula which is in disjunctive normal form:
       // (foo AND bar) OR (blub AND bla)
@@ -696,7 +699,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 +709,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 +742,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 +767,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;
    }