public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/109779] New: isolib SkipLine skips the first character of the successive line
@ 2023-05-08 19:36 gaius at gcc dot gnu.org
  2023-05-08 19:48 ` [Bug modula2/109779] " 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-08 19:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109779
           Summary: isolib SkipLine skips the first character of the
                    successive line
           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: ---

This bug report is copied from the gm2 mailing list.

It appears that the first character is consumed from the subsequent line when
using SkipLine (as seen when using ReadString after SkipLine).


MODULE port_test6_gm2;

FROM ChanConsts IMPORT
  OpenResults, old, read, write;
FROM IOChan IMPORT
  ChanId;
FROM StdChans IMPORT
  StdOutChan;
IMPORT StreamFile;
FROM TextIO IMPORT
  ReadString, SkipLine, WriteLn, WriteString;


PROCEDURE SkipReadTest();
  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;
    a_str:                      arr_type;
    res:                        OpenResults;

  BEGIN                         (* PROCEDURE SkipReadTest *)
    cid_out:=StdOutChan();

    file_name:='test_data';

    (* create file and write 2 lines to it *)
    StreamFile.Open(cid_file, file_name, write+old, res);
    IF res=opened THEN
      WriteString(cid_file, '# line1');
      WriteLn(cid_file);
      WriteString(cid_file, '# line2');
      WriteLn(cid_file);
      StreamFile.Close(cid_file);
    END;                        (* IF res=opened *)

    (* (re-)open file and read from it *)
    StreamFile.Open(cid_file, file_name, read, res);
    IF res=opened THEN
      SkipLine(cid_file);
      ReadString(cid_file, a_str);
      WriteString(cid_out, a_str);
      WriteLn(cid_out);
      StreamFile.Close(cid_file);
    END;                        (* IF res=opened *)
  END SkipReadTest;


BEGIN                           (* MODULE port_test6_gm2 *)
  SkipReadTest();
END port_test6_gm2.

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-08 19:36 [Bug modula2/109779] New: isolib SkipLine skips the first character of the successive line gaius at gcc dot gnu.org
2023-05-08 19:48 ` [Bug modula2/109779] " gaius at gcc dot gnu.org
2023-05-09  4:08 ` gaius at gcc dot gnu.org
2023-05-09 17:17 ` cvs-commit at gcc dot gnu.org
2023-05-09 17:18 ` gaius at gcc dot gnu.org
2023-07-28 16:52 ` 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).