Mercurial > octave
comparison test/io.tst @ 28220:6cccc3c82175 stable
attempt to work around Windows ftello/fseeko bug (bug #58055)
* lo-sysdep.cc (check_fseek_ftell_workaround_needed): New static function.
(sys::fopen): Use it to check whether to work around text mode
ftello/fseeko bug. Store result in static variable. If bug is
detected, use non-buffered I/O for files opened in text mode.
* io.tst: New test.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 14 Apr 2020 22:53:19 -0400 |
parents | bd51beb6205e |
children | ebff357efd56 ad9252d7472b |
comparison
equal
deleted
inserted
replaced
28219:f84ee2305174 | 28220:6cccc3c82175 |
---|---|
920 %!assert (sprintf ("a %s b", ''), "a b") | 920 %!assert (sprintf ("a %s b", ''), "a b") |
921 %!assert (sprintf ("a %s b", ' '), "a b") | 921 %!assert (sprintf ("a %s b", ' '), "a b") |
922 | 922 |
923 %!assert <*53148> (double (sprintf ("B\0B")), [66, 0, 66]) | 923 %!assert <*53148> (double (sprintf ("B\0B")), [66, 0, 66]) |
924 %!assert <*53148> (sscanf ("B\0B 13", "B\0B %d"), 13) | 924 %!assert <*53148> (sscanf ("B\0B 13", "B\0B %d"), 13) |
925 | |
926 %!test <58055> | |
927 %! w_modes = {"wb", "wt"}; | |
928 %! r_modes = {"rb", "rt"}; | |
929 %! f_texts = {"foo\nbar\nbaz\n", "foo\rbar\rbaz\r", "foo\r\nbar\r\nbaz\r\n"}; | |
930 %! for i = 1:numel (w_modes) | |
931 %! w_mode = w_modes{i}; | |
932 %! for j = 1:numel (r_modes); | |
933 %! r_mode = r_modes{j}; | |
934 %! for k = 1:numel (f_texts); | |
935 %! f_text = f_texts{k}; | |
936 %! fname = tempname () | |
937 %! fid = fopen (fname, w_mode); | |
938 %! unwind_protect | |
939 %! fprintf (fid, "%s", f_text); | |
940 %! fclose (fid); | |
941 %! fid = fopen (fname, r_mode) | |
942 %! fgetl (fid); | |
943 %! pos = ftell (fid); | |
944 %! buf1 = fgetl (fid); | |
945 %! fgetl (fid); | |
946 %! fseek (fid, pos, SEEK_SET); | |
947 %! buf2 = fgetl (fid); | |
948 %! assert (buf1, buf2); | |
949 %! unwind_protect_cleanup | |
950 %! fclose (fid); | |
951 %! unlink (fname); | |
952 %! end_unwind_protect | |
953 %! endfor | |
954 %! endfor | |
955 %! endfor |