@@ -91,10 +91,28 @@ cpp_vendor <- function(path = "./inst/include/") {
9191
9292 message(" Removing 'LinkingTo: cpp11' from DESCRIPTION." )
9393
94- desc <- readLines(" DESCRIPTION" )
95- desc <- desc [! grepl(" ^LinkingTo:\\ s*cpp11" , desc )]
96- desc <- gsub(" ^LinkingTo:\\ s*cpp11,\\ s*" , " LinkingTo: " , desc )
97- desc <- gsub(" ,\\ s*cpp11" , " " , desc )
94+ descr <- readLines(" DESCRIPTION" )
95+ linking_to <- which(grepl(" ^LinkingTo:" , descr ))
96+
97+ if (length(linking_to ) > 0 ) {
98+ linking_to_end <- which(! grepl(" ^\\ s" , descr [- (1 : linking_to )]))
99+ if (length(linking_to_end ) > 0 ) {
100+ linking_to_end <- linking_to_end [1 ] + linking_to - 1
101+ } else {
102+ linking_to_end <- length(descr )
103+ }
104+ linking_to_str <- paste(descr [linking_to : linking_to_end ], collapse = " " )
105+ linking_to_str <- gsub(" \\ s+" , " " , linking_to_str )
106+ descr [linking_to ] <- linking_to_str
107+ descr <- descr [- ((linking_to + 1 ): linking_to_end )]
108+ linking_to_str <- gsub(" \\ s*cpp11(,|\\ s*\\ (.*\\ ))?" , " " , linking_to_str , perl = TRUE )
109+ linking_to_str <- gsub(" ,\\ s*$" , " " , linking_to_str )
110+ descr [linking_to ] <- linking_to_str
111+ }
112+
113+ if (grepl(" ^LinkingTo:\\ s*$" , descr [linking_to ])) {
114+ descr <- descr [- linking_to ]
115+ }
98116
99117 writeLines(descr , " DESCRIPTION" )
100118
0 commit comments