Move DEPEND empty sublist processing back into use_reduce
authorJason Stubbs <jstubbs@gentoo.org>
Tue, 24 Jan 2006 14:54:31 +0000 (14:54 -0000)
committerJason Stubbs <jstubbs@gentoo.org>
Tue, 24 Jan 2006 14:54:31 +0000 (14:54 -0000)
svn path=/main/trunk/; revision=2578

pym/portage.py
pym/portage_dep.py

index e05d311c58bc7513deb8c6198b659df1ea478ef5..44e4b92600d9c8775ce5a029885c12d1b9a2cfc8 100644 (file)
@@ -3375,26 +3375,6 @@ 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 de5c504ccee45e4d9ab3467f7abdf0db74c5a007..116bb204393948199f26e933ee1ce7b93ea47fa5 100644 (file)
@@ -79,7 +79,11 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
                head = mydeparray.pop(0)
 
                if type(head) == types.ListType:
-                       rlist.append(use_reduce(head, uselist, masklist, matchall, excludeall))
+                       additions = use_reduce(head, uselist, masklist, matchall, excludeall)
+                       if additions:
+                               rlist.append(additions)
+                       elif rlist and rlist[-1] in ("||","&&"):
+                               raise portage_exception.InvalidDependString("INVALID "+rlist[-1]+" DEPEND STRING: "+str(deparray))
 
                else:
                        if head[-1] == "?": # Use reduce next group on fail.
@@ -122,7 +126,9 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
                                if ismatch:
                                        target = newdeparray[-1]
                                        if isinstance(target, list):
-                                               rlist.append(use_reduce(target, uselist, masklist, matchall, excludeall))
+                                               additions = use_reduce(target, uselist, masklist, matchall, excludeall)
+                                               if additions:
+                                                       rlist.append(additions)
                                        else:
                                                rlist += [target]