Skip to content

Commit

Permalink
Merge pull request #332 from RcppCore/feature/rf_installchar
Browse files Browse the repository at this point in the history
use Rf_installChar() for R 3.2.0 or newer (closes #331)
  • Loading branch information
jjallaire committed Jul 24, 2015
2 parents 3bd9606 + 30642ee commit 674c40e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2015-07-23 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/Symbol.h: Use Rf_installChar(x) instead of
Rf_install(CHAR(X)) if R 3.2.0 or later is used

2015-07-07 Qiang Kou <qkou@umaikl.iu.edu>

* src/include/Rcpp/String.h: Ensure proper initialization of String
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Rcpp
Title: Seamless R and C++ Integration
Version: 0.11.6.4.2
Date: 2015-07-21
Version: 0.11.6.4.3
Date: 2015-07-23
Author: Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey,
Douglas Bates, and John Chambers
Maintainer: Dirk Eddelbuettel <edd@debian.org>
Expand Down
2 changes: 2 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
request 322 and 329 by Qiang Kou)
\item DataFrame constructors are now a little more careful (via pull
request 301 by Romain Francois)
\item For R 3.2.0 or newer, \code{Rf_installChar()} is used instead of
\code{Rf_install(CHAR())}.
}
\item Changes in Rcpp Attributes:
\itemize{
Expand Down
10 changes: 9 additions & 1 deletion inst/include/Rcpp/Symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Symbol.h: Rcpp R/C++ interface class library -- access R environments
//
// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2013 - 2015 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
Expand Down Expand Up @@ -43,13 +43,21 @@ namespace Rcpp{
Storage::set__( x ) ;
break; /* nothing to do */
case CHARSXP: {
#if R_VERSION >= R_Version(3,2,0)
SEXP charSym = Rf_installChar(x); // R 3.2.0 or later have Rf_installChar
#else
SEXP charSym = Rf_install(CHAR(x)); // cannot be gc()'ed once in symbol table
#endif
Storage::set__( charSym ) ;
break ;
}
case STRSXP: {
/* FIXME: check that there is at least one element */
#if R_VERSION >= R_Version(3,2,0)
SEXP charSym = Rf_installChar(STRING_ELT(x, 0 )); // R 3.2.0 or later have Rf_installChar
#else
SEXP charSym = Rf_install( CHAR(STRING_ELT(x, 0 )) ); // cannot be gc()'ed once in symbol table
#endif
Storage::set__( charSym );
break ;
}
Expand Down

0 comments on commit 674c40e

Please sign in to comment.