[net.bugs] Bug in 4.2 BSD Pascal implementation ???

russell@muddcs.UUCP (Russell Shilling) (09/01/84)

[eat this, Sucker !!!]

	Recently I've been trying to write introductory manuals for some
of the languages we have available, and in the process of converting a
Modula-2 program to Pascal I found an (apparent) error in the definition
of the Pascal language (we have 4.2 BSD.)
	It seems that the "read" statement will allow reading past the end
of the current line and on to the next.  Isn't this wrong, (at least as
far as the way the read was supposed to work) ???
	As an example, the following code will not operate correctly
(as I understand the idea of correctness):

program ReadTest(input,output);
  var C: char;
  begin
    repeat
      while not eoln do begin	(* should echo one line of chars *)
        read(C);   write(C);
      end;
      readln(C);	(* supposed to be required to read past *)
      writeln;		(* end-of-line marker, right ???        *)
    until eof;
  end.
  
	This program seems to work fine when you are reading from the 
standard input, but if you redirect input from a file, every other line
is skipped.  Perhaps I'm full of blue mud, but I thought that you could
"read" forever without reading past the end of line.  Can someone explain
either where my misconception of the language definition is, or maybe
verify that this is a legitimate bug ?


-- 

	Russell Shilling

	{ allegra, ihnp4, seismo }!scgvaxd!muddcs!russell
	=====  plplplplplplplplplplplplplplplplplp  =====

hans@log-hb.UUCP (Hans Albertsson) (09/04/84)

[]
read(..); may indeed read past end of line; when actually reading
the eoln-marker, itv returns a blank in its argument. Readln is merely
a convenient way to skip to the next line without knowing how far
the next end-of-line is.
J&W is quite clear on this.

-- 
			{decvax,philabs}!mcvax!enea!log-hb!hans
			Hans Albertsson, 
			TeleLOGIC AB
			Box 1001,
			S-14901 Nynashamn,
			SWEDEN