diff --git a/tconfpy.py b/tconfpy.py index 9610206..bbeecc7 100755 --- a/tconfpy.py +++ b/tconfpy.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "tconfpy" -RCSID = "$Id: tconfpy.py,v 2.103 2005/01/14 08:30:49 tundra Exp $" +RCSID = "$Id: tconfpy.py,v 2.104 2005/01/14 09:54:16 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -597,7 +597,7 @@ # Dereference Variables ########## -def DerefVar(line, cfgfile, linenum, reporterr=True): +def DerefVar(line, cfgfile, linenum, RetBoolState=False): # Find all symbols refrences and replace w/sym table entry if present @@ -646,8 +646,31 @@ DebugMsg("dVARREF", (cfgfile, linenum, var, envvar)) # Handle variables in symbol table + + # The RetBoolState API flag here means that we want to + # replace references like [BooleanVar] based on the + # *state* of the variable. This is used by the conditional + # logic for .ifall/any/none to allow logical conditions like + # + # .ifall [Bool1] [Bool2] + # + # In this case, if the boolean is True, we return the name of + # the boolean to make the existential test True. Otherwise we + # replace the reference with the name of a variable than can + # never exist - it has a malformed name. This will cause the + # existential test count of found variables to change and + # affect the final logical outcome. + elif sym in SymTable.Symbols: symval = str(SymTable.Symbols[sym].Value) + + if RetBoolState and (SymTable.Symbols[sym].Type == TYPE_BOOL): + + if symval == sTRUE: + symval = sym + else: + symval = IllegalChars[0] + line = line.replace(var, symval) if SymTable.DEBUG: @@ -655,18 +678,9 @@ # Reference to undefined variable + else: - # There are times a reference to an undefined variable - # should not produce and error message. For example, - # during existential conditional processing, we just - # want to check whether variables are defined or not. - # Attempts to reference undefined variables are legitimate - # in this case and ought not to generate an error message. - - - if reporterr: - ErrorMsg("eVARUNDEF", (cfgfile, linenum, sym)) - + ErrorMsg("eVARUNDEF", (cfgfile, linenum, sym)) ref_ok = False return line, ref_ok @@ -969,8 +983,8 @@ # Dereference any variables - line, ref_ok = DerefVar(line, cfgfile, linenum) - + line, ref_ok = DerefVar(line, cfgfile, linenum, RetBoolState=True) + if ref_ok: vars = line.split()