From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 85FE63856968; Fri, 12 May 2023 14:23:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85FE63856968 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683901426; bh=WNe5kTnWOHYUixgoRQpOXDHg0UaLjlZxvdVyNY6M2lc=; h=From:To:Subject:Date:From; b=IigmlmIdGjulM6Lk6vrgZZ+J5Gdu89pSjtFzSAgwU5gCnXX7K8uncKLB1ja81x1WA tyJMFhxJ9ff5U37BSbvfmdgCJmRgvBBeDEEAtvCQ2A64gj/EKE8sQzQCnfYCRyKggV gWkPAkwWXTbfvu1Nbctb0JpKF17UaBbb1gzeS2g8= From: "gaius at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug modula2/109830] New: m2iso library SeqFile.mod - appending to a file overwrites the contents Date: Fri, 12 May 2023 14:23:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: modula2 X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gaius at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: gaius at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109830 Bug ID: 109830 Summary: m2iso library SeqFile.mod - appending to a file overwrites the contents 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: --- A reported on the gm2 mailing list, attempting to append data to a existing file using the module SeqFile will overwrite the data. For example: MODULE seqappend ; FROM ChanConsts IMPORT OpenResults, old, raw, write, read ; FROM IOChan IMPORT ChanId, RawWrite, RawRead ; FROM SYSTEM IMPORT ADR; FROM libc IMPORT exit, printf ; FROM StrLib IMPORT StrEqual ; IMPORT StreamFile; IMPORT SeqFile; PROCEDURE stress ; VAR cid : ChanId ; res : OpenResults; str : ARRAY [0..20] OF CHAR ; actual: CARDINAL ; code : INTEGER ; BEGIN code :=3D 0 ; str :=3D '0123456789' ; (* Open file and create data. *) StreamFile.Open (cid, 'testdata', write+old+raw, res) ; IF res =3D opened THEN (* Now write data creating new contents. *) RawWrite (cid, ADR (str), 10) ; StreamFile.Close(cid) ELSE printf ("failed to open file for write\n") ; code :=3D 2 END ; str :=3D 'abcdefghij' ; (* Now attempt to append the alphabetic str. *) SeqFile.OpenAppend (cid, 'testdata', write+old+raw, res) ; IF res =3D opened THEN RawWrite (cid, ADR (str), 10); SeqFile.Close (cid) ELSE printf ("failed to open file for append\n") ; code :=3D 3 END ; (* And now test the file for the appended data. *) StreamFile.Open (cid, 'testdata', read+raw, res) ; IF res =3D opened THEN (* Now write data creating new contents. *) RawRead (cid, ADR (str), 20, actual) ; IF actual # 20 THEN printf ("short read occurred: %d...\n", actual) ; code :=3D 5 END ; StreamFile.Close (cid) ; str[20] :=3D 0C ; IF StrEqual (str, '0123456789abcdefghij') THEN printf ("append test passed\n") ELSE printf ("append test failed\n") ; code :=3D 1 END ELSE printf ("failed to open result file\n") ; code :=3D 4 END ; exit (code) END stress ; BEGIN stress END seqappend. fails.=