From 3211bee5956a195168721f7d85737bc6e2ad2a2b Mon Sep 17 00:00:00 2001 From: dos-reis Date: Sun, 6 Nov 2011 04:16:59 +0000 Subject: * interp/c-doc.boot (checkBalance): Fix a latent logic bug. * algebra/Makefile.in: Tidy. --- src/interp/c-doc.boot | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src/interp') diff --git a/src/interp/c-doc.boot b/src/interp/c-doc.boot index 63473e10..c56883af 100644 --- a/src/interp/c-doc.boot +++ b/src/interp/c-doc.boot @@ -1009,23 +1009,20 @@ checkSplitOn(x) == checkBalance u == checkBeginEnd u stack := nil - while u repeat - do - x := first u - closer := scalarTarget(x,$checkPrenAlist) --is it an open bracket? - => stack := [closer,:stack] --yes, push the open bracket - open := rassoc(x,$checkPrenAlist) => --it is a close bracket! - stack is [top,:restStack] => --does corresponding open bracket match? - if open ~= top then --yes: just pop the stack - checkDocError - ['"Mismatch: left ",checkSayBracket top,'" matches right ",checkSayBracket open] - stack := restStack - checkDocError ['"Missing left ",checkSayBracket open] - u := rest u - if stack then + while u is [x,:u] repeat + not char? x => nil + closer := scalarTarget(x,$checkPrenAlist) => --is it an open bracket? + stack := [closer,:stack] --yes, push the open bracket + open := rassoc(x,$checkPrenAlist) => --it is a close bracket! + stack is [top,:restStack] => --does corresponding open bracket match? + x = top => stack := restStack --yes: just pop the stack + checkDocError + ['"Mismatch: left ",checkSayBracket open,'" matches right ",checkSayBracket x] + checkDocError ['"Missing left ",checkSayBracket x] + stack ~= nil => for x in reverse! stack repeat checkDocError ['"Missing right ",checkSayBracket x] - u + nil ++ returns the class of the parenthesis x ++ pren ::= '(' | ')' -- cgit v1.2.3