@@ -1141,6 +1141,11 @@ namespace attributes {
11411141 bool parseDependencies)
11421142 : sourceFile_(sourceFile), hasPackageInit_(false )
11431143 {
1144+
1145+ // transform packageName to valid C++ symbol
1146+ std::string packageNameCpp = packageName;
1147+ std::replace (packageNameCpp.begin (), packageNameCpp.end (), ' .' , ' _' );
1148+
11441149 // First read the entire file into a std::stringstream so we can check
11451150 // it for attributes (we don't want to do any of our more expensive
11461151 // processing steps if there are no attributes to parse)
@@ -1151,7 +1156,7 @@ namespace attributes {
11511156 // Check for attribute signature
11521157 if (contents.find (" [[Rcpp::" ) != std::string::npos ||
11531158 contents.find (" RCPP_MODULE" ) != std::string::npos ||
1154- contents.find (" R_init_" + packageName ) != std::string::npos) {
1159+ contents.find (" R_init_" + packageNameCpp ) != std::string::npos) {
11551160
11561161 // Now read into a list of strings (which we can pass to regexec)
11571162 // First read into a std::deque (which will handle lots of append
@@ -1230,7 +1235,7 @@ namespace attributes {
12301235 // Scan for package init function
12311236 hasPackageInit_ = false ;
12321237 commentState.reset ();
1233- std::string pkgInit = " R_init_" + packageName ;
1238+ std::string pkgInit = " R_init_" + packageNameCpp ;
12341239 Rcpp::List initMatches = regexMatches (lines_, " ^[^/]+" + pkgInit + " .*DllInfo.*$" );
12351240 for (int i = 0 ; i<initMatches.size (); i++) {
12361241
@@ -1968,7 +1973,7 @@ namespace attributes {
19681973 std::vector<std::size_t > routineArgs;
19691974 for (std::size_t i=0 ;i<nativeRoutines_.size (); i++) {
19701975 const Attribute& attr = nativeRoutines_[i];
1971- routineNames.push_back (package () + " _" + attr.function ().name ());
1976+ routineNames.push_back (packageCpp () + " _" + attr.function ().name ());
19721977 routineArgs.push_back (attr.function ().arguments ().size ());
19731978 }
19741979 std::string kRcppModuleBoot = " _rcpp_module_boot_" ;
@@ -2016,7 +2021,7 @@ namespace attributes {
20162021
20172022 ostr () << std::endl;
20182023
2019- ostr () << " RcppExport void R_init_" << package () << " (DllInfo *dll) {" << std::endl;
2024+ ostr () << " RcppExport void R_init_" << packageCpp () << " (DllInfo *dll) {" << std::endl;
20202025 ostr () << " R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);" << std::endl;
20212026 ostr () << " R_useDynamicSymbols(dll, FALSE);" << std::endl;
20222027 ostr () << " }" << std::endl;
0 commit comments