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/109830] New: m2iso library SeqFile.mod - appending to a file overwrites the contents Date: Fri, 12 May 2023 14:23:46 +0000 [thread overview] Message-ID: <bug-109830-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109830 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 := 0 ; str := '0123456789' ; (* Open file and create data. *) StreamFile.Open (cid, 'testdata', write+old+raw, res) ; IF res = 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 := 2 END ; str := 'abcdefghij' ; (* Now attempt to append the alphabetic str. *) SeqFile.OpenAppend (cid, 'testdata', write+old+raw, res) ; IF res = opened THEN RawWrite (cid, ADR (str), 10); SeqFile.Close (cid) ELSE printf ("failed to open file for append\n") ; code := 3 END ; (* And now test the file for the appended data. *) StreamFile.Open (cid, 'testdata', read+raw, res) ; IF res = 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 := 5 END ; StreamFile.Close (cid) ; str[20] := 0C ; IF StrEqual (str, '0123456789abcdefghij') THEN printf ("append test passed\n") ELSE printf ("append test failed\n") ; code := 1 END ELSE printf ("failed to open result file\n") ; code := 4 END ; exit (code) END stress ; BEGIN stress END seqappend. fails.
next reply other threads:[~2023-05-12 14:23 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-12 14:23 gaius at gcc dot gnu.org [this message] 2023-05-12 14:24 ` [Bug modula2/109830] " gaius at gcc dot gnu.org 2023-05-12 14:34 ` gaius at gcc dot gnu.org 2023-05-12 16:46 ` cvs-commit at gcc dot gnu.org 2023-05-12 17:09 ` gaius at gcc dot gnu.org 2023-07-28 20:09 ` 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-109830-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: linkBe 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).