Path: utzoo!attcan!uunet!munnari!vuwcomp!windy!srwhmdr From: srwhmdr@windy.dsir.govt.nz (Malcolm Robbins) Newsgroups: comp.os.vms Subject: Bug in VAXTPU searching? (ANY) Message-ID: <1711@windy.dsir.govt.nz> Date: 21 Jul 88 14:03:00 GMT Organization: DSIR, Wellington, NZ Lines: 90 I've either found a bug in VAXTPU when it does a search for an alphabetic character at the beginning of a line or, I lack some understanding about pattern matching. For example if I construct a TPU procedure to do a search for the following pattern I find it occaisionally matches an empty line. LINE_BEGIN & ANY ('ABCDEFGHIJKLMNOPQRSTUVWXYZ') In fact, given that a mismatch occurs, the problem can be restricted to searching for LINE_BEGIN & ANY ('G') say, (assuming that G is what is being matched by accident) and the same thing occurs. Furthermore if I cut the area affected and then repaste it in exactly the same position, so no difference is visible, then the problem disappears!! If, instead, I remove the ANY and search only for: LINE_BEGIN & ANY ('G') VAXTPU behaves correctly (but this is not what I want to do of course). Therefore the function ANY appears to be causing the problem. What I'd like to know is: o Is this problem caused by a lack of understanding on my part or is this a VAXTPU bug? Perhaps the mode of the search (Seek versus incremental) is causing the unexpected, but "valid" behaviour. o How can I do what I intended, which is to search for an alphabetic character at the start of a line, in a reliable way? For those of you who are raised to the challenge here's a sample TPU procedure that shows up the problem. Simply compile it and execute it from the top of a (largish) file with a number of empty lines in it. Hopefully at least one empty line will match in the unexpected way. Any replies would be greatly appreciated. In fact to show my appreciation I'll post a "detab" procedure for removing TABs in a file to this newsgroup shortly. ------------------------------ Cut Here ------------------------------ PROCEDURE any_bug LOCAL pat, rng; pat := LINE_BEGIN & ANY ('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'); LOOP ! ! Ensure we move off current position for multiple calls to any_bug ! MOVE_HORIZONTAL (1); rng := SEARCH (pat, FORWARD, EXACT); EXITIF rng = 0; ! ! If the search is successful move to it and see if an empty line has ! been matched. This should not occur but does. ! IF rng <> 0 THEN POSITION (rng); this_char := CURRENT_CHARACTER; IF this_char = "" THEN MESSAGE ('Here is an invalid match!'); RETURN; ENDIF; ENDIF; ENDLOOP; MESSAGE ('No match found'); ENDPROCEDURE ------------------------------ Cut Here ------------------------------ +-----------------------------------------------------------------------------+ | Malcolm Robbins, | | Department of Scientific and Industrial Research | | New Zealand. | | | | Internet: srwhmdr@wnv.dsir.govt.nz | | Pacnet: PSI%(05301)4600000060::SRWHMDR | +-----------------------------------------------------------------------------+