'k. reverted use_reduce filtering of empty lists (was resulting in ["||"] as element...
authorBrian Harring <ferringb@gentoo.org>
Thu, 5 Jan 2006 05:33:25 +0000 (05:33 -0000)
committerBrian Harring <ferringb@gentoo.org>
Thu, 5 Jan 2006 05:33:25 +0000 (05:33 -0000)
a recursive filter of empty sets/resolved || and && nodes; in the process, keeps portage from using an empty bool as a satisfier in
|| () restriction sets.

svn path=/main/trunk/; revision=2528

pym/portage.py
pym/portage_dep.py

index 1865557009a068f8bd5279f778ab6c014bed47c8..6105e0810f117adadf210e386d24816d31c9464a 100644 (file)
@@ -3374,6 +3374,26 @@ def dep_check(depstring,mydbapi,mysettings,use="yes",mode=None,myuse=None,use_ca
        #if mysplit==None, then we have a parse error (paren mismatch or misplaced ||)
        #up until here, we haven't needed to look at the database tree
 
+       # recursive cleansing of empty arrays.
+       # without this, portage eats itself if fed a || ()
+       def f(a):
+               x = 0
+               l = len(a)
+               while x < l:
+                       if isinstance(a[x], list):
+                               l2 = len(a[x])
+                               if l2 == 0:
+                                       a.pop(x)
+                               elif l2 == 1 and a[x][0] in ("||", "&&"):
+                                       a.pop(x)
+                               else:
+                                       f(a[x])
+                                       x+=1
+                                       continue
+                               l-=1
+                       x+=1
+       f(mysplit)
+                       
        if mysplit==None:
                return [0,"Parse Error (parentheses mismatch?)"]
        elif mysplit==[]:
index 5467e005542bcf580fb74f683b0f789af69c2b6a..de5c504ccee45e4d9ab3467f7abdf0db74c5a007 100644 (file)
@@ -79,9 +79,7 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
                head = mydeparray.pop(0)
 
                if type(head) == types.ListType:
-                       additions = use_reduce(head, uselist, masklist, matchall, excludeall)
-                       if additions:
-                               rlist.append(additions)
+                       rlist.append(use_reduce(head, uselist, masklist, matchall, excludeall))
 
                else:
                        if head[-1] == "?": # Use reduce next group on fail.
@@ -124,9 +122,7 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
                                if ismatch:
                                        target = newdeparray[-1]
                                        if isinstance(target, list):
-                                               additions = use_reduce(target, uselist, masklist, matchall, excludeall)
-                                               if additions:
-                                                       rlist.append(additions)
+                                               rlist.append(use_reduce(target, uselist, masklist, matchall, excludeall))
                                        else:
                                                rlist += [target]