#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==[]:
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.
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]