[Oberon] Newlines and Carriage-Returns

Jörg joerg.straube at iaeth.ch
Mon Jan 7 12:05:53 CET 2019


Your mentioned change in Texts was originated by me. I pointed out to NW that it is just superfluous code that got cleaned up now.
Has nothing to do with Scan.

Both lines
(a)   WHILE ~S.eot & (ch <= " ") DO .. END;
(b)   WHILE (ch = " ") OR (ch = TAB) OR (ch = CR) DO .. END;
will not hang the system. (b) will not hang due to the fact that ch = 0X if S.eot is TRUE.

(a) has the beauty that it's shorter and will "swallow" the LF as well. But also other characters with ORD() values smaller than space are "swallowed".
(b) is didactically cleaner, as it exactly states what characters are defined as "white spaces" and hence eaten away.

(a) is more kind of "error recovery" until Scan hits something known.
(b) is an explicit list of allowed white spaces.


Am 07.01.19, 11:37 schrieb "Oberon im Auftrag von Chris Burrows" <oberon-bounces at lists.inf.ethz.ch im Auftrag von chris at cfbsoftware.com>:

    > On Sat, Jan 5, 2019 at 12:52 PM Andreas Pirklbauer
    > <andreas_pirklbauer at yahoo.com> wrote:
    > For procedure Texts.Scan it is actually slightly better to use the
    > following code for the WHILE loop instead:
    >      WHILE ~S.eot & (ch <= " ") DO
    > Reason: This code will *not* hang the system if an EOT is encountered
    > in the file before any of the characters in the WHILE condition.. for
    > example with a file which consists *just* of an EOT.
    > This  bug  was already fixed at one point at www.projectoberon.com,
    > but now the old version is back.
    I'm not so sure. I recommend you check the other change that was made at the same time. i.e. in Texts.Read before drawing any conclusions:
          IF R.ref.f = TrailerFile THEN R.eot := TRUE END;
          R.org := R.org + R.off; R.off := 0;
          R.ref := R.ref.next; R.org := R.org + R.off; R.off := 0; 
          IF R.ref.f = TrailerFile THEN R.eot := TRUE END;
          R.ref := R.ref.next; R.org := R.org + R.off; R.off := 0;
    Chris Burrows
    CFB Software
    Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems

More information about the Oberon mailing list