Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
8ece5428
Commit
8ece5428
authored
Apr 27, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the cout and cerr redirection in mex files restore the state of the
streambufs before exiting.
parent
9f2f6146
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
mex_wrapper.cpp
dlib/matlab/mex_wrapper.cpp
+17
-4
No files found.
dlib/matlab/mex_wrapper.cpp
View file @
8ece5428
...
...
@@ -2928,7 +2928,13 @@ namespace mex_binding
setp
(
&
buf
[
0
],
&
buf
[
0
]
+
buf
.
size
()
-
2
);
// make cout send data to mex_streambuf
std
::
cout
.
rdbuf
(
this
);
oldbuf
=
std
::
cout
.
rdbuf
(
this
);
}
~
mex_streambuf
()
{
// put cout back to the way we found it before running our mex function.
std
::
cout
.
rdbuf
(
oldbuf
);
}
...
...
@@ -2964,6 +2970,7 @@ namespace mex_binding
private
:
std
::
vector
<
char
>
buf
;
std
::
streambuf
*
oldbuf
;
};
...
...
@@ -2978,9 +2985,14 @@ namespace mex_binding
setp
(
&
buf
[
0
],
&
buf
[
0
]
+
buf
.
size
()
-
2
);
// make cout send data to mex_warn_streambuf
std
::
cerr
.
rdbuf
(
this
);
oldbuf
=
std
::
cerr
.
rdbuf
(
this
);
}
~
mex_warn_streambuf
()
{
// put cerr back to the way we found it before running our mex function.
std
::
cerr
.
rdbuf
(
oldbuf
);
}
protected
:
...
...
@@ -3014,6 +3026,7 @@ namespace mex_binding
private
:
std
::
vector
<
char
>
buf
;
std
::
streambuf
*
oldbuf
;
};
...
...
@@ -4523,9 +4536,9 @@ void mexFunction( int nlhs, mxArray *plhs[],
// Only remap cout and cerr if we aren't using octave since octave already does this.
#if !defined(OCTAVE_IMPORT) && !defined(OCTAVE_API)
// make it so cout prints to mexPrintf()
static
mex_binding
::
mex_streambuf
sb
;
mex_binding
::
mex_streambuf
sb
;
// make it so cerr prints to mexWarnMsgTxt()
static
mex_binding
::
mex_warn_streambuf
wsb
;
mex_binding
::
mex_warn_streambuf
wsb
;
#endif
mex_binding
::
call_mex_function
(
mex_function
,
nlhs
,
plhs
,
nrhs
,
prhs
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment