DEFINITION MODULE WildCard;

        (********************************************************)
        (*                                                      *)
        (*            String matching with wildcards            *)
        (*                                                      *)
        (*  Programmer:         P. Moylan                       *)
        (*  Started:            8 June 1999                     *)
        (*  Last edited:        26 March 2003                   *)
        (*  Status:             WildMatch OK                    *)
        (*                      Now working on WildMatchS       *)
        (*                                                      *)
        (********************************************************)


TYPE CharSet = SET OF CHAR;

PROCEDURE WildMatch (VAR (*IN*) input, template: ARRAY OF CHAR): BOOLEAN;

    (* Returns TRUE if template and input are equal, with the extra     *)
    (* rules:                                                           *)
    (*   1. Character case is not significant.                          *)
    (*   2. A '?' in template matches any single character.             *)
    (*   3. A '*' in template matches any string of zero or more        *)
    (*      characters.                                                 *)

PROCEDURE WildMatchS (VAR (*IN*) input, template: ARRAY OF CHAR;
                                              Stoppers: CharSet): BOOLEAN;

    (* Like WildMatch, with the additional rule that '%' is a wildcard  *)
    (* character that matches any string (of zero or more characters)   *)
    (* that does not contain any character in Stoppers.                 *)

END WildCard.

