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

* [Bug modula2/109879] ReadCard and ReadInt from WholeIO have problems with leading space
  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 ` gaius at gcc dot gnu.org
  2023-05-16 21:47 ` 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-16 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

Here is a proposed patch and testcase.

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

* [Bug modula2/109879] ReadCard and ReadInt from WholeIO have problems with leading space
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-16 21:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Confirmed as a bug.

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

* [Bug modula2/109879] ReadCard and ReadInt from WholeIO have problems with leading space
  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
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-16 23:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:509eef9314b24eff20a5dbdd92f6ab52e2c0c786

commit r14-920-g509eef9314b24eff20a5dbdd92f6ab52e2c0c786
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Wed May 17 00:18:56 2023 +0100

    PR modula2/109879 WholeIO.ReadCard and ReadInt should consume leading space

    The Read{TYPE} procedures in LongIO, LongWholeIO, RealIO, ShortWholeIO and
    WholeIO all require skip space functionality.  A new module TextUtil
    is supplied with this functionality and the previous modules have been
    changed to call SkipSpaces.

    gcc/m2/ChangeLog:

            PR modula2/109879
            * gm2-libs-iso/LongIO.mod (ReadReal): Call SkipSpaces.
            * gm2-libs-iso/LongWholeIO.mod (ReadInt): Call SkipSpaces.
            (ReadCard): Call SkipSpaces.
            * gm2-libs-iso/RealIO.mod (ReadReal): Call SkipSpaces.
            * gm2-libs-iso/ShortWholeIO.mod: (ReadInt): Call SkipSpaces.
            (ReadCard): Call SkipSpaces.
            * gm2-libs-iso/TextIO.mod: Import SkipSpaces.
            * gm2-libs-iso/WholeIO.mod (ReadInt): Call SkipSpaces.
            (ReadCard): Call SkipSpaces.
            * gm2-libs-iso/TextUtil.def: New file.
            * gm2-libs-iso/TextUtil.mod: New file.

    libgm2/ChangeLog:

            PR modula2/109879
            * Makefile.in: Regenerate.
            * aclocal.m4: Regenerate.
            * libm2cor/Makefile.in: Regenerate.
            * libm2iso/Makefile.am (M2DEFS): Add TextUtil.def.
            (M2MODS): Add TextUtil.mod.
            * libm2iso/Makefile.in: Regenerate.
            * libm2log/Makefile.in: Regenerate.
            * libm2min/Makefile.in: Regenerate.
            * libm2pim/Makefile.in: Regenerate.

    gcc/testsuite/ChangeLog:

            PR modula2/109879
            * gm2/isolib/run/pass/testreadint.mod: New test.

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

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

* [Bug modula2/109879] ReadCard and ReadInt from WholeIO have problems with leading space
  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
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-16 23:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug modula2/109879] ReadCard and ReadInt from WholeIO have problems with leading space
  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
                   ` (3 preceding siblings ...)
  2023-05-16 23:22 ` gaius at gcc dot gnu.org
@ 2023-07-28 23:28 ` 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 23:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:461359a8f8361d00f926985050e06bd13445ea69

commit r13-7637-g461359a8f8361d00f926985050e06bd13445ea69
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Sat Jul 29 00:27:22 2023 +0100

    PR modula2/109879 WholeIO.ReadCard and ReadInt should consume leading space

    The Read{TYPE} procedures in LongIO, LongWholeIO, RealIO, ShortWholeIO and
    WholeIO all require skip space functionality.  A new module TextUtil
    is supplied with this functionality and the previous modules have been
    changed to call SkipSpaces.

    gcc/m2/ChangeLog:

            PR modula2/109879
            * gm2-libs-iso/LongIO.mod (ReadReal): Call SkipSpaces.
            * gm2-libs-iso/LongWholeIO.mod (ReadInt): Call SkipSpaces.
            (ReadCard): Call SkipSpaces.
            * gm2-libs-iso/RealIO.mod (ReadReal): Call SkipSpaces.
            * gm2-libs-iso/ShortWholeIO.mod: (ReadInt): Call SkipSpaces.
            (ReadCard): Call SkipSpaces.
            * gm2-libs-iso/TextIO.mod: Import SkipSpaces.
            * gm2-libs-iso/WholeIO.mod (ReadInt): Call SkipSpaces.
            (ReadCard): Call SkipSpaces.
            * gm2-libs-iso/TextUtil.def: New file.
            * gm2-libs-iso/TextUtil.mod: New file.

    libgm2/ChangeLog:

            PR modula2/109879
            * Makefile.in: Regenerate.
            * aclocal.m4: Regenerate.
            * libm2cor/Makefile.in: Regenerate.
            * libm2iso/Makefile.am (M2DEFS): Add TextUtil.def.
            (M2MODS): Add TextUtil.mod.
            * libm2iso/Makefile.in: Regenerate.
            * libm2log/Makefile.in: Regenerate.
            * libm2min/Makefile.in: Regenerate.
            * libm2pim/Makefile.in: Regenerate.

    gcc/testsuite/ChangeLog:

            PR modula2/109879
            * gm2/isolib/run/pass/testreadint.mod: New test.

    (cherry picked from commit 509eef9314b24eff20a5dbdd92f6ab52e2c0c786)

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