Skip to content

Commit 9d7e6fc

Browse files
committed
Further refine Depends: as we cannot reply on a whitespace
1 parent b09406b commit 9d7e6fc

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

R/controlFiles.R

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,20 @@
1414
if (is.na(dt[,Depends])) return(invisible(NULL))
1515

1616
dep <- gsub("\\n", "", dt[,Depends])
17-
dep <- gsub("^R \\(.*?\\)[, ]*", "", dep, perl=TRUE)
18-
dep <- gsub(" \\(.*?\\)[, ]*", "", dep, perl=TRUE)
17+
deps <- trimws(strsplit(dep, ",")[[1]])
18+
deps <- sapply(deps, \(x) gsub("^R \\(.*?\\)", "", x, perl=TRUE), USE.NAMES=FALSE)
19+
deps <- Filter(nzchar, deps)
20+
deps <- sapply(deps, \(x) trimws(gsub("\\(.*?\\)", "", x, perl=TRUE)), USE.NAMES=FALSE)
1921

2022
curpkg <- dt[1,Package]
2123
rtdeps <- .pkgenv[["runtimedeps"]]
2224
has_rtdeps <- any(grepl(paste0("^",curpkg,":"), rtdeps))
2325
if (nchar(dep) == 0 && !has_rtdeps)
2426
return(invisible(NULL))
2527

26-
deps <- strsplit(dep, ",")[[1]]
27-
for (i in deps) {
28-
i <- gsub("^ ", "", i)
29-
if (.isBasePackage(i)) next
30-
j <- gsub(" ?\\(.*?\\)", "", i)
31-
p <- ap[Package==j, deb]
28+
for (d in deps) {
29+
if (.isBasePackage(d)) next
30+
p <- ap[Package==d, deb]
3231
cat(", ", p ,sep="", file=con, append=TRUE)
3332
}
3433

0 commit comments

Comments
 (0)