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

Annotation of OpenXM_contrib/PHC/Ada/System/file_scanning.adb, Revision 1.1.1.1

1.1       maekawa     1: package body File_Scanning is
                      2:
                      3:   procedure Scan ( file : in file_type; ch : in character;
                      4:                    found : out boolean ) is
                      5:
                      6:     c : character;
                      7:
                      8:   begin
                      9:     while not End_of_File(file) loop
                     10:       get(file,c);
                     11:       if c = ch
                     12:        then found := true;
                     13:             return;
                     14:       end if;
                     15:     end loop;
                     16:     found := false;
                     17:   end Scan;
                     18:
                     19:   procedure Scan ( file : in file_type; banner : in string;
                     20:                    found : out boolean ) is
                     21:
                     22:     index : natural := banner'first-1;
                     23:     ch : character;
                     24:
                     25:   begin
                     26:     while not End_of_File(file) loop
                     27:       get(file,ch);
                     28:       if index < banner'first
                     29:        then
                     30:          if ch = banner(banner'first)
                     31:           then index := banner'first+1;
                     32:          end if;
                     33:        else
                     34:          if ch = banner(index)
                     35:           then index := index + 1;
                     36:           else index := banner'first-1;
                     37:          end if;
                     38:       end if;
                     39:       exit when index > banner'last;
                     40:     end loop;
                     41:     if index > banner'last
                     42:      then found := true;
                     43:      else found := false;
                     44:     end if;
                     45:   exception
                     46:     when others => found := false; return;
                     47:   end Scan;
                     48:
                     49:   procedure Scan_and_Skip ( file : in file_type; banner : in string;
                     50:                             found : out boolean ) is
                     51:
                     52:     fnd : boolean;
                     53:
                     54:   begin
                     55:     Scan(file,banner,fnd);
                     56:     if fnd
                     57:      then skip_line(file);
                     58:     end if;
                     59:     found := fnd;
                     60:   end Scan_and_Skip;
                     61:
                     62: end File_Scanning;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>