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 - metrics - download
Index: B T

⟦192b42cc7⟧ TextFile

    Length: 3663 (0xe4f)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

with String_Utilities;

separate (Tar)
package body Naming is

    Wild_Cards : constant String := "?@*";

    function Is_Wild_Card (C : Character) return Boolean is
    begin
        for I in Wild_Cards'Range loop
            if C = Wild_Cards (I) then
                return True;
            end if;
        end loop;
        return False;
    end Is_Wild_Card;

    function To_Rational_Name (Unix_Name : String) return String is

        Uname : constant String := Unix_Name;
        U : Natural := Uname'First;
        Rname : String (1 .. Uname'Length + 2);
        R : Natural := Rname'First;

        procedure Put (S : String) is
        begin
            Rname (R .. R + S'Length - 1) := S;
            R := R + S'Length;
        end Put;

    begin
        if Uname (U) = '/' then
            Put ("!");
            U := U + 1;
        elsif Uname (U .. U + 1) = "./" then
            Put ("$");
            U := U + 2;
        else
            Put ("$");
        end if;

        case Uname (U) is
            when '0' .. '9' =>
                Put ("AA_");
            when '_' | '.' =>
                Put ("AA");
            when others =>
                null;
        end case;

        for I in U .. Uname'Last loop
            if Uname (I) = '/' then
                Put ("_"); -- kludge, should be "."
            elsif Uname (I) = '.' then
                Put ("_");
            elsif Uname (I) = '^' then
                null;
            else
                Put (Uname (I .. I));
            end if;
        end loop;

        case Uname (Uname'Last) is
            when '_' | '.' =>
                Put ("ZZ");  
            when others =>
                null;
        end case;

        return Rname (Rname'First .. R - 1);
    end To_Rational_Name;

    function To_Unix_Name (Rational_Name : String) return String is
        First : Natural := Rational_Name'Last;
    begin
        while First >= Rational_Name'First loop
            case Rational_Name (First) is
                when '.' | ']' | '`' | '!' | '$' | '\' | '^' =>
                    exit;
                when others =>
                    First := First - 1;
            end case;
        end loop;
        return Rational_Name (First + 1 .. Rational_Name'Last);
    end To_Unix_Name;

    function Matches (Name, Template : String) return Boolean is
        Uname : constant String := String_Utilities.Upper_Case (Name);
        Utemp : constant String := String_Utilities.Upper_Case (Template);
        Matched : Natural := 0;
    begin
        for I in Utemp'Range loop
            Matched := I - Utemp'First;
            if Matched >= Uname'Length then
                -- the party's over.
                for J in I .. Utemp'Last loop
                    if not Is_Wild_Card (Utemp (J)) then
                        return False;
                    end if;
                end loop;
                return True;
            elsif Is_Wild_Card (Utemp (I)) then
                -- The wild card replaces 0 or more characters.
                -- Try each of the possibilities.
                for J in Uname'First + Matched .. Uname'Last + 1 loop
                    if Matches (Uname (J .. Uname'Last),
                                Utemp (I + 1 .. Utemp'Last)) then
                        return True;
                    end if;
                end loop;
                return False;
            elsif Utemp (I) /= Uname (Uname'First + (I - Utemp'First)) then
                return False; -- mismatch
            end if;
        end loop;
        -- no wild cards, no mismatches:
        return (Uname'Length = Utemp'Length);
    end Matches;

end Naming;