Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2017-02-14 Iñaki Ucar <i.ucar86@gmail.com>

* inst/include/Rcpp/iostream/Rstreambuf.h: Fixed single-character handling
(pull request #649, fixes issue #647)

2017-02-13 Dirk Eddelbuettel <edd@debian.org>

* R/Attributes.R (.plugins[["cpp17"]]): New plugin
Expand Down
2 changes: 2 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
\itemize{
\item Added new size attribute aliases for number of rows and columns in
DataFrame (James Balamuta in \ghpr{638} addressing \ghit{630}).
\item Fixed single-character handling in \code{Rstreambuf} (Iñaki Ucar in
\ghpr{649} addressing \ghit{647}).
}
\item Changes in Rcpp Sugar:
\itemize{
Expand Down
16 changes: 11 additions & 5 deletions inst/include/Rcpp/iostream/Rstreambuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Rcpp {
protected:
virtual std::streamsize xsputn(const char *s, std::streamsize n );

virtual int overflow(int c = EOF );
virtual int overflow(int c = traits_type::eof() );

virtual int sync() ;
};
Expand Down Expand Up @@ -67,12 +67,18 @@ namespace Rcpp {
}

template <> inline int Rstreambuf<true>::overflow(int c ) {
if (c != EOF) Rprintf( "%.1s", &c ) ;
return c ;
if (c != traits_type::eof()) {
char_type ch = traits_type::to_char_type(c);
return xsputn(&ch, 1) == 1 ? c : traits_type::eof();
}
return c;
}
template <> inline int Rstreambuf<false>::overflow(int c ) {
if (c != EOF) REprintf( "%.1s", &c ) ;
return c ;
if (c != traits_type::eof()) {
char_type ch = traits_type::to_char_type(c);
return xsputn(&ch, 1) == 1 ? c : traits_type::eof();
}
return c;
}

template <> inline int Rstreambuf<true>::sync(){
Expand Down