Skip to content

Commit fc33ab1

Browse files
committed
use zero length integer value when search is out of range
1 parent 20e11fa commit fc33ab1

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import(biocViews)
1010
import(methods)
1111
importFrom(BiocBaseUtils,checkInstalled)
1212
importFrom(BiocBaseUtils,isScalarCharacter)
13+
importFrom(BiocBaseUtils,isScalarNumber)
1314
importFrom(BiocBaseUtils,selectSome)
1415
importFrom(BiocFileCache,BiocFileCache)
1516
importFrom(BiocFileCache,bfcdownload)

R/checkRcoding.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,9 @@ checkSingleColon <- function(.BiocPackage, avail_pkgs = character(0L)) {
268268
found <- Reduce(`|`, found)
269269
hits <- which(found & tokens[, "token"] == tokenType)
270270
openBracket <- if (isExp) "{" else "("
271-
opar <- which(txt == openBracket)
272-
startHit <- vapply(hits, function(x) min(opar[opar > x]), numeric(1L))
273-
parnum <- tokens[startHit, "parent"]
274-
endHit <- nrow(tokens) - match(parnum, rev(tokens[, "parent"]))
275-
Map(seq, startHit, endHit)
271+
.getSigRange(
272+
tokens, hits, openBracket
273+
)
276274
}
277275

278276
.findMinNext <- function(tokens, after, cname = c("token", "text"), cvalue) {
@@ -284,6 +282,7 @@ checkSingleColon <- function(.BiocPackage, avail_pkgs = character(0L)) {
284282
min()
285283
}
286284

285+
#' @importFrom BiocBaseUtils isScalarNumber
287286
.getSigRange <- function(tokens, signalers, bracket) {
288287
opar <- which(tokens[, "text"] == bracket)
289288
lapply(
@@ -309,7 +308,10 @@ checkSingleColon <- function(.BiocPackage, avail_pkgs = character(0L)) {
309308
parnum <- tokens[startSig, "parent"]
310309
endSig <- nrow(tokens) - match(parnum, rev(tokens[, "parent"]))
311310
}
312-
seq(startSig, endSig)
311+
if (!isScalarNumber(startSig) || !isScalarNumber(endSig))
312+
integer(0L)
313+
else
314+
seq(startSig, endSig)
313315
}
314316
)
315317
}

0 commit comments

Comments
 (0)