annotate libinterp/corefcn/oct-fstrm.cc @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents 3988112c7116
children e88a07dec498
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29991
diff changeset
3 // Copyright (C) 1996-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
28 #endif
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
29
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
30 #include <cerrno>
10463
bbe99b2a5ba7 undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents: 10447
diff changeset
31 #include <cstring>
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
32
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
33 #include "error.h"
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
34 #include "oct-fstrm.h"
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
35
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
36 OCTAVE_NAMESPACE_BEGIN
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
37
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
38 stream
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
39 fstream::create (const std::string& nm_arg, std::ios::openmode arg_md,
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
40 mach_info::float_format ff)
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 2847
diff changeset
41 {
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
42 return stream (new fstream (nm_arg, arg_md, ff));
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 2847
diff changeset
43 }
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 2847
diff changeset
44
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
45 fstream::fstream (const std::string& nm_arg, std::ios::openmode arg_md,
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
46 mach_info::float_format ff)
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
47 : base_stream (arg_md, ff), m_name (nm_arg)
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
48 {
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
49 m_fstream.open (m_name.c_str (), arg_md);
3775
13905c3a24af [project @ 2001-02-06 01:56:59 by jwe]
jwe
parents: 3652
diff changeset
50
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
51 if (! m_fstream)
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
52 // Note: error is inherited from base_stream, not ::error.
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
53 error (std::strerror (errno));
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
54 }
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
55
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
56 // Position a stream at OFFSET relative to ORIGIN.
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
57
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
58 int
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
59 fstream::seek (off_t, int)
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
60 {
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
61 // Note: error is inherited from base_stream, not ::error.
20931
69dcb58b9ada Clean up use of error() versus ::error() in stream-based code.
Rik <rik@octave.org>
parents: 20916
diff changeset
62 // This error function does not halt execution so "return ..." must exist.
4797
19b8225bdaa2 [project @ 2004-02-23 22:10:31 by jwe]
jwe
parents: 4643
diff changeset
63 error ("fseek: invalid_operation");
20916
8ddb11c0b1f8 restore return statements after calls to octave_base_stream::error
John W. Eaton <jwe@octave.org>
parents: 20893
diff changeset
64 return -1;
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
65 }
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
66
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
67 // Return current stream position.
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
68
16011
8122286c69a9 initial large file support for 32-bit systems
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
69 off_t
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
70 fstream::tell (void)
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
71 {
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
72 // Note: error is inherited from base_stream, not ::error.
20931
69dcb58b9ada Clean up use of error() versus ::error() in stream-based code.
Rik <rik@octave.org>
parents: 20916
diff changeset
73 // This error function does not halt execution so "return ..." must exist.
4797
19b8225bdaa2 [project @ 2004-02-23 22:10:31 by jwe]
jwe
parents: 4643
diff changeset
74 error ("ftell: invalid_operation");
20916
8ddb11c0b1f8 restore return statements after calls to octave_base_stream::error
John W. Eaton <jwe@octave.org>
parents: 20893
diff changeset
75 return -1;
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
76 }
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
77
18812
9ac2357f19bc doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents: 17744
diff changeset
78 // Return nonzero if EOF has been reached on this stream.
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
79
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
80 bool
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
81 fstream::eof (void) const
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
82 {
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
83 return m_fstream.eof ();
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
84 }
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
85
3652
25e84fcef38a [project @ 2000-03-31 08:50:48 by jwe]
jwe
parents: 3570
diff changeset
86 void
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
87 fstream::do_close (void)
3652
25e84fcef38a [project @ 2000-03-31 08:50:48 by jwe]
jwe
parents: 3570
diff changeset
88 {
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
89 m_fstream.close ();
3652
25e84fcef38a [project @ 2000-03-31 08:50:48 by jwe]
jwe
parents: 3570
diff changeset
90 }
25e84fcef38a [project @ 2000-03-31 08:50:48 by jwe]
jwe
parents: 3570
diff changeset
91
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3340
diff changeset
92 std::istream *
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
93 fstream::input_stream (void)
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
94 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23220
diff changeset
95 std::istream *retval = nullptr;
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
96
3544
71bd2d124119 [project @ 2000-02-02 21:02:31 by jwe]
jwe
parents: 3531
diff changeset
97 if (mode () & std::ios::in)
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
98 retval = &m_fstream;
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
99
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
100 return retval;
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
101 }
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
102
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3340
diff changeset
103 std::ostream *
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
104 fstream::output_stream (void)
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
105 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23220
diff changeset
106 std::ostream *retval = nullptr;
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
107
3544
71bd2d124119 [project @ 2000-02-02 21:02:31 by jwe]
jwe
parents: 3531
diff changeset
108 if (mode () & std::ios::out)
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
109 retval = &m_fstream;
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
110
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
111 return retval;
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
112 }
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
113
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
114 OCTAVE_NAMESPACE_END