public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gaius at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug modula2/109879] New: ReadCard and ReadInt from WholeIO have problems with leading space
Date: Tue, 16 May 2023 21:41:16 +0000	[thread overview]
Message-ID: <bug-109879-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109879

            Bug ID: 109879
           Summary: ReadCard and ReadInt from WholeIO have problems with
                    leading space
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: gaius at gcc dot gnu.org
  Target Milestone: ---

As reported on the gn2 mailing list, leading spaces are not skipped when
performing ReadInt or ReadCard.


module port_test10a_gm2;

from ChanConsts IMPORT
  OpenResults, old, read, write;
from IOChan IMPORT
  ChanId;
from StdChans IMPORT
  StdOutChan;
import StreamFile;
from TextIO IMPORT
  SkipLine, WriteLn, WriteString;
from WholeIO IMPORT
  ReadCard, ReadInt, WriteCard, WriteInt;


procedure ReadNumbersTest();
  const
    arr_len=                    128;

  type
    arr_type=                   ARRAY[0..arr_len-1] of char;

  var
    cid_file:                   ChanId;
    cid_out:                    ChanId;
    file_name:                  arr_type;
    res:                        OpenResults;
    c1:                         cardinal;
    ival:                       integer;
    cval:                       cardinal;

  begin                         (* procedure ReadNumbersTest *)
    cid_out:=StdOutChan();

    file_name:='test_data';

    (* create file and write (integer) numbers to it *)
    WriteString(cid_out, 'write (integer) numbers to file...');
    WriteLn(cid_out);
    StreamFile.Open(cid_file, file_name, write+old, res);
    if res=opened THEN
      WriteString(cid_file, ' 123');
      WriteLn(cid_file);
      WriteString(cid_file, '234');
      WriteLn(cid_file);
      StreamFile.Close(cid_file);
    end;                        (* if res=opened *)

    (* (re-)open file and read numbers with ReadCard *)
    WriteString(cid_out, 'read numbers with ReadCard...');
    WriteLn(cid_out);
    StreamFile.Open(cid_file, file_name, read, res);
    if res=opened THEN
      for c1:=1 TO 2 DO
        ReadCard(cid_file, cval);
        WriteCard(cid_out, cval, 1);
        WriteLn(cid_out);
        SkipLine(cid_file);
      end;                      (* for c1 *)
      StreamFile.Close(cid_file);
    end;                        (* if res=opened *)
    WriteLn(cid_out);

    (* (re-)open file and read numbers with ReadInt *)
    WriteString(cid_out, 'read numbers with ReadInt...');
    WriteLn(cid_out);
    StreamFile.Open(cid_file, file_name, read, res);
    if res=opened THEN
      for c1:=1 TO 2 DO
        ReadInt(cid_file, ival);
        WriteInt(cid_out, ival, 1);
        WriteLn(cid_out);
        SkipLine(cid_file);
      end;                      (* for c1 *)
      StreamFile.Close(cid_file);
    end;                        (* if res=opened *)
    WriteLn(cid_out);

  end ReadNumbersTest;


begin                           (* module port_test10a_gm2 *)
  ReadNumbersTest();
end port_test10a_gm2.

             reply	other threads:[~2023-05-16 21:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16 21:41 gaius at gcc dot gnu.org [this message]
2023-05-16 21:46 ` [Bug modula2/109879] " gaius at gcc dot gnu.org
2023-05-16 21:47 ` gaius at gcc dot gnu.org
2023-05-16 23:19 ` cvs-commit at gcc dot gnu.org
2023-05-16 23:22 ` gaius at gcc dot gnu.org
2023-07-28 23:28 ` cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109879-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).