octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63930] fprintf problem


From: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #63930] fprintf problem
Date: Fri, 24 Mar 2023 17:30:38 -0400 (EDT)

Update of bug #63930 (project octave):

                  Status:               Need Info => In Progress            

    _______________________________________________________

Follow-up Comment #23:

It broke only one BIST for me, which after working through the checks
manually, I am thinking the BIST needs to be updated. This is the BIST:


## file stream with encoding
%!test
%! f = tempname ();
%! fid = fopen (f, "w+", "n", "iso-8859-1");
%! unwind_protect
%!   fprintf (fid, "abc,äöü\n");
%!   fflush (fid);
%!   fseek (fid, 0, "bof");
%!   obs = textscan (fid, "%s", "delimiter", ",");
%!   fclose (fid);
%!   assert (obs, { {"abc"; "äöü"} });
%! unwind_protect_cleanup
%!   unlink (f);
%! end_unwind_protect


The behavior hinges on what exactly is mode "w+" for opening a file. The help
text says that's supposed to be read and write, discarding old contents if
any, but **doesn't** say if it's binary mode or not. Which is it supposed to
be? The code itself does this:


  else if (mode == "w+b" || mode == "wb+" || mode == "w+")
    retval = (std::ios::in | std::ios::out | std::ios::trunc
              | std::ios::binary);


So that code opens it in binary mode read/write/trunc, and the BIST explicitly
sets the encoding to ISO-8859-1. *IS* a binary mode file operation supposed to
even have a text encoding? Should that BIST be changed to say "wt+" instead of
"w+", because "wt+" does not use binary mode:

  else if (mode == "w+t" || mode == "wt+")
    retval = std::ios::in | std::ios::out | std::ios::trunc;


>From the context of the BIST, it's to test text encoding, so "wt+" makes more
sense than "w+". Thoughts?

Do you have other failing tests?



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63930>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]