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/109779] New: isolib SkipLine skips the first character of the successive line
Date: Mon, 08 May 2023 19:36:31 +0000	[thread overview]
Message-ID: <bug-109779-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2023-05-08 19:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-08 19:36 gaius at gcc dot gnu.org [this message]
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

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