summaryrefslogtreecommitdiff
path: root/gcc/m2/gm2-libs-iso/TextUtil.mod
blob: 6f6c02e68b12eea036f9e51e82245bcff59324fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
IMPLEMENTATION MODULE TextUtil ;

IMPORT IOChan, CharClass, IOConsts ;

(*
   SkipSpaces - skips any spaces.
*)

PROCEDURE SkipSpaces (cid: IOChan.ChanId) ;
VAR
   ch : CHAR ;
   res: IOConsts.ReadResults ;
BEGIN
   WHILE CharAvailable (cid) DO
      IOChan.Look (cid, ch, res) ;
      IF (res = IOConsts.allRight) AND CharClass.IsWhiteSpace (ch)
      THEN
         IOChan.Skip (cid)
      ELSE
         RETURN
      END
   END
END SkipSpaces ;


(* The following procedures do not read past line marks.  *)

PROCEDURE CharAvailable (cid: IOChan.ChanId) : BOOLEAN ;
BEGIN
   RETURN( (IOChan.ReadResult (cid) = IOConsts.notKnown) OR
           (IOChan.ReadResult (cid) = IOConsts.allRight) )
END CharAvailable ;


PROCEDURE EofOrEoln (cid: IOChan.ChanId) : BOOLEAN ;
BEGIN
   RETURN( (IOChan.ReadResult (cid) = IOConsts.endOfLine) OR
           (IOChan.ReadResult (cid) = IOConsts.endOfInput) )
END EofOrEoln ;


END TextUtil.