Mercurial > octave
annotate libinterp/corefcn/procstream.cc @ 31211:8340137bb190
maint: Merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 29 Aug 2022 13:58:00 +0200 |
parents | 796f54d4ddbf |
children | e88a07dec498 |
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) 1993-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 //////////////////////////////////////////////////////////////////////// |
1 | 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" |
1 | 28 #endif |
29 | |
25438
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
30 #include <iomanip> |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
31 |
1 | 32 #include "procstream.h" |
33 | |
29991
3988112c7116
move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
34 OCTAVE_NAMESPACE_BEGIN |
3988112c7116
move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
35 |
4051 | 36 procstreambase::procstreambase (const std::string& command, int mode) |
37 { | |
27175
613a31410ad0
backout changeset 196dfb42f3e9
John W. Eaton <jwe@octave.org>
parents:
27172
diff
changeset
|
38 pb_init (); |
613a31410ad0
backout changeset 196dfb42f3e9
John W. Eaton <jwe@octave.org>
parents:
27172
diff
changeset
|
39 |
27172 | 40 if (! m_pb.open (command.c_str (), mode)) |
4051 | 41 std::ios::setstate (std::ios::badbit); |
42 } | |
43 | |
1965 | 44 procstreambase::procstreambase (const char *command, int mode) |
1 | 45 { |
27175
613a31410ad0
backout changeset 196dfb42f3e9
John W. Eaton <jwe@octave.org>
parents:
27172
diff
changeset
|
46 pb_init (); |
613a31410ad0
backout changeset 196dfb42f3e9
John W. Eaton <jwe@octave.org>
parents:
27172
diff
changeset
|
47 |
27172 | 48 if (! m_pb.open (command, mode)) |
3563 | 49 std::ios::setstate (std::ios::badbit); |
1 | 50 } |
51 | |
52 void | |
1965 | 53 procstreambase::open (const char *command, int mode) |
1 | 54 { |
55 clear (); | |
1380 | 56 |
27172 | 57 if (! m_pb.open (command, mode)) |
3563 | 58 std::ios::setstate (std::ios::badbit); |
1 | 59 } |
60 | |
483 | 61 int |
1965 | 62 procstreambase::close (void) |
1380 | 63 { |
64 int status = 0; | |
65 | |
66 if (is_open ()) | |
67 { | |
27172 | 68 if (! m_pb.close ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
69 std::ios::setstate (std::ios::failbit); |
3189 | 70 |
27172 | 71 status = m_pb.wait_status (); |
1380 | 72 } |
73 | |
74 return status; | |
75 } | |
29991
3988112c7116
move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
76 |
3988112c7116
move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
77 OCTAVE_NAMESPACE_END |