ソースを参照

* deb/deblistparser.cc:
- ensure that mixed positive/negative architecture wildcards
are handled in the same way as dpkg handles them

David Kalnischkies 14 年 前
コミット
cd9694bf7c
共有2 個のファイルを変更した39 個の追加23 個の削除を含む
  1. 30 23
      apt-pkg/deb/deblistparser.cc
  2. 9 0
      debian/changelog

+ 30 - 23
apt-pkg/deb/deblistparser.cc

@@ -561,28 +561,27 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
       // Parse an architecture
       // Parse an architecture
       if (I != Stop && *I == '[')
       if (I != Stop && *I == '[')
       {
       {
+	 ++I;
 	 // malformed
 	 // malformed
-         I++;
-         if (I == Stop)
-	    return 0; 
-	 
-         const char *End = I;
-         bool Found = false;
-      	 bool NegArch = false;
-         while (I != Stop) 
+	 if (unlikely(I == Stop))
+	    return 0;
+
+	 const char *End = I;
+	 bool Found = false;
+	 bool NegArch = false;
+	 while (I != Stop)
 	 {
 	 {
-            // look for whitespace or ending ']'
-	    while (End != Stop && !isspace(*End) && *End != ']') 
-	       End++;
-	 
-	    if (End == Stop) 
+	    // look for whitespace or ending ']'
+	    for (;End != Stop && !isspace(*End) && *End != ']'; ++End);
+
+	    if (unlikely(End == Stop))
 	       return 0;
 	       return 0;
 
 
 	    if (*I == '!')
 	    if (*I == '!')
-            {
+	    {
 	       NegArch = true;
 	       NegArch = true;
-	       I++;
-            }
+	       ++I;
+	    }
 
 
 	    if (stringcmp(arch,I,End) == 0) {
 	    if (stringcmp(arch,I,End) == 0) {
 	       Found = true;
 	       Found = true;
@@ -591,23 +590,31 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
 	       if (fnmatch(wildcard.c_str(), completeArch.c_str(), 0) == 0)
 	       if (fnmatch(wildcard.c_str(), completeArch.c_str(), 0) == 0)
 	          Found = true;
 	          Found = true;
 	    }
 	    }
-	    
+
+	    if (Found == true)
+	    {
+	       if (I[-1] != '!')
+		  NegArch = false;
+	       // we found a match, so fast-forward to the end of the wildcards
+	       for (; End != Stop && *End != ']'; ++End);
+	    }
+
 	    if (*End++ == ']') {
 	    if (*End++ == ']') {
 	       I = End;
 	       I = End;
 	       break;
 	       break;
 	    }
 	    }
-	    
+
 	    I = End;
 	    I = End;
 	    for (;I != Stop && isspace(*I) != 0; I++);
 	    for (;I != Stop && isspace(*I) != 0; I++);
-         }
+	 }
 
 
-	 if (NegArch)
+	 if (NegArch == true)
 	    Found = !Found;
 	    Found = !Found;
-	 
-         if (Found == false)
+
+	 if (Found == false)
 	    Package = ""; /* not for this arch */
 	    Package = ""; /* not for this arch */
       }
       }
-      
+
       // Skip whitespace
       // Skip whitespace
       for (;I != Stop && isspace(*I) != 0; I++);
       for (;I != Stop && isspace(*I) != 0; I++);
    }
    }

+ 9 - 0
debian/changelog

@@ -1,3 +1,12 @@
+apt (0.9.6.1) UNRELEASED; urgency=low
+
+  [ David Kalnischkies ]
+  * deb/deblistparser.cc:
+    - ensure that mixed positive/negative architecture wildcards
+      are handled in the same way as dpkg handles them
+
+ -- David Kalnischkies <kalnischkies@gmail.com>  Thu, 14 Jun 2012 15:45:13 +0200
+
 apt (0.9.6) unstable; urgency=low
 apt (0.9.6) unstable; urgency=low
 
 
   [ David Kalnischkies ]
   [ David Kalnischkies ]