🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.pascal
Article #94

Re: Bug in 4.2 BSD Pascal implementation ???

#94
From: Neil Faiman ~ ZKO2-3/N30 ~ 381-2...
Date: Sun, 02 Sep 1984 21:06
32 lines
1795 bytes
/////

> 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.

The Pascal procedure to advance to the next line is "Readln", with no
parameter.  "Readln(C)" is equivalent to "Read(C); Readln", which in
turn is equivalent to "C:=Input^; Get(Input); Readln(Input)".  This
assigns the space character to C (Input^ = ' ' when Eoln(Input) is true).
The Get advances over the end-of-line condition (Get will advance to the
next line, just like Readln, when Eoln is true).  And finally, the Readln
advances to the NEXT line.  Presto -- you just skipped over an input line.
So, it's not a compiler bug.

	-Neil Faiman

USENET:    ...{ucbvax,allegra,decvax}!decwrl!dec-rhea!dec-eludom!faiman
ARPA:      FAIMAN%ELUDOM.DEC@DECWRL.ARPA
DEC:       ELUDOM::FAIMAN
Technical Details
Message-ID: <3503@decwrl.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!linus!decvax!decwrl!dec-rhea!dec-eludom!faiman

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site decwrl.UUCP
Path: arc1-ca.pugleaf.net!utzoo!linus!decvax!decwrl!dec-rhea!dec-eludom!faiman
From: faiman@eludom.DEC (Neil Faiman ~ ZKO2-3/N30 ~ 381-2017)
Newsgroups: net.lang.pascal
Subject: Re: Bug in 4.2 BSD Pascal implementation ???
Message-ID: <3503@decwrl.UUCP>
Date: Sun, 2-Sep-84 17:06:49 EDT
Article-I.D.: decwrl.3503
Posted: Sun Sep  2 17:06:49 1984
Date-Received: Thu, 13-Sep-84 04:43:41 EDT
Sender: daemon@decwrl.UUCP
Organization: DEC Engineering Network
Lines: 32