public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/109879] New: ReadCard and ReadInt from WholeIO have problems with leading space
@ 2023-05-16 21:41 gaius at gcc dot gnu.org
  2023-05-16 21:46 ` [Bug modula2/109879] " gaius at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-16 21:41 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-28 23:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16 21:41 [Bug modula2/109879] New: ReadCard and ReadInt from WholeIO have problems with leading space gaius at gcc dot gnu.org
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

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