WILD_MATCH Match wildcard pattern 14-MAR-1994 18:50:04 AMAC V1.8-17-251J Page 1 VER 1.0.0 7-MAR-1994 17:13:50 [TKS0.TKSLEN.AXP_PROGRAMS.FINGER]WILD.MAR;2 00000000 1 .TITLE Wild_Match Match wildcard pattern 00000000 2 .IDENT /VER 1.0.0/ 00000000 3 00000000 4 .LIBRARY /alpha$LIBRARY:LIB/ 00000000 5 00000000 699 $SSDEF 00000000 700 ;++ 00000000 701 ; This routine was copied from the F11B module MATCHNAME of the VMS V3.0 00000000 702 ; microfiche. Thank you, DEC! 00000000 703 ; 00000000 704 ; Wild_Match (pattern.rd, candidate.rd) 00000000 705 ; 00000000 706 ; R0 LBS if candidate matches pattern 00000000 707 ; 00000000 708 ;-- 00000000 709 00000000 710 ; .ENTRY Wild_Match, ^M 00000000 711 Wild_Match:: ?01T 00000002 760 .CALL_ENTRY HOME_ARGS=TRUE,MAX_ARGS=2 00000002 761 ; MOVAB G^LIB$SIG_TO_RET, (FP) 00000002 762 CMPB (AP), S^#2 00000005 763 BGEQ 10$ 00000007 764 00000007 765 MOVZWL #SS$_INSFARG, R0 0000000C 766 RET 0000000D 767 0000000D 768 10$: MOVQ @4(AP), R4 00000011 769 MOVQ @8(AP), R2 00000015 770 MOVZWL R2, R2 00000018 771 MOVZWL R4, R4 0000001B 772 MOVZWL #SS$_NOLOGNAM, R0 00000020 773 CLRL R6 00000022 774 ; 00000022 775 ; Main scanning loop. 00000022 776 ; 00000022 777 20$: DECL R4 ; Pattern exhausted? 00000024 778 BLSS 40$ ; Branch if yes. 00000026 779 MOVZBL (R5)+, R1 ; Get next character in pattern 00000029 780 CMPB R1, #^A/*/ ; Wild string? 0000002C 781 BEQL 70$ ; Branch if yes 0000002E 782 DECL R2 ; Candidate exhausted? 00000030 783 BLSS 60$ ; Branch if yes 00000032 784 CMPB R1, (R3)+ ; Compare pattern with candidate 00000035 785 BEQL 20$ ; Loop if match 00000037 786 CMPB R1, #^A/%/ ; Wild (joker) character? 0000003A 787 BEQL 20$ ; Branch if yes. 0000003C 788 ; 0000003C 789 ; We have detected a mismatch, or we are out of pattern while there is 0000003C 790 ; candidate left. Back up to the last '*', advance a candidate character, 0000003C 791 ; and try again. 0000003C 792 ; 0000003C 793 30$: DECL R6 ; Count a saved candidate char 0000003E 794 BLSS 60$ ; Branch if none saved 00000040 795 INCL R7 ; Set to try next character 00000042 796 MOVQ R6, R2 ; Restore descriptors to backup 00000045 797 MOVQ R8, R4 00000048 798 BRB 20$ ; Continue testing. WILD_MATCH Match wildcard pattern 14-MAR-1994 18:50:04 AMAC V1.8-17-251J Page 2 VER 1.0.0 7-MAR-1994 17:13:50 [TKS0.TKSLEN.AXP_PROGRAMS.FINGER]WILD.MAR;2 0000004A 799 ; 0000004A 800 ; Here when pattern is exhausted. 0000004A 801 ; 0000004A 802 40$: TSTL R2 ; Candidate exhausted? 0000004C 803 BNEQ 30$ ; Branch if no 0000004E 804 ; 0000004E 805 ; Here to return. 0000004E 806 ; 0000004E 807 50$: MOVL S^#1, R0 00000051 808 60$: RET 00000052 809 ; 00000052 810 ; We have detected a '*' in the pattern. Save the descriptors for later 00000052 811 ; backtracking. 00000052 812 ; 00000052 813 70$: TSTL R4 ; Pattern null after '*'? 00000054 814 BEQL 50$ ; Branch if yes 00000056 815 MOVQ R2, R6 ; Save both descriptors 00000059 816 MOVQ R4, R8 0000005C 817 BRB 20$ ; Continue testing. 0000005E 818 0000005E 819 .END