[med-svn] [r-cran-globals] 03/05: New upstream version 0.10.3
Andreas Tille
tille at debian.org
Mon Oct 23 17:52:59 UTC 2017
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository r-cran-globals.
commit f65c9a25c9f84b4135b832c059ad5539c44ab696
Author: Andreas Tille <tille at debian.org>
Date: Mon Oct 23 19:50:59 2017 +0200
New upstream version 0.10.3
---
DESCRIPTION | 6 +++---
MD5 | 12 ++++++------
NEWS | 9 +++++++++
R/globalsOf.R | 24 +++++++++++++++++++++---
R/where.R | 4 ++--
man/globalsOf.Rd | 5 ++++-
tests/globalsOf.R | 25 +++++++++++++++++++++++++
7 files changed, 70 insertions(+), 15 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index 900945a..8e5c2ab 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,5 +1,5 @@
Package: globals
-Version: 0.10.2
+Version: 0.10.3
Depends: R (>= 3.1.2)
Imports: codetools
Title: Identify Global Objects in R Expressions
@@ -18,8 +18,8 @@ URL: https://github.com/HenrikBengtsson/globals
BugReports: https://github.com/HenrikBengtsson/globals/issues
RoxygenNote: 6.0.1
NeedsCompilation: no
-Packaged: 2017-08-08 07:17:15 UTC; hb
+Packaged: 2017-10-12 22:07:42 UTC; hb
Author: Henrik Bengtsson [aut, cre, cph]
Maintainer: Henrik Bengtsson <henrikb at braju.com>
Repository: CRAN
-Date/Publication: 2017-08-08 13:12:42 UTC
+Date/Publication: 2017-10-13 21:21:23 UTC
diff --git a/MD5 b/MD5
index b51154a..14e053e 100644
--- a/MD5
+++ b/MD5
@@ -1,25 +1,25 @@
-f2c2e4944d74ec290572d329bdfc6f40 *DESCRIPTION
+4f760cff11b2a21837febd6378ab1245 *DESCRIPTION
5103aaaf89ff0d14004d90b05fcc644f *NAMESPACE
-86ee49825cba10d85cd3afb38e7d5fa5 *NEWS
+ee1dea051f8fc61662ae83684d3858f5 *NEWS
4cae63bc2a767f0522c0943358e99d6f *R/Globals-class.R
bcb4032fbccd0e0c961146919372ffbc *R/cleanup.R
f801a77d386300552ddb867996f2aeb7 *R/findGlobals.R
-94d29805f550354c3c1d75fd53eb2f87 *R/globalsOf.R
+dd28303e3b38b94664f082b69e858105 *R/globalsOf.R
a3bb9fec59515b028f65771de5f47315 *R/packagesOf.R
f878905dff9c939fce69298df7b224be *R/utils.R
378b34c7d7031f615af88b52de72f936 *R/walkAST.R
-995c6d77b293896d9943e59be4310520 *R/where.R
+02769684a9ccbf65df50900fb885496b *R/where.R
abec206d57e9f3f4d34bb4a875d35490 *man/Globals.Rd
978342cde4007f1977a2a355dabf6ffa *man/cleanup.Globals.Rd
fc7000ee5990508042e8b53ede23dae1 *man/globalsByName.Rd
-b03448eb49c04241d505d1d570340a33 *man/globalsOf.Rd
+b3557e2741ae0c038c9f65ffdcda804a *man/globalsOf.Rd
71d33dd463fd36bf678fcf037e0d62aa *man/packagesOf.Globals.Rd
7520df319b9afd0c632d73ae339af702 *man/walkAST.Rd
97257c489172ab40d42d209b6ae579ee *tests/Globals.R
5c5558c14915e4f98844ac49f39be46b *tests/conservative.R
e373e47a402e06c64c0f7d18b0c78508 *tests/dotdotdot.R
e3e4b49566be287f8beeeaf1346f6ca9 *tests/formulas.R
-190f42520dc316df82c5353e5c1a246e *tests/globalsOf.R
+a80ceb7806f7313639e75b8fe501ad2f *tests/globalsOf.R
574e081fe6528451f152c2c1239ce806 *tests/liberal.R
3058995bc5b96840c58c0c4219d3e018 *tests/utils.R
c9bb0296119e85b060ad2a6bce2a4315 *tests/walkAST.R
diff --git a/NEWS b/NEWS
index 132e9ff..d3b1597 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,15 @@
Package: globals
================
+Version: 0.10.3 [2017-10-12]
+
+BUG FIXES:
+
+ o globalsOf(..., recursive = TRUE) would result in "Error in match.fun(FUN) :
+ node stack overflow" if one of the globals identified was a function that
+ called itself recursively (either directly or indirectly).
+
+
Version: 0.10.2 [2017-08-08]
BUG FIXES:
diff --git a/R/globalsOf.R b/R/globalsOf.R
index 4f35dc3..b258682 100644
--- a/R/globalsOf.R
+++ b/R/globalsOf.R
@@ -26,6 +26,9 @@
#' exist outside of namespaces ("packages"), will be recursively
#' scanned for globals.
#'
+#' @param skip (internal) A list of globals not to be searched for
+#' additional globals. Ignored unless \code{recursive} is TRUE.
+#'
#' @return A \link{Globals} object.
#'
#' @details
@@ -62,11 +65,12 @@
globalsOf <- function(expr, envir = parent.frame(), ...,
method = c("ordered", "conservative", "liberal"),
tweak = NULL, substitute = FALSE, mustExist = TRUE,
- unlist = TRUE, recursive = TRUE) {
+ unlist = TRUE, recursive = TRUE, skip = NULL) {
method <- match.arg(method)
if (substitute) expr <- substitute(expr)
-
+ stopifnot(is.null(skip) || is.list(skip))
+
mdebug("globalsOf(..., method = '%s', mustExist = %s, unlist = %s, recursive = %s) ...", method, mustExist, unlist, recursive) #nolint
## 1. Identify global variables (static code inspection)
@@ -111,16 +115,30 @@ globalsOf <- function(expr, envir = parent.frame(), ...,
mdebug(" - subset of globals to be scanned: [%d] %s",
length(globals_t), hpaste(sQuote(names(globals_t))))
names_t <- names(globals_t)
+
+ ## Avoid recursive scanning of already scanned ("known") globals
+ skip_t <- c(skip, globals_t)
+
for (gg in seq_along(globals_t)) {
mdebug(" + scanning global #%d (%s) ...", gg, sQuote(names_t[[gg]]))
fcn <- globals_t[[gg]]
+
+ ## Is function 'fcn' among the already identified globals?
+ already_scanned <- any(sapply(skip, FUN = identical, fcn))
+ if (already_scanned) next;
+
env <- environment(fcn) ## was 'env <- envir' in globals 0.8.0.
+
globals_gg <- globalsOf(fcn, envir = env, ..., method = method,
tweak = tweak, substitute = FALSE,
mustExist = mustExist, unlist = unlist,
- recursive = recursive)
+ recursive = recursive,
+ skip = skip_t)
if (length(globals_gg) > 0) {
globals <- c(globals, globals_gg)
+
+ skip_gg <- globals_gg[sapply(globals_gg, FUN = typeof) == "closure"]
+ skip_t <- c(skip_t, skip_gg)
}
}
globals <- unique(globals)
diff --git a/R/where.R b/R/where.R
index 392110e..d9891c9 100644
--- a/R/where.R
+++ b/R/where.R
@@ -28,7 +28,7 @@ where <- function(x, where = -1,
}
if (!inherits) {
- mdebug(" + failed to located: NULL")
+ mdebug(" + failed to locate: NULL")
mdebug("where(%s, where = %d, envir = %s, mode = %s, inherits = %s) ... DONE", sQuote(x), where, sQuote(envname(envir)), sQuote(mode), inherits) #nolint
return(NULL)
}
@@ -36,7 +36,7 @@ where <- function(x, where = -1,
env <- parent.env(env)
}
- mdebug("- failed to located: NULL")
+ mdebug("- failed to locate: NULL")
mdebug("where(%s, where = %d, envir = %s, mode = %s, inherits = %s) ... DONE",
sQuote(x), where, sQuote(envname(envir)), sQuote(mode), inherits)
diff --git a/man/globalsOf.Rd b/man/globalsOf.Rd
index e352a88..854d2d2 100644
--- a/man/globalsOf.Rd
+++ b/man/globalsOf.Rd
@@ -7,7 +7,7 @@
\usage{
globalsOf(expr, envir = parent.frame(), ..., method = c("ordered",
"conservative", "liberal"), tweak = NULL, substitute = FALSE,
- mustExist = TRUE, unlist = TRUE, recursive = TRUE)
+ mustExist = TRUE, unlist = TRUE, recursive = TRUE, skip = NULL)
}
\arguments{
\item{expr}{An R expression.}
@@ -35,6 +35,9 @@ If FALSE, a list of \code{length(expr)} sublists.}
\item{recursive}{If TRUE, globals that are closures (functions) and that
exist outside of namespaces ("packages"), will be recursively
scanned for globals.}
+
+\item{skip}{(internal) A list of globals not to be searched for
+additional globals. Ignored unless \code{recursive} is TRUE.}
}
\value{
A \link{Globals} object.
diff --git a/tests/globalsOf.R b/tests/globalsOf.R
index fcad2ff..b4c936f 100644
--- a/tests/globalsOf.R
+++ b/tests/globalsOf.R
@@ -160,6 +160,31 @@ for (method in c("ordered", "conservative", "liberal")) {
stopifnot(all(names(globals_l) %in% c("foo", "bar", "a")))
}
+
+message(" ** globalsOf() w/ recursive functions:")
+
+## "Easy"
+f <- function() Recall()
+globals <- globalsOf(f)
+str(globals)
+
+## Direct recursive call
+f <- function() f()
+globals <- globalsOf(f)
+str(globals)
+
+## Indirect recursive call
+f <- function() g()
+g <- function() f()
+globals_f <- globalsOf(f)
+str(globals_f)
+globals_g <- globalsOf(g)
+str(globals_g)
+globals_f <- globals_f[order(names(globals_f))]
+globals_g <- globals_g[order(names(globals_g))]
+stopifnot(identical(globals_g, globals_f))
+
+
message("*** globalsOf() ... DONE")
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-globals.git
More information about the debian-med-commit
mailing list