EOL Wizard

Just a small problem that popped up at the Modula-2 Google Mailing list: how to process EOL (End Of Line) markers between different operating systems. So I created eolwiz: EOL Wizard. Here's the first attempt at it:

MODULE eolwiz;

(* eolwiz = EOL wizard, handles all end-of-line markers 

 version	date		does
 -------        --------	----------------------------
   01		15.03.09	count lines
   
*)

IMPORT	InOut, Arguments;

CONST	CR	= 15C;
	LF	= 12C;
	TAB	= 11C;

VAR	lines, crs, lfs		: CARDINAL;
	ch			: CHAR;
	hitEOL			: BOOLEAN;


PROCEDURE Summ (l, c, f);

BEGIN
  InOut.WriteString ("Processing done.");					InOut.WriteLn;
  InOut.WriteString ("Lines : ");		InOut.WriteCard (l, 6); 	InOut.WriteLn;
  InOut.WriteString ("cr's  : ");		InOut.WriteCard (c, 6); 	InOut.WriteLn;
  InOut.WriteString ("lf's  : ");		InOut.WriteCard (f, 6); 	InOut.WriteLn;
  InOut.WriteString ("Thanks for using EolWiz");				InOut.WriteLn
END Summ;


BEGIN
  lines := 0;		crs := 0;		lfs := 0;
  hitEOL := FALSE;
  LOOP
    IF  InOut.EOF ()  THEN  EXIT  END;
    InOut.Read (ch);
    IF  (ch = LF)  OR  (ch = CR)  THEN  
      IF  NOT hitEOL  THEN  INC (lines)  END;
      hitEOL := TRUE;
      IF  ch = LF  THEN  INC (lfs)  ELSE  INC (crs)  END
    END;
    IF  (ch >= ' ') OR (ch = TAB) THEN  hitEOL := FALSE  END
  END;
  Summ (lines, crs, lfs)
END eolwiz.
   
The program relies on piped data, i.e. it just reads its source data from the console. Hence the commandline is something like
jan@nitrogen ~/Modula/eol$ eolwiz <~/Oberon/texts/Oberon.Texts.Mod     
Processing done.
Lines :   1206
cr's  :   1293
lf's  :      1
Thanks for using EolWiz
   
This is a typical Oberon OS source file. Oberon uses CR as EOL. Unix uses LF:
jan@nitrogen ~/Modula/eol$ eolwiz <eolwiz.mod
Processing done.
Lines :     48
cr's  :      0
lf's  :     65
Thanks for using EolWiz
   
as you can clearly see.

Page created 11 March 2015 and