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

* [Bug modula2/109779] isolib SkipLine skips the first character of the successive line
  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 ` gaius at gcc dot gnu.org
  2023-05-09  4:08 ` gaius at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-08 19:48 UTC (permalink / raw)
  To: gcc-bugs

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

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-05-08

--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Confirmed this is a bug in the m2iso library.

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

* [Bug modula2/109779] isolib SkipLine skips the first character of the successive line
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-09  4:08 UTC (permalink / raw)
  To: gcc-bugs

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

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gaius at gcc dot gnu.org

--- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 55025
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55025&action=edit
Proposed fix

A proposed patch for m2/gm2-libs-iso/RTgen.mod:doLook and
m2/gm2-libs-iso/TextIO.mod:SkipLine.

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

* [Bug modula2/109779] isolib SkipLine skips the first character of the successive line
  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
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-09 17:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:

https://gcc.gnu.org/g:434dade5a11f63533cbf6059a862856c9b11c711

commit r14-620-g434dade5a11f63533cbf6059a862856c9b11c711
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Tue May 9 18:17:13 2023 +0100

    PR modula2/109779 isolib SkipLine skips the first character of the
successive line

    This is a patch for the m2iso library to prevent SkipLine from consuming
    the next character on the next line.

    gcc/m2/ChangeLog:

            PR modula2/109779
            * gm2-libs-iso/RTgen.mod (doLook): Remove old.
            Remove re-assignment of result.
            * gm2-libs-iso/TextIO.mod (CanRead): Rename into ...
            (CharAvailable): ... this.
            (DumpState): New procedure.
            (SetResult): Rename as SetNul.
            (WasGoodChar): Rename into ...
            (EofOrEoln): ... this.
            (SkipLine): Skip over the newline.
            (ReadString): Flip THEN ELSE statements after testing for
            EofOrEoln.
            (ReadRestLine): Flip THEN ELSE statements after testing for
            EofOrEoln.

    gcc/testsuite/ChangeLog:

            PR modula2/109779
            * gm2/isolib/run/pass/skiplinetest.mod: New test.

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

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

* [Bug modula2/109779] isolib SkipLine skips the first character of the successive line
  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
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-09 17:18 UTC (permalink / raw)
  To: gcc-bugs

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

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Closing as patch has been applied.

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

* [Bug modula2/109779] isolib SkipLine skips the first character of the successive line
  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
                   ` (3 preceding siblings ...)
  2023-05-09 17:18 ` gaius at gcc dot gnu.org
@ 2023-07-28 16:52 ` cvs-commit at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-28 16:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Gaius Mulley
<gaius@gcc.gnu.org>:

https://gcc.gnu.org/g:41e3fd01c204563fc892cd2e7606d01f6467c3e5

commit r13-7623-g41e3fd01c204563fc892cd2e7606d01f6467c3e5
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Fri Jul 28 17:51:53 2023 +0100

    PR modula2/109779 isolib SkipLine skips the first character of the
successive line

    This is a patch for the m2iso library to prevent SkipLine from consuming
    the next character on the next line.

    gcc/m2/ChangeLog:

            PR modula2/109779
            * gm2-libs-iso/RTgen.mod (doLook): Remove old.
            Remove re-assignment of result.
            * gm2-libs-iso/TextIO.mod (CanRead): Rename into ...
            (CharAvailable): ... this.
            (DumpState): New procedure.
            (SetResult): Rename as SetNul.
            (WasGoodChar): Rename into ...
            (EofOrEoln): ... this.
            (SkipLine): Skip over the newline.
            (ReadString): Flip THEN ELSE statements after testing for
            EofOrEoln.
            (ReadRestLine): Flip THEN ELSE statements after testing for
            EofOrEoln.

    gcc/testsuite/ChangeLog:

            PR modula2/109779
            * gm2/isolib/run/pass/skiplinetest.mod: New test.

    (cherry picked from commit 434dade5a11f63533cbf6059a862856c9b11c711)

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

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