; This file updates SRDTST.MAC;1 from SRD V6.5 to SRDTST.MAC;2 for SRD V6.6. SRDTST.MAC;2/AU=SRDTST.MAC;1 \ -/.IDENT/,. .IDENT -6.6- ; Jun-85 -/;=/,. ; ; Version 6.6 - 12-Jun-85 (;WG6.6) ; ; SRD Working Group ; ; Rewrote most of the routine, making the logic easier to ; follow, while fixing a bug which ignored /WI when a '*' ; was given in the match template (e.g. AB*D failed to match ; ABCDE). ; ;= % -,,/;WG6.6/ -/WLDFLG:/,. WIFLAG: .BLKB ; Flag indicating /WI or (/WD and (/DE or /SD)) -/SRDTST::/ -/CLRB...WLDFLG/,/CALL...MATCH0/ CLRB WIFLAG ; Clear flag for automatic wildcarding BIT #WISW,SWMS2$ ; Was /WI specified? BEQ 20$ ; EQ - no BIT #WDSW,SWMS2$ ; Was /WD also specified? BNE 10$ ; NE - yes BIT #,SWMSK$ ; Was /DE or /SD specified? BNE 20$ ; NE - yes 10$: INCB WIFLAG ; Set for automatic wildcarding 20$: CALL MATCHP ; Match from current position to next terminator BCS 30$ ; CS - failed to match (C-bit is left set) TSTB (R5)+ ; Was this the last terminator (null)? ; Note: TSTB clears the C-bit BNE 20$ ; NE - no, process next part of name 30$: ; Return success or failure -/MATCH0:/,/.END/ ; ; ; Match from the current position to the next terminator ; MATCHP: MOVB (R2)+,R4 ; Get character from match template CMPB R4,#'* ; Is it a '*'? (wild string character) BNE 60$ ; NE - no, proceed ; Wild card character is in match template 10$: MOVB (R2)+,R4 ; Get next character from match template CMPB R4,#'* ; Is it another '*'? BEQ 10$ ; EQ - yes, ignore it CMPB R4,(R5) ; Is it the terminator? BEQ TOTERM ; EQ - yes, we match rest of this part of name TSTB -(R2) ; Restore match template pointer MOV R2,-(SP) ; Save current position in match template MOV R1,-(SP) ; Save current position in file name string 20$: CALL MATCHP ; Try to match rest of this part of file name BCC 30$ ; CC - matched successfully INC (SP) ; Advance one character in file name string MOV (SP),R1 ; Point to new position in file name string MOV 2(SP),R2 ; Restore position in match template CMPB (R1),(R5) ; Are we at the terminator in the file name? BNE 20$ ; NE - no, try to match starting at new position ; There are no more characters left in the file name CMP (SP)+,(SP)+ ; Tidy the stack BR FAIL ; Indicate failure ; Successfully matched rest of this part of the file name 30$: CMP (SP)+,(SP)+ ; Tidy the stack BR SUCCES ; Indicate success ; Not a wild card - try normal matching 60$: MOVB (R1)+,R3 ; Get character from file name string CMPB R3,#<' > ; Is it a blank? BEQ 60$ ; EQ - yes, skip over all blanks CMPB R4,(R5) ; Are we at the terminator in match template? BNE 80$ ; NE - no ; At terminator in the match template CMPB R3,(R5) ; Are we also at the terminator in file name? BEQ SUCCES ; EQ - yes, a successful match TSTB WIFLAG ; Do we have the wildcard switch condition? BNE TOTERM ; NE - yes, rest of this part matches BR FAIL ; Indicate failure ; Not yet at terminator in the match template 80$: CMPB R3,(R5) ; Are we at the terminator in the file name? BEQ FAIL ; EQ - yes, a match failure CMPB R3,R4 ; Does file name char. match template char.? BEQ MATCHP ; EQ - yes, proceed matching with next chars. CMPB R4,#'% ; Is the template character a joker ('%')? BEQ MATCHP ; EQ - yes, proceed matching with next chars. CMPB R4,#'? ; Is the template character other joker ('?')? BEQ MATCHP ; EQ - yes, proceed matching with next chars. FAIL: SEC ; Indicate match failure RETURN TOTERM: ; We have not gone beyond the terminator (i.e. R3 does not contain terminator) 5$: CMPB (R1)+,(R5) ; Advance to the terminator in file name BNE 5$ ; SUCCES: CLC ; Indicate successful match RETURN ; .END /