I already found an improvement for the previous patch, so I 
made a new one against plain cml2-1.9.6.

This one works slightly better for problem (2).  

It makes sure that anything it might rebind the ancestor to
is either a bool or trit. 

thanks,
Richard


On Mon, Dec 10, 2001 at 09:27:22AM +0000, Richard Todd wrote:
> On Sun, Dec 09, 2001 at 03:32:49AM -0500, Eric S. Raymond wrote:
> > 
> > The bug queue is empty.
> 
> I tried it for the first time today, and I definitely like 
> the CML2 tools better than CML1.  I came across two issues
> today, though.  The attached patch appears to fix them
> for me.
> 
> Both issues happen when running with 'Unsuppress' on.
> 1) If you set a tri-state dependent to 'm' while the
>    bool ancestor is 'n,' then it sets the ancestor to
>    'm.'  This is not a valid value for the bool
>    ancestor!
> 
> 2) If a dependent is set to a non-'n' value, while
>    the ancestor is 'n,' it sets the ancestor to 
>    non-'n'.  If you then set another dependent to
>    non-'n,' and then set the first dependent to
>    'n' again, the ancestor moves back to 'n', even
>    though this is not a valid configuration!
> 
>    for instance:
> 
>    SYM1 = n { SYM2 =n  SYM3=n }
> 
>    Set SYM2='y', Sym3='y', SYM2='n', and
>    at the end, SYM1 will be 'n' while SYM3 is 'y'!
>  
> I didn't test it too thoroughly, but the specific
> cases I was looking at (on the AGP, DRM page) 
> were fixed after these changes.

> --- cml2-1.9.6/cmlsystem.py   Sun Dec  9 08:27:31 2001
> +++ cml333/cmlsystem.py       Mon Dec 10 09:06:34 2001
> @@ -210,6 +210,15 @@
>          if listhead:
>              while listhead:
>                  listhead.symbol.bindingstack.remove(listhead)
> +                # if this binding was in the ancestor list of the symbol whose
> +                # bindings are being removed, it may be that another dependent
> +                # has been activated since, and we should move the binding to
> +                # that symbol instead.
> +                if listhead.symbol in symbol.ancestors:
> +                   for dependent in listhead.symbol.dependents:
> +                       if not cml.evaluate(dependent) == cml.n:
> +                           self.__bindsymbol(listhead.symbol, listhead.value, 
>dependent)
> +                           break
>                  listhead = listhead.link
>              del context[symbol]
>              if symbol.menu.type == "choices":
> @@ -593,7 +602,9 @@
>              if dependvalue > ancvalue:
>                  if dependent.type == anctype or not self.trits_enabled:
>                      self.__set_symbol_internal(ancestor, dependvalue,dependent)
> -                elif dependent.type == "trit":
> +                elif anctype == "bool":
> +                    self.__set_symbol_internal(ancestor, cml.y,dependent)
> +                elif ancvalue == cml.n:
>                      self.__set_symbol_internal(ancestor, dependvalue,dependent)
>          # Recurse upwards, first through ancestors... 
>          for upper in ancestor.ancestors:

--- cml2-1.9.6/cmlsystem.py     Sun Dec  9 08:27:31 2001
+++ cml333/cmlsystem.py Mon Dec 10 09:46:47 2001
@@ -210,6 +210,16 @@
         if listhead:
             while listhead:
                 listhead.symbol.bindingstack.remove(listhead)
+                # if this binding was in the ancestor list of the symbol whose
+                # bindings are being removed, it may be that another dependent
+                # has been activated since, and we should move the binding to
+                # that symbol instead.
+                if listhead.symbol in symbol.ancestors:
+                   for dependent in listhead.symbol.dependents:
+                       if not cml.evaluate(dependent) == cml.n and \
+                          (dependent.type == "trit" or dependent.type == "bool"):
+                           self.__bindsymbol(listhead.symbol, listhead.value, 
+dependent)
+                           break
                 listhead = listhead.link
             del context[symbol]
             if symbol.menu.type == "choices":
@@ -593,7 +603,9 @@
             if dependvalue > ancvalue:
                 if dependent.type == anctype or not self.trits_enabled:
                     self.__set_symbol_internal(ancestor, dependvalue,dependent)
-                elif dependent.type == "trit":
+                elif anctype == "bool":
+                    self.__set_symbol_internal(ancestor, cml.y,dependent)
+                elif ancvalue == cml.n:
                     self.__set_symbol_internal(ancestor, dependvalue,dependent)
         # Recurse upwards, first through ancestors... 
         for upper in ancestor.ancestors:

Reply via email to