MODULE; IMPORT Buf, Marker, Wx, Wr, Thread; VAR special := ARRAY CHAR OF BOOLEAN { FALSE, .. }; PROCEDURE CMarkUp Annotate (buf: Buf.T; wx: Wx.T; ins: Marker.LineInsertion) RAISES {Wr.Failure, Thread.Alerted} = VAR c: CHAR; line := 1; BEGIN wx.put ("<PRE>\n"); GenInserts (wx, ins, line); FOR i := 0 TO LAST (buf^) DO c := buf[i]; IF NOT special[c] THEN wx.putChar (c); ELSIF (c = '<') THEN wx.put ("<"); ELSIF (c = '>') THEN wx.put (">"); ELSIF (c = '&') THEN wx.put ("&"); ELSIF (c = '"') THEN wx.put ("""); ELSIF (c = '\n') THEN wx.putChar ('\n'); INC (line); GenInserts (wx, ins, line); ELSE (*skip*) END; END; wx.put ("\n"); GenInserts (wx, ins, LAST (INTEGER)); wx.put ("</PRE>\n"); END Annotate; PROCEDUREGenInserts (wx: Wx.T; ins: Marker.LineInsertion; line: INTEGER) RAISES {Wr.Failure, Thread.Alerted} = BEGIN WHILE (ins # NIL) AND (ins.line < line) DO wx.put (ins.insert); ins := ins.next; END; END GenInserts; BEGIN special ['\n'] := TRUE; special ['<'] := TRUE; special ['>'] := TRUE; special ['&'] := TRUE; special ['"'] := TRUE; special ['\000'] := TRUE; END CMarkUp.