.TITLE SRDTST TEST FOR MATCH .IDENT -6.6- ; Jun-85 .ENABL LC ; ON ENTRY: ; R1 POINTS TO THE ACTUAL FILE-NAME ; R2 POINTS TO THE MATCH TEMPLATE ; NB: ; THE TEMPLATE IS GUARANTEED TO CONTAIN (AT LEAST) ONE ; FULL STOP AND ONE SEMI-COLON, AND IS TERMINATED BY A NULL. ; ; THE TEMPLATE IS A FILESPEC (NAME.EXT;VER) WITH ANY OF THE ; FOLLOWING SPECIAL CHARACTERS IN IT:- ; % - MATCHES ONE WILDCARD CHARACTER ; ? - SAME AS % ; * - MATCHES ANY NUMBER (INCL 0) OF WILDCARD CHARACTERS ; NOTE THAT ONCE * IS USED, THEN THE TERMINATING CHARACTER OF THE ; TEMPLATE MUST MATCH THAT OF THE FILENAME (UNLESS, OF COURSE, IT IS *) ; THIS MEANS THAT WHILE 'SRD /SE:F??L' WILL MATCH ; FILL ; FIXLE ; FIILXXL ; BUT NOT ; FIL ; FIIIL ; 'SRD /SE:F*L' WILL MATCH ; FL ; FILL ; FILIL ; BUT NOT ; FILE ; FLLLX ; THESE WILDCARDS CAN BE COMBINED IN ANY VARIETY, SO THAT ; 'SRD /SE:S?V*X*Y' WILL MATCH ALL NAMES WHICH START WITH ; S, END WITH Y, HAVE A V AS THE 3RD CHARACTER AND AN X ; SOMEWHERE AFTER THE THIRD CHARACTER. ; ; modifications: ; ; CEF001 Carl Friedberg 1-June-83 add Psects ; ; ; 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). ; ;= ; ; RETURNS SUCCESS OR FAILURE INDICATOR IN THE 'C'-BIT ; .PSECT SRDATA,RW,D,LCL,REL,CON ;CEF001 WIFLAG: .BLKB ; Flag indicating /WI or (/WD and (/DE or /SD)) ;WG6.6 TERMRS: .ASCIZ \.;\ ; FILE-NAME FIELD TERMINATORS ;**-1 .EVEN .PSECT SRDCOD,RO,I,LCL,REL,CON ;CEF001 SRDTST:: MOV R1,-(SP) ;SAVE THE REGISTERS THAT WE WILL USE MOV R2,-(SP) ;(GOOD CODING PRACTICE, IF RATHER TOO MOV R3,-(SP) ; MUCH LIKE HARD WORK FOR THE AVERAGE MOV R4,-(SP) ; [WHERE AVERAGE=MEAN] PROGRAMMER). MOV R5,-(SP) ; MOV #TERMRS,R5 ; CLRB WIFLAG ; Clear flag for automatic wildcarding ;WG6.6 BIT #WISW,SWMS2$ ; Was /WI specified? ;WG6.6 BEQ 20$ ; EQ - no ;WG6.6 BIT #WDSW,SWMS2$ ; Was /WD also specified? ;WG6.6 BNE 10$ ; NE - yes ;WG6.6 BIT #,SWMSK$ ; Was /DE or /SD specified? ;WG6.6 BNE 20$ ; NE - yes ;WG6.6 10$: INCB WIFLAG ; Set for automatic wildcarding ;WG6.6 20$: CALL MATCHP ; Match from current position to next terminator;WG6.6 BCS 30$ ; CS - failed to match (C-bit is left set) ;WG6.6 TSTB (R5)+ ; Was this the last terminator (null)? ;WG6.6 ; Note: TSTB clears the C-bit ;WG6.6 BNE 20$ ; NE - no, process next part of name ;WG6.6 30$: ; Return success or failure ;WG6.6 MOV (SP)+,R5 ; ;**-2 MOV (SP)+,R4 ;> N.B. A COMPLEX PROBLEM IS ONE WHICH MOV (SP)+,R3 ;>> CONTAINS BOTH REAL AND IMAGINARY MOV (SP)+,R2 ;>>> DIFFICULTIES... MOV (SP)+,R1 ;>>>> RETURN ;---> ALL DONE - GO HOME TO MOTHER. ; ; ;WG6.6 ; ;WG6.6 ; Match from the current position to the next terminator ;WG6.6 ; ;WG6.6 MATCHP: ;WG6.6 MOVB (R2)+,R4 ; Get character from match template ;WG6.6 CMPB R4,#'* ; Is it a '*'? (wild string character) ;WG6.6 BNE 60$ ; NE - no, proceed ;WG6.6 ; Wild card character is in match template ;WG6.6 10$: ;WG6.6 MOVB (R2)+,R4 ; Get next character from match template ;WG6.6 CMPB R4,#'* ; Is it another '*'? ;WG6.6 BEQ 10$ ; EQ - yes, ignore it ;WG6.6 CMPB R4,(R5) ; Is it the terminator? ;WG6.6 BEQ TOTERM ; EQ - yes, we match rest of this part of name ;WG6.6 TSTB -(R2) ; Restore match template pointer ;WG6.6 MOV R2,-(SP) ; Save current position in match template ;WG6.6 MOV R1,-(SP) ; Save current position in file name string ;WG6.6 20$: CALL MATCHP ; Try to match rest of this part of file name ;WG6.6 BCC 30$ ; CC - matched successfully ;WG6.6 INC (SP) ; Advance one character in file name string ;WG6.6 MOV (SP),R1 ; Point to new position in file name string ;WG6.6 MOV 2(SP),R2 ; Restore position in match template ;WG6.6 CMPB (R1),(R5) ; Are we at the terminator in the file name? ;WG6.6 BNE 20$ ; NE - no, try to match starting at new position;WG6.6 ; There are no more characters left in the file name ;WG6.6 CMP (SP)+,(SP)+ ; Tidy the stack ;WG6.6 BR FAIL ; Indicate failure ;WG6.6 ; Successfully matched rest of this part of the file name ;WG6.6 30$: CMP (SP)+,(SP)+ ; Tidy the stack ;WG6.6 BR SUCCES ; Indicate success ;WG6.6 ; Not a wild card - try normal matching ;WG6.6 60$: MOVB (R1)+,R3 ; Get character from file name string ;WG6.6 CMPB R3,#<' > ; Is it a blank? ;WG6.6 BEQ 60$ ; EQ - yes, skip over all blanks ;WG6.6 CMPB R4,(R5) ; Are we at the terminator in match template? ;WG6.6 BNE 80$ ; NE - no ;WG6.6 ; At terminator in the match template ;WG6.6 CMPB R3,(R5) ; Are we also at the terminator in file name? ;WG6.6 BEQ SUCCES ; EQ - yes, a successful match ;WG6.6 TSTB WIFLAG ; Do we have the wildcard switch condition? ;WG6.6 BNE TOTERM ; NE - yes, rest of this part matches ;WG6.6 BR FAIL ; Indicate failure ;WG6.6 ; Not yet at terminator in the match template ;WG6.6 80$: CMPB R3,(R5) ; Are we at the terminator in the file name? ;WG6.6 BEQ FAIL ; EQ - yes, a match failure ;WG6.6 CMPB R3,R4 ; Does file name char. match template char.? ;WG6.6 BEQ MATCHP ; EQ - yes, proceed matching with next chars. ;WG6.6 CMPB R4,#'% ; Is the template character a joker ('%')? ;WG6.6 BEQ MATCHP ; EQ - yes, proceed matching with next chars. ;WG6.6 CMPB R4,#'? ; Is the template character other joker ('?')? ;WG6.6 BEQ MATCHP ; EQ - yes, proceed matching with next chars. ;WG6.6 FAIL: SEC ; Indicate match failure ;WG6.6 RETURN ;WG6.6 TOTERM: ;WG6.6 ; We have not gone beyond the terminator (i.e. R3 does not contain terminator);WG6.6 5$: CMPB (R1)+,(R5) ; Advance to the terminator in file name ;WG6.6 BNE 5$ ; ;WG6.6 SUCCES: CLC ; Indicate successful match ;WG6.6 RETURN ;WG6.6 ; ;WG6.6 .END ;WG6.6