[BACK]Return to file_scanning.adb CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / System

File: [local] / OpenXM_contrib / PHC / Ada / System / file_scanning.adb (download)

Revision 1.1, Sun Oct 29 17:45:34 2000 UTC (23 years, 7 months ago) by maekawa
Branch point for: MAIN

Initial revision

package body File_Scanning is

  procedure Scan ( file : in file_type; ch : in character;
                   found : out boolean ) is

    c : character;

  begin
    while not End_of_File(file) loop
      get(file,c);
      if c = ch
       then found := true;
            return;
      end if;
    end loop;
    found := false;
  end Scan;

  procedure Scan ( file : in file_type; banner : in string;
                   found : out boolean ) is

    index : natural := banner'first-1;
    ch : character;

  begin
    while not End_of_File(file) loop
      get(file,ch);
      if index < banner'first
       then
         if ch = banner(banner'first)
          then index := banner'first+1;
         end if;
       else
         if ch = banner(index)
          then index := index + 1;
          else index := banner'first-1;
         end if;
      end if;
      exit when index > banner'last;
    end loop;
    if index > banner'last
     then found := true;
     else found := false;
    end if;
  exception
    when others => found := false; return;
  end Scan;

  procedure Scan_and_Skip ( file : in file_type; banner : in string;
                            found : out boolean ) is

    fnd : boolean;

  begin
    Scan(file,banner,fnd);
    if fnd
     then skip_line(file);
    end if;
    found := fnd;
  end Scan_and_Skip;

end File_Scanning;