Skip to content

Commit 7c38923

Browse files
try an alterntive impl of wrap( const char*)
1 parent 0886391 commit 7c38923

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

inst/include/Rcpp/internal/wrap.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -920,13 +920,11 @@ inline SEXP module_wrap<SEXP>( const SEXP& obj ){
920920
return obj ;
921921
}
922922

923-
924-
// special case - FIXME : this is not template specializations of wrap<>
925923
inline SEXP wrap(const char* const v ){
926-
if (v == NULL)
927-
return R_NilValue;
928-
else
929-
return Rf_mkString(v) ;
924+
if (v)
925+
return Rf_mkString(v) ;
926+
else
927+
return R_NilValue;
930928
}
931929

932930
/**

inst/unitTests/cpp/wrap.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,14 @@ List multimap_string_generic(){
138138

139139
// [[Rcpp::export]]
140140
SEXP null_const_char(){
141-
const char *p = NULL; return wrap(p);
141+
const char *p = NULL;
142+
return wrap(p);
142143
}
143144

144145
// [[Rcpp::export]]
145146
SEXP nonnull_const_char(){
146-
const char *p = "foo"; return wrap(p) ;
147+
const char *p = "foo";
148+
return wrap(p) ;
147149
}
148150

149151
// [[Rcpp::export]]

0 commit comments

Comments
 (0)