diff --git a/tconfpy.py b/tconfpy.py index 2f4742e..bd1408b 100755 --- a/tconfpy.py +++ b/tconfpy.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "tconfpy" -RCSID = "$Id: tconfpy.py,v 1.130 2004/03/22 17:56:10 tundra Exp $" +RCSID = "$Id: tconfpy.py,v 1.131 2004/03/24 08:47:55 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -231,6 +231,7 @@ Messages["eENDIFEXTRA"] = FILENUM + "'" + ENDIF + "' Without Matching Condition" Messages["eENDIFMISS"] = FILENUM + "Missing %d" + " '%s' " % ENDIF + " Statement(s)" Messages["eEQUIVEXTRA"] = FILENUM + "Only a single '%s' Or '%s' Operator Permitted" % (EQUIV, NOTEQUIV) +Messages["eIFEXTRATXT"] = FILENUM + "Extra Text On Line. '%s' Only Accepts Variable References As Arguments" Messages["eVARUNDEF"] = FILENUM + "Attempt To Reference Undefined Variable '%s'" @@ -246,7 +247,6 @@ Messages["wENDLITMISS"] = FILENUM + "Missing '%s' Statement. All lines treated literally to end-of-file" % ENDLITERAL Messages["wENDLITEXTRA"] = FILENUM + "'%s' Statement Without Preceding '%s'. Statement Ignored" % (ENDLITERAL, LITERAL) -Messages["wEXTRATEXT"] = FILENUM + " '%s' Statements Only Process Variables. Extra Text Ignored" Messages["wLITEXTRA"] = FILENUM + "Already In A Literal Block. '%s' Statement Ignored" % LITERAL @@ -356,7 +356,7 @@ WarnMsgs = [] LiteralLines = [] - CondStack = [True,] + CondStack = [True,] # Always has one entry as a sentinel TotalLines = 0 # Add any passed symbols to the SymbolTable @@ -560,7 +560,7 @@ # Error, if there are more .endifs than conditionals if not CondStack: ErrorMsg("eENDIFEXTRA", (cfgfile, linenum)) - CondStack.append(False) # Inhibit further parsing + CondStack.append(False) # Restore sentinel & inhibit further parsing ##### # Check State Of Parser @@ -583,7 +583,6 @@ if ref_ok: ParseFile(line, cfgfile, linenum) - ##### # Conditional Processing # @@ -632,29 +631,34 @@ for v in vars: plain=plain.replace(v, "") + # Only arguments that are allowed are variable references if len(plain.strip()): - WarningMsg("wEXTRATEXT", (cfgfile, linenum, FIRSTTOK)) - + ErrorMsg("eIFEXTRATXT", (cfgfile, linenum, FIRSTTOK)) + condstate = False + if vars: - # Go see how many references actually resolve - - resolved = 0 - for v in vars: - v, ref_ok = DerefVar(v, cfgfile, linenum, reporterr=False) - if ref_ok: - resolved += 1 + # Only do this if the syntax check above was OK + if condstate: - # And set the conditional state accordingly + # Go see how many references actually resolve - if FIRSTTOK == IFALL and len(vars) != resolved: - condstate = False + resolved = 0 + for v in vars: + v, ref_ok = DerefVar(v, cfgfile, linenum, reporterr=False) + if ref_ok: + resolved += 1 - if FIRSTTOK == IFANY and not resolved: - condstate = False + # And set the conditional state accordingly - if FIRSTTOK == IFNONE and resolved: - condstate = False + if FIRSTTOK == IFALL and len(vars) != resolved: + condstate = False + + if FIRSTTOK == IFANY and not resolved: + condstate = False + + if FIRSTTOK == IFNONE and resolved: + condstate = False # Bogus conditional syntax - no variable refs found else: @@ -757,7 +761,7 @@ # it because any problems with these directives have already been # handled. - elif FIRSTTOK not in (ENDIF, INCLUDE): + elif line != ENDIF and FIRSTTOK != INCLUDE: ErrorMsg("eBADSYNTAX", (cfgfile, linenum))