annotate libinterp/corefcn/oct-fstrm.cc @ 23457:21baad6b35c4

maint: Use C++11 nullptr rather than 0 or NULL when possible. * FigureWindow.h, Logger.cc, Menu.cc, MouseModeActionGroup.h, Object.h, ObjectFactory.cc, ObjectProxy.h, color-picker.h, documentation-dock-widget.h, files-dock-widget.h, find-files-dialog.h, history-dock-widget.h, file-editor-tab.cc, file-editor.cc, file-editor.h, find-dialog.h, main-window.cc, main-window.h, octave-dock-widget.h, parser.cc, parser.h, webinfo.h, resource-manager.cc, shortcut-manager.cc, shortcut-manager.h, terminal-dock-widget.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.h, workspace-view.h, __magick_read__.cc, call-stack.cc, call-stack.h, cdisplay.c, display.cc, dlmread.cc, dynamic-ld.cc, ft-text-renderer.cc, gl2ps-print.cc, graphics.cc, graphics.in.h, input.h, interpreter.cc, interpreter.h, ls-hdf5.cc, mex.cc, mxarray.in.h, oct-errno.in.cc, oct-fstrm.cc, oct-iostrm.h, oct-procbuf.cc, oct-stdstrm.h, oct-stream.cc, oct-stream.h, octave-link.cc, pager.cc, pr-output.cc, profiler.h, qz.cc, sighandlers.cc, strfns.cc, symtab.cc, symtab.h, typecast.cc, urlwrite.cc, variables.cc, __eigs__.cc, __init_fltk__.cc, __ode15__.cc, colamd.cc, ov-base-int.cc, ov-base.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-builtin.cc, ov-class.cc, ov-classdef.cc, ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-java.cc, ov-java.h, ov-lazy-idx.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-str-mat.cc, ov-struct.cc, ov-usr-fcn.h, octave.cc, octave.h, bp-table.cc, jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, lex.h, pt-arg-list.cc, pt-arg-list.h, pt-array-list.h, pt-cell.h, pt-classdef.h, pt-colon.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.h, pt-idx.h, pt-jit.cc, pt-jit.h, pt-loop.h, pt-mat.h, pt-select.h, pt.h, CSparse.cc, dSparse.cc, DASPK.cc, DASRT.cc, DASSL.cc, oct-fftw.cc, oct-rand.cc, oct-spparms.cc, child-list.cc, file-ops.cc, mach-info.cc, oct-env.cc, oct-time.cc, cmd-edit.cc, cmd-hist.cc, oct-locbuf.cc, oct-shlib.cc, pathsearch.cc, singleton-cleanup.cc, unwind-prot.h, url-transfer.cc: Use C++11 nullptr rather than 0 or NULL when possible.
author Rik <rik@octave.org>
date Fri, 28 Apr 2017 13:19:12 -0700
parents 092078913d54
children 194eb4bd202b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
1 /*
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 1996-2017 John W. Eaton
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
4
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
6
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
8 under the terms of the GNU General Public License as published by
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
9 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
10 (at your option) any later version.
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
15 GNU General Public License for more details.
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
16
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
19 <http://www.gnu.org/licenses/>.
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
20
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
21 */
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
24 # include "config.h"
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
25 #endif
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
26
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
27 #include <cerrno>
10463
bbe99b2a5ba7 undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents: 10447
diff changeset
28 #include <cstring>
2081
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 "error.h"
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
31 #include "oct-fstrm.h"
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
32
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
33 octave::stream
3570
f74d9dfec96f [project @ 2000-02-03 11:27:10 by jwe]
jwe
parents: 3560
diff changeset
34 octave_fstream::create (const std::string& nm_arg, std::ios::openmode arg_md,
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
35 octave::mach_info::float_format ff)
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 2847
diff changeset
36 {
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
37 return octave::stream (new octave_fstream (nm_arg, arg_md, ff));
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 2847
diff changeset
38 }
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 2847
diff changeset
39
3552
41daa489833a [project @ 2000-02-03 03:05:28 by jwe]
jwe
parents: 3546
diff changeset
40 octave_fstream::octave_fstream (const std::string& nm_arg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
41 std::ios::openmode arg_md,
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
42 octave::mach_info::float_format ff)
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
43 : octave::base_stream (arg_md, ff), nm (nm_arg)
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
44 {
3775
13905c3a24af [project @ 2001-02-06 01:56:59 by jwe]
jwe
parents: 3652
diff changeset
45 fs.open (nm.c_str (), arg_md);
13905c3a24af [project @ 2001-02-06 01:56:59 by jwe]
jwe
parents: 3652
diff changeset
46
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
47 if (! fs)
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
48 // Note: error is inherited from octave::base_stream, not ::error.
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
49 error (std::strerror (errno));
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
50 }
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
51
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
52 // Position a stream at OFFSET relative to ORIGIN.
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
53
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
54 int
16011
8122286c69a9 initial large file support for 32-bit systems
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
55 octave_fstream::seek (off_t, int)
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
56 {
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
57 // Note: error is inherited from octave::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
58 // 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
59 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
60 return -1;
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
61 }
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
62
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
63 // Return current stream position.
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
64
16011
8122286c69a9 initial large file support for 32-bit systems
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
65 off_t
4797
19b8225bdaa2 [project @ 2004-02-23 22:10:31 by jwe]
jwe
parents: 4643
diff changeset
66 octave_fstream::tell (void)
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
67 {
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
68 // Note: error is inherited from octave::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
69 // 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
70 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
71 return -1;
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
72 }
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
73
18812
9ac2357f19bc doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents: 17744
diff changeset
74 // 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
75
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
76 bool
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
77 octave_fstream::eof (void) const
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
78 {
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
79 return fs.eof ();
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
80 }
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
81
3652
25e84fcef38a [project @ 2000-03-31 08:50:48 by jwe]
jwe
parents: 3570
diff changeset
82 void
25e84fcef38a [project @ 2000-03-31 08:50:48 by jwe]
jwe
parents: 3570
diff changeset
83 octave_fstream::do_close (void)
25e84fcef38a [project @ 2000-03-31 08:50:48 by jwe]
jwe
parents: 3570
diff changeset
84 {
25e84fcef38a [project @ 2000-03-31 08:50:48 by jwe]
jwe
parents: 3570
diff changeset
85 fs.close ();
25e84fcef38a [project @ 2000-03-31 08:50:48 by jwe]
jwe
parents: 3570
diff changeset
86 }
25e84fcef38a [project @ 2000-03-31 08:50:48 by jwe]
jwe
parents: 3570
diff changeset
87
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3340
diff changeset
88 std::istream *
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
89 octave_fstream::input_stream (void)
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
90 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23220
diff changeset
91 std::istream *retval = nullptr;
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
92
3544
71bd2d124119 [project @ 2000-02-02 21:02:31 by jwe]
jwe
parents: 3531
diff changeset
93 if (mode () & std::ios::in)
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
94 retval = &fs;
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
95
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
96 return retval;
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
97 }
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
98
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3340
diff changeset
99 std::ostream *
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
100 octave_fstream::output_stream (void)
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
101 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23220
diff changeset
102 std::ostream *retval = nullptr;
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
103
3544
71bd2d124119 [project @ 2000-02-02 21:02:31 by jwe]
jwe
parents: 3531
diff changeset
104 if (mode () & std::ios::out)
2081
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
105 retval = &fs;
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
106
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
107 return retval;
e9ec222a53e1 [project @ 1996-04-25 03:17:36 by jwe]
jwe
parents:
diff changeset
108 }