]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/115057 TextIO.ReadRestLine raises an exception when buffer is exceeded
authorGaius Mulley <gaiusmod2@gmail.com>
Wed, 15 May 2024 15:58:21 +0000 (16:58 +0100)
committerGaius Mulley <gaiusmod2@gmail.com>
Wed, 15 May 2024 15:58:21 +0000 (16:58 +0100)
commit680af0e1e90d4b80260d173636dfe15654fd470d
treedd8157dd5778cffd6c6b874e987afae49f082a48
parent3cefe91b74f65f0db71472e01ca83c69e2cd81cc
PR modula2/115057 TextIO.ReadRestLine raises an exception when buffer is exceeded

TextIO.ReadRestLine will raise an "attempting to read beyond end of file"
exception if the buffer is exceeded.  This bug is caused by the
TextIO.ReadRestLine calling IOChan.Skip without a preceeding IOChan.Look.
The Look procedure will update the status result whereas
Skip always sets read result to allRight.

gcc/m2/ChangeLog:

PR modula2/115057
* gm2-libs-iso/TextIO.mod (ReadRestLine): Use ReadChar to
skip unwanted characters as this calls IOChan.Look and updates
the cid result status.  A Skip without a Look does not update
the status.  Skip always sets read result to allRight.
* gm2-libs-iso/TextUtil.def (SkipSpaces): Improve comments.
(CharAvailable): Improve comments.
* gm2-libs-iso/TextUtil.mod (SkipSpaces): Improve comments.
(CharAvailable): Improve comments.

gcc/testsuite/ChangeLog:

PR modula2/115057
* gm2/isolib/run/pass/testrestline.mod: New test.
* gm2/isolib/run/pass/testrestline2.mod: New test.
* gm2/isolib/run/pass/testrestline3.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-libs-iso/TextIO.mod
gcc/m2/gm2-libs-iso/TextUtil.def
gcc/m2/gm2-libs-iso/TextUtil.mod
gcc/testsuite/gm2/isolib/run/pass/testrestline.mod [new file with mode: 0644]
gcc/testsuite/gm2/isolib/run/pass/testrestline2.mod [new file with mode: 0644]
gcc/testsuite/gm2/isolib/run/pass/testrestline3.mod [new file with mode: 0644]