DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ B T

⟦63f8d580e⟧ TextFile

    Length: 4661 (0x1235)
    Types: TextFile
    Names: »B«

Derivation

└─⟦149519bd4⟧ Bits:30000546 8mm tape, Rational 1000, !projects 93-07-13
    └─ ⟦124ff5788⟧ »DATA« 
        └─⟦this⟧ 
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
    └─ ⟦129cab021⟧ »DATA« 
        └─⟦this⟧ 
└─⟦f64eaa120⟧ Bits:30000752 8mm tape, Rational 1000, !projects 93 02 16
    └─ ⟦6f12a12be⟧ »DATA« 
        └─⟦this⟧ 
└─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04
    └─ ⟦d65440be7⟧ »DATA« 
        └─⟦this⟧ 

TextFile

-------------------------------------------------------------------------------
with String_Run;

package body Wild_String is

    ---------------------------------------------------------------------------
    function Is_With_Wildcards (Word : String) return Boolean is

    begin
        for I in Word'Range loop  
            case (Word (I)) is  
                when Wildcard.Pound_Sign =>
                    return True;
                when Wildcard.At_Sign =>
                    return True;  
                when Wildcard.Question_Mark =>
                    return True;
                when others =>
                    null;
            end case;
        end loop;  
        return False;
    end Is_With_Wildcards;

    ---------------------------------------------------------------------------
    function At_Sign_At_End (Iter : String_Run.Iterator) return Boolean is

    begin
        if (String_Run.Value (Iter) = Wildcard.At_Sign) then
            return String_Run.Next_Done (Iter);
        else
            return False;
        end if;
    end At_Sign_At_End;

    ---------------------------------------------------------------------------
    function Is_Wild_Equal (Left, Right : String) return Boolean is
        Iter_Left  : String_Run.Iterator;
        Iter_Right : String_Run.Iterator;
        Find       : Boolean;

    begin  
        String_Run.Init (Iter_Left, Left);
        String_Run.Init (Iter_Right, Right);

        loop
            if (String_Run.Done (Iter_Left) and
                String_Run.Done (Iter_Right)) then  
                return True;
            end if;

            if (String_Run.Done (Iter_Left)) then
                return At_Sign_At_End (Iter_Right);
            end if;

            if (String_Run.Done (Iter_Right)) then
                return At_Sign_At_End (Iter_Left);
            end if;

            case (String_Run.Value (Iter_Left)) is
                when Wildcard.Pound_Sign =>
                    String_Run.Next (Iter_Left);
                    String_Run.Next (Iter_Right);
                when Wildcard.At_Sign =>
                    if (String_Run.Next_Done (Iter_Left)) then
                        return True;
                    else  
                        Find := False;
                        for I in String_Run.Current_Index (Iter_Right) ..
                                    Right'Length loop
                            Find := True;  
                            exit when Is_Wild_Equal
                                         (String_Run.Rest (Iter_Left),
                                          String_Run.Cut (Iter_Right, I));
                            Find := False;
                        end loop;
                        return Find;
                    end if;
                when Wildcard.Question_Mark =>
                    if (String_Run.Next_Done (Iter_Left)) then
                        return (not String_Run.Done (Iter_Right));
                    else  
                        Find := False;
                        for I in String_Run.Current_Index (Iter_Right) + 1 ..
                                    Right'Length loop
                            Find := True;
                            exit when Is_Wild_Equal
                                         (String_Run.Rest (Iter_Left),
                                          String_Run.Cut (Iter_Right, I));
                            Find := False;
                        end loop;
                        return Find;
                    end if;

                when others =>
                    if (String_Run.Value (Iter_Left) /=
                        String_Run.Value (Iter_Right)) then
                        return False;
                    end if;
                    String_Run.Next (Iter_Left);
                    String_Run.Next (Iter_Right);
            end case;  
        end loop;

    end Is_Wild_Equal;

    ---------------------------------------------------------------------------
    function Is_Equal (Left, Right : String) return Boolean is
        Left_Wild  : Boolean;
        Right_Wild : Boolean;

    begin  
        Left_Wild  := Is_With_Wildcards (Left);
        Right_Wild := Is_With_Wildcards (Right);

        if (Left_Wild and Right_Wild) then
            raise Invalid_Argument_Error;
        end if;

        if (Left_Wild) then
            return Is_Wild_Equal (Left, Right);
        end if;

        if (Right_Wild) then
            return Is_Wild_Equal (Right, Left);
        end if;

        return Left = Right;

    end Is_Equal;

end Wild_String;
-------------------------------------------------------------------------------