1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-10-18 07:24:16 +00:00

Match patterns with ending wildcard

This commit is contained in:
David Schmenk 2020-01-10 11:23:25 -08:00
parent 12f8cf8053
commit fb3a4964c8
2 changed files with 9 additions and 5 deletions

Binary file not shown.

View File

@ -6,17 +6,21 @@ var dirbuf
// Match next section of source and expression
//
def matchNext(src, srcofst, exp, expofst)
if ^src >= srcofst and ^exp >= expofst
if ^exp >= expofst
when exp->[expofst]
is '*' // Multi-char wildcard
if matchNext(src, srcofst + 1, exp, expofst + 1)
if matchNext(src, srcofst, exp, expofst + 1) // Match zero wild chars
return TRUE
elsif ^src >= srcofst and matchNext(src, srcofst + 1, exp, expofst) // Match more wild chars
return TRUE
fin
return matchNext(src, srcofst + 1, exp, expofst)
is '?' // Single char wildcard
return matchNext(src, srcofst + 1, exp, expofst + 1)
if ^src >= srcofst
return matchNext(src, srcofst + 1, exp, expofst + 1)
fin
return FALSE
otherwise // verbatim match
if src->[srcofst] == exp->[expofst]
if ^src >= srcofst and src->[srcofst] == exp->[expofst]
return matchNext(src, srcofst + 1, exp, expofst + 1)
fin
return FALSE