From 45f1f3b0d119d7d8a93f68e8a57aa37019559147 Mon Sep 17 00:00:00 2001 From: smeyer Date: Sat, 27 Apr 2024 14:09:33 +0000 Subject: [PATCH 001/546] faster re-make vignettes: skip compactPDF if up-to-date git-svn-id: https://svn.r-project.org/R/trunk@86485 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/admin.R | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/library/tools/R/admin.R b/src/library/tools/R/admin.R index be25605487a..13c40d9ca65 100644 --- a/src/library/tools/R/admin.R +++ b/src/library/tools/R/admin.R @@ -1,7 +1,7 @@ # File src/library/tools/R/admin.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2023 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -710,10 +710,7 @@ function(dir, outDir, keep.source = TRUE) domain = NA) ## We have to be careful to avoid repeated rebuilding. - vignettePDFs <- - file.path(outVignetteDir, - sub("$", ".pdf", - basename(file_path_sans_ext(vigns$docs)))) + vignettePDFs <- file.path(outVignetteDir, paste0(vigns$names, ".pdf")) upToDate <- file_test("-nt", vignettePDFs, vigns$docs) ## The primary use of this function is to build and install PDF @@ -756,12 +753,8 @@ function(dir, outDir, keep.source = TRUE) }) ## In case of an error, do not clean up: should we point to ## buildDir for possible inspection of results/problems? - ## We need to ensure that vignetteDir is in TEXINPUTS and BIBINPUTS. + ## We need to ensure that the src vignettes dir is in (TEX|BIB)INPUTS. if (vignette_is_tex(output)) { - ## - ## What if this fails? - ## Now gives a more informative error texi2pdf fails - ## or if it does not produce a .pdf. tryCatch({ texi2pdf(file = output, quiet = TRUE, texinputs = vigns$dir) output <- find_vignette_product(name, by = "texi2pdf", engine = engine) @@ -770,7 +763,6 @@ function(dir, outDir, keep.source = TRUE) sQuote(output), conditionMessage(e)), domain = NA, call. = FALSE) }) - ## } if(!file.copy(output, outVignetteDir, overwrite = TRUE)) @@ -780,6 +772,7 @@ function(dir, outDir, keep.source = TRUE) domain = NA) } + if (any(!upToDate)) compactPDF(outVignetteDir, gs_quality = "ebook") ## Need to change out of this dir before we delete it, From d12e98f0a7c8e24b221d7621f00563c5883a7f09 Mon Sep 17 00:00:00 2001 From: smeyer Date: Sat, 27 Apr 2024 15:26:27 +0000 Subject: [PATCH 002/546] fix checkVignettes(latex=TRUE) (was broken since R 3.0.0) git-svn-id: https://svn.r-project.org/R/trunk@86486 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/Vignettes.R | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/library/tools/R/Vignettes.R b/src/library/tools/R/Vignettes.R index c78e325c682..ef013982db4 100644 --- a/src/library/tools/R/Vignettes.R +++ b/src/library/tools/R/Vignettes.R @@ -1,7 +1,7 @@ # File src/library/tools/R/Vignettes.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2022 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -273,15 +273,20 @@ function(package, dir, lib.loc = NULL, ## for (i in seq_along(result$weave)) { file <- names(result$weave)[i] - output <- result$weave[i] + output <- result$weave[[i]] if (inherits(output, "error")) next if (!vignette_is_tex(output)) next + ## Ensure that the vignette dir is in TEX/BIBINPUTS. + ## This will often fail, however, when checking from an + ## installed 'package', as bib files are usually not installed .eval_with_capture({ result$latex[[file]] <- tryCatch({ - texi2pdf(file = output, clean = FALSE, quiet = TRUE) - find_vignette_product(name, by = "texi2pdf", engine = engine) + texi2pdf(file = output, clean = FALSE, quiet = TRUE, + texinputs = vigns$dir) + find_vignette_product(file_path_sans_ext(output), + by = "texi2pdf", engine = engine) }, error = identity) }) } From 68b7a64d1c4a9261ebe38d45f95b5bdd40f87209 Mon Sep 17 00:00:00 2001 From: smeyer Date: Sat, 27 Apr 2024 15:30:11 +0000 Subject: [PATCH 003/546] tweaks git-svn-id: https://svn.r-project.org/R/trunk@86487 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/stats/vignettes/reshape.Rnw | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/library/stats/vignettes/reshape.Rnw b/src/library/stats/vignettes/reshape.Rnw index fd8ff8d4b6c..f5e25a9cf80 100644 --- a/src/library/stats/vignettes/reshape.Rnw +++ b/src/library/stats/vignettes/reshape.Rnw @@ -58,7 +58,7 @@ time-varying variable. <<>>= set.seed(12345) n <- 5 -d1 <- data.frame(sex = sample(c("M", "F"), n, rep = TRUE), +d1 <- data.frame(sex = sample(c("M", "F"), n, replace = TRUE), ht.before = round(rnorm(n, 165, 6), 1), ht.after = round(rnorm(n, 165, 6), 1), wt.before = round(rnorm(n, 80, 6)), @@ -103,7 +103,7 @@ to be \dQuote{nicely} formatted. Suppose we instead had <<>>= n <- 5 -d2 <- data.frame(sex = sample(c("M", "F"), n, rep = TRUE), +d2 <- data.frame(sex = sample(c("M", "F"), n, replace = TRUE), ht_before = round(rnorm(n, 165, 6), 1), ht_after = round(rnorm(n, 165, 6), 1), wt_before = round(rnorm(n, 80, 6)), @@ -292,7 +292,7 @@ Conversion from long to wide format is generally simpler. Let us simulate long format data from the same hypothetical setup. <<>>= -d3 <- data.frame(sex = sample(c("M", "F"), 2 * n, rep = TRUE), +d3 <- data.frame(sex = sample(c("M", "F"), 2 * n, replace = TRUE), ht = round(rnorm(2 * n, 165, 6), 1), wt = round(rnorm(2 * n, 80, 6)), subject = rep(1:n, 2), @@ -325,7 +325,7 @@ in the dataset we have created. Let us fix that: <<>>= n <- 10 -d4 <- data.frame(sex = rep(sample(c("M", "F"), n, rep = TRUE), 2), +d4 <- data.frame(sex = rep(sample(c("M", "F"), n, replace = TRUE), 2), ht = round(rnorm(2 * n, 165, 6), 1), wt = round(rnorm(2 * n, 80, 6)), subject = rep(1:n, 2), From 3668ed5bfe5f1128d67d9027f2c202494c6b93f8 Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 29 Apr 2024 12:18:53 +0000 Subject: [PATCH 004/546] docu tweak, fixing PR#16865 git-svn-id: https://svn.r-project.org/R/trunk@86488 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/man/glob2rx.Rd | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/library/utils/man/glob2rx.Rd b/src/library/utils/man/glob2rx.Rd index 6e32952e434..62f72198d10 100644 --- a/src/library/utils/man/glob2rx.Rd +++ b/src/library/utils/man/glob2rx.Rd @@ -1,7 +1,7 @@ % File src/library/utils/man/glob2rx.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2008 R Core Team -% Copyright 2002-2008 The R Foundation +% Copyright 1995-2024 R Core Team +% Copyright 2002-2024 The R Foundation % Distributed under GPL 2 or later \name{glob2rx} @@ -10,6 +10,9 @@ \description{ Change \emph{wildcard} aka \emph{globbing} patterns into the corresponding regular expressions (\code{\link{regexp}}). + + This is also a practical didactical example for the use of + \code{\link{sub}()} and regular expressions. } \usage{ glob2rx(pattern, trim.head = FALSE, trim.tail = TRUE) @@ -31,7 +34,8 @@ glob2rx(pattern, trim.head = FALSE, trim.tail = TRUE) Note that now even \samp{(}, \samp{[} and \samp{\{} can be used in \code{pattern}, but \code{glob2rx()} may not work correctly with - arbitrary characters in \code{pattern}. + arbitrary characters in \code{pattern}, for example escaped special + characters. } \value{ A character vector of the same length as the input \code{pattern} @@ -42,6 +46,8 @@ glob2rx(pattern, trim.head = FALSE, trim.tail = TRUE) \seealso{ \code{\link{regexp}} about regular expression, \code{\link{sub}}, etc about substitutions using regexps. + \code{\link{Sys.glob}} does wildcard expansio, i.e., \dQuote{globbing} on + file paths more subtly, e.g., allowing to escape special characters. } \examples{ stopifnot(glob2rx("abc.*") == "^abc\\\\.",% '\\' doubled in Rd file! From b0f9958d7ea938151e007e401400d58beb16490f Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 29 Apr 2024 13:14:52 +0000 Subject: [PATCH 005/546] Tweaks for c86371. git-svn-id: https://svn.r-project.org/R/trunk@86489 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/version.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library/base/R/version.R b/src/library/base/R/version.R index 2842faf449e..a4c9507f1d6 100644 --- a/src/library/base/R/version.R +++ b/src/library/base/R/version.R @@ -321,9 +321,9 @@ function(..., na.rm) } else switch(.Generic, - max = x[which.max(v)], - min = x[which.min(v)], - range = x[c(which.min(v), which.max(v))]) + max = x[which(v == max(v))], + min = x[which(v == min(v))], + range = x[c(which(v == min(v)), which(v == max(v)))]) } as.character.numeric_version <- From c1f052f3b8c15986d6400efc4fea64950061412c Mon Sep 17 00:00:00 2001 From: smeyer Date: Mon, 29 Apr 2024 13:41:51 +0000 Subject: [PATCH 006/546] fix format input git-svn-id: https://svn.r-project.org/R/trunk@86490 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/stats/R/nlsFunc.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/stats/R/nlsFunc.R b/src/library/stats/R/nlsFunc.R index 791543d6f46..9526a82eaef 100644 --- a/src/library/stats/R/nlsFunc.R +++ b/src/library/stats/R/nlsFunc.R @@ -50,7 +50,7 @@ asOneSidedFormula <- character = as.name(object), expression = object[[1L]], stop(gettextf("'%s' cannot be of mode '%s'", - substitute(object), mode(object)), + deparse1(substitute(object)), mode(object)), domain = NA) )) class(ff) <- "formula" From 3246bd1c581dbcd1512d560fb07c82e0cfcea1fa Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 29 Apr 2024 14:08:58 +0000 Subject: [PATCH 007/546] Always stop on invalid numeric version specs. git-svn-id: https://svn.r-project.org/R/trunk@86492 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/version.R | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/library/base/R/version.R b/src/library/base/R/version.R index a4c9507f1d6..1a7f04f7efa 100644 --- a/src/library/base/R/version.R +++ b/src/library/base/R/version.R @@ -49,22 +49,7 @@ function(x, strict = TRUE, regexp, classes = NULL) if(!is.character(x)) { msg <- gettextf("invalid non-character version specification 'x' (type: %s)", typeof(x)) - if(tolower(Sys.getenv("_R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_")) - != "false") - stop(msg, domain = NA) - else - warning(msg, domain = NA, immediate. = TRUE) - if(nzchar(Sys.getenv("_R_CALLS_INVALID_NUMERIC_VERSION_"))) { - ## Showing the call stack as part of warning() may - ## truncate, so do it via message() ... - calls <- sys.calls() - msg <- paste0(gettext("Calls"), ":\n", - paste0(sprintf("%2i: ", seq_along(calls)), - vapply(calls, deparse1, "", - collapse = "\n "), - collapse = "\n")) - message(msg, domain = NA) - } + stop(msg, domain = NA) } x <- as.character(x) y <- rep.int(list(integer()), length(x)) From c9354b39169e43c3fd063eedce41014f985224d2 Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 29 Apr 2024 14:32:00 +0000 Subject: [PATCH 008/546] RIP Fritz Leisch git-svn-id: https://svn.r-project.org/R/trunk@86493 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/AUTHORS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/AUTHORS b/doc/AUTHORS index ce10c02bf23..3333dcc399c 100644 --- a/doc/AUTHORS +++ b/doc/AUTHORS @@ -13,7 +13,6 @@ Kurt Hornik Ross Ihaka Tomas Kalibera Michael Lawrence -Friedrich Leisch Uwe Ligges Thomas Lumley Martin Maechler @@ -28,7 +27,8 @@ Simon Urbanek plus Heiner Schwarte up to October 1999, Guido Masarotto up to June 2003, Stefano Iacus up to July 2014, Seth Falcon up to August 2015, Duncan Murdoch -up to September 2017, Martin Morgan up to June 2021, and Douglas Bates up to March 2024. +up to September 2017, Martin Morgan up to June 2021, Douglas Bates up to March 2024, +and Friedrich Leisch up to April 2024. Current R-core members can be contacted via email to R-project.org From 4d43a639936a466db1d039595b53c394c08d0e90 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 29 Apr 2024 14:48:41 +0000 Subject: [PATCH 009/546] Tweaks for c86489. git-svn-id: https://svn.r-project.org/R/trunk@86494 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/version.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/library/base/R/version.R b/src/library/base/R/version.R index 1a7f04f7efa..94b7a9d4fec 100644 --- a/src/library/base/R/version.R +++ b/src/library/base/R/version.R @@ -306,9 +306,10 @@ function(..., na.rm) } else switch(.Generic, - max = x[which(v == max(v))], - min = x[which(v == min(v))], - range = x[c(which(v == min(v)), which(v == max(v)))]) + max = x[which(v == max(v))[1L]], + min = x[which(v == min(v))[1L]], + range = x[c(which(v == min(v))[1L], + which(v == max(v))[1L])]) } as.character.numeric_version <- From 11a2f4083652e973316f01a1d0301ceb8517427b Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 29 Apr 2024 14:54:44 +0000 Subject: [PATCH 010/546] RIP 2 git-svn-id: https://svn.r-project.org/R/trunk@86495 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-FAQ.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-FAQ.texi b/doc/manual/R-FAQ.texi index d3465a54383..56dadf9311e 100644 --- a/doc/manual/R-FAQ.texi +++ b/doc/manual/R-FAQ.texi @@ -253,7 +253,6 @@ modify the R source code archive, currently consisting of @I{Ross Ihaka}, @I{Tomas Kalibera}, @I{Michael Lawrence}, -@I{Friedrich Leisch}, @I{Uwe Ligges}, @I{Thomas Lumley}, @I{Martin Maechler}, @@ -273,8 +272,9 @@ plus @I{Stefano Iacus} up to July 2014, @I{Seth Falcon} up to August 2015, @I{Duncan Murdoch} up to September 2017, -@I{Martin Morgan} up to June 2021, and -@I{Douglas Bates} up to March 2024. +@I{Martin Morgan} up to June 2021, +@I{Douglas Bates} up to March 2024, and +@I{Friedrich Leisch} up to April 2024. R has a home page at @url{https://www.R-project.org/}. It is @url{https://www.gnu.org/philosophy/free-sw.html, free software} From dd83e82c7b28b27c6198886ad9905d9bf22bad6f Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 30 Apr 2024 10:41:28 +0000 Subject: [PATCH 011/546] minor docfix git-svn-id: https://svn.r-project.org/R/trunk@86496 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/man/pkg2HTML.Rd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/tools/man/pkg2HTML.Rd b/src/library/tools/man/pkg2HTML.Rd index f071cd2d896..2fe1d7cbb1c 100644 --- a/src/library/tools/man/pkg2HTML.Rd +++ b/src/library/tools/man/pkg2HTML.Rd @@ -56,8 +56,8 @@ pkg2HTML(package, dir = NULL, lib.loc = NULL, \code{\link{Rd2HTML}}. } \item{out}{a filename or connection object to which to write the - output. The default \code{out = ""} is equivalent to - \code{out = \link{stdout}()}.} + output. By default (\code{NULL}), the filename is inferred from + \code{hooks$pkg_href}, which defaults to \file{\var{pkg}.html}.} \item{toc_entry}{ Determines whether the entry for a help page in the table of contents is the name of the help page or its title. } \item{...}{additional arguments, passed on to From 43563c0316335e512937109bc491da06d2280709 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 30 Apr 2024 10:46:38 +0000 Subject: [PATCH 012/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86497 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index 2011f42fe39..2e6f6d8c346 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -16,7 +16,7 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Canada (BC) [https]",Canada,Burnaby,https://mirror.rcg.sfu.ca/mirror/CRAN/,"Simon Fraser University, Burnaby","research-support # sfu.ca",1,ca "Canada (MB) [https]",Canada,Winnipeg,https://muug.ca/mirror/cran/,"Manitoba Unix User Group","mirror # muug.ca",1,ca,"secure_mirror_from_master" "Canada (ON 1) [https]",Canada,Waterloo,https://mirror.csclub.uwaterloo.ca/CRAN/,"University of Waterloo","syscom # csclub.uwaterloo.ca",1,ca,"secure_mirror_from_master" -"Canada (ON 2) [https]",Canada,Hamilton,https://cran.mirror.rafal.ca/,"Rafal Rzeczkowski","Rafal Rzeczkowski ",1,ca, +"Canada (ON 2) [https]",Canada,Hamilton,https://cran.mirror.rafal.ca/,"Rafal Rzeczkowski","Rafal Rzeczkowski ",1,ca,"secure_mirror_from_master" "Chile (Santiago) [https]",Chile,Santiago,https://cran.dcc.uchile.cl/,"Departamento de Ciencias de la ComputaciĆ³n, Universidad de Chile","Mauricio Vargas ",1,cl,"secure_mirror_from_master" "China (Beijing 1) [https]",China,Beijing,https://mirrors.tuna.tsinghua.edu.cn/CRAN/,"TUNA Team, Tsinghua University","Justin Wong ",1,cn, "China (Beijing 2) [https]",China,Beijing,https://mirrors.bfsu.edu.cn/CRAN/,"Beijing Foreign Studies University","Aron Xu ",1,cn,"secure_mirror_from_master" From 7a21ab3bd67b00097ad899c1cfa7fe9be7757629 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 30 Apr 2024 10:48:30 +0000 Subject: [PATCH 013/546] =?UTF-8?q?Belatedly=20add=20info=20on=20breaking?= =?UTF-8?q?=20changes=20from=20c85933=20(wish=20of=20Herv=C3=A9=20Pag?= =?UTF-8?q?=C3=A8s).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.r-project.org/R/trunk@86498 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index c2402284995..a08842fc159 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -374,6 +374,9 @@ allows non-syntactic completions to be wrapped in backquotes. This is currently only useful for \I{Jupyter} notebooks via the \pkg{IRkernel} package, and may cause problems for other backends. + + \item The numeric version creators now stop on invalid + non-character version specifications. } } From 9ef44be4ac35b77afde80fa8dd98300d27fce95b Mon Sep 17 00:00:00 2001 From: maechler Date: Tue, 30 Apr 2024 13:55:21 +0000 Subject: [PATCH 014/546] fulfill PR#17409 "wish" git-svn-id: https://svn.r-project.org/R/trunk@86501 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 8 ++++++-- src/library/base/R/datetime.R | 9 +++++++-- tests/datetime3.R | 13 +++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index a08842fc159..7ebcc743a61 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -15,8 +15,8 @@ \subsection{NEW FEATURES}{ \itemize{ \item \code{as.integer(rl)} and hence \code{as.raw(rl)} now work for - a \code{list} of \code{raw(1)} elements, as proposed by Michael - Chirico's \PR{18696}. + a \code{list} of \code{raw(1)} elements, as proposed by \I{Michael + Chirico}'s \PR{18696}. } } @@ -85,6 +85,10 @@ \item \code{as.data.frame(m, make.names=NA)} now works correctly for a matrix \code{m} with \code{NA}'s in row names. + + \item The error message from \code{[["hour"]]} and similar + now mentions \code{*[[, "hour"]]}, as wished for in \PR{17409} and + proposed by \I{Michael Chirico}. } } } diff --git a/src/library/base/R/datetime.R b/src/library/base/R/datetime.R index d3185db7fea..f870e95a966 100644 --- a/src/library/base/R/datetime.R +++ b/src/library/base/R/datetime.R @@ -1,7 +1,7 @@ # File src/library/base/R/datetime.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2023 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -1509,7 +1509,12 @@ OlsonNames <- function(tzdir = NULL) `[[.POSIXlt` <- function(x, i, drop = TRUE) { if(!missing(i) && is.character(i)) { - i <- match(i, names(x), incomparables = c("", NA_character_)) + idx <- match(i, names(x), incomparables = c("", NA_character_)) + if (length(i) == 1L && is.na(idx) && i %in% names(unclass(x[[1L]]))) + stop(gettextf( + 'No element named "%s" found in x, did you mean x[, "%1$s"] instead?', i), + domain = NA) + i <- idx } .POSIXlt(lapply(unCfillPOSIXlt(x), `[[`, i, drop = drop), attr(x, "tzone"), oldClass(x)) diff --git a/tests/datetime3.R b/tests/datetime3.R index bb9b47ae4f9..a274768b035 100644 --- a/tests/datetime3.R +++ b/tests/datetime3.R @@ -3,6 +3,8 @@ .pt <- proc.time() +tryCmsg <- function(expr) tryCatch(expr, error = conditionMessage) # typically == *$message +assertErrV <- function(...) tools::assertError(..., verbose=TRUE) options(warn = max(1, getOption("warn"))) if(!nzchar(Sys.getenv("_R_CHECK_DATETIME3_NO_TZ_"))) withAutoprint({ @@ -575,6 +577,17 @@ ct <- .POSIXct(c(-1.25, -1, 0, 1), tz = "UTC") stopifnot(d1 == 0, d2 == 0) ## where (1 0 0 0) and (2 0 0 0) {w/ "internal" tz src} in R <= 4.3.1 +## [[ method uses underlying class names as a backup +(pl <- as.POSIXlt(as.POSIXct("2024-04-25 12:34:56") + c(a = 0, mday = 10))) +assertErrV(pl[["b"]]) +stopifnot(exprs = { + identical(pl[["a"]], pl[[1L]]) # both as previously + identical(pl[["mday"]], pl[[2L]]) + identical(pl[,"mday"], rep(25L, 2)) + identical(pl[,"yday"], rep(115L, 2)) + grepl('x[, "yday"]', print(tryCmsg(pl[["yday"]])))# new error msg +}) + ## keep at end From 967289ddc051c05c9568307eb747842a1ab6dbdf Mon Sep 17 00:00:00 2001 From: maechler Date: Wed, 1 May 2024 08:43:29 +0000 Subject: [PATCH 015/546] fix discrete inversion p |--> q; for qbinom() and more: PR#18711 git-svn-id: https://svn.r-project.org/R/trunk@86504 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 6 +++++- src/nmath/qDiscrete_search.h | 28 +++++++++++++++++----------- tests/d-p-q-r-tst-2.R | 16 ++++++++++++++++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 7ebcc743a61..2dbbd42d427 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -49,7 +49,7 @@ \subsection{C-LEVEL FACILITIES}{ \itemize{ \item The non-API and hidden entry points \code{Rf_setIVector}, - \code{Rf_setRVector} and \code{Rf_setSVector} have been removed. + \code{Rf_setRVector} and \code{Rf_setSVector} have been removed. } } @@ -89,6 +89,10 @@ \item The error message from \code{[["hour"]]} and similar now mentions \code{*[[, "hour"]]}, as wished for in \PR{17409} and proposed by \I{Michael Chirico}. + + \item \code{qbinom()} and potentially \code{qpois()}, \code{qnbinom()}, + no longer sometimes fail accurate inversion (of \code{pbinom()}, + etc), thanks to Christopher Chang's report and patch in \PR{18711}. } } } diff --git a/src/nmath/qDiscrete_search.h b/src/nmath/qDiscrete_search.h index 0bdbcb49eea..df7bdf1ad6b 100644 --- a/src/nmath/qDiscrete_search.h +++ b/src/nmath/qDiscrete_search.h @@ -1,6 +1,6 @@ /* * Mathlib : A C Library of Special Functions - * Copyright (C) 2000-2021 The R Core Team + * Copyright (C) 2000-2024 The R Core Team * Copyright (C) 2005-2021 The R Foundation * * This program is free software; you can redistribute it and/or modify @@ -18,7 +18,7 @@ * https://www.R-project.org/Licenses/ */ -/* This is #included from ./qnbinom.c , ......... +/* This is #included from ./qpois.c ./qbinom.c, ./qnbinom{,_mu}.c */ #define PST_0(a, b) a ## b @@ -31,7 +31,7 @@ #define _qDIST_ PASTE(q, _thisDIST_) /** For a discrete distribution on the integers, - For P(x) := (x, ), find p-quantile y(p) :<==> P(y) < p <= P(y) + For P(x) := (x, ), find p-quantile y = y(p) :<==> P(y-1) < p <= P(y) @param y current guess @param *z := (y, ..) @@ -90,38 +90,44 @@ static double DO_SEARCH_FUN(_dist_PARS_DECL_) } else { // (lower_tail, *z < p) or (upper tail, *z >= p): search to the __right__ for(int iter = 0; ; iter++) { + double prevy = y; + double newz = -1.; // -Wall #ifndef MATHLIB_STANDALONE if(iter % 10000 == 0) R_CheckUserInterrupt(); #endif y += incr; #ifdef _dist_MAX_y if(y < _dist_MAX_y) - *z = P_DIST(y, _dist_PARS_); + newz = P_DIST(y, _dist_PARS_); else if(y > _dist_MAX_y) y = _dist_MAX_y; #else - *z = P_DIST(y, _dist_PARS_); + newz = P_DIST(y, _dist_PARS_); #endif if( #ifdef _dist_MAX_y y == _dist_MAX_y || #endif - ISNAN(*z) || (lower_tail ? (*z >= p) : (*z < p))) + ISNAN(newz) || (lower_tail ? (newz >= p) : (newz < p))) { R_DBG_printf(" new y=%.15g, z=%g = " AS_CHAR(_pDIST_) "(y,*) %s;" - " ==> search() returns after %d iter.\n", y, *z, - ISNAN(*z) ? "is NaN" : (lower_tail ? ">= p" : "< p"), iter); - return y; + " ==> search() returns after %d iter.\n", y, newz, + ISNAN(newz) ? "is NaN" : (lower_tail ? ">= p" : "< p"), iter); + if (incr <= 1) { + *z = newz; + return y; + } + return prevy; } + *z = newz; } } } // do_search() /* -* Note : "same" code in qbinom.c, qnbinom.c __FIXME__ NOT YET for qpois() ?? -* FIXME: This is far from optimal [cancellation for p ~= 1, etc]: +* Note : called in qbinom.c, qnbinom.c but not (yet) qpois.c -- NB: only DBG_print()ing; *no other* effect */ #define q_DISCRETE_01_CHECKS() do { \ double p_n; /* p in the "normal" (lower_tail=TRUE, log.p=FALSE) scale */ \ diff --git a/tests/d-p-q-r-tst-2.R b/tests/d-p-q-r-tst-2.R index 97df2e02e16..2c7fe4c0623 100644 --- a/tests/d-p-q-r-tst-2.R +++ b/tests/d-p-q-r-tst-2.R @@ -856,6 +856,7 @@ stopifnot(exprs = { pbeta(1, 0, 0) == 1 # gave 0.5 }) + ## PR#18640 -- stirlerr(x) concerns (for *non* half-integer x) -- visible in dgamma() sh <- 465/32 # = 14.53125 x0 <- 1/4 + 8:20 @@ -870,5 +871,20 @@ relE * 2^53 # 2 2 -2 0 0 2 -1 0 0 2 0 0 2 // was in {-95 : -91} in R stopifnot(abs(relE) < 9e-16) # max{x86_64}: 2.22e-16 +## PR#18711 -- qbinom() - inversion of pbinom() +## but probably also fixing qpois(), qnbinom() cases +sz <- 6040:6045 +prb <- 0.995 +(qb6 <- qbinom(p = 0.05, size = sz, prob = prb)) +(pqb6 <- pbinom(qb6, size = sz, prob = prb)) +(pqb6_1 <- pbinom(qb6-1, size = sz, prob = prb)) +stopifnot(exprs = { + qb6 == c(6001:6004,6004:6005) # not in R 4.4.0, nor 4.1.0 + 1 > pqb6 & pqb6 >= 0.05 # " +X 0.05 > pqb6_1 & pqb6_1 >= 0.035# " +}) +## was wrong for R versions in [4.1.1, 4.4.0] + + cat("Time elapsed: ", proc.time() - .ptime,"\n") From 2c5ea73312f8fa9a158d3cafd12c7f11c9c2892b Mon Sep 17 00:00:00 2001 From: ripley Date: Wed, 1 May 2024 14:35:32 +0000 Subject: [PATCH 016/546] clean up git-svn-id: https://svn.r-project.org/R/trunk@86505 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/d-p-q-r-tst-2.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/d-p-q-r-tst-2.R b/tests/d-p-q-r-tst-2.R index 2c7fe4c0623..256950ec99c 100644 --- a/tests/d-p-q-r-tst-2.R +++ b/tests/d-p-q-r-tst-2.R @@ -881,7 +881,7 @@ prb <- 0.995 stopifnot(exprs = { qb6 == c(6001:6004,6004:6005) # not in R 4.4.0, nor 4.1.0 1 > pqb6 & pqb6 >= 0.05 # " -X 0.05 > pqb6_1 & pqb6_1 >= 0.035# " + 0.05 > pqb6_1 & pqb6_1 >= 0.035# " }) ## was wrong for R versions in [4.1.1, 4.4.0] From 1f97573c65beb39865c3214bf2c01363b2c8468f Mon Sep 17 00:00:00 2001 From: maechler Date: Wed, 1 May 2024 18:23:49 +0000 Subject: [PATCH 017/546] fix s/1.1/1.0/ thinko in comment git-svn-id: https://svn.r-project.org/R/trunk@86506 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/d-p-q-r-tst-2.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/d-p-q-r-tst-2.R b/tests/d-p-q-r-tst-2.R index 256950ec99c..98c2c88a40e 100644 --- a/tests/d-p-q-r-tst-2.R +++ b/tests/d-p-q-r-tst-2.R @@ -879,7 +879,7 @@ prb <- 0.995 (pqb6 <- pbinom(qb6, size = sz, prob = prb)) (pqb6_1 <- pbinom(qb6-1, size = sz, prob = prb)) stopifnot(exprs = { - qb6 == c(6001:6004,6004:6005) # not in R 4.4.0, nor 4.1.0 + qb6 == c(6001:6004,6004:6005) # not in R 4.4.0, nor 4.1.1 1 > pqb6 & pqb6 >= 0.05 # " 0.05 > pqb6_1 & pqb6_1 >= 0.035# " }) From cae99e94ed95882edf9ca4392c9454444b9d828f Mon Sep 17 00:00:00 2001 From: maechler Date: Wed, 1 May 2024 18:40:30 +0000 Subject: [PATCH 018/546] comment only: _skewness_ (PR#8058) git-svn-id: https://svn.r-project.org/R/trunk@86507 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/nmath/qpois.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nmath/qpois.c b/src/nmath/qpois.c index e6f87d3bca9..b5c81e9e9a9 100644 --- a/src/nmath/qpois.c +++ b/src/nmath/qpois.c @@ -64,7 +64,7 @@ double qpois(double p, double lambda, int lower_tail, int log_p) double mu = lambda, sigma = sqrt(lambda), - // had gamma = sigma; PR#8058 should be kurtosis which is mu^-0.5 = 1/sigma + // had gamma = sigma; PR#8058 should be skewness which is mu^-0.5 = 1/sigma gamma = 1.0/sigma; R_DBG_printf("qpois(p=%.12g, lambda=%.15g, l.t.=%d, log=%d):" From ac4a7db9323f196e546e7999394880bb563c6f0c Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 2 May 2024 09:21:58 +0000 Subject: [PATCH 019/546] Do not allow NA as double/complex in scan() when not in na.strings() (PR#17289). git-svn-id: https://svn.r-project.org/R/trunk@86508 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/scan.c | 6 +++--- tests/reg-tests-1e.R | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/scan.c b/src/main/scan.c index f78ea1b0723..a24e93805db 100644 --- a/src/main/scan.c +++ b/src/main/scan.c @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 1998-2023 The R Core Team. + * Copyright (C) 1998-2024 The R Core Team. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -522,7 +522,7 @@ static void extractItem(char *buffer, SEXP ans, R_xlen_t i, LocalData *d) if (isNAstring(buffer, 0, d)) REAL(ans)[i] = NA_REAL; else { - REAL(ans)[i] = Strtod(buffer, &endp, TRUE, d); + REAL(ans)[i] = Strtod(buffer, &endp, FALSE, d); if (!isBlankString(endp)) expected("a real", buffer, d); } @@ -531,7 +531,7 @@ static void extractItem(char *buffer, SEXP ans, R_xlen_t i, LocalData *d) if (isNAstring(buffer, 0, d)) COMPLEX(ans)[i].r = COMPLEX(ans)[i].i = NA_REAL; else { - COMPLEX(ans)[i] = strtoc(buffer, &endp, TRUE, d); + COMPLEX(ans)[i] = strtoc(buffer, &endp, FALSE, d); if (!isBlankString(endp)) expected("a complex", buffer, d); } diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index eb0ca7f825b..08c3d40bd93 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1380,6 +1380,12 @@ stopifnot(exprs = { }) ## the last lost row.names => dim(.) was 0 x 3 instead of d0's 2 x 3, in R <= 4.4.0 +## Scan should not treat "NA" as double/complex when na.strings doesn't +## include it (PR#17289) +(r <- tryCid(scan(text="NA", what=double(), na.strings=character()))) +stopifnot(inherits(r, "error")) +(r <- tryCid(scan(text="NA", what=complex(), na.strings=character()))) +stopifnot(inherits(r, "error")) ## keep at end From a57e698f01879189d2e7f8a2759579f53ab1c202 Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 2 May 2024 12:40:59 +0000 Subject: [PATCH 020/546] Use a blocking socket in Rhttpd worker threads on Windows. git-svn-id: https://svn.r-project.org/R/trunk@86509 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/modules/internet/Rhttpd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/internet/Rhttpd.c b/src/modules/internet/Rhttpd.c index 35e27755fc9..70d4f722399 100644 --- a/src/modules/internet/Rhttpd.c +++ b/src/modules/internet/Rhttpd.c @@ -1292,6 +1292,13 @@ static void srv_input_handler(void *data) if (c->ih) c->ih->userData = c; add_worker(c); #else + /* The accepted socket inherits properties of the socket listened to. + The server socket is non-blocking, because WSAEventSelect has been used on it. + Make sure the accepted socket is blocking. */ + WSAEventSelect(c->sock, NULL, 0); + unsigned long mode = 0; + ioctlsocket(c->sock, FIONBIO, &mode); + if (!add_worker(c)) { /* create worker thread only if the worker * was accepted */ if (!(c->thread = CreateThread(NULL, 0, WorkerThreadProc, From 522fbe53f67020f647a814a518c0a04e19a06040 Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 2 May 2024 13:01:40 +0000 Subject: [PATCH 021/546] Fix formatted output in debug messages. git-svn-id: https://svn.r-project.org/R/trunk@86510 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/modules/internet/Rhttpd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/modules/internet/Rhttpd.c b/src/modules/internet/Rhttpd.c index 70d4f722399..a43e52a1557 100644 --- a/src/modules/internet/Rhttpd.c +++ b/src/modules/internet/Rhttpd.c @@ -301,7 +301,7 @@ static int add_worker(httpd_conn_t *c) { for (; i < MAX_WORKERS; i++) if (!workers[i]) { #ifdef _WIN32 - DBG(printf("registering worker %p as %d (thread=0x%x)\n", (void*) c, i, (int) c->thread)); + DBG(printf("registering worker %p as %d (thread=%p)\n", (void*) c, i, (void *) c->thread)); #else DBG(printf("registering worker %p as %d (handler=%p)\n", (void*) c, i, (void*) c->ih)); #endif @@ -904,7 +904,8 @@ static void worker_input_handler(void *data) { char *s = c->line_buf; ssize_t n = recv(c->sock, c->line_buf + c->line_pos, LINE_BUF_SIZE - c->line_pos - 1, 0); - DBG(printf("[recv n=%d, line_pos=%d, part=%d]\n", n, c->line_pos, (int)c->part)); + DBG(printf("[recv n=%lld, line_pos=%llu, part=%d]\n", (long long)n, + (unsigned long long)c->line_pos, (int)c->part)); if (n < 0) { /* error, scrape this worker */ remove_worker(c); return; @@ -1108,10 +1109,12 @@ static void worker_input_handler(void *data) { } if (c->part == PART_BODY && c->body) { /* BODY - this branch always returns */ if (c->body_pos < c->content_length) { /* need to receive more ? */ - DBG(printf("BODY: body_pos=%d, content_length=%ld\n", c->body_pos, c->content_length)); + DBG(printf("BODY: body_pos=%llu, content_length=%ld\n", + (unsigned long long)c->body_pos, c->content_length)); ssize_t n = recv(c->sock, c->body + c->body_pos, c->content_length - c->body_pos, 0); - DBG(printf(" [recv n=%d - had %u of %lu]\n", n, c->body_pos, c->content_length)); + DBG(printf(" [recv n=%lld - had %llu of %lu]\n", (long long)n, + (unsigned long long)c->body_pos, c->content_length)); c->line_pos = 0; if (n < 0) { /* error, scrap this worker */ remove_worker(c); @@ -1211,7 +1214,7 @@ static WSAEVENT server_thread_should_stop = NULL; */ static LRESULT CALLBACK RhttpdWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - DBG(Rprintf("RhttpdWindowProc(%x, %x, %x, %x)\n", (int) hwnd, (int) uMsg, (int) wParam, (int) lParam)); + DBG(Rprintf("RhttpdWindowProc(%p, %x, %x, %x)\n", (void *) hwnd, (int) uMsg, (int) wParam, (int) lParam)); if (hwnd == message_window && uMsg == WM_RHTTP_CALLBACK) { httpd_conn_t *c = (httpd_conn_t*) lParam; process_request_main_thread(c); From 145c843da2856bf06c817b2831f4fcf9f515f2e7 Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 2 May 2024 15:39:31 +0000 Subject: [PATCH 022/546] Fix debug messages not to use R API (they may be printed on non-R threads). git-svn-id: https://svn.r-project.org/R/trunk@86511 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/modules/internet/Rhttpd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules/internet/Rhttpd.c b/src/modules/internet/Rhttpd.c index a43e52a1557..9ee71f4c222 100644 --- a/src/modules/internet/Rhttpd.c +++ b/src/modules/internet/Rhttpd.c @@ -496,9 +496,9 @@ static void process_request(httpd_conn_t *c) /* SendMessage is synchronous, so it will wait until the message * is processed */ - DBG(Rprintf("enqueuing process_request_main_thread\n")); + DBG(printf("enqueuing process_request_main_thread\n")); SendMessage(message_window, WM_RHTTP_CALLBACK, 0, (LPARAM) c); - DBG(Rprintf("process_request_main_thread returned\n")); + DBG(printf("process_request_main_thread returned\n")); ReleaseMutex(process_request_mutex); } @@ -527,7 +527,7 @@ static SEXP handler_for_path(const char *path) { char fn[64]; memcpy(fn, e, c - e); /* create a local C string with the name for the install() call */ fn[c - e] = 0; - DBG(Rprintf("handler_for_path('%s'): looking up custom handler '%s'\n", path, fn)); + DBG(printf("handler_for_path('%s'): looking up custom handler '%s'\n", path, fn)); /* we cache custom_handlers_env so in case it has not been loaded yet, fetch it */ if (!custom_handlers_env) { if (!R_HandlersName) R_HandlersName = install(".httpd.handlers.env"); @@ -543,7 +543,7 @@ static SEXP handler_for_path(const char *path) { } } } - DBG(Rprintf(" - falling back to default httpd\n")); + DBG(printf(" - falling back to default httpd\n")); return install("httpd"); } @@ -557,7 +557,7 @@ static void process_request_(void *ptr) int code = 200; const void *vmax = NULL; - DBG(Rprintf("process request for %p\n", (void*) c)); + DBG(printf("process request for %p\n", (void*) c)); if (!c || !c->url) return; /* if there is not enough to process, bail out */ vmax = vmaxget(); s = c->url; @@ -578,7 +578,7 @@ static void process_request_(void *ptr) LCONS(handler_for_path(c->url), sArgs), sTrue)); SET_TAG(CDR(CDR(x)), install("silent")); - DBG(Rprintf("eval(try(httpd('%s'),silent=TRUE))\n", c->url)); + DBG(printf("eval(try(httpd('%s'),silent=TRUE))\n", c->url)); /* evaluate the above in the tools namespace */ SEXP toolsNS = PROTECT(R_FindNamespace(mkString("tools"))); @@ -619,7 +619,7 @@ static void process_request_(void *ptr) if (TYPEOF(x) == STRSXP && LENGTH(x) > 0) { /* string means there was an error */ const char *s = translateCharUTF8(STRING_ELT(x, 0)); send_http_response(c, " 500 Evaluation error\r\nConnection: close\r\nContent-type: text/plain\r\n\r\n"); - DBG(Rprintf("respond with 500 and content: %s\n", translateChar(STRING_ELT(x, 0)))); + DBG(printf("respond with 500 and content: %s\n", translateChar(STRING_ELT(x, 0)))); if (c->method != METHOD_HEAD) send_response(c->sock, s, strlen(s)); c->attr |= CONNECTION_CLOSE; /* force close */ @@ -1214,7 +1214,7 @@ static WSAEVENT server_thread_should_stop = NULL; */ static LRESULT CALLBACK RhttpdWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - DBG(Rprintf("RhttpdWindowProc(%p, %x, %x, %x)\n", (void *) hwnd, (int) uMsg, (int) wParam, (int) lParam)); + DBG(printf("RhttpdWindowProc(%p, %x, %x, %x)\n", (void *) hwnd, (int) uMsg, (int) wParam, (int) lParam)); if (hwnd == message_window && uMsg == WM_RHTTP_CALLBACK) { httpd_conn_t *c = (httpd_conn_t*) lParam; process_request_main_thread(c); From 4e9cc9bddf4ff138b003826675f01bd77309c751 Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 3 May 2024 09:49:12 +0000 Subject: [PATCH 023/546] deprecating another dozen functions useing `MethodsList` class (now defunct) git-svn-id: https://svn.r-project.org/R/trunk@86513 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 + src/library/methods/NAMESPACE | 5 +- src/library/methods/R/ClassUnion.R | 5 +- src/library/methods/R/MethodsList.R | 213 ++---------------- src/library/methods/R/MethodsListClass.R | 20 +- src/library/methods/R/NextMethod.R | 5 +- src/library/methods/R/RMethodUtils.R | 12 +- src/library/methods/R/methods-defunct.R | 182 ++++++++++++++- src/library/methods/R/methodsTable.R | 42 ++-- .../methods/man/EmptyMethodsList-class.Rd | 34 ++- .../methods/man/MethodDefinition-class.Rd | 2 +- .../methods/man/MethodWithNext-class.Rd | 6 +- src/library/methods/man/MethodsList-class.Rd | 63 ------ src/library/methods/man/MethodsList.Rd | 201 ----------------- src/library/methods/man/RMethodUtils.Rd | 27 +-- .../methods/man/genericFunction-class.Rd | 4 +- src/library/methods/man/loadMethod.Rd | 46 ++++ src/library/methods/man/methods-defunct.Rd | 31 ++- tests/reg-S4.Rout.save | 6 +- 19 files changed, 352 insertions(+), 556 deletions(-) delete mode 100644 src/library/methods/man/MethodsList-class.Rd delete mode 100644 src/library/methods/man/MethodsList.Rd create mode 100644 src/library/methods/man/loadMethod.Rd diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 2dbbd42d427..73f36860046 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -31,6 +31,10 @@ \itemize{ \item \code{is.R()} is defunct. Environment variable \env{_R_DEPRECATED_IS_R_} no longer has any effect. + + \item Several deprecated auxiliary functions and the + \code{MethodsList} class for S4 method handling are now defunct in + package \pkg{methods}, or have even been removed. } } diff --git a/src/library/methods/NAMESPACE b/src/library/methods/NAMESPACE index 4bf8f6842bf..240658e1a47 100644 --- a/src/library/methods/NAMESPACE +++ b/src/library/methods/NAMESPACE @@ -97,7 +97,7 @@ export(getGroup) export(getGroupMembers) export(getLoadActions) export(getMethod) -export(getMethods) +export(getMethods) # "semi"-deprecated export(getMethodsForDispatch) export(getMethodsMetaData) export(getPackageName) @@ -125,9 +125,7 @@ export(isVirtualClass) export(isXS3Class) export(languageEl) export("languageEl<-") -export(linearizeMlist) export(listFromMethods) -export(listFromMlist) export(loadMethod) export(makeClassRepresentation) export(makeExtends) @@ -186,7 +184,6 @@ export(showClass) export(showDefault) export(showExtends) export(showMethods) -export(showMlist) export(sigToEnv) export(signature) export(slot, "slot<-", ".hasSlot") diff --git a/src/library/methods/R/ClassUnion.R b/src/library/methods/R/ClassUnion.R index 35a47cb3b43..6b90dee0526 100644 --- a/src/library/methods/R/ClassUnion.R +++ b/src/library/methods/R/ClassUnion.R @@ -27,9 +27,8 @@ }, where = where) ## some classes in methods package are unions--now they can be officially setClassUnion("OptionalFunction", c("function", "NULL"), where) - setClassUnion("PossibleMethod", c("function", "MethodDefinition"), where) - clList <- c("ClassUnionRepresentation", "OptionalFunction", - "PossibleMethod") + ## rather in ./MethodsListClass.R .InitMethod...(): setClassUnion("PossibleMethod", .....) + clList <- c("ClassUnionRepresentation", "OptionalFunction") assign(".SealedClasses", c(get(".SealedClasses", where), clList), where) } diff --git a/src/library/methods/R/MethodsList.R b/src/library/methods/R/MethodsList.R index 4bb8932c9d7..fb02e3def8e 100644 --- a/src/library/methods/R/MethodsList.R +++ b/src/library/methods/R/MethodsList.R @@ -1,7 +1,7 @@ # File src/library/methods/R/MethodsList.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2018 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ MethodsList <- ## methods and, in R, to emulate S4-style methods. function(.ArgName, ...) { - .MlistDeprecated("MethodsList()") + .MlistDefunct("MethodsList") value <- makeMethodsList(list(...)) if(is.name(.ArgName)){} else if(is.character(.ArgName) && length(.ArgName) == 1) @@ -46,7 +46,7 @@ MethodsList <- makeMethodsList <- function(object, level=1) { - .MlistDeprecated("makeMethodsList()") + .MlistDefunct("makeMethodsList()") mnames <- allNames(object) if(.noMlists()) { keep <- mnames %in% c("", "ANY") @@ -91,7 +91,7 @@ SignatureMethod <- ## the signatures. function(names, signature, definition) { - .MlistDeprecated("SignatureMethod()") + .MlistDefunct("SignatureMethod()") n <- length(signature) if(n > length(names)) stop("arguments 'names' and 'signature' must have the same length") @@ -111,7 +111,7 @@ insertMethod <- ## the signature, and return the modified MethodsList. function(mlist, signature, args, def, cacheOnly = FALSE) { - .MlistDeprecated("insertMethod()") + .MlistDefunct("insertMethod()") if(.noMlists() && !identical(unique(signature), "ANY")) return(mlist) ## Checks for assertions about valid calls. @@ -205,7 +205,7 @@ MethodsListSelect <- resetAllowed = TRUE # FALSE when called from selectMethod, .findNextMethod ) { - .MlistDeprecated("MethodsListSelect()") + .MlistDefunct("MethodsListSelect()") if(!resetAllowed) # ensure we restore the real methods for this function resetMlist <- .getMethodsForDispatch(fdef) ## look for call from C dispatch code during another call to MethodsListSelect @@ -358,13 +358,13 @@ MethodsListSelect <- } emptyMethodsList <- function(mlist, thisClass = "ANY", sublist = list()) { - .MlistDeprecated("emptyMethodsList()") + .MlistDefunct("emptyMethodsList()") sublist[thisClass] <- list(NULL) new("EmptyMethodsList", argument = mlist@argument, sublist = sublist) } insertMethodInEmptyList <- function(mlist, def) { - .MlistDeprecated("insertMethodInEmptyList()") + .MlistDefunct("insertMethodInEmptyList()") value <- new("MethodsList", argument = mlist@argument) sublist <- mlist@sublist submethods <- sublist[[1L]] @@ -399,7 +399,7 @@ finalDefaultMethod <- domain = NA) } method -} + } inheritedSubMethodLists <- @@ -412,7 +412,7 @@ inheritedSubMethodLists <- ## on which methods were previously used. See the detailed discussion of methods.) function(object, thisClass, mlist, ev) { - .MlistDeprecated("inheritedSubMethodLists()") + .MlistDefunct("inheritedSubMethodLists()") methods <- slot(mlist, "methods")## only direct methods defaultMethod <- methods[["ANY"]]## maybe NULL classes <- names(methods) @@ -606,79 +606,6 @@ matchSignature <- value } -showMlist <- - ## Prints the contents of the MethodsList. If `includeDefs' the signatures and the - ## corresponding definitions will be printed; otherwise, only the signatures. - ## - ## If `includeDefs' is `TRUE', the currently known inherited methods are included; - ## otherwise, only the directly defined methods. -function(mlist, includeDefs = TRUE, inherited = TRUE, classes = NULL, useArgNames = TRUE, - printTo = stdout()) -{ - .MlistDeprecated("showMlist()") - if(isFALSE(printTo)) { - tmp <- tempfile() - con <- file(tmp, "w") - } - else - con <- printTo - object <- linearizeMlist(mlist, inherited) - methods <- object@methods - signatures <- object@classes - args <- object@arguments - if(!is.null(classes) && length(signatures)>0) { - keep <- !vapply(signatures, function(x, y) all(is.na(match(x, y))), NA, classes) - methods <- methods[keep] - signatures <- signatures[keep] - args <- args[keep] - } - if(length(methods) == 0) - cat(file=con, "\n") - else { - n <- length(methods) - labels <- character(n) - if(useArgNames) { - for(i in 1L:n) { - sigi <- signatures[[i]] - labels[[i]] <- paste0(args[[i]], " = \"", sigi, "\"", - collapse = ", ") - } - } - else { - for(i in 1L:n) - labels[[i]] <- paste(signatures[[i]], collapse = ", ") - } - for(i in seq_along(methods)) { - cat(file=con, (if(includeDefs) "## Signature:" else ""), labels[[i]]) - method <- methods[[i]] - if(includeDefs) { - cat(file=con, ":\n") - if(is(method, "MethodDefinition")) ## really an assertion - cat(file=con, deparse(method@.Data), sep="\n") - else - cat(file=con, deparse(method), sep="\n") - } - if(is(method, "MethodDefinition") && - !identical(method@target, method@defined)) { - defFrom <- method@defined - cat(file = con, if(includeDefs) "##:" else "\n", - " (inherited from ", - paste0(names(defFrom), " = \"", - as.character(defFrom), "\"", - collapse = ", "), - ")", if(includeDefs) "\n", sep="") - } - cat(file=con, "\n") - } - } - if(isFALSE(printTo)) { - close(con) - value <- readLines(tmp) - unlink(tmp) - value - } -} - promptMethods <- function(f, filename = NULL, methods) { ## Generate information in the style of 'prompt' for the methods of @@ -760,107 +687,8 @@ promptMethods <- function(f, filename = NULL, methods) invisible(filename) } -##' only called from showMlist() above, which has been deprecated in R 3.2.0 (Apr.2015): -linearizeMlist <- - ## Undo the recursive nature of the methods list, making a list of - ## function definitions, with the names of the list being the - ## corresponding signatures (designed for printing; for looping over - ## the methods, use `listFromMlist' instead). - ## - ## The function calls itself recursively. `prev' is the previously - ## selected class names. - ## - ## If argument `classes' is provided, only signatures containing one - ## of these classes will be included. - function(mlist, inherited = TRUE) { - methods <- mlist@methods - allMethods <- mlist@allMethods - if(inherited && length(allMethods) >= length(methods)) { -## anames <- names(allMethods) -## inh <- is.na(match(anames, names(methods))) - methods <- allMethods - } - preC <- function(y, x)c(x,y) # used with lapply below - cnames <- names(methods) - value <- list() - classes <- list() - arguments <- list() - argname <- as.character(mlist@argument) - for(i in seq_along(cnames)) { - mi <- methods[[i]] - if(is.function(mi)) { - value <- c(value, list(mi)) - classes <- c(classes, list(cnames[[i]])) - arguments <- c(arguments, list(argname)) - } - else if(is(mi, "MethodsList")) { - .MlistDeprecated() - mi <- Recall(mi, inherited) - value <- c(value, mi@methods) - classes <- c(classes, lapply(mi@classes, preC, cnames[[i]])) - arguments <- c(arguments, lapply(mi@arguments, preC, argname)) - } - else - warning(gettextf("skipping methods list element %s of unexpected class %s\n\n", - paste(cnames[i], collapse = ", "), - dQuote(.class1(mi))), - domain = NA) - } - new("LinearMethodsList", methods = value, classes = classes, arguments = arguments) - } - -print.MethodsList <- function(x, ...) - showMlist(x) -## In R's own code, this is *only* used in mergeMethods(), deprecated in R 3.2.0 (Apr.2015) -listFromMlist <- - ## linearizes the MethodsList object into list(sigs, methods); `prefix' is the partial - ## signature (a named list of classes) to be prepended to the signatures in this object. - ## - ## A utility function used to iterate over all the individual methods in the object. - function(mlist, prefix = list(), sigs. = TRUE, methods. = TRUE) -{ - methodSlot <- slot(mlist, "methods") - mnames <- names(methodSlot) - argName <- as.character(slot(mlist, "argument")) - sigs <- list() - methods <- list() - for(i in seq_along(methodSlot)) { - thisMethod <- methodSlot[i] - thisClass <- mnames[[i]] - prefix[[argName]] <- thisClass - if(is.function(thisMethod)) { - if(sigs.) sigs <- c(sigs, list(prefix)) - if(methods.) methods <- c(methods, list(thisMethod)) - } - else { - more <- Recall(thisMethod, prefix) - if(sigs.) sigs <- c(sigs, more[[1]]) - if(methods.) methods <- c(methods, more[[2]]) - } - } - list(sigs, methods) -} - -.insertCachedMethods <- function(mlist, argName, Class, fromClass, def) { - if(is(def, "MethodsList")) { - .MlistDeprecated() - ## insert all the cached methods in def - newArg <- c(argName, as.character(def@argument)) - newDefs <- def@allMethods - newSigs <- as.list(names(newDefs)) - for(j in seq_along(newDefs)) - mlist <- Recall(mlist, newArg, c(Class, newSigs[[j]]), fromClass, - newDefs[[j]]) - } - else { - def <- .addMethodFrom(def, argName[1L], Class[1L], fromClass) - mlist <- insertMethod(mlist, Class, argName, def, TRUE) - } - mlist -} - .addMethodFrom <- function(def, arg, Class, fromClass) { if(is(def, "MethodDefinition")) { ## eventually, we may enforce method definition objects @@ -878,29 +706,16 @@ asMethodDefinition <- function(def, signature = list(.anyClassName), sealed = FA if(is.primitive(def) || is(def, "MethodDefinition")) def else { - value = new("MethodDefinition") + value <- new("MethodDefinition") value@.Data <- def classes <- .MakeSignature(new("signature"), def, signature, fdef) - value@target <- classes - value@defined <- classes + value@target <- classes + value@defined <- classes value } - } - -.trimMlist <- function(mlist, fromClass) { - mlist@methods <- mlist@methods[fromClass] - mlist@allMethods <- mlist@allMethods[fromClass] - mlist } -.noMlistsFlag <- TRUE -.noMlists <- function() { - ## if this were to be dynamically variable, but - ## it can't, IMO - ## isTRUE(getOption("noMlists")) - ## so instead - .noMlistsFlag -} +.noMlists <- function() TRUE .MlistDepTable <- new.env() .MlistDeprecated <- function(this = "", instead) { diff --git a/src/library/methods/R/MethodsListClass.R b/src/library/methods/R/MethodsListClass.R index fdb48731346..1a37e150f5b 100644 --- a/src/library/methods/R/MethodsListClass.R +++ b/src/library/methods/R/MethodsListClass.R @@ -1,7 +1,7 @@ # File src/library/methods/R/MethodsListClass.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2015 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,18 +16,12 @@ # A copy of the GNU General Public License is available at # https://www.R-project.org/Licenses/ +## 'FIXME' the function name is a *misnomer* since MethodsList s are defunct .InitMethodsListClass <- function(envir) { - if(exists(classMetaName("EmptyMethodsList"), envir)) + if(exists(classMetaName("PossibleMethod"), envir)) return(FALSE) clList <- character() - ## Even though it is defunct from R 3.2.0, other functions using it are - ## only deprecated: So we define it and give .MlistDeprecated() messages there: - setClass("MethodsList", - representation(methods = "list", argument = "name", allMethods = "list"), - where = envir); clList <- c(clList, "MethodsList") - setClass("EmptyMethodsList", representation(argument = "name", sublist = "list"), - where = envir); clList <- c(clList, "EmptyMethodsList") ## the classes for method definitions setClass("PossibleMethod", where = envir); clList <- c(clList, "PossibleMethod") @@ -89,6 +83,10 @@ TRUE } + +## Skeleton for the generic below +loadMethod <- function(method, fname, envir) method + ## some initializations that need to be done late .InitMethodDefinitions <- function(envir) { assign("asMethodDefinition", @@ -200,10 +198,6 @@ value[[what]] <- args[[what]] value }, where = envir) - ## from 2.11.0, the MethodsList class is deprecated - ## from 3.2.0, it is defunct - setMethod("initialize", "MethodsList", function(.Object, ...) .MlistDefunct(), - where = envir) ## make sure body(m) <- .... leaves a method as a method setGeneric("body<-", where = envir) diff --git a/src/library/methods/R/NextMethod.R b/src/library/methods/R/NextMethod.R index 796c574d505..d6c83de7987 100644 --- a/src/library/methods/R/NextMethod.R +++ b/src/library/methods/R/NextMethod.R @@ -1,7 +1,7 @@ # File src/library/methods/R/NextMethod.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2016 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -141,9 +141,6 @@ callNextMethod <- function(...) { } } -## Skeleton for the generic in ./MethodsListClass.R : -loadMethod <- function(method, fname, envir) method - .doSubNextCall <- function(call, method) { idrop <- match("drop", names(call)) hasDrop <- !is.na(idrop) diff --git a/src/library/methods/R/RMethodUtils.R b/src/library/methods/R/RMethodUtils.R index 5c3bb76da62..495c6d48bda 100644 --- a/src/library/methods/R/RMethodUtils.R +++ b/src/library/methods/R/RMethodUtils.R @@ -1,7 +1,7 @@ # File src/library/methods/R/RMethodUtils.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2021 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -259,7 +259,7 @@ mergeMethods <- ## and return the merged result. function(m1, m2, genericLabel = character()) { - .MlistDeprecated("mergeMethods()") + .MlistDefunct("mergeMethods()") if(length(genericLabel) && is(m2, "MethodsList")) m2 <- .GenericInPrimitiveMethods(m2, genericLabel) if(is.null(m1) || is(m1, "EmptyMethodsList")) @@ -731,7 +731,7 @@ assignMethodsMetaData <- { where <- as.environment(where) if(is(value, "MethodsList")) { - .MlistDeprecated() + .MlistDefunct() mname <- methodsPackageMetaName("M",fdef@generic, fdef@package) if(exists(mname, envir = where, inherits = FALSE) && bindingIsLocked(mname, where)) @@ -994,7 +994,7 @@ MethodAddCoerce <- function(method, argName, thisClass, methodClass) body(method, envir = environment(method)) <- newBody } else if(is(method, "MethodsList")) { - .MlistDeprecated() + .MlistDefunct() methods <- method@allMethods for(i in seq_along(methods)) methods[[i]] <- Recall(methods[[i]], addExpr) @@ -1012,7 +1012,7 @@ missingArg <- function(symbol, envir = parent.frame(), eval = FALSE) balanceMethodsList <- function(mlist, args, check = TRUE) { - .MlistDeprecated("balanceMethodsList()") + .MlistDefunct("balanceMethodsList()") moreArgs <- args[-1L] if(length(moreArgs) == 0L) return(mlist) @@ -1243,7 +1243,7 @@ metaNameUndo <- function(strings, prefix, searchForm = FALSE) list(FF = f,BODY = body(mi))) } else if(is(mi, "MethodsList")) { - .MlistDeprecated() + .MlistDefunct() mi <- Recall(mi, f) } else stop(sprintf("internal error: Bad methods list object in fixing methods for primitive function %s", diff --git a/src/library/methods/R/methods-defunct.R b/src/library/methods/R/methods-defunct.R index 4c806c499e5..174cadeef68 100644 --- a/src/library/methods/R/methods-defunct.R +++ b/src/library/methods/R/methods-defunct.R @@ -1,7 +1,7 @@ # File src/library/methods/R/methods-deprecated.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2012 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,3 +33,183 @@ ## } ## traceOff <- function(whatL) .Defunct("untrace") ## + + +## +## Defunct in 4.5.0 +## Removed in 4.5.0 +## --------- <----- 'sub-entry' separator +## showMlist <- +## ## Prints the contents of the MethodsList. If `includeDefs' the signatures and the +## ## corresponding definitions will be printed; otherwise, only the signatures. +## ## +## ## If `includeDefs' is `TRUE', the currently known inherited methods are included; +## ## otherwise, only the directly defined methods. +## function(mlist, includeDefs = TRUE, inherited = TRUE, classes = NULL, useArgNames = TRUE, +## printTo = stdout()) +## { +## .MlistDeprecated("showMlist()") +## if(isFALSE(printTo)) { +## tmp <- tempfile() +## con <- file(tmp, "w") +## } +## else +## con <- printTo +## object <- linearizeMlist(mlist, inherited) +## methods <- object@methods +## signatures <- object@classes +## args <- object@arguments +## if(!is.null(classes) && length(signatures)>0) { +## keep <- !vapply(signatures, function(x, y) all(is.na(match(x, y))), NA, classes) +## methods <- methods[keep] +## signatures <- signatures[keep] +## args <- args[keep] +## } +## if(length(methods) == 0) +## cat(file=con, "\n") +## else { +## n <- length(methods) +## labels <- character(n) +## if(useArgNames) { +## for(i in 1L:n) { +## sigi <- signatures[[i]] +## labels[[i]] <- paste0(args[[i]], " = \"", sigi, "\"", +## collapse = ", ") +## } +## } +## else { +## for(i in 1L:n) +## labels[[i]] <- paste(signatures[[i]], collapse = ", ") +## } +## for(i in seq_along(methods)) { +## cat(file=con, (if(includeDefs) "## Signature:" else ""), labels[[i]]) +## method <- methods[[i]] +## if(includeDefs) { +## cat(file=con, ":\n") +## if(is(method, "MethodDefinition")) ## really an assertion +## cat(file=con, deparse(method@.Data), sep="\n") +## else +## cat(file=con, deparse(method), sep="\n") +## } +## if(is(method, "MethodDefinition") && +## !identical(method@target, method@defined)) { +## defFrom <- method@defined +## cat(file = con, if(includeDefs) "##:" else "\n", +## " (inherited from ", +## paste0(names(defFrom), " = \"", +## as.character(defFrom), "\"", +## collapse = ", "), +## ")", if(includeDefs) "\n", sep="") +## } +## cat(file=con, "\n") +## } +## } +## if(isFALSE(printTo)) { +## close(con) +## value <- readLines(tmp) +## unlink(tmp) +## value +## } +## } +## --------- +## ##' only called from showMlist() above, which has been deprecated in R 3.2.0 (Apr.2015): +## linearizeMlist <- +## ## Undo the recursive nature of the methods list, making a list of +## ## function definitions, with the names of the list being the +## ## corresponding signatures (designed for printing; for looping over +## ## the methods, use `listFromMlist' instead). +## ## +## ## The function calls itself recursively. `prev' is the previously +## ## selected class names. +## ## +## ## If argument `classes' is provided, only signatures containing one +## ## of these classes will be included. +## function(mlist, inherited = TRUE) { +## methods <- mlist@methods +## allMethods <- mlist@allMethods +## if(inherited && length(allMethods) >= length(methods)) { +## ## anames <- names(allMethods) +## ## inh <- is.na(match(anames, names(methods))) +## methods <- allMethods +## } +## preC <- function(y, x)c(x,y) # used with lapply below +## cnames <- names(methods) +## value <- list() +## classes <- list() +## arguments <- list() +## argname <- as.character(mlist@argument) +## for(i in seq_along(cnames)) { +## mi <- methods[[i]] +## if(is.function(mi)) { +## value <- c(value, list(mi)) +## classes <- c(classes, list(cnames[[i]])) +## arguments <- c(arguments, list(argname)) +## } +## else if(is(mi, "MethodsList")) { +## .MlistDeprecated() +## mi <- Recall(mi, inherited) +## value <- c(value, mi@methods) +## classes <- c(classes, lapply(mi@classes, preC, cnames[[i]])) +## arguments <- c(arguments, lapply(mi@arguments, preC, argname)) +## } +## else +## warning(gettextf("skipping methods list element %s of unexpected class %s\n\n", +## paste(cnames[i], collapse = ", "), +## dQuote(.class1(mi))), +## domain = NA) +## } +## new("LinearMethodsList", methods = value, classes = classes, arguments = arguments) +## } +## --------- +## print.MethodsList <- function(x, ...) +## showMlist(x) +## --------- +## ## In R's own code, this is *only* used in mergeMethods(), deprecated in R 3.2.0 (Apr.2015) +## listFromMlist <- +## ## linearizes the MethodsList object into list(sigs, methods); `prefix' is the partial +## ## signature (a named list of classes) to be prepended to the signatures in this object. +## ## +## ## A utility function used to iterate over all the individual methods in the object. +## function(mlist, prefix = list(), sigs. = TRUE, methods. = TRUE) +## { +## methodSlot <- slot(mlist, "methods") +## mnames <- names(methodSlot) +## argName <- as.character(slot(mlist, "argument")) +## sigs <- list() +## methods <- list() +## for(i in seq_along(methodSlot)) { +## thisMethod <- methodSlot[i] +## thisClass <- mnames[[i]] +## prefix[[argName]] <- thisClass +## if(is.function(thisMethod)) { +## if(sigs.) sigs <- c(sigs, list(prefix)) +## if(methods.) methods <- c(methods, list(thisMethod)) +## } +## else { +## more <- Recall(thisMethod, prefix) +## if(sigs.) sigs <- c(sigs, more[[1]]) +## if(methods.) methods <- c(methods, more[[2]]) +## } +## } +## list(sigs, methods) +## } +## --------- +## .insertCachedMethods <- function(mlist, argName, Class, fromClass, def) { +## if(is(def, "MethodsList")) { +## .MlistDeprecated() +## ## insert all the cached methods in def +## newArg <- c(argName, as.character(def@argument)) +## newDefs <- def@allMethods +## newSigs <- as.list(names(newDefs)) +## for(j in seq_along(newDefs)) +## mlist <- Recall(mlist, newArg, c(Class, newSigs[[j]]), fromClass, +## newDefs[[j]]) +## } +## else { +## def <- .addMethodFrom(def, argName[1L], Class[1L], fromClass) +## mlist <- insertMethod(mlist, Class, argName, def, TRUE) +## } +## mlist +## } +## --------- +## diff --git a/src/library/methods/R/methodsTable.R b/src/library/methods/R/methodsTable.R index 4a905dbbf38..9260eb3473a 100644 --- a/src/library/methods/R/methodsTable.R +++ b/src/library/methods/R/methodsTable.R @@ -1,7 +1,7 @@ # File src/library/methods/R/methodsTable.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2023 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -208,13 +208,14 @@ } -.mlistAddToTable <- function(generic, mlist, table = new.env(TRUE, fenv), add = TRUE) { +## called only from .setupMethodsTables() [further below]: +.mtableAddToTable <- function(generic, mlist, table = new.env(TRUE, fenv), add = TRUE) { fenv <- environment(generic) signature <- generic@signature - if(!exists(".SigLength", envir = fenv, inherits = FALSE)) + if(!exists(".SigLength", envir = fenv, inherits = FALSE)) .setupMethodsTables(generic) n <- get(".SigLength", envir = fenv, inherits = FALSE) - .storeMlist(table, rep("ANY", n), mlist, 1, add, fenv) + .storeMtable(table, rep("ANY", n), mlist, 1, add, fenv) ## check for more args in the mlist than in the table nNow <- get(".SigLength", envir = fenv, inherits = FALSE) if(nNow > n) { @@ -225,17 +226,13 @@ } ## utility now *only* called once above -.storeMlist <- function(table, sig, mlist, i, add, fenv) { - ## once generic functions are installed from 2.11.0 or later, this should - ## only be called with mlist a method or NULL. - if(is.null(mlist)) return(table) - m <- if(is(mlist, "MethodsList")) { .MlistDefunct(); mlist@methods } - else list(ANY=mlist) - - ## once MethodsList is defunct, this should be rewritten (and renamed!) +.storeMtable <- function(table, sig, method, i, add, fenv) { + ## method: a method or NULL. + if(is.null(method)) return(table) + ## else + m <- list(ANY=method) - ## the methods slot is a list named by class, with elements either - ## method definitions or mlists + ## the methods slot is a list named by class, with elements method definitions classes <- names(m) for(j in seq_along(m)) { el <- m[[j]] @@ -248,17 +245,10 @@ } else if(is(el,"MethodsList")) { .MlistDefunct() - i1 <- i+1 - if(i1 >= length(sig)) { - ## a reset of the labels will be needed - assign(".SigLength", i1, envir = fenv) - sig <- c(sig, rep("ANY", i1-length(sig))) - } - Recall(table, sig, el, i1, add, fenv) } else stop(gettextf( - "invalid mlist element for signature %s at level %d (should be MethodDefinition or .Primitive, had class %s)", + "invalid method element for signature %s at level %d (should be MethodDefinition or .Primitive, had class %s)", sQuote(classes[[j]]), i, dQuote(class(el))), @@ -270,8 +260,8 @@ .cacheMethodInTable <- function(fdef, sig, def, table = get(".AllMTable", envir = fenv)) { ## store method in cache table. - ## called from setMethod() - ## also Called from cacheMethod (from as(), as<-()) + ## called from setMethod(), and + ## also from cacheMethod (from as(), as<-()) fenv <- environment(fdef) if(missing(table) && !exists(".AllMTable", envir = fenv, inherits = FALSE)) .setupMethodsTables(fdef) @@ -975,8 +965,8 @@ argSyms <- lapply(generic@signature, as.name) assign(".SigArgs", argSyms, envir = env) if(initialize) { - mlist <- generic@default # from 2.11.0: method, primitive or NULL, not MethodsList - mtable <- .mlistAddToTable(generic, mlist) # by default, adds to an empty table + mtable <- generic@default # from 2.11.0: method, primitive or NULL, not MethodsList + mtable <- .mtableAddToTable(generic, mtable) # by default, adds to an empty table assign(".MTable", mtable, envir = env) } else ## the current .MTable diff --git a/src/library/methods/man/EmptyMethodsList-class.Rd b/src/library/methods/man/EmptyMethodsList-class.Rd index cd48e2f8500..83af300dd72 100644 --- a/src/library/methods/man/EmptyMethodsList-class.Rd +++ b/src/library/methods/man/EmptyMethodsList-class.Rd @@ -2,11 +2,20 @@ % Part of the R package, https://www.R-project.org % Copyright 1995-2015 R Core Team % Distributed under GPL 2 or later - \name{EmptyMethodsList-class} \docType{class} +\title{S4 Classes Used Internally During Method Selection} \alias{EmptyMethodsList-class} -\title{Internal Class representing Empty Methods List } +\alias{optionalMethod-class} +\alias{PossibleMethod-class} +\alias{standardGeneric-class} +\alias{standardGenericWithTrace-class} +\alias{nonstandardGeneric-class} +\alias{nonstandardGenericFunction-class} +\alias{nonstandardGroupGenericFunction-class} +\alias{OptionalFunction-class} +\alias{derivedDefaultMethod-class} +\alias{internalDispatchMethod-class} \description{ Objects from class \code{"EmptyMethodsList"} are generated during method selection to indicate failed search (forcing backtracking). @@ -14,24 +23,35 @@ All these are for internal use.} \usage{ ## class described below -"EmptyMethodsList" +"EmptyMethodsList" # deprecated, since \R 3.2.0; rather "defunct" from 4.5.0 ### Other, virtual classes used in method dispatch -"OptionalMethods" +"standardGeneric" +"standardGenericWithTrace" +"nonstandardGeneric" +"nonstandardGenericFunction" +"nonstandardGroupGenericFunction" +"OptionalFunction" +"optionalMethod" "PossibleMethod" +"derivedDefaultMethod" +"internalDispatchMethod" } -\section{Slots}{ +\section{Extends / Slots}{ + \code{"EmptyMethodsList"}: \describe{ \item{\code{argument}:}{Object of class \code{"name"} the argument names being selected on.} \item{\code{sublist}:}{Object of class \code{"list"} (unused, and perhaps to be dropped in a later version.) } } + + \code{"optionalMethod"} and + \code{"PossibleMethod"} have \emph{no} slots and extend S4 class \code{"\linkS4class{function}"}. } \section{Methods}{ - No methods defined with class \code{"EmptyMethodsList"} in the - signature. + No methods defined with class \code{"EmptyMethodsList"} in the signature. } \seealso{ Function \code{\link{MethodsListSelect}} (deprecated since \R version diff --git a/src/library/methods/man/MethodDefinition-class.Rd b/src/library/methods/man/MethodDefinition-class.Rd index 3556b65ce1a..d7e244d9f1b 100644 --- a/src/library/methods/man/MethodDefinition-class.Rd +++ b/src/library/methods/man/MethodDefinition-class.Rd @@ -36,7 +36,7 @@ \section{Extends}{ Class \code{"function"}, from data part.\cr Class \code{"PossibleMethod"}, directly.\cr - Class \code{"OptionalMethods"}, by class \code{"function"}. + Class \code{"optionalMethod"}, by class \code{"function"}. } \details{ Method definition objects are functions with additional information diff --git a/src/library/methods/man/MethodWithNext-class.Rd b/src/library/methods/man/MethodWithNext-class.Rd index 7d44926629c..ce9f297c6fc 100644 --- a/src/library/methods/man/MethodWithNext-class.Rd +++ b/src/library/methods/man/MethodWithNext-class.Rd @@ -1,6 +1,6 @@ % File src/library/methods/man/MethodWithNext-class.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2007 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{MethodWithNext-class} @@ -33,14 +33,12 @@ Class \code{"MethodDefinition"}, directly.\cr Class \code{"function"}, from data part.\cr Class \code{"PossibleMethod"}, by class \code{"MethodDefinition"}.\cr - Class \code{"OptionalMethods"}, by class \code{"MethodDefinition"}. + Class \code{"optionalMethod"}, by class \code{"MethodDefinition"}. } \section{Methods}{ \describe{ \item{findNextMethod}{\code{signature(method = "MethodWithNext")}: used internally by method dispatch. } - \item{loadMethod}{\code{signature(method = "MethodWithNext")}: used - internally by method dispatch. } \item{show}{\code{signature(object = "MethodWithNext")} } } } diff --git a/src/library/methods/man/MethodsList-class.Rd b/src/library/methods/man/MethodsList-class.Rd deleted file mode 100644 index bdd3b1ea2c8..00000000000 --- a/src/library/methods/man/MethodsList-class.Rd +++ /dev/null @@ -1,63 +0,0 @@ -% File src/library/methods/man/MethodsList-class.Rd -% Part of the R package, https://www.R-project.org -% Copyright 1995-2015 R Core Team -% Distributed under GPL 2 or later - -\name{MethodsList-class} -\alias{MethodsList-class} -\alias{body<-,MethodDefinition-method} -\docType{class} -\title{Class \code{"MethodsList"}, Defunct Representation of Methods } -\description{ This class of objects was used in the original - implementation of the package to control method dispatch. Its use - is now defunct, but object appear as the default method slot in - generic functions. This and any other remaining uses will be - removed in the future. - - For the modern alternative, see \linkS4class{listOfMethods}. - -The details in this documentation are retained to allow analysis of -old-style objects. } -\section{Slots}{\describe{ - - \item{\code{argument}:}{Object of class \code{"name"}. The name of the - argument being used for dispatch at this level. } - \item{\code{methods}:}{A named list of the methods (and method lists) - defined \emph{explicitly} for this argument. - The names are the names of classes, and the corresponding - element defines the method or methods to be used if the corresponding - argument has that class. See the details below.} - \item{\code{allMethods}:}{A named list, contains - all the directly defined methods from the \code{methods} slot, plus - any inherited methods. Ignored when methods tables are used for dispatch (see \link{Methods_Details}). } -}} - -\details{ - Suppose a function \code{f} has - formal arguments \code{x} and \code{y}. The methods list object for - that function has the object \code{as.name("x")} as its - \code{argument} slot. An element of the methods named \code{"track"} - is selected if the actual argument corresponding to \code{x} is an - object of class \code{"track"}. If there is such an element, it can - generally be either a function or another methods list object. - - In the first case, the function defines the method to use for any call - in which \code{x} is of class \code{"track"}. In the second case, the - new methods list object defines the available methods depending on - the remaining formal arguments, in this example, \code{y}. - - Each method corresponds conceptually to a \emph{signature}; - that is a named list of classes, with names corresponding to some or - all of the formal arguments. In the previous example, if selecting - class \code{"track"} for \code{x}, finding that the selection was - another methods list and then selecting class \code{"numeric"} for - \code{y} would produce a method associated with the signature - \code{x = "track", y = "numeric"}. - -} - -\section{Extends}{ -Class \code{"OptionalMethods"}, directly. -} -\keyword{classes} -\keyword{methods} diff --git a/src/library/methods/man/MethodsList.Rd b/src/library/methods/man/MethodsList.Rd deleted file mode 100644 index 6948e911b9e..00000000000 --- a/src/library/methods/man/MethodsList.Rd +++ /dev/null @@ -1,201 +0,0 @@ -% File src/library/methods/man/MethodsList.Rd -% Part of the R package, https://www.R-project.org -% Copyright 1995-2016 R Core Team -% Distributed under GPL 2 or later - -\name{MethodsList} -\title{\code{MethodsList} Objects} -% -\alias{listFromMlist}% only used in listFromMlist(), deprecated below -\alias{linearizeMlist}% only used in showMlist(), deprecated below -% -% but finalDefaultMethod() and loadMethod() seem somewhat important : -\alias{finalDefaultMethod} -\alias{loadMethod} -\alias{loadMethod-methods} -\alias{loadMethod,ANY-method} -\alias{loadMethod,MethodDefinition-method} -\alias{loadMethod,MethodWithNext-method} -%% ALl the following are deprecated since R 3.2.0: -\alias{MethodsList} -\alias{makeMethodsList} -\alias{SignatureMethod} -\alias{insertMethod} -\alias{inheritedSubMethodLists} -\alias{showMlist} -\alias{print.MethodsList} -\alias{emptyMethodsList} -\alias{insertMethodInEmptyList} -\alias{mergeMethods} -\alias{MethodsListSelect} -\description{ - These functions create and manipulate \code{MethodsList} objects, the - objects formerly used in \R to store methods for dispatch. Use of - these objects is deprecated since \R 3.2.0, as it will rarely be a - good idea. Where methods dispatch is - to be studied, see \code{\link{selectMethod}}. For computations - that iterate over methods or over method signatures, see - \code{\link{findMethods}}, which returns a linearized methods list - to hold method definitions, usually more convenient for iteration - than the recursive \code{MethodsList} objects. -} -\usage{ -listFromMlist(mlist, prefix = list(), sigs. = TRUE, methods. = TRUE) - -linearizeMlist(mlist, inherited = TRUE) - -finalDefaultMethod(method) - -loadMethod(method, fname, envir) - -##--------- These are all deprecated, since R 3.2.0 ---------- - -MethodsList(.ArgName, ...) -makeMethodsList(object, level=1) -SignatureMethod(names, signature, definition) -insertMethod(mlist, signature, args, def, cacheOnly) -inheritedSubMethodLists(object, thisClass, mlist, ev) - -showMlist(mlist, includeDefs = TRUE, inherited = TRUE, - classes, useArgNames, printTo = stdout() ) -\method{print}{MethodsList}(x, ...) - -mergeMethods(m1, m2, genericLabel) - -emptyMethodsList(mlist, thisClass = "ANY", sublist = list()) -} - -\section{Details}{ - - \describe{ - - %% \item{\code{MethodsList}:}{ - %% Create a MethodsList object out of the arguments. - - %% Conceptually, this object is a named collection of methods to be - %% dispatched when the (first) argument in a function call matches - %% the class corresponding to one of the names. A final, unnamed - %% element (i.e., with name \code{""}) corresponds to the default - %% method. - - %% The elements can be either a function, or another MethodsList. In - %% the second case, this list implies dispatching on the second - %% argument to the function using that list, given a selection of - %% this element on the first argument. Thus, method dispatching on - %% an arbitrary number of arguments is defined. - - %% MethodsList objects are used primarily to dispatch OOP-style - %% methods and, in R, to emulate S4-style methods. - %% } - - %% \item{\code{SignatureMethod}:}{ - %% construct a MethodsList object containing (only) this method, - %% corresponding to the signature; i.e., such that - %% \code{signature[[1]]} is the match for the first argument, - %% \code{signature[[2]]} for the second argument, and so on. The - %% string \code{"missing"} means a match for a missing argument, and - %% \code{"ANY"} means use this as the default setting at this level. - - %% The first argument is the argument names to be used for dispatch - %% corresponding to the signatures. - %% } - - %% \item{\code{insertMethod}:}{ - %% insert the definition \code{def} into the MethodsList object, - %% \code{mlist}, corresponding to the signature. By default, insert - %% it in the slot \code{"methods"}, but \code{cacheOnly=TRUE} inserts - %% it into the \code{"allMethods"} slot (used for dispatch but not saved). - %% } - - %% \item{\code{inheritedSubMethodLists}:}{ - %% Utility function to match the object or the class (if the object - %% is \code{NULL}) to the elements of a methods list. - %% Used in finding inherited methods, and not meant to be called - %% directly. - %% } - - %% \item{\code{showMlist}:}{ - %% Prints the contents of the MethodsList. If \code{includeDefs} the - %% signatures and the corresponding definitions will be printed; - %% otherwise, only the signatures. - %% } - - \item{\code{listFromMlist}:}{ - Undo the recursive nature of the methods list, making a list of - \code{list(sigs,methods)} of function definitions, i.e.\sspace{}of - matching signatures and methods. - \code{prefix} is the partial signature (a named list of classes) - to be prepended to the signatures in this object. If \code{sigs.} - or \code{methods.} are \code{FALSE}, the resulting part of the - return value will be empty. - - A utility function used to iterate over all the individual methods - in the object, it calls itself recursively. - } - - \item{\code{linearizeMlist}:}{ - Undo the recursive nature of the methods list, making a list of - function definitions, with the names of the list being the - corresponding signatures. - - Designed for printing; for looping over the methods, use the above - \code{listFromMlist} instead. - } - - \item{\code{finalDefaultMethod}:}{ - The default method or NULL. With the demise of - \code{"MethodsList"} objects, this function only checks that the - value given it is a method definition, primitive or NULL. - } - - %% \item{\code{mergeMethods}:}{ - %% Merges the methods in the second MethodsList object into the - %% first, and returns the merged result. Called from - %% \code{\link{getAllMethods}}. For a primitive function, - %% \code{genericLabel} is supplied as the name of the generic. - %% } - - \item{\code{loadMethod}:}{ - Called, if necessary, just before a call to \code{method} is - dispatched in the frame \code{envir}. The function exists so that - methods can be defined for special classes of objects. Usually - the point is to assign or modify information in the frame - environment to be used evaluation. For example, the standard - class \code{MethodDefinition} has a method that stores the target - and defined signatures in the environment. Class - \code{MethodWithNext} has a method taking account of the - mechanism for storing the method to be used in a call to - \code{\link{callNextMethod}}. - - Any methods defined for \code{loadMethod} must return the function - definition to be used for this call; typically, this is just the - \code{method} argument. - } - - %% \item{\code{MethodsListSelect}}{ - %% The function \code{MethodsListSelect} performs a full search - %% (including all inheritance and group generic information: see the - %% \link{Methods} documentation page for details on how this works). - %% The call returns a possibly revised methods list object, - %% incorporating any method found as part of the \code{allMethods} - %% slot. This search was used by the evaluator when methods lists - %% were the metadata for methods dispatch. This function is now deprecated. - %% } - } -} -%% \note{ -%% Note that \code{MethodsList} objects represent methods only in the \R -%% implementation. You can use them to find or manipulate information about -%% methods, but avoid doing so if you want your code to port to S-Plus. -%% } -\references{ - Chambers, John M. (2008) - \emph{Software for Data Analysis: Programming with R} - Springer. (For the R version.) - - Chambers, John M. (1998) - \emph{Programming with Data} - Springer (For the original S4 version.) -} -\keyword{internal} - diff --git a/src/library/methods/man/RMethodUtils.Rd b/src/library/methods/man/RMethodUtils.Rd index e9daac2a45d..de2d244a916 100644 --- a/src/library/methods/man/RMethodUtils.Rd +++ b/src/library/methods/man/RMethodUtils.Rd @@ -1,22 +1,10 @@ % File src/library/methods/man/RMethodUtils.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2015 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{RMethodUtils} \title{Method Utilities} -%% FIXME: undocumented utilities (Sep. 23/02) -\alias{asMethodDefinition} -\alias{standardGeneric-class} -\alias{standardGenericWithTrace-class} -\alias{nonstandardGeneric-class} -\alias{nonstandardGenericFunction-class} -\alias{nonstandardGroupGenericFunction-class} -\alias{OptionalFunction-class} -\alias{PossibleMethod-class} -\alias{optionalMethod-class} -\alias{derivedDefaultMethod-class} -\alias{internalDispatchMethod-class} %% \alias{substituteFunctionArgs} \alias{makeGeneric} @@ -38,11 +26,12 @@ \alias{cacheGenericsMetaData} \alias{setPrimitiveMethods} \alias{missingArg} -\alias{balanceMethodsList} +\alias{balanceMethodsList}% defunct \alias{sigToEnv} \alias{rematchDefinition} \alias{isRematched} \alias{unRematchDefinition} +\alias{asMethodDefinition} \alias{addNextMethod,MethodDefinition-method} \alias{addNextMethod,MethodWithNext-method} \alias{addNextMethod} @@ -55,6 +44,10 @@ Utility functions to support the definition and use of formal methods. Most of these functions will not normally be called directly by the user. + + Partly, they work with S4 classes which are also normally not for the + user, see their help page \code{\linkS4class{optionalMethods}}. + } \usage{ getGeneric(f, mustFind=FALSE, where, package) @@ -107,7 +100,7 @@ addNextMethod(method, f, mlist, optional, envir) insertClassMethods(methods, Class, value, fieldNames, returnAll) -balanceMethodsList(mlist, args, check = TRUE) # <- deprecated since R 3.2.0 +balanceMethodsList(mlist, args, check = TRUE) # <- defunct since R 4.5.0 substituteFunctionArgs(def, newArgs, args = formalArgs(def), silent = FALSE, functionName = "a function") @@ -236,8 +229,8 @@ substituteFunctionArgs(def, newArgs, args = formalArgs(def), } \item{\code{balanceMethodsList}:}{ - Used to be called from \code{setMethod()} and is \emph{deprecated} - since \R version 3.2.0. + Used to be called from \code{setMethod()} and is \emph{defunct} since + \R version 4.5.0 (\sQuote{deprecated} \R 3.2.0). %% Called from \code{\link{setMethod}} to ensure that all nodes in %% the list have the same depth (i.e., the same number of levels of %% arguments). Balance is needed to ensure that all necessary diff --git a/src/library/methods/man/genericFunction-class.Rd b/src/library/methods/man/genericFunction-class.Rd index 147fc22ef79..f8164b560a7 100644 --- a/src/library/methods/man/genericFunction-class.Rd +++ b/src/library/methods/man/genericFunction-class.Rd @@ -60,8 +60,8 @@ } \section{Extends}{ Class \code{"function"}, from data part.\cr - Class \code{"OptionalMethods"}, by class \code{"function"}.\cr - Class \code{"PossibleMethod"}, by class \code{"function"}. + Classes \code{"optionalMethod"}, \code{"PossibleMethod"}, and + \code{"OptionalFunction"} by class \code{"function"}. } \section{Methods}{ Generic function objects are used in the creation and dispatch of diff --git a/src/library/methods/man/loadMethod.Rd b/src/library/methods/man/loadMethod.Rd new file mode 100644 index 00000000000..b59434052bd --- /dev/null +++ b/src/library/methods/man/loadMethod.Rd @@ -0,0 +1,46 @@ +% File src/library/methods/man/MethodsList.Rd +% Part of the R package, https://www.R-project.org +% Copyright 1995-2024 R Core Team +% Distributed under GPL 2 or later + +\name{loadMethod} +\title{Load an S4 Method} +% +\alias{loadMethod} +\alias{loadMethod-methods} +\alias{loadMethod,ANY-method} +\alias{loadMethod,MethodDefinition-method} +\alias{loadMethod,MethodWithNext-method} +\description{ + Internal generic function with methods; only for internal use of methods initialization. +} +\usage{ +loadMethod(method, fname, envir) +} +\details{ + Called, if necessary, just before a call to \code{method} is + dispatched in the frame \code{envir}. The function exists so that + methods can be defined for special classes of objects. Usually + the point is to assign or modify information in the frame + environment to be used evaluation. For example, the standard + class \code{MethodDefinition} has a method that stores the target + and defined signatures in the environment. Class + \code{MethodWithNext} has a method taking account of the + mechanism for storing the method to be used in a call to + \code{\link{callNextMethod}}. + + Any methods defined for \code{loadMethod} must return the function + definition to be used for this call; typically, this is just the + \code{method} argument. +} +\references{ + Chambers, John M. (2008) + \emph{Software for Data Analysis: Programming with R} + Springer. (For the R version.) + + Chambers, John M. (1998) + \emph{Programming with Data} + Springer (For the original S4 version.) +} +\keyword{internal} + diff --git a/src/library/methods/man/methods-defunct.Rd b/src/library/methods/man/methods-defunct.Rd index d1d2fafe552..25ea350be93 100644 --- a/src/library/methods/man/methods-defunct.Rd +++ b/src/library/methods/man/methods-defunct.Rd @@ -1,9 +1,10 @@ % File src/library/methods/man/methods-defunct.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2012 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{methods-defunct} +\title{Defunct Functions in Package \pkg{methods}} \alias{methods-defunct} \alias{getAllMethods} \alias{mlistMetaName} @@ -21,7 +22,33 @@ \alias{trySilent} \alias{traceOn} \alias{traceOff} -\title{Defunct Functions in Package \pkg{methods}} +%--------------- former \code{MethodsList} Objects ------------------------------ +% \code{MethodsList-class}: ~~~~~~~~~~~ +\alias{MethodsList-class} +\alias{body<-,MethodDefinition-method} +%----- +\alias{listFromMlist}% only used in listFromMlist() +\alias{linearizeMlist}% only used in showMlist() +% finalDefaultMethod() [somewhat important]: +\alias{finalDefaultMethod} +%% were deprecated since R 3.2.0: +\alias{MethodsList} +\alias{makeMethodsList} +\alias{SignatureMethod} +\alias{insertMethod} +\alias{inheritedSubMethodLists} +\alias{showMlist} +\alias{print.MethodsList} +\alias{emptyMethodsList} +\alias{insertMethodInEmptyList} +\alias{mergeMethods} +\alias{MethodsListSelect} +% already removed: +% \alias{linearizeMlist} +% \alias{listFromMlist} +% \alias{showMlist} + +%--------------------------- former {MethodsList} Objects ----------------------- \description{ Defunct functions in package \pkg{methods}. } diff --git a/tests/reg-S4.Rout.save b/tests/reg-S4.Rout.save index 40a2a4b775b..15dd3c218e3 100644 --- a/tests/reg-S4.Rout.save +++ b/tests/reg-S4.Rout.save @@ -1,6 +1,6 @@ -R Under development (unstable) (2023-08-15 r84951) -- "Unsuffered Consequences" -Copyright (C) 2023 The R Foundation for Statistical Computing +R Under development (unstable) (2024-04-19 r86451) -- "Unsuffered Consequences" +Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -47,7 +47,7 @@ Extends: Class "genericFunction", directly Class "function", by class "genericFunction", distance 2 Class "OptionalFunction", by class "function", distance 3 -Class "PossibleMethod", by class "function", distance 3 +Class "PossibleMethod", by class "genericFunction", distance 3 Class "optionalMethod", by class "genericFunction", distance 4 Known Subclasses: "standardGenericWithTrace" From 7c9930c00980aac8be243a6f8604be0eb7335d0e Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 3 May 2024 11:33:24 +0000 Subject: [PATCH 024/546] Comment. git-svn-id: https://svn.r-project.org/R/trunk@86514 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/modules/internet/Rhttpd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/modules/internet/Rhttpd.c b/src/modules/internet/Rhttpd.c index 9ee71f4c222..0c83201fca7 100644 --- a/src/modules/internet/Rhttpd.c +++ b/src/modules/internet/Rhttpd.c @@ -20,6 +20,18 @@ /* This is a small HTTP server that serves requests by evaluating * the httpd() function and passing the result to the browser. */ +/* Note that the server runs partially on the main R thread (it has to, + because it uses R), and it also sends the response mostly from the + main thread. It is thus not possible to use the server from the R thread + itself, e.g. via download.file(), because of a deadlock between the + server and the client, when the data isn't sent in a single chunk. + On Unix, the deadlock could also happen when the client is sending a + request to the server (and the request isn't sent in a single chunk). + + This cannot happen with the intended use of this server, when it is used + to serve help pages to an external client (a web browser). +*/ + /* Example: httpd <- function(path,query=NULL,...) { cat("Request for:", path,"\n"); print(query); From 072155ebd4ba471f5ce8929591ce2d502fa675f4 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 3 May 2024 20:21:41 +0000 Subject: [PATCH 025/546] Standardize wording to 'Part of the API.' git-svn-id: https://svn.r-project.org/R/trunk@86515 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/R_ext/Arith.h | 2 +- src/include/R_ext/BLAS.h | 2 -- src/include/R_ext/Boolean.h | 2 +- src/include/R_ext/Complex.h | 2 +- src/include/R_ext/Constants.h | 2 +- src/include/R_ext/Error.h | 2 +- src/include/R_ext/Memory.h | 2 +- src/include/R_ext/Print.h | 2 +- src/include/R_ext/Random.h | 2 +- src/include/R_ext/Utils.h | 2 +- 10 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/include/R_ext/Arith.h b/src/include/R_ext/Arith.h index 0a5a852be56..d1b9cec6bf7 100644 --- a/src/include/R_ext/Arith.h +++ b/src/include/R_ext/Arith.h @@ -22,7 +22,7 @@ * https://www.R-project.org/Licenses/ */ -/* Included by R.h: API */ +/* Included by R.h: Part of the API. */ #ifndef R_ARITH_H_ #define R_ARITH_H_ diff --git a/src/include/R_ext/BLAS.h b/src/include/R_ext/BLAS.h index e7f125fb04e..2c6f636fba4 100644 --- a/src/include/R_ext/BLAS.h +++ b/src/include/R_ext/BLAS.h @@ -30,8 +30,6 @@ $(BLAS_LIBS) $(FLIBS) */ -/* Part of the API */ - #ifndef R_BLAS_H #define R_BLAS_H diff --git a/src/include/R_ext/Boolean.h b/src/include/R_ext/Boolean.h index 56bce4e4a0b..9d643aa3b02 100644 --- a/src/include/R_ext/Boolean.h +++ b/src/include/R_ext/Boolean.h @@ -21,7 +21,7 @@ * https://www.R-project.org/Licenses/ */ -/* Included by R.h: API */ +/* Included by R.h: Part of the API. */ #ifndef R_EXT_BOOLEAN_H_ #define R_EXT_BOOLEAN_H_ diff --git a/src/include/R_ext/Complex.h b/src/include/R_ext/Complex.h index b18115f5f4d..6d27ac70072 100644 --- a/src/include/R_ext/Complex.h +++ b/src/include/R_ext/Complex.h @@ -21,7 +21,7 @@ * https://www.R-project.org/Licenses/ */ -/* Included by R.h: API */ +/* Included by R.h: Part of the API. */ #ifndef R_COMPLEX_H #define R_COMPLEX_H diff --git a/src/include/R_ext/Constants.h b/src/include/R_ext/Constants.h index d7b326b88fd..ad7c1247776 100644 --- a/src/include/R_ext/Constants.h +++ b/src/include/R_ext/Constants.h @@ -22,7 +22,7 @@ * https://www.R-project.org/Licenses/ */ -/* Included by R.h: API */ +/* Included by R.h: Part of the API. */ #ifndef R_EXT_CONSTANTS_H_ #define R_EXT_CONSTANTS_H_ diff --git a/src/include/R_ext/Error.h b/src/include/R_ext/Error.h index 91a535337e4..5bccb3d7103 100644 --- a/src/include/R_ext/Error.h +++ b/src/include/R_ext/Error.h @@ -21,7 +21,7 @@ * https://www.R-project.org/Licenses/ */ -/* Included by R.h: API */ +/* Included by R.h: Part of the API. */ #ifndef R_ERROR_H_ #define R_ERROR_H_ diff --git a/src/include/R_ext/Memory.h b/src/include/R_ext/Memory.h index a63d9be971b..05fde59ee5c 100644 --- a/src/include/R_ext/Memory.h +++ b/src/include/R_ext/Memory.h @@ -24,7 +24,7 @@ * Memory Allocation (garbage collected) --- INCLUDING S compatibility --- */ -/* Included by R.h: API */ +/* Included by R.h: Part of the API. */ #ifndef R_EXT_MEMORY_H_ #define R_EXT_MEMORY_H_ diff --git a/src/include/R_ext/Print.h b/src/include/R_ext/Print.h index ff6a3d95b39..1888b6faa87 100644 --- a/src/include/R_ext/Print.h +++ b/src/include/R_ext/Print.h @@ -21,7 +21,7 @@ * https://www.R-project.org/Licenses/ */ -/* Included by R.h: API */ +/* Included by R.h: Part of the API. */ #ifndef R_EXT_PRINT_H_ #define R_EXT_PRINT_H_ diff --git a/src/include/R_ext/Random.h b/src/include/R_ext/Random.h index 7dc13f9b9ee..64d5c0f9121 100644 --- a/src/include/R_ext/Random.h +++ b/src/include/R_ext/Random.h @@ -21,7 +21,7 @@ * https://www.R-project.org/Licenses/ */ -/* Included by R.h: API */ +/* Included by R.h: Part of the API. */ #ifndef R_RANDOM_H #define R_RANDOM_H diff --git a/src/include/R_ext/Utils.h b/src/include/R_ext/Utils.h index 95afb645d4a..69d40adce7a 100644 --- a/src/include/R_ext/Utils.h +++ b/src/include/R_ext/Utils.h @@ -120,7 +120,7 @@ int F77_SUB(interv)(double *xt, int *n, double *x, Rboolean *rightmost_closed, Rboolean *all_inside, int *ilo, int *mflag); #endif -/* not API, mo longer in R +/* not API, no longer in R void find_interv_vec(double *xt, int *n, double *x, int *nx, int *rightmost_closed, int *all_inside, int *indx); */ From 932c3b93581b5ae1372047cc9f89b0224a416089 Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 3 May 2024 20:39:15 +0000 Subject: [PATCH 026/546] finish 86513 {defunctifying & removing "MethodsList"-class related} git-svn-id: https://svn.r-project.org/R/trunk@86516 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/methods/R/MethodsList.R | 173 ------------------------ src/library/methods/R/RMethodUtils.R | 23 ---- src/library/methods/R/methods-defunct.R | 40 ++++++ src/library/methods/man/RMethodUtils.Rd | 5 +- 4 files changed, 42 insertions(+), 199 deletions(-) diff --git a/src/library/methods/R/MethodsList.R b/src/library/methods/R/MethodsList.R index fb02e3def8e..d9ade83a8f7 100644 --- a/src/library/methods/R/MethodsList.R +++ b/src/library/methods/R/MethodsList.R @@ -183,179 +183,6 @@ insertMethod <- } -MethodsListSelect <- - ## select the element of a MethodsList object corresponding to the - ## actual arguments (as defined in the suppled environment), - ## and return the object, extended to include that method if necessary. - ## - ## Works recursively. At each level finds an argument name from the current `mlist' - ## object, and evaluates this argument (if it is not missing), then uses the - ## class of the result to select an element of `mlist'. If such an element - ## exists and is another `MethodsList' object, `MethodsListSelect' calls itself recursively - ## to resolve using further arguments. Matching includes using a default selection or - ## a method specifically linked to class `"missing"'. Once a function is found, it - ## is returned as the value. If matching fails, NULL is returned. - function(f, env, - mlist = NULL, - fEnv = if(is(fdef, "genericFunction")) environment(fdef) else baseenv(), - finalDefault = finalDefaultMethod(mlist), - evalArgs = TRUE, - useInherited = TRUE, ## supplied when evalArgs is FALSE - fdef = getGeneric(f, where = env), # MUST BE SAFE FROM RECUSIVE METHOD SELECTION - resetAllowed = TRUE # FALSE when called from selectMethod, .findNextMethod - ) -{ - .MlistDefunct("MethodsListSelect()") - if(!resetAllowed) # ensure we restore the real methods for this function - resetMlist <- .getMethodsForDispatch(fdef) - ## look for call from C dispatch code during another call to MethodsListSelect - if(is.null(f)) {} # Recall, not from C - else { - fMethods <- .getMethodsForDispatch(fdef) - if(is.null(mlist) || (evalArgs && is.function(fMethods))) - mlist <- fMethods - } - resetNeeded <- .setIfBase(f, fdef, mlist) # quickly protect against recursion -- see Methods.R - if(resetNeeded) { - on.exit(.setMethodsForDispatch(f, fdef, mlist)) - } - if(!is(mlist, "MethodsList")) { - if(is.function(mlist)) # call to f, inside MethodsListSelect - {on.exit(); return(mlist)} - if(is.null(f)) # recursive recall of MethodsListSelect - stop("invalid method sublist") - else if(!is.null(mlist)) # NULL => 1st call to genericFunction - stop(gettextf("%f is not a valid generic function: methods list was an object of class %s", - sQuote(f), dQuote(class(mlist))), - domain = NA) - } - if(!is.logical(useInherited)) - stop(gettextf("%s must be TRUE, FALSE, or a named logical vector of those values; got an object of class %s", - sQuote("useInherited"), - dQuote(class(useInherited))), - domain = NA) - if(identical(mlist, .getMethodsForDispatch(fdef))) { - resetNeeded <- TRUE - ## On the initial call: - ## turn off any further method dispatch on this function, to avoid recursive - ## loops if f is a function used in MethodsListSelect. - ## TODO: Using namespaces in the methods package would eliminate the need for this - .setMethodsForDispatch(f, fdef, finalDefault) - if(is(mlist, "MethodsList")) { - on.exit(.setMethodsForDispatch(f, fdef, mlist)) - } - } - argName <- slot(mlist, "argument") - arg <- NULL ## => don't use instance-specific inheritance - if(evalArgs) { - ## check for missing argument. NB: S sense, not that of R base missing() - if(missingArg(argName, env, TRUE)) - thisClass <- "missing" - else { - arg <- eval(as.name(argName), env) ## DO use instance-specific inheritance - if(missing(arg)) ## S3 weird R code? Bail out! - return(finalDefault) - thisClass <- .class1(arg) - } - } - else - thisClass <- get(as.character(argName), envir = env, inherits = FALSE) - if(isTRUE(useInherited) || isFALSE(useInherited)) - thisInherit <- nextUseInherited <- useInherited - else { - which <- match(as.character(argName), names(useInherited)) - if(is.na(which)) { - nextUseInherited <- useInherited - thisInherit <- TRUE - } - else { - thisInherit <- useInherited[[which]] - nextUseInherited <- useInherited[-which] - } - } - fromClass <- thisClass ## will mark the class actually providing the method - allMethods <- mlist@allMethods - which <- match(thisClass, names(allMethods)) - inherited <- is.na(which) - selection <- if(inherited) NULL else allMethods[[which]] - if(!inherited) { - if(is.function(selection)) { - if(is.null(f)) { - ## An inherited method at the next level up. - ## only the inherited method should be added - mlist <- .trimMlist(mlist, fromClass) - } - value <- mlist ## no change - } - else { - ## recursive call with NULL function name, to allow search to fail & - ## to suppress any reset actions. - method <- Recall(NULL, env, selection, finalDefault = finalDefault, - evalArgs = evalArgs, useInherited = nextUseInherited, fdef = fdef, - ) - if(is(method, "EmptyMethodsList")) - value <- method - else { - mlist@allMethods[[which]] <- method - value <- mlist - } - } - } - if(inherited || is(value, "EmptyMethodsList")) { - ## direct selection failed at this level or below - method <- NULL - if(thisInherit) { - allSelections <- inheritedSubMethodLists(arg, fromClass, mlist, env) - allClasses <- names(allSelections) - for(i in seq_along(allSelections)) { - selection <- allSelections[[i]] - fromClass <- allClasses[[i]] - if(is.function(selection)) - method <- selection - else if(is(selection, "MethodsList")) { - ## go on to try matching further arguments - method <- Recall(NULL, env, selection, finalDefault = finalDefault, - evalArgs = evalArgs, - useInherited = nextUseInherited, fdef = fdef) - if(is(method, "EmptyMethodsList")) - selection <- method ## recursive selection failed - } - if(!is(selection, "EmptyMethodsList")) - break - } - } - if((is.null(selection) || is(selection, "EmptyMethodsList")) - && !is.null(f) && !is.null(finalDefault)) { - ## only use the final default method after exhausting all - ## other possibilities, at all levels. - method <- finalDefault - fromClass <- "ANY" - } - if(is.null(method) || is(method, "EmptyMethodsList")) - value <- emptyMethodsList(mlist, thisClass) ## nothing found - else { - method <- MethodAddCoerce(method, argName, thisClass, fromClass) - value <- .insertCachedMethods(mlist, as.character(argName), thisClass, fromClass, - method) - } - } - if(!is.null(f)) { - ## top level - if(is(value, "EmptyMethodsList")) ## selection failed - value <- NULL - if(resetNeeded) { - on.exit() # cancel the restore of the original mlist - if(resetAllowed) { - if(is.null(value)) resetMlist <- mlist else resetMlist <- value - } - .setMethodsForDispatch(f, fdef, resetMlist) - if(dispatchIsInternal(fdef)) - setPrimitiveMethods(f, finalDefault, "set", fdef, resetMlist) - } - - } - value -} emptyMethodsList <- function(mlist, thisClass = "ANY", sublist = list()) { .MlistDefunct("emptyMethodsList()") diff --git a/src/library/methods/R/RMethodUtils.R b/src/library/methods/R/RMethodUtils.R index 495c6d48bda..2de23f04794 100644 --- a/src/library/methods/R/RMethodUtils.R +++ b/src/library/methods/R/RMethodUtils.R @@ -254,29 +254,6 @@ defaultDumpName <- } -mergeMethods <- - ## merge the methods in the second MethodsList object into the first, - ## and return the merged result. - function(m1, m2, genericLabel = character()) -{ - .MlistDefunct("mergeMethods()") - if(length(genericLabel) && is(m2, "MethodsList")) - m2 <- .GenericInPrimitiveMethods(m2, genericLabel) - if(is.null(m1) || is(m1, "EmptyMethodsList")) - return(m2) - tmp <- listFromMlist(m2) - sigs <- tmp[[1]] - methods <- tmp[[2]] - for(i in seq_along(sigs)) { - sigi <- sigs[[i]] - if(.noMlists() && !identical(unique(sigi), "ANY")) - next - args <- names(sigi) - m1 <- insertMethod(m1, as.character(sigi), args, methods[[i]], FALSE) - } - m1 -} - doPrimitiveMethod <- ## do a primitive call to builtin function 'name' the definition and call ## provided, and carried out in the environment 'ev'. diff --git a/src/library/methods/R/methods-defunct.R b/src/library/methods/R/methods-defunct.R index 174cadeef68..f1462e2213e 100644 --- a/src/library/methods/R/methods-defunct.R +++ b/src/library/methods/R/methods-defunct.R @@ -35,6 +35,46 @@ ## +## +## Defunct in 4.5.0 +MethodsListSelect <- + ## select the element of a MethodsList object corresponding to the + ## actual arguments (as defined in the suppled environment), + ## and return the object, extended to include that method if necessary. + ## + ## Works recursively. At each level finds an argument name from the current `mlist' + ## object, and evaluates this argument (if it is not missing), then uses the + ## class of the result to select an element of `mlist'. If such an element + ## exists and is another `MethodsList' object, `MethodsListSelect' calls itself recursively + ## to resolve using further arguments. Matching includes using a default selection or + ## a method specifically linked to class `"missing"'. Once a function is found, it + ## is returned as the value. If matching fails, NULL is returned. + function(f, env, + mlist = NULL, + fEnv = if(is(fdef, "genericFunction")) environment(fdef) else baseenv(), + finalDefault = finalDefaultMethod(mlist), + evalArgs = TRUE, + useInherited = TRUE, ## supplied when evalArgs is FALSE + fdef = getGeneric(f, where = env), # MUST BE SAFE FROM RECUSIVE METHOD SELECTION + resetAllowed = TRUE # FALSE when called from selectMethod, .findNextMethod + ) +{ + .MlistDefunct("MethodsListSelect()") +} +## + + +## +## Defunct in 4.5.0 +mergeMethods <- + ## merge the methods in the second MethodsList object into the first, + ## and return the merged result. + function(m1, m2, genericLabel = character()) +{ + .MlistDefunct("mergeMethods()") +} +## + ## ## Defunct in 4.5.0 ## Removed in 4.5.0 diff --git a/src/library/methods/man/RMethodUtils.Rd b/src/library/methods/man/RMethodUtils.Rd index de2d244a916..0c3a8197a5a 100644 --- a/src/library/methods/man/RMethodUtils.Rd +++ b/src/library/methods/man/RMethodUtils.Rd @@ -46,8 +46,7 @@ by the user. Partly, they work with S4 classes which are also normally not for the - user, see their help page \code{\linkS4class{optionalMethods}}. - + user, see their help page \code{\linkS4class{optionalMethod}}. } \usage{ getGeneric(f, mustFind=FALSE, where, package) @@ -103,7 +102,7 @@ insertClassMethods(methods, Class, value, fieldNames, returnAll) balanceMethodsList(mlist, args, check = TRUE) # <- defunct since R 4.5.0 substituteFunctionArgs(def, newArgs, args = formalArgs(def), - silent = FALSE, functionName = "a function") + silent = FALSE, functionName = "a function") .valueClassTest(object, classes, fname) } From cc7f6c14fa84b2a49aeab3e004cd891d19558ef9 Mon Sep 17 00:00:00 2001 From: smeyer Date: Fri, 3 May 2024 21:25:54 +0000 Subject: [PATCH 027/546] spelling git-svn-id: https://svn.r-project.org/R/trunk@86517 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/find.package.Rd | 2 +- src/library/base/man/ns-load.Rd | 2 +- src/library/base/man/options.Rd | 4 ++-- src/library/base/man/zapsmall.Rd | 2 +- src/library/methods/man/new.Rd | 2 +- src/library/parallel/man/splitIndices.Rd | 2 +- src/library/parallel/man/unix/mclapply.Rd | 2 +- src/library/stats/man/heatmap.Rd | 2 +- src/library/stats/man/order.dendrogram.Rd | 2 +- src/library/tools/man/bibstyle.Rd | 2 +- src/library/tools/man/psnice.Rd | 2 +- src/library/utils/man/removeSource.Rd | 2 +- tests/Examples/tools-Ex.Rout.save | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/library/base/man/find.package.Rd b/src/library/base/man/find.package.Rd index f67596af423..885231c8a31 100644 --- a/src/library/base/man/find.package.Rd +++ b/src/library/base/man/find.package.Rd @@ -82,4 +82,4 @@ findPkgAll <- function(pkg) findPkgAll("MASS") findPkgAll("knitr") } -\keyword{files} +\keyword{file} diff --git a/src/library/base/man/ns-load.Rd b/src/library/base/man/ns-load.Rd index b3eb5790ee8..40e5bc7e550 100644 --- a/src/library/base/man/ns-load.Rd +++ b/src/library/base/man/ns-load.Rd @@ -137,7 +137,7 @@ isNamespaceLoaded(name) statL <- isNamespaceLoaded("stats")% checks work also when it is *not* loaded stopifnot( identical(statL, "stats" \%in\% lns) ) - ## The string "foo" and the symbol 'foo' can be used interchangably here: + ## The string "foo" and the symbol 'foo' can be used interchangeably here: stopifnot( identical(isNamespaceLoaded( "foo" ), FALSE), identical(isNamespaceLoaded(quote(foo)), FALSE), identical(isNamespaceLoaded(quote(stats)), statL)) diff --git a/src/library/base/man/options.Rd b/src/library/base/man/options.Rd index 998290892dc..ec7b657a270 100644 --- a/src/library/base/man/options.Rd +++ b/src/library/base/man/options.Rd @@ -879,8 +879,8 @@ options(error = quote({dump.frames(to.file = TRUE); q()})) } # Compare the two ways to get an option and use it - # acconting for the possibility it might not be set. -if(as.logical(getOption("performCleanp", TRUE))) + # accounting for the possibility it might not be set. +if(as.logical(getOption("performCleanup", TRUE))) cat("do cleanup\n") \dontrun{ diff --git a/src/library/base/man/zapsmall.Rd b/src/library/base/man/zapsmall.Rd index 3c6ef7f96eb..fe99aa951e5 100644 --- a/src/library/base/man/zapsmall.Rd +++ b/src/library/base/man/zapsmall.Rd @@ -38,7 +38,7 @@ zapsmall(x, digits = getOption("digits"), \examples{ x2 <- pi * 100^(-2:2)/10 print( x2, digits = 4) -zapsmall( x2) # automatical digits +zapsmall( x2) # automatic digits zapsmall( x2, digits = 4) zapsmall(c(x2, Inf)) # round()s to integer .. zapsmall(c(x2, Inf), min.d=-Inf) # everything is small wrt Inf diff --git a/src/library/methods/man/new.Rd b/src/library/methods/man/new.Rd index 939a462bb62..bd2ea9c0a17 100644 --- a/src/library/methods/man/new.Rd +++ b/src/library/methods/man/new.Rd @@ -39,7 +39,7 @@ named classes.} \section{Initialize Methods}{ The generic function \code{initialize} is not called directly. A call to \code{new} begins by copying the prototype object from - the class definition, and then calls \code{intialize()} with this + the class definition, and then calls \code{initialize()} with this object as the first argument, followed by the \dots{} arguments. The interpretation of the \code{\dots} arguments in a call to a diff --git a/src/library/parallel/man/splitIndices.Rd b/src/library/parallel/man/splitIndices.Rd index 97159667b4b..616b99bae4b 100644 --- a/src/library/parallel/man/splitIndices.Rd +++ b/src/library/parallel/man/splitIndices.Rd @@ -26,4 +26,4 @@ splitIndices(nx, ncl) \examples{ splitIndices(20, 3) } -\keyword{ utility } +\keyword{ utilities } diff --git a/src/library/parallel/man/unix/mclapply.Rd b/src/library/parallel/man/unix/mclapply.Rd index 92ace56f661..b5328130285 100644 --- a/src/library/parallel/man/unix/mclapply.Rd +++ b/src/library/parallel/man/unix/mclapply.Rd @@ -206,7 +206,7 @@ B <- runif(2500000,0,100) C <- runif(5000000,0,100) first <- function(i) head(sort(i), n = 1) -# Restict all elements of X to run on CPU 1 and 2 +# Restrict all elements of X to run on CPU 1 and 2 affL <- list(c(1,2), c(1,2), c(1,2)) mclapply(list(A, A, A), first, mc.preschedule = FALSE, affinity.list = affL) diff --git a/src/library/stats/man/heatmap.Rd b/src/library/stats/man/heatmap.Rd index c953c6e59f3..998ee863d97 100644 --- a/src/library/stats/man/heatmap.Rd +++ b/src/library/stats/man/heatmap.Rd @@ -110,7 +110,7 @@ heatmap(x, Rowv = NULL, Colv = if(symm)"Rowv" else NULL, \code{heatmap()} uses \code{\link{layout}} and draws the \code{\link{image}} in the lower right corner of a 2x2 layout. - Consequentially, it can \bold{not} be used in a multi column/row + Consequently, it can \bold{not} be used in a multi column/row layout, i.e., when \code{\link{par}(mfrow = *)} or \code{(mfcol = *)} has been called. } diff --git a/src/library/stats/man/order.dendrogram.Rd b/src/library/stats/man/order.dendrogram.Rd index 9a236ab9b4b..ceca2f25236 100644 --- a/src/library/stats/man/order.dendrogram.Rd +++ b/src/library/stats/man/order.dendrogram.Rd @@ -9,7 +9,7 @@ \alias{labels.dendrogram} \title{Ordering or Labels of the Leaves in a Dendrogram} \description{ - Theses functions return the order (index) or the \code{"label"} + These functions return the order (index) or the \code{"label"} attribute for the leaves in a dendrogram. These indices can then be used to access the appropriate components of any additional data. diff --git a/src/library/tools/man/bibstyle.Rd b/src/library/tools/man/bibstyle.Rd index d5fd1876f8f..7fc94088940 100644 --- a/src/library/tools/man/bibstyle.Rd +++ b/src/library/tools/man/bibstyle.Rd @@ -122,5 +122,5 @@ bibstyle("unsorted", sortKeys = function(refs) seq_along(refs), .init = TRUE) print(refs, .bibstyle = "unsorted") } -\keyword{ utilties } +\keyword{ utilities } \keyword{ documentation } diff --git a/src/library/tools/man/psnice.Rd b/src/library/tools/man/psnice.Rd index 0c678955a05..b6e93cc21a4 100644 --- a/src/library/tools/man/psnice.Rd +++ b/src/library/tools/man/psnice.Rd @@ -54,4 +54,4 @@ psnice(pid = Sys.getpid(), value = NA_integer_) \code{\link{pskill}}. } -\keyword{ utility } +\keyword{ utilities } diff --git a/src/library/utils/man/removeSource.Rd b/src/library/utils/man/removeSource.Rd index 1f7051dc090..4205fbdb34f 100644 --- a/src/library/utils/man/removeSource.Rd +++ b/src/library/utils/man/removeSource.Rd @@ -59,4 +59,4 @@ stopifnot(length(attributes(E )) > 0, is.null(attributes(E.))) options(op) # reset to previous state } -\keyword{utility} +\keyword{utilities} diff --git a/tests/Examples/tools-Ex.Rout.save b/tests/Examples/tools-Ex.Rout.save index fb746590039..ae441b81be5 100644 --- a/tests/Examples/tools-Ex.Rout.save +++ b/tests/Examples/tools-Ex.Rout.save @@ -185,7 +185,7 @@ Error in assertWarning(ff()) : > ### Name: bibstyle > ### Title: Select or Define a Bibliography Style > ### Aliases: bibstyle getBibstyle -> ### Keywords: utilties documentation +> ### Keywords: utilities documentation > > ### ** Examples > From c9fe937348401c7ba9b1fb359a98a44b16ceb93e Mon Sep 17 00:00:00 2001 From: smeyer Date: Fri, 3 May 2024 21:44:54 +0000 Subject: [PATCH 028/546] update for new Repository field in BioC packages git-svn-id: https://svn.r-project.org/R/trunk@86518 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 0ebfd74b5a5..c879ab27435 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -1,7 +1,7 @@ # File src/library/utils/R/citation.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2023 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -1401,8 +1401,8 @@ function(package = "base", lib.loc = NULL, auto = NULL) z$note <- paste(z$note, rfr, sep = "/r") } - if((is.null(meta$Repository) || - identical(meta$Repository, "Bioconductor")) && + if((is.null(meta$Repository) || # older BioC releases + startsWith(meta$Repository, "Bioconductor")) && # "Bioconductor 3.19" !is.null(meta$git_url) && startsWith(meta$git_url, "https://git.bioconductor.org/packages")) { From 602bd170700c788fb8f95e9fb4d5388a71c8d890 Mon Sep 17 00:00:00 2001 From: ripley Date: Sat, 4 May 2024 07:46:21 +0000 Subject: [PATCH 029/546] update comments git-svn-id: https://svn.r-project.org/R/trunk@86520 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Rinternals.h | 1 + src/main/util.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index e91c1bd4e75..05cea62a5d8 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -488,6 +488,7 @@ SEXP Rf_allocMatrix(SEXPTYPE, int, int); SEXP Rf_allocList(int); SEXP Rf_allocS4Object(void); SEXP Rf_allocSExp(SEXPTYPE); +// next is not documented but generated by inlined calls to Rf_allocVector SEXP Rf_allocVector3(SEXPTYPE, R_xlen_t, R_allocator_t*); R_xlen_t Rf_any_duplicated(SEXP x, Rboolean from_last); R_xlen_t Rf_any_duplicated3(SEXP x, SEXP incomp, Rboolean from_last); diff --git a/src/main/util.c b/src/main/util.c index 9eee1cb9cb8..74243078a75 100644 --- a/src/main/util.c +++ b/src/main/util.c @@ -2081,7 +2081,7 @@ int attribute_hidden Rf_AdobeSymbol2ucs2(int n) Also allows complete control of which non-numeric strings are accepted; e.g. glibc allows NANxxxx, macOS NAN(s), this accepts "NA". - Exported and in Utils.h (but not in R-exts). + Exported and in Utils.h (but only in R-exts as of 4.4.1). Variants: R_strtod4 is used by scan(), allows the decimal point (byte) to be From b5582bb6dc31e988de5c33ebb28932901c2206ae Mon Sep 17 00:00:00 2001 From: ripley Date: Sat, 4 May 2024 07:48:58 +0000 Subject: [PATCH 030/546] update comments git-svn-id: https://svn.r-project.org/R/trunk@86521 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/R_ext/RS.h | 17 ++++++++++------- src/include/R_ext/Rallocators.h | 3 ++- src/include/R_ext/Rdynload.h | 9 ++++++++- src/include/R_ext/Utils.h | 9 +++++---- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/include/R_ext/RS.h b/src/include/R_ext/RS.h index 8ab58dfdbb2..d6c4717ca20 100644 --- a/src/include/R_ext/RS.h +++ b/src/include/R_ext/RS.h @@ -21,7 +21,7 @@ * https://www.R-project.org/Licenses/ */ -/* Included by R.h: mainly API */ +/* Included by R.h: nowadays almost all API */ #ifndef R_RS_H #define R_RS_H @@ -44,29 +44,32 @@ extern "C" { /* S Like Memory Management */ +/* not of themselves API */ extern void *R_chk_calloc(R_SIZE_T, R_SIZE_T); extern void *R_chk_realloc(void *, R_SIZE_T); extern void R_chk_free(void *); #ifndef STRICT_R_HEADERS -/* S-PLUS 3.x but not 5.x NULLed the pointer in Free */ +/* S-PLUS 3.x but not 5.x NULLed the pointer in Free. + Not API. +*/ #define Calloc(n, t) (t *) R_chk_calloc( (R_SIZE_T) (n), sizeof(t) ) #define Realloc(p,n,t) (t *) R_chk_realloc( (void *)(p), (R_SIZE_T)((n) * sizeof(t)) ) #define Free(p) (R_chk_free( (void *)(p) ), (p) = NULL) #endif - + +/* API */ #define R_Calloc(n, t) (t *) R_chk_calloc( (R_SIZE_T) (n), sizeof(t) ) #define R_Realloc(p,n,t) (t *) R_chk_realloc( (void *)(p), (R_SIZE_T)((n) * sizeof(t)) ) #define R_Free(p) (R_chk_free( (void *)(p) ), (p) = NULL) -/* undocumented until 4.1.2: widely used. */ +/* Nowadays API: undocumented until 4.1.2: widely used. */ #define Memcpy(p,q,n) memcpy( p, q, (R_SIZE_T)(n) * sizeof(*p) ) -/* added for 3.0.0 but undocumented until 4.1.2. - Used by a couple of packages. */ +/* Nowadays API: added for 3.0.0 but undocumented until 4.1.2. */ #define Memzero(p,n) memset(p, 0, (R_SIZE_T)(n) * sizeof(*p)) -/* Added in R 2.6.0 */ +/* API: Added in R 2.6.0 */ #define CallocCharBuf(n) (char *) R_chk_calloc(((R_SIZE_T)(n))+1, sizeof(char)) /* S Like Fortran Interface */ diff --git a/src/include/R_ext/Rallocators.h b/src/include/R_ext/Rallocators.h index 6878300d806..cdb89a50d52 100644 --- a/src/include/R_ext/Rallocators.h +++ b/src/include/R_ext/Rallocators.h @@ -24,7 +24,8 @@ * Definition of the R_allocator_t structure for custom allocators * to be used with allocVector3() * - * Not API + * allocVector3 is also not declared as API in + * Rinternals.h nor documented in R-ests. */ #ifndef R_EXT_RALLOCATORS_H_ diff --git a/src/include/R_ext/Rdynload.h b/src/include/R_ext/Rdynload.h index 056f8b5f217..a24f609c1ba 100644 --- a/src/include/R_ext/Rdynload.h +++ b/src/include/R_ext/Rdynload.h @@ -85,16 +85,21 @@ int R_registerRoutines(DllInfo *info, const R_CMethodDef * const croutines, Rboolean R_useDynamicSymbols(DllInfo *info, Rboolean value); Rboolean R_forceSymbols(DllInfo *info, Rboolean value); +/* Not API */ DllInfo *R_getDllInfo(const char *name); /* To be used by applications embedding R to register their symbols - that are not related to any dynamic module */ + that are not related to any dynamic module/ + + Not API +*/ DllInfo *R_getEmbeddingDllInfo(void); typedef struct Rf_RegisteredNativeSymbol R_RegisteredNativeSymbol; typedef enum {R_ANY_SYM=0, R_C_SYM, R_CALL_SYM, R_FORTRAN_SYM, R_EXTERNAL_SYM} NativeSymbolType; +/* Not API */ DL_FUNC R_FindSymbol(char const *, char const *, R_RegisteredNativeSymbol *symbol); @@ -103,6 +108,8 @@ DL_FUNC R_FindSymbol(char const *, char const *, for use from C code in a package. The registration part probably ought to be integrated with the other registrations. The naming of these routines may be less than ideal. + + Declarations in the manual, so API */ void R_RegisterCCallable(const char *package, const char *name, DL_FUNC fptr); diff --git a/src/include/R_ext/Utils.h b/src/include/R_ext/Utils.h index 69d40adce7a..47a473cafcb 100644 --- a/src/include/R_ext/Utils.h +++ b/src/include/R_ext/Utils.h @@ -83,12 +83,11 @@ const char *R_ExpandFileName(const char *); // not API const char *R_ExpandFileNameUTF8(const char *); #endif -// this group is not API -/* - attribute_hidden and no longer used. +/* attribute_hidden and no longer used. void setIVector(int*, int, int); void setRVector(double*, int, double); */ +/* Not API */ Rboolean StringFalse(const char *); // used by iotools Rboolean StringTrue(const char *); // used by iotools Rboolean isBlankString(const char *); // used by iotools and openxlsx2 @@ -108,7 +107,9 @@ void R_CheckStack(void); void R_CheckStack2(R_SIZE_T); -/* ../../appl/interv.c: first also in Applic.h */ +/* ../../appl/interv.c: first also in Applic.h + Both are API +*/ int findInterval(double *xt, int n, double x, Rboolean rightmost_closed, Rboolean all_inside, int ilo, int *mflag); From 7b577aca3974cefcceedf9ed86afa2acdbdc2eea Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 6 May 2024 09:46:13 +0000 Subject: [PATCH 031/546] NEWS entry for 86509. git-svn-id: https://svn.r-project.org/R/trunk@86522 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 73f36860046..a1d760e06db 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -97,6 +97,9 @@ \item \code{qbinom()} and potentially \code{qpois()}, \code{qnbinom()}, no longer sometimes fail accurate inversion (of \code{pbinom()}, etc), thanks to Christopher Chang's report and patch in \PR{18711}. + + \item The internal help server on Windows can again serve requests + sent in quick succession, fixing a regression in \R 4.4.0. } } } From 2f6e042c8df0f8e87b3a08b1d0c4c9c160bc6ae3 Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 6 May 2024 13:16:30 +0000 Subject: [PATCH 032/546] give details for defunctified "MethodsList"-alikes, as requested (for pkg maintainers) git-svn-id: https://svn.r-project.org/R/trunk@86524 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index a1d760e06db..1b6c56501ab 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -32,9 +32,17 @@ \item \code{is.R()} is defunct. Environment variable \env{_R_DEPRECATED_IS_R_} no longer has any effect. - \item Several deprecated auxiliary functions and the - \code{MethodsList} class for S4 method handling are now defunct in - package \pkg{methods}, or have even been removed. + \item Deprecated (for more than 9 years!) functions + \code{linearizeMlist}, \code{listFromMlist}, and \code{showMlist} and + the \code{"MethodsList"} class for S4 method handling were removed + from package \pkg{methods}. + Deprecated functions \code{balanceMethodsList}, \code{emptyMethodsList}, + \code{inheritedSubMethodLists}, \code{insertMethod}, + \code{insertMethodInEmptyList}, \code{makeMethodsList}, + \code{mergeMethods}, \code{MethodsList}, \code{MethodsListSelect}, and + \code{SignatureMethod} were made defunct, as were the + \code{"MethodsList"} branches of functions \code{assignMethodsMetaData}, + \code{finalDefaultMethod}, and \code{MethodAddCoerce}. } } From 18b3d1d3d424caea82dca869a99073b4e3b28b9f Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 6 May 2024 13:17:36 +0000 Subject: [PATCH 033/546] finalDefaultMethod(): defunctify "MethodsList" branch git-svn-id: https://svn.r-project.org/R/trunk@86525 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/methods/R/MethodsList.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/methods/R/MethodsList.R b/src/library/methods/R/MethodsList.R index d9ade83a8f7..d146d447490 100644 --- a/src/library/methods/R/MethodsList.R +++ b/src/library/methods/R/MethodsList.R @@ -217,7 +217,7 @@ finalDefaultMethod <- || is.null(method)) break if(is(method, "MethodsList")) { - .MlistDeprecated() + .MlistDefunct() method <- slot(method, "methods")[["ANY"]] } else stop(gettextf( From 38660422577679fdaf83d1a407e52cd812c2115b Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 6 May 2024 17:17:06 +0000 Subject: [PATCH 034/546] Disable memory cap on macOS (32-bit, PR#18713). git-svn-id: https://svn.r-project.org/R/trunk@86526 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/startup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/startup.c b/src/main/startup.c index bb75a859ee4..1d2a6755b5a 100644 --- a/src/main/startup.c +++ b/src/main/startup.c @@ -238,7 +238,8 @@ void R_SizeFromEnv(Rstart Rp) else Rp->max_vsize = value; } -#if defined(__APPLE__) && defined(_SC_PHYS_PAGES) && defined(_SC_PAGE_SIZE) +#if defined(__APPLE__) && defined(_SC_PHYS_PAGES) && defined(_SC_PAGE_SIZE) \ + && (SIZEOF_SIZE_T > 4) /* For now only on macOS place a default limit on the vector heap size to avoid having R killed due to memory overcommit. Setting the limit at the maximum of 16Gb and available physical From 9711c6f405a6c29104c0b5337c7ccafc4168fc9c Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 7 May 2024 08:04:08 +0000 Subject: [PATCH 035/546] Add backup physical memory detection on macOS when _SC_PHYS_PAGES is not defined on macOS (PR#18713). git-svn-id: https://svn.r-project.org/R/trunk@86527 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/startup.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/startup.c b/src/main/startup.c index 1d2a6755b5a..59c87af32ab 100644 --- a/src/main/startup.c +++ b/src/main/startup.c @@ -34,6 +34,11 @@ #include #endif +#ifdef __APPLE__ +# include +# include +#endif + /* These are used in ../gnuwin32/system.c, ../unix/sys-std.c */ SA_TYPE SaveAction = SA_SAVEASK; SA_TYPE RestoreAction = SA_RESTORE; @@ -251,6 +256,17 @@ void R_SizeFromEnv(Rstart Rp) R_size_t MinMaxVSize = 17179869184; /* 16 Gb */ Rp->max_vsize = sysmem > MinMaxVSize ? sysmem : MinMaxVSize; } +#elif defined(__APPLE__) && (SIZEOF_SIZE_T > 4) + else { + R_size_t sysmem = 0; + R_size_t len = sizeof(sysmem); + if (!sysctlbyname("hw.memsize", &sysmem, &len, NULL, 0) + && len == sizeof(sysmem)) { + + R_size_t MinMaxVSize = 17179869184; /* 16 Gb */ + Rp->max_vsize = sysmem > MinMaxVSize ? sysmem : MinMaxVSize; + } + } #endif if((p = getenv("R_VSIZE"))) { value = R_Decode2Long(p, &ierr); From 4ef6ec3173e74a81910d9e541181d696f108b4db Mon Sep 17 00:00:00 2001 From: smeyer Date: Wed, 8 May 2024 21:51:50 +0000 Subject: [PATCH 036/546] tweak citation() with newline-separated URLs git-svn-id: https://svn.r-project.org/R/trunk@86528 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 8 +++++--- tests/reg-tests-3.R | 9 ++++++++- tests/reg-tests-3.Rout.save | 25 +++++++++++++++++++------ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index c879ab27435..8d25385c84e 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -1439,13 +1439,15 @@ function(package = "base", lib.loc = NULL, auto = NULL) } if(!length(z$url) && !is.null(url <- meta$URL)) { + ## WRE: "a list of URLs separated by commas or whitespace". ## Cannot have several URLs in BibTeX and bibentry object URL ## fields (PR #16240). - if(grepl("[, ]", url)) { + if(length(urls <- strsplit(url, "[, \n]+")[[1L]]) > 1L) { ## Show the first URL as the BibTeX url, and add the others ## to the note (PR#18547). - z$url <- sub(",.*", "", url) - z$note <- paste0(z$note, sub("^[^,]*, ?", ", ", url)) + z$url <- urls[1L] + z$note <- paste0(c(z$note, sprintf("\\url{%s}", urls[-1L])), + collapse = ", ") } else z$url <- url } diff --git a/tests/reg-tests-3.R b/tests/reg-tests-3.R index 09bde772707..f6736a636ae 100644 --- a/tests/reg-tests-3.R +++ b/tests/reg-tests-3.R @@ -253,7 +253,7 @@ stopifnot(exprs = { pkg <- "nlme" (hasME <- requireNamespace(pkg, quietly=TRUE, lib.loc = .Library)) if(hasME) withAutoprint({ - c2 <- citation(package=pkg) + c2 <- citation(pkg, .Library) ## avoid spurious diffs: c2$author[[1]]$given[[1]] <- "J." c2$year[[1]] <- "9999" @@ -277,6 +277,13 @@ if(hasME) withAutoprint({ nchar(f2N[ie]) < nchar(f2B[ie]) startsWith(f2B[ie], f2N[ie]) }) + + desc <- packageDescription(pkg, .Library) + desc$URL <- paste(URL1 <- "https://example.org", + "https://example.com", sep = "\n") # via continuation line + desc$Repository <- NULL + c3 <- citation(auto = desc) + stopifnot(identical(print(c3$url), URL1)) # R <= 4.4.0 gave both URLs }) cat('Time elapsed: ', proc.time(),'\n') diff --git a/tests/reg-tests-3.Rout.save b/tests/reg-tests-3.Rout.save index ff6e18b734a..2aef01593c4 100644 --- a/tests/reg-tests-3.Rout.save +++ b/tests/reg-tests-3.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-02-15 r85920) -- "Unsuffered Consequences" +R Under development (unstable) (2024-05-07 r86527) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -927,8 +927,8 @@ standardGeneric for "chol2inv" defined from package "base" function (x, ...) standardGeneric("chol2inv") - - + + Methods may be defined for arguments: x Use showMethods(chol2inv) for currently available ones. > @@ -969,7 +969,7 @@ packages. > (hasME <- requireNamespace(pkg, quietly=TRUE, lib.loc = .Library)) [1] TRUE > if(hasME) withAutoprint({ -+ c2 <- citation(package=pkg) ++ c2 <- citation(pkg, .Library) + ## avoid spurious diffs: + c2$author[[1]]$given[[1]] <- "J." + c2$year[[1]] <- "9999" @@ -993,8 +993,15 @@ packages. + nchar(f2N[ie]) < nchar(f2B[ie]) + startsWith(f2B[ie], f2N[ie]) + }) ++ ++ desc <- packageDescription(pkg, .Library) ++ desc$URL <- paste(URL1 <- "https://example.org", ++ "https://example.com", sep = "\n") # via continuation line ++ desc$Repository <- NULL ++ c3 <- citation(auto = desc) ++ stopifnot(identical(print(c3$url), URL1)) # R <= 4.4.0 gave both URLs + }) -> c2 <- citation(package = pkg) +> c2 <- citation(pkg, .Library) > c2$author[[1]]$given[[1]] <- "J." > c2$year[[1]] <- "9999" > c2$note[[1]] <- sub("3.1-[0-9]*$", "3.1-999", c2$note[[1]]) @@ -1066,7 +1073,13 @@ A BibTeX entry for LaTeX users is + startsWith(f2B[ie], f2N[ie]) + }) [1] 4 +> desc <- packageDescription(pkg, .Library) +> desc$URL <- paste(URL1 <- "https://example.org", "https://example.com", sep = "\n") +> desc$Repository <- NULL +> c3 <- citation(auto = desc) +> stopifnot(identical(print(c3$url), URL1)) +[1] "https://example.org" > > cat('Time elapsed: ', proc.time(),'\n') -Time elapsed: 2.245 0.124 2.369 0.001 0 +Time elapsed: 2.884 0.14 3.09 0.003 0 > From 05465fc7b3a3cbd953d80b966ef4d1050dfe853f Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 10 May 2024 12:58:09 +0000 Subject: [PATCH 037/546] Make stopCluster() of a SOCK cluster wait a little bit for the workers to shut down (PR#18133). git-svn-id: https://svn.r-project.org/R/trunk@86529 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/parallel/NAMESPACE | 1 + src/library/parallel/R/snowSOCK.R | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/library/parallel/NAMESPACE b/src/library/parallel/NAMESPACE index 800fcc75eff..bbad65dc633 100644 --- a/src/library/parallel/NAMESPACE +++ b/src/library/parallel/NAMESPACE @@ -29,6 +29,7 @@ S3method(recvOneData, SOCKcluster) S3method(sendData, SOCKnode) S3method(sendData, SOCK0node) S3method(stopCluster, default) +S3method(stopCluster, SOCKcluster) ## To support snow clusters #S3method(closeNode, NWSnode) diff --git a/src/library/parallel/R/snowSOCK.R b/src/library/parallel/R/snowSOCK.R index 49d845a8907..e6efef3ff75 100644 --- a/src/library/parallel/R/snowSOCK.R +++ b/src/library/parallel/R/snowSOCK.R @@ -1,7 +1,7 @@ # File src/library/parallel/R/snowSOCK.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2023 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -125,7 +125,8 @@ newPSOCKnode <- function(machine = "localhost", ..., class = if(useXDR) "SOCKnode" else "SOCK0node") } -closeNode.SOCKnode <- closeNode.SOCK0node <- function(node) close(node$con) +## Let the OS close the connection (see stopCluster). +closeNode.SOCKnode <- closeNode.SOCK0node <- function(node) {} sendData.SOCKnode <- function(node, data) serialize(data, node$con) sendData.SOCK0node <- function(node, data) serialize(data, node$con, xdr = FALSE) @@ -269,6 +270,29 @@ print.SOCKnode <- print.SOCK0node <- function(x, ...) invisible(x) } +stopCluster.SOCKcluster <- function(cl = NULL) +{ + for (n in cl) postNode(n, "DONE") + cons <- lapply(cl, function(x) x$con) + + ## Wait (with a timeout) for the worker connection to be closed by the + ## OS, so that the cleanup of the worker's R session has a chance to run + ## before stopCluster() finishes (PR#18133). + + t0 <- Sys.time() + cleanup_timeout <- 5 + while(length(cons) > 0) { + done <- socketSelect(cons, write = FALSE, timeout = cleanup_timeout) + for(con in cons[done]) close(con) + cons <- cons[!done] + if (difftime(Sys.time(), t0, units="secs") > cleanup_timeout) + break + } + + ## Close the remaining worker connections unconditionally. + for(con in cons) close(con) +} + .workRSOCK <- function() { makeSOCKmaster <- function(master, port, setup_timeout, timeout, useXDR, From 1ed73d6cddf90ffa5c4d2e7a84c9b87477ed6760 Mon Sep 17 00:00:00 2001 From: Jeroen Ooms Date: Fri, 10 May 2024 19:31:20 +0200 Subject: [PATCH 038/546] rename master to main --- .github/scripts/svn-sync.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/scripts/svn-sync.sh b/.github/scripts/svn-sync.sh index 60e0d2693b0..6e2a353f36c 100755 --- a/.github/scripts/svn-sync.sh +++ b/.github/scripts/svn-sync.sh @@ -5,18 +5,18 @@ # git svn clone -T trunk https://svn.r-project.org/R # git checkout origin/trunk -b trunk # git remote add github https://github.com/r-devel/r-svn -# git checkout master -# git fetch github master -# git reset --hard github/master +# git checkout main +# git fetch github main +# git reset --hard github/main set -e set -x git checkout trunk git svn rebase git push github trunk -git checkout master -git fetch github master -git reset --hard github/master -LASTMSG=$(git log master --grep="git-svn-id: https://svn.r-project.org/R/trunk" -n1 | grep -o 'git-svn-id: [^ ]*') +git checkout main +git fetch github main +git reset --hard github/main +LASTMSG=$(git log main --grep="git-svn-id: https://svn.r-project.org/R/trunk" -n1 | grep -o 'git-svn-id: [^ ]*') LASTSVN=$(git log trunk --grep="$LASTMSG" -n1 --pretty="%H") if [ -z "$LASTSVN" ]; then echo "FAILED TO FIND LASTSVN" @@ -33,9 +33,9 @@ do GIT_COMMITTER_NAME="$(git log -1 $hash --pretty=format:%cn)" \ GIT_COMMITTER_EMAIL="$(git log -1 $hash --pretty=format:%ce)" \ git cherry-pick "$hash" - git push github master + git push github main done -# Check that master and trunk are identical except for .github directory +# Check that main and trunk are identical except for .github directory # This verifies that we haven't omitted any commits -git diff --stat master trunk -- . ':(exclude).github' +git diff --stat main trunk -- . ':(exclude).github' From 56d66b12442868c7432a31f3505bca96f6ca45a1 Mon Sep 17 00:00:00 2001 From: ripley Date: Sat, 11 May 2024 12:59:48 +0000 Subject: [PATCH 039/546] updares of Fortran 2023 git-svn-id: https://svn.r-project.org/R/trunk@86530 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 2c192f569c1..ded9036531b 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -2890,7 +2890,7 @@ selected as @samp{FC}, so platforms might be encountered which only support Fortran 90. However, Fortran 95 is supported on all known platforms. -Most compilers specified by @samp{FC} will accept Fortran 2003, 2008 or +Most compilers specified by @samp{FC} will accept most Fortran 2003, 2008 or 2018 code: such code should still use file extension @file{.f90}. Most current platforms use @command{gfortran} where you might need to include @option{-std=f2003}, @option{-std=f2008} or (from version 8) @@ -2898,10 +2898,25 @@ current platforms use @command{gfortran} where you might need to include default is `GNU Fortran', currently Fortran 2018 (but Fortran 95 prior to @command{gfortran}@tie{}8) with non-standard extensions. The other compilers in current use (@I{LLVM}'s @command{flang-new} and Intel's -@command{ifx}) default to Fortran 2018. +@command{ifx}) default to Fortran 2018@footnote{but was said to have +complete support only from version 2023.0.0.}. It is good practice to describe a Fortran version requirement in -@file{DESCRIPTION}'s @samp{SystemRequirements} field. +@file{DESCRIPTION}'s @samp{SystemRequirements} field. Note that this is +purely for information: the package also needs a @command{configure} +script to determine the compiler and set approrpriate option(s) and test +that the features needed from the standard are actually supported. + +The Fortran 2023 released in Nov 2023: as usual compiler vedors are +introducing support incrementally. +For Intel's @command{ifx} see +@uref{https://www.intel.com/content/www/us/en/developer/articles/technical/fortran-language-and-openmp-features-in-ifx.html#Fortran%20Standards}. +For LLVM's @command{flang-new} see +@uref{https://flang.llvm.org/docs/F202X.html}. +@code{gfortran} does not have complete support even for the 2008 and +2018 standards, but recent versions support the option @option{-std=f2023}. +@c https://gcc.gnu.org/wiki/Fortran2008Status +@c https://gcc.gnu.org/wiki/Fortran2018Status @c The Oracle @command{f95} compiler `accepts some Fortran 2003/8 features' @c (search for `Oracle Developer Studio 12.6: Fortran User's Guide' and From abe625945c4402cd2bb97b5a64e7469db3e904f0 Mon Sep 17 00:00:00 2001 From: smeyer Date: Sat, 11 May 2024 13:42:13 +0000 Subject: [PATCH 040/546] fix S4 lookup in debugcall() (PR#18143) git-svn-id: https://svn.r-project.org/R/trunk@86532 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 ++++ src/library/utils/R/debugcall.R | 5 +++-- tests/reg-tests-1e.R | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 1b6c56501ab..16467578ae2 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -108,6 +108,10 @@ \item The internal help server on Windows can again serve requests sent in quick succession, fixing a regression in \R 4.4.0. + + \item \code{debugcall(\var{S3Generic}())} now also works when a + corresponding S4-generic version is in the \pkg{methods} cache + (\PR{18143}). } } } diff --git a/src/library/utils/R/debugcall.R b/src/library/utils/R/debugcall.R index f4ca9cbaa37..7cc988d81c2 100644 --- a/src/library/utils/R/debugcall.R +++ b/src/library/utils/R/debugcall.R @@ -1,7 +1,7 @@ ## File src/library/utils/R/debugcall.R ## Part of the R package, https://www.R-project.org ## -## Copyright (C) 1995-2023 The R Core Team +## Copyright (C) 1995-2024 The R Core Team ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -30,7 +30,8 @@ mcall <- match.call(func, call) env <- parent.frame(2L) - if(!(have.methods && methods::isGeneric(funsym))) { # not S4-generic + isS4Generic <- have.methods && methods::isGeneric(funsym, env) + if(!isS4Generic) { s3ret <- isS3stdGeneric(func) if(s3ret) { genname <- names(s3ret) diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 08c3d40bd93..c3ed4cdb4bc 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1380,6 +1380,7 @@ stopifnot(exprs = { }) ## the last lost row.names => dim(.) was 0 x 3 instead of d0's 2 x 3, in R <= 4.4.0 + ## Scan should not treat "NA" as double/complex when na.strings doesn't ## include it (PR#17289) (r <- tryCid(scan(text="NA", what=double(), na.strings=character()))) @@ -1388,6 +1389,22 @@ stopifnot(inherits(r, "error")) stopifnot(inherits(r, "error")) +## PR#18143: debugcall(()) when an S4-generic version is cached +stopifnot(exprs = { + isGeneric("summary", getNamespace("stats4")) + isNamespaceLoaded("stats4") + isS3stdGeneric(summary) # cached S4 generic is not visible +}) +debugcall(summary(factor(1))) +## failed in R <= 4.4.0 with Error in fdef@signature : +## no applicable method for `@` applied to an object of class "function" +stopifnot(isdebugged(summary.factor)) +undebug(summary.factor) +stopifnot(!isdebugged(summary.factor)) +unloadNamespace("stats4") + + + ## keep at end rbind(last = proc.time() - .pt, total = proc.time()) From d5b883e69a0f5713f88229aea3b974881ddc97e2 Mon Sep 17 00:00:00 2001 From: ripley Date: Sun, 12 May 2024 13:03:51 +0000 Subject: [PATCH 041/546] warn on the use of GNU Fortran EXIT git-svn-id: https://svn.r-project.org/R/trunk@86533 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 5 ++++- src/library/tools/R/sotools.R | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index ded9036531b..7a6389ad913 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -2914,7 +2914,8 @@ For Intel's @command{ifx} see For LLVM's @command{flang-new} see @uref{https://flang.llvm.org/docs/F202X.html}. @code{gfortran} does not have complete support even for the 2008 and -2018 standards, but recent versions support the option @option{-std=f2023}. +2018 standards, but the option @option{-std=f2023} is supported from +version 14.1. @c https://gcc.gnu.org/wiki/Fortran2008Status @c https://gcc.gnu.org/wiki/Fortran2018Status @@ -5235,6 +5236,8 @@ makefiles in sub-directories may also need to define @code{NDEBUG}. This applies not only to your own code but to any external software you compile in or link to. +Nor should Fortran code call @code{STOP} nor @code{EXIT} (a GNU extension). + @item Compiled code should not write to @file{stdout} or @file{stderr} and C++ and Fortran I/O should not be used. As with the previous item such diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 095338c0715..92ae47ee244 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -151,6 +151,8 @@ so_symbol_names_table <- "linux, Fortran, gfortran, random_number, _gfortran_rand", "linux, Fortran, gfortran, random_seed, _gfortran_random_seed_i4", "linux, Fortran, gfortran, random_seed, _gfortran_random_seed_i8", + "linux, Fortran, gfortran, exit, _gfortran_exit_i4", + "linux, Fortran, gfortran, exit, _gfortran_exit_i8", ## Classic flang from Dec 2017 (and untested since) "linux, Fortran, ClassicFlang, open, f90io_open03", @@ -297,6 +299,8 @@ so_symbol_names_table <- "macos, Fortran, gfortran, random_number, __gfortran_rand", "macos, Fortran, gfortran, random_seed, __gfortran_random_seed_i4", "macos, Fortran, gfortran, random_seed, __gfortran_random_seed_i8", + "macos, Fortran, gfortran, exit, __gfortran_exit_i4", + "macos, Fortran, gfortran, exit, __gfortran_exit_i8", ## This is old: freebsd defaults to clang these days, and ## gfortran and (classic) flang are available (and 'f18' will be) @@ -445,6 +449,8 @@ so_symbol_names_table <- "windows, Fortran, gfortran, random_number, _gfortran_random_r16", "windows, Fortran, gfortran, random_seed, _gfortran_random_seed_i4", "windows, Fortran, gfortran, random_seed, _gfortran_random_seed_i8", + "windows, Fortran, gfortran, exit, _gfortran_exit_i4", + "windows, Fortran, gfortran, exit, _gfortran_exit_i8", ## currently copy from Linux ## flang-new but executable already named 'flang' From fde9789bddddfcb062fce2ef5accb75b04b83279 Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 13 May 2024 07:32:57 +0000 Subject: [PATCH 042/546] finally report Fortran 2018 deleted features git-svn-id: https://svn.r-project.org/R/trunk@86535 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 57a0b84eafc..2302b2f2c59 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -5868,8 +5868,10 @@ add_dummies <- function(dir, Log) lines <- filtergrep(ex_re, lines, useBytes = TRUE) ## and gfortran 9 warnings about F2018 - ex_re <- "^Warning: Fortran 2018 deleted feature:" - lines <- filtergrep(ex_re, lines, useBytes = TRUE) + ## No longer filtered in R 4.5.0. + ## Many are errors with -std=f2018 + ## ex_re <- "^Warning: Fortran 2018 deleted feature:" + ## lines <- filtergrep(ex_re, lines, useBytes = TRUE) ## and gfortran 10 warnings ex_re <- "^Warning: Array.*is larger than limit set" From 291ee38c92e04bfcc32c0bab43dc4a7d22e65594 Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 13 May 2024 09:48:44 +0000 Subject: [PATCH 043/546] Make closeNode() behavior in SOCK clusters closer to what has been before 86529 (PR#18133). git-svn-id: https://svn.r-project.org/R/trunk@86536 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/parallel/R/snowSOCK.R | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/library/parallel/R/snowSOCK.R b/src/library/parallel/R/snowSOCK.R index e6efef3ff75..c274fb7113c 100644 --- a/src/library/parallel/R/snowSOCK.R +++ b/src/library/parallel/R/snowSOCK.R @@ -125,8 +125,14 @@ newPSOCKnode <- function(machine = "localhost", ..., class = if(useXDR) "SOCKnode" else "SOCK0node") } -## Let the OS close the connection (see stopCluster). -closeNode.SOCKnode <- closeNode.SOCK0node <- function(node) {} +closeNode.SOCKnode <- closeNode.SOCK0node <- function(node) +{ + if ("host" %in% names(node) && "rank" %in% names(node)) + close(node$con) + + ## Let the OS close the connection to the master node (see stopCluster) + ## when a worker finishes. +} sendData.SOCKnode <- function(node, data) serialize(data, node$con) sendData.SOCK0node <- function(node, data) serialize(data, node$con, xdr = FALSE) @@ -273,7 +279,6 @@ print.SOCKnode <- print.SOCK0node <- function(x, ...) stopCluster.SOCKcluster <- function(cl = NULL) { for (n in cl) postNode(n, "DONE") - cons <- lapply(cl, function(x) x$con) ## Wait (with a timeout) for the worker connection to be closed by the ## OS, so that the cleanup of the worker's R session has a chance to run @@ -281,16 +286,18 @@ stopCluster.SOCKcluster <- function(cl = NULL) t0 <- Sys.time() cleanup_timeout <- 5 - while(length(cons) > 0) { + nodes <- cl + while(length(nodes) > 0) { + cons <- lapply(nodes, function(x) x$con) done <- socketSelect(cons, write = FALSE, timeout = cleanup_timeout) - for(con in cons[done]) close(con) - cons <- cons[!done] + for(n in nodes[done]) closeNode(n) + nodes <- nodes[!done] if (difftime(Sys.time(), t0, units="secs") > cleanup_timeout) break } ## Close the remaining worker connections unconditionally. - for(con in cons) close(con) + for(n in nodes) closeNode(con) } .workRSOCK <- function() From 6a34bc178d1fc5b912849d8a03095655ce581655 Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 13 May 2024 10:02:09 +0000 Subject: [PATCH 044/546] fix toTitleCase(character(0)) git-svn-id: https://svn.r-project.org/R/trunk@86537 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 ++++ src/library/tools/R/utils.R | 10 +++++----- tests/reg-tests-1e.R | 6 ++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 16467578ae2..f74a7489a0e 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -112,6 +112,10 @@ \item \code{debugcall(\var{S3Generic}())} now also works when a corresponding S4-generic version is in the \pkg{methods} cache (\PR{18143}). + + \item Package \pkg{tools}' \code{toTitleCase(ch0)} now returns + \code{character(0)} when \code{ch0} is of zero length; fixing + \PR{18724}, reported by David Hugh Jones. } } } diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index 30f307ff287..9e97162b3a2 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -1,7 +1,7 @@ # File src/library/tools/R/utils.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2023 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -826,7 +826,7 @@ function(x) "\\makeatother"), collapse = ""), x, x) -} +} ### ** .file_path_relative_to_dir @@ -990,7 +990,7 @@ function(Tidy = Sys.getenv("R_TIDYCMD", "tidy")) attr(Tidy, "msg") <- msg } Tidy -} +} ### ** .get_BibTeX_errors_from_blg_file @@ -2561,7 +2561,7 @@ function(fun, args = list(), opts = "--no-save --no-restore", ## escape issue if we use backslashes in paths, hence convert to "/" tfi <- normalizePath(tempfile("runri"), winslash="/", mustWork=FALSE) tfo <- normalizePath(tempfile("runro"), winslash="/", mustWork=FALSE) - + wrk <- c(sprintf("x <- readRDS(\"%s\")", tfi), "options(repos = x$repos)", ## need quote = TRUE in case some of args are not self-evaluating @@ -2698,7 +2698,7 @@ function(text) } if(typeof(text) != "character") stop("'text' must be a character vector") - sapply(text, titleCase1, USE.NAMES = FALSE) + vapply(text, titleCase1, "", USE.NAMES = FALSE) } ### ** path_and_libPath diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index c3ed4cdb4bc..08bbea1e266 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1404,6 +1404,12 @@ stopifnot(!isdebugged(summary.factor)) unloadNamespace("stats4") +## PR#18724 - toTitleCase(character(0)) +ch0 <- character(0L) +stopifnot(identical(ch0, tools::toTitleCase(ch0))) +## was list() in R <= 4.4.0 + + ## keep at end rbind(last = proc.time() - .pt, From 95601e1adf3b1d51acd97b704cdba1dc4cb7b29e Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 13 May 2024 10:31:43 +0000 Subject: [PATCH 045/546] report some flang warnings paralleling gfortran ones git-svn-id: https://svn.r-project.org/R/trunk@86538 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 10 ++++++++++ src/library/tools/R/check.R | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index f74a7489a0e..17f9cc57214 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -87,6 +87,16 @@ } } + \subsection{UTILITIES}{ + \itemize{ + \item \command{R CMD check} now reports as warnings what + \command{gfortran} calls \sQuote{Fortran 2018 deleted features}, all + of which have long been marked as \sQuote{obsolescent} and some of + which were deleted in Fortran 2008 or earlier. Fortran compilers + are no longer required to support these. + } + } + \subsection{BUG FIXES}{ \itemize{ \item \code{as.numeric()}, \code{scan()}, \code{type.convert()} diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 2302b2f2c59..e11ce5b0ef8 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -5822,7 +5822,12 @@ add_dummies <- function(dir, Log) "warning: .* \\[-Wincompatible-pointer-types-discards-qualifiers\\]", ## LLVM clang 16 - " warning: use of unary operator that may be intended as compound assignment" + " warning: use of unary operator that may be intended as compound assignment", + + ## LLVM flang warnings: + ## Includes Hollerith constants + ## does not complain about 'Shared DO termination' + "(portability: A DO loop should terminate with an END DO or CONTINUE|portability: deprecated usage|in the context: arithmetic IF statement)" ) warn_re <- paste0("(", paste(warn_re, collapse = "|"), ")") From 0dd023e9a7b1060c9c7e51a4238d99fef1c97673 Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 13 May 2024 13:11:14 +0000 Subject: [PATCH 046/546] Fix fallback closeNode(). git-svn-id: https://svn.r-project.org/R/trunk@86541 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/parallel/R/snowSOCK.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/parallel/R/snowSOCK.R b/src/library/parallel/R/snowSOCK.R index c274fb7113c..18786fec129 100644 --- a/src/library/parallel/R/snowSOCK.R +++ b/src/library/parallel/R/snowSOCK.R @@ -297,7 +297,7 @@ stopCluster.SOCKcluster <- function(cl = NULL) } ## Close the remaining worker connections unconditionally. - for(n in nodes) closeNode(con) + for(n in nodes) closeNode(n) } .workRSOCK <- function() From fe393a751965604329e95e1588d35bceb456907e Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 13 May 2024 14:20:44 +0000 Subject: [PATCH 047/546] modernize Fortran git-svn-id: https://svn.r-project.org/R/trunk@86542 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/stats/src/eureka.f | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/library/stats/src/eureka.f b/src/library/stats/src/eureka.f index 8397d8e6869..9cce4ef36c9 100644 --- a/src/library/stats/src/eureka.f +++ b/src/library/stats/src/eureka.f @@ -37,34 +37,34 @@ subroutine eureka (lr,r,g,f,var,a) q = f(1,1)*r(2) var(1) = (1 - f(1,1)*f(1,1))*r(1) if (lr .eq. 1) return - do 60 l = 2, lr + do l = 2, lr a(l) = -d/v if (l .gt. 2) then l1 = (l - 2)/2 l2 = l1 + 1 - do 10 j = 2, l2 + do j = 2, l2 hold = a(j) k = l - j + 1 a(j) = a(j) + a(l)*a(k) a(k) = a(k) + a(l)*hold - 10 continue + end do if (2*l1 .ne. l - 2) a(l2+1) = a(l2+1)*(1.0d0 + a(l)) endif v = v + a(l)*d f(l,l) = (g(l+1) - q)/v - do 40 j = 1, l-1 + do j = 1, l-1 f(l,j) = f(l-1, j) + f(l, l)*a(l-j+1) - 40 continue + end do c estimate the innovations variance var(l) = var(l-1) * (1 - f(l,l)*f(l,l)) if (l .eq. lr) return d = 0.0d0 q = 0.0d0 - do 50 i = 1, l + do i = 1, l k = l-i+2 d = d + a(i)*r(k) q = q + f(l,i)*r(k) - 50 continue - 60 continue + end do + end do return end From bd0df7fe4cdb7caf69cc3f73b3e76b5977c77974 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 13 May 2024 16:33:49 +0000 Subject: [PATCH 048/546] SET_ENCLOS now checks for cycles and that the new value is an ENVSXP. git-svn-id: https://svn.r-project.org/R/trunk@86545 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 ++++ src/main/memory.c | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 17f9cc57214..e3d3b67796e 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -62,6 +62,10 @@ \itemize{ \item The non-API and hidden entry points \code{Rf_setIVector}, \code{Rf_setRVector} and \code{Rf_setSVector} have been removed. + + \item The internal code for changing the parent of an environment + now signals an error if the new parent is not an environment or if + the change would create a cycle in the parent chain. } } diff --git a/src/main/memory.c b/src/main/memory.c index be530f7c454..5a2ab5e053f 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4494,7 +4494,19 @@ SEXP (HASHTAB)(SEXP x) { return CHK(HASHTAB(CHK(x))); } int (ENVFLAGS)(SEXP x) { return ENVFLAGS(CHK(x)); } void (SET_FRAME)(SEXP x, SEXP v) { FIX_REFCNT(x, FRAME(x), v); CHECK_OLD_TO_NEW(x, v); FRAME(x) = v; } -void (SET_ENCLOS)(SEXP x, SEXP v) { FIX_REFCNT(x, ENCLOS(x), v); CHECK_OLD_TO_NEW(x, v); ENCLOS(x) = v; } + +void (SET_ENCLOS)(SEXP x, SEXP v) +{ + if (TYPEOF(v) != ENVSXP) + error(_("'parent' is not an environment")); + for (SEXP e = v; e != R_NilValue; e = ENCLOS(e)) + if (e == x) + error(_("cycles in parent chains are not allowed")); + FIX_REFCNT(x, ENCLOS(x), v); + CHECK_OLD_TO_NEW(x, v); + ENCLOS(x) = v; +} + void (SET_HASHTAB)(SEXP x, SEXP v) { FIX_REFCNT(x, HASHTAB(x), v); CHECK_OLD_TO_NEW(x, v); HASHTAB(x) = v; } void (SET_ENVFLAGS)(SEXP x, int v) { SET_ENVFLAGS(x, v); } From de37f1ef0fa17b1dcb0d73996f687cc5d26dfc3b Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 13 May 2024 17:36:14 +0000 Subject: [PATCH 049/546] report [-Wswitch-bool] (from clang++) git-svn-id: https://svn.r-project.org/R/trunk@86546 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index e11ce5b0ef8..29d521bb016 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -5824,6 +5824,9 @@ add_dummies <- function(dir, Log) ## LLVM clang 16 " warning: use of unary operator that may be intended as compound assignment", + ## Apple and LLVM clang + " warning: switch condition has boolean value \\[-Wswitch-bool\\]", + ## LLVM flang warnings: ## Includes Hollerith constants ## does not complain about 'Shared DO termination' From 68c56a662c6b7cafbcae7889d847214ab3d5ebdc Mon Sep 17 00:00:00 2001 From: smeyer Date: Mon, 13 May 2024 19:27:55 +0000 Subject: [PATCH 050/546] fix sealClass() (PR#17496) git-svn-id: https://svn.r-project.org/R/trunk@86547 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/methods/R/SClasses.R | 4 ++-- tests/reg-S4.R | 11 +++++++++++ tests/reg-S4.Rout.save | 13 ++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/library/methods/R/SClasses.R b/src/library/methods/R/SClasses.R index 244a0a9e2fe..c6aa3478504 100644 --- a/src/library/methods/R/SClasses.R +++ b/src/library/methods/R/SClasses.R @@ -808,7 +808,7 @@ isSealedClass <- function(Class, where = topenv(parent.frame())) { sealClass <- function(Class, where = topenv(parent.frame())) { if(missing(where)) - where <- findClass(Class, unique = "sealing the class", where = where) + where <- findClass(Class, unique = "sealing the class", where = where)[[1L]] classDef <- getClassDef(Class, where) if(!classDef@sealed) { classDef@sealed <- TRUE @@ -912,7 +912,7 @@ className <- function(class, package) { else { classDef <- findClass(className, topenv(parent.frame())) if(length(classDef) == 1) - classDef <- classDef[[1]] + classDef <- classDef[[1L]] } ## at this point, classDef is the definition if ## unique, otherwise a list of 0 or >1 definitions diff --git a/tests/reg-S4.R b/tests/reg-S4.R index 39d5bfaa097..f1ca099a2de 100644 --- a/tests/reg-S4.R +++ b/tests/reg-S4.R @@ -877,3 +877,14 @@ body(cd@contains[["A"]]@coerce)[[2]] ## >> value <- methods::new("A") setClass("foo", slots = c(y = "numeric")) setClass("bar", contains = "foo") body(getClass("bar")@contains[[1]]@coerce)[[2]] + + +## PR#17496: sealClass() +setClass("foo", slots = c(name = "character"), sealed = TRUE) +stopifnot(isSealedClass("foo")) +tools::assertError(setClass("foo")) +stopifnot(removeClass("foo")) +setClass("foo") +sealClass("foo") # failed in R < 4.5.0 +stopifnot(isSealedClass("foo")) +stopifnot(removeClass("foo")) diff --git a/tests/reg-S4.Rout.save b/tests/reg-S4.Rout.save index 15dd3c218e3..eba98ed3774 100644 --- a/tests/reg-S4.Rout.save +++ b/tests/reg-S4.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-04-19 r86451) -- "Unsuffered Consequences" +R Under development (unstable) (2024-05-13 r86546) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -1176,3 +1176,14 @@ value <- methods::new("A") > body(getClass("bar")@contains[[1]]@coerce)[[2]] class(from) <- "foo" > +> +> ## PR#17496: sealClass() +> setClass("foo", slots = c(name = "character"), sealed = TRUE) +> stopifnot(isSealedClass("foo")) +> tools::assertError(setClass("foo")) +> stopifnot(removeClass("foo")) +> setClass("foo") +> sealClass("foo") # failed in R < 4.5.0 +> stopifnot(isSealedClass("foo")) +> stopifnot(removeClass("foo")) +> From 98eee1316c70a4f9a9537ecce0f7a6530aaa822a Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 14 May 2024 06:31:41 +0000 Subject: [PATCH 051/546] Spelling. git-svn-id: https://svn.r-project.org/R/trunk@86548 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 6 +++--- src/library/stats/R/ts-tests.R | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 7a6389ad913..76b63e95a34 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -2904,14 +2904,14 @@ complete support only from version 2023.0.0.}. It is good practice to describe a Fortran version requirement in @file{DESCRIPTION}'s @samp{SystemRequirements} field. Note that this is purely for information: the package also needs a @command{configure} -script to determine the compiler and set approrpriate option(s) and test +script to determine the compiler and set appropriate option(s) and test that the features needed from the standard are actually supported. -The Fortran 2023 released in Nov 2023: as usual compiler vedors are +The Fortran 2023 released in Nov 2023: as usual compiler vendors are introducing support incrementally. For Intel's @command{ifx} see @uref{https://www.intel.com/content/www/us/en/developer/articles/technical/fortran-language-and-openmp-features-in-ifx.html#Fortran%20Standards}. -For LLVM's @command{flang-new} see +For @I{LLVM}'s @command{flang-new} see @uref{https://flang.llvm.org/docs/F202X.html}. @code{gfortran} does not have complete support even for the 2008 and 2018 standards, but the option @option{-std=f2023} is supported from diff --git a/src/library/stats/R/ts-tests.R b/src/library/stats/R/ts-tests.R index 31b145f2de2..f05d2991f58 100644 --- a/src/library/stats/R/ts-tests.R +++ b/src/library/stats/R/ts-tests.R @@ -21,6 +21,7 @@ Box.test <- function (x, lag = 1, type=c("Box-Pierce", "Ljung-Box"), fitdf=0) if (NCOL(x) > 1) stop ("x is not a vector or univariate time series") DNAME <- deparse1(substitute(x)) + lag <- as.integer(lag) type <- match.arg(type) cor <- acf (x, lag.max = lag, plot = FALSE, na.action = na.pass) n <- sum(!is.na(x)) From bddefcf86e535ce6fb9638067a413137c601bec8 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 14 May 2024 06:32:06 +0000 Subject: [PATCH 052/546] Spelling. git-svn-id: https://svn.r-project.org/R/trunk@86549 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/man/glob2rx.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/utils/man/glob2rx.Rd b/src/library/utils/man/glob2rx.Rd index 62f72198d10..d8e294fcbe6 100644 --- a/src/library/utils/man/glob2rx.Rd +++ b/src/library/utils/man/glob2rx.Rd @@ -46,7 +46,7 @@ glob2rx(pattern, trim.head = FALSE, trim.tail = TRUE) \seealso{ \code{\link{regexp}} about regular expression, \code{\link{sub}}, etc about substitutions using regexps. - \code{\link{Sys.glob}} does wildcard expansio, i.e., \dQuote{globbing} on + \code{\link{Sys.glob}} does wildcard expansion, i.e., \dQuote{globbing} on file paths more subtly, e.g., allowing to escape special characters. } \examples{ From c638d52481cfde128b9c6dd272e31318321c5fc3 Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 14 May 2024 07:58:36 +0000 Subject: [PATCH 053/546] more on obsolescent and deleted Fortran features git-svn-id: https://svn.r-project.org/R/trunk@86550 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 53 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 76b63e95a34..4047ca77c8c 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -6575,6 +6575,22 @@ The use of @code{DFLOAT}, which was superseded by @code{DBLE} in Fortran 77. Also, use of @code{DCMPLX}, @code{DCONJG}, @code{DIMAG} and similar. +@item +Use of what @command{gfprtran} calls `Fortran 2018 deleted features', +although most were `deleted' in earlier standards: those itmeize here +were deleted in Fortran 2008. (In the Fortran standards `deleted' means +features that compilers are not required to implement.) These include +@itemize +@item +Aritmmetic @code{IF} statements. +@item +@code{DO} loops whch are not terminated with a @code{END DO} or +@code{CONTINUE} statement. (Unlabelled @code{DO} loops terminated by +@code{END DO} are preferred for readability.) +@item +Labelled @code{DO} loops sharing a terminating @code{CONTINUE} statement. +@end itemize + @item The use of GNU Fortran extensions. Some are listed at @uref{https://gcc.gnu.org/onlinedocs/gfortran/Extensions-implemented-in-GNU-Fortran.html}. @@ -6639,16 +6655,49 @@ works around this for packages without a @file{src/Makefile}. @c Intel has fpp. Use of extensions @file{.F} and @code{.F90} to indicate source code to be preprocessed: the preprocessor used is compiler-specific and may or -may not be @command{cpp}. +may not be @command{cpp}. Compilers may even preproces files with +extension @file{.f} or @file{.f90} (Intel does). @item Fixed form Fortran (with extension @file{.f}) should only use 72 columns, and free-form at most 132 columns. This includes trailing comments. Over-long lines may be silently truncated or give a warning. -%% The Intel compilers warn. +@c The Intel compilers warn. + +@item +Tabs are not part of the Fortran character set: compilers tend to accept +them but how they are interpreted is compiler-specific. +@item +Fortran-66-style Hollerith constants. @end itemize +As well as `deleted features', Fortran standards have `obsolescent +features'. These are similar to `deprecated' in other languages, but +the Fortran standards committee has said it will only move them to +`deleted' status when they are no longer much used. These include +@itemize +@item +@code{ENTTRY} statements. +@item +@code{FORALL} statements. +@item +Labelled @code{DO} statements. +@item +@code{COMMON} and @code{EQUIVALENCE} statements, and @code{BLOCK DATA} +units. +@item +Computed @code{GOTO} statmennts, replaced by @code{SELECT CASE}. +@item +Statement functions. +@item +@code{DATA} statments after executable statements. +@item +Specific (rather than generic) names for intrinsic functions. +@end itemize +@noindent +@code{gfortran} with option @option{-std=f2018} will warn about these: +@R{} will report only in the installation log. @node Binary distribution, , Portable Fortran code, Writing portable packages @subsection Binary distribution From b41e4f1c86369e817d8300b928f1086f7cac4e63 Mon Sep 17 00:00:00 2001 From: maechler Date: Tue, 14 May 2024 10:21:28 +0000 Subject: [PATCH 054/546] tweak related to |ncp| <= 37.62 + "promise" git-svn-id: https://svn.r-project.org/R/trunk@86551 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/stats/man/TDist.Rd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library/stats/man/TDist.Rd b/src/library/stats/man/TDist.Rd index 4aa04902167..52542237b88 100644 --- a/src/library/stats/man/TDist.Rd +++ b/src/library/stats/man/TDist.Rd @@ -1,6 +1,6 @@ % File src/library/stats/man/TDist.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2023 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{TDist} @@ -30,7 +30,7 @@ rt(n, df, ncp) \item{df}{degrees of freedom (\eqn{> 0}, maybe non-integer). \code{df = Inf} is allowed.} \item{ncp}{non-centrality parameter \eqn{\delta}{delta}; - currently except for \code{rt()}, only for \code{abs(ncp) <= 37.62}. + currently except for \code{rt()}, accurate only for \code{abs(ncp) <= 37.62}. If omitted, use the central t distribution.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are @@ -117,7 +117,7 @@ rt(n, df, ncp) Cumulative distribution function of the non-central \eqn{t} distribution, \emph{Applied Statistics} \bold{38}, 185--189. - This computes the lower tail only, so the upper tail suffers from + This computes the lower tail only, so the upper tail currently suffers from cancellation and a warning will be given when this is likely to be significant. From 4bc409afe0a03701c28d63dac133d72a3792cb5f Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 14 May 2024 19:58:51 +0000 Subject: [PATCH 055/546] more use of DO..END DO git-svn-id: https://svn.r-project.org/R/trunk@86553 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/stats/src/bsplvd.f | 42 +++++------ src/library/stats/src/bvalue.f | 44 ++++++------ src/library/stats/src/bvalus.f | 4 +- src/library/stats/src/portsrc.f | 24 +++---- src/library/stats/src/sinerp.f | 12 ++-- src/library/stats/src/stl.f | 120 ++++++++++++++++---------------- 6 files changed, 123 insertions(+), 123 deletions(-) diff --git a/src/library/stats/src/bsplvd.f b/src/library/stats/src/bsplvd.f index 97e06958245..7eec811beef 100644 --- a/src/library/stats/src/bsplvd.f +++ b/src/library/stats/src/bsplvd.f @@ -58,15 +58,15 @@ subroutine bsplvd ( t, lent, k, x, left, a, dbiatx, nderiv ) c order before bsplvb is called to put values for the next c higher order on top of it. ideriv = mhigh - do 15 m=2,mhigh + do m=2,mhigh jp1mid = 1 - do 11 j=ideriv,k + do j=ideriv,k dbiatx(j,ideriv) = dbiatx(jp1mid,1) jp1mid = jp1mid + 1 - 11 continue + end do ideriv = ideriv - 1 call bsplvb(t,lent,kp1-ideriv,2,x,left,dbiatx) - 15 continue + end do c c at this point, b(left-k+i, k+1-j)(x) is in dbiatx(i,j) for c i=j,...,k and j=1,...,mhigh ('=' nderiv). in particular, the @@ -75,17 +75,17 @@ subroutine bsplvd ( t, lent, k, x, left, a, dbiatx, nderiv ) c rate their b-repr. by differencing, then evaluate at x. c jlow = 1 - do 20 i=1,k - do 19 j=jlow,k + do i=1,k + do j=jlow,k a(j,i) = 0d0 - 19 continue + end do jlow = i a(i,i) = 1d0 - 20 continue + end do c at this point, a(.,j) contains the b-coeffs for the j-th of the c k b-splines of interest here. c - do 45 m=2,mhigh + do m=2,mhigh kp1mm = kp1 - m fkp1mm = dble(kp1mm) il = left @@ -95,17 +95,17 @@ subroutine bsplvd ( t, lent, k, x, left, a, dbiatx, nderiv ) c b-splines from those for preceding derivative by differencing c and store again in a(.,j) . the fact that a(i,j) = 0 for c i < j is used.sed. - do 25 ldummy=1,kp1mm + do ldummy=1,kp1mm factor = fkp1mm/(t(il+kp1mm) - t(il)) c the assumption that t(left) < t(left+1) makes denominator c in factor nonzero. - do 24 j=1,i + do j=1,i a(i,j) = (a(i,j) - a(i-1,j))*factor - 24 continue + end do il = il - 1 i = i - 1 - 25 continue -c + end do +c c for i=1,...,k, combine b-coeffs a(.,i) with b-spline values c stored in dbiatx(.,m) to get value of (m-1)st derivative of c i-th b-spline (of interest here) at x , and store in @@ -113,15 +113,15 @@ subroutine bsplvd ( t, lent, k, x, left, a, dbiatx, nderiv ) c of order m there is safe since the remaining b-spline derivat- c ive of the same order do not use this value due to the fact c that a(j,i) = 0 for j < i . - do 40 i=1,k + do i=1,k sum = 0.d0 jlow = max0(i,m) - do 35 j=jlow,k + do j=jlow,k sum = a(j,i)*dbiatx(j,m) + sum - 35 continue + end do dbiatx(i,m) = sum - 40 continue - 45 continue + end do + end do end subroutine bsplvb ( t, lent,jhigh, index, x, left, biatx ) @@ -217,11 +217,11 @@ subroutine bsplvb ( t, lent,jhigh, index, x, left, biatx ) deltar(j) = t(left+j) - x deltal(j) = x - t(left+1-j) saved = 0d0 - do 26 i=1,j + do i=1,j term = biatx(i)/(deltar(i) + deltal(jp1-i)) biatx(i) = saved + deltar(i)*term saved = deltal(jp1-i)*term - 26 continue + end do biatx(jp1) = saved j = jp1 if (j .lt. jhigh) go to 20 diff --git a/src/library/stats/src/bvalue.f b/src/library/stats/src/bvalue.f index 4abf281c9ef..5d65980ff73 100644 --- a/src/library/stats/src/bvalue.f +++ b/src/library/stats/src/bvalue.f @@ -78,7 +78,7 @@ double precision function bvalue(t,bcoef,n,k,x,jderiv) data i/1/ bvalue = 0.d0 - if (jderiv .ge. k) go to 99 + if (jderiv .ge. k) return c c *** find i s.t. 1 <= i < n+k and t(i) < t(i+1) and c t(i) <= x < t(i+1) . if no such i can be found, x lies @@ -89,7 +89,7 @@ double precision function bvalue(t,bcoef,n,k,x,jderiv) i = interv ( t, n+k, x, 0, 0, i, mflag) if (mflag .ne. 0) then call rwarn('bvalue() mflag != 0: should never happen!') - go to 99 + return endif else i = n @@ -99,7 +99,7 @@ double precision function bvalue(t,bcoef,n,k,x,jderiv) km1 = k - 1 if (km1 .le. 0) then bvalue = bcoef(i) - go to 99 + return endif c c *** store the k b-spline coefficients relevant for the knot interval @@ -110,18 +110,18 @@ double precision function bvalue(t,bcoef,n,k,x,jderiv) jcmin = 1 imk = i - k if (imk .ge. 0) then - do 9 j=1,km1 + do j=1,km1 dm(j) = x - t(i+1-j) - 9 continue + end do else jcmin = 1 - imk - do 5 j=1,i + do j=1,i dm(j) = x - t(i+1-j) - 5 continue - do 6 j=i,km1 + end do + do j=i,km1 aj(k-j) = 0.d0 dm(j) = dm(i) - 6 continue + end do endif c jcmax = k @@ -135,13 +135,13 @@ double precision function bvalue(t,bcoef,n,k,x,jderiv) 19 continue else jcmax = k + nmi - do 15 j=1,jcmax + do j=1,jcmax dp(j) = t(i+j) - x - 15 continue - do 16 j=jcmax,km1 + end do + do j=jcmax,km1 aj(j+1) = 0.d0 dp(j) = dp(jcmax) - 16 continue + end do endif c @@ -151,15 +151,15 @@ double precision function bvalue(t,bcoef,n,k,x,jderiv) c c *** difference the coefficients jderiv times. if (jderiv .ge. 1) then - do 23 j=1,jderiv + do j=1,jderiv kmj = k-j fkmj = dble(kmj) ilo = kmj - do 24 jj=1,kmj + do jj=1,kmj aj(jj) = ((aj(jj+1) - aj(jj))/(dm(ilo) + dp(jj)))*fkmj ilo = ilo - 1 - 24 continue - 23 continue + end do + end do endif c @@ -168,18 +168,18 @@ double precision function bvalue(t,bcoef,n,k,x,jderiv) if (jderiv .ne. km1) then jdrvp1 = jderiv + 1 - do 33 j=jdrvp1,km1 + do j=jdrvp1,km1 kmj = k-j ilo = kmj - do 34 jj=1,kmj + do jj=1,kmj aj(jj) = (aj(jj+1)*dm(ilo) + aj(jj)*dp(jj)) / * (dm(ilo)+dp(jj)) ilo = ilo - 1 - 34 continue - 33 continue + end do + end do endif bvalue = aj(1) c - 99 return + return end diff --git a/src/library/stats/src/bvalus.f b/src/library/stats/src/bvalus.f index 1dd84f856ec..faae4052ac9 100644 --- a/src/library/stats/src/bvalus.f +++ b/src/library/stats/src/bvalus.f @@ -6,8 +6,8 @@ subroutine bvalus(n,knot,coef,nk,x,s,order) double precision bvalue integer i - do 10 i=1,n + do i=1,n s(i)=bvalue(knot,coef,nk,4,x(i),order) - 10 continue + end do return end diff --git a/src/library/stats/src/portsrc.f b/src/library/stats/src/portsrc.f index 27a9a13a5c0..ff5cdac1eff 100644 --- a/src/library/stats/src/portsrc.f +++ b/src/library/stats/src/portsrc.f @@ -311,10 +311,10 @@ SUBROUTINE DRN2G(D, DR, IV, LIV, LV, N, ND, N1, N2, P, R, C 130 Y1 = IV(Y) YI = Y1 - DO 140 L = 1, P + DO L = 1, P V(YI) = V(YI) + DD7TPR(NN, DR(1,L), R) YI = YI + 1 - 140 CONTINUE + END DO IF (N2 .LT. N) GO TO 270 IV(1) = 2 IF (N1 .GT. 1) IV(1) = -3 @@ -332,10 +332,10 @@ SUBROUTINE DRN2G(D, DR, IV, LIV, LV, N, ND, N1, N2, P, R, C *** COMPUTE GRADIENT ONLY (FOR USE IN COVARIANCE COMPUTATION) *** C GI = G1 - DO 160 L = 1, P + DO L = 1, P V(GI) = V(GI) + DD7TPR(NN, R, DR(1,L)) GI = GI + 1 - 160 CONTINUE + END DO GO TO 190 C C *** COMPUTE INITIAL FUNCTION VALUE WHEN ND .LT. N *** @@ -481,24 +481,24 @@ SUBROUTINE DL7SQR(N, A, L) C NP1 = N + 1 I0 = N*(N+1)/2 - DO 30 II = 1, N + DO II = 1, N I = NP1 - II IP1 = I + 1 I0 = I0 - I J0 = I*(I+1)/2 - DO 20 JJ = 1, I + DO JJ = 1, I J = IP1 - JJ J0 = J0 - J T = 0.0D0 - DO 10 K = 1, J + DO K = 1, J IK = I0 + K JK = J0 + K T = T + L(IK)*L(JK) - 10 CONTINUE + END DO IJ = I0 + J A(IJ) = T - 20 CONTINUE - 30 CONTINUE + END DO + END DO RETURN END SUBROUTINE DRMNHB(B, D, FX, G, H, IV, LH, LIV, LV, N, V, X) @@ -707,11 +707,11 @@ SUBROUTINE DRMNHB(B, D, FX, G, H, IV, LH, LIV, LV, N, V, X) C *** CHECK CONSISTENCY OF B AND INITIALIZE IP ARRAY *** C IPI = IV(PERM) - DO 40 I = 1, N + DO I = 1, N IV(IPI) = I IPI = IPI + 1 IF (B(1,I) .GT. B(2,I)) GO TO 420 - 40 CONTINUE + END DO C C *** GET INITIAL FUNCTION VALUE *** C diff --git a/src/library/stats/src/sinerp.f b/src/library/stats/src/sinerp.f index 0b0458e2c1f..0d522f4e58e 100644 --- a/src/library/stats/src/sinerp.f +++ b/src/library/stats/src/sinerp.f @@ -32,7 +32,7 @@ subroutine sinerp(abd,ld4,nk,p1ip,p2ip,ldnk,flag) wjm2(1)=0d0 wjm2(2)=0d0 wjm1(1)=0d0 - do 100 i=1,nk + do i=1,nk j=nk-i+1 c0 = 1d0/abd(4,j) if(j.le.nk-3)then @@ -64,21 +64,21 @@ subroutine sinerp(abd,ld4,nk,p1ip,p2ip,ldnk,flag) wjm2(1)=wjm1(1) wjm2(2)=p1ip(3,j) wjm1(1)=p1ip(4,j) - 100 continue + end do if(flag.ne.0) then C ____ Pass 2 _____ Compute p2ip [never from R's code!] - do 120 i=1,nk + do i=1,nk j=nk-i+1 C for(k=1;k<=4 & j+k-1<=nk;k=k+1) { p2ip(.) = .. }: do k=1,4 if(j+k-1 .gt. nk) goto 120 p2ip(j,j+k-1) = p1ip(5-k,j) end do - 120 continue + 120 end do - do 170 i=1,nk + do i=1,nk j=nk-i+1 c for(k=j-4;k>=1;k=k-1){ if(j-4 .ge. 1) then @@ -91,7 +91,7 @@ subroutine sinerp(abd,ld4,nk,p1ip,p2ip,ldnk,flag) & c3*p2ip(k+1,j) ) end do endif - 170 continue + end do endif return end diff --git a/src/library/stats/src/stl.f b/src/library/stats/src/stl.f index 83d99b4589b..f3dc9eb9b98 100644 --- a/src/library/stats/src/stl.f +++ b/src/library/stats/src/stl.f @@ -30,9 +30,9 @@ subroutine stl(y,n,np,ns,nt,nl, isdeg,itdeg,ildeg, logical userw userw = .false. - do 1 i = 1,n + do i = 1,n trend(i) = 0.d0 - 1 continue + end do c the three spans must be at least three and odd: newns = max0(3,ns) newnt = max0(3,nt) @@ -51,9 +51,9 @@ subroutine stl(y,n,np,ns,nt,nl, isdeg,itdeg,ildeg, k = k+1 if(k .gt. no) goto 10 - do 3 i = 1,n + do i = 1,n work(i,1) = trend(i)+season(i) - 3 continue + end do call stlrwt(y,n,work(1,1),rw) userw = .true. goto 100 @@ -89,11 +89,11 @@ subroutine stless(y,n,len,ideg,njump,userw,rw,ys,res) if(len .ge. n) then nleft = 1 nright = n - do 20 i = 1,n,newnj + do i = 1,n,newnj call stlest(y,n,len,ideg,dble(i),ys(i),nleft,nright,res, & userw,rw,ok) if(.not. ok) ys(i) = y(i) - 20 continue + end do else @@ -101,7 +101,7 @@ subroutine stless(y,n,len,ideg,njump,userw,rw,ys,res) nsh = (len+1)/2 nleft = 1 nright = len - do 30 i = 1,n + do i = 1,n if(i .gt. nsh .and. nright .ne. n) then nleft = nleft+1 nright = nright+1 @@ -109,10 +109,10 @@ subroutine stless(y,n,len,ideg,njump,userw,rw,ys,res) call stlest(y,n,len,ideg,dble(i),ys(i),nleft,nright,res, & userw,rw,ok) if(.not. ok) ys(i) = y(i) - 30 continue + end do else nsh = (len+1)/2 - do 40 i = 1,n,newnj + do i = 1,n,newnj if(i .lt. nsh) then nleft = 1 nright = len @@ -127,19 +127,19 @@ subroutine stless(y,n,len,ideg,njump,userw,rw,ys,res) call stlest(y,n,len,ideg,dble(i),ys(i),nleft,nright,res, & userw,rw,ok) if(.not. ok) ys(i) = y(i) - 40 continue + end do endif endif if(newnj .ne. 1) then - do 45 i = 1,n-newnj,newnj + do i = 1,n-newnj,newnj delta = (ys(i+newnj)-ys(i))/dble(newnj) - do 47 j = i+1,i+newnj-1 + do j = i+1,i+newnj-1 ys(j) = ys(i)+delta*dble(j-i) - 47 continue - 45 continue + end do + end do k = ((n-1)/newnj)*newnj+1 if(k .ne. n) then @@ -149,9 +149,9 @@ subroutine stless(y,n,len,ideg,njump,userw,rw,ys,res) if(k .ne. n-1) then delta = (ys(n)-ys(k))/dble(n-k) - do 55 j = k+1,n-1 + do j = k+1,n-1 ys(j) = ys(k)+delta*dble(j-k) - 55 continue + end do endif endif endif @@ -176,7 +176,7 @@ subroutine stlest(y,n,len,ideg,xs,ys,nleft,nright,w, h9 = 0.999d0*h h1 = 0.001d0*h a = 0.d0 - do 60 j = nleft,nright + do j = nleft,nright r = abs(dble(j)-xs) if(r .le. h9) then if(r .le. h1) then @@ -189,36 +189,36 @@ subroutine stlest(y,n,len,ideg,xs,ys,nleft,nright,w, else w(j) = 0.d0 endif - 60 continue + end do if(a .le. 0.d0) then ok = .false. else ok = .true. - do 69 j = nleft,nright + do j = nleft,nright w(j) = w(j)/a - 69 continue + end do if((h .gt. 0.d0) .and. (ideg .gt. 0)) then a = 0.d0 - do 73 j = nleft,nright + do j = nleft,nright a = a+w(j)*dble(j) - 73 continue + end do b = xs-a c = 0.d0 - do 75 j = nleft,nright + do j = nleft,nright c = c+w(j)*(dble(j)-a)**2 - 75 continue + end do if(sqrt(c) .gt. 0.001d0*range) then b = b/c - do 79 j = nleft,nright + do j = nleft,nright w(j) = w(j)*(b*(dble(j)-a)+1.0d0) - 79 continue + end do endif endif ys = 0.d0 - do 81 j = nleft,nright + do j = nleft,nright ys = ys+w(j)*y(j) - 81 continue + end do endif return @@ -251,19 +251,19 @@ subroutine stlma(x, n, len, ave) newn = n-len+1 flen = dble(len) v = 0.d0 - do 3 i = 1,len + do i = 1,len v = v+x(i) - 3 continue + end do ave(1) = v/flen if(newn .gt. 1) then k = len m = 0 - do 7 j = 2, newn + do j = 2, newn k = k+1 m = m+1 v = v-x(m)+x(k) ave(j) = v/flen - 7 continue + end do endif return end @@ -280,24 +280,24 @@ subroutine stlstp(y,n,np,ns,nt,nl,isdeg,itdeg,ildeg,nsjump, c Var integer i,j - do 80 j = 1,ni - do 1 i = 1,n + do j = 1,ni + do i = 1,n work(i,1) = y(i)-trend(i) - 1 continue + end do call stlss(work(1,1),n,np,ns,isdeg,nsjump,userw,rw,work(1,2), & work(1,3),work(1,4),work(1,5),season) call stlfts(work(1,2),n+2*np,np,work(1,3),work(1,1)) call stless(work(1,3),n,nl,ildeg,nljump,.false.,work(1,4), & work(1,1),work(1,5)) - do 3 i = 1,n + do i = 1,n season(i) = work(np+i,2)-work(i,1) - 3 continue - do 5 i = 1,n + end do + do i = 1,n work(i,1) = y(i)-season(i) - 5 continue + end do call stless(work(1,1),n,nt,itdeg,ntjump,userw,rw,trend, & work(1,3)) - 80 continue + end do return end @@ -314,9 +314,9 @@ subroutine stlrwt(y,n,fit,rw) integer mid(2), i double precision cmad, c9, c1, r - do 7 i = 1,n + do i = 1,n rw(i) = abs(y(i)-fit(i)) - 7 continue + end do mid(1) = n/2+1 mid(2) = n-mid(1)+1 call psort(rw,n,mid,2) @@ -324,7 +324,7 @@ subroutine stlrwt(y,n,fit,rw) c = 6 * MAD c9 = 0.999d0*cmad c1 = 0.001d0*cmad - do 10 i = 1,n + do i = 1,n r = abs(y(i)-fit(i)) if(r .le. c1) then rw(i) = 1.d0 @@ -333,7 +333,7 @@ subroutine stlrwt(y,n,fit,rw) else rw(i) = 0.d0 endif - 10 continue + end do return end @@ -355,15 +355,15 @@ subroutine stlss(y,n,np,ns,isdeg,nsjump,userw,rw,season, if(np .lt. 1) return - do 200 j = 1, np + do j = 1, np k = (n-j)/np+1 - do 10 i = 1,k + do i = 1,k work1(i) = y((i-1)*np+j) - 10 continue + end do if(userw) then - do 12 i = 1,k + do i = 1,k work3(i) = rw((i-1)*np+j) - 12 continue + end do endif call stless(work1,k,ns,isdeg,nsjump,userw,work3,work2(2),work4) xs = 0 @@ -376,11 +376,11 @@ subroutine stlss(y,n,np,ns,isdeg,nsjump,userw,rw,season, call stlest(work1,k,ns,isdeg,xs,work2(k+2),nleft,k,work4, & userw,work3,ok) if(.not. ok) work2(k+2) = work2(k+1) - do 18 m = 1,k+2 + do m = 1,k+2 season((m-1)*np+j) = work2(m) - 18 continue + end do - 200 continue + end do return end @@ -420,9 +420,9 @@ subroutine stlez(y, n, np, ns, isdeg, itdeg, robust, no, rw, nsjump = max0(1,int(float(newns)/10 + 0.9)) ntjump = max0(1,int(float(nt)/10 + 0.9)) nljump = max0(1,int(float(nl)/10 + 0.9)) - do 2 i = 1,n + do i = 1,n trend(i) = 0.d0 - 2 continue + end do call stlstp(y,n,newnp,newns,nt,nl,isdeg,itdeg,ildeg,nsjump, & ntjump,nljump,ni,.false.,rw,season,trend,work) @@ -431,11 +431,11 @@ subroutine stlez(y, n, np, ns, isdeg, itdeg, robust, no, rw, j=1 C Loop --- 15 robustness iterations 100 if(j .le. 15) then - do 35 i = 1,n + do i = 1,n work(i,6) = season(i) work(i,7) = trend(i) work(i,1) = trend(i)+season(i) - 35 continue + end do call stlrwt(y,n,work(1,1),rw) call stlstp(y, n, newnp, newns, nt,nl, isdeg,itdeg,ildeg, & nsjump,ntjump,nljump, ni, .true., @@ -447,7 +447,7 @@ subroutine stlez(y, n, np, ns, isdeg, itdeg, robust, no, rw, mint = work(1,7) maxds = abs(work(1,6) - season(1)) maxdt = abs(work(1,7) - trend(1)) - do 137 i = 2,n + do i = 2,n if(maxs .lt. work(i,6)) maxs = work(i,6) if(maxt .lt. work(i,7)) maxt = work(i,7) if(mins .gt. work(i,6)) mins = work(i,6) @@ -456,7 +456,7 @@ subroutine stlez(y, n, np, ns, isdeg, itdeg, robust, no, rw, dift = abs(work(i,7) - trend(i)) if(maxds .lt. difs) maxds = difs if(maxdt .lt. dift) maxdt = dift - 137 continue + end do if((maxds/(maxs-mins) .lt. 0.01d0) .and. & (maxdt/(maxt-mint) .lt. 0.01d0)) goto 300 continue @@ -469,9 +469,9 @@ subroutine stlez(y, n, np, ns, isdeg, itdeg, robust, no, rw, else c .not. robust - do 150 i = 1,n + do i = 1,n rw(i) = 1.0d0 - 150 continue + end do endif return From f23d3683a3219c58e8c78b86366e838561331743 Mon Sep 17 00:00:00 2001 From: ripley Date: Wed, 15 May 2024 06:04:09 +0000 Subject: [PATCH 056/546] do..end do git-svn-id: https://svn.r-project.org/R/trunk@86554 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/stats/src/bvalue.f | 8 ++++---- src/library/stats/src/stl.f | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/library/stats/src/bvalue.f b/src/library/stats/src/bvalue.f index 5d65980ff73..cdb9d1b4c9c 100644 --- a/src/library/stats/src/bvalue.f +++ b/src/library/stats/src/bvalue.f @@ -127,12 +127,12 @@ double precision function bvalue(t,bcoef,n,k,x,jderiv) jcmax = k nmi = n - i if (nmi .ge. 0) then - do 19 j=1,km1 + do j=1,km1 C the following if() happens; e.g. in pp <- predict(cars.spl, xx) c - if( (i+j) .gt. lent) write(6,9911) i+j,lent c - 9911 format(' i+j, lent ',2(i6,1x)) dp(j) = t(i+j) - x - 19 continue + end do else jcmax = k + nmi do j=1,jcmax @@ -145,9 +145,9 @@ double precision function bvalue(t,bcoef,n,k,x,jderiv) endif c - do 21 jc=jcmin,jcmax + do jc=jcmin,jcmax aj(jc) = bcoef(imk + jc) - 21 continue + end do c c *** difference the coefficients jderiv times. if (jderiv .ge. 1) then diff --git a/src/library/stats/src/stl.f b/src/library/stats/src/stl.f index f3dc9eb9b98..1e314c19205 100644 --- a/src/library/stats/src/stl.f +++ b/src/library/stats/src/stl.f @@ -62,9 +62,9 @@ subroutine stl(y,n,np,ns,nt,nl, isdeg,itdeg,ildeg, c robustness weights when there were no robustness iterations: if(no .le. 0) then - do 15 i = 1,n + do i = 1,n rw(i) = 1.d0 - 15 continue + end do endif return end From 3d881c07114051b64940554ec8beaf4e5d78c0e2 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 15 May 2024 11:59:37 +0000 Subject: [PATCH 057/546] SET_ENCLOS now silently converts R_NilValue parent to R_EmptyEnv. git-svn-id: https://svn.r-project.org/R/trunk@86555 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/memory.c b/src/main/memory.c index 5a2ab5e053f..78b0519c942 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4497,6 +4497,9 @@ void (SET_FRAME)(SEXP x, SEXP v) { FIX_REFCNT(x, FRAME(x), v); CHECK_OLD_TO_NEW( void (SET_ENCLOS)(SEXP x, SEXP v) { + if (v == R_NilValue) + /* mainly to handle unserializing old files */ + v = R_EmptyEnv; if (TYPEOF(v) != ENVSXP) error(_("'parent' is not an environment")); for (SEXP e = v; e != R_NilValue; e = ENCLOS(e)) From 434f2ef80ec987f2ed081bc9b88fcf1d64f51396 Mon Sep 17 00:00:00 2001 From: smeyer Date: Wed, 15 May 2024 18:52:53 +0000 Subject: [PATCH 058/546] report (all) unstated dependencies when offline (PR#17978) git-svn-id: https://svn.r-project.org/R/trunk@86556 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index 8fbe19a3235..3e9dfe016bf 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -6659,6 +6659,7 @@ function(dir, testdir, lib.loc = NULL) ## checking. repos <- .get_standard_repository_URLs() available <- utils::available.packages(repos = repos) + if (nrow(available)) # cannot filter when offline res[1L : 3L] <- lapply(bad, intersect, available[, "Package"]) } res From c224518baed40e28c7d53d79cf0ff393c0bcd325 Mon Sep 17 00:00:00 2001 From: smeyer Date: Thu, 16 May 2024 10:53:53 +0000 Subject: [PATCH 059/546] cannot tangle without engine git-svn-id: https://svn.r-project.org/R/trunk@86557 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 29d521bb016..84d15794138 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -6408,8 +6408,8 @@ add_dummies <- function(dir, Log) summaryLog(Log) do_exit(1L) } else if (length(res$required_for_checking_but_not_installed)) { - warningLog(Log, "Skipping vignette re-building") - do_build_vignettes <<- FALSE + warningLog(Log, "Cannot process vignettes") + do_vignettes <<- FALSE printLog0(Log, paste(out, collapse = "\n")) } else { if( length(res[["orphaned"]]) || length(res[["orphaned1"]]) ) From ef9652cd170acf8c43ca762115b10dd136e56771 Mon Sep 17 00:00:00 2001 From: ripley Date: Thu, 16 May 2024 14:46:47 +0000 Subject: [PATCH 060/546] improve error messages git-svn-id: https://svn.r-project.org/R/trunk@86558 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/Vignettes.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/Vignettes.R b/src/library/tools/R/Vignettes.R index ef013982db4..40a1aec6d9c 100644 --- a/src/library/tools/R/Vignettes.R +++ b/src/library/tools/R/Vignettes.R @@ -1195,8 +1195,10 @@ vignetteEngine <- local({ pkgs <- sapply(result, function(engine) engine$package) keep <- is.element(pkgs, package) if (!any(keep)) { - stop(gettextf("None of packages %s have registered vignette engines", - paste(sQuote(package), collapse = ", ")), + msg <-ngettext(length(package), + "Package %s does not have a registered vignette engine", + "None of packages %s have registered vignette engines") + stop(sprintf(msg, paste(sQuote(package), collapse = ", ")), domain = NA) } result <- result[keep] From f713b01cf171c07b2c501b862fddf94f8fcd4034 Mon Sep 17 00:00:00 2001 From: ripley Date: Thu, 16 May 2024 15:16:46 +0000 Subject: [PATCH 061/546] workaround for packages with VignetteBuilder but no vignettes git-svn-id: https://svn.r-project.org/R/trunk@86559 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/Vignettes.R | 1 + src/library/tools/R/check.R | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/library/tools/R/Vignettes.R b/src/library/tools/R/Vignettes.R index 40a1aec6d9c..36c008dc93f 100644 --- a/src/library/tools/R/Vignettes.R +++ b/src/library/tools/R/Vignettes.R @@ -1187,6 +1187,7 @@ vignetteEngine <- local({ key } + ## FIXME: return a character vector, not stop here. getEngine <- function(name, package) { if (missing(name)) { result <- as.list(registry) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 84d15794138..ffdfa03ded2 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -686,14 +686,15 @@ add_dummies <- function(dir, Log) if (!is.na(buildPkgs)) { buildPkgs <- unlist(strsplit(buildPkgs, ",")) buildPkgs <- unique(gsub('[[:space:]]', '', buildPkgs)) - engineList <- vignetteEngine(package = buildPkgs) - for(nm in names(engineList)) { - pattern <- engineList[[nm]]$pattern - sources <- c(sources, - setdiff(list.files(file.path("inst", "doc"), - pattern = pattern), - list.files("vignettes", pattern = pattern))) - } + engineList <- try(vignetteEngine(package = buildPkgs)) + if (!inherits(engineList, "try-catch")) + for(nm in names(engineList)) { + pattern <- engineList[[nm]]$pattern + sources <- c(sources, + setdiff(list.files(file.path("inst", "doc"), + pattern = pattern), + list.files("vignettes", pattern = pattern))) + } } sources <- unique(sources) if(length(sources)) { From 6c0c9181f52f154a15dd668338e9fcc92fdcdae3 Mon Sep 17 00:00:00 2001 From: ripley Date: Fri, 17 May 2024 05:38:39 +0000 Subject: [PATCH 062/546] reort on packages with VignetteDepends but no vignettes git-svn-id: https://svn.r-project.org/R/trunk@86560 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 12 +++++++++++- src/library/tools/R/check.R | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index 3e9dfe016bf..65056add6e0 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -3253,6 +3253,8 @@ function(dir, force_suggests = TRUE, check_incoming = FALSE, bad2 <- setdiff(bad2, bad) if(length(bad2)) bad_depends$required_for_checking_but_not_installed <- bad2 + if (length(VB) && !dir.exists(file.path(dir, "vignettes"))) + bad_depends$no_vignettes <- VB } } ## FIXME: is this still needed now we do dependency analysis? @@ -3449,7 +3451,15 @@ function(x, ...) "\\VignetteDepends{}")), "") }, - if(length(bad <- x$missing_rdmacros_depends)) { + if(length(bad <- x$no_vignettes)) { + c(if(length(bad) > 1L) { + c("Vignette dependencies required without any vignettes:", .pretty_format(bad)) + } else { + sprintf("Vignette dependency required without any vignettes:: %s", sQuote(bad)) + }, + "") + }, + if(length(bad <- x$missing_vignette_depends)) { c(if(length(bad) > 1L) .pretty_format2("RdMacros packages not required:", bad) else diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index ffdfa03ded2..8173f7d3c82 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -6394,6 +6394,7 @@ add_dummies <- function(dir, Log) "hdOnly", "orphaned2", "orphaned", "orphaned1", "required_for_checking_but_not_installed", + "no_vignettes", if(!check_incoming) "bad_engine") if(!all(names(res) %in% allowed)) { errorLog(Log) From 45a236c0335ae4a38e978ad0db4eb297e94a87b3 Mon Sep 17 00:00:00 2001 From: ripley Date: Fri, 17 May 2024 07:15:26 +0000 Subject: [PATCH 063/546] getEngine returns character() with a warning not an error git-svn-id: https://svn.r-project.org/R/trunk@86561 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/Vignettes.R | 8 +++++--- src/library/tools/R/check.R | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/library/tools/R/Vignettes.R b/src/library/tools/R/Vignettes.R index 36c008dc93f..d77eebae0fb 100644 --- a/src/library/tools/R/Vignettes.R +++ b/src/library/tools/R/Vignettes.R @@ -386,7 +386,7 @@ function(package, dir, subdirs = NULL, lib.loc = NULL, output = FALSE, # Locate all vignette files buildPkgs <- loadVignetteBuilder(dir, mustwork = FALSE, lib.loc = lib.loc) - engineList <- vignetteEngine(package = buildPkgs) + engineList <- vignetteEngine(package = buildPkgs) # could be character() docs <- names <- engines <- patterns <- character() allFiles <- list.files(docdir, all.files = FALSE, full.names = TRUE) @@ -1196,11 +1196,13 @@ vignetteEngine <- local({ pkgs <- sapply(result, function(engine) engine$package) keep <- is.element(pkgs, package) if (!any(keep)) { + ## was stop() in R 4.4.0 msg <-ngettext(length(package), "Package %s does not have a registered vignette engine", "None of packages %s have registered vignette engines") - stop(sprintf(msg, paste(sQuote(package), collapse = ", ")), - domain = NA) + warning(sprintf(msg, paste(sQuote(package), collapse = ", ")), + domain = NA, call. = FALSE) + ## return character() below } result <- result[keep] pkgs <- pkgs[keep] diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 8173f7d3c82..4f01a3286ab 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -676,6 +676,7 @@ add_dummies <- function(dir, Log) } if (dir.exists("inst/doc") && do_install) check_doc_contents() if (dir.exists("vignettes")) check_vign_contents(ignore_vignettes) + ## FIXME: remove this long-obsolete check if (!ignore_vignettes) { if (dir.exists("inst/doc") && !dir.exists("vignettes")) { pattern <- vignetteEngine("Sweave")$pattern @@ -686,15 +687,15 @@ add_dummies <- function(dir, Log) if (!is.na(buildPkgs)) { buildPkgs <- unlist(strsplit(buildPkgs, ",")) buildPkgs <- unique(gsub('[[:space:]]', '', buildPkgs)) - engineList <- try(vignetteEngine(package = buildPkgs)) - if (!inherits(engineList, "try-catch")) - for(nm in names(engineList)) { - pattern <- engineList[[nm]]$pattern - sources <- c(sources, - setdiff(list.files(file.path("inst", "doc"), - pattern = pattern), - list.files("vignettes", pattern = pattern))) - } + ## next could be character() + engineList <- vignetteEngine(package = buildPkgs) + for(nm in names(engineList)) { + pattern <- engineList[[nm]]$pattern + sources <- c(sources, + setdiff(list.files(file.path("inst", "doc"), + pattern = pattern), + list.files("vignettes", pattern = pattern))) + } } sources <- unique(sources) if(length(sources)) { From 912ccb951602e1075d0a9e93873e046e8812d691 Mon Sep 17 00:00:00 2001 From: ripley Date: Fri, 17 May 2024 08:18:30 +0000 Subject: [PATCH 064/546] document check fixup, revert unintended change git-svn-id: https://svn.r-project.org/R/trunk@86562 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 5 +++++ src/library/tools/R/QC.R | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index e3d3b67796e..34fd0de093f 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -130,6 +130,11 @@ \item Package \pkg{tools}' \code{toTitleCase(ch0)} now returns \code{character(0)} when \code{ch0} is of zero length; fixing \PR{18724}, reported by David Hugh Jones. + + \item \command{R CMD check} is no longer broken (without a check + result and no explanation in \file{00check.log}) for a package + which declares an invalid \code{VignetteBuilder} in + \file{DESCRIPTION} but has no vignettes. } } } diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index 65056add6e0..59dd1c20d44 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -3459,7 +3459,7 @@ function(x, ...) }, "") }, - if(length(bad <- x$missing_vignette_depends)) { + if(length(bad <- x$missing_rdmacros_depends)) { c(if(length(bad) > 1L) .pretty_format2("RdMacros packages not required:", bad) else From 85bfa2524f6230289f6c41d7991c48b39ba17a83 Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 17 May 2024 16:38:33 +0000 Subject: [PATCH 065/546] add prI() example; option "scipen" git-svn-id: https://svn.r-project.org/R/trunk@86565 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/print.default.Rd | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/library/base/man/print.default.Rd b/src/library/base/man/print.default.Rd index 33ba721a6bc..08df5fd9a6b 100644 --- a/src/library/base/man/print.default.Rd +++ b/src/library/base/man/print.default.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/print.default.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2020 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{print.default} @@ -61,6 +61,12 @@ least one element has a non-zero final digit. Decimal points are only included if at least one decimal place is selected. + You can suppress \dQuote{exponential} / \code{scientific} notation in + printing of numbers (atomic vectors \code{x}), + via \code{format(., scientific=FALSE)}, see the \code{prI()} example + below, or also by increasing global option \code{scipen}, e.g., + \code{\link{options}(scipen = 12)}. + Attributes are printed respecting their class(es), using the values of \code{digits} to \code{print.default}, but using the default values (for the methods called) of the other arguments. @@ -153,5 +159,9 @@ M <- cbind(I = 1, matrix(1:10000, ncol = 10, dimnames = list(NULL, LETTERS[1:10]))) utils::head(M) # makes more sense than print(M, max = 1000) # prints 90 rows and a message about omitting 910 + +(x <- 2^seq(-8, 30, by=1/4)) # auto-prints; by default all in "exponential" format +prI <- function(x) noquote(format(x, scientific = FALSE)) +prI(x) # prints more "nicely" (using a bit more space) } \keyword{print} From f409a0bf5eef2c4b63a9ec38e9a7d348f1d835a0 Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 20 May 2024 14:31:20 +0000 Subject: [PATCH 066/546] updates for macOS git-svn-id: https://svn.r-project.org/R/trunk@86567 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 2812065147a..26058c7b476 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -5304,14 +5304,25 @@ PKG_CONFIG_PATH=$LOCAL/lib/pkgconfig:/usr/lib/pkgconfig further flags are desirable in @file{config.site}: @example CFLAGS="-falign-functions=8 -g -O2" +@end example +@noindent +is needed to inter-work with @command{gfortran} without segfaulting in +some packages. Some builds of @command{gfortran} have targetted the +current version of macOS (unlike @command{clang}), causing linker +warnings) to avoid these use +@example +FFLAGS="-g -O2 -mmacosx-version-min=11.0" +FCFLAGS="-g -O2 -mmacosx-version-min=11.0" +@end example +@noindent +or perhaps +@example FFLAGS="-g -O2 -mmacos-version-min=11.0" FCFLAGS="-g -O2 -mmacos-version-min=11.0" @end example @noindent -(the first flag in @code{CFLAGS} is needed to inter-work with the -@command{gfortran} without segfaulting in some packages, and some builds -of @command{gfortran} have targetted the current version of macOS (unlike -@command{clang}, causing linker warnings). +where @code{11.0} can be replaced by @code{12.0}, @code{13.0} or +@code{14.0} for macOS 12.x, 13.x and 14.x. To install packages using compiled code one needs the Command Line Tools (or @I{Xcode}) and appropriate compilers, e.g.@: the C/C++ compilers from @@ -5390,7 +5401,7 @@ contains the correct information. @node Fortran compilers, Cairo graphics, Prerequisites, macOS @subsection Fortran compiler -There is `universal' (Intel and @code{arm64}) build of +There is a `universal' (Intel and @code{arm64}) build of @command{gfortran} 12.2 at @uref{https://mac.r-project.org/tools/gfortran-12.2-universal.pkg}. This installs into @file{/opt/gfortran}. @@ -5403,11 +5414,12 @@ symlink is broken, the driver will issue a warning and use @code{xcrun is used when using @command{gfortran} to link, so not when building @R{} but when installing a few packages.) -A build of @command{gfortran} 13.2 for @code{arm64} macOS 14 is +Builds of @command{gfortran} 13.2 and 14.1 for @code{arm64} macOS 14 are available at -@uref{https://github.com/fxcoudert/gfortran-for-macOS/releases}. -This can be built for Intel and older OSes from the sources at -@uref{https://github.com/iains/gcc-13-branch/}. +@uref{https://github.com/fxcoudert/gfortran-for-macOS/releases}. These +can be built for Intel and older OSes from the sources at +@uref{https://github.com/iains/gcc-13-branch/} and +@code{gcc-14-branch/}. @node Cairo graphics, Other C/C++ compilers, Fortran compilers, macOS @subsection Cairo graphics From b15e1b534b230cb5f3f036e697ba22fbee4b0a20 Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 20 May 2024 14:31:45 +0000 Subject: [PATCH 067/546] comment out check for vignette sources in inst/doc git-svn-id: https://svn.r-project.org/R/trunk@86568 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 68 ++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 4f01a3286ab..a8717f8e749 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -676,40 +676,40 @@ add_dummies <- function(dir, Log) } if (dir.exists("inst/doc") && do_install) check_doc_contents() if (dir.exists("vignettes")) check_vign_contents(ignore_vignettes) - ## FIXME: remove this long-obsolete check - if (!ignore_vignettes) { - if (dir.exists("inst/doc") && !dir.exists("vignettes")) { - pattern <- vignetteEngine("Sweave")$pattern - sources <- setdiff(list.files(file.path("inst", "doc"), - pattern = pattern), - list.files("vignettes", pattern = pattern)) - buildPkgs <- .get_package_metadata(".")["VignetteBuilder"] - if (!is.na(buildPkgs)) { - buildPkgs <- unlist(strsplit(buildPkgs, ",")) - buildPkgs <- unique(gsub('[[:space:]]', '', buildPkgs)) - ## next could be character() - engineList <- vignetteEngine(package = buildPkgs) - for(nm in names(engineList)) { - pattern <- engineList[[nm]]$pattern - sources <- c(sources, - setdiff(list.files(file.path("inst", "doc"), - pattern = pattern), - list.files("vignettes", pattern = pattern))) - } - } - sources <- unique(sources) - if(length(sources)) { - checkingLog(Log, "for old-style vignette sources") - msg <- c("Vignette sources only in 'inst/doc':", - strwrap(paste(sQuote(sources), collapse = ", "), - indent = 2L, exdent = 2L), - "A 'vignettes' directory is required as from R 3.1.0", - "and these will not be indexed nor checked") - ## warning or error eventually - noteLog(Log, paste(msg, collapse = "\n")) - } - } - } + ## R 4.5.0: remove this long-obsolete check + ## if (!ignore_vignettes) { + ## if (dir.exists("inst/doc") && !dir.exists("vignettes")) { + ## pattern <- vignetteEngine("Sweave")$pattern + ## sources <- setdiff(list.files(file.path("inst", "doc"), + ## pattern = pattern), + ## list.files("vignettes", pattern = pattern)) + ## buildPkgs <- .get_package_metadata(".")["VignetteBuilder"] + ## if (!is.na(buildPkgs)) { + ## buildPkgs <- unlist(strsplit(buildPkgs, ",")) + ## buildPkgs <- unique(gsub('[[:space:]]', '', buildPkgs)) + ## ## next could be character() + ## engineList <- vignetteEngine(package = buildPkgs) + ## for(nm in names(engineList)) { + ## pattern <- engineList[[nm]]$pattern + ## sources <- c(sources, + ## setdiff(list.files(file.path("inst", "doc"), + ## pattern = pattern), + ## list.files("vignettes", pattern = pattern))) + ## } + ## } + ## sources <- unique(sources) + ## if(length(sources)) { + ## checkingLog(Log, "for old-style vignette sources") + ## msg <- c("Vignette sources only in 'inst/doc':", + ## strwrap(paste(sQuote(sources), collapse = ", "), + ## indent = 2L, exdent = 2L), + ## "A 'vignettes' directory is required as from R 3.1.0", + ## "and these will not be indexed nor checked") + ## ## warning or error eventually + ## noteLog(Log, paste(msg, collapse = "\n")) + ## } + ## } + ## } setwd(pkgoutdir) From be6efee4f0ea5927a313948dcbd0ae005f295278 Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 21 May 2024 08:31:31 +0000 Subject: [PATCH 068/546] Avoid writing superfluous null byte into commands file (reported in PR#18133), tweak. git-svn-id: https://svn.r-project.org/R/trunk@86570 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/system.c | 5 +++-- src/unix/system.c | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gnuwin32/system.c b/src/gnuwin32/system.c index a3592a01a37..659cc49ef15 100644 --- a/src/gnuwin32/system.c +++ b/src/gnuwin32/system.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1997--2023 The R Core Team + * Copyright (C) 1997--2024 The R Core Team * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka * * This program is free software; you can redistribute it and/or modify @@ -1310,7 +1310,8 @@ int cmdlineoptions(int ac, char **av) if(!ifp) R_Suicide(_("creation of tmpfile failed -- set TMPDIR suitably?")); /* Unix does unlink(ifile) here, but Windows cannot delete open files */ } - fwrite(cmdlines, strlen(cmdlines)+1, 1, ifp); + if (fwrite(cmdlines, 1, strlen(cmdlines), ifp) != strlen(cmdlines)) + R_Suicide("fwrite error in cmdlineoptions"); fflush(ifp); rewind(ifp); } diff --git a/src/unix/system.c b/src/unix/system.c index ff5751d708f..4ad7971dfda 100644 --- a/src/unix/system.c +++ b/src/unix/system.c @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 1997--2023 The R Core Team + * Copyright (C) 1997--2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -488,8 +488,8 @@ int Rf_initialize_R(int ac, char **av) ifp = fdopen(ifd, "w+"); if(!ifp) R_Suicide(_("creating temporary file for '-e' failed")); unlink(ifile); - res = fwrite(cmdlines, strlen(cmdlines)+1, 1, ifp); - if(res != 1) R_Suicide("fwrite error in initialize_R"); + res = fwrite(cmdlines, 1, strlen(cmdlines), ifp); + if(res != strlen(cmdlines)) R_Suicide("fwrite error in initialize_R"); fflush(ifp); rewind(ifp); } From aabc703117533ef276b65ec717a77ab906411065 Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 21 May 2024 15:49:26 +0000 Subject: [PATCH 069/546] report --timings even in the case of error git-svn-id: https://svn.r-project.org/R/trunk@86572 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 130 +++++++++++++++++++----------------- src/library/tools/R/check.R | 21 ++++++ 2 files changed, 88 insertions(+), 63 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 26058c7b476..84cf1f9b3c4 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -234,9 +234,9 @@ platforms including @samp{@var{cpu}-*-linux-gnu} for the @c Actually, see https://packages.debian.org/unstable/math/r-base-core as @c the build daemon is not used for all platforms; note also that Debian @c has x86_64 <=> amd64, ix86 <=> i386. -@samp{x86_64-@/apple-@/darwin} and @samp{aarch64-@/apple-@/darwin}@footnote{aka `Apple Silicon', known to -some as @samp{arm64-@/apple-@/darwin}.} as well as perhaps (it is +some as @samp{arm64-@/apple-@/darwin}.} and +@samp{x86_64-@/apple-@/darwin} as well as perhaps (it is tested less frequently on these platforms) @samp{x86_64-@/*-@/freebsd}, @samp{x86_64-@/*-@/openbsd} and @samp{powerpc-@/ibm-@/aix6*} @@ -1580,22 +1580,22 @@ Remember that @LaTeX{} needs to be on the path. @c The front page of a @acronym{CRAN} site has a link `Download R for (Mac) OS X' which takes you to a new page. Two files are offered for download, -@file{R-@value{VERSIONno}-arm64.pkg} and @file{R-@value{VERSIONno}.pkg}. +@file{R-@value{VERSIONno}-arm64.pkg} and @file{R-@value{VERSIONno}-x86_64.pkg}. Both are for macOS 11 or later (@I{Big Sur}, @I{Monterey}, @I{Ventura}, @I{Sonoma}, @dots{}). -The first is for `Apple Silicon' (@emph{aka} `M1', `M2' or 'M3') Macs, the +The first is for `Apple Silicon' (@emph{aka} `M1', `M2', @dots{}) Macs, the second for older Macs with an @cputype{x86_64} (Intel) CPU. -Package @file{R-@value{VERSIONno}.pkg} also be installed on `Apple -Silicon' CPUs using `Rosetta' emulation@footnote{You may be asked to -install Rosetta at first use -- -@url{https://support.apple.com/en-us/102527} -- which may need -administrator privileges.}, but the native build is preferred. It is a -little faster (and for some tasks, considerably so) but may give -different numerical results from the more common @cputype{x86_64} -platforms (on Windows, Linux, @dots{} as well as macOS) as ARM hardware -lacks extended-precision floating-point operations. +@c Package @file{R-@value{VERSIONno}.pkg} also be installed on `Apple +@c Silicon' CPUs using `Rosetta' emulation@footnote{You may be asked to +@c install Rosetta at first use -- +@c @url{https://support.apple.com/en-us/102527} -- which may need +@c administrator privileges.}, but the native build is preferred. It is a +@c little faster (and for some tasks, considerably so) but may give +@c different numerical results from the more common @cputype{x86_64} +@c platforms (on Windows, Linux, @dots{} as well as macOS) as ARM hardware +@c lacks extended-precision floating-point operations. It is important that if you use a binary installer package that your OS is fully updated: look at `Software Update' in 'System Preferences' @@ -1676,18 +1676,17 @@ as on any other Unix-alike: see the next chapter of this manual. There are some small differences which may surprise users of @R{} on other platforms, notably the default location of the personal library directory (under @file{~/Library/R}, e.g.@: -@file{~/Library/R/x86_64/4.2/library}), and that warnings, messages and +@file{~/Library/R/arm64/4.4/library}), and that warnings, messages and other output to @file{stderr} are highlighted in bold. @c https://ryanhomer.github.io/posts/build-openmp-macos-catalina-complete -Those using the @command{zsh} shell (the default for new user accounts -as from Catalina) might find the command @command{R} being masked by the -@command{zsh} builtin @command{r} (which recalls commands). One can use -a full path to @R{} in an alias, or add @code{disable r} to -@file{~/.zshrc}. +Those using the @command{zsh} shell (the default for new user accounts) +might find the command @command{R} being masked by the @command{zsh} +builtin @command{r} (which recalls commands). One can use a full path +to @R{} in an alias, or add @code{disable r} to @file{~/.zshrc}. -If you have installed both installer packages on an @code{arm64} Mac, -the last installed will be used. +@c If you have installed both installer packages on an @code{arm64} Mac, +@c the last installed will be used. @c https://stat.ethz.ch/pipermail/r-sig-mac/2014-October/011131.html It has been reported that running @Rapp{} may fail if no preferences are @@ -1736,11 +1735,11 @@ upright ones. @R{} for macOS consists of two parts: the GUI (@Rapp{}) and the R framework. @I{Un-installation} is as simple as removing those folders -(e.g.@: by dragging them onto the Bin aka Trash). The typical installation will -install the GUI into the @file{/Applications/R.app} folder and the R -framework into the @file{/Library/Frameworks/R.framework} folder. The -links to @file{R} and @file{Rscript} in @file{/usr/local/bin} should -also be removed. +(e.g.@: by dragging them onto the Bin@footnote{Formerly known as the +Trash.}). The typical installation will install the GUI into the +@file{/Applications/R.app} folder and the R framework into the +@file{/Library/Frameworks/R.framework} folder. The links to @file{R} +and @file{Rscript} in @file{/usr/local/bin} should also be removed. If you want to get rid of @R{} more completely using a Terminal, simply run: @@ -1752,9 +1751,9 @@ sudo rm -Rf /Library/Frameworks/R.framework /Applications/R.app \ The installation consists of up to four Apple packages:@footnote{At the time of writing: use @command{pkgutil --pkgs | grep -i org.r-project} to -check.} for the Intel build, @code{org.R-project.x86_64.R.fw.pkg}, -@code{org.R-project.x86_64.R.GUI.pkg}, @code{org.r-project.x86_64.tcltk} -and @code{org.r-project.x86_64.texinfo}. You can use @code{sudo pkgutil +check.} for the `Apple Silicon' build, @code{org.R-project.arm64.R.fw.pkg}, +@code{org.R-project.arm64.R.GUI.pkg}, @code{org.r-project.arm64.tcltk} +and @code{org.r-project.arm64.texinfo}. You can use @code{sudo pkgutil --forget} if you want the Apple Installer to forget about the package without deleting its files (useful for the @R{} framework when installing multiple @R{} versions in parallel), or after you have @@ -1762,17 +1761,17 @@ deleted the files. @strong{NB:} the package names are case-sensitive and the @R{} domain is named inconsistently. Uninstalling the Tcl/Tk and @I{Texinfo} components (which are installed under -@file{/opt/R/x86_64} on a @cputype{x86_64} build and @file{/opt/R/arm64} -for an @cputype{arm64} one) is not as simple. You can list the files +@file{/opt/R/arm64} on a @cputype{arm64} build and @file{/opt/R/x86_64} +for an @cputype{x86_64} one) is not as simple. You can list the files they installed in a Terminal by e.g.@: @example -pkgutil --files org.r-project.x86_64.tcltk -pkgutil --files org.r-project.x86_64.texinfo +pkgutil --files org.r-project.arm64.tcltk +pkgutil --files org.r-project.arm64.texinfo @end example @noindent -(For the `Apple Silicon' build, replace @code{x86_64} by @code{arm64}.) +(For the `Intel build, replace @code{arm64} by @code{x86_64}.) These are paths relative to @file{/}, the root of the file system. @c Maybe too dangerous for naive users. @c file.remove removes empty directories on Unix. @@ -1788,13 +1787,13 @@ These are paths relative to @file{/}, the root of the file system. @c run as the owner of @file{/usr/local}. If you are not compiling @R{} nor installing packages from source you -could remove all of @file{/opt/R/x86_64} or @file{/opt/R/arm64}. +could remove all of @file{/opt/R/arm64} or @file{/opt/R/x86_64}. @node Multiple versions, , Uninstalling under macOS, Installing R under macOS @section Multiple versions The installer will remove any previous version@footnote{More precisely, -of the Apple package of the same name: this means that Intel and ARM +of the Apple package of the same name: this means that ARM and Intel versions can be installed together.} of the @R{} framework which it finds installed. This can be avoided by using @command{pkgutil --forget} (see the previous section). However, note that different @@ -1804,7 +1803,7 @@ versions are installed under different @samp{4.x.y} versions installed for the same @samp{x} and CPU type. -@Rapp{} will always run the `current' version, that is the last +@Rapp{} will always run the `current' version of @R{}, that is the last installed version. @node Running R, Add-on packages, Installing R under macOS, Top @@ -5154,8 +5153,8 @@ there.) @node Prerequisites, Fortran compilers, macOS, macOS @subsection Prerequisites -The Intel components install into @file{/opt/R/x86_64}, the Apple -silicon ones into @file{/opt/R/arm64}. This may not exist@footnote{it +The Apple silicon conmponents install into @file{/opt/R/arm64}, the +Intel ones into @file{/opt/R/x86_64}. That may not exist@footnote{it will if @R{} has been installed from @acronym{CRAN} since @R{} 4.3.0.} so it is simplest to first create the directory and adjust its ownership if desired: for example by @@ -5165,12 +5164,12 @@ sudo mkdir -p /opt/R/arm64 sudo chown -R $USER /opt/R @end example @noindent -Also, add @file{/opt/R/x86_64/bin} or @file{/opt/R/arm64/bin} to your path. +Also, add @file{/opt/R/arm64/bin} or @file{/opt/R/x86_64/bin} to your path. Define an appropriate variable in your Terminal: @example -set LOCAL=/opt/R/x86_64 # Intel set LOCAL=/opt/R/arm64 # Apple Silicon +set LOCAL=/opt/R/x86_64 # Intel @end example @noindent to use the code snippets here. @@ -5211,14 +5210,14 @@ ones are for macOS 10.13--10.15. Or this can be done manually, by for example @example -curl -OL https://mac.r-project.org/bin/darwin20/x86_64/pcre2-10.42-darwin.20-x86_64.tar.xz -sudo tar -xvzf pcre2-10.42-darwin.20-x86_64.tar.gz -C / -curl -OL https://mac.r-project.org/bin/darwin20/x86_64/xz-5.4.2-darwin.20-x86_64.tar.xz -sudo tar -xvzf xz-5.4.2-darwin.20-x86_64.tar.xz -C / +curl -OL https://mac.r-project.org/bin/darwin20/arm64/pcre2-10.42-darwin.20-arm64.tar.xz +sudo tar -xvzf pcre2-10.42-darwin.20-arm64.tar.gz -C / +curl -OL https://mac.r-project.org/bin/darwin20/arm64/xz-5.4.2-darwin.20-arm64.tar.xz +sudo tar -xvzf xz-5.4.2-darwin.20-arm64.tar.xz -C / @end example @noindent -(@command{sudo} is not needed if your account owns @file{/opt/R/x86_64} or -@file{/opt/R/arm64} as appropriate.) +(@command{sudo} is not needed if your account owns @file{/opt/R/arm64} or +@file{/opt/R/x86_64} as appropriate.) Messages like @samp{opt/R/: Can't restore time} should be ignored. @end itemize @@ -5334,12 +5333,17 @@ requirements such as component @command{pkgconfig} (and to set A subversion client can be obtained from @uref{https://mac.r-project.org/tools/}, for example by @example +curl -OL https://mac.r-project.org/tools/subversion-1.14.1-darwin.20-arm64.tar.gz +tar xf subversion-1.14.1-darwin.20-arm64.tar.gz +sudo cp subversion-1.14.1-darwin-20-arm64/svn $LOCAL/bin +@end example +@noindent +or +@example curl -OL https://mac.r-project.org/tools/subversion-1.14.0-darwin15.6.tar.gz tar xf subversion-1.14.0-darwin15.6.tar.gz sudo cp subversion-1.14.0-darwin15.6/svn $LOCAL/bin @end example -@noindent -(There also an @code{arm64} version on that web page.) If building software or installing source packages with @command{cmake} (or a non-Apple @command{make}) for `Apple Silicon' ensure it contains @@ -5390,7 +5394,7 @@ above) or @command{xattr -c} to remove extended attributes. @command{configure} defaults to @option{--with-internal-tzcode} on macOS. The native implementation used to be unusable on earlier versions (with a 32-bit @code{time_t} and/or timezone tables missing -information beyond the 32-bit range). For, e.g.@:, macOS 12.6, option +information beyond the 32-bit range). As from macOS 12.6, option @option{--without-internal-tzcode} can be used to override this and @R{} contains sufficient workarounds (for example, the native code fails to recognize dates with a negative @code{tm_year}, that is dates before @@ -5401,7 +5405,7 @@ contains the correct information. @node Fortran compilers, Cairo graphics, Prerequisites, macOS @subsection Fortran compiler -There is a `universal' (Intel and @code{arm64}) build of +There is a `universal' (@code{arm64} and Intel) build of @command{gfortran} 12.2 at @uref{https://mac.r-project.org/tools/gfortran-12.2-universal.pkg}. This installs into @file{/opt/gfortran}. @@ -5576,8 +5580,8 @@ inconsolata texinfo} .} @pkg{helvetic}, @pkg{inconsolata} and packages needed to check @acronym{CRAN} increased this to about 600MB.} @samp{TeX Live Utility} (available @emph{via} the @I{MacTeX} front page) provides a graphical means to manage @TeX{} packages. These contain -executables which run natively on both @cputype{x86_64} and -@cputype{arm64}. +executables which run natively on both @cputype{arm64} and +@cputype{x86_64}. Checking packages thoroughly requires @I{Ghostscript} (part of the full @I{MacTeX} distribution or separately from @@ -5598,7 +5602,7 @@ installed under @file{/usr/local} and not supersede the system versions. Parallel installation of packages will make use of the utility -@command{timeout} if available. A dual-architecture build can be +@command{timeout} if available. A `universal' build can be downloaded from @uref{https://www.stats.ox.ac.uk/pub/bdr/timeout}: make it executable (@code{chmod 755 timeout}) and put it somewhere on your path. @@ -5744,8 +5748,8 @@ will likely be needed to be run before using Java-using packages. To see what compatible versions of Java are currently installed, run the appropriate one of @example -/usr/libexec/java_home -V -a x86_64 /usr/libexec/java_home -V -a arm64 +/usr/libexec/java_home -V -a x86_64 @end example @noindent If needed, set the environment variable @env{JAVA_HOME} to choose @@ -5762,7 +5766,7 @@ but it may need some help, e.g.@: by setting environment variable @env{JAVA_HOME}. To select a build from @uref{https://adoptium.net, Adoptium} set e.g.@: @example -JAVA_HOME=/Library/Java/JavaVirtualMachines/termurin-17.jdk/Contents/Home +JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home @end example @noindent in @file{config.site}. For Java 21 from @uref{https://jdk.java.net/} @@ -5781,10 +5785,10 @@ and from @I{OpenJDK} at @uref{https://jdk.java.net/}, for which @env{JAVA_HOME} may need to be set both when configuring @R{} and at runtime. -To use Java (specifically, binary package @CRANpkg{rJava}) with a -@acronym{CRAN} (@cputype{x86_64}) binary distribution of @R{} on -@cputype{arm64} macOS, install an Intel build of a Java @abbr{JRE} from -one of the sites linked above, then run @command{sudo R CMD javareconf}. +@c To use Java (specifically, binary package @CRANpkg{rJava}) with a +@c @acronym{CRAN} (@cputype{x86_64}) binary distribution of @R{} on +@c @cputype{arm64} macOS, install an Intel build of a Java @abbr{JRE} from +@c one of the sites linked above, then run @command{sudo R CMD javareconf}. @c jdk.java.net no longer has Java 11 nor 17 LTS builds. @@ -5866,8 +5870,8 @@ Current @acronym{CRAN} macOS distributions are targeted at @I{Big Sur} so it is wise to ensure that the compilers generate code that will run on @I{Big Sur} or later. With the recommended compilers we can use @example -CC="clang -mmacosx-version-min=11.0" -CXX="clang++ -mmacosx-version-min=11.0" +CC="clang -mmacos-version-min=11.0" +CXX="clang++ -mmacos-version-min=11.0" FC="/opt//gfortran/bin/gfortran -mmacosx-version-min=11.0" @end example @noindent @@ -5933,7 +5937,7 @@ any issues with C++ libraries. @subsection Building for Intel on @samp{arm64} Should one want to build @R{} for Intel on an @cputype{arm64} @I{Big Sur} -Mac, add the target for the C and C++ compilers: +Mac, add the target for the compilers: @example CC="clang -arch x86_64 diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index a8717f8e749..855a13ed3e5 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -4126,6 +4126,27 @@ add_dummies <- function(dir, Log) printLog(Log, "The error occurred in:\n\n") printLog0(Log, txt, "\n") } + if(do_timings) { + theta <- + as.numeric(Sys.getenv("_R_CHECK_EXAMPLE_TIMING_THRESHOLD_", + "5")) + tfile <- paste0(pkgname, "-Ex.timings") + times <- + utils::read.table(tfile, header = TRUE, row.names = 1L, + colClasses = c("character", rep.int("numeric", 3))) + o <- order(times[[1L]] + times[[2L]], decreasing = TRUE) + times <- times[o, ] + keep <- ((times[[1L]] + times[[2L]] > theta) | + (times[[3L]] > theta)) + if(any(keep)) { + printLog(Log, + sprintf("Examples with CPU (user + system) or elapsed time > %gs\n", + theta)) + out <- utils::capture.output(format(times[keep, ])) + printLog0(Log, paste(out, collapse = "\n"), "\n") + } + } + return(FALSE) } From c7fff6b19c7e096dceeffe44387ad0b85501bc28 Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 21 May 2024 17:02:08 +0000 Subject: [PATCH 070/546] Prevent integer overflow in strftime (PR#18688). git-svn-id: https://svn.r-project.org/R/trunk@86573 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/datetime.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/datetime.c b/src/main/datetime.c index 1795bcd6e40..079a94725e2 100644 --- a/src/main/datetime.c +++ b/src/main/datetime.c @@ -282,6 +282,23 @@ static int validate_tm (stm *tm) return res; } // validate_tm +/* + glibc and internal strftime are subject to integer overflow when + tm->tm_year + 1900 does not fit into an integer +*/ +static int likely_strftime_overflow (stm *tm) +{ + double year = 1900.0 + tm->tm_year; + +#if SIZEOF_INT <= 4 + return (year > INT_MAX || year < INT_MIN); +#else + /* err on the safe side to avoid surprise due to imprecise floating point + representation of the limits */ + return !(year < INT_MAX && year > INT_MIN); +#endif +} + /* days_in_year is the same for year mod 400. We could avoid loops altogether by computing how many leap years @@ -1336,7 +1353,7 @@ attribute_hidden SEXP do_formatPOSIXlt(SEXP call, SEXP op, SEXP args, SEXP env) } else if(tm.tm_min == NA_INTEGER || tm.tm_hour == NA_INTEGER || tm.tm_mday == NA_INTEGER || tm.tm_mon == NA_INTEGER || tm.tm_year == NA_INTEGER) { SET_STRING_ELT(ans, i, NA_STRING); - } else if(validate_tm(&tm) < 0) { + } else if(validate_tm(&tm) < 0 || likely_strftime_overflow(&tm)) { SET_STRING_ELT(ans, i, NA_STRING); } else { /* We could translate to wchar_t and use wcsftime if we From 8b8d08af26b95d95dbb8c6fb85af634a94c6928c Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 21 May 2024 17:04:43 +0000 Subject: [PATCH 071/546] Fix information on dates overflow in documentation (PR#18688). git-svn-id: https://svn.r-project.org/R/trunk@86574 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/Dates.Rd | 4 ++-- tests/datetime4.R | 2 +- tests/datetime4.Rout.save | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/library/base/man/Dates.Rd b/src/library/base/man/Dates.Rd index 8fd4ae82d17..c5ff4cdc3a6 100644 --- a/src/library/base/man/Dates.Rd +++ b/src/library/base/man/Dates.Rd @@ -60,8 +60,8 @@ as midnight in UTC. Printing dates involves conversion to class \code{"\link{POSIXlt}"} - which treats dates of more than about 780 million years from present - as \code{NA}. + which treats dates of more than about 780 billion days (2.1 billion + years) from present as \code{NA}. For the many methods see \code{methods(class = "Date")}. Several are documented separately, see below. diff --git a/tests/datetime4.R b/tests/datetime4.R index cd2c8ed3eaa..3f5902411b5 100644 --- a/tests/datetime4.R +++ b/tests/datetime4.R @@ -47,7 +47,7 @@ strptime("2022-01-01 -1500", "%Y-%m-%d %z", tz = "UTC") ## extreme values for as.Date (negative ones were wrong in R 4.2.2) as.Date(2^(30:33)) as.Date(-2^(30:33)) -## tm$year will overflow ints in less than 800 milion years from present. +## tm$year will overflow ints in less than 800 billion days from present. as.Date(c(7e11, 8e11, -7e11, -8e11)) diff --git a/tests/datetime4.Rout.save b/tests/datetime4.Rout.save index 27fbf578746..d670b87de79 100644 --- a/tests/datetime4.Rout.save +++ b/tests/datetime4.Rout.save @@ -179,7 +179,7 @@ Warning in strptime("2022-01-01 -1500", "%Y-%m-%d %z", tz = "UTC") : [1] "2941775-04-07" "5881580-07-12" "11761191-01-21" "23520412-02-10" > as.Date(-2^(30:33)) [1] "-2937836-09-26" "-5877641-06-23" "-11757252-12-12" "-23516473-11-23" -> ## tm$year will overflow ints in less than 800 milion years from present. +> ## tm$year will overflow ints in less than 800 billion days from present. > as.Date(c(7e11, 8e11, -7e11, -8e11)) [1] "1916536874-11-22" NA "-1916532935-02-09" [4] NA From 08d1cb2e1eb16843fd3b97e3e8ac838b51c259e8 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 21 May 2024 19:43:28 +0000 Subject: [PATCH 072/546] Use index tags to identify functions, variables, and headers i the API. git-svn-id: https://svn.r-project.org/R/trunk@86575 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 785 +++++++++++++++++++++++++++-------------- 1 file changed, 516 insertions(+), 269 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 4047ca77c8c..46e5909102d 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -4,6 +4,9 @@ @settitle Writing R Extensions @setchapternewpage on @documentencoding UTF-8 +@defcodeindex ap +@defcodeindex ae +@defcodeindex em @c %**end of header @c Put the functions in the variable index @@ -19,6 +22,46 @@ @include R-defs.texi @include version.texi +@comment move to R-defs.texi? +@macro apifun {f} +@apindex \f\ +@findex \f\ +@end macro +@macro apivar {f} +@apindex \f\ +@findex \f\ +@end macro +@macro apihdr {f} +@apindex \f\ +@findex \f\ +@end macro + +@macro eapifun {f} +@aeindex \f\ +@findex \f\ +@end macro +@macro eapivar {f} +@aeindex \f\ +@findex \f\ +@end macro +@macro eapihdr {f} +@aeindex \f\ +@findex \f\ +@end macro + +@macro embfun {f} +@emindex \f\ +@findex \f\ +@end macro +@macro embvar {f} +@emindex \f\ +@findex \f\ +@end macro +@macro embhdr {f} +@emindex \f\ +@findex \f\ +@end macro + @copying This manual is for R, version @value{VERSION}. @@ -6433,6 +6476,8 @@ something like @c Linux and Windows are said to have 48-bit virtual address limits. (This could print to full precision, lengths well beyond the address space limits of current OSes, let alone practical limits.) +@apifun XLENGTH +@apifun xlength @c 'int' on 32-but platforms, 'long' on known 64-bit platforms except Windows If you do want to use an integer format, be aware that @code{R_xlen_t} @@ -6577,14 +6622,14 @@ similar. @item Use of what @command{gfprtran} calls `Fortran 2018 deleted features', -although most were `deleted' in earlier standards: those itmeize here +although most were `deleted' in earlier standards: those itemized here were deleted in Fortran 2008. (In the Fortran standards `deleted' means features that compilers are not required to implement.) These include @itemize @item -Aritmmetic @code{IF} statements. +Arithmetic @code{IF} statements. @item -@code{DO} loops whch are not terminated with a @code{END DO} or +@code{DO} loops which are not terminated with a @code{END DO} or @code{CONTINUE} statement. (Unlabelled @code{DO} loops terminated by @code{END DO} are preferred for readability.) @item @@ -6655,7 +6700,7 @@ works around this for packages without a @file{src/Makefile}. @c Intel has fpp. Use of extensions @file{.F} and @code{.F90} to indicate source code to be preprocessed: the preprocessor used is compiler-specific and may or -may not be @command{cpp}. Compilers may even preproces files with +may not be @command{cpp}. Compilers may even preprocess files with extension @file{.f} or @file{.f90} (Intel does). @item @@ -6687,11 +6732,11 @@ Labelled @code{DO} statements. @code{COMMON} and @code{EQUIVALENCE} statements, and @code{BLOCK DATA} units. @item -Computed @code{GOTO} statmennts, replaced by @code{SELECT CASE}. +Computed @code{GOTO} statements, replaced by @code{SELECT CASE}. @item Statement functions. @item -@code{DATA} statments after executable statements. +@code{DATA} statements after executable statements. @item Specific (rather than generic) names for intrinsic functions. @end itemize @@ -10453,8 +10498,8 @@ The key to inspecting @R{} objects from compiled code is the function @code{PrintValue(SEXP @var{s})} which uses the normal @R{} printing mechanisms to print the @R{} object pointed to by @var{s}, or the safer version @code{R_PV(SEXP @var{s})} which will only print `objects'. -@findex PrintValue -@findex R_PV +@apifun PrintValue +@apifun R_PV One way to make use of @code{PrintValue} is to insert suitable calls into the code to be debugged. @@ -10882,6 +10927,7 @@ appear to work on some, including @cputype{x86_64} Windows). Note also that if your compiled code is a mixture of C functions and Fortran subprograms the argument types must match as given in the table above. +@apihdr R_ext/Complex.h C type @code{Rcomplex} is a structure with @code{double} members @code{r} and @code{i} defined in the header file @file{R_ext/Complex.h}.@footnote{This is currently included by @@ -11182,7 +11228,7 @@ at compilation time, and it provides a run-time check that the entry point is called with the right number of arguments and, optionally, the right argument types. -@findex R_registerRoutines +@apifun R_registerRoutines To register routines with @R{}, one calls the C routine @code{R_registerRoutines}. This is typically done when the DLL is first loaded within the initialization routine @code{R_init_@var{dll name}} @@ -11355,8 +11401,8 @@ void attribute_visible R_init_mypkg(DllInfo *dll) @end example @noindent -@findex R_useDynamicSymbols -@findex R_forceSymbols +@apifun R_useDynamicSymbols +@apifun R_forceSymbols The @code{R_useDynamicSymbols} call says the DLL is not to be searched for entry points specified by character strings so @code{.C} etc calls will only find registered symbols: the @code{R_forceSymbols} call only @@ -11703,6 +11749,7 @@ spline_value(SEXP knots, SEXP coeff, SEXP order, SEXP x, SEXP deriv) @dots{} @end group @end example +@apihdr R_ext/Visibility.h @noindent Alternatively, we can change the default visibility for all C symbols by @@ -11772,8 +11819,8 @@ times be useful for one package to make some of its C routines available to be called by C code in another package. The interface consists of two routines declared in header @file{R_ext/Rdynload.h} as -@findex R_RegisterCCallable -@findex R_GetCCallable +@apifun R_RegisterCCallable +@apifun R_GetCCallable @example void R_RegisterCCallable(const char *package, const char *name, DL_FUNC fptr); @@ -12468,10 +12515,10 @@ right type. @subsection Handling the effects of garbage collection @cindex Garbage collection -@findex PROTECT -@findex UNPROTECT -@findex protect -@findex unprotect +@apifun PROTECT +@apifun UNPROTECT +@apifun protect +@apifun unprotect We need to know a little about the way @R{} handles memory allocation. The memory allocated for @R{} objects is not freed by the user; instead, @@ -12554,20 +12601,20 @@ multiple times. It has been superseded by multi-set based functions in a multi-set created by @code{R_NewPreciousMSet} and typically itself protected using @code{PROTECT}. These functions should not be needed outside parsers. -@findex UNPROTECT_PTR -@findex unprotect_ptr -@findex R_PreserveInMSet -@findex R_ReleaseFromMSet -@findex R_NewPreciousMSet +@apifun UNPROTECT_PTR +@apifun unprotect_ptr +@apifun R_PreserveInMSet +@apifun R_ReleaseFromMSet +@apifun R_NewPreciousMSet Sometimes an object is changed (for example duplicated, coerced or grown) yet the current value needs to be protected. For these cases @code{PROTECT_WITH_INDEX} saves an index of the protection location that can be used to replace the protected value using @code{REPROTECT}. -@findex PROTECT_WITH_INDEX -@findex REPROTECT -@findex R_ProtectWithIndex -@findex R_Reprotect +@apifun PROTECT_WITH_INDEX +@apifun REPROTECT +@apifun R_ProtectWithIndex +@apifun R_Reprotect For example (from the internal code for @code{optim}) @example @@ -12583,8 +12630,8 @@ Note that it is dangerous to mix @code{UNPROTECT_PTR} also with locations of objects that were protected after the one being unprotected. -@findex R_PreserveObject -@findex R_ReleaseObject +@apifun R_PreserveObject +@apifun R_ReleaseObject There is another way to avoid the effects of garbage collection: a call to @code{R_PreserveObject} adds an object to an internal list of objects not to be collects, and a subsequent call to @code{R_ReleaseObject} @@ -12644,7 +12691,7 @@ For many purposes it is sufficient to allocate @R{} objects and manipulate those. There are quite a few @code{alloc@var{Xxx}} functions defined in @file{Rinternals.h}---you may want to explore them. -@findex allocVector +@apifun allocVector One that is commonly used is @code{allocVector}, the C-level equivalent of @R{}-level @code{vector()} and its wrappers such as @code{integer()} and @code{character()}. One distinction is that whereas the @R{} @@ -12704,18 +12751,18 @@ should check the data types. Sometimes it may also be necessary to check data types of objects created by evaluating an @R{} expression in the C code. You can use functions like @code{isReal}, @code{isInteger} and @code{isString} to do type checking. -@findex isReal -@findex isInteger -@findex isString +@apifun isReal +@apifun isInteger +@apifun isString Other such functions declared in the header file @file{Rinternals.h} include @code{isNull}, @code{isSymbol}, @code{isLogical}, @code{isComplex}, @code{isExpression}, and @code{isEnvironment}. -@findex isNull -@findex isSymbol -@findex isLogical -@findex isComplex -@findex isExpression -@findex isEnvironment +@apifun isNull +@apifun isSymbol +@apifun isLogical +@apifun isComplex +@apifun isExpression +@apifun isEnvironment All of these take a @code{SEXP} as argument and return 1 or 0 to indicate @var{TRUE} or @var{FALSE}. @@ -12729,7 +12776,7 @@ object, you can change the type by using @example @var{newSexp} = PROTECT(coerceVector(@var{oldSexp}, REALSXP)); @end example -@findex coerceVector +@apifun coerceVector @noindent Protection is needed as a new @emph{object} is created; the object @@ -12838,8 +12885,8 @@ SEXP out(SEXP x, SEXP y) This example introduces several new features. The @code{getAttrib} and @code{setAttrib} -@findex getAttrib -@findex setAttrib +@apifun getAttrib +@apifun setAttrib functions get and set individual attributes. Their second argument is a @code{SEXP} defining the name in the symbol table of the attribute we want; these and many such symbols are defined in the header file @@ -12851,17 +12898,17 @@ default methods of @code{names<-}, @code{dim<-} and @code{dimnames<-} (for vectors and arrays), and there are functions such as @code{GetColNames}, @code{GetRowNames}, @code{GetMatrixDimnames} and @code{GetArrayDimnames}. -@findex GetArrayDimnames -@findex GetMatrixDimnames -@findex GetColNames -@findex GetRowNames -@findex namesgets -@findex dimnamesgets -@findex dimgets +@apifun GetArrayDimnames +@apifun GetMatrixDimnames +@apifun GetColNames +@apifun GetRowNames +@apifun namesgets +@apifun dimnamesgets +@apifun dimgets What happens if we want to add an attribute that is not pre-defined? We need to add a symbol for it @emph{via} a call to -@findex install +@apifun install @code{install}. Suppose for illustration we wanted to add an attribute @code{"version"} with value @code{3.0}. We could use @@ -12924,7 +12971,7 @@ We can use @} @end group @end example -@findex classgets +@apifun classgets @noindent As the value is a character vector, we have to know how to create that @@ -13000,8 +13047,8 @@ R character vectors are stored as @code{STRSXP}s, a vector type like @code{VECSXP} where every element is of type @code{CHARSXP}. The @code{CHARSXP} elements of @code{STRSXP}s are accessed using @code{STRING_ELT} and @code{SET_STRING_ELT}. -@findex STRING_ELT -@findex SET_STRING_ELT +@apifun STRING_ELT +@apifun SET_STRING_ELT @code{CHARSXP}s are read-only objects and must never be modified. In particular, the C-style string contained in a @code{CHARSXP} should be @@ -13069,8 +13116,8 @@ void defineVar(SEXP symbol, SEXP value, SEXP rho) void setVar(SEXP symbol, SEXP value, SEXP rho) @end group @end example -@findex defineVar -@findex setVar +@apifun defineVar +@apifun setVar @noindent can be used to assign values to @R{} variables. @code{defineVar} @@ -13095,7 +13142,7 @@ At times it may also be useful to create a new environment frame in C code. SEXP R_NewEnv(SEXP enclos, int hash, int size) @end group @end example -@findex R_NewEnv +@apifun R_NewEnv @node Some convenience functions, Named objects and copying, Finding and setting variables, Handling R objects in C @subsection Some convenience functions @@ -13119,11 +13166,11 @@ failed. There are also @code{asInteger}, @code{asReal} and @code{asComplex}. The function @code{asChar} returns a @code{CHARSXP}. All of these functions ignore any elements of an input vector after the first. -@findex asInteger -@findex asLogical -@findex asReal -@findex asComplex -@findex asChar +@apifun asInteger +@apifun asLogical +@apifun asReal +@apifun asComplex +@apifun asChar To return a length-one real vector we can use @@ -13139,13 +13186,13 @@ and there are versions of this for all the atomic vector types (those for a length-one character vector being @code{ScalarString} with argument a @code{CHARSXP} and @code{mkString} with argument @code{const char *}). -@findex ScalarReal -@findex ScalarInteger -@findex ScalarLogical -@findex ScalarComplex -@findex ScalarRaw -@findex ScalarString -@findex mkString +@apifun ScalarReal +@apifun ScalarInteger +@apifun ScalarLogical +@apifun ScalarComplex +@apifun ScalarRaw +@apifun ScalarString +@apifun mkString @example @group SEXP ScalarReal(double); @@ -13163,25 +13210,25 @@ Some of the @code{is@var{XXXX}} functions differ from their apparent atomic vector type (@code{isVectorAtomic}) and for lists and expressions (@code{isVectorList}) (with no check on attributes). @code{isMatrix} is a test of a length-2 @code{"dim"} attribute. -@findex isVector -@findex isVectorAtomic -@findex isVectorList -@findex isMatrix -@findex isPairList -@findex isPrimitive -@findex isTs -@findex isNumeric -@findex isArray -@findex isFactor -@findex isObject -@findex isFunction -@findex isLanguage -@findex isNewList -@findex isList -@findex isOrdered -@findex isUnordered -@comment @findex isNumber -@comment @findex isFrame +@apifun isVector +@apifun isVectorAtomic +@apifun isVectorList +@apifun isMatrix +@apifun isPairList +@apifun isPrimitive +@apifun isTs +@apifun isNumeric +@apifun isArray +@apifun isFactor +@apifun isObject +@apifun isFunction +@apifun isLanguage +@apifun isNewList +@apifun isList +@apifun isOrdered +@apifun isUnordered +@comment @apifun isNumber +@comment @apifun isFrame @example @group Rboolean isVector(SEXP); @@ -13215,36 +13262,36 @@ that constructs a language object. Functions @code{list1} to @code{list6} construct a pairlist from one to six items, and @code{lang1} to @code{lang6} do the same for a language object (a function to call plus zero to five arguments). -@findex CONS -@findex cons -@findex list1 -@findex list2 -@findex list3 -@findex list4 -@findex list5 -@findex list6 -@findex LCONS -@findex lcons -@findex lang1 -@findex lang2 -@findex lang3 -@findex lang4 -@findex lang5 -@findex lang6 +@apifun CONS +@apifun cons +@apifun list1 +@apifun list2 +@apifun list3 +@apifun list4 +@apifun list5 +@apifun list6 +@apifun LCONS +@apifun lcons +@apifun lang1 +@apifun lang2 +@apifun lang3 +@apifun lang4 +@apifun lang5 +@apifun lang6 Functions @code{elt} and @code{lastElt} find the @I{@var{i}-th} element and the last element of a pairlist, and @code{nthcdr} returns a pointer to the @I{@var{n}-th} position in the pairlist (whose @code{CAR} is the @I{@var{n}-th} item). -@findex elt -@findex lastElt -@findex nthcdr +@apifun elt +@apifun lastElt +@apifun nthcdr Functions @code{str2type} and @code{type2str} map @R{} length-one character strings to and from @code{SEXPTYPE} numbers, and @code{type2char} maps numbers to C character strings. -@findex str2type -@findex type2str -@findex type2char +@apifun str2type +@apifun type2str +@apifun type2char @comment Want to encourage use of some of the more stable and useful R_* @comment and Rf_* functions: @@ -13261,15 +13308,24 @@ These typically contain ``workhorses'' of their @R{} counterparts. Functions @code{any_duplicated} and @code{any_duplicated3} are fast versions of @R{}'s @code{any(duplicated(.))}. -@findex any_duplicated -@findex any_duplicated3 +@eapifun any_duplicated +@eapifun any_duplicated3 Function @code{R_compute_identical} corresponds to @R{}'s @code{identical} function. -@findex R_compute_identical +@eapifun R_compute_identical +Function @code{R_BindingIsLocked} corresponds to @R{}'s @code{bindingIsLocked} function. +@eapifun R_ActiveBindingFunction +@eapifun R_BindingIsActive +@eapifun R_BindingIsLocked +@eapifun R_EnvironmentIsLocked +@eapifun R_LockBinding +@eapifun R_LockEnvironment +@eapifun R_MakeActiveBinding +@eapifun R_unLockBinding @node Named objects and copying, , Some convenience functions, Handling R objects in C @subsection Named objects and copying -@findex duplicate +@apifun duplicate @cindex Copying objects [The @code{NAMED} mechanism has been replaced by reference counting.] @@ -13353,9 +13409,9 @@ This mechanism was replaced in @R{} 4.0.0. To support future changes, package code should use the macros @code{MAYBE_REFERENCED}, @code{MAYBE_SHARED}, and @code{MARK_NOT_MUTABLE}. These currently correspond to -@findex MAYBE_REFERENCED -@findex MAYBE_SHARED -@findex MARK_NOT_MUTABLE +@apifun MAYBE_REFERENCED +@apifun MAYBE_SHARED +@apifun MARK_NOT_MUTABLE @table@code @item MAYBE_REFERENCED(x) @@ -13477,17 +13533,17 @@ of the interface they are objects that are already in use. The macros fifth = CAD5R(args); @end group @end example -@findex CADR -@findex CADDR -@findex CADDDR -@findex CAD4R -@findex CAD5R +@apifun CADR +@apifun CADDR +@apifun CADDDR +@apifun CAD4R +@apifun CAD5R @noindent provide convenient ways to access the first four arguments. More generally we can use the -@findex CAR -@findex CDR +@apifun CAR +@apifun CDR @code{CDR} and @code{CAR} macros as in @example @@ -13558,9 +13614,9 @@ SEXP showArgs(SEXP args) @} @end group @end example -@findex PRINTNAME -@findex TYPEOF -@findex TAG +@apifun PRINTNAME +@apifun TYPEOF +@apifun TAG This can be called by the wrapper function @@ -13581,18 +13637,18 @@ The (very similar) C code is in the scripts. Additional functions for accessing pairlist components are @code{CAAR}, @code{CDAR}, @code{CDDR}, and @code{CDDDR}. -@findex CAAR -@findex CDAR -@findex CDDR -@findex CDDDR +@apifun CAAR +@apifun CDAR +@apifun CDDR +@apifun CDDDR These components can be modified with @code{SETCAR}, @code{SETCDR}, @code{SETCADR}, @code{SETCADDR}, @code{SETCADDDR}, and @code{SETCAD4R}. -@findex SETCAR -@findex SETCDR -@findex SETCADR -@findex SETCADDR -@findex SETCADDDR -@findex SETCAD4R +@apifun SETCAR +@apifun SETCDR +@apifun SETCADR +@apifun SETCADDR +@apifun SETCADDDR +@apifun SETCAD4R @node Missing and special values, , Calling .External, Interface functions .Call and .External @subsection Missing and special values @@ -13609,6 +13665,7 @@ implementation this is also true of @code{NA} as it is a type of @code{NaN}, but it is unwise to rely on such details. Thus we will re-write the code to handle @code{NA}s using macros defined in @file{R_ext/Arith.h} included by @file{R.h}. +@apihdr R_ext/Arith.h The code changes are the same in any of the versions of @code{convolve2} or @code{convolveE}: @@ -13626,8 +13683,8 @@ or @code{convolveE}: @end group @end example -@findex ISNA -@findex ISNAN +@apifun ISNA +@apifun ISNAN Note that the @code{ISNA} macro, and the similar macros @code{ISNAN} (which checks for @code{NaN} or @code{NA}) and @code{R_FINITE} (which is @@ -13649,14 +13706,14 @@ The main function we will use is @example SEXP eval(SEXP expr, SEXP rho); @end example -@findex eval +@apifun eval @noindent the equivalent of the interpreted @R{} code @code{eval(expr, envir = rho)} (so @code{rho} must be an environment), although we can also make use of @code{findVar}, @code{defineVar} and @code{findFun} (which restricts the search to functions). -@findex findFun +@apifun findFun To see how this might be applied, here is a simplified internal version of @code{lapply} for expressions, used as @@ -13949,6 +14006,8 @@ SEXP numeric_deriv(SEXP args) gradient = PROTECT(allocMatrix(REALSXP, LENGTH(ans), LENGTH(theta))); rgr = REAL(gradient); rans = REAL(ans); @end group +@apifun LENGTH +@apifun length @group for(i = 0, start = 0; i < LENGTH(theta); i++, start += LENGTH(ans)) @{ @@ -14015,7 +14074,7 @@ the matrix: here we want it to be @code{REALSXP}. The other two arguments are the numbers of rows and columns. (Note that @code{LENGTH} is intended to be used for vectors: @code{length} is more generally applicable.) -@findex allocMatrix +@apifun allocMatrix @example @group @@ -14136,7 +14195,7 @@ SEXP menu_ttest3() Note that a single line of text may give rise to more than one @R{} expression. -@findex R_ParseVector +@apifun R_ParseVector @code{R_ParseVector} is essentially the code used to implement @code{parse(text=)} at @R{} level. The first argument is a character vector (corresponding to @code{text}) and the second the maximal @@ -14208,7 +14267,7 @@ An external pointer is created by @example SEXP R_MakeExternalPtr(void *p, SEXP tag, SEXP prot); @end example -@findex R_MakeExternalPtr +@apifun R_MakeExternalPtr @noindent where @code{p} is the pointer (and hence this cannot portably be a @@ -14228,7 +14287,7 @@ is typedef void * (*R_DL_FUNC)(); SEXP R_MakeExternalPtrFn(R_DL_FUNC p, SEXP tag, SEXP prot); @end example -@findex R_MakeExternalPtrFn +@apifun R_MakeExternalPtrFn The elements of an external pointer can be accessed and set @emph{via} @@ -14243,14 +14302,14 @@ void R_SetExternalPtrAddr(SEXP s, void *p); void R_SetExternalPtrTag(SEXP s, SEXP tag); void R_SetExternalPtrProtected(SEXP s, SEXP p); @end example -@findex R_ExternalPtrAddr -@findex R_ExternalPtrAddrFn -@findex R_ExternalPtrTag -@findex R_ExternalPtrProtected -@findex R_ClearExternalPtr -@findex R_SetExternalPtrAddr -@findex R_SetExternalPtrTag -@findex R_SetExternalPtrProtected +@apifun R_ExternalPtrAddr +@apifun R_ExternalPtrAddrFn +@apifun R_ExternalPtrTag +@apifun R_ExternalPtrProtected +@apifun R_ClearExternalPtr +@apifun R_SetExternalPtrAddr +@apifun R_SetExternalPtrTag +@apifun R_SetExternalPtrProtected @noindent @@ -14269,10 +14328,10 @@ typedef void (*R_CFinalizer_t)(SEXP); void R_RegisterCFinalizer(SEXP s, R_CFinalizer_t fun); void R_RegisterCFinalizerEx(SEXP s, R_CFinalizer_t fun, Rboolean onexit); @end example -@findex R_RegisterFinalizer -@findex R_RegisterCFinalizer -@findex R_RegisterFinalizerEx -@findex R_RegisterCFinalizerEx +@apifun R_RegisterFinalizer +@apifun R_RegisterCFinalizer +@apifun R_RegisterFinalizerEx +@apifun R_RegisterCFinalizerEx @noindent The @R{} function indicated by @code{fun} should be a function of a @@ -14313,8 +14372,8 @@ SEXP R_MakeWeakRef(SEXP key, SEXP val, SEXP fin, Rboolean onexit); SEXP R_MakeWeakRefC(SEXP key, SEXP val, R_CFinalizer_t fin, Rboolean onexit); @end example -@findex R_MakeWeakRef -@findex R_MakeWeakRefC +@apifun R_MakeWeakRef +@apifun R_MakeWeakRefC @noindent where the @R{} or C finalizer are specified in exactly the same way as @@ -14328,9 +14387,9 @@ SEXP R_WeakRefKey(SEXP w); SEXP R_WeakRefValue(SEXP w); void R_RunWeakRefFinalizer(SEXP w); @end example -@findex R_WeakRefKey -@findex R_WeakRefValue -@findex R_RunWeakRefFinalizer +@apifun R_WeakRefKey +@apifun R_WeakRefValue +@apifun R_RunWeakRefFinalizer A toy example of the use of weak references can be found at @uref{https://homepage.stat.uiowa.edu/~luke/R/references/weakfinex.html}, @@ -14403,16 +14462,23 @@ The vector accessors like @code{REAL}, @code{INTEGER}, @code{LOGICAL}, when used in @R{} extensions. (For efficiency they may be macros or inline functions when used in the @R{} source code, apart from @code{SET_STRING_ELT} and @code{SET_VECTOR_ELT} which are always -functions.) -@findex VECTOR_ELT -@findex SET_VECTOR_ELT -@findex REAL -@findex INTEGER -@findex LOGICAL -@findex RAW -@findex COMPLEX - -The accessor functions check that they are being used on an appropriate +functions. When used outside the @R{} source code all vector accessors +are functions.) +@apifun VECTOR_ELT +@apifun SET_VECTOR_ELT +@apifun REAL +@apifun INTEGER +@apifun LOGICAL +@apifun RAW +@apifun COMPLEX +There are also read-only versions that return a @code{const} data pointer. +For example, the return type of @code{REAL_RO} is @code{const double *} +@apifun REAL_RO +@apifun INTEGER_RO +@apifun LOGICAL_RO +@apifun RAW_RO +@apifun COMPLEX_RO +These accessor functions check that they are being used on an appropriate type of @code{SEXP}. Formerly it was possible for packages to obtain internal versions of @@ -14420,6 +14486,22 @@ some accessors by defining @samp{USE_RINTERNALS} before including @file{Rinternals.h}. This is no longer the case. Defining @samp{USE_RINTERNALS} now has no effect. +Atomic vector elements can also be accessed and set using element-wise +operations like @code{INTEGER_ELT} and @code{SET_INTEGER_ELT}. For +objects with a compact representation using these may avoid fully +materializing the object. In contrast, obtaining a data pointer will +have to fully materialize the object. +@apifun COMPLEX_ELT +@apifun INTEGER_ELT +@apifun LOGICAL_ELT +@apifun RAW_ELT +@apifun REAL_ELT +@apifun SET_COMPLEX_ELT +@apifun SET_INTEGER_ELT +@apifun SET_LOGICAL_ELT +@apifun SET_RAW_ELT +@apifun SET_REAL_ELT + @node Character encoding issues, , Vector accessor functions, System and foreign language interfaces @section Character encoding issues @@ -14564,6 +14646,7 @@ system headers and those for external software used by the package) before any @R{} headers. (Headers from other packages may include @R{} headers directly or @emph{via} inclusion from further packages, and may define @code{R_NO_REMAP} with or without including @file{Rinternals.h}.) +@apihdr R_ext/Error.h We can classify the entry points as @@ -14571,7 +14654,7 @@ We can classify the entry points as @item API Entry points which are documented in this manual and declared in an installed header file. These can be used in distributed packages and -will only be changed after deprecation. +ideally will only be changed after deprecation. @item public Entry points declared in an installed header file that are exported @@ -14592,7 +14675,35 @@ Entry points declared in an installed header file that are part of an experimental API, such as @file{R_ext/Altrep.h}. These are subject to change, so package authors wishing to use these should be prepared to adapt. + +@item embedding +Entry points intended primarily for embedding ar and creating new +front-ends. It is not clear that this needs to be a separate category +but it may be useful to keep it separate for now. @end table +@eapihdr R_ext/Altrep.h + +@comment FIXME ideally these should be links: feel free to add +See API index, Experimental API index, Embedding API index for the +classification of entry points in this document. + +@comment FIXME be more explicit as: ask on the R-devel mailing list or +@comment post a WISHLIST PR +@comment FIXME should we reference and link to bugdilla? +If you would like to use an entry point or variable that is not +identified as part of the API in this document, or is currently hidden, +you can make a request for it to be made available. Entry points or +variables not identified as in the API may be changed or removed with no +notice as part of efforts to improve aspects of @R{}. + +@strong{Work in progress:} Currently Entry points in the API are +identified in the source for this document with @code{@@apifun}, +@code{@@eapifun}, and @code{@@embfun} entries. Similarly, +@code{@@apivar}, @code{@@eapivar}, and @code{@@embvar} identify +variables, and @code{@@apihdr}, @code{@@eapihdr}, and @code{@@embhdr} +identify headers in the API. This could be used for programmatic +extraction, but the specific format is work in progress and even the way +this document is produced is subject to change. @node Memory allocation, Error signaling, The R API, The R API @section Memory allocation @@ -14604,21 +14715,21 @@ adapt. @end menu There are two types of memory allocation available to the C programmer, -one in which @R{} manages the clean-up and the other in which user -has full control (and responsibility). +one in which @R{} manages the clean-up and the other in which users +have full control (and responsibility). These functions are declared in header @file{R_ext/RS.h} which is included by @file{R.h}. @node Transient storage allocation, User-controlled memory, Memory allocation, Memory allocation @subsection Transient storage allocation -@findex R_alloc -@findex R_allocLD -@findex S_alloc -@findex S_realloc -@findex vmaxget -@findex vmaxset -@findex nrows +@apifun R_alloc +@apifun R_allocLD +@apifun S_alloc +@apifun S_realloc +@apifun vmaxget +@apifun vmaxset +@apifun nrows Here @R{} will reclaim the memory at the end of the call to @code{.C}, @code{.Call} or @code{.External}. Use @@ -14696,9 +14807,9 @@ never from front-ends. They are not thread-safe. @node User-controlled memory, , Transient storage allocation, Memory allocation @subsection User-controlled memory -@findex R_Calloc -@findex R_Realloc -@findex R_Free +@apifun R_Calloc +@apifun R_Realloc +@apifun R_Free The other form of memory allocation is an interface to @code{malloc}, the interface providing @R{} error signaling. This memory lasts until @@ -14735,9 +14846,9 @@ the case on Windows prior to @R{} 4.2.0.} in particular do not use Memory obtained by these macros should be aligned in the same way as @code{malloc}, that is `suitably aligned for any kind of variable'. -@findex Calloc -@findex Realloc -@findex Free +@apifun Calloc +@apifun Realloc +@apifun Free @c The R_ forms were introduced in 2016-09, hence for R 3.4.0 Historically the macros @code{Calloc}, @code{Free} and @code{Realloc} were used, and these remain available unless @code{STRICT_R_HEADERS} @@ -14774,10 +14885,10 @@ void warningcall(SEXP @var{call}, const char * @var{format}, ...); void warningcall_immediate(SEXP @var{call}, const char * @var{format}, ...); @end group @end example -@findex error -@findex warning -@findex errorcall -@findex warningcall +@apifun error +@apifun warning +@apifun errorcall +@apifun warningcall @findex warningcall_immediate @noindent @@ -14814,15 +14925,15 @@ Messages of more than 255 characters are truncated, with a warning. @node Random numbers, Missing and IEEE values, Error signaling, The R API @section Random number generation @cindex Random numbers in C -@findex unif_rand -@findex norm_rand -@findex exp_rand -@findex R_unif_index -@findex GetRNGstate -@findex PutRNGstate -@findex .Random.seed -@c @findex seed_in -@c @findex seed_out +@apifun unif_rand +@apifun norm_rand +@apifun exp_rand +@apifun R_unif_index +@apifun GetRNGstate +@apifun PutRNGstate +@apifun .Random.seed +@c @apifun seed_in +@c @apifun seed_out The interface to @R{}'s internal random number generation routines is @@ -14934,13 +15045,13 @@ by something like (fixed-form Fortran 90 code): @section Missing and @acronym{IEEE} special values @cindex Missing values @cindex IEEE special values -@findex ISNA -@findex ISNAN -@findex R_FINITE -@findex R_IsNaN -@findex R_PosInf -@findex R_NegInf -@findex NA_REAL +@apifun ISNA +@apifun ISNAN +@apifun R_FINITE +@apifun R_IsNaN +@apifun R_PosInf +@apifun R_NegInf +@apifun NA_REAL A set of functions is provided to test for @code{NA}, @code{Inf}, @code{-Inf} and @code{NaN}. These functions are accessed @emph{via} macros: @@ -14979,10 +15090,10 @@ These are defined in header @file{R_ext/Arith.h} included by @file{R.h}. @node Printing, Calling C from Fortran and vice versa, Missing and IEEE values, The R API @section Printing @cindex Printing from C -@findex Rprintf -@findex REprintf -@findex Rvprintf -@findex REvprintf +@apifun Rprintf +@apifun REprintf +@apifun Rvprintf +@apifun REvprintf The most useful function for printing from a C routine compiled into @R{} is @code{Rprintf}. This is used in exactly the same way as @@ -15022,9 +15133,9 @@ avoided. Some subroutines are provided to ease the output of information from Fortran code. -@findex dblepr -@findex realpr -@findex intpr +@apifun dblepr +@apifun realpr +@apifun intpr @example @group subroutine dblepr(@var{label}, @var{nchar}, @var{data}, @var{ndata}) @@ -15035,10 +15146,10 @@ subroutine intpr (@var{label}, @var{nchar}, @var{data}, @var{ndata}) @noindent and from @R{}@tie{}4.0.0, -@findex labelpr -@findex dblepr1 -@findex realpr1 -@findex intpr1 +@apifun labelpr +@apifun dblepr1 +@apifun realpr1 +@apifun intpr1 @example @group subroutine labelpr(@var{label}, @var{nchar}) @@ -15380,18 +15491,24 @@ using @command{f2c}. @R{} contains a large number of mathematical functions for its own use, for example numerical linear algebra computations and special functions. +@apihdr R_ext/BLAS.h +@apihdr R_ext/Lapack.h +@apihdr R_ext/Linpack.h The header files @file{R_ext/BLAS.h}, @file{R_ext/Lapack.h} and -@file{R_ext/Linpack.h} contains declarations of the BLAS, LAPACK and +@file{R_ext/Linpack.h} contain declarations of the BLAS, LAPACK and LINPACK linear algebra functions included in @R{}. These are expressed as calls to Fortran subroutines, and they will also be usable from users' Fortran code. Although not part of the official @acronym{API}, this set of subroutines is unlikely to change (but might be supplemented). +@comment API: This is really confusing. What is the 'official API'? Are +@comment things in these headers OK so use in packages or not? The header file @file{Rmath.h} lists many other functions that are available and documented in the following subsections. Many of these are C interfaces to the code behind @R{} functions, so the @R{} function documentation may give further details. +@apihdr Rmath.h @menu * Distribution functions:: @@ -15521,12 +15638,16 @@ and @code{rN} must point to a length-@code{K} integer vector @eqn{n_j=, nj=}@code{rN[j]} is ``filled'' by a random binomial from @eqn{Bin(n; \pi_j), Bin(n; prob[j])}, constrained to @eqn{\sum_{j=1}^K n_j = n, sum(rN[.]) == n}. +@apifun rmultinom After calls to @code{dwilcox}, @code{pwilcox} or @code{qwilcox} the function @code{wilcox_free()} should be called, and similarly @code{signrank_free()} for the signed rank functions. -@findex wilcox_free -@findex signrank_free +@apifun dwilcox +@apifun pwilcox +@apifun qwilcox +@apifun wilcox_free +@apifun signrank_free Since @code{wilcox_free()} and @code{signrank_free()} were only added to @file{Rmath.h} in @R{}@tie{} 4.2.0, their use requires something like @example @@ -15564,6 +15685,14 @@ q = 1-p} which may be advantageous when one of them is close to @eqn{1, @cindex Gamma function @cindex @I{Polygamma} functions +@apifun gammafn +@apifun lgammafn +@apifun digamma +@apifun trigamma +@apifun tetragamma +@apifun pentagamma +@apifun psigamma +@apifun dpsifn @deftypefun double gammafn (double @var{x}) @deftypefunx double lgammafn (double @var{x}) @deftypefunx double digamma (double @var{x}) @@ -15588,11 +15717,15 @@ is the @I{k-th} derivative of @eqn{\psi(x), Psi(x)}, i.e., @end deftypefun @cindex Beta function +@apifun beta +@apifun lbeta @deftypefun double beta (double @var{a}, double @var{b}) @deftypefunx double lbeta (double @var{a}, double @var{b}) The (complete) Beta function and its natural logarithm. @end deftypefun +@apifun choose +@apifun lchoose @deftypefun double choose (double @var{n}, double @var{k}) @deftypefunx double lchoose (double @var{n}, double @var{k}) The number of combinations of @var{k} items chosen from @var{n} and @@ -15602,6 +15735,10 @@ needed). @end deftypefun @cindex Bessel functions +@apifun bessel_i +@apifun bessel_j +@apifun bessel_k +@apifun bessel_y @deftypefun double bessel_i (double @var{x}, double @var{nu}, double @var{expo}) @deftypefunx double bessel_j (double @var{x}, double @var{nu}) @deftypefunx double bessel_k (double @var{x}, double @var{nu}, double @var{expo}) @@ -15619,6 +15756,9 @@ values.) There are a few other numerical utility functions available as entry points. +@apifun R_pow +@apifun R_pow_di +@apifun pow1p @deftypefun double R_pow (double @var{x}, double @var{y}) @deftypefunx double R_pow_di (double @var{x}, int @var{i}) @deftypefunx double pow1p (double @var{x}, double @var{y}) @@ -15632,6 +15772,7 @@ missing or infinite or @code{NaN}. even for small @var{x}, i.e., @eqn{|x| \ll 1, |x| << 1}. @end deftypefun +@apifun log1p @deftypefun double log1p (double @var{x}) Computes @code{log(1 + @var{x})} (@emph{log 1 @I{@b{p}lus} x}), accurately even for small @var{x}, i.e., @eqn{|x| \ll 1, |x| << 1}. @@ -15642,16 +15783,19 @@ included in @file{Rmath.h}, but is (probably) in @file{math.h} which C++98). @end deftypefun +@apifun log1pmx @deftypefun double log1pmx (double @var{x}) Computes @code{log(1 + @var{x}) - @var{x}} (@emph{log 1 @I{@b{p}lus} x @I{@b{m}inus} @b{x}}), accurately even for small @var{x}, i.e., @eqn{|x| \ll 1, |x| << 1}. @end deftypefun +@apifun log1pexp @deftypefun double log1pexp (double @var{x}) Computes @code{log(1 + exp(@var{x}))} (@emph{log 1 @I{@b{p}lus} @b{exp}}), accurately, notably for large @var{x}, e.g., @eqn{x > 720, x > 720}. @end deftypefun +@apifun log1mexp @deftypefun double log1mexp (double @var{x}) Computes @code{log(1 - exp(@var{-x}))} (@emph{log 1 @I{@b{m}inus} @b{exp}}), accurately, carefully for two regions of @var{x}, optimally cutting @@ -15660,6 +15804,7 @@ off at @eqn{\log 2, log 2} (= 0.693147..), using @end deftypefun +@apifun expm1 @deftypefun double expm1 (double @var{x}) Computes @code{exp(@var{x}) - 1} (@emph{exp x @I{@b{m}inus} 1}), accurately even for small @var{x}, i.e., @eqn{|x| \ll 1, |x| << 1}. @@ -15670,11 +15815,13 @@ included in @file{Rmath.h}, but is (probably) in @file{math.h} which C++98). @end deftypefun +@apifun lgamma1p @deftypefun double lgamma1p (double @var{x}) Computes @code{log(gamma(@var{x} + 1))} (@emph{log(gamma(1 @I{@b{p}lus} x))}), accurately even for small @var{x}, i.e., @eqn{0 < x < 0.5, 0 < x < 0.5}. @end deftypefun +@apifun cospi @deftypefun double cospi (double @var{x}) Computes @code{cos(pi * x)} (where @code{pi} is 3.14159...), accurately, notably for half integer @var{x}. @@ -15691,6 +15838,7 @@ neither @file{math.h} nor @file{cmath} is included before before the first inclusion.) @end deftypefun +@apifun sinpi @deftypefun double sinpi (double @var{x}) Computes @code{sin(pi * x)} accurately, notably for (half) integer @var{x}. @@ -15699,12 +15847,14 @@ included in @file{Rmath.h}, but is in @file{math.h} which @file{Rmath.h} includes (but see the comments for @code{cospi}). @end deftypefun +@apifun Rtanpi @deftypefun double Rtanpi (double @var{x}) Computes @code{tan(pi * x)} accurately, notably for integer @var{x}, giving @var{NaN} for half integer @var{x} and exactly +1 or -1 for (non half) quarter integers. @end deftypefun +@apifun tanpi @deftypefun double tanpi (double @var{x}) Computes @code{tan(pi * x)} accurately for integer @var{x} with possibly platform dependent behavior for half (and quarter) integers. @@ -15713,6 +15863,9 @@ in @file{Rmath.h}, but is in @file{math.h} which @file{Rmath.h} includes (but see the comments for @code{cospi}). @end deftypefun +@apifun logspace_add +@apifun logspace_sub +@apifun logspace_sum @deftypefun double logspace_add (double @var{logx}, double @var{logy}) @deftypefunx double logspace_sub (double @var{logx}, double @var{logy}) @deftypefunx double logspace_sum (const double* @var{logx}, int @var{n}) @@ -15723,6 +15876,10 @@ and ``sum_i x[i]'' as @code{log (sum[i = 1:@var{n} exp(@var{logx}[i])] )} without causing unnecessary overflows or throwing away too much accuracy. @end deftypefun +@apifun imax2 +@apifun imin2 +@apifun fmax2 +@apifun fmin2 @deftypefun int imax2 (int @var{x}, int @var{y}) @deftypefunx int imin2 (int @var{x}, int @var{y}) @deftypefunx double fmax2 (double @var{x}, double @var{y}) @@ -15734,16 +15891,19 @@ arguments is a @code{NaN}: these versions return @code{NaN}. @end deftypefun @deftypefun double sign (double @var{x}) +@apifun sign Compute the @emph{signum} function, where sign(@var{x}) is 1, 0, or @math{-1}, when @var{x} is positive, 0, or negative, respectively, and @code{NaN} if @code{x} is a @code{NaN}. @end deftypefun +@apifun fsign @deftypefun double fsign (double @var{x}, double @var{y}) Performs ``transfer of sign'' and is defined as @eqn{|x| * \hbox{sign}(y), |x| * sign(y)}. @end deftypefun +@apifun fprec @deftypefun double fprec (double @var{x}, double @var{digits}) Returns the value of @var{x} rounded to @var{digits} decimal digits (after the decimal point). @@ -15751,6 +15911,7 @@ Returns the value of @var{x} rounded to @var{digits} decimal digits This is the function used by @R{}'s @code{signif()}. @end deftypefun +@apifun fround @deftypefun double fround (double @var{x}, double @var{digits}) Returns the value of @var{x} rounded to @var{digits} @emph{significant} decimal digits. @@ -15759,6 +15920,7 @@ This is the function used by @R{}'s @code{round()}. (Note that C99/C++11 provide a @code{round} function but C++98 need not.) @end deftypefun +@apifun ftrunc @deftypefun double ftrunc (double @var{x}) Returns the value of @var{x} truncated (to an integer value) towards zero. @@ -15766,8 +15928,8 @@ zero. @node Mathematical constants, , Numerical Utilities, Numerical analysis subroutines @subsection Mathematical constants -@findex M_E -@findex M_PI +@apivar M_E +@apivar M_PI @c maybe not all into the index ... @R{} has a set of commonly used mathematical constants encompassing @@ -15808,14 +15970,16 @@ natural logarithm (@code{log(x)} in @R{}). @end multitable @end quotation +@apihdr R_ext/Constants.h There are a set of constants (@code{PI}, @code{DOUBLE_EPS}) (and so on) defined (unless @code{STRICT_R_HEADERS} is defined) in the included header @file{R_ext/Constants.h}, mainly for compatibility with @Sl{}. All but @code{PI} are deprecated and should be replaced by the C99/C++11 versions used in that file. -@findex TRUE -@findex FALSE +@apivar TRUE +@apivar FALSE +@apihdr R_ext/Boolean.h Further, the included header @file{R_ext/Boolean.h} has enumeration constants @code{TRUE} and @code{FALSE} of type @code{Rboolean} in order to provide a way of using ``logical'' variables in C consistently. @@ -15830,7 +15994,7 @@ The C code underlying @code{optim} can be accessed directly. The user needs to supply a function to compute the function to be minimized, of the type -@findex optimfn +@apifun optimfn @example typedef double optimfn(int n, double *par, void *ex); @end example @@ -15842,7 +16006,7 @@ routine, normally used to carry auxiliary information. Some of the methods also require a gradient function -@findex optimgr +@apifun optimgr @example typedef void optimgr(int n, double *par, double *gr, void *ex); @end example @@ -15856,7 +16020,7 @@ The interfaces (defined in header @file{R_ext/Applic.h}) are @itemize @bullet @item @I{Nelder Mead}: -@findex nmmin +@apifun nmmin @example void nmmin(int n, double *xin, double *x, double *Fmin, optimfn fn, int *fail, double abstol, double intol, void *ex, @@ -15865,7 +16029,7 @@ void nmmin(int n, double *xin, double *x, double *Fmin, optimfn fn, @end example @item BFGS: -@findex vmmin +@apifun vmmin @example void vmmin(int n, double *x, double *Fmin, optimfn fn, optimgr gr, int maxit, int trace, @@ -15874,7 +16038,7 @@ void vmmin(int n, double *x, double *Fmin, @end example @item Conjugate gradients: -@findex cgmin +@apifun cgmin @example void cgmin(int n, double *xin, double *x, double *Fmin, optimfn fn, optimgr gr, int *fail, double abstol, @@ -15883,7 +16047,7 @@ void cgmin(int n, double *xin, double *x, double *Fmin, @end example @item Limited-memory BFGS with bounds: -@findex lbfgsb +@apifun lbfgsb @example void lbfgsb(int n, int lmm, double *x, double *lower, double *upper, int *nbd, double *Fmin, optimfn fn, @@ -15893,7 +16057,7 @@ void lbfgsb(int n, int lmm, double *x, double *lower, @end example @item Simulated annealing: -@findex samin +@apifun samin @example void samin(int n, double *x, double *Fmin, optimfn fn, int maxit, int tmax, double temp, int trace, void *ex); @@ -15919,7 +16083,7 @@ The C code underlying @code{integrate} can be accessed directly. The user needs to supply a @emph{vectorizing} C function to compute the function to be integrated, of the type -@findex integr_fn +@apifun integr_fn @example typedef void integr_fn(double *x, int n, void *ex); @end example @@ -15940,7 +16104,7 @@ integrals over finite and infinite intervals (or ``ranges'' or @itemize @bullet @item Finite: -@findex Rdqags +@apifun Rdqags @example void Rdqags(integr_fn f, void *ex, double *a, double *b, double *epsabs, double *epsrel, @@ -15950,7 +16114,7 @@ void Rdqags(integr_fn f, void *ex, double *a, double *b, @end example @item Infinite: -@findex Rdqagi +@apifun Rdqagi @example void Rdqagi(integr_fn f, void *ex, double *bound, int *inf, double *epsabs, double *epsrel, @@ -16007,6 +16171,8 @@ more details, particularly about reasons for failure (@code{ier >= 1}). available to users' C code. The following is declared in header file @file{Rinternals.h}. +@apifun R_orderVector +@apifun R_orderVector1 @deftypefun void R_orderVector (int* @var{indx}, int @var{n}, SEXP @var{arglist}, Rboolean @var{nalast}, Rboolean @var{decreasing}) @deftypefunx void R_orderVector1 (int* @var{indx}, int @var{n}, SEXP @var{x}, Rboolean @var{nalast}, Rboolean @var{decreasing}) @@ -16028,6 +16194,10 @@ decreasing)}. It was added in @R{} 3.3.0. All other sort routines are declared in header file @file{R_ext/Utils.h} (included by @file{R.h}) and include the following. +@apifun R_isort +@apifun R_rsort +@apifun R_csort +@apifun rsort_with_index @deftypefun void R_isort (int* @var{x}, int @var{n}) @deftypefunx void R_rsort (double* @var{x}, int @var{n}) @deftypefunx void R_csort (Rcomplex* @var{x}, int @var{n}) @@ -16040,11 +16210,15 @@ the imaginary part.) @code{NA}s are sorted last. permutation to @var{index}. @code{NA}s are sorted last. @end deftypefun +@apifun revsort @deftypefun void revsort (double* @var{x}, int* @var{index}, int @var{n}) Is similar to @code{rsort_with_index} but sorts into decreasing order, and @code{NA}s are not handled. @end deftypefun +@apifun iPsort +@apifun rPsort +@apifun cPsort @deftypefun void iPsort (int* @var{x}, int @var{n}, int @var{k}) @deftypefunx void rPsort (double* @var{x}, int @var{n}, int @var{k}) @deftypefunx void cPsort (Rcomplex* @var{x}, int @var{n}, int @var{k}) @@ -16053,6 +16227,10 @@ These all provide (very) partial sorting: they permute @var{x} so that the left, larger ones to the right. @end deftypefun +@apifun R_qsort +@apifun R_qsort_I +@apifun R_qsort_int +@apifun R_qsort_int_I @deftypefun void R_qsort (double *@var{v}, size_t @var{i}, size_t @var{j}) @deftypefunx void R_qsort_I (double *@var{v}, int *@var{I}, int @var{i}, int @var{j}) @deftypefunx void R_qsort_int (int *@var{iv}, size_t @var{i}, size_t @var{j}) @@ -16071,6 +16249,8 @@ Note that @code{NA}s are not handled (explicitly) and you should use different sorting functions if @code{NA}s can be present. @end deftypefun +@apifun qsort4 +@apifun qsort3 @deftypefun subroutine qsort4 (double precision @var{v}, integer @var{indx}, integer @var{ii}, integer @var{jj}) @deftypefunx subroutine qsort3 (double precision @var{v}, integer @var{ii}, integer @var{jj}) @@ -16079,6 +16259,7 @@ The Fortran interface routines for sorting double precision vectors are @code{R_qsort_I}, respectively. @end deftypefun +@apifun R_max_col @deftypefun void R_max_col (double* @var{matrix}, int* @var{nr}, int* @var{nc}, int* @var{maxes}, int* @var{ties_meth}) Given the @var{nr} by @var{nc} matrix @code{matrix} in column-major (``Fortran'') @@ -16090,8 +16271,10 @@ column number of the maximal element in the @I{@var{i}-th} row (the same as See @R{}'s help page @code{?max.col}. @end deftypefun +@apifun findInterval +@apifun findInterval2 @deftypefun int findInterval (double* @var{xt}, int @var{n}, double @var{x}, Rboolean @var{rightmost_closed}, Rboolean @var{all_inside}, int @var{ilo}, int* @var{mflag}) -@deftypefunx int findInterval2(double* @var{xt}, int @var{n}, double @var{x}, Rboolean @var{rightmost_closed}, Rboolean @var{all_inside}, Rboolean @var{left_open}, int @var{ilo}, int* @var{mflag}) +@deftypefunx int findInterval2 (double* @var{xt}, int @var{n}, double @var{x}, Rboolean @var{rightmost_closed}, Rboolean @var{all_inside}, Rboolean @var{left_open}, int @var{ilo}, int* @var{mflag}) Given the ordered vector @var{xt} of length @var{n}, return the interval or index of @var{x} in @code{@var{xt}[]}, typically max(@math{i}; @eqn{1 \le i \le @var{n}, 1 <= i <= @var{n}} & @math{@var{xt}[i]} @eqn{\le, <=} @@ -16120,6 +16303,9 @@ There is also an @code{F77_CALL(interv)()} version of A system-independent interface to produce the name of a temporary file is provided as +@apifun R_tmpnam +@apifun R_tmpnam2 +@apifun R_free_tmpnam @deftypefun {char *} R_tmpnam (const char *@var{prefix}, const char *@var{tmpdir}) @deftypefunx {char *} R_tmpnam2 (const char *@var{prefix}, const char *@var{tmpdir}, const char *@var{fileext}) @deftypefunx {void} R_free_tmpnam (char *@var{name}) @@ -16132,6 +16318,8 @@ system call @code{tmpnam}). Freeing the result using @code{free} is no longer recommended. @end deftypefun +@apifun R_atof +@apifun R_strtod @deftypefun void R_atof (const char* @var{str}) @deftypefunx void R_strtod (const char* @var{str}, char ** @var{end}) Implementations of the C99/POSIX functions @code{atof} and @code{strtod} @@ -16146,6 +16334,7 @@ period as the decimal point @emph{aka} `@I{radix character}' and converting There is also the internal function used to expand file names in several @R{} functions, and called directly by @code{path.expand}. +@apifun R_ExpandFileName @deftypefun {const char *} R_ExpandFileName (const char *@var{fn}) Expand a path name @var{fn} by replacing a leading tilde by the user's home directory (if defined). The precise meaning is platform-specific; @@ -16159,6 +16348,8 @@ e.g.@: @code{F77_CALL(d1mach)(4)}. Note that these are emulations of the original functions by Fox, Hall and @I{Schryer} on @I{Netlib} at @uref{https://netlib.org/slatec/src/} for @acronym{IEC}@tie{}60559 arithmetic (required by @R{}). +@apifun d1mach +@apifun i1mach @node Re-encoding, Condition handling and cleanup code, Utility functions, The R API @section Re-encoding @@ -16169,12 +16360,15 @@ incompatibilities between the declarations in different implementations of @code{iconv}. These are declared in header file @file{R_ext/Riconv.h}. +@apihdr R_ext/Riconv.h +@apifun Riconv_open @deftypefun {void *} Riconv_open (const char *@var{to}, const char *@var{from}) Set up a pointer to an encoding object to be used to convert between two encodings: @code{""} indicates the current locale. @end deftypefun +@apifun Riconv @deftypefun size_t Riconv (void *@var{cd}, const char **@var{inbuf}, size_t *@var{inbytesleft}, char **@var{outbuf}, size_t *@var{outbytesleft}) Convert as much as possible of @code{inbuf} to @code{outbuf}. Initially the @code{size_t} variables indicate the number of bytes available in the @@ -16188,6 +16382,7 @@ and might be invalid in the encoding specified) or @code{EINVAL} (the input does not end with a complete multi-byte character). @end deftypefun +@apifun Riconv_close @deftypefun int Riconv_close (void * @var{cd}) Free the resources of an encoding object. @end deftypefun @@ -16215,9 +16410,9 @@ SEXP R_tryCatch(SEXP (*fun)(void *data), void *data, SEXP R_withCallingErrorHandler(SEXP (*fun)(void *data), void *data, SEXP (*hndlr)(SEXP cond, void *hdata), void *hdata) @end example -@findex R_tryCatchError -@findex R_tryCatch -@findex R_withCallingErrorHandler +@apifun R_tryCatchError +@apifun R_tryCatch +@apifun R_withCallingErrorHandler @code{R_tryCatchError} establishes an exiting handler for conditions inheriting form class @code{error}. @@ -16245,7 +16440,7 @@ SEXP R_UnwindProtect(SEXP (*fun)(void *data), void *data, void (*clean)(void *data, Rboolean jump), void *cdata, SEXP cont); @end example -@findex R_UnwindProtect +@apifun R_UnwindProtect @code{R_UnwindProtect} can be used in two ways. The simper usage, suitable for use in C code, passes @code{NULL} for the @code{cont} @@ -16263,8 +16458,8 @@ two additional functions: SEXP R_MakeUnwindCont(); NORET void R_ContinueUnwind(SEXP cont); @end example -@findex R_MakeUnwindCont -@findex R_ContinueUnwind +@apifun R_MakeUnwindCont +@apifun R_ContinueUnwind @code{R_MakeUnwindCont} allocates a @emph{continuation token} @code{cont} to pass to @code{R_UnwindProtect}. This token should be @@ -16289,7 +16484,7 @@ interrupted at suitable points by calling from C void R_CheckUserInterrupt(void); @end example -@findex R_CheckUserInterrupt +@apifun R_CheckUserInterrupt @noindent and from Fortran @@ -16297,7 +16492,7 @@ and from Fortran @example subroutine rchkusr() @end example -@findex rchkusr +@apifun rchkusr These check if the user has requested an interrupt, and if so branch to @R{}'s error signaling functions. @@ -16311,7 +16506,7 @@ or generate an error and so not return to your code. @section Platform and version information @cindex Version information from C @cindex @I{OpenMP} -@findex R_Version +@apifun R_Version The header files define @code{USING_R}, which can be used to test if the code is indeed being used with @R{}. @@ -16370,7 +16565,7 @@ platforms. @node Inlining C functions, Controlling visibility, Platform and version information, The R API @section Inlining C functions -@findex R_INLINE +@apivar R_INLINE The C99 keyword @code{inline} should be recognized by all compilers nowadays used to build @R{}. Portable code which might be used with @@ -16583,6 +16778,8 @@ The following headers are included by @file{R.h}: @file{R.dll} on Windows. @end multitable @end quotation +@apihdr R_ext/Memory.h +@apihdr R_ext/Random.h The graphics systems are exposed in headers @file{R_ext/GraphicsEngine.h}, @file{R_ext/GraphicsDevice.h} (which it @@ -16590,6 +16787,9 @@ includes) and @file{R_ext/QuartzDevice.h}. Facilities for defining custom connection implementations are provided in @file{R_ext/Connections.h}, but make sure you consult the file before use. +@eapihdr R_ext/QuartzDevice.h +@eapihdr R_ext/GraphicsEngine.h +@eapihdr R_ext/GraphicsDevice.h Let us re-iterate the advice to include in C++ code system headers before the @R{} header files, especially @file{Rinternals.h} (included @@ -16883,11 +17083,12 @@ are not part of the automated test procedures and so little tested.} in the @file{tests/Embedding} directory. These make use of @code{Rf_initEmbeddedR} in @file{src/main/Rembedded.c}, and essentially use -@findex Rf_initEmbeddedR -@findex R_ReplDLLinit -@findex R_ReplDLLdo1 -@findex Rf_endEmbeddedR -@findex run_Rmainloop +@embfun Rf_initEmbeddedR +@embfun R_ReplDLLinit +@embfun R_ReplDLLdo1 +@embfun Rf_endEmbeddedR +@embfun run_Rmainloop +@embhdr Rembedded.h @example #include @@ -16936,7 +17137,10 @@ way, @emph{unless} @code{R_TempDir} is set to a non-NULL value before @code{Rf_initEmbeddedR} is called. In that case the value is assumed to contain an existing writable directory, and it is not cleaned up when @R{} is shut down. +@embvar R_TempDir +@embfun R_Interactive +@embhdr Rinterface.h @code{Rf_initEmbeddedR} sets @R{} to be in interactive mode: you can set @code{R_Interactive} (defined in @file{Rinterface.h}) subsequently to change this. @@ -17075,17 +17279,25 @@ extern void (*ptr_R_ProcessEvents)(); which allow standard @R{} callbacks to be redirected to your GUI. What these do is generally documented in the file @file{src/unix/system.txt}. +@apifun R_ShowMessage @deftypefun void R_ShowMessage (char *@var{message}) This should display the message, which may have multiple lines: it should be brought to the user's attention immediately. @end deftypefun +@embfun R_Busy @deftypefun void R_Busy (int @var{which}) This function invokes actions (such as change of cursor) when @R{} embarks on an extended computation (@code{@var{which}=1}) and when such a state terminates (@code{@var{which}=0}). @end deftypefun +@embfun R_ReadConsole +@embfun R_WriteConsole +@embfun R_WriteConsoleEx +@embfun R_ResetConsole +@embfun R_FlushConsole +@embfun R_ClearerrConsole @deftypefun int R_ReadConsole (const char *@var{prompt}, unsigned char *@var{buf}, @ int @var{buflen}, int @var{hist}) @deftypefunx void R_WriteConsole (const char *@var{buf}, int @var{buflen}) @@ -17123,6 +17335,7 @@ system console. @code{R_ClearerrConsole} clears any errors associated with reading from the console. @end deftypefun +@embfun R_ShowFiles @deftypefun int R_ShowFiles (int @var{nfile}, const char **@var{file}, @ const char **@var{headers}, const char *@var{wtitle}, Rboolean @var{del}, @ const char *@var{pager}) @@ -17130,6 +17343,7 @@ with reading from the console. This function is used to display the contents of files. @end deftypefun +@embfun R_ChooseFile @deftypefun int R_ChooseFile (int @var{new}, char *@var{buf}, @ int @var{len}) @@ -17137,15 +17351,20 @@ Choose a file and return its name in @var{buf} of length @var{len}. Return value is 0 for success, > 0 otherwise. @end deftypefun +@embfun R_EditFile @deftypefun int R_EditFile (const char *@var{buf}) Send a file to an editor window. @end deftypefun +@embfun R_EditFiles @deftypefun int R_EditFiles (int @var{nfile}, const char **@var{file}, const char **@var{title}, const char *@var{editor}) Send @var{nfile} files to an editor, with titles possibly to be used for the editor window(s). @end deftypefun +@embfun R_loadhistory +@embfun R_savehistory +@embfun R_addhistory @deftypefun SEXP R_loadhistory (SEXP, SEXP, SEXP, SEXP); @deftypefunx SEXP R_savehistory (SEXP, SEXP, SEXP, SEXP); @deftypefunx SEXP R_addhistory (SEXP, SEXP, SEXP, SEXP); @@ -17236,13 +17455,13 @@ void R_CleanUp (SA_TYPE saveact, int status, int RunLast) @} @end example @end deftypefun -@findex R_dot_Last -@findex R_RunExitFinalizers -@findex R_CleanTempDir -@findex R_SaveGlobalEnv -@findex Rf_KillAllDevices -@findex CleanEd -@findex fpu_setup +@embfun R_dot_Last +@embfun R_RunExitFinalizers +@embfun R_CleanTempDir +@embfun R_SaveGlobalEnv +@embfun Rf_KillAllDevices +@embfun CleanEd +@embfun fpu_setup These callbacks should never be changed in a running @R{} session (and hence cannot be called from an extension package). @@ -17268,7 +17487,7 @@ register symbols to be used with @code{.C}, @code{.Call} etc. This entry can be obtained by calling @code{getEmbeddingDllInfo}, so a typical use is -@findex R_getEmbeddingDllInfo +@embfun R_getEmbeddingDllInfo @example DllInfo *info = R_getEmbeddingDllInfo(); R_registerRoutines(info, cMethods, callMethods, NULL, NULL); @@ -17335,8 +17554,8 @@ handler for events on a particular file descriptor, or to set a polling interval (@emph{via} @code{R_wait_usec}) and a function to be called periodically @emph{via} @code{R_PolledEvents}: the polling mechanism is used by the @pkg{tcltk} package. -@findex R_PolledEvents -@findex R_wait_usec +@embfun R_PolledEvents +@embfun R_wait_usec It is not intended that these facilities are used by packages, but if they are needed exceptionally, the package should ensure that it cleans @@ -17471,9 +17690,10 @@ Examples of calling @file{R.dll} directly are provided in the directory @file{src/@/gnuwin32/@/front-ends}, including a simple command-line front end @file{rtest.c} whose code is -@findex setup_Rmainloop -@findex R_setStartTime -@findex R_set_command_line_arguments +@embfun setup_Rmainloop +@embfun R_setStartTime +@embfun R_set_command_line_arguments +@embhdr R_ext/RStartup.h @smallexample #define Win32 #include @@ -17592,9 +17812,9 @@ administrative install and @code{HKEY_CURRENT_USER\Software\R-core\R\InstallPath} otherwise, if selected during installation (as it is by default). -@findex R_DefParams -@findex R_DefParamsEx -@findex R_SetParams +@embfun R_DefParams +@embfun R_DefParamsEx +@embfun R_SetParams @item Define startup conditions and callbacks @emph{via} the @code{Rstart} structure. @code{R_DefParams} sets the defaults, and @code{R_SetParams} sets @@ -17631,8 +17851,8 @@ needed -- two ways are provided to allow this: @code{Rp->callback}. A version of this is used to run package Tcl/Tk for @pkg{tcltk} under Windows, for the code is -@findex R_ProcessEvents -@findex onintr +@embfun R_ProcessEvents +@apifun onintr @example void R_ProcessEvents(void) @{ @@ -17738,11 +17958,38 @@ use its value for @code{InstallPath}. @printindex vr -@node Concept index, , Function and variable index, Top +@node Concept index, API index, Function and variable index, Top @unnumbered Concept index @printindex cp +@node API index, Experimental API index, Concept index, Top +@unnumbered API index + +Entry points and variables listed in this index and in header files +listed here are intended to be used in distributed packages and ideally +will only be changed after deprecation. + +@printindex ap + +@node Experimental API index, Embedding API index, API index, Top +@unnumbered Experimental API index + +Entry points and variables listed in this index and in header files +listed here are part of an experimental API, such as +R_ext/Altrep.h. These are subject to change, so package authors wishing +to use these should be prepared to adapt. + +@printindex ae + +@node Embedding API index, , API index, Top +@unnumbered Embedding API index + +Functions, variables, and header files to support creating alternate +front ends and other forms of embedding @R{}. + +@printindex em + @bye @c Local Variables: *** From f4997fe0ac11900f1ebcc8fcaedf10b8320cae87 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 21 May 2024 19:55:46 +0000 Subject: [PATCH 073/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86576 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index 2e6f6d8c346..f7ada4f1d23 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -73,7 +73,7 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "New Zealand [https]","New Zealand",Auckland,https://cran.stat.auckland.ac.nz/,"University of Auckland","s.urbanek # auckland.ac.nz",1,nz,"secure_mirror_from_master" "Norway [https]",Norway,Bergen,https://cran.uib.no/,"University of Bergen","sundrift # It.uib.no",1,no,"secure_mirror_from_master" "Philippines [https]",Philippines,"Quezon City",https://cran.stat.upd.edu.ph/,"University of the Philippines and PREGINET","COARE Team , ops # pregi.net",0,ph,"maintainer_address_bounces" -"Poland [https]",Poland,Warsaw,https://cran.mi2.ai/,"MI2.ai, Warsaw University of Technology","przemyslaw.biecek # gmail.com",0,pl +"Poland [https]",Poland,Warsaw,https://cran.mi2.ai/,"MI2.ai, Warsaw University of Technology","przemyslaw.biecek # gmail.com",1,pl "Portugal (Lisbon) [https]",Portugal,Lisbon,https://cran.radicaldevelop.com/,"RadicalDevelop, Lda","geral # radicaldevelop.com",1,pt "Russia (Novosibirsk) [https]",Russia,Novosibirsk,https://mirror.truenetwork.ru/CRAN/,"Truenetwork","mirror # truenetwork.ru",1,ru "South Africa (Johannesburg) [https]","South Africa",Johannesburg,https://cran.mirror.ac.za/,"TENET, Johannesburg","mirroradmin # tenet.ac.za",1,za,"secure_mirror_from_master" From 1b8ba70c63329c96468e58bcbc7aa2c825f87a99 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 21 May 2024 19:56:59 +0000 Subject: [PATCH 074/546] Allow customizing curl handle options. git-svn-id: https://svn.r-project.org/R/trunk@86577 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/urltools.R | 68 +++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/src/library/tools/R/urltools.R b/src/library/tools/R/urltools.R index cdbbffc67fe..92c1f32d73d 100644 --- a/src/library/tools/R/urltools.R +++ b/src/library/tools/R/urltools.R @@ -513,7 +513,7 @@ function(db, remote = TRUE, verbose = FALSE, parallel = FALSE, pool = NULL) } ## if((s != "200") && use_curl) { - g <- .curl_GET_status(u) + g <- .curl_GET_status_code(u) if(g == "200") { s <- g msg <- "OK" @@ -777,7 +777,8 @@ function(urls, verbose = FALSE, pool = NULL) { .curl_multi_run_worker <- -function(urls, nobody = FALSE, verbose = FALSE, pool = NULL) +function(urls, nobody = FALSE, verbose = FALSE, pool = NULL, + opts = NULL) { ## Use 'nobody = TRUE' to fetch only headers. @@ -810,6 +811,15 @@ function(urls, nobody = FALSE, verbose = FALSE, pool = NULL) if(is.null(pool)) pool <- curl::new_pool() + if(is.null(opts)) + opts <- .curl_handle_default_opts + opts <- c(opts, list(nobody = nobody)) + timeout <- as.integer(getOption("timeout")) + if(!is.na(timeout) && (timeout > 0L)) + opts <- c(opts, + list(connecttimeout = timeout, + timeout = timeout)) + bar <- .progress_bar(if (verbose) length(urls), msg = "fetching ") out <- vector("list", length(urls)) @@ -817,17 +827,7 @@ function(urls, nobody = FALSE, verbose = FALSE, pool = NULL) for(i in seq_along(out)) { u <- urls[[i]] h <- curl::new_handle(url = u) - curl::handle_setopt(h, - nobody = nobody, - cookiesession = 1L, - followlocation = 1L, - http_version = 2L, - ssl_enable_alpn = 0L) - timeout <- as.integer(getOption("timeout")) - if(!is.na(timeout) && (timeout > 0L)) - curl::handle_setopt(h, - connecttimeout = timeout, - timeout = timeout) + curl::handle_setopt(h, .list = opts) if(grepl("^https?://github[.]com", u) && nzchar(a <- Sys.getenv("GITHUB_PAT", ""))) { curl::handle_setheaders(h, "Authorization" = paste("token", a)) @@ -859,33 +859,43 @@ function(urls, nobody = FALSE, verbose = FALSE, pool = NULL) out } -.curl_GET_status <- -function(u, verbose = FALSE) +.curl_GET_status_code <- +function(u, verbose = FALSE, opts = NULL) { if(verbose) message(sprintf("processing %s", u)) + + if(is.null(opts)) + opts <- .curl_handle_default_opts + timeout <- as.integer(getOption("timeout")) + if(!is.na(timeout) && (timeout > 0L)) + opts <- c(opts, + list(connecttimeout = timeout, + timeout = timeout)) + ## Configure curl handle for better luck with JSTOR URLs/DOIs. ## Alternatively, special-case requests to ## https?://doi.org/10.2307 ## https?://www.jstor.org h <- curl::new_handle() - curl::handle_setopt(h, - cookiesession = 1, - followlocation = 1, - http_version = 2L, - ssl_enable_alpn = 0) - timeout <- as.integer(getOption("timeout")) - if(!is.na(timeout) && (timeout > 0L)) - curl::handle_setopt(h, - connecttimeout = timeout, - timeout = timeout) + curl::handle_setopt(h, .list = opts) if(startsWith(u, "https://github.com") && nzchar(a <- Sys.getenv("GITHUB_PAT", ""))) curl::handle_setheaders(h, "Authorization" = paste("token", a)) + g <- tryCatch(curl::curl_fetch_memory(u, handle = h), error = identity) - if(inherits(g, "error")) - -1L - else - g$status_code + .curl_response_status_code(g) +} + +.curl_response_status_code <- +function(x) +{ + if(inherits(x, "error")) -1L else x$status_code } + +.curl_handle_default_opts <- + list(cookiesession = 1L, + followlocation = 1L, + http_version = 2L, + ssl_enable_alpn = 0L) From 23fa34cd057ff6ebe9824dfa7783429e1083437e Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 21 May 2024 20:22:59 +0000 Subject: [PATCH 075/546] more mocOS tweaks git-svn-id: https://svn.r-project.org/R/trunk@86578 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 84cf1f9b3c4..3b28ac554d5 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -1798,8 +1798,8 @@ versions can be installed together.} of the @R{} framework which it finds installed. This can be avoided by using @command{pkgutil --forget} (see the previous section). However, note that different versions are installed under -@file{/Library/Frameworks/R.framework/Versions} as @file{4.4} (or -@file{4.4-arm64}), @file{4.3} and so on, so it is not possible to have +@file{/Library/Frameworks/R.framework/Versions} as @file{4.4-arm64} (or +@file{4.4-x86_64}), @file{4.3} and so on, so it is not possible to have different @samp{4.x.y} versions installed for the same @samp{x} and CPU type. @@ -5189,7 +5189,7 @@ partially or completely remove them. The Command Line Tools provide C and C++ compilers derived from @I{LLVM}'s @command{clang} but nowadays known as `Apple clang' with different -versioning (so Apple clang 14 is unrelated to @I{LLVM} clang 14). +versioning (so Apple clang 15 is unrelated to @I{LLVM} clang 15). @item A Fortran compiler. @xref{Fortran compilers}. @@ -5308,7 +5308,7 @@ CFLAGS="-falign-functions=8 -g -O2" is needed to inter-work with @command{gfortran} without segfaulting in some packages. Some builds of @command{gfortran} have targetted the current version of macOS (unlike @command{clang}), causing linker -warnings) to avoid these use +warnings: to avoid these use @example FFLAGS="-g -O2 -mmacosx-version-min=11.0" FCFLAGS="-g -O2 -mmacosx-version-min=11.0" @@ -5331,14 +5331,14 @@ requirements such as component @command{pkgconfig} (and to set @c svn was in CLT 11.3.1, even in the opensource.apple.com repository A subversion client can be obtained from -@uref{https://mac.r-project.org/tools/}, for example by +@uref{https://mac.r-project.org/tools/}, for example by (Apple Silicon) @example curl -OL https://mac.r-project.org/tools/subversion-1.14.1-darwin.20-arm64.tar.gz tar xf subversion-1.14.1-darwin.20-arm64.tar.gz sudo cp subversion-1.14.1-darwin-20-arm64/svn $LOCAL/bin @end example @noindent -or +or (Intel) @example curl -OL https://mac.r-project.org/tools/subversion-1.14.0-darwin15.6.tar.gz tar xf subversion-1.14.0-darwin15.6.tar.gz @@ -5590,10 +5590,10 @@ Checking packages thoroughly requires @I{Ghostscript} (part of the full the @file{bin} directory of a binary installation of @R{}, usually @file{/Library/@/Frameworks/@/R.framework/@/Resources/@/bin/@/qpdf}). -@command{R CMD check --as-cran} makes use of `HTML Tidy'. macOS has -a version in @file{/usr/bin/tidy} dating from 2006 which is far too -old and is skipped. Up-to-date versions can be installed from -@uref{http://binaries.html-tidy.org/}. +@command{R CMD check --as-cran} makes use of `HTML Tidy'. macOS at the +time of writing has a version in @file{/usr/bin/tidy} dating from 2006 +which is far too old. Up-to-date versions can be +installed from @uref{http://binaries.html-tidy.org/}. One macOS quirk is that the default path has @file{/usr/local/bin} after @file{/usr/bin}, contrary to common practice on Unix-alikes. This means @@ -5805,9 +5805,9 @@ selected by the option @example ./configure --enable-R-framework @end example - +@noindent (This is intended to be used with an Apple toolchain: others may not -support frameworks correctly but those from @I{LLVM} do.) +support frameworks correctly but those from @I{LLVM} have done so.) It is only needed if you want to build @R{} for use with the @Rapp{} console, and implies @option{--enable-R-shlib} to build @R{} as a @@ -5926,7 +5926,7 @@ PKG_LIBS = /usr/local/llvm/lib/libc++.a /usr/local/llvm/lib/libc++abi.a in @file{src/Makevars}. It would also be possible to static link the Fortran runtime libraries @file{libgfortran.a} and @file{libquadmath.a} should the Fortran compiler have later versions (but @command{gfortran} -8--13 all have version @code{5}). +8--14 all have version @code{5}). @end itemize @noindent The @acronym{CRAN} binary packages are built with the Apple compiler on From 6eac3590d0c895f353d329d34e62262abd48b404 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 21 May 2024 21:22:33 +0000 Subject: [PATCH 076/546] Add some very preliminatry tools for working with WRE API annotations. git-svn-id: https://svn.r-project.org/R/trunk@86579 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/apitools.R | 242 +++++++++++++++++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 src/library/tools/R/apitools.R diff --git a/src/library/tools/R/apitools.R b/src/library/tools/R/apitools.R new file mode 100644 index 00000000000..ed9c592ff43 --- /dev/null +++ b/src/library/tools/R/apitools.R @@ -0,0 +1,242 @@ +# File src/library/tools/R/apitools.R +# Part of the R package, https://www.R-project.org +# +# Copyright (C) 2024 The R Core Team +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License is available at +# https://www.R-project.org/Licenses/ + +## +## Work out the function API from information in WRE +## + +## eventually either install this or get from svn: +## wreloc <- file.path(R.home("doc"), "R-ext.texi") +## WRE(newpath) forces a new load with the new path. + +apidata <- + list2env( + list( + wrelines = NULL, + wreloc = "https://svn.r-project.org/R/trunk/doc/manual/R-exts.texi", + fapi = NULL, + rfuns = NULL)) + +resetAPI <- function(newloc = "") { + if (newloc != "") + apidata$wreloc <- newloc + apidata$wrelines <- NULL + apidata$fapi <- NULL + ## reset rfuns also? +} + +WRE <- function() { + if (is.null(apidata$wrelines)) + apidata$wrelines <- readLines(apidata$wreloc) + apidata$wrelines +} + +unmap <- function(x) sub("^Rf_", "", gsub("^_|_$", "", trimws(x))) + +getOneFunAPI <- function(apitype) { + wrelines <- WRE() + fpat <- sprintf("^@(%s)fun +", apitype) + hpat <- sprintf("^@(%s)hdr +", apitype) + funs <- sub(fpat, "", grep(fpat, wrelines, value = TRUE)) + hdrs <- sub(hpat, "", grep(hpat, wrelines, value = TRUE)) + wAPI <- data.frame(name = funs, loc = rep("WRE", length(names))) + getHdrAPI <- function(hdr) { + hfuns <- getFunsHdr(file.path(R.home("include"), hdr)) + data.frame(name = hfuns, loc = rep(hdr, length(hfuns))) + } + hAPI <- lapply(hdrs, getHdrAPI) + val <- rbind(wAPI, do.call(rbind, hAPI)) + val$apitype <- rep(apitype, nrow(val)) + val$unmapped <-unmap(val$name) + rownames(val) <- NULL + val +} + +getFunAPI <- function() { + apitypes <- c("api", "eapi", "emb") + val <- do.call(rbind, lapply(apitypes, getOneFunAPI)) + val <- unique(val) + val <- by(val, + list(val$unmapped), + ## picks max WRE > api > eapi > emb + ## picks first if unmapped and mapped are in WRE + function(x) if (nrow(x) > 1) x[1, ] else x, + simplify = FALSE) + val <- do.call(rbind, val) + val$unmapped <- NULL ## not needed in final output + rownames(val) <- NULL + val +} + +funAPI <- function() { + if (is.null(apidata$fapi)) + apidata$fapi <- getFunAPI() + apidata$fapi +} + +## getFunsHdr tries to get the functions declared in a header file +## without additional tools beyond cc -E. Using a proper +## header-parsing tool would be more accurate, but this seems adequate +## for now. +getFunsHdr <- function(fpath, lines) { + if (missing(lines)) { + lines <- readLines(fpath) + name <- basename(fpath) + } + else name <- NULL + + ## NORET has to be handled before ccE since what it expands into varies + lines <- ifelse(grepl("^#", lines), + lines, + gsub(r"{.*\s*NORET\s*}", " ", lines)) + + lines <- lines[! grepl("^#\\s*error", lines)] ## for GraphicsDevice.h + + lines <- ccE(lines) + lines <- dropBraces(lines) + + ## these could be incorporated into the regex + lines <- gsub(r"{\s*(const|extern|long|unsigned)\s*}", "", lines) + lines <- sub(r"{^\s*(\w*[(])}", "void \\1", lines) + lines <- gsub(r"{\(\s*\*\s*(\w+)\s*\)}", "(\\1)", lines) + + ## original from SO: https://stackoverflow.com/questions/476173/regex-to-pull-out-c-function-prototype-declarations + ## funcRegexp <- r"{^\s*(?:(?:inline|static)\s+){0,2}(?!else|typedef|return)\w+\s+\*?\s*(\w+)\s*\([^0]+\)\s*;?}" + ## allow for parens around function name + ## make closing paren for arguments optional + funcRegexp <- r"{^\s*(?:(?:inline|static)\s+){0,2}(?!else|typedef|return)\w+\s*\*?\s*\(?(\w+)\)?\s*\([^0]+\)?\s*;?}" + + m <- gregexec(funcRegexp, lines, perl = TRUE) + v <- regmatches(lines, m) + val <- sapply(v[lengths(v) > 0], `[[`, 2) + val <- unique(as.character(val)) + + ## drop halucinations + val <- val[! (val %in% letters | val %in% LETTERS)] + val <- val[! grepl("_t$", val)] + val <- val[! grepl("user_(unif|norm)", val)] + val <- val[! grepl("Quartz|Win32", val)] + + val +} + +ccE <- function(lines, include = R.home("include"), clean = TRUE) { + if (Sys.which("cc") == "") + stop("'cc' is not on the path") + tfile <- tempfile(fileext = ".h") + on.exit(unlink(tfile)) + writeLines(lines, tfile) + cmd <- sprintf("cc -E -I%s %s", include, tfile) + val <- system(cmd, intern=TRUE) + if (clean) + ccEclean(val, tfile) + else val +} + +ccEclean <- function(lines, pattern = "Rtmp") { + fline <- grepl("^#", lines) + keep <- grepl(pattern, lines[fline]) + len <- diff(c(which(fline), length(lines) + 1)) + keep <- unlist(mapply(rep, keep, len, USE.NAMES = FALSE)) + lines <- lines[keep & ! fline] + lines +} + +dropBraces <- function(lines) { + ## drop {...} fully within a line + lines <- sub("[{].*[}]", " ", lines) + + ## drop {...} crossing several lines + start <- grepl("[{]", lines) + end <- grepl("[}]", lines) + ## could check for balance + lines <- lines[cumsum(start - end) == 0 | start | end] + lines <- sub("[{].*", "", lines) ## keep stuff before { + lines <- lines[! grepl(".*[}]", lines)] ## don't keep stuff after } + + lines +} + + +## +## Check a shared library's use of R entry points +## + +checkLibRfuns <- function(lpath) { + ldata <- readFileSyms(lpath) + lsyms <- subset(ldata, type == "U")$name + lsyms <- inRfuns(lsyms) + lsyms <- data.frame(name = lsyms, unmapped = unmap(lsyms)) + api <- transform(funAPI(), unmapped = unmap(name), name = NULL, loc = NULL) + val <- merge(lsyms, api, all.x = TRUE) + val <- val[order(val$api), ] + rownames(val) <- NULL + val +} + +readFileSyms <- function(fpath) { + ## this uses nm + ## could try objdump if nm doesn't work + v <- tools:::read_symbols_from_object_file(fpath) + if (is.null(v)) + data.frame(name = character(0), type = character(0)) + else as.data.frame(v)[c("name", "type")] +} + +## crude approach based on string matching +inRfunsCrude <- function(syms) { + syms <- union(syms[syms == toupper(syms)], + grep("^_?Rf?_", syms, value = TRUE)) + pat <- "R_MB_CUR_MAX|R_BaseNamespace|R_BlankScalarString|R_BlankString" + pat <- sprintf("%s|R_CStackDir|R_CStackLimit|R_CStackStart", pat) + pat <- sprintf("%s|R_Consolefile|R_CurrentExpression|R_Interactive", pat) + pat <- sprintf("%s|R_Outputfile|R_Srcref|R_TempDir", pat) + pat <- sprintf("%s|R_compact_.*_class|R_ignore_SIGPIPE", pat) + pat <- sprintf("%s|R_interrupts_pending|R_interrupts_suspended", pat) + pat <- sprintf("%s|R_isForkedChild", pat) + pat <- sprintf("%s|R_NilValue|R_MissingArg|R_Visible", pat) + pat <- sprintf("%s|R_.*Symbol$|R_dot_|R_Na", pat) + pat <- sprintf("%s|R_NilValue|R_GlobalEnv|R_BaseEnv|R_EmptyEnv", pat) + pat <- sprintf("%s|R_(Pos|Neg)Inf|R_.*Value$|R_.*Handlers$", pat) + syms[! grepl(pat, syms)] +} + +## approach based on computing the entry points in the executable and core libs +## fall back to the crude approach if entry points can't be found +inRfuns <- function(syms) { + rfuns <- Rfuns() + if (length(rfuns) == 0) + inRfunsCrude(syms) + else + syms[unmap(syms) %in% unmap(rfuns)] +} + +getRfuns <- function() { + pat <- sprintf("(\\.dylib|%s)$", .Platform$dynlib.ext) + ofiles <- c(file.path(R.home("bin"), "exec", "R"), + dir(R.home("lib"), pattern = pat, full.names = TRUE), + dir(R.home("modules"), pattern = pat, full.names = TRUE)) + fdata <- do.call(rbind, lapply(ofiles, readFileSyms)) + subset(fdata, type == "T")$name +} + +Rfuns <- function() { + if (is.null(apidata$rfuns)) + apidata$rfuns <- getRfuns() + apidata$rfuns +} From f9cc42e54379c09a735cc977ca5d49a4ebb25b92 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 21 May 2024 21:43:47 +0000 Subject: [PATCH 077/546] News entry for WRE annotations. git-svn-id: https://svn.r-project.org/R/trunk@86580 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 34fd0de093f..514c842da28 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -66,6 +66,13 @@ \item The internal code for changing the parent of an environment now signals an error if the new parent is not an environment or if the change would create a cycle in the parent chain. + + \item The \sQuote{Writing R Extensions} \I{Texinfo} source now + contains very experimental annotations for more clearly + identifying the API status of C entry points. These annotations + are used to produce indices for API, experimental API, and + embedded API entry points in the rendered versions. This is very + preliminary and may be dropped if a better approach emerges. } } From c407f826eefb1aff3cead7a920cd64280a202818 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 22 May 2024 00:16:05 +0000 Subject: [PATCH 078/546] Install info from WRE in rools package directory at build time. git-svn-id: https://svn.r-project.org/R/trunk@86581 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/Makefile.in | 8 +++++++- src/library/tools/R/apitools.R | 11 +++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/library/tools/Makefile.in b/src/library/tools/Makefile.in index 786a6d78937..dcb03b6d0d4 100644 --- a/src/library/tools/Makefile.in +++ b/src/library/tools/Makefile.in @@ -15,6 +15,9 @@ DISTFILES = DESCRIPTION.in Makefile.in Makefile.win NAMESPACE pkg = tools +WRE_DATA = $(top_builddir)/library/$(pkg)/wre.txt +WRE_SRC = $(top_srcdir)/doc/manual/R-exts.texi + RSRC = `LC_COLLATE=C ls $(srcdir)/R/*.R` ## avoid bootstrapping issue with internal tzcode. @@ -27,7 +30,7 @@ update: ## This is deliberately conservative: -nt seems to work differently in some shells ## We first use mkdesc2 (with date) to install the DESCRIPTION, then re-install -all: Makefile DESCRIPTION +all: Makefile DESCRIPTION $(WRE_DATA) @$(ECHO) "building package '$(pkg)'" @$(MKINSTALLDIRS) $(top_builddir)/library/$(pkg) @$(MAKE) mkR1 mkdesc2 @@ -44,6 +47,9 @@ all: Makefile DESCRIPTION mkR: mkR1 +$(WRE_DATA): $(WRE_SRC) + grep -E '^@(api|eapi|emb)(fun|var|hdr)' $< > $@ + include $(top_srcdir)/share/make/basepkg.mk ## Note that R_COMPILER_SUPPRESS_ALL is now on by default diff --git a/src/library/tools/R/apitools.R b/src/library/tools/R/apitools.R index ed9c592ff43..7ca505e3148 100644 --- a/src/library/tools/R/apitools.R +++ b/src/library/tools/R/apitools.R @@ -28,7 +28,7 @@ apidata <- list2env( list( wrelines = NULL, - wreloc = "https://svn.r-project.org/R/trunk/doc/manual/R-exts.texi", + wreloc = NULL, fapi = NULL, rfuns = NULL)) @@ -41,8 +41,15 @@ resetAPI <- function(newloc = "") { } WRE <- function() { - if (is.null(apidata$wrelines)) + if (is.null(apidata$wrelines)) { + if (is.null(apidata$wreloc)) { + apidata$wreloc <- system.file(package = "tools", "wre.txt") + if (apidata$wreloc == "") + apidata$wreloc <- + "https://svn.r-project.org/R/trunk/doc/manual/R-exts.texi" + } apidata$wrelines <- readLines(apidata$wreloc) + } apidata$wrelines } From a883fcd38bdf2257d0940c9dc7753094e20cc850 Mon Sep 17 00:00:00 2001 From: ripley Date: Wed, 22 May 2024 07:56:52 +0000 Subject: [PATCH 079/546] more macOS tweaks git-svn-id: https://svn.r-project.org/R/trunk@86584 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 3b28ac554d5..26cf517d563 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -5129,8 +5129,8 @@ Windows). @section macOS @cindex macOS -The instructions here are for Intel 64-bit (@cputype{x86_64}) or `Apple -Silicon' (@cputype{arm64}) builds on macOS 11 (@I{Big Sur}), 12 +The instructions here are for `Apple Silicon' (@cputype{arm64}) or Intel +64-bit (@cputype{x86_64}) builds on macOS 11 (@I{Big Sur}), 12 (@I{Monterey)}, 13 (@I{Ventura}), 14 (@I{Sonoma}) and likely later. (They may well work on Intel macOS 10.14 or 10.15, but are untested there.) @@ -5725,21 +5725,20 @@ includes @code{Tktable} and the @acronym{CRAN} package @c details see @uref{https://www.macstrategy.com/article.php?3}.} and @c distribution of Java for all platforms changed in 2018. -macOS does not comes with an installed Java runtime (@abbr{JRE}) and a macOS -upgrade may remove one if already installed: it is intended to be +macOS does not comes with an installed Java runtime (@abbr{JRE}) and a +macOS upgrade may remove one if already installed: it is intended to be installed at first use. Check if a @abbr{JRE} is installed by running @command{java -version} in a @command{Terminal} window: if Java is not installed@footnote{In the unlikely event that the version reported does not start with @code{1.8.0}, @code{11} or higher you need to update your -Java.} this should prompt you to install it.@footnote{Not at the time of -writing for @cputype{arm64}.} Builds of @I{OpenJDK} may also be available, -e.g.@: from @uref{https://adoptium.net, Adoptium}, -@uref{https://www.azul.com/downloads/zulu-community/, Azul} or -@uref{https://jdk.java.net/}. We recommend you install a version with -long-term support, e.g.@: 11, 17 or 21 but not -12--16, 18--20, 22 which have/had a 6-month lifetime. (Note that these -sources may use unusual designations for Intel macOS builds such as -@code{x86 64-bit} and @code{x64}.) +Java.} this may prompt you to install it.@footnote{Not at the time of +writing for @cputype{arm64}.} Builds of @I{OpenJDK} may also be +available, e.g.@: from @uref{https://adoptium.net, +Adoptium}@footnote{which website works with Safari but not some other +browsers.}. We recommend you install a version with long-term support, +e.g.@: 17 or 21 but not 18--20, 22 which have/had a 6-month lifetime. +(Note that Java distribution sites may use unusual designations for +Intel macOS builds such as @code{aarch64} and @code{x64}.) Binary distributions of @R{} are built against a specific version (e.g.@: 11.0.18 or 17.0.1) of Java so @command{sudo R CMD javareconf} From 7a7daaea0a8e462118e2f7e89c53820436c3960e Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 22 May 2024 10:28:01 +0000 Subject: [PATCH 080/546] Move creating wre.txt file after creating install dirs. git-svn-id: https://svn.r-project.org/R/trunk@86585 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/tools/Makefile.in b/src/library/tools/Makefile.in index dcb03b6d0d4..f8574402fcc 100644 --- a/src/library/tools/Makefile.in +++ b/src/library/tools/Makefile.in @@ -30,10 +30,10 @@ update: ## This is deliberately conservative: -nt seems to work differently in some shells ## We first use mkdesc2 (with date) to install the DESCRIPTION, then re-install -all: Makefile DESCRIPTION $(WRE_DATA) +all: Makefile DESCRIPTION @$(ECHO) "building package '$(pkg)'" @$(MKINSTALLDIRS) $(top_builddir)/library/$(pkg) - @$(MAKE) mkR1 mkdesc2 + @$(MAKE) mkR1 mkdesc2 $(WRE_DATA) @$(MAKE) mksrc @if ! test -f $(top_builddir)/library/$(pkg)/R/$(pkg); then \ $(INSTALL_DATA) all.R $(top_builddir)/library/$(pkg)/R/$(pkg); \ From 609d5ad1146d08b586a997586976b3fb069ed76a Mon Sep 17 00:00:00 2001 From: ripley Date: Wed, 22 May 2024 10:35:39 +0000 Subject: [PATCH 081/546] updates on Java support git-svn-id: https://svn.r-project.org/R/trunk@86586 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 64 ++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 26cf517d563..e7056d7c281 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -3543,9 +3543,9 @@ development files installed. The build process looks for Java support on the host system, and if it finds it sets some settings which are useful for Java-using packages -(such as @CRANpkg{rJava} and @CRANpkg{JavaGD}: these require a full -@abbr{JDK}). This check can be suppressed by configure option -@option{--disable-java}. +(such as @CRANpkg{rJava} and @CRANpkg{JavaGD}: installing these from +source requires a full @abbr{JDK}). This check can be suppressed by +configure option @option{--disable-java}. @enindex JAVA_HOME Configure variable @env{JAVA_HOME} can be set to point to a specific @abbr{JRE}/@abbr{JDK}, on the @command{configure} command line or in the environment. @@ -3596,12 +3596,10 @@ Java 8 aka 1.8.0). `Non-server' Oracle distributions of Java as from version 11 are of a full @abbr{JDK}. However, Linux distributions can be confusing: for example -Fedora 34 had +Fedora 38 had @example java-1.8.0-openjdk java-1.8.0-openjdk-devel -java-openjdk -java-openjdk-devel java-11-openjdk java-11-openjdk-devel java-17-openjdk @@ -3615,7 +3613,7 @@ where the @code{-devel} @abbr{RPM}s are needed to complete the @abbr{JDK}. Debia @example sudo apt install default-jdk @end example -@c https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-18-04 +@c https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-22-04 @node Other compiled languages, , Java support, Useful libraries and programs @subsection Other compiled languages @@ -5729,19 +5727,31 @@ macOS does not comes with an installed Java runtime (@abbr{JRE}) and a macOS upgrade may remove one if already installed: it is intended to be installed at first use. Check if a @abbr{JRE} is installed by running @command{java -version} in a @command{Terminal} window: if Java is not -installed@footnote{In the unlikely event that the version reported does -not start with @code{1.8.0}, @code{11} or higher you need to update your -Java.} this may prompt you to install it.@footnote{Not at the time of -writing for @cputype{arm64}.} Builds of @I{OpenJDK} may also be -available, e.g.@: from @uref{https://adoptium.net, -Adoptium}@footnote{which website works with Safari but not some other -browsers.}. We recommend you install a version with long-term support, -e.g.@: 17 or 21 but not 18--20, 22 which have/had a 6-month lifetime. -(Note that Java distribution sites may use unusual designations for -Intel macOS builds such as @code{aarch64} and @code{x64}.) +installed on an Intel Mac this may prompt you to install it. We +recommend you install a version with long-term support, e.g.@: 17 or +21@footnote{The planned nextLTS release is 25 in September 2025. Java 8 +@emph{aka} 1.8.0 is still LTS but some packages require 11 or later.} +but not 18--20, 22--24 with a 6-month lifetime. + +The currently simplest way to install Java is from +@uref{https://adoptium.net, Adoptium}@footnote{which website works with +Safari but not some other browsers.}: this installs into an +Apple-standard location and so works with @command{/usr/bin/java}. Other +builds are available from +@uref{https://www.azul.com/downloads/zulu-community/?os=macos&architecture=arm-64-bit&package=jdk} +and from @I{OpenJDK} at @uref{https://jdk.java.net/}, for which +@env{JAVA_HOME} may need to be set both when configuring @R{} and at +runtime. Note that Java distribution sites may use unusual designations +for macOS CPUs such as @code{AArch64}, @code{x64} or @code{x86 +64-bit}. + Binary distributions of @R{} are built against a specific version -(e.g.@: 11.0.18 or 17.0.1) of Java so @command{sudo R CMD javareconf} +(e.g.@: 11.0.18 or 17.0.1) of Java so +@example +sudo R CMD javareconf +@end example +@noindent will likely be needed to be run before using Java-using packages. To see what compatible versions of Java are currently installed, run the @@ -5758,7 +5768,7 @@ between these, both when @R{} is built from the sources and when Configuring and building @R{} both looks for a @abbr{JRE} and for support for compiling @abbr{JNI} programs (used to install packages @CRANpkg{rJava} and @CRANpkg{JavaGD}); the latter requires a @abbr{JDK} (Java @abbr{SDK}). Most -distributions of Java 9 or later are of a full @abbr{JDK}. +distributions of Java 11 or later are of a full @abbr{JDK}. The build process tries to fathom out what @abbr{JRE}/@abbr{JDK} to use, but it may need some help, e.g.@: by setting environment variable @@ -5774,20 +5784,8 @@ in @file{config.site}. For Java 21 from @uref{https://jdk.java.net/} JAVA_HOME=/path/to/jdk-21.jdk/Contents/Home @end example -For an @cputype{arm64} build, the earliest Java version which is -officially supported is 17. The currently simplest way to install Java -is from @uref{https://adoptium.net, Adoptium} (who call the architecture -@cputype{aarch64}): this installs into an Apple-standard location and so -works with @command{/usr/bin/java}. Other builds are available from -@uref{https://www.azul.com/downloads/zulu-community/?os=macos&architecture=arm-64-bit&package=jdk} -and from @I{OpenJDK} at @uref{https://jdk.java.net/}, for which -@env{JAVA_HOME} may need to be set both when configuring @R{} and at -runtime. - -@c To use Java (specifically, binary package @CRANpkg{rJava}) with a -@c @acronym{CRAN} (@cputype{x86_64}) binary distribution of @R{} on -@c @cputype{arm64} macOS, install an Intel build of a Java @abbr{JRE} from -@c one of the sites linked above, then run @command{sudo R CMD javareconf}. +@c For an @cputype{arm64} build, the earliest Java version which is +@c officially supported is 17. @c jdk.java.net no longer has Java 11 nor 17 LTS builds. From 60160696e5f3acf1e0682708825c77da6a4bd9ce Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 22 May 2024 13:57:38 +0000 Subject: [PATCH 082/546] Add checkPkgRfuns and checkAllPkgFuns. git-svn-id: https://svn.r-project.org/R/trunk@86587 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/apitools.R | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/library/tools/R/apitools.R b/src/library/tools/R/apitools.R index 7ca505e3148..5bd15dd70c6 100644 --- a/src/library/tools/R/apitools.R +++ b/src/library/tools/R/apitools.R @@ -192,6 +192,7 @@ checkLibRfuns <- function(lpath) { api <- transform(funAPI(), unmapped = unmap(name), name = NULL, loc = NULL) val <- merge(lsyms, api, all.x = TRUE) val <- val[order(val$api), ] + val$unmapped <- NULL ## not needed in final output rownames(val) <- NULL val } @@ -206,6 +207,7 @@ readFileSyms <- function(fpath) { } ## crude approach based on string matching +## **** this is to crude -- needs to allow more inRfunsCrude <- function(syms) { syms <- union(syms[syms == toupper(syms)], grep("^_?Rf?_", syms, value = TRUE)) @@ -247,3 +249,37 @@ Rfuns <- function() { apidata$rfuns <- getRfuns() apidata$rfuns } + + +## +## Check an installed package's use of R entry points +## + +checkPkgRfuns <- function(pkg, lib.loc = NULL) { + libdir <- system.file("libs", package = pkg, lib.loc = lib.loc) + libs <- Sys.glob(file.path(libdir, sprintf("*%s", .Platform$dynlib.ext))) + if (length(libs) > 0) { + val <- do.call(rbind, lapply(libs, checkLibRfuns)) + unique(val) + } + else NULL +} + +checkAllPkgFuns <- function(lib.loc = NULL, priority = NULL, + all = FALSE, verbose = FALSE) { + p <- rownames(installed.packages(lib.loc = lib.loc, priority = priority)) + checkOne <- function(pkg) { + if (verbose) cat(pkg, "\n") + data <- checkPkgRfuns(pkg, lib.loc = lib.loc) + if (! is.null(data)) + transform(data, pkg = rep(pkg, nrow(data))) + } + val <- lapply(rownames(installed.packages(lib.loc = "library")), checkOne) + val <- do.call(rbind, val) + if (! all) + val <- val[is.na(val$apitype), ] + rownames(val) <- NULL + val +} + + From 6e904610d8e4f3fcb3cacc9ce751673b33ecf057 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 22 May 2024 18:29:34 +0000 Subject: [PATCH 083/546] Cleanups and some renaming. git-svn-id: https://svn.r-project.org/R/trunk@86588 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/apitools.R | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/library/tools/R/apitools.R b/src/library/tools/R/apitools.R index 5bd15dd70c6..2d607e76d8b 100644 --- a/src/library/tools/R/apitools.R +++ b/src/library/tools/R/apitools.R @@ -184,7 +184,7 @@ dropBraces <- function(lines) { ## Check a shared library's use of R entry points ## -checkLibRfuns <- function(lpath) { +checkLibAPI <- function(lpath) { ldata <- readFileSyms(lpath) lsyms <- subset(ldata, type == "U")$name lsyms <- inRfuns(lsyms) @@ -255,29 +255,30 @@ Rfuns <- function() { ## Check an installed package's use of R entry points ## -checkPkgRfuns <- function(pkg, lib.loc = NULL) { +checkPkgAPI <- function(pkg, lib.loc = NULL, all = FALSE) { libdir <- system.file("libs", package = pkg, lib.loc = lib.loc) libs <- Sys.glob(file.path(libdir, sprintf("*%s", .Platform$dynlib.ext))) if (length(libs) > 0) { - val <- do.call(rbind, lapply(libs, checkLibRfuns)) - unique(val) + val <- do.call(rbind, lapply(libs, checkLibAPI)) + if (! all) + val <- val[is.na(val$apitype), ] + val <- unique(val) + rownames(val) <- NULL + val } else NULL } -checkAllPkgFuns <- function(lib.loc = NULL, priority = NULL, +checkAllPkgsAPI <- function(lib.loc = NULL, priority = NULL, all = FALSE, verbose = FALSE) { p <- rownames(installed.packages(lib.loc = lib.loc, priority = priority)) checkOne <- function(pkg) { if (verbose) cat(pkg, "\n") - data <- checkPkgRfuns(pkg, lib.loc = lib.loc) + data <- checkPkgAPI(pkg, lib.loc = lib.loc) if (! is.null(data)) transform(data, pkg = rep(pkg, nrow(data))) } - val <- lapply(rownames(installed.packages(lib.loc = "library")), checkOne) - val <- do.call(rbind, val) - if (! all) - val <- val[is.na(val$apitype), ] + val <- do.call(rbind, lapply(p, checkOne)) rownames(val) <- NULL val } From 6c41af65edbf093484fca8f00341ff28b20a6ad1 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 22 May 2024 19:24:08 +0000 Subject: [PATCH 084/546] Add some more API entries for use in base and recommended packages. git-svn-id: https://svn.r-project.org/R/trunk@86589 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 46e5909102d..d39e60929b4 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13060,8 +13060,8 @@ be shared by any @code{STRSXP} needing an element representing the same string. @R{} maintains a global cache of @code{CHARSXP}s so that there is only ever one @code{CHARSXP} representing a given string in memory. -@findex mkChar -@findex mkCharLen +@apifun mkChar +@apifun mkCharLen You can obtain a @code{CHARSXP} by calling @code{mkChar} and providing a @abbr{NUL}-terminated C-style string. This function will return a pre-existing @code{CHARSXP} if one with a matching string already exists, otherwise @@ -13323,9 +13323,12 @@ Function @code{R_BindingIsLocked} corresponds to @R{}'s @code{bindingIsLocked} @eapifun R_MakeActiveBinding @eapifun R_unLockBinding +The C function @code{inherits} corresponds to the @R{} function of the +same name. +@apifun inherits + @node Named objects and copying, , Some convenience functions, Handling R objects in C @subsection Named objects and copying -@apifun duplicate @cindex Copying objects [The @code{NAMED} mechanism has been replaced by reference counting.] @@ -13346,7 +13349,10 @@ usual @R{} semantics are to apply. Note that whereas @code{.C} and @code{.Fortran} do copy their arguments (unless the dangerous @code{dup = FALSE} is used), @code{.Call} and @code{.External} do not. So @code{duplicate} is commonly called on arguments to @code{.Call} before -modifying them. +modifying them. If only the sop level is modified it may suffice to call +@code{shallow_duplicate}. +@apifun duplicate +@apifun shallow_duplicate However, at least some of this copying is unneeded. In the first assignment shown, @code{x <- 1:10}, @R{} first creates an object with @@ -13811,7 +13817,7 @@ and evaluating, consider the following fragment of UNPROTECT(1); @end example @findex allocList -@findex SET_TAG +@apifun SET_TAG @noindent At this point @code{CAR(a)} is the @R{} object to be printed, the @@ -14506,8 +14512,8 @@ have to fully materialize the object. @node Character encoding issues, , Vector accessor functions, System and foreign language interfaces @section Character encoding issues -@findex translateChar -@findex translateCharUTF8 +@apifun translateChar +@apifun translateCharUTF8 @code{CHARSXP}s can be marked as coming from a known encoding (Latin-1 or UTF-8). This is mainly intended for human-readable output, and most packages can just treat such @code{CHARSXP}s as a whole. However, if @@ -14529,8 +14535,8 @@ Both @code{translateChar} and @code{translateCharUTF8} will translate any input, using escapes such as @samp{} and @samp{} to represent untranslatable parts of the input. -@findex getCharCE -@findex mkCharCE +@apifun getCharCE +@apifun mkCharCE There is a public interface to the encoding marked on @code{CHARSXPs} @emph{via} @@ -14555,7 +14561,7 @@ string is treated as a series of bytes. (See the comments under Function -@findex reEnc +@apifun reEnc @example const char *reEnc(const char *x, cetype_t ce_in, cetype_t ce_out, int subst); @@ -14570,7 +14576,7 @@ invalid input: this is done byte-by-byte with @code{1} indicates to output hex of the form @code{}, and @code{2} to replace by @code{.}, with any other value causing the byte to produce no output. -@findex mkCharLenCE +@apifun mkCharLenCE There is also @example @@ -14730,6 +14736,7 @@ included by @file{R.h}. @apifun vmaxget @apifun vmaxset @apifun nrows +@apifun ncols Here @R{} will reclaim the memory at the end of the call to @code{.C}, @code{.Call} or @code{.External}. Use @@ -14918,6 +14925,8 @@ subroutine rexit(@var{message}) subroutine rwarn(@var{message}) @end group @end example +@apifun rexit +@apifun rwarn Messages of more than 255 characters are truncated, with a warning. @@ -16299,6 +16308,7 @@ of @R{} function @code{findInterval} for details. There is also an @code{F77_CALL(interv)()} version of @code{findInterval()} with the same arguments, but all pointers. @end deftypefun +@apifun interv A system-independent interface to produce the name of a temporary file is provided as From 53b41b8286617d8e1fa38c4fb5a2222e3371c535 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 22 May 2024 21:28:05 +0000 Subject: [PATCH 085/546] More API tags. git-svn-id: https://svn.r-project.org/R/trunk@86590 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index d39e60929b4..a0549341d9d 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14814,9 +14814,6 @@ never from front-ends. They are not thread-safe. @node User-controlled memory, , Transient storage allocation, Memory allocation @subsection User-controlled memory -@apifun R_Calloc -@apifun R_Realloc -@apifun R_Free The other form of memory allocation is an interface to @code{malloc}, the interface providing @R{} error signaling. This memory lasts until @@ -14832,6 +14829,9 @@ The interface macros are void R_Free(@var{any} *@var{p}) @end group @end example +@apifun R_Calloc +@apifun R_Realloc +@apifun R_Free @noindent providing analogues of @code{calloc}, @code{realloc} and @code{free}. @@ -14861,6 +14861,15 @@ Historically the macros @code{Calloc}, @code{Free} and @code{Realloc} were used, and these remain available unless @code{STRICT_R_HEADERS} was defined prior to the inclusion of the header. +@code{R_Calloc}, @code{R_Realloc}, and @code{R_Free} are currently +implemented as macros expanding to calls to @code{R_chk_calloc}, +@code{R_chk_realloc}, and @code{R_chk_free}, respectively. These should +not be called directly as they may be removed in the future. +@comment detecting direct use of these is hard, so mark as 'experimental' +@eapifun R_chk_calloc +@eapifun R_chk_realloc +@eapifun R_chk_free + @findex CallocCharBuf @findex Memcpy @findex Memzero From f3c1b772fd51d08b50081a27d386d12abc5cb429 Mon Sep 17 00:00:00 2001 From: ripley Date: Thu, 23 May 2024 07:18:06 +0000 Subject: [PATCH 086/546] pacify gcc 14.1 on macOS git-svn-id: https://svn.r-project.org/R/trunk@86591 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/connections.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/connections.c b/src/main/connections.c index 66730b2ed0e..0da64528931 100644 --- a/src/main/connections.c +++ b/src/main/connections.c @@ -230,7 +230,7 @@ int getActiveSink(int n) static void conFinalizer(SEXP ptr) { - int i, ncon; + int i, ncon = 0; void *cptr = R_ExternalPtrAddr(ptr); if(!cptr) return; From 66ce19da64ba145df0f280ab28e7c713bc084acb Mon Sep 17 00:00:00 2001 From: ripley Date: Thu, 23 May 2024 07:42:06 +0000 Subject: [PATCH 087/546] more GCC 14 and macOS updates git-svn-id: https://svn.r-project.org/R/trunk@86592 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 141 ++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 77 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index e7056d7c281..dfb75a46ef6 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -1197,7 +1197,7 @@ linking process: set the make macro @samp{LTO} to something like @file{config.site}. Under some circumstances and for a few packages, the PIC flags have -needed overriding on Linux with GCC 9 and later: e.g@: use in +needed overriding on Linux with GCC 9: e.g@: use in @file{config.site}: @example CPICFLAGS=-fPIC @@ -1209,12 +1209,11 @@ CXX20PICFLAGS=-fPIC FPICFLAGS=-fPIC @end example @noindent -We suggest only using these if the problem is encountered (it was not -seen on @acronym{CRAN} with GCC 10 at the time of writing). +We suggest only using these if the problem is encountered (it had not +been seen on @acronym{CRAN} with GCC 10--14 at the time of writing). Note that @R{} may need to be re-compiled after even a minor update to -the compiler (e.g.@: from 10.1 to 10.2) but this may not be clear from -confused compiler messages. +the compiler (e.g.@: from 13.1 to 13.2). @node LTO with LLVM, LTO for package checking, LTO with GCC, Link-Time Optimization @subsubsection @abbr{LTO} with @I{LLVM} @@ -2238,24 +2237,25 @@ So for example you could select a specific @I{LLVM} @command{clang} for both C and C++ with extensive checking by having in @file{~/.R/Makevars} @example -CC = /usr/local/clang/bin/clang -isysroot - /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -CXX = /usr/local/clang/bin/clang++ -isysroot - /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk +SDK=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk +CC = /usr/local/clang/bin/clang -isysroot $(SDK) +CXX = /usr/local/clang/bin/clang++ -isysroot $(SDK) CXX11 = $CXX CXX14 = $CXX CXX17 = $CXX CXX20 = $CXX +CXX23 = $CXX CFLAGS = -g -O2 -Wall -pedantic -Wconversion -Wno-sign-conversion CXXFLAGS = -g -O2 -Wall -pedantic -Wconversion -Wno-sign-conversion CXX11FLAGS = $CXXFLAGS CXX14FLAGS = $CXXFLAGS CXX17FLAGS = $CXXFLAGS CXX20FLAGS = $CXXFLAGS +CXX23FLAGS = $CXXFLAGS @end example @noindent -(long lines split for the manual only) and for the current macOS -distribution of @command{gfortran} at +(the current SDK can be found by running @command{xcrun -show-sdk-path}) +and for the current macOS distribution of @command{gfortran} at @uref{https://mac.r-project.org/tools/} @example FC = /opt/gfortran/bin/gfortran @@ -2281,21 +2281,6 @@ for the @code{libomp.dylib} library to be found at both install time and run time, for example by copying/linking it somewhere that is searched such as @file{/usr/local/lib}. -@c Seems unneeded as running from the R executable forces x86_64 compiles. -@c -@c Installing a source package containing C/C++ code into @acronym{CRAN} -@c distribution of @R{} running on an @cputype{arm64} Mac requires telling -@c the compiler(s) to generate Intel code. For example, for Command Line -@c Tools / Xcode 12.x one could have in @file{~/.R/Makevars} - -@c @example -@c CC = clang -target x86_64-apple-macos10.15 -@c CXX = clang++ -target x86_64-apple-macos10.15 -@c @end example - -@c @noindent -@c (Using @code{-arch x86_64} also works.) - Apple includes many Open Source libraries in macOS but increasingly without the corresponding headers (not even in @I{Xcode} nor the Command Line Tools): they are often rather old versions. If installing packages @@ -2306,22 +2291,9 @@ But sometimes it is desirable/necessary to use Apple's dynamically linked library, in which case appropriate headers could be extracted from the sources@footnote{Note that capitalization and versioning may differ from the Open Source project.} available @emph{via} -@uref{https://opensource.apple.com} -- this has been used for +@uref{https://opensource.apple.com/releases} -- this has been used for @code{iodbc}. -@c Those using Command Line Tools / Xcode 12 or later (as released for -@c macOS 11 `Big Sur') probably want to arrange that the flag - -@c @example -@c -Wno-implicit-function-declaration -@c @end example - -@c @noindent -@c is part of @code{CFLAGS}. Apple has changed the default to make -@c implicit declarations a compilation error and authors of packages and -@c external software have been unaware that this might be done --- most -@c issues seen were in @command{configure} scripts. - Some care may be needed with selecting compilers when installing external software for use with packages. The `system' compilers as used when building @R{} are @command{clang} and @command{clang++}, but the Apple @@ -2339,31 +2311,25 @@ consistency one can use @noindent (avoiding @command{autoconf}'s default @option{-g}). -@c Be careful if you -@c put the @file{/usr/local/gfortran/bin} directory on your path as that -@c contains (real) @command{gcc} and @command{g++} which may be found -@c rather the Apple-provided commands, and may not be able to find the -@c headers and libraries@footnote{From Big Sur those libraries are not -@c publicly visible: rather the system compilers link to `text-based -@c definition' (@file{.tbd}) files.} of the @abbr{SDK}. @command{R CMD INSTALL} and @code{install.packages()} try to invoke @command{configure} with the same compilers and flags used to build @R{}. -For @cputype{arm64}, not all configure scripts have been updated to -recognize the platform and so might need the flag -@option{--build=aarch64-apple-darwin20.1.0}. Also, be aware that -running the compilers from a @cputype{x86_64} application switches them -to generating code for that CPU: this applies to a Terminal, a shell, -older @command{cmake} or (non-system) @command{make}, and from -@command{R CMD INSTALL} or @code{install.packages()}. One can use +@c For @cputype{arm64}, not all configure scripts have been updated to +@c recognize the platform and so might need the flag +@c @option{--build=aarch64-apple-darwin20.1.0}. +@c Also, be aware that +@c running the compilers from a @cputype{x86_64} application switches them +@c to generating code for that CPU: this applies to a Terminal, a shell, +@c older @command{cmake} or (non-system) @command{make}, and from +@c @command{R CMD INSTALL} or @code{install.packages()}. One can use -@example -./configure CC="clang -arch arm64" CFLAGS=-O2 CXX="clang++ -arch arm64" CXXFLAGS=-O2 -@end example +@c @example +@c ./configure CC="clang -arch arm64" CFLAGS=-O2 CXX="clang++ -arch arm64" CXXFLAGS=-O2 +@c @end example -@noindent -to force @cputype{arm64} code. +@c @noindent +@c to force @cputype{arm64} code. @node Customizing package compilation, Multiple sub-architectures, macOS packages, Installing packages @@ -5421,7 +5387,14 @@ available at @uref{https://github.com/fxcoudert/gfortran-for-macOS/releases}. These can be built for Intel and older OSes from the sources at @uref{https://github.com/iains/gcc-13-branch/} and -@code{gcc-14-branch/}. +@code{gcc-14-branch/}. To use one of the pre-built compilers with Apple +@command{clang} needs something like +@example +LDFLAGS="-L/opt/R/arm64/lib -rpath /usr/local/gfortran/lib" +@end example +@noindent +in @file{config.site} to ensure the Fortran run-time libraries are +found. @node Cairo graphics, Other C/C++ compilers, Fortran compilers, macOS @subsection Cairo graphics @@ -5495,27 +5468,26 @@ what is missing. At the time of writing using pre-built components @node Other C/C++ compilers, Other libraries, Cairo graphics, macOS @subsection Other C/C++ compilers -Other distributions of @command{clang} may be available from -@uref{https://github.com/llvm/llvm-project/releases/} (recently only for -@code{arm64} and usually unsigned/not notarized which makes them hard to -use). In particular, these include support for @abbr{OpenMP} which Apple -@command{clang} does not. Some of these have included support for the -@abbr{ASan} and @abbr{UBSan} sanitizers. +@c Un May 2024, 18.1.6 was the final release of that series, but the +@c latest binary build was 17.0.6. +Other pre-compiled distributions of @command{clang} may be available +from @uref{https://github.com/llvm/llvm-project/releases/} (recently +only for @code{arm64} and usually unsigned/not notarized which makes +them hard to use). In particular, these include support for +@abbr{OpenMP} which Apple @command{clang} does not. Some of these have +included support for the @abbr{ASan} and @abbr{UBSan} sanitizers. Suppose one of these distributions is installed under @file{$LOCAL/llvm}. Use a file @file{config.site} containing @example -CC="$LOCAL/llvm/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" -CXX="$LOCAL/llvm/bin/clang++ -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" +SDK=`xcrun -show-sdk-path` +CC="$LOCAL/llvm/bin/clang -isysroot $SDK" +CXX="$LOCAL/llvm/bin/clang++ -isysroot $SDK" OBJC=$CC FC=/opt/gfortran/bin/gfortran LDFLAGS="-L$LOCAL/llvm/lib -L$LOCAL/lib" R_LD_LIBRARY_PATH=$LOCAL/llvm/lib:$LOCAL/lib @end example -@noindent -Should the location of the @abbr{SDK} change (or where @I{Xcode} provides the @abbr{SDK} -rather than the Command Line Tools), it can be found by running -@command{xcrun -show-sdk-path}. The care to specify library paths is to ensure that the @abbr{OpenMP} runtime library, here @file{$LOCAL/llvm/lib/libomp.dylib}, is found when needed. @@ -5528,11 +5500,26 @@ in the @command{configure} output. Also, @samp{R_LD_LIBRARY_PATH} needs to be set to find the latest version of the C++ run-time libraries rather than the system ones. -It is usually possible to build @R{} with GCC (built from the sources, -from a @command{gfortran} distribution, from @I{Homebrew}, @dots{}). When -last tested@footnote{with @command{gcc} 10.2.} it was not possible to -use @command{gcc} to build the @code{quartz()} device, so -@command{configure --without-aqua} may be required. +It is normally possible to build @R{} with GCC (built from the sources, +from a @command{gfortran} distribution, from @I{Homebrew}, @dots{}). +@c re-trested with GCC 14.1 +When last tested it was not possible to use @command{gcc} to build the +@code{quartz()} device, so @command{configure --without-aqua} may be +required. @R{} was built and tested with the GCC 14.1 compilers in the +@code{arm64} @command{gfortran} distribution mentioned above using a +@file{config.site} containing +@example +CC=/usr/local/gfortran/bin/gcc +CXX=/usr/local/gfortran/bin/g++ +FC=/usr/local/gfortran/bin/gfortran +CFLAGS="-g -O2 -Wall -pedantic -Wstrict-prototypes" +C17FLAGS="-g -O2 -Wall -pedantic -Wno-strict-prototypes" +C90FLAGS=$C17FLAGS +C99FLAGS=$C17FLAGS +CXXFLAGS="-g -O2 -Wall -pedantic" +CPPFLAGS='-isystem /opt/R/arm64/include' +LDFLAGS=-L/opt/R/arm64/lib +@end example It is usually possible to add some @abbr{OpenMP} support to the Apple @command{clang} compilers: see @uref{https://mac.r-project.org/openmp/}. From 7c34dbb34bc9d0c80eb0a3ad897c28409d8718d9 Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 23 May 2024 08:50:33 +0000 Subject: [PATCH 088/546] Detect invalid length (thanks to Ivan Krylov). git-svn-id: https://svn.r-project.org/R/trunk@86594 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/serialize.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/serialize.c b/src/main/serialize.c index a190fbf8f3c..0b1c050b286 100644 --- a/src/main/serialize.c +++ b/src/main/serialize.c @@ -1985,6 +1985,8 @@ static SEXP ReadItem_Recursive (int flags, SEXP ref_table, R_inpstream_t stream) { /* These are all short strings */ length = InInteger(stream); + if (length < 0) + error(_("invalid length")); R_CheckStack2(length+1); char cbuf[length+1]; InString(stream, cbuf, length); @@ -2000,7 +2002,9 @@ static SEXP ReadItem_Recursive (int flags, SEXP ref_table, R_inpstream_t stream) case CHARSXP: /* these are currently limited to 2^31 -1 bytes */ length = InInteger(stream); - if (length == -1) + if (length < -1) + error(_("invalid length")); + else if (length == -1) PROTECT(s = NA_STRING); else if (length < 1000) { char cbuf[length+1]; @@ -2247,7 +2251,7 @@ SEXP R_Unserialize(R_inpstream_t stream) case 3: { int nelen = InInteger(stream); - if (nelen > R_CODESET_MAX) + if (nelen > R_CODESET_MAX || nelen < 0) error(_("invalid length of encoding name")); InString(stream, stream->native_encoding, nelen); stream->native_encoding[nelen] = '\0'; @@ -2338,7 +2342,7 @@ SEXP R_SerializeInfo(R_inpstream_t stream) if (version == 3) { SET_STRING_ELT(names, 4, mkChar("native_encoding")); int nelen = InInteger(stream); - if (nelen > R_CODESET_MAX) + if (nelen > R_CODESET_MAX || nelen < 0) error(_("invalid length of encoding name")); char nbuf[nelen + 1]; InString(stream, nbuf, nelen); From 6e65ae84fd8555312c55f3087c2663eeb2ae861d Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 23 May 2024 08:54:06 +0000 Subject: [PATCH 089/546] Spelling. git-svn-id: https://svn.r-project.org/R/trunk@86595 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 8 ++++---- doc/manual/R-exts.texi | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index dfb75a46ef6..0534eb823db 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -2254,7 +2254,7 @@ CXX20FLAGS = $CXXFLAGS CXX23FLAGS = $CXXFLAGS @end example @noindent -(the current SDK can be found by running @command{xcrun -show-sdk-path}) +(the current @I{SDK} can be found by running @command{xcrun -show-sdk-path}) and for the current macOS distribution of @command{gfortran} at @uref{https://mac.r-project.org/tools/} @example @@ -5117,7 +5117,7 @@ there.) @node Prerequisites, Fortran compilers, macOS, macOS @subsection Prerequisites -The Apple silicon conmponents install into @file{/opt/R/arm64}, the +The Apple silicon components install into @file{/opt/R/arm64}, the Intel ones into @file{/opt/R/x86_64}. That may not exist@footnote{it will if @R{} has been installed from @acronym{CRAN} since @R{} 4.3.0.} so it is simplest to first create the directory and adjust its ownership @@ -5716,8 +5716,8 @@ installed at first use. Check if a @abbr{JRE} is installed by running @command{java -version} in a @command{Terminal} window: if Java is not installed on an Intel Mac this may prompt you to install it. We recommend you install a version with long-term support, e.g.@: 17 or -21@footnote{The planned nextLTS release is 25 in September 2025. Java 8 -@emph{aka} 1.8.0 is still LTS but some packages require 11 or later.} +21@footnote{The planned @I{nextLTS} release is 25 in September 2025. Java 8 +@emph{aka} 1.8.0 is still @I{LTS} but some packages require 11 or later.} but not 18--20, 22--24 with a 6-month lifetime. The currently simplest way to install Java is from diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index a0549341d9d..5d8dfe14e51 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14683,7 +14683,7 @@ change, so package authors wishing to use these should be prepared to adapt. @item embedding -Entry points intended primarily for embedding ar and creating new +Entry points intended primarily for embedding and creating new front-ends. It is not clear that this needs to be a separate category but it may be useful to keep it separate for now. @end table @@ -17996,7 +17996,7 @@ will only be changed after deprecation. Entry points and variables listed in this index and in header files listed here are part of an experimental API, such as -R_ext/Altrep.h. These are subject to change, so package authors wishing +@file{R_ext/Altrep.h}. These are subject to change, so package authors wishing to use these should be prepared to adapt. @printindex ae From baa026389dc7a21587017591ea3343036521d748 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 23 May 2024 08:54:22 +0000 Subject: [PATCH 090/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86596 00db46b3-68df-0310-9c12-caf00c1e9a41 --- share/dictionaries/R_manuals.rds | Bin 1332 -> 1334 bytes share/dictionaries/R_manuals.txt | 1 + 2 files changed, 1 insertion(+) diff --git a/share/dictionaries/R_manuals.rds b/share/dictionaries/R_manuals.rds index 0a28e61abfd0eba62ca6a8f21224eaa3db47be5c..b7327cbe7ba49da40edebd34a091491ff68b788f 100644 GIT binary patch literal 1334 zcmV-61*_E=8aJW{*ViX$$` z@FH3M$bM77wE$2Lwijm!ECC!`{O`2a>-BqsEBFmRz24Q2*Sp_-hlfw_^Ivb!o50_Z zsA3X2oW-H2Yim%N2(4`;qV;EBN&p_2i4?82qE@CkLyHWxqEQu`KB4ADRC{NAlrhp(!3JJntTWKj@Y8a(CAGioQfF| zQL*o%YA1Y<5${r2=_|F-Xlq)5+deo^v31)zrNu^R6;FJubtwu~ysoUNRsK|YwIQHe z)v%V?THgv&eBT_bK2UHzRW_L@y)rR@wFCQ|0)!vDDL;u=>EXB*QAX90N3}esmuwLN zYK%EAs|!p0<-;AlR@<%g(o{@{d2Np-h}LPw2FvwRp!W%0U78%$C#^OpeU_?`rj|LF zHmKq{19=b{b>tfa1m8@yaQDnH@^`DWbRzE1-z-QIm86d?0KxlWW%t89n!c4(=k!yh3P5-ZlS9<(=g^%BsUofb9 zUs5U)T?Z}iUEeR33h5MAaW-e21gfM$Vg4>fQ& zNmB15Qg6jxW?tgWP^LJy!Z#f!sp*V?J>o*=EThgM1L0&MbbreG=T=qT3SaFYo-h?W z9lu&BbN>&0PlZZqEsPYHp4G$aik{a$*Vv=l1P%IJ+eLO39UgaH3a0JYTpk)cEpL&f zqbDcL?Rtp;%i{ebDq4`%Kh~Jq8O)TOHMxCaXP7zR^Kd8{?oEau3|@tc_C_#Ih>^>a zfRf#Rz9na$mv@v02LnR7=!*`U#~YM6k;r+`w1Nx)&!Vu4(I`F_v0w3$YpKV_qhr=mHzq;+oh$UK+Au57}S zUr9jmG8F+(@EQVz$$eSguGaYa+DmFjMgM_Fh*)uF8T&jQJl$*rp5&zQ>rSj$Kg-3= zl0BEOew35?rVB@%VCG6<&li$Skqkti zD(=1^Z7MB*NhM-kIlE_oz}=POd(H_e)`E=5UkP>vGByG%iiX8gn>#Ii>O(C0cGtw- zm`xFyp)87K0<+v{Q38;IcWVk2Yc(u;3OPF^fKru_z2b?SW!??PXOS&>*b0l5Kk7La&?{YG;;Zidv zuPxdgXy&?x5r6?9ATW}9chTA=8G%ya#*~3Z!7fGZg%M8Rbq2A@$l5%k0oL7uq!5H| zg`&M3WUxewJF6nh>?<&uX;6(+YV&TDZefaYWJZ8_-tNZ-0Tv>U&;!K7`pb_`5#;zH sQgHUD!cIdRP${oE-9HjUpreNoT>9Ptyi*K*{;_)eAAn6NnBffo07sm9VE_OC literal 1332 zcmV-41Os;%%rM!ZX9rLWXRqpf)bZu{Uw#nx@-lolJMRXp;s&ZQ_=@v5?>R{2xq)y9A} zs%0(HSlEW~%QAX8~N3}eqmuwLN zYK%EAt20Z()%`8KR!t+lG!+x#vbF~kMCUYPqt*H;(E9|h&P|T%qgES~K1xr`pA=KtrNgUyoF4d znt&EUco0XXdh5k80PQfa)7INVk)Yw->o>ID0;{#`B-O>FeOE;hOo5kmWoy)(p^OLS zAAnQDm6M7?QVzd9|A{WET3WcC+p3Bn0}(!Rda4ZMjnAp_;dJ zvtU)EEJpYdoh%uBo($`t2L__pUHHJvH2N1W-LWYk$^ARJAE?oWCD+^Nc2;j1mg6Q+Wv z;}?(0-2Fq}Q=yVt3nK-l=kfmak)GE-*Vv=F1P%IB+eLPkJs!7S3a0JUoF5uJt!|K| zlP4$5&3c6a%i`SwDq4`%Kh~Jq16RS zfRa6Yz9DCySGSZ02LnR7=!*`U#~YM6k;r+`c7hB6Tp4JOC8DhOl5NUsgAdYkYm>B{iR-+koF9R@_IXJ`V#=H=BSbIYs=s7i-qfa@<7ku?1Q&H7H!L^PcYqbGPB`QGbgVr znj2{5x`u|20U;nTk~?+L$YvRVQsFj~fmXrhMD2wUPT*ArvC7EWWkv%mw*^Td2>rrD zTRO;KiPm&hMVQ%FU^Ky?8mZJS`^C9~naPov0Oom@pY8=%h&(X&5D)9mKR!p0rHV}ah9tLjddk^piG5Yz( Date: Thu, 23 May 2024 08:56:30 +0000 Subject: [PATCH 091/546] Add ignores for new API tags. git-svn-id: https://svn.r-project.org/R/trunk@86597 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/aspell.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/library/utils/R/aspell.R b/src/library/utils/R/aspell.R index 8a4c9867c00..66b489a3eb0 100644 --- a/src/library/utils/R/aspell.R +++ b/src/library/utils/R/aspell.R @@ -468,6 +468,15 @@ aspell_control_R_manuals <- "--add-texinfo-ignore=deqn", "--add-texinfo-ignore=eqn", "--add-texinfo-ignore=pkg", + "--add-texinfo-ignore=apifun", + "--add-texinfo-ignore=apihdr", + "--add-texinfo-ignore=comment", + "--add-texinfo-ignore=defcodeindex", + "--add-texinfo-ignore=eapifun", + "--add-texinfo-ignore=eapihdr", + "--add-texinfo-ignore=embfun", + "--add-texinfo-ignore=embhdr", + "--add-texinfo-ignore=embvar", character() ), hunspell = From 5d146c6d02617e391a3ca350dd975607799baa81 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 23 May 2024 08:56:48 +0000 Subject: [PATCH 092/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86598 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/checktools.R | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/library/tools/R/checktools.R b/src/library/tools/R/checktools.R index d046cd86178..59862ed096d 100644 --- a/src/library/tools/R/checktools.R +++ b/src/library/tools/R/checktools.R @@ -1128,16 +1128,14 @@ function(new, old, outputs = FALSE) ## Drop checks that are OK in both versions x.issue <- !is.na(match(db$Status.x, - c("ERROR","FAILURE","NOTE","WARNING"))) + c("NOTE", "WARNING", "ERROR", "FAILURE"))) y.issue <- !is.na(match(db$Status.y, - c("ERROR","FAILURE","NOTE","WARNING"))) + c("NOTE", "WARNING", "ERROR", "FAILURE"))) db <- db[x.issue | y.issue,] ## Even with the above simplification, missing entries do not ## necessarily indicate "OK" (checks could have been skipped). ## Hence leave as missing and show as empty in the diff. - ## An exception to this rule is made if we find an "ERROR" result - ## as this may explain skipped checks. sx <- as.character(db$Status.x) sy <- as.character(db$Status.y) From bab8aaa7cd266ba32b3340b9dc03d617eb3c147e Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 23 May 2024 08:57:55 +0000 Subject: [PATCH 093/546] Extract functions for getting URLs from DESCRIPTION fields. git-svn-id: https://svn.r-project.org/R/trunk@86599 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/urltools.R | 63 +++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/src/library/tools/R/urltools.R b/src/library/tools/R/urltools.R index 92c1f32d73d..70d81db0fa5 100644 --- a/src/library/tools/R/urltools.R +++ b/src/library/tools/R/urltools.R @@ -188,35 +188,52 @@ function(meta) fields <- c("URL", "BugReports") for(v in meta[fields]) { if(is.na(v)) next - pattern <- - "<(URL: *)?((https?|ftp)://[^[:space:],]*)[[:space:]]*>" - m <- gregexpr(pattern, v) - urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) - regmatches(v, m) <- "" - pattern <- "(^|[^>\"])((https?|ftp)://[^[:space:],]*)" - m <- gregexpr(pattern, v) - urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) + urls <- c(urls, .get_urls_from_DESCRIPTION_URL_field(v)) } if(!is.na(v <- meta["Description"])) { - pattern <- - "<(URL: *)?((https?|ftp)://[^[:space:]]+)[[:space:]]*>" - m <- gregexpr(pattern, v) - urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) - regmatches(v, m) <- "" - pattern <- - "([^>\"])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/])" - m <- gregexpr(pattern, v) - urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) - regmatches(v, m) <- "" - pattern <- "<([A-Za-z][A-Za-z0-9.+-]*:[^>]+)>" - ## scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) - m <- gregexpr(pattern, v) - urls <- c(urls, .gregexec_at_pos(pattern, v, m, 2L)) + urls <- c(urls, .get_urls_from_DESCRIPTION_Description_field(v)) } - url_db(urls, rep.int("DESCRIPTION", length(urls))) } +.get_urls_from_DESCRIPTION_URL_field <- +function(v) +{ + urls <- character() + if(is.na(v)) return(urls) + pattern <- + "<(URL: *)?((https?|ftp)://[^[:space:],]*)[[:space:]]*>" + m <- gregexpr(pattern, v) + urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) + regmatches(v, m) <- "" + pattern <- "(^|[^>\"])((https?|ftp)://[^[:space:],]*)" + m <- gregexpr(pattern, v) + urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) + urls +} + +.get_urls_from_DESCRIPTION_Description_field <- +function(v) +{ + urls <- character() + if(is.na(v)) return(urls) + pattern <- + "<(URL: *)?((https?|ftp)://[^[:space:]]+)[[:space:]]*>" + m <- gregexpr(pattern, v) + urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) + regmatches(v, m) <- "" + pattern <- + "([^>\"])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/])" + m <- gregexpr(pattern, v) + urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) + regmatches(v, m) <- "" + pattern <- "<([A-Za-z][A-Za-z0-9.+-]*:[^>]+)>" + ## scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) + m <- gregexpr(pattern, v) + urls <- c(urls, .gregexec_at_pos(pattern, v, m, 2L)) + urls +} + url_db_from_package_citation <- function(dir, meta, installed = FALSE) { From 9847f8172639eb393faeb98caa34d47ecb140f79 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 23 May 2024 10:13:13 +0000 Subject: [PATCH 094/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86600 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/apitools.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/library/tools/R/apitools.R b/src/library/tools/R/apitools.R index 2d607e76d8b..08fc2a56378 100644 --- a/src/library/tools/R/apitools.R +++ b/src/library/tools/R/apitools.R @@ -191,7 +191,7 @@ checkLibAPI <- function(lpath) { lsyms <- data.frame(name = lsyms, unmapped = unmap(lsyms)) api <- transform(funAPI(), unmapped = unmap(name), name = NULL, loc = NULL) val <- merge(lsyms, api, all.x = TRUE) - val <- val[order(val$api), ] + val <- val[order(val$apitype), ] val$unmapped <- NULL ## not needed in final output rownames(val) <- NULL val @@ -200,7 +200,7 @@ checkLibAPI <- function(lpath) { readFileSyms <- function(fpath) { ## this uses nm ## could try objdump if nm doesn't work - v <- tools:::read_symbols_from_object_file(fpath) + v <- read_symbols_from_object_file(fpath) if (is.null(v)) data.frame(name = character(0), type = character(0)) else as.data.frame(v)[c("name", "type")] @@ -271,7 +271,8 @@ checkPkgAPI <- function(pkg, lib.loc = NULL, all = FALSE) { checkAllPkgsAPI <- function(lib.loc = NULL, priority = NULL, all = FALSE, verbose = FALSE) { - p <- rownames(installed.packages(lib.loc = lib.loc, priority = priority)) + p <- rownames(utils::installed.packages(lib.loc = lib.loc, + priority = priority)) checkOne <- function(pkg) { if (verbose) cat(pkg, "\n") data <- checkPkgAPI(pkg, lib.loc = lib.loc) From b020f54242f03387a4951197dfa25c40741cb8b6 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 23 May 2024 10:14:35 +0000 Subject: [PATCH 095/546] Change opts for .curl_GET_status_code(), and also use this for re-checking when checking in parallel (hence via curl). git-svn-id: https://svn.r-project.org/R/trunk@86601 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/urltools.R | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/library/tools/R/urltools.R b/src/library/tools/R/urltools.R index 70d81db0fa5..6ebc299cda8 100644 --- a/src/library/tools/R/urltools.R +++ b/src/library/tools/R/urltools.R @@ -529,7 +529,7 @@ function(db, remote = TRUE, verbose = FALSE, parallel = FALSE, pool = NULL) } } ## - if((s != "200") && use_curl) { + if((s != "200") && (use_curl || parallel)) { g <- .curl_GET_status_code(u) if(g == "200") { s <- g @@ -777,8 +777,12 @@ function(urls, verbose = FALSE, ids = urls) urls, verbose, ids) .fetch_headers_via_curl <- -function(urls, verbose = FALSE, pool = NULL) { - out <- .curl_multi_run_worker(urls, TRUE, verbose, pool) +function(urls, verbose = FALSE, pool = NULL) +{ + out <- .curl_multi_run_worker(urls, TRUE, verbose, pool, + c(.curl_handle_default_opts, + list(http_version = 2L, + ssl_enable_alpn = 0L))) ind <- !vapply(out, inherits, NA, "error") if(any(ind)) out[ind] <- lapply(out[ind], @@ -792,7 +796,6 @@ function(urls, verbose = FALSE, pool = NULL) { out } - .curl_multi_run_worker <- function(urls, nobody = FALSE, verbose = FALSE, pool = NULL, opts = NULL) @@ -913,6 +916,4 @@ function(x) .curl_handle_default_opts <- list(cookiesession = 1L, - followlocation = 1L, - http_version = 2L, - ssl_enable_alpn = 0L) + followlocation = 1L) From b19089e3227856acc668a68a2cb0e85854a7b38f Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 23 May 2024 11:30:31 +0000 Subject: [PATCH 096/546] Fixes from Sebastian. git-svn-id: https://svn.r-project.org/R/trunk@86602 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 5d8dfe14e51..a404d6f2c21 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -29,11 +29,10 @@ @end macro @macro apivar {f} @apindex \f\ -@findex \f\ +@vindex \f\ @end macro @macro apihdr {f} @apindex \f\ -@findex \f\ @end macro @macro eapifun {f} @@ -42,11 +41,10 @@ @end macro @macro eapivar {f} @aeindex \f\ -@findex \f\ +@vindex \f\ @end macro @macro eapihdr {f} @aeindex \f\ -@findex \f\ @end macro @macro embfun {f} @@ -55,11 +53,10 @@ @end macro @macro embvar {f} @emindex \f\ -@findex \f\ +@vindex \f\ @end macro @macro embhdr {f} @emindex \f\ -@findex \f\ @end macro @copying @@ -14949,7 +14946,7 @@ Messages of more than 255 characters are truncated, with a warning. @apifun R_unif_index @apifun GetRNGstate @apifun PutRNGstate -@apifun .Random.seed +@vindex .Random.seed @c @apifun seed_in @c @apifun seed_out From 565c57eca46c729a47712f0f311f080c368b98d1 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 23 May 2024 12:16:13 +0000 Subject: [PATCH 097/546] Add Ncpus support to checkAllPkgsAPI. git-svn-id: https://svn.r-project.org/R/trunk@86603 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/apitools.R | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/library/tools/R/apitools.R b/src/library/tools/R/apitools.R index 08fc2a56378..a8b2641818a 100644 --- a/src/library/tools/R/apitools.R +++ b/src/library/tools/R/apitools.R @@ -269,19 +269,18 @@ checkPkgAPI <- function(pkg, lib.loc = NULL, all = FALSE) { else NULL } -checkAllPkgsAPI <- function(lib.loc = NULL, priority = NULL, - all = FALSE, verbose = FALSE) { +checkAllPkgsAPI <- function(lib.loc = NULL, priority = NULL, all = FALSE, + Ncpus = getOption("Ncpus", 1L), + verbose = getOption("verbose")) { p <- rownames(utils::installed.packages(lib.loc = lib.loc, priority = priority)) checkOne <- function(pkg) { - if (verbose) cat(pkg, "\n") data <- checkPkgAPI(pkg, lib.loc = lib.loc) if (! is.null(data)) transform(data, pkg = rep(pkg, nrow(data))) } - val <- do.call(rbind, lapply(p, checkOne)) + val <- do.call(rbind, .package_apply(p, checkOne, + Ncpus = Ncpus, verbose = verbose)) rownames(val) <- NULL val } - - From 10b9151209d287e3e5468ad96604f45af2968484 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 23 May 2024 12:34:12 +0000 Subject: [PATCH 098/546] Fix PR#18735. git-svn-id: https://svn.r-project.org/R/trunk@86604 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index 59dd1c20d44..c8d1f45ae2e 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -3775,7 +3775,11 @@ function(dfile) imports <- .get_requires_from_package_db(db, "Imports") suggests <- .get_requires_from_package_db(db, "Suggests") enhances <- .get_requires_from_package_db(db, "Enhances") - allpkgs <- c(depends, imports, suggests, enhances) + ## Packages may occur several times in each dependency field to + ## specify version ranges. + ## See . + allpkgs <- c(unique(depends), unique(imports), + unique(suggests), unique(enhances)) out <- unique(allpkgs[duplicated(allpkgs)]) links <- missing_incs <- character() llinks <- .get_requires_with_version_from_package_db(db, "LinkingTo") From b8ca0a54c3e7c41a886468ee082233fd20fab913 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 23 May 2024 12:37:36 +0000 Subject: [PATCH 099/546] Improve detection of appropriate HTML Tidy (PR#18731, by Ivan Krylov). git-svn-id: https://svn.r-project.org/R/trunk@86605 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/utils.R | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index 9e97162b3a2..8b0d3629f0b 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -972,19 +972,35 @@ function(v, env, last = NA, default = NA) { .find_tidy_cmd <- function(Tidy = Sys.getenv("R_TIDYCMD", "tidy")) { - ## require HTML Tidy, and not macOS's ancient version. + ## Require a recent enough version of HTML Tidy. + ## We really need HTML Tidy 5.0.0 or later, and all these versions + ## should have tidy --version match + ## ^HTML Tidy .*version (\\d+\\.\\d+\\.\\d+) + ## See + ## + ## and + ## . msg <- "" OK <- nzchar(Sys.which(Tidy)) if(OK) { ver <- system2(Tidy, "--version", stdout = TRUE) - OK <- startsWith(ver, "HTML Tidy") + mat <- regexec("^HTML Tidy .*version (\\d+\\.\\d+\\.\\d+)$", + ver) + ver <- regmatches(ver, mat)[[1L]][2L] + OK <- !is.na(ver) if(OK) { - OK <- !grepl('Apple Inc. build 2649', ver) - if(!OK) msg <- "'tidy' is Apple's too old build" - ## Maybe we should also check version, - ## but e.g. Ubuntu 16.04 does not show one. - } else msg <- "'tidy' is not HTML Tidy" - } else msg <- "no command 'tidy' found" + ## Minimum version requirement. + req <- "5.0.0" + OK <- numeric_version(ver) >= req + if(!OK) + msg <- + sprintf("'%s' is too old: need version %s, found %s", + Tidy, req, ver) + } else + msg <- + sprintf("'%s' doesn't look like recent enough HTML Tidy", + Tidy) + } else msg <- sprintf("no command '%s' found", Tidy) if(nzchar(msg)) { Tidy <- "" attr(Tidy, "msg") <- msg From fa454088d0f0cadea7dc6227cb2786b7397a5d3a Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 23 May 2024 14:14:28 +0000 Subject: [PATCH 100/546] Tweak. git-svn-id: https://svn.r-project.org/R/trunk@86606 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/urltools.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/urltools.R b/src/library/tools/R/urltools.R index 6ebc299cda8..2a9ea972dbb 100644 --- a/src/library/tools/R/urltools.R +++ b/src/library/tools/R/urltools.R @@ -530,7 +530,7 @@ function(db, remote = TRUE, verbose = FALSE, parallel = FALSE, pool = NULL) } ## if((s != "200") && (use_curl || parallel)) { - g <- .curl_GET_status_code(u) + g <- .curl_fetch_memory_status_code(u) if(g == "200") { s <- g msg <- "OK" @@ -879,7 +879,7 @@ function(urls, nobody = FALSE, verbose = FALSE, pool = NULL, out } -.curl_GET_status_code <- +.curl_fetch_memory_status_code <- function(u, verbose = FALSE, opts = NULL) { if(verbose) From 9f2c3cadbe4b8ea9f0759b9a2e2ed9ab4f2ab0a4 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 23 May 2024 14:14:45 +0000 Subject: [PATCH 101/546] Fix some FIXMEs. git-svn-id: https://svn.r-project.org/R/trunk@86607 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/CRANtools.R | 4 ---- src/library/tools/R/QC.R | 17 ++--------------- src/library/tools/R/Rd.R | 6 +----- src/library/tools/R/admin.R | 10 ---------- src/library/tools/R/build.R | 8 -------- src/library/tools/R/check.R | 8 ++++---- src/library/tools/R/checktools.R | 13 ------------- src/library/tools/R/news.R | 8 ++++---- src/library/tools/R/utils.R | 3 --- 9 files changed, 11 insertions(+), 66 deletions(-) diff --git a/src/library/tools/R/CRANtools.R b/src/library/tools/R/CRANtools.R index a0ddc184483..929156442bb 100644 --- a/src/library/tools/R/CRANtools.R +++ b/src/library/tools/R/CRANtools.R @@ -230,10 +230,6 @@ function(flavors = NULL) "web/checks/check_details.rds") if(!is.null(flavors)) db <- db[!is.na(match(db$Flavor, flavors)), ] - ## - ## Remove eventually ... - class(db) <- c("CRAN_check_details", "check_details", "data.frame") - ## db } diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index c8d1f45ae2e..f4628ce2f3a 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -1623,7 +1623,7 @@ function(x, ...) })), "") - ## + ## ## Terrible hack, see comments on ## __R_CHECK_DOC_FILES_NOTE_IF_ALL_SPECIAL__ ## in check.R @@ -1633,6 +1633,7 @@ function(x, ...) "FALSE") == "TRUE") && isTRUE(attr(x, "all_special"))) y <- c(y, "All issues in internal Rd files checked specially.") + ## y } @@ -9715,21 +9716,7 @@ function(x) ## transformations before collapsing ... txt <- .dquote_method_markup(txt, .S3_method_markup_regexp) txt <- .dquote_method_markup(txt, .S4_method_markup_regexp) - ## - ## Commented 2023-08-11: remove eventually. - ## ## Stop doing this. - ## ## Transform <> style markup so that we can catch and - ## ## throw it, rather than "basically ignore" it by putting it in the - ## ## bad_lines attribute. - ## txt <- gsub("(<>?)", "`\\1`", txt) - ## ## \usage is only 'verbatim-like' - ## ## - ## ## 'LanguageClasses.Rd' in package methods has '"\{"' in its usage. - ## ## But why should it use the backslash escape? - ## txt <- gsub("\\{", "{", txt, fixed = TRUE) - ## txt <- gsub("\\}", "}", txt, fixed = TRUE) - ## ## ## now any valid escape by \ is ## \a \b \f \n \r \t \u \U \v \x \' \" \\ or \octal txt <- gsub("(^|[^\\])\\\\($|[^abfnrtuUvx0-9'\"\\])", diff --git a/src/library/tools/R/Rd.R b/src/library/tools/R/Rd.R index 104d12cf94c..38dcadae6a6 100644 --- a/src/library/tools/R/Rd.R +++ b/src/library/tools/R/Rd.R @@ -21,10 +21,6 @@ Rd_info <- function(file, encoding = "unknown") { - ## - ## This used to work only for a given Rd file. - ## now only for a parsed Rd object. - if(inherits(file, "Rd")) { Rd <- file description <- attr(attr(Rd, "srcref"), "srcfile")$filename @@ -620,7 +616,7 @@ function(x, predicate) ## ## Should we do f(e) if not is.list(e)? e - ## + ## } recurse(x) } diff --git a/src/library/tools/R/admin.R b/src/library/tools/R/admin.R index 13c40d9ca65..b5104ebbd7f 100644 --- a/src/library/tools/R/admin.R +++ b/src/library/tools/R/admin.R @@ -89,16 +89,6 @@ function(dir, outDir, builtStamp=character()) .expand_package_description_db_R_fields(db), Built = Built) - ## - ## This should no longer be necessary? - ## - ## ## This cannot be done in a MBCS: write.dcf fails - ## ctype <- Sys.getlocale("LC_CTYPE") - ## Sys.setlocale("LC_CTYPE", "C") - ## on.exit(Sys.setlocale("LC_CTYPE", ctype)) - ## - ## - .write_description(db, file.path(outDir, "DESCRIPTION")) outMetaDir <- file.path(outDir, "Meta") diff --git a/src/library/tools/R/build.R b/src/library/tools/R/build.R index c71d1be21b0..2d5a05147a1 100644 --- a/src/library/tools/R/build.R +++ b/src/library/tools/R/build.R @@ -721,14 +721,6 @@ inRbuildignore <- function(files, pkgdir) { if(dep$version >= package_version(ver)) return() } - ## - ## This should no longer be necessary? - ## - ## on.exit(Sys.setlocale("LC_CTYPE", Sys.getlocale("LC_CTYPE"))) - ## Sys.setlocale("LC_CTYPE", "C") - ## - ## - flatten <- function(x) { if(length(x) == 3L) paste0(x$name, " (", x$op, " ", x$version, ")") diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 855a13ed3e5..e0f13288300 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -2558,7 +2558,7 @@ add_dummies <- function(dir, Log) "The \\usage entries must correspond to syntactically", "valid R code.\n") any <- FALSE - ## + ## ## Hack to see whether all issues are from internal Rd files ## checked specially and only give a NOTE in this case. ## Ideally, we would use R() to get the check object and be @@ -2584,7 +2584,7 @@ add_dummies <- function(dir, Log) wrapLog(msg_doc_files) wrapLog(msg_writing_Rd) } - ## + ## if (R_check_Rd_style && haveR) { msg_doc_style <- @@ -4314,7 +4314,7 @@ add_dummies <- function(dir, Log) } ## It ran, but did it create any examples? if (file.exists(exfile)) { - ## + ## ## This used to be ## enc <- if (!is.na(e <- desc["Encoding"])) { ## paste0("--encoding=", e) @@ -4332,7 +4332,7 @@ add_dummies <- function(dir, Log) if(length(suppressMessages(showNonASCIIfile(exfile)))) { "--encoding=UTF-8" } else "" - ## + ## if (!this_multiarch) { exout <- paste0(pkgname, "-Ex.Rout") if(!run_one_arch(exfile, exout)) maybe_exit(1L) diff --git a/src/library/tools/R/checktools.R b/src/library/tools/R/checktools.R index 59862ed096d..5e41705224f 100644 --- a/src/library/tools/R/checktools.R +++ b/src/library/tools/R/checktools.R @@ -745,19 +745,6 @@ function(log, drop = TRUE, ...) } } - ## ## - ## ## Remove eventually. - ## len <- length(lines) - ## end <- lines[len] - ## if(length(end) && - ## grepl(re <- "^(\\*.*\\.\\.\\.)(\\* elapsed time.*)$", end, - ## perl = TRUE, useBytes = TRUE)) { - ## lines <- c(lines[seq_len(len - 1L)], - ## sub(re, "\\1", end, perl = TRUE, useBytes = TRUE), - ## sub(re, "\\2", end, perl = TRUE, useBytes = TRUE)) - ## } - ## ## + ## ## We had planned to eventually add support for DESCRIPTION ## News/File ## News/Format ## News/Reader ## News/Reader@R - ## entries. But now that we're moving to NEWS.Rd, there seems - ## little point in providing format/reader support ... - ## + ## entries. But now that there are NEWS.Rd and NEWS.md, there + ## seems little point in providing format/reader support ... + ## ## Look for new-style inst/NEWS.Rd installed as NEWS.Rd ## If not found, look for NEWS.md. diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index 8b0d3629f0b..ec0a57a5dc7 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -213,8 +213,6 @@ function(dir) { ### ** reQuote -## -## Move into base eventually ... reQuote <- function(x) { @@ -224,7 +222,6 @@ function(x) regmatches(x, m) <- lapply(regmatches(x, m), escape) x } -## ### ** showNonASCII From 8eb8e8e12dfafc7f953fe42d15148fcc87db8c27 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 23 May 2024 14:31:29 +0000 Subject: [PATCH 102/546] Avoid subset() and transform() to keep codetools happy. git-svn-id: https://svn.r-project.org/R/trunk@86608 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/apitools.R | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/library/tools/R/apitools.R b/src/library/tools/R/apitools.R index a8b2641818a..f2edb0b90ef 100644 --- a/src/library/tools/R/apitools.R +++ b/src/library/tools/R/apitools.R @@ -186,10 +186,13 @@ dropBraces <- function(lines) { checkLibAPI <- function(lpath) { ldata <- readFileSyms(lpath) - lsyms <- subset(ldata, type == "U")$name + lsyms <- ldata[ldata$type == "U", ]$name lsyms <- inRfuns(lsyms) lsyms <- data.frame(name = lsyms, unmapped = unmap(lsyms)) - api <- transform(funAPI(), unmapped = unmap(name), name = NULL, loc = NULL) + api <- funAPI() + api$unmapped <- unmap(api$name) + api$name <- NULL + api$loc <- NULL val <- merge(lsyms, api, all.x = TRUE) val <- val[order(val$apitype), ] val$unmapped <- NULL ## not needed in final output @@ -240,8 +243,9 @@ getRfuns <- function() { ofiles <- c(file.path(R.home("bin"), "exec", "R"), dir(R.home("lib"), pattern = pat, full.names = TRUE), dir(R.home("modules"), pattern = pat, full.names = TRUE)) - fdata <- do.call(rbind, lapply(ofiles, readFileSyms)) - subset(fdata, type == "T")$name + data <- do.call(rbind, lapply(ofiles, readFileSyms)) + fdata <- data[data$type == "T", ] + fdata$name } Rfuns <- function() { @@ -277,7 +281,8 @@ checkAllPkgsAPI <- function(lib.loc = NULL, priority = NULL, all = FALSE, checkOne <- function(pkg) { data <- checkPkgAPI(pkg, lib.loc = lib.loc) if (! is.null(data)) - transform(data, pkg = rep(pkg, nrow(data))) + data$pkg <- rep(pkg, nrow(data)) + data } val <- do.call(rbind, .package_apply(p, checkOne, Ncpus = Ncpus, verbose = verbose)) From b3133c253e72c7ae069e0d46964c9458a7219eaa Mon Sep 17 00:00:00 2001 From: hornik Date: Fri, 24 May 2024 11:02:59 +0000 Subject: [PATCH 103/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86609 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index f7ada4f1d23..3d166817268 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -79,7 +79,7 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "South Africa (Johannesburg) [https]","South Africa",Johannesburg,https://cran.mirror.ac.za/,"TENET, Johannesburg","mirroradmin # tenet.ac.za",1,za,"secure_mirror_from_master" "Spain (A CoruƱa) [https]","Spain","A CoruƱa",https://ftp.cixug.es/CRAN/,"Oficina de software libre (CIXUG)","",1,es,"secure_mirror_from_master" "Spain (Madrid) [https]",Spain,Madrid,https://cran.rediris.es/,"Spanish National Research Network, Madrid","Jose Manuel Macias ",1,es,"secure_mirror_from_master" -"Sweden (UmeĆ„) [https]",Sweden,UmeĆ„,https://ftp.acc.umu.se/mirror/CRAN/,"Academic Computer Club, UmeĆ„ University","",1,se,"secure_mirror_from_master" +"Sweden (UmeĆ„) [https]",Sweden,UmeĆ„,https://mirror.accum.se/mirror/CRAN/,"Academic Computer Club in UmeĆ„, Sweden","",1,se,"secure_mirror_from_master" "Switzerland (Zurich 1) [https]",Switzerland,ZĆ¼rich,https://stat.ethz.ch/CRAN/,"ETH ZĆ¼rich","Martin.Maechler # R-project.org",1,ch,"secure_mirror_from_master" "Switzerland (Zurich 2) [https]",Switzerland,ZĆ¼rich,https://mirror.metanet.ch/cran/," METNET AG","mirror # metanet.ch",1,ch "Taiwan (Taipei) [https]",Taiwan,Taipei,https://cran.csie.ntu.edu.tw/,"National Taiwan University, Taipei","b90098 # csie.ntu.edu.tw",1,tw,"secure_mirror_from_master" From 685baa84532ee09727f04725d5128f39d564bea5 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 24 May 2024 14:32:47 +0000 Subject: [PATCH 104/546] Mark a few more things as in an API. git-svn-id: https://svn.r-project.org/R/trunk@86610 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index a404d6f2c21..5bd02943973 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -12879,6 +12879,8 @@ SEXP out(SEXP x, SEXP y) @} @end group @end example +@apivar R_NamesSymbol +@apivar R_DimNamesSymbol This example introduces several new features. The @code{getAttrib} and @code{setAttrib} @@ -13025,6 +13027,7 @@ SEXP getListElement(SEXP list, const char *str) @} @end group @end example +@apivar R_NilValue @noindent and enables us to say @@ -14227,8 +14230,8 @@ The source references added by the parser are recorded by @R{}'s evaluator as it evaluates code. Two functions make these available to debuggers running C code: @findex R_Srcref -@findex R_GetCurrentSrcref -@findex R_GetSrcFilename +@apifun R_GetCurrentSrcref +@apifun R_GetSrcFilename @example SEXP R_GetCurrentSrcref(int skip); @@ -17477,6 +17480,7 @@ void R_CleanUp (SA_TYPE saveact, int status, int RunLast) @embfun R_SaveGlobalEnv @embfun Rf_KillAllDevices @embfun CleanEd +@embfun R_CleanUp @embfun fpu_setup These callbacks should never be changed in a running @R{} session (and From cb211c3a3563d2fa140826fbc5e583b814e99751 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 24 May 2024 18:40:52 +0000 Subject: [PATCH 105/546] Hide some entry point in memory.c not used on CRAN/BIOC or in current API. git-svn-id: https://svn.r-project.org/R/trunk@86611 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/Rdll.hide | 42 ++++++++++++++++++++++++--- src/main/memory.c | 64 +++++++++++++++++++++++++++--------------- 2 files changed, 80 insertions(+), 26 deletions(-) diff --git a/src/gnuwin32/Rdll.hide b/src/gnuwin32/Rdll.hide index 244a1e78c43..d22b6724308 100644 --- a/src/gnuwin32/Rdll.hide +++ b/src/gnuwin32/Rdll.hide @@ -12,6 +12,7 @@ ALTREP_UNSERIALIZE_EX ALTSTRING_SET_ELT ALTVEC_EXTRACT_SUBSET + ASSIGNMENT_PENDING BASE_SYM_CACHED BINDING_IS_LOCKED BM_norm_keep @@ -54,19 +55,26 @@ BZ2_hbMakeCodeLengths BZ2_indexIntoF BZ2_rNums + CAR0 CONS_NR CPFun ConsoleAcceptCmd + DECREMENT_REFCNT + DISABLE_REFCNT DebugMenuitem DefaultPalette + ENABLE_REFCNT + ENSURE_NAMED EhiWakeUp EncodeEnvironment EncodeExtptr EncodeReal2 HASHASH - INIT_BNDCELL IF_PROMSXP_SET_PRVALUE + INCREMENT_REFCNT + INIT_BNDCELL IS_ACTIVE_BINDING + IS_ASSIGNMENT_CALL IS_BYTES IS_LATIN1 IS_SPECIAL_SYMBOL @@ -76,15 +84,24 @@ Init_R_Variables LOCK_BINDING LoadInitFile + MARK + MARK_ASSIGNMENT_CALL + MAYBEJIT MDIset MDIsize + MISSING MainThread + NOJIT NO_SPECIAL_SYMBOLS + PROMISE_IS_EVALUATED + PROMISE_TAG PrintUsage ProfileEvent - PROMISE_IS_EVALUATED + RAISE_NAMED REvprintf_internal RExitContext + RSTEP + RTRACE R_BCIntActive R_BCNodeStackBase R_BCProtReset @@ -222,6 +239,7 @@ R_XDRDecodeInteger R_XDREncodeDouble R_XDREncodeInteger + R_allocObject R_args_enable_refcnt R_binary R_checkConstants @@ -252,12 +270,14 @@ R_dot_Group R_dot_Methods R_expand_binding_value + R_expand_promise_value R_fgetc R_findBCInterpreterSrcref R_findExecContext R_findParentContext R_fixslash R_flexiblas_info + R_gc_running R_getBCInterpreterExpression R_getClockIncrement R_getCurrentSrcref @@ -351,7 +371,6 @@ Rconn_getline Rcons_vprintf Rconsolesetwidth - Rf_applyClosure Rf_AdobeSymbol2ucs2 Rf_BindDomain Rf_CheckFormals @@ -423,6 +442,7 @@ Rf_WarningMessage Rf_addMissingVarsToNewEnv Rf_allocCharsxp + Rf_applyClosure Rf_asVecSize Rf_bd0 Rf_chebyshev_eval @@ -533,8 +553,10 @@ Rvsnprintf_mbcs Rwin_rename Rwin_wrename + SETTER_CLEAR_NAMED SET_ACTIVE_BINDING_BIT SET_ASCII + SET_ASSIGNMENT_PENDING SET_BASE_SYM_CACHED SET_BNDCELL SET_BNDCELL_DVAL @@ -544,16 +566,28 @@ SET_BYTES SET_CACHED SET_CXTAIL + SET_DDVAL SET_HASHASH + SET_INTERNAL SET_LATIN1 + SET_MAYBEJIT + SET_MISSING + SET_NOJIT SET_NO_SPECIAL_SYMBOLS SET_PRIMOFFSET + SET_PRINTNAME + SET_PROMISE_TAG + SET_RSTEP + SET_RTRACE SET_SPECIAL_SYMBOL + SET_SYMVALUE SET_UTF8 Sys_TempDir + TRACKREFS UNIMPLEMENTED_TYPEt UNLOCK_BINDING UNSET_BASE_SYM_CACHED + UNSET_MAYBEJIT UNSET_NO_SPECIAL_SYMBOLS UNSET_SPECIAL_SYMBOL UTF8in @@ -771,8 +805,8 @@ do_curlGetHeaders do_curlVersion do_date - do_declare do_debug + do_declare do_delayed do_deparse do_detach diff --git a/src/main/memory.c b/src/main/memory.c index 78b0519c942..9c40fc53b27 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -116,7 +116,7 @@ static void gc_error(const char *msg) } /* These are used in profiling to separate out time in GC */ -int R_gc_running(void) { return R_in_gc; } +attribute_hidden int R_gc_running(void) { return R_in_gc; } #ifdef TESTING_WRITE_BARRIER # define PROTECTCHECK @@ -3849,26 +3849,34 @@ DL_FUNC R_ExternalPtrAddrFn(SEXP s) /* General Cons Cell Attributes */ SEXP (ATTRIB)(SEXP x) { return CHK(ATTRIB(CHK(x))); } int (OBJECT)(SEXP x) { return OBJECT(CHK(x)); } -int (MARK)(SEXP x) { return MARK(CHK(x)); } int (TYPEOF)(SEXP x) { return TYPEOF(CHK(x)); } int (NAMED)(SEXP x) { return NAMED(CHK(x)); } -int (RTRACE)(SEXP x) { return RTRACE(CHK(x)); } +attribute_hidden int (RTRACE)(SEXP x) { return RTRACE(CHK(x)); } int (LEVELS)(SEXP x) { return LEVELS(CHK(x)); } int (REFCNT)(SEXP x) { return REFCNT(CHK(x)); } -int (TRACKREFS)(SEXP x) { return TRACKREFS(CHK(x)); } +attribute_hidden int (TRACKREFS)(SEXP x) { return TRACKREFS(CHK(x)); } int (ALTREP)(SEXP x) { return ALTREP(CHK(x)); } int (IS_SCALAR)(SEXP x, int type) { return IS_SCALAR(CHK(x), type); } +void (MARK_NOT_MUTABLE)(SEXP x) { MARK_NOT_MUTABLE(CHK(x)); } + +attribute_hidden int (MARK)(SEXP x) { return MARK(CHK(x)); } +attribute_hidden void (DECREMENT_REFCNT)(SEXP x) { DECREMENT_REFCNT(CHK(x)); } +attribute_hidden void (INCREMENT_REFCNT)(SEXP x) { INCREMENT_REFCNT(CHK(x)); } +attribute_hidden void (DISABLE_REFCNT)(SEXP x) { DISABLE_REFCNT(CHK(x)); } +attribute_hidden void (ENABLE_REFCNT)(SEXP x) { ENABLE_REFCNT(CHK(x)); } -void (MARK_NOT_MUTABLE)(SEXP x) { MARK_NOT_MUTABLE(CHK(x)); } +attribute_hidden int (ASSIGNMENT_PENDING)(SEXP x) { return ASSIGNMENT_PENDING(CHK(x)); } -void (SET_ASSIGNMENT_PENDING)(SEXP x, int v) +attribute_hidden void (SET_ASSIGNMENT_PENDING)(SEXP x, int v) { SET_ASSIGNMENT_PENDING(CHK(x), v); } +attribute_hidden int (IS_ASSIGNMENT_CALL)(SEXP x) { return IS_ASSIGNMENT_CALL(CHK(x)); } +attribute_hidden void (MARK_ASSIGNMENT_CALL)(SEXP x) { MARK_ASSIGNMENT_CALL(CHK(x)); } void (SET_ATTRIB)(SEXP x, SEXP v) { @@ -3887,6 +3895,7 @@ void (SET_NAMED)(SEXP x, int v) SET_NAMED(CHK(x), v); #endif } +attribute_hidden void (SET_RTRACE)(SEXP x, int v) { SET_RTRACE(CHK(x), v); } int (SETLEVELS)(SEXP x, int v) { return SETLEVELS(CHK(x), v); } void DUPLICATE_ATTRIB(SEXP to, SEXP from) { @@ -3901,8 +3910,10 @@ void SHALLOW_DUPLICATE_ATTRIB(SEXP to, SEXP from) { } void (ENSURE_NAMEDMAX)(SEXP x) { ENSURE_NAMEDMAX(CHK(x)); } -void (ENSURE_NAMED)(SEXP x) { ENSURE_NAMED(CHK(x)); } +attribute_hidden void (ENSURE_NAMED)(SEXP x) { ENSURE_NAMED(CHK(x)); } +attribute_hidden void (SETTER_CLEAR_NAMED)(SEXP x) { SETTER_CLEAR_NAMED(CHK(x)); } +attribute_hidden void (RAISE_NAMED)(SEXP x, int n) { RAISE_NAMED(CHK(x), n); } /* S4 object testing */ @@ -3911,11 +3922,11 @@ void (SET_S4_OBJECT)(SEXP x){ SET_S4_OBJECT(CHK(x)); } void (UNSET_S4_OBJECT)(SEXP x){ UNSET_S4_OBJECT(CHK(x)); } /* JIT optimization support */ -int (NOJIT)(SEXP x) { return NOJIT(CHK(x)); } -int (MAYBEJIT)(SEXP x) { return MAYBEJIT(CHK(x)); } -void (SET_NOJIT)(SEXP x) { SET_NOJIT(CHK(x)); } -void (SET_MAYBEJIT)(SEXP x) { SET_MAYBEJIT(CHK(x)); } -void (UNSET_MAYBEJIT)(SEXP x) { UNSET_MAYBEJIT(CHK(x)); } +attribute_hidden int (NOJIT)(SEXP x) { return NOJIT(CHK(x)); } +attribute_hidden int (MAYBEJIT)(SEXP x) { return MAYBEJIT(CHK(x)); } +attribute_hidden void (SET_NOJIT)(SEXP x) { SET_NOJIT(CHK(x)); } +attribute_hidden void (SET_MAYBEJIT)(SEXP x) { SET_MAYBEJIT(CHK(x)); } +attribute_hidden void (UNSET_MAYBEJIT)(SEXP x) { UNSET_MAYBEJIT(CHK(x)); } /* Growable vector support */ int (IS_GROWABLE)(SEXP x) { return IS_GROWABLE(CHK(x)); } @@ -3954,9 +3965,11 @@ void (SETLENGTH)(SEXP x, R_xlen_t v) void (SET_TRUELENGTH)(SEXP x, R_xlen_t v) { SET_TRUELENGTH(CHK2(x), v); } int (IS_LONG_VEC)(SEXP x) { return IS_LONG_VEC(CHK2(x)); } #ifdef TESTING_WRITE_BARRIER +attribute_hidden R_xlen_t (STDVEC_LENGTH)(SEXP x) { return STDVEC_LENGTH(CHK2(x)); } +attribute_hidden R_xlen_t (STDVEC_TRUELENGTH)(SEXP x) { return STDVEC_TRUELENGTH(CHK2(x)); } -void (SETALTREP)(SEXP x, int v) { SETALTREP(x, v); } +attribute_hidden void (SETALTREP)(SEXP x, int v) { SETALTREP(x, v); } #endif /* temporary, to ease transition away from remapping */ @@ -4325,7 +4338,7 @@ attribute_hidden void R_try_clear_args_refcnt(SEXP args) /* List Accessors */ SEXP (TAG)(SEXP e) { return CHK(TAG(CHKCONS(e))); } -SEXP (CAR0)(SEXP e) { return CHK(CAR0(CHKCONS(e))); } +attribute_hidden SEXP (CAR0)(SEXP e) { return CHK(CAR0(CHKCONS(e))); } SEXP (CDR)(SEXP e) { return CHK(CDR(CHKCONS(e))); } SEXP (CAAR)(SEXP e) { return CHK(CAAR(CHKCONS(e))); } SEXP (CDAR)(SEXP e) { return CHK(CDAR(CHKCONS(e))); } @@ -4336,7 +4349,7 @@ SEXP (CADDR)(SEXP e) { return CHK(CADDR(CHKCONS(e))); } SEXP (CADDDR)(SEXP e) { return CHK(CADDDR(CHKCONS(e))); } SEXP (CAD4R)(SEXP e) { return CHK(CAD4R(CHKCONS(e))); } SEXP (CAD5R)(SEXP e) { return CHK(CAD5R(CHKCONS(e))); } -int (MISSING)(SEXP x) { return MISSING(CHKCONS(x)); } +attribute_hidden int (MISSING)(SEXP x) { return MISSING(CHKCONS(x)); } void (SET_TAG)(SEXP x, SEXP v) { @@ -4443,6 +4456,7 @@ SEXP (EXTPTR_PROT)(SEXP x) { return EXTPTR_PROT(CHK(x)); } SEXP (EXTPTR_TAG)(SEXP x) { return EXTPTR_TAG(CHK(x)); } void *(EXTPTR_PTR)(SEXP x) { return EXTPTR_PTR(CHK(x)); } +attribute_hidden void (SET_MISSING)(SEXP x, int v) { SET_MISSING(CHKCONS(x), v); } /* Closure Accessors */ @@ -4450,12 +4464,13 @@ SEXP (FORMALS)(SEXP x) { return CHK(FORMALS(CHK(x))); } SEXP (BODY)(SEXP x) { return CHK(BODY(CHK(x))); } SEXP (CLOENV)(SEXP x) { return CHK(CLOENV(CHK(x))); } int (RDEBUG)(SEXP x) { return RDEBUG(CHK(x)); } -int (RSTEP)(SEXP x) { return RSTEP(CHK(x)); } +attribute_hidden int (RSTEP)(SEXP x) { return RSTEP(CHK(x)); } void (SET_FORMALS)(SEXP x, SEXP v) { FIX_REFCNT(x, FORMALS(x), v); CHECK_OLD_TO_NEW(x, v); FORMALS(x) = v; } void (SET_BODY)(SEXP x, SEXP v) { FIX_REFCNT(x, BODY(x), v); CHECK_OLD_TO_NEW(x, v); BODY(x) = v; } void (SET_CLOENV)(SEXP x, SEXP v) { FIX_REFCNT(x, CLOENV(x), v); CHECK_OLD_TO_NEW(x, v); CLOENV(x) = v; } void (SET_RDEBUG)(SEXP x, int v) { SET_RDEBUG(CHK(x), v); } +attribute_hidden void (SET_RSTEP)(SEXP x, int v) { SET_RSTEP(CHK(x), v); } /* These are only needed with the write barrier on */ @@ -4473,8 +4488,10 @@ SEXP (SYMVALUE)(SEXP x) { return CHK(SYMVALUE(CHK(x))); } SEXP (INTERNAL)(SEXP x) { return CHK(INTERNAL(CHK(x))); } int (DDVAL)(SEXP x) { return DDVAL(CHK(x)); } +attribute_hidden void (SET_PRINTNAME)(SEXP x, SEXP v) { FIX_REFCNT(x, PRINTNAME(x), v); CHECK_OLD_TO_NEW(x, v); PRINTNAME(x) = v; } +attribute_hidden void (SET_SYMVALUE)(SEXP x, SEXP v) { if (SYMVALUE(x) == v) @@ -4484,8 +4501,13 @@ void (SET_SYMVALUE)(SEXP x, SEXP v) SYMVALUE(x) = v; } -void (SET_INTERNAL)(SEXP x, SEXP v) { FIX_REFCNT(x, INTERNAL(x), v); CHECK_OLD_TO_NEW(x, v); INTERNAL(x) = v; } -void (SET_DDVAL)(SEXP x, int v) { SET_DDVAL(CHK(x), v); } +attribute_hidden +void (SET_INTERNAL)(SEXP x, SEXP v) { + FIX_REFCNT(x, INTERNAL(x), v); + CHECK_OLD_TO_NEW(x, v); + INTERNAL(x) = v; +} +attribute_hidden void (SET_DDVAL)(SEXP x, int v) { SET_DDVAL(CHK(x), v); } /* Environment Accessors */ SEXP (FRAME)(SEXP x) { return CHK(FRAME(CHK(x))); } @@ -4783,8 +4805,7 @@ void *R_AllocStringBuffer(size_t blen, R_StringBuffer *buf) return buf->data; } -void -R_FreeStringBuffer(R_StringBuffer *buf) +void R_FreeStringBuffer(R_StringBuffer *buf) { if (buf->data != NULL) { free(buf->data); @@ -4793,8 +4814,7 @@ R_FreeStringBuffer(R_StringBuffer *buf) } } -attribute_hidden void -R_FreeStringBufferL(R_StringBuffer *buf) +void R_FreeStringBufferL(R_StringBuffer *buf) { if (buf->bufsize > buf->defaultSize) { free(buf->data); From 88df503f595efddbf9612d99674dd5ea892a0257 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 24 May 2024 23:25:23 +0000 Subject: [PATCH 106/546] Hide some more entry points. git-svn-id: https://svn.r-project.org/R/trunk@86612 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/altrep.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/altrep.c b/src/main/altrep.c index 5f82b31c927..01befe9b67d 100644 --- a/src/main/altrep.c +++ b/src/main/altrep.c @@ -337,12 +337,12 @@ ALTREP_UNSERIALIZE_EX(SEXP info, SEXP state, SEXP attr, int objf, int levs) return val; } -R_xlen_t /*attribute_hidden*/ ALTREP_LENGTH(SEXP x) +/*attribute_hidden*/ R_xlen_t ALTREP_LENGTH(SEXP x) { return ALTREP_DISPATCH(Length, x); } -R_xlen_t /*attribute_hidden*/ ALTREP_TRUELENGTH(SEXP x) { return 0; } +attribute_hidden R_xlen_t ALTREP_TRUELENGTH(SEXP x) { return 0; } /* @@ -371,17 +371,17 @@ static R_INLINE void *ALTVEC_DATAPTR_EX(SEXP x, Rboolean writable) return val; } -void /*attribute_hidden*/ *ALTVEC_DATAPTR(SEXP x) +/*attribute_hidden*/ void *ALTVEC_DATAPTR(SEXP x) { return ALTVEC_DATAPTR_EX(x, TRUE); } -const void /*attribute_hidden*/ *ALTVEC_DATAPTR_RO(SEXP x) +/*attribute_hidden*/ const void *ALTVEC_DATAPTR_RO(SEXP x) { return ALTVEC_DATAPTR_EX(x, FALSE); } -const void /*attribute_hidden*/ *ALTVEC_DATAPTR_OR_NULL(SEXP x) +attribute_hidden const void *ALTVEC_DATAPTR_OR_NULL(SEXP x) { return ALTVEC_DISPATCH(Dataptr_or_null, x); } @@ -471,7 +471,7 @@ R_xlen_t LOGICAL_GET_REGION(SEXP sx, R_xlen_t i, R_xlen_t n, int *buf) return ALTLOGICAL_DISPATCH(Get_region, sx, i, n, buf); } -int LOGICAL_IS_SORTED(SEXP x) +attribute_hidden int LOGICAL_IS_SORTED(SEXP x) { return ALTREP(x) ? ALTLOGICAL_DISPATCH(Is_sorted, x) : UNKNOWN_SORTEDNESS; } @@ -556,7 +556,7 @@ int STRING_NO_NA(SEXP x) return ALTREP(x) ? ALTSTRING_DISPATCH(No_NA, x) : 0; } -SEXP /*attribute_hidden*/ ALTLIST_ELT(SEXP x, R_xlen_t i) +attribute_hidden SEXP ALTLIST_ELT(SEXP x, R_xlen_t i) { SEXP val = NULL; @@ -573,7 +573,7 @@ SEXP /*attribute_hidden*/ ALTLIST_ELT(SEXP x, R_xlen_t i) return val; } -void attribute_hidden ALTLIST_SET_ELT(SEXP x, R_xlen_t i, SEXP v) +attribute_hidden void ALTLIST_SET_ELT(SEXP x, R_xlen_t i, SEXP v) { /**** move GC disabling into method? */ if (R_in_gc) @@ -587,39 +587,39 @@ void attribute_hidden ALTLIST_SET_ELT(SEXP x, R_xlen_t i, SEXP v) R_GCEnabled = enabled; } -SEXP ALTINTEGER_SUM(SEXP x, Rboolean narm) +attribute_hidden SEXP ALTINTEGER_SUM(SEXP x, Rboolean narm) { return ALTINTEGER_DISPATCH(Sum, x, narm); } -SEXP ALTINTEGER_MIN(SEXP x, Rboolean narm) +attribute_hidden SEXP ALTINTEGER_MIN(SEXP x, Rboolean narm) { return ALTINTEGER_DISPATCH(Min, x, narm); } -SEXP ALTINTEGER_MAX(SEXP x, Rboolean narm) +attribute_hidden SEXP ALTINTEGER_MAX(SEXP x, Rboolean narm) { return ALTINTEGER_DISPATCH(Max, x, narm); } -SEXP ALTREAL_SUM(SEXP x, Rboolean narm) +attribute_hidden SEXP ALTREAL_SUM(SEXP x, Rboolean narm) { return ALTREAL_DISPATCH(Sum, x, narm); } -SEXP ALTREAL_MIN(SEXP x, Rboolean narm) +attribute_hidden SEXP ALTREAL_MIN(SEXP x, Rboolean narm) { return ALTREAL_DISPATCH(Min, x, narm); } -SEXP ALTREAL_MAX(SEXP x, Rboolean narm) +attribute_hidden SEXP ALTREAL_MAX(SEXP x, Rboolean narm) { return ALTREAL_DISPATCH(Max, x, narm); } -SEXP ALTLOGICAL_SUM(SEXP x, Rboolean narm) +attribute_hidden SEXP ALTLOGICAL_SUM(SEXP x, Rboolean narm) { return ALTLOGICAL_DISPATCH(Sum, x, narm); } @@ -644,27 +644,27 @@ attribute_hidden Rbyte ALTRAW_ELT(SEXP x, R_xlen_t i) * Not yet implemented */ -void ALTINTEGER_SET_ELT(SEXP x, R_xlen_t i, int v) +attribute_hidden void ALTINTEGER_SET_ELT(SEXP x, R_xlen_t i, int v) { INTEGER(x)[i] = v; /* dispatch here */ } -void ALTLOGICAL_SET_ELT(SEXP x, R_xlen_t i, int v) +attribute_hidden void ALTLOGICAL_SET_ELT(SEXP x, R_xlen_t i, int v) { LOGICAL(x)[i] = v; /* dispatch here */ } -void ALTREAL_SET_ELT(SEXP x, R_xlen_t i, double v) +attribute_hidden void ALTREAL_SET_ELT(SEXP x, R_xlen_t i, double v) { REAL(x)[i] = v; /* dispatch here */ } -void ALTCOMPLEX_SET_ELT(SEXP x, R_xlen_t i, Rcomplex v) +attribute_hidden void ALTCOMPLEX_SET_ELT(SEXP x, R_xlen_t i, Rcomplex v) { COMPLEX(x)[i] = v; /* dispatch here */ } -void ALTRAW_SET_ELT(SEXP x, R_xlen_t i, Rbyte v) +attribute_hidden void ALTRAW_SET_ELT(SEXP x, R_xlen_t i, Rbyte v) { RAW(x)[i] = v; /* dispatch here */ } From 9af719f2b64ae33d82e1023224029a23792d1779 Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 25 May 2024 02:18:15 +0000 Subject: [PATCH 107/546] Add allocLang to make it easier to avoid using SET_TYPEOF. git-svn-id: https://svn.r-project.org/R/trunk@86613 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 6 ++++-- src/include/Rinternals.h | 2 ++ src/main/memory.c | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 5bd02943973..378dd7653c1 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -12986,6 +12986,7 @@ LISP-like lists (now called ``pairlists'') to S-like generic vectors. As a result, the appropriate test for an object of mode @code{list} is @code{isNewList}, and we need @code{allocVector(VECSXP, @var{n}}) and @emph{not} @code{allocList(@var{n})}. +@apifun allocList List elements can be retrieved or set by direct access to the elements of the generic vector. Suppose we have a list object @@ -13816,8 +13817,9 @@ and evaluating, consider the following fragment of eval(s, env); UNPROTECT(1); @end example -@findex allocList -@apifun SET_TAG +@apifun allocList +@apifun allocLang +@comment mention allocLang and get rid of SET_TYPEOF @noindent At this point @code{CAR(a)} is the @R{} object to be printed, the diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index 05cea62a5d8..e7104093d20 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -485,6 +485,7 @@ char * Rf_acopy_string(const char *); SEXP Rf_alloc3DArray(SEXPTYPE, int, int, int); SEXP Rf_allocArray(SEXPTYPE, SEXP); SEXP Rf_allocMatrix(SEXPTYPE, int, int); +SEXP Rf_allocLang(int); SEXP Rf_allocList(int); SEXP Rf_allocS4Object(void); SEXP Rf_allocSExp(SEXPTYPE); @@ -863,6 +864,7 @@ void R_orderVector1(int *indx, int n, SEXP x, Rboolean nalast, Rboolean de #define allocFormalsList4 Rf_allocFormalsList4 #define allocFormalsList5 Rf_allocFormalsList5 #define allocFormalsList6 Rf_allocFormalsList6 +#define allocLang Rf_allocLang #define allocList Rf_allocList #define allocMatrix Rf_allocMatrix #define allocS4Object Rf_allocS4Object diff --git a/src/main/memory.c b/src/main/memory.c index 9c40fc53b27..160446e93a1 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -2994,6 +2994,14 @@ SEXP allocList(int n) return result; } +SEXP allocLang(int n) +{ + if (n > 0) + return LCONS(R_NilValue, allocList(n - 1)); + else + return R_NilValue; +} + SEXP allocS4Object(void) { SEXP s; From 9702d680dacdfd1518248b466264456a5edaa679 Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 25 May 2024 12:04:09 +0000 Subject: [PATCH 108/546] Add entry for allocLang. git-svn-id: https://svn.r-project.org/R/trunk@86614 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 514c842da28..78e3ff18c1c 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -73,6 +73,10 @@ are used to produce indices for API, experimental API, and embedded API entry points in the rendered versions. This is very preliminary and may be dropped if a better approach emerges. + + \item The new function \code{Rf_allocLang} is now available. This + provides an alternative to the idiom of calling + \code{Rf_allocList} followed by \code{SET_TYPEOF}. } } From 81a6e9218ca722cfe86696534818c9600a9559ff Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 25 May 2024 12:38:08 +0000 Subject: [PATCH 109/546] The SET_TYPEOF function in memory.c now throws an error if old and new types are not compatible in memory layout and content. git-svn-id: https://svn.r-project.org/R/trunk@86615 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 8 +++++- src/main/altclasses.c | 4 ++- src/main/altrep.c | 3 ++- src/main/memory.c | 59 ++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 70 insertions(+), 4 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 78e3ff18c1c..9256713e267 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -76,7 +76,13 @@ \item The new function \code{Rf_allocLang} is now available. This provides an alternative to the idiom of calling - \code{Rf_allocList} followed by \code{SET_TYPEOF}. + \code{Rf_allocList} followed by \code{SET_TYPEOF}. + + \item \code{SET_TYPEOF} now signals an error unless the old and + new types have compatible memory structure and content. Use of + \code{SET_TYPE} in package C code should be avoided and may be + deprecated in the near future. It is better to allocate an object + of the proper type in the first place. } } diff --git a/src/main/altclasses.c b/src/main/altclasses.c index aba36a03e15..ce2015a3abd 100644 --- a/src/main/altclasses.c +++ b/src/main/altclasses.c @@ -2047,7 +2047,9 @@ attribute_hidden SEXP R_tryUnwrap(SEXP x) /* Clear the fields to drop reference counts and set the type to LISTSXP to limit errors in case the object is still live. */ - SET_TYPEOF(x, LISTSXP); + void ALTREP_SET_TYPEOF(SEXP, int); /* in memory.c */ + ALTREP_SET_TYPEOF(x, LISTSXP); + SETALTREP(x, 0); SET_ATTRIB(x, R_NilValue); SETCAR(x, R_NilValue); SETCDR(x, R_NilValue); diff --git a/src/main/altrep.c b/src/main/altrep.c index 01befe9b67d..75bc66c92fd 100644 --- a/src/main/altrep.c +++ b/src/main/altrep.c @@ -1149,10 +1149,11 @@ DEFINE_METHOD_SETTER(altlist, Set_elt) SEXP R_new_altrep(R_altrep_class_t aclass, SEXP data1, SEXP data2) { + void ALTREP_SET_TYPEOF(SEXP, int); /* in memory.c */ SEXP sclass = R_SEXP(aclass); int type = ALTREP_CLASS_BASE_TYPE(sclass); SEXP ans = CONS(data1, data2); - SET_TYPEOF(ans, type); + ALTREP_SET_TYPEOF(ans, type); SET_ALTREP_CLASS(ans, sclass); return ans; } diff --git a/src/main/memory.c b/src/main/memory.c index 160446e93a1..c7aa785251c 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -3896,7 +3896,6 @@ void (SET_ATTRIB)(SEXP x, SEXP v) { ATTRIB(x) = v; } void (SET_OBJECT)(SEXP x, int v) { SET_OBJECT(CHK(x), v); } -void (SET_TYPEOF)(SEXP x, int v) { SET_TYPEOF(CHK(x), v); } void (SET_NAMED)(SEXP x, int v) { #ifndef SWITCH_TO_REFCNT @@ -3917,6 +3916,64 @@ void SHALLOW_DUPLICATE_ATTRIB(SEXP to, SEXP from) { IS_S4_OBJECT(from) ? SET_S4_OBJECT(to) : UNSET_S4_OBJECT(to); } +NORET static void bad_SET_TYPEOF(int from, int to) +{ + error(_("can't change type from %s to %s"), + sexptype2char(from), sexptype2char(to)); +} + +static void check_SET_TYPEOF(SEXP x, int v) +{ + if (ALTREP(x)) + error(_("can't change the type of an ALTREP object from %s to %s"), + sexptype2char(TYPEOF(x)), sexptype2char(v)); + switch (TYPEOF(x)) { + case LISTSXP: + case LANGSXP: + case DOTSXP: + if (BNDCELL_TAG(x)) + error(_("can't change the type of a binding cell")); + switch (v) { + case LISTSXP: + case LANGSXP: + case DOTSXP: + case BCODESXP: return; + default: bad_SET_TYPEOF(TYPEOF(x), v); + } + case INTSXP: + case LGLSXP: + switch (v) { + case INTSXP: + case LGLSXP: return; + default: bad_SET_TYPEOF(TYPEOF(x), v); + } + case VECSXP: + case EXPRSXP: + switch (v) { + case VECSXP: + case EXPRSXP: return; + default: bad_SET_TYPEOF(TYPEOF(x), v); + } + default: bad_SET_TYPEOF(TYPEOF(x), v); + } +} + +void (SET_TYPEOF)(SEXP x, int v) +{ + /* Ideally this should not exist as a function outsie of base, but + it was shown in WRE and is used in a good number of packages. + So try to make it a little safer by only allowing some type + changes. + */ + if (TYPEOF(CHK(x)) != v) { + check_SET_TYPEOF(x, v); + SET_TYPEOF(CHK(x), v); + } +} + +attribute_hidden +void (ALTREP_SET_TYPEOF)(SEXP x, int v) { SET_TYPEOF(CHK(x), v); } + void (ENSURE_NAMEDMAX)(SEXP x) { ENSURE_NAMEDMAX(CHK(x)); } attribute_hidden void (ENSURE_NAMED)(SEXP x) { ENSURE_NAMED(CHK(x)); } attribute_hidden From 6f5e6335c6bbdbf358aac1ae92a9594a6377852a Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 25 May 2024 14:01:50 +0000 Subject: [PATCH 110/546] Update call example to use allocLang instead of allocList/SET_TYPEOF. git-svn-id: https://svn.r-project.org/R/trunk@86617 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 378dd7653c1..3d16d6c21da 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13798,18 +13798,12 @@ this will only be clear to those with a knowledge of a LISP-like language. As a more comprehensive example of constructing an @R{} call in C code -and evaluating, consider the following fragment of -@code{printAttributes} in @file{src/main/print.c}. +and evaluating, consider the following fragment. Similar code appears in +the definition of @code{do_docall} in @file{src/main/coerce.c}. @example - /* Need to construct a call to - print(CAR(a), digits=digits) - based on the R_print structure, then eval(call, env). - See do_docall for the template for this sort of thing. - */ SEXP s, t; - t = s = PROTECT(allocList(3)); - SET_TYPEOF(s, LANGSXP); + t = s = PROTECT(allocLang(3)); SETCAR(t, install("print")); t = CDR(t); SETCAR(t, CAR(a)); t = CDR(t); SETCAR(t, ScalarInteger(digits)); @@ -13817,9 +13811,15 @@ and evaluating, consider the following fragment of eval(s, env); UNPROTECT(1); @end example -@apifun allocList @apifun allocLang -@comment mention allocLang and get rid of SET_TYPEOF +@apifun SET_TAG +The function @code{allocLang} is available as of @R{} 4 4.1; for older +versions replace @code{allocLang(3)} with +@example +LCONS(R_NilValue, allocList(2)) +@end example +@apifun LCONS +@apifun allocList @noindent At this point @code{CAR(a)} is the @R{} object to be printed, the From 8e74f3a7bbd31776e3fcd4c50c05aabaa78da78e Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 25 May 2024 14:31:03 +0000 Subject: [PATCH 111/546] Replace allocList/SET_TYPEOF idiom with allocLang. git-svn-id: https://svn.r-project.org/R/trunk@86618 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/stats/src/deriv.c | 3 +-- src/library/stats/src/model.c | 3 +-- src/main/attrib.c | 3 +-- src/main/coerce.c | 3 +-- src/main/eval.c | 3 +-- src/main/options.c | 3 +-- src/main/subset.c | 3 +-- 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/library/stats/src/deriv.c b/src/library/stats/src/deriv.c index 9f4b005473e..1d117ec630b 100644 --- a/src/library/stats/src/deriv.c +++ b/src/library/stats/src/deriv.c @@ -487,8 +487,7 @@ static SEXP D(SEXP expr, SEXP var) UNPROTECT(4); } else if (CAR(expr) == SqrtSymbol) { - PROTECT(expr1 = allocList(3)); - SET_TYPEOF(expr1, LANGSXP); + PROTECT(expr1 = allocLang(3)); SETCAR(expr1, PowerSymbol); SETCADR(expr1, CADR(expr)); SETCADDR(expr1, Constant(0.5)); diff --git a/src/library/stats/src/model.c b/src/library/stats/src/model.c index ab27b5963a8..6ef57808e5c 100644 --- a/src/library/stats/src/model.c +++ b/src/library/stats/src/model.c @@ -484,8 +484,7 @@ SEXP modelmatrix(SEXP call, SEXP op, SEXP args, SEXP rho) PROTECT(contr1 = allocVector(VECSXP, nVar)); PROTECT(contr2 = allocVector(VECSXP, nVar)); - PROTECT(expr = allocList(3)); - SET_TYPEOF(expr, LANGSXP); + PROTECT(expr = allocLang(3)); SETCAR(expr, install("contrasts")); SETCADDR(expr, allocVector(LGLSXP, 1)); diff --git a/src/main/attrib.c b/src/main/attrib.c index 4f7a103ba9d..603ae178143 100644 --- a/src/main/attrib.c +++ b/src/main/attrib.c @@ -929,8 +929,7 @@ attribute_hidden SEXP do_namesgets(SEXP call, SEXP op, SEXP args, SEXP env) SEXP names = CADR(args); if (names != R_NilValue && ! (TYPEOF(names) == STRSXP && ATTRIB(names) == R_NilValue)) { - PROTECT(call = allocList(2)); - SET_TYPEOF(call, LANGSXP); + PROTECT(call = allocLang(2)); SETCAR(call, R_AsCharacterSymbol); SETCADR(call, names); names = eval(call, env); diff --git a/src/main/coerce.c b/src/main/coerce.c index bc3c1f12deb..2c8fb8a0375 100644 --- a/src/main/coerce.c +++ b/src/main/coerce.c @@ -2737,8 +2737,7 @@ attribute_hidden SEXP do_docall(SEXP call, SEXP op, SEXP args, SEXP rho) n = length(args); PROTECT(names = getAttrib(args, R_NamesSymbol)); - PROTECT(c = call = allocList(n + 1)); - SET_TYPEOF(c, LANGSXP); + PROTECT(c = call = allocLang(n + 1)); if( isString(fun) ) { const char *str = translateChar(STRING_ELT(fun, 0)); if (streql(str, ".Internal")) error("illegal usage"); diff --git a/src/main/eval.c b/src/main/eval.c index f97d52cef7b..5fcd0379116 100644 --- a/src/main/eval.c +++ b/src/main/eval.c @@ -2629,7 +2629,7 @@ static SEXP replaceCall(SEXP fun, SEXP val, SEXP args, SEXP rhs) PROTECT(args); PROTECT(rhs); PROTECT(val); - ptmp = tmp = allocList(length(args)+3); + ptmp = tmp = allocLang(length(args)+3); UNPROTECT(4); SETCAR(ptmp, fun); ptmp = CDR(ptmp); SETCAR(ptmp, val); ptmp = CDR(ptmp); @@ -2641,7 +2641,6 @@ static SEXP replaceCall(SEXP fun, SEXP val, SEXP args, SEXP rhs) } SETCAR(ptmp, rhs); SET_TAG(ptmp, R_valueSym); - SET_TYPEOF(tmp, LANGSXP); MARK_ASSIGNMENT_CALL(tmp); return tmp; } diff --git a/src/main/options.c b/src/main/options.c index ba9ea4c62e3..60077d70e37 100644 --- a/src/main/options.c +++ b/src/main/options.c @@ -117,8 +117,7 @@ static SEXP FindTaggedItem(SEXP lst, SEXP tag) static SEXP makeErrorCall(SEXP fun) { SEXP call; - PROTECT(call = allocList(1)); - SET_TYPEOF(call, LANGSXP); + PROTECT(call = allocLang(1)); SETCAR(call, fun); UNPROTECT(1); return call; diff --git a/src/main/subset.c b/src/main/subset.c index 93a9fbada75..dbef02b252b 100644 --- a/src/main/subset.c +++ b/src/main/subset.c @@ -900,9 +900,8 @@ attribute_hidden SEXP do_subset_dflt(SEXP call, SEXP op, SEXP args, SEXP rho) if (type == LANGSXP) { ax = ans; - PROTECT(ans = allocList(LENGTH(ax))); + PROTECT(ans = allocLang(LENGTH(ax))); if ( LENGTH(ax) > 0 ) { - SET_TYPEOF(ans, LANGSXP); SEXP px; int i; for(px = ans, i = 0 ; px != R_NilValue ; px = CDR(px)) SETCAR(px, VECTOR_ELT(ax, i++)); From d8be69d06d7a52559b9a60ac4b8d2e63d9486347 Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 25 May 2024 20:22:48 +0000 Subject: [PATCH 112/546] Hide some more entry points on Windows to match Linux. git-svn-id: https://svn.r-project.org/R/trunk@86619 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/Rdll.hide | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/gnuwin32/Rdll.hide b/src/gnuwin32/Rdll.hide index d22b6724308..5c065594b68 100644 --- a/src/gnuwin32/Rdll.hide +++ b/src/gnuwin32/Rdll.hide @@ -1,16 +1,32 @@ ALTCOMPLEX_ELT + ALTCOMPLEX_SET_ELT ALTINTEGER_ELT + ALTINTEGER_MAX + ALTINTEGER_MIN + ALTINTEGER_SET_ELT + ALTINTEGER_SUM + ALTLIST_ELT ALTLIST_SET_ELT ALTLOGICAL_ELT + ALTLOGICAL_SET_ELT + ALTLOGICAL_SUM ALTRAW_ELT + ALTRAW_SET_ELT ALTREAL_ELT + ALTREAL_MAX + ALTREAL_MIN + ALTREAL_SET_ELT + ALTREAL_SUM ALTREP_COERCE ALTREP_DUPLICATE_EX ALTREP_INSPECT ALTREP_SERIALIZED_CLASS ALTREP_SERIALIZED_STATE + ALTREP_SET_TYPEOF + ALTREP_TRUELENGTH ALTREP_UNSERIALIZE_EX ALTSTRING_SET_ELT + ALTVEC_DATAPTR_OR_NULL ALTVEC_EXTRACT_SUBSET ASSIGNMENT_PENDING BASE_SYM_CACHED @@ -83,6 +99,7 @@ Init_R_Machine Init_R_Variables LOCK_BINDING + LOGICAL_IS_SORTED LoadInitFile MARK MARK_ASSIGNMENT_CALL @@ -106,6 +123,7 @@ R_BCNodeStackBase R_BCProtReset R_BCProtTop + R_BCRelPC R_BCVersionOK R_BCbody R_BCpc @@ -209,6 +227,7 @@ R_SetMaxNSize R_SetMaxVSize R_SetNconn + R_SetOption R_SetOptionWarn R_SetOptionWidth R_SetPPSize @@ -425,6 +444,7 @@ Rf_PrintVersion Rf_PrintVersionString Rf_PrintVersion_part_1 + Rf_PrintWarnings Rf_RealFromComplex Rf_RealFromInteger Rf_RealFromLogical @@ -536,6 +556,7 @@ Rf_utf8toucs32 Rf_vectorIndex Rf_wcs4toutf8 + Rf_wcstoutf8 Rf_wtransChar2 Rf_yychar Rf_yylval @@ -1250,6 +1271,7 @@ dos_wglobfree drawconsole dt_invalidate_locale + dummy54321 editorchecksave editorcleanall editorsetfont @@ -1512,6 +1534,7 @@ newpager newxbuf nl_Rdummy + orderVector1 pR_ShowMessage pagerMultiple pagerbclose From e44e5de436e2dddb12c2571f29d8f3af1100cfbd Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 25 May 2024 21:24:38 +0000 Subject: [PATCH 113/546] Revert new Windows entry point hiding for now. git-svn-id: https://svn.r-project.org/R/trunk@86620 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/Rdll.hide | 42 ++++-------------------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/src/gnuwin32/Rdll.hide b/src/gnuwin32/Rdll.hide index 5c065594b68..e4cbd1bc8d7 100644 --- a/src/gnuwin32/Rdll.hide +++ b/src/gnuwin32/Rdll.hide @@ -28,7 +28,6 @@ ALTSTRING_SET_ELT ALTVEC_DATAPTR_OR_NULL ALTVEC_EXTRACT_SUBSET - ASSIGNMENT_PENDING BASE_SYM_CACHED BINDING_IS_LOCKED BM_norm_keep @@ -71,26 +70,19 @@ BZ2_hbMakeCodeLengths BZ2_indexIntoF BZ2_rNums - CAR0 CONS_NR CPFun ConsoleAcceptCmd - DECREMENT_REFCNT - DISABLE_REFCNT DebugMenuitem DefaultPalette - ENABLE_REFCNT - ENSURE_NAMED EhiWakeUp EncodeEnvironment EncodeExtptr EncodeReal2 HASHASH - IF_PROMSXP_SET_PRVALUE - INCREMENT_REFCNT INIT_BNDCELL + IF_PROMSXP_SET_PRVALUE IS_ACTIVE_BINDING - IS_ASSIGNMENT_CALL IS_BYTES IS_LATIN1 IS_SPECIAL_SYMBOL @@ -101,24 +93,15 @@ LOCK_BINDING LOGICAL_IS_SORTED LoadInitFile - MARK - MARK_ASSIGNMENT_CALL - MAYBEJIT MDIset MDIsize - MISSING MainThread - NOJIT NO_SPECIAL_SYMBOLS - PROMISE_IS_EVALUATED - PROMISE_TAG PrintUsage ProfileEvent - RAISE_NAMED + PROMISE_IS_EVALUATED REvprintf_internal RExitContext - RSTEP - RTRACE R_BCIntActive R_BCNodeStackBase R_BCProtReset @@ -258,7 +241,6 @@ R_XDRDecodeInteger R_XDREncodeDouble R_XDREncodeInteger - R_allocObject R_args_enable_refcnt R_binary R_checkConstants @@ -289,14 +271,12 @@ R_dot_Group R_dot_Methods R_expand_binding_value - R_expand_promise_value R_fgetc R_findBCInterpreterSrcref R_findExecContext R_findParentContext R_fixslash R_flexiblas_info - R_gc_running R_getBCInterpreterExpression R_getClockIncrement R_getCurrentSrcref @@ -390,6 +370,7 @@ Rconn_getline Rcons_vprintf Rconsolesetwidth + Rf_applyClosure Rf_AdobeSymbol2ucs2 Rf_BindDomain Rf_CheckFormals @@ -462,7 +443,6 @@ Rf_WarningMessage Rf_addMissingVarsToNewEnv Rf_allocCharsxp - Rf_applyClosure Rf_asVecSize Rf_bd0 Rf_chebyshev_eval @@ -574,10 +554,8 @@ Rvsnprintf_mbcs Rwin_rename Rwin_wrename - SETTER_CLEAR_NAMED SET_ACTIVE_BINDING_BIT SET_ASCII - SET_ASSIGNMENT_PENDING SET_BASE_SYM_CACHED SET_BNDCELL SET_BNDCELL_DVAL @@ -587,28 +565,16 @@ SET_BYTES SET_CACHED SET_CXTAIL - SET_DDVAL SET_HASHASH - SET_INTERNAL SET_LATIN1 - SET_MAYBEJIT - SET_MISSING - SET_NOJIT SET_NO_SPECIAL_SYMBOLS SET_PRIMOFFSET - SET_PRINTNAME - SET_PROMISE_TAG - SET_RSTEP - SET_RTRACE SET_SPECIAL_SYMBOL - SET_SYMVALUE SET_UTF8 Sys_TempDir - TRACKREFS UNIMPLEMENTED_TYPEt UNLOCK_BINDING UNSET_BASE_SYM_CACHED - UNSET_MAYBEJIT UNSET_NO_SPECIAL_SYMBOLS UNSET_SPECIAL_SYMBOL UTF8in @@ -826,8 +792,8 @@ do_curlGetHeaders do_curlVersion do_date - do_debug do_declare + do_debug do_delayed do_deparse do_detach From 84321beeaaace2e9971c136d5d8c0e60efb9ee48 Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 25 May 2024 22:24:03 +0000 Subject: [PATCH 114/546] Another try at entry point hiding. git-svn-id: https://svn.r-project.org/R/trunk@86621 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/Rdll.hide | 44 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/src/gnuwin32/Rdll.hide b/src/gnuwin32/Rdll.hide index e4cbd1bc8d7..853f3aeb74e 100644 --- a/src/gnuwin32/Rdll.hide +++ b/src/gnuwin32/Rdll.hide @@ -28,6 +28,7 @@ ALTSTRING_SET_ELT ALTVEC_DATAPTR_OR_NULL ALTVEC_EXTRACT_SUBSET + ASSIGNMENT_PENDING BASE_SYM_CACHED BINDING_IS_LOCKED BM_norm_keep @@ -70,19 +71,27 @@ BZ2_hbMakeCodeLengths BZ2_indexIntoF BZ2_rNums + CAR0 CONS_NR CPFun ConsoleAcceptCmd + DECREMENT_REFCNT + DISABLE_REFCNT DebugMenuitem DefaultPalette + ENABLE_REFCNT + ENSURE_NAMED EhiWakeUp EncodeEnvironment EncodeExtptr EncodeReal2 HASHASH + IF_PROMSXP_SET_PRVALUE + INCREMENT_REFCNT INIT_BNDCELL IF_PROMSXP_SET_PRVALUE IS_ACTIVE_BINDING + IS_ASSIGNMENT_CALL IS_BYTES IS_LATIN1 IS_SPECIAL_SYMBOL @@ -93,15 +102,24 @@ LOCK_BINDING LOGICAL_IS_SORTED LoadInitFile + MARK + MARK_ASSIGNMENT_CALL + MAYBEJIT MDIset MDIsize + MISSING MainThread + NOJIT NO_SPECIAL_SYMBOLS + PROMISE_IS_EVALUATED + PROMISE_TAG PrintUsage ProfileEvent - PROMISE_IS_EVALUATED + RAISE_NAMED REvprintf_internal RExitContext + RSTEP + RTRACE R_BCIntActive R_BCNodeStackBase R_BCProtReset @@ -241,6 +259,7 @@ R_XDRDecodeInteger R_XDREncodeDouble R_XDREncodeInteger + R_allocObject R_args_enable_refcnt R_binary R_checkConstants @@ -271,12 +290,14 @@ R_dot_Group R_dot_Methods R_expand_binding_value + R_expand_promise_value R_fgetc R_findBCInterpreterSrcref R_findExecContext R_findParentContext R_fixslash R_flexiblas_info + R_gc_running R_getBCInterpreterExpression R_getClockIncrement R_getCurrentSrcref @@ -370,7 +391,6 @@ Rconn_getline Rcons_vprintf Rconsolesetwidth - Rf_applyClosure Rf_AdobeSymbol2ucs2 Rf_BindDomain Rf_CheckFormals @@ -443,6 +463,7 @@ Rf_WarningMessage Rf_addMissingVarsToNewEnv Rf_allocCharsxp + Rf_applyClosure Rf_asVecSize Rf_bd0 Rf_chebyshev_eval @@ -536,7 +557,6 @@ Rf_utf8toucs32 Rf_vectorIndex Rf_wcs4toutf8 - Rf_wcstoutf8 Rf_wtransChar2 Rf_yychar Rf_yylval @@ -554,8 +574,10 @@ Rvsnprintf_mbcs Rwin_rename Rwin_wrename + SETTER_CLEAR_NAMED SET_ACTIVE_BINDING_BIT SET_ASCII + SET_ASSIGNMENT_PENDING SET_BASE_SYM_CACHED SET_BNDCELL SET_BNDCELL_DVAL @@ -565,16 +587,28 @@ SET_BYTES SET_CACHED SET_CXTAIL + SET_DDVAL SET_HASHASH + SET_INTERNAL SET_LATIN1 + SET_MAYBEJIT + SET_MISSING + SET_NOJIT SET_NO_SPECIAL_SYMBOLS SET_PRIMOFFSET + SET_PRINTNAME + SET_PROMISE_TAG + SET_RSTEP + SET_RTRACE SET_SPECIAL_SYMBOL + SET_SYMVALUE SET_UTF8 Sys_TempDir + TRACKREFS UNIMPLEMENTED_TYPEt UNLOCK_BINDING UNSET_BASE_SYM_CACHED + UNSET_MAYBEJIT UNSET_NO_SPECIAL_SYMBOLS UNSET_SPECIAL_SYMBOL UTF8in @@ -792,8 +826,8 @@ do_curlGetHeaders do_curlVersion do_date - do_declare do_debug + do_declare do_delayed do_deparse do_detach @@ -1237,7 +1271,6 @@ dos_wglobfree drawconsole dt_invalidate_locale - dummy54321 editorchecksave editorcleanall editorsetfont @@ -1500,7 +1533,6 @@ newpager newxbuf nl_Rdummy - orderVector1 pR_ShowMessage pagerMultiple pagerbclose From abff40fab2e1866cc6f167e9e5054602cbc7668f Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 25 May 2024 22:43:47 +0000 Subject: [PATCH 115/546] Unhide Rf_PrintWarnings. git-svn-id: https://svn.r-project.org/R/trunk@86622 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/Rdll.hide | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gnuwin32/Rdll.hide b/src/gnuwin32/Rdll.hide index 853f3aeb74e..59cbd2077a7 100644 --- a/src/gnuwin32/Rdll.hide +++ b/src/gnuwin32/Rdll.hide @@ -445,7 +445,6 @@ Rf_PrintVersion Rf_PrintVersionString Rf_PrintVersion_part_1 - Rf_PrintWarnings Rf_RealFromComplex Rf_RealFromInteger Rf_RealFromLogical From 62dd8b09461d5d1313f4722d9d63abb463a9e42d Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 26 May 2024 01:24:47 +0000 Subject: [PATCH 116/546] Arrange for MAYBE_SHARED and NO_REFERENCES to be functions in packages. This will eventually allow REFCNT to be hidden. git-svn-id: https://svn.r-project.org/R/trunk@86623 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Rinternals.h | 15 ++++++++++----- src/main/memory.c | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index e7104093d20..9a891ca9014 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -233,12 +233,17 @@ Rboolean (Rf_isObject)(SEXP s); #endif /* Macros for some common idioms. */ -#ifdef SWITCH_TO_REFCNT -# define MAYBE_SHARED(x) (REFCNT(x) > 1) -# define NO_REFERENCES(x) (REFCNT(x) == 0) +#ifdef USE_RINTERNALS +# ifdef SWITCH_TO_REFCNT +# define MAYBE_SHARED(x) (REFCNT(x) > 1) +# define NO_REFERENCES(x) (REFCNT(x) == 0) +# else +# define MAYBE_SHARED(x) (NAMED(x) > 1) +# define NO_REFERENCES(x) (NAMED(x) == 0) +# endif #else -# define MAYBE_SHARED(x) (NAMED(x) > 1) -# define NO_REFERENCES(x) (NAMED(x) == 0) +int (MAYBE_SHARED)(SEXP x); +int (NO_REFERENCES)(SEXP x); #endif #define MAYBE_REFERENCED(x) (! NO_REFERENCES(x)) #define NOT_SHARED(x) (! MAYBE_SHARED(x)) diff --git a/src/main/memory.c b/src/main/memory.c index c7aa785251c..40ea199416f 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -3866,6 +3866,8 @@ attribute_hidden int (TRACKREFS)(SEXP x) { return TRACKREFS(CHK(x)); } int (ALTREP)(SEXP x) { return ALTREP(CHK(x)); } int (IS_SCALAR)(SEXP x, int type) { return IS_SCALAR(CHK(x), type); } void (MARK_NOT_MUTABLE)(SEXP x) { MARK_NOT_MUTABLE(CHK(x)); } +int (MAYBE_SHARED)(SEXP x) { return MAYBE_SHARED(CHK(x)); } +int (NO_REFERENCES)(SEXP x) { return NO_REFERENCES(CHK(x)); } attribute_hidden int (MARK)(SEXP x) { return MARK(CHK(x)); } attribute_hidden From a138dc82f503858bdccfc0cb9857cd9804bd450e Mon Sep 17 00:00:00 2001 From: ripley Date: Sun, 26 May 2024 10:28:55 +0000 Subject: [PATCH 117/546] updates for macOS git-svn-id: https://svn.r-project.org/R/trunk@86624 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 0534eb823db..38ee72d7adf 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -2197,7 +2197,16 @@ Installing source packages which do not contain compiled code should work with no additional tools. For others you will need the `Command Line Tools' for @command{Xcode} and compilers which match those used to build @R{}, plus a Fortran compiler for packages which contain Fortran -code: see @ref{macOS}. +code: see @ref{macOS}. Packages with C/C++ source code which link to +Fortran libraries (which include the @acronym{BLAS} and @acronym{LAPACK} +libraries) will need either the Fortran compiler or, for @acronym{CRAN} +binary distributions of @R{}, to specify +@example +FLIBS = -L/Library/Frameworks/R.framework/Resources/lib -lgfortran -lquadmath +@end example +@noindent +in a @file{Makevars} file (see the next section) to point to the Fortran +libraries in the binary distribution. Package @CRANpkg{rJava} and those which depend on it need a Java runtime installed and several packages need X11 installed, including those using @@ -2209,7 +2218,7 @@ at Tcl/Tk extension @code{BWidget} used to be distributed with @R{} but no longer is; @code{Tktable} has been distributed with recent versions of @R{}. -% (but not 4.0.0 and not @cputype{arm64} builds of 4.1.0 or 4.1.1). +@c (but not 4.0.0 and not @cputype{arm64} builds of 4.1.0 or 4.1.1). @c A few of the binary packages need other software to be installed on your @c system. In particular packages using Gtk+ (@CRANpkg{RGtk2}, @@ -2350,7 +2359,7 @@ problems} can be specified @emph{via} the environment variable Package developers are encouraged to use this mechanism to enable a reasonable amount of diagnostic messaging (``warnings'') when compiling, such as e.g.@: @option{-Wall -pedantic} for tools from GCC, the GNU -Compiler Collection, or for @command{clang}. +Compiler Collection, and for LLVM (@command{clang} and @command{flang-new}). Note that this mechanism can also be used when it is necessary to change the optimization level whilst installing a particular package. For From a3546ad1ab8277e9777f937464eb42f01bcd3347 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 26 May 2024 12:08:14 +0000 Subject: [PATCH 118/546] Tag CHAR and R_CHAR as @apifun. git-svn-id: https://svn.r-project.org/R/trunk@86626 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 3d16d6c21da..1c9c2165c87 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14096,11 +14096,14 @@ Here, we are entering a for loop. We loop through each of the variables. In the @code{for} loop, we first create a symbol corresponding to the @I{@code{i}-th} element of the @code{STRSXP} @code{theta}. Here, @code{STRING_ELT(theta, i)} accesses the -@I{@code{i}-th} element of the @code{STRSXP} @code{theta}. Macro +@I{@code{i}-th} element of the @code{STRSXP} @code{theta}. @code{CHAR()} extracts the actual character representation@footnote{@pxref{Character encoding issues} for why this might not be what is required.} of it: it returns a pointer. We then install the name and use @code{findVar} to find its value. +@apifun CHAR +@comment FIXME in packages CHAR is remapped to R_CHAR; menion that here? +@apifun R_CHAR @example @group From 07cf82236c212263cf9d01b3bda5f86ac2666d8b Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 26 May 2024 12:39:57 +0000 Subject: [PATCH 119/546] Add @apifun tags for NO_REFERENCES and @apifun MAYBE_REFERENCED; cleanups. +@apifun NOT_SHARED git-svn-id: https://svn.r-project.org/R/trunk@86627 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 1c9c2165c87..29f63509c6b 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13347,11 +13347,10 @@ assignments @code{y} and @code{x} are bound to the same @code{SEXPREC} (the structure a @code{SEXP} points to). This means that any code which alters one of them has to make a copy before modifying the copy if the usual @R{} semantics are to apply. Note that whereas @code{.C} and -@code{.Fortran} do copy their arguments (unless the dangerous @code{dup -= FALSE} is used), @code{.Call} and @code{.External} do not. So -@code{duplicate} is commonly called on arguments to @code{.Call} before -modifying them. If only the sop level is modified it may suffice to call -@code{shallow_duplicate}. +@code{.Fortran} do copy their arguments, @code{.Call} and +@code{.External} do not. So @code{duplicate} is commonly called on +arguments to @code{.Call} before modifying them. If only the top level +is modified it may suffice to call @code{shallow_duplicate}. @apifun duplicate @apifun shallow_duplicate @@ -13413,27 +13412,15 @@ make no reference to @code{x}, and no one is going to attempt a direct call such as @code{y <- "foo<-"(x)}.) This mechanism was replaced in @R{} 4.0.0. To -support future changes, package code should use the macros -@code{MAYBE_REFERENCED}, @code{MAYBE_SHARED}, and -@code{MARK_NOT_MUTABLE}. These currently correspond to +support future changes, package code should use @code{NO_REFERENCES}, +@code{MAYBE_REFERENCED}, @code{NOT_SHARED}, @code{MAYBE_SHARED}, and +@code{MARK_NOT_MUTABLE}. +@apifun NO_REFERENCES @apifun MAYBE_REFERENCED +@apifun NOT_SHARED @apifun MAYBE_SHARED @apifun MARK_NOT_MUTABLE -@table@code -@item MAYBE_REFERENCED(x) -@code{NAMED(x) > 0} -@item MAYBE_SHARED(x) -@code{NAMED(x) > 1} -@item MARK_NOT_MUTABLE(x) -@code{SET_NAMED(x, NAMEDMAX)} -@end table - -@c commented out as people misread this as general. -@c Currently all arguments to a @code{.Call} call will have @code{NAMED} -@c set to 2 or higher and so users must assume that they need to be duplicated -@c before alteration. - @node Interface functions .Call and .External, Evaluating R expressions from C, Handling R objects in C, System and foreign language interfaces @section Interface functions @code{.Call} and @code{.External} @cindex Interfaces to compiled code From ff8acdedcc78ce1dfeb7b38e41c5681b0641e5dc Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 26 May 2024 20:32:44 +0000 Subject: [PATCH 120/546] Allow some inline functions to be hidden frome use in packages. git-svn-id: https://svn.r-project.org/R/trunk@86628 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Rinlinedfuns.h | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/include/Rinlinedfuns.h b/src/include/Rinlinedfuns.h index ae3b10544da..2dee8612756 100644 --- a/src/include/Rinlinedfuns.h +++ b/src/include/Rinlinedfuns.h @@ -45,6 +45,7 @@ #ifdef COMPILING_R /* defined only in inlined.c: this emits standalone code there */ # define INLINE_FUN +# define HIDDEN attribute_hidden #else /* This section is normally only used for versions of gcc which do not support C99 semantics. __GNUC_STDC_INLINE__ is defined if @@ -58,6 +59,7 @@ # else # define INLINE_FUN extern R_INLINE # endif +# define HIDDEN #endif /* ifdef COMPILING_R */ #if C99_INLINE_SEMANTICS @@ -322,11 +324,11 @@ INLINE_FUN int *LOGICAL0(SEXP x) { CHECK_STDVEC_LGL(x); return (int *) STDVEC_DATAPTR(x); } -INLINE_FUN Rboolean SCALAR_LVAL(SEXP x) { +HIDDEN INLINE_FUN Rboolean SCALAR_LVAL(SEXP x) { CHECK_SCALAR_LGL(x); return LOGICAL0(x)[0]; } -INLINE_FUN void SET_SCALAR_LVAL(SEXP x, Rboolean v) { +HIDDEN INLINE_FUN void SET_SCALAR_LVAL(SEXP x, Rboolean v) { CHECK_SCALAR_LGL(x); LOGICAL0(x)[0] = v; } @@ -335,11 +337,11 @@ INLINE_FUN int *INTEGER0(SEXP x) { CHECK_STDVEC_INT(x); return (int *) STDVEC_DATAPTR(x); } -INLINE_FUN int SCALAR_IVAL(SEXP x) { +HIDDEN INLINE_FUN int SCALAR_IVAL(SEXP x) { CHECK_SCALAR_INT(x); return INTEGER0(x)[0]; } -INLINE_FUN void SET_SCALAR_IVAL(SEXP x, int v) { +HIDDEN INLINE_FUN void SET_SCALAR_IVAL(SEXP x, int v) { CHECK_SCALAR_INT(x); INTEGER0(x)[0] = v; } @@ -348,11 +350,11 @@ INLINE_FUN double *REAL0(SEXP x) { CHECK_STDVEC_REAL(x); return (double *) STDVEC_DATAPTR(x); } -INLINE_FUN double SCALAR_DVAL(SEXP x) { +HIDDEN INLINE_FUN double SCALAR_DVAL(SEXP x) { CHECK_SCALAR_REAL(x); return REAL0(x)[0]; } -INLINE_FUN void SET_SCALAR_DVAL(SEXP x, double v) { +HIDDEN INLINE_FUN void SET_SCALAR_DVAL(SEXP x, double v) { CHECK_SCALAR_REAL(x); REAL0(x)[0] = v; } @@ -361,11 +363,11 @@ INLINE_FUN Rcomplex *COMPLEX0(SEXP x) { CHECK_STDVEC_CPLX(x); return (Rcomplex *) STDVEC_DATAPTR(x); } -INLINE_FUN Rcomplex SCALAR_CVAL(SEXP x) { +HIDDEN INLINE_FUN Rcomplex SCALAR_CVAL(SEXP x) { CHECK_SCALAR_CPLX(x); return COMPLEX0(x)[0]; } -INLINE_FUN void SET_SCALAR_CVAL(SEXP x, Rcomplex v) { +HIDDEN INLINE_FUN void SET_SCALAR_CVAL(SEXP x, Rcomplex v) { CHECK_SCALAR_CPLX(x); COMPLEX0(x)[0] = v; } @@ -374,11 +376,11 @@ INLINE_FUN Rbyte *RAW0(SEXP x) { CHECK_STDVEC_RAW(x); return (Rbyte *) STDVEC_DATAPTR(x); } -INLINE_FUN Rbyte SCALAR_BVAL(SEXP x) { +HIDDEN INLINE_FUN Rbyte SCALAR_BVAL(SEXP x) { CHECK_SCALAR_RAW(x); return RAW0(x)[0]; } -INLINE_FUN void SET_SCALAR_BVAL(SEXP x, Rbyte v) { +HIDDEN INLINE_FUN void SET_SCALAR_BVAL(SEXP x, Rbyte v) { CHECK_SCALAR_RAW(x); RAW0(x)[0] = v; } @@ -754,7 +756,7 @@ INLINE_FUN SEXP lang6(SEXP s, SEXP t, SEXP u, SEXP v, SEXP w, SEXP x) /* Check to see if the arrays "x" and "y" have the identical extents */ -INLINE_FUN Rboolean conformable(SEXP x, SEXP y) +HIDDEN INLINE_FUN Rboolean conformable(SEXP x, SEXP y) { int i, n; PROTECT(x = getAttrib(x, R_DimSymbol)); @@ -797,7 +799,7 @@ INLINE_FUN Rboolean isValidStringF(SEXP x) return isValidString(x) && CHAR(STRING_ELT(x, 0))[0]; } -INLINE_FUN Rboolean isUserBinop(SEXP s) +HIDDEN INLINE_FUN Rboolean isUserBinop(SEXP s) { if (TYPEOF(s) == SYMSXP) { const char *str = CHAR(PRINTNAME(s)); @@ -1101,7 +1103,7 @@ INLINE_FUN SEXP mkString(const char *s) } /* index of a given C string in (translated) R string vector */ -INLINE_FUN int +HIDDEN INLINE_FUN int stringPositionTr(SEXP string, const char *translatedElement) { int slen = LENGTH(string); @@ -1119,7 +1121,7 @@ stringPositionTr(SEXP string, const char *translatedElement) { } /* duplicate RHS value of complex assignment if necessary to prevent cycles */ -INLINE_FUN SEXP R_FixupRHS(SEXP x, SEXP y) +HIDDEN INLINE_FUN SEXP R_FixupRHS(SEXP x, SEXP y) { if( y != R_NilValue && MAYBE_REFERENCED(y) ) { if (R_cycle_detected(x, y)) { From 92c1d5de23c93576f55062e26d446feface07250 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 26 May 2024 22:29:48 +0000 Subject: [PATCH 121/546] Hide some more functions in inlined.c. Also define STRICT_TYPECHECK when compiling inlined.c. git-svn-id: https://svn.r-project.org/R/trunk@86629 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Rinlinedfuns.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/include/Rinlinedfuns.h b/src/include/Rinlinedfuns.h index 2dee8612756..362805a9b97 100644 --- a/src/include/Rinlinedfuns.h +++ b/src/include/Rinlinedfuns.h @@ -77,7 +77,7 @@ #include /* for strlen, strcmp */ /* define inline-able functions */ -#ifdef TESTING_WRITE_BARRIER +#if defined(TESTING_WRITE_BARRIER) || defined(COMPILING_R) # define STRICT_TYPECHECK # define CATCH_ZERO_LENGTH_ACCESS #endif @@ -96,7 +96,7 @@ SEXP CAR(SEXP e); #endif #ifdef STRICT_TYPECHECK -INLINE_FUN void CHKVEC(SEXP x) { +HIDDEN INLINE_FUN void CHKVEC(SEXP x) { switch (TYPEOF(x)) { case CHARSXP: case LGLSXP: @@ -320,7 +320,7 @@ INLINE_FUN int LENGTH_EX(SEXP x, const char *file, int line) # define CHECK_VECTOR_RAW_ELT(x, i) do { } while(0) #endif -INLINE_FUN int *LOGICAL0(SEXP x) { +HIDDEN INLINE_FUN int *LOGICAL0(SEXP x) { CHECK_STDVEC_LGL(x); return (int *) STDVEC_DATAPTR(x); } @@ -333,7 +333,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_LVAL(SEXP x, Rboolean v) { LOGICAL0(x)[0] = v; } -INLINE_FUN int *INTEGER0(SEXP x) { +HIDDEN INLINE_FUN int *INTEGER0(SEXP x) { CHECK_STDVEC_INT(x); return (int *) STDVEC_DATAPTR(x); } @@ -346,7 +346,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_IVAL(SEXP x, int v) { INTEGER0(x)[0] = v; } -INLINE_FUN double *REAL0(SEXP x) { +/*HIDDEN*/ INLINE_FUN double *REAL0(SEXP x) { CHECK_STDVEC_REAL(x); return (double *) STDVEC_DATAPTR(x); } @@ -359,7 +359,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_DVAL(SEXP x, double v) { REAL0(x)[0] = v; } -INLINE_FUN Rcomplex *COMPLEX0(SEXP x) { +/*HIDDEN*/ INLINE_FUN Rcomplex *COMPLEX0(SEXP x) { CHECK_STDVEC_CPLX(x); return (Rcomplex *) STDVEC_DATAPTR(x); } @@ -372,7 +372,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_CVAL(SEXP x, Rcomplex v) { COMPLEX0(x)[0] = v; } -INLINE_FUN Rbyte *RAW0(SEXP x) { +HIDDEN INLINE_FUN Rbyte *RAW0(SEXP x) { CHECK_STDVEC_RAW(x); return (Rbyte *) STDVEC_DATAPTR(x); } From 23b0245ba77083b6156d011a8f582cfa7c6d221c Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 26 May 2024 23:29:21 +0000 Subject: [PATCH 122/546] More entry point hiding. git-svn-id: https://svn.r-project.org/R/trunk@86630 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/arithmetic.c | 3 ++- src/main/duplicate.c | 2 +- src/main/envir.c | 7 ++++--- src/main/eval.c | 8 ++++---- src/main/memory.c | 13 +++++-------- src/main/print.c | 2 +- src/main/unique.c | 4 ++-- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/main/arithmetic.c b/src/main/arithmetic.c index 4c25a077ac5..e93e8cef117 100644 --- a/src/main/arithmetic.c +++ b/src/main/arithmetic.c @@ -2318,7 +2318,8 @@ attribute_hidden SEXP do_math5(SEXP call, SEXP op, SEXP args, SEXP env) #endif /* Math5 is there */ /* This is used for experimenting with parallelized nmath functions -- LT */ -CCODE R_get_arith_function(int which) +/* Hide for now */ +attribute_hidden CCODE R_get_arith_function(int which) { switch (which) { case 1: return do_math1; diff --git a/src/main/duplicate.c b/src/main/duplicate.c index e6244d677d7..9c78294a736 100644 --- a/src/main/duplicate.c +++ b/src/main/duplicate.c @@ -216,7 +216,7 @@ static SEXP duplicate_child(SEXP s, Rboolean deep) { FALSE. Could be made more efficient, at least with partial inlining, but probably not worth while until it starts showing up significantly in profiling. Based on code from Michael Lawrence. */ -Rboolean R_cycle_detected(SEXP s, SEXP child) { +attribute_hidden Rboolean R_cycle_detected(SEXP s, SEXP child) { if (s == child) { switch (TYPEOF(child)) { case NILSXP: diff --git a/src/main/envir.c b/src/main/envir.c index 57da03ea5a3..29c4335e409 100644 --- a/src/main/envir.c +++ b/src/main/envir.c @@ -174,7 +174,7 @@ static SEXP getActiveValue(SEXP fun) #define ISNULL(x) ((x) == R_NilValue) /* Function to determine whethr an environment contains special symbols */ -Rboolean R_envHasNoSpecialSymbols (SEXP env) +attribute_hidden Rboolean R_envHasNoSpecialSymbols (SEXP env) { SEXP frame; @@ -3493,7 +3493,7 @@ Rboolean R_BindingIsActive(SEXP sym, SEXP env) } } -Rboolean R_HasFancyBindings(SEXP rho) +attribute_hidden Rboolean R_HasFancyBindings(SEXP rho) { if (IS_HASHED(rho)) { SEXP table, chain; @@ -3637,7 +3637,7 @@ SEXP R_NewEnv(SEXP enclos, int hash, int size) return NewEnvironment(R_NilValue, R_NilValue, enclos); } -void R_RestoreHashCount(SEXP rho) +attribute_hidden void R_RestoreHashCount(SEXP rho) { if (IS_HASHED(rho)) { SEXP table; @@ -4525,6 +4525,7 @@ Rboolean attribute_hidden isUnmodifiedSpecSym(SEXP sym, SEXP env) { return TRUE; } +attribute_hidden void findFunctionForBodyInNamespace(SEXP body, SEXP nsenv, SEXP nsname) { if (R_IsNamespaceEnv(nsenv) != TRUE) error("argument 'nsenv' is not a namespace"); diff --git a/src/main/eval.c b/src/main/eval.c index 5fcd0379116..6011e257c14 100644 --- a/src/main/eval.c +++ b/src/main/eval.c @@ -8728,7 +8728,7 @@ static void bcEval_init(void) { bcEval_loop(NULL); } -SEXP R_bcEncode(SEXP bytes) +attribute_hidden SEXP R_bcEncode(SEXP bytes) { SEXP code; BCODE *pc; @@ -8787,7 +8787,7 @@ static int findOp(void *addr) return 0; /* not reached */ } -SEXP R_bcDecode(SEXP code) { +attribute_hidden SEXP R_bcDecode(SEXP code) { int n, i, j, *ipc; BCODE *pc; SEXP bytes; @@ -8816,8 +8816,8 @@ SEXP R_bcDecode(SEXP code) { } #else static void bcEval_init(void) { return; } -SEXP R_bcEncode(SEXP x) { return x; } -SEXP R_bcDecode(SEXP x) { return duplicate(x); } +attribute_hidden SEXP R_bcEncode(SEXP x) { return x; } +attribute_hidden SEXP R_bcDecode(SEXP x) { return duplicate(x); } #endif /* Add BCODESXP bc into the constants registry, performing a deep copy of the diff --git a/src/main/memory.c b/src/main/memory.c index 40ea199416f..5f061ba0d26 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4709,13 +4709,10 @@ attribute_hidden Rboolean (NO_SPECIAL_SYMBOLS)(SEXP b) { return NO_SPECIAL_SYMBOLS(CHK(b)); } /* R_FunTab accessors, only needed when write barrier is on */ -/* Not hidden to allow experimentation without rebuilding R - LT */ -/* attribute_hidden */ -int (PRIMVAL)(SEXP x) { return PRIMVAL(CHK(x)); } -/* attribute_hidden */ -CCODE (PRIMFUN)(SEXP x) { return PRIMFUN(CHK(x)); } -/* attribute_hidden */ -void (SET_PRIMFUN)(SEXP x, CCODE f) { PRIMFUN(CHK(x)) = f; } +/* Might want to not hide for experimentation without rebuilding R - LT */ +attribute_hidden int (PRIMVAL)(SEXP x) { return PRIMVAL(CHK(x)); } +attribute_hidden CCODE (PRIMFUN)(SEXP x) { return PRIMFUN(CHK(x)); } +attribute_hidden void (SET_PRIMFUN)(SEXP x, CCODE f) { PRIMFUN(CHK(x)) = f; } /* for use when testing the write barrier */ int attribute_hidden (IS_BYTES)(SEXP x) { return IS_BYTES(CHK(x)); } @@ -4729,7 +4726,7 @@ attribute_hidden void (SET_UTF8)(SEXP x) { SET_UTF8(CHK(x)); } attribute_hidden void (SET_ASCII)(SEXP x) { SET_ASCII(CHK(x)); } int (ENC_KNOWN)(SEXP x) { return ENC_KNOWN(CHK(x)); } attribute_hidden void (SET_CACHED)(SEXP x) { SET_CACHED(CHK(x)); } -int (IS_CACHED)(SEXP x) { return IS_CACHED(CHK(x)); } +attribute_hidden int (IS_CACHED)(SEXP x) { return IS_CACHED(CHK(x)); } /*******************************************/ /* Non-sampling memory use profiler diff --git a/src/main/print.c b/src/main/print.c index 0e973fa084b..e37a86eb527 100644 --- a/src/main/print.c +++ b/src/main/print.c @@ -84,7 +84,7 @@ static void PrintObject(SEXP, R_PrintData *); #define TAGBUFLEN0 (TAGBUFLEN + 6) static char tagbuf[TAGBUFLEN0 * 2]; /* over-allocate to allow overflow check */ -void PrintInit(R_PrintData *data, SEXP env) +attribute_hidden void PrintInit(R_PrintData *data, SEXP env) { data->na_string = NA_STRING; data->na_string_noquote = mkChar(""); diff --git a/src/main/unique.c b/src/main/unique.c index b54d0881bb4..e66c9c00a09 100644 --- a/src/main/unique.c +++ b/src/main/unique.c @@ -666,7 +666,7 @@ SEXP duplicated(SEXP x, Rboolean from_last) return ans; } -R_xlen_t sorted_real_count_NANs(SEXP x) { +attribute_hidden R_xlen_t sorted_real_count_NANs(SEXP x) { R_xlen_t n = XLENGTH(x); if(n == 0) return 0; @@ -860,7 +860,7 @@ static SEXP Duplicated(SEXP x, Rboolean from_last, int nmax) return ans; } -R_xlen_t sorted_any_duplicated(SEXP x, Rboolean from_last) { +attribute_hidden R_xlen_t sorted_any_duplicated(SEXP x, Rboolean from_last) { int itmp, sorted; double rtmp; Rboolean seen_na = FALSE, seen_nan = FALSE, na1st = FALSE; From 7767796827e7a07afc7351b63dfe2c280a3f2e98 Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 27 May 2024 07:08:55 +0000 Subject: [PATCH 123/546] modernize the Fortran git-svn-id: https://svn.r-project.org/R/trunk@86631 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/appl/dqrdc2.f | 111 ++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 59 deletions(-) diff --git a/src/appl/dqrdc2.f b/src/appl/dqrdc2.f index c918bb78607..523252ee5bc 100644 --- a/src/appl/dqrdc2.f +++ b/src/appl/dqrdc2.f @@ -1,14 +1,14 @@ C Dqrdc2 is a *modification* of Linpack's dqrdc ('DQRDC') for R c -c dqrdc2 uses householder transformations to compute the qr -c factorization of an n by p matrix x. a limited column +c dqrdc2 uses Householder transformations to compute the qr +c factorization of an n by p matrix x. A limited column c pivoting strategy based on the 2-norms of the reduced columns c moves columns with near-zero norm to the right-hand edge of -c the x matrix. this strategy means that sequential one +c the x matrix. This strategy means that sequential one c degree-of-freedom effects can be computed in a natural way. c -c i am very nervous about modifying linpack code in this way. -c if you are a computational linear algebra guru and you really +c I am very nervous about modifying linpack code in this way. +c If you are a computational linear algebra guru and you really c understand how to solve this problem please feel free to c suggest improvements to this code. c @@ -68,13 +68,14 @@ c permutation of 1:p; it is called 'pivot' in R c -c original (dqrdc.f) linpack version dated 08/14/78 . -c g.w. stewart, university of maryland, argonne national lab. +c Original (dqrdc.f) linpack version dated 08/14/78 . +c G.W. Stewart, University of Maryland, Argonne National Lab. c C This version dated 22 August 1995 C Ross Ihaka c -c bug fixes 29 September 1999 BDR (p > n case, inaccurate ranks) +c Bug fixes 29 September 1999 BDR (p > n case, inaccurate ranks) +c Fortran modernized to F77, 2024-05 BDR c c c dqrdc2 uses the following functions and subprograms. @@ -89,7 +90,7 @@ subroutine dqrdc2(x,ldx,n,p,tol,k,qraux,jpvt,work) c c internal variables c - integer i,j,l,lp1,lup,k + integer i,j,l,lup,k double precision dnrm2,tt,ttt double precision ddot,nrmxl,t c @@ -98,19 +99,19 @@ subroutine dqrdc2(x,ldx,n,p,tol,k,qraux,jpvt,work) c if (n .gt. 0) then c avoid accessing element beyond the bound - do 70 j = 1, p + do j = 1, p qraux(j) = dnrm2(n,x(1,j),1) work(j,1) = qraux(j) work(j,2) = qraux(j) if(work(j,2) .eq. 0.0d0) work(j,2) = 1.0d0 - 70 continue - endif + end do + end if c c perform the householder reduction of x. c - lup = min0(n,p) + lup = min(n,p) k = p + 1 - do 200 l = 1, lup + do l = 1, lup c c previous version only cycled l to lup c @@ -120,81 +121,73 @@ subroutine dqrdc2(x,ldx,n,p,tol,k,qraux,jpvt,work) c tol times its original norm. the check for l .le. k c avoids infinite cycling. c - 80 continue - if (l .ge. k .or. qraux(l) .ge. work(l,2)*tol) go to 120 - lp1 = l+1 - do 100 i=1,n + do + if (l .ge. k .or. qraux(l) .ge. work(l,2)*tol) exit + do i=1,n t = x(i,l) - do 90 j=lp1,p + do j=l+1,p x(i,j-1) = x(i,j) - 90 continue + end do x(i,p) = t - 100 continue + end do i = jpvt(l) t = qraux(l) tt = work(l,1) ttt = work(l,2) - do 110 j=lp1,p + do j=l+1,p jpvt(j-1) = jpvt(j) qraux(j-1) = qraux(j) work(j-1,1) = work(j,1) work(j-1,2) = work(j,2) - 110 continue + end do jpvt(p) = i qraux(p) = t work(p,1) = tt work(p,2) = ttt k = k - 1 - go to 80 - 120 continue - if (l .eq. n) go to 190 + end do + if (l .ne. n) then c c compute the householder transformation for column l. c nrmxl = dnrm2(n-l+1,x(l,l),1) - if (nrmxl .eq. 0.0d0) go to 180 - if (x(l,l) .ne. 0.0d0) nrmxl = dsign(nrmxl,x(l,l)) + if (nrmxl .ne. 0.0d0) then + if (x(l,l) .ne. 0.0d0) nrmxl = sign(nrmxl,x(l,l)) call dscal(n-l+1,1.0d0/nrmxl,x(l,l),1) x(l,l) = 1.0d0 + x(l,l) c c apply the transformation to the remaining columns, c updating the norms. c - lp1 = l + 1 - if (p .lt. lp1) go to 170 - do 160 j = lp1, p - t = -ddot(n-l+1,x(l,l),1,x(l,j),1)/x(l,l) - call daxpy(n-l+1,t,x(l,l),1,x(l,j),1) - if (qraux(j) .eq. 0.0d0) go to 150 - tt = 1.0d0 - (dabs(x(l,j))/qraux(j))**2 - tt = dmax1(tt,0.0d0) - t = tt -c -c modified 9/99 by BDR. Re-compute norms if there is large reduction + if (p .ge. l+1) then + do j = l+1, p + t = -ddot(n-l+1,x(l,l),1,x(l,j),1)/x(l,l) + call daxpy(n-l+1,t,x(l,l),1,x(l,j),1) + if (qraux(j) .ne. 0.0d0) then + tt = 1.0d0 - (abs(x(l,j))/qraux(j))**2 + tt = max(tt,0.0d0) + t = tt +c +c Modified 9/99 by BDR. Re-compute norms if there is large reduction c The tolerance here is on the squared norm c In this version we need accurate norms, so re-compute often. -c work(j,1) is only updated in one case: looks like a bug -- no longer used -c -c tt = 1.0d0 + 0.05d0*tt*(qraux(j)/work(j,1))**2 -c if (tt .eq. 1.0d0) go to 130 - if (dabs(t) .lt. 1d-6) go to 130 - qraux(j) = qraux(j)*dsqrt(t) - go to 140 - 130 continue - qraux(j) = dnrm2(n-l,x(l+1,j),1) - work(j,1) = qraux(j) - 140 continue - 150 continue - 160 continue - 170 continue -c -c save the transformation. + if (dabs(t) .ge. 1d-6) then + qraux(j) = qraux(j)*sqrt(t) + else + qraux(j) = dnrm2(n-l,x(l+1,j),1) + work(j,1) = qraux(j) + end if + end if + end do + end if +c +c Save the transformation. c qraux(l) = x(l,l) x(l,l) = -nrmxl - 180 continue - 190 continue - 200 continue - k = min0(k - 1, n) + end if + end if + end do + k = min(k - 1, n) return end From 2d877f4c483671b77f96317a3a617e2b3c12ea8a Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 27 May 2024 07:52:24 +0000 Subject: [PATCH 124/546] modernize archaic (non-generic) Fortran intrinsics git-svn-id: https://svn.r-project.org/R/trunk@86632 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/appl/dchdc.f | 4 ++-- src/appl/dpbfa.f | 8 ++++---- src/appl/dpbsl.f | 6 +++--- src/appl/dpoco.f | 32 ++++++++++++++++---------------- src/appl/dqrdc.f | 10 +++++----- src/appl/dqrdc2.f | 2 +- src/appl/dqrsl.f | 4 ++-- src/appl/dsvdc.f | 32 ++++++++++++++++---------------- src/appl/dtrco.f | 22 +++++++++++----------- 9 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/appl/dchdc.f b/src/appl/dchdc.f index dcd5ab3b2f1..93c37ef1816 100644 --- a/src/appl/dchdc.f +++ b/src/appl/dchdc.f @@ -78,7 +78,7 @@ subroutine dchdc(a,lda,p,work,jpvt,job,info) c c c blas daxpy,dswap -c fortran dsqrt +c fortran sqrt c c internal variables c @@ -205,7 +205,7 @@ subroutine dchdc(a,lda,p,work,jpvt,job,info) c c reduction step. pivoting is contained across the rows. c - work(k) = dsqrt(a(k,k)) + work(k) = sqrt(a(k,k)) a(k,k) = work(k) if (p .lt. kp1) go to 260 do 250 j = kp1, p diff --git a/src/appl/dpbfa.f b/src/appl/dpbfa.f index 3c22a86094b..b19a327e1cc 100644 --- a/src/appl/dpbfa.f +++ b/src/appl/dpbfa.f @@ -45,7 +45,7 @@ subroutine dpbfa(abd,lda,n,m,info) c c m = (band width above diagonal) c do 20 j = 1, n -c i1 = max0(1, j-m) +c i1 = max(1, j-m) c do 10 i = i1, j c k = i-j+m+1 c abd(k,j) = a(i,j) @@ -58,7 +58,7 @@ subroutine dpbfa(abd,lda,n,m,info) c subroutines and functions c c blas ddot -c fortran max0,sqrt +c fortran max,sqrt c c internal variables c @@ -72,8 +72,8 @@ subroutine dpbfa(abd,lda,n,m,info) info = j s = 0.0d0 ik = m + 1 - jk = max0(j-m,1) - mu = max0(m+2-j,1) + jk = max(j-m,1) + mu = max(m+2-j,1) if (m .lt. mu) go to 20 do 10 k = mu, m diff --git a/src/appl/dpbsl.f b/src/appl/dpbsl.f index d910deef88e..7728e68bc0f 100644 --- a/src/appl/dpbsl.f +++ b/src/appl/dpbsl.f @@ -50,7 +50,7 @@ subroutine dpbsl(abd,lda,n,m,b) c subroutines and functions c c blas daxpy,ddot -c fortran min0 +c fortran min c c internal variables c @@ -60,7 +60,7 @@ subroutine dpbsl(abd,lda,n,m,b) c solve trans(r)*y = b c do 10 k = 1, n - lm = min0(k-1,m) + lm = min(k-1,m) la = m + 1 - lm lb = k - lm t = ddot(lm,abd(la,k),1,b(lb),1) @@ -71,7 +71,7 @@ subroutine dpbsl(abd,lda,n,m,b) c do 20 kb = 1, n k = n + 1 - kb - lm = min0(k-1,m) + lm = min(k-1,m) la = m + 1 - lm lb = k - lm b(k) = b(k)/abd(m+1,k) diff --git a/src/appl/dpoco.f b/src/appl/dpoco.f index 7cf7902593c..7e8e4832f03 100644 --- a/src/appl/dpoco.f +++ b/src/appl/dpoco.f @@ -58,7 +58,7 @@ c c linpack dpofa c blas daxpy,ddot,dscal,dasum -c fortran dabs,dmax1,dreal,dsign +c fortran abs,max,sign c subroutine dpoco(a,lda,n,rcond,z,info) integer lda,n,info @@ -79,13 +79,13 @@ subroutine dpoco(a,lda,n,rcond,z,info) jm1 = j - 1 if (jm1 .lt. 1) go to 20 do 10 i = 1, jm1 - z(i) = z(i) + dabs(a(i,j)) + z(i) = z(i) + abs(a(i,j)) 10 continue 20 continue 30 continue anorm = 0.0d0 do 40 j = 1, n - anorm = dmax1(anorm,z(j)) + anorm = max(anorm,z(j)) 40 continue c c factor @@ -106,24 +106,24 @@ subroutine dpoco(a,lda,n,rcond,z,info) z(j) = 0.0d0 50 continue do 110 k = 1, n - if (z(k) .ne. 0.0d0) ek = dsign(ek,-z(k)) - if (dabs(ek-z(k)) .le. a(k,k)) go to 60 - s = a(k,k)/dabs(ek-z(k)) + if (z(k) .ne. 0.0d0) ek = sign(ek,-z(k)) + if (abs(ek-z(k)) .le. a(k,k)) go to 60 + s = a(k,k)/abs(ek-z(k)) call dscal(n,s,z,1) ek = s*ek 60 continue wk = ek - z(k) wkm = -ek - z(k) - s = dabs(wk) - sm = dabs(wkm) + s = abs(wk) + sm = abs(wkm) wk = wk/a(k,k) wkm = wkm/a(k,k) kp1 = k + 1 if (kp1 .gt. n) go to 100 do 70 j = kp1, n - sm = sm + dabs(z(j)+wkm*a(k,j)) + sm = sm + abs(z(j)+wkm*a(k,j)) z(j) = z(j) + wk*a(k,j) - s = s + dabs(z(j)) + s = s + abs(z(j)) 70 continue if (s .ge. sm) go to 90 t = wkm - wk @@ -142,8 +142,8 @@ subroutine dpoco(a,lda,n,rcond,z,info) c do 130 kb = 1, n k = n + 1 - kb - if (dabs(z(k)) .le. a(k,k)) go to 120 - s = a(k,k)/dabs(z(k)) + if (abs(z(k)) .le. a(k,k)) go to 120 + s = a(k,k)/abs(z(k)) call dscal(n,s,z,1) 120 continue z(k) = z(k)/a(k,k) @@ -159,8 +159,8 @@ subroutine dpoco(a,lda,n,rcond,z,info) c do 150 k = 1, n z(k) = z(k) - ddot(k-1,a(1,k),1,z(1),1) - if (dabs(z(k)) .le. a(k,k)) go to 140 - s = a(k,k)/dabs(z(k)) + if (abs(z(k)) .le. a(k,k)) go to 140 + s = a(k,k)/abs(z(k)) call dscal(n,s,z,1) ynorm = s*ynorm 140 continue @@ -174,8 +174,8 @@ subroutine dpoco(a,lda,n,rcond,z,info) c do 170 kb = 1, n k = n + 1 - kb - if (dabs(z(k)) .le. a(k,k)) go to 160 - s = a(k,k)/dabs(z(k)) + if (abs(z(k)) .le. a(k,k)) go to 160 + s = a(k,k)/abs(z(k)) call dscal(n,s,z,1) ynorm = s*ynorm 160 continue diff --git a/src/appl/dqrdc.f b/src/appl/dqrdc.f index f11aa55fa03..eef24a03ed1 100644 --- a/src/appl/dqrdc.f +++ b/src/appl/dqrdc.f @@ -76,7 +76,7 @@ c dqrdc uses the following functions and subprograms. c c blas daxpy,ddot,dscal,dswap,dnrm2 -c fortran dabs,dmax1,min0,dsqrt +c fortran abs,max,min,sqrt c subroutine dqrdc(x,ldx,n,p,qraux,jpvt,work,job) integer ldx,n,p,job @@ -137,7 +137,7 @@ subroutine dqrdc(x,ldx,n,p,qraux,jpvt,work,job) c c perform the householder reduction of x. c - lup = min0(n,p) + lup = min(n,p) do 200 l = 1, lup if (l .lt. pl .or. l .ge. pu) go to 120 c @@ -182,12 +182,12 @@ subroutine dqrdc(x,ldx,n,p,qraux,jpvt,work,job) call daxpy(n-l+1,t,x(l,l),1,x(l,j),1) if (j .lt. pl .or. j .gt. pu) go to 150 if (qraux(j) .eq. 0.0d0) go to 150 - tt = 1.0d0 - (dabs(x(l,j))/qraux(j))**2 - tt = dmax1(tt,0.0d0) + tt = 1.0d0 - (aabs(x(l,j))/qraux(j))**2 + tt = max(tt,0.0d0) t = tt tt = 1.0d0 + 0.05d0*tt*(qraux(j)/work(j))**2 if (tt .eq. 1.0d0) go to 130 - qraux(j) = qraux(j)*dsqrt(t) + qraux(j) = qraux(j)*sqrt(t) go to 140 130 continue qraux(j) = dnrm2(n-l,x(l+1,j),1) diff --git a/src/appl/dqrdc2.f b/src/appl/dqrdc2.f index 523252ee5bc..12ac3fa591a 100644 --- a/src/appl/dqrdc2.f +++ b/src/appl/dqrdc2.f @@ -81,7 +81,7 @@ c dqrdc2 uses the following functions and subprograms. c c blas daxpy,ddot,dscal,dnrm2 -c fortran dabs,dmax1,min0,dsqrt +c fortran abs,max,min,sqrt c subroutine dqrdc2(x,ldx,n,p,tol,k,qraux,jpvt,work) integer ldx,n,p diff --git a/src/appl/dqrsl.f b/src/appl/dqrsl.f index 3c7ac53a6fd..2964e8c2ec6 100644 --- a/src/appl/dqrsl.f +++ b/src/appl/dqrsl.f @@ -135,7 +135,7 @@ c dqrsl uses the following functions and subprograms. c c BLAS daxpy,dcopy,ddot -c Fortran dabs,min0,mod +c Fortran min,mod c subroutine dqrsl(x,ldx,n,k,qraux,y,qy,qty,b,rsd,xb,job,info) integer ldx,n,k,job,info @@ -160,7 +160,7 @@ subroutine dqrsl(x,ldx,n,k,qraux,y,qy,qty,b,rsd,xb,job,info) cb = mod(job,1000)/100 .ne. 0 cr = mod(job,100)/10 .ne. 0 cxb = mod(job,10) .ne. 0 - ju = min0(k,n-1) + ju = min(k,n-1) c c special action when n=1. c diff --git a/src/appl/dsvdc.f b/src/appl/dsvdc.f index 8e24cc26436..77c74f68478 100644 --- a/src/appl/dsvdc.f +++ b/src/appl/dsvdc.f @@ -100,7 +100,7 @@ c c external drot c blas daxpy,ddot,dscal,dswap,dnrm2,drotg -c fortran dabs,dmax1,max0,min0,mod,dsqrt +c fortran abs,max,min,mod,sqrt c subroutine dsvdc(x,ldx,n,p,s,e,u,ldu,v,ldv,work,job,info) integer ldx,n,p,ldu,ldv,job,info @@ -132,7 +132,7 @@ subroutine dsvdc(x,ldx,n,p,s,e,u,ldu,v,ldv,work,job,info) wantv = .false. jobu = mod(job,100)/10 ncu = n - if (jobu .gt. 1) ncu = min0(n,p) + if (jobu .gt. 1) ncu = min(n,p) if (jobu .ne. 0) wantu = .true. if (mod(job,10) .ne. 0) wantv = .true. c @@ -140,9 +140,9 @@ subroutine dsvdc(x,ldx,n,p,s,e,u,ldu,v,ldv,work,job,info) c in s and the super-diagonal elements in e. c info = 0 - nct = min0(n-1,p) - nrt = max0(0,min0(p-2,n)) - lu = max0(nct,nrt) + nct = min(n-1,p) + nrt = max(0,min(p-2,n)) + lu = max(nct,nrt) if (lu .lt. 1) go to 170 do 160 l = 1, lu lp1 = l + 1 @@ -226,7 +226,7 @@ subroutine dsvdc(x,ldx,n,p,s,e,u,ldu,v,ldv,work,job,info) c c set up the final bidiagonal matrix or order m. c - m = min0(p,n+1) + m = min(p,n+1) nctp1 = nct + 1 nrtp1 = nrt + 1 if (nct .lt. p) s(nctp1) = x(nctp1,nctp1) @@ -329,9 +329,9 @@ subroutine dsvdc(x,ldx,n,p,s,e,u,ldu,v,ldv,work,job,info) l = m - ll c ...exit if (l .eq. 0) go to 400 - test = dabs(s(l)) + dabs(s(l+1)) - ztest = test + dabs(e(l)) - acc = dabs(test - ztest)/(1.0d-100 + test) + test = abs(s(l)) + abs(s(l+1)) + ztest = test + abs(e(l)) + acc = abs(test - ztest)/(1.0d-100 + test) if (acc .gt. 1.d-15) goto 380 c if (ztest .ne. test) go to 380 e(l) = 0.0d0 @@ -351,11 +351,11 @@ subroutine dsvdc(x,ldx,n,p,s,e,u,ldu,v,ldv,work,job,info) c ...exit if (ls .eq. l) go to 440 test = 0.0d0 - if (ls .ne. m) test = test + dabs(e(ls)) - if (ls .ne. l + 1) test = test + dabs(e(ls-1)) - ztest = test + dabs(s(ls)) + if (ls .ne. m) test = test + abs(e(ls)) + if (ls .ne. l + 1) test = test + abs(e(ls-1)) + ztest = test + abs(s(ls)) c 1.0d-100 is to guard against a zero matrix, hence zero test - acc = dabs(test - ztest)/(1.0d-100 + test) + acc = abs(test - ztest)/(1.0d-100 + test) if (acc .gt. 1.d-15) goto 420 c if (ztest .ne. test) go to 420 s(ls) = 0.0d0 @@ -432,8 +432,8 @@ subroutine dsvdc(x,ldx,n,p,s,e,u,ldu,v,ldv,work,job,info) c c calculate the shift. c - scale = dmax1(dabs(s(m)),dabs(s(m-1)),dabs(e(m-1)), - * dabs(s(l)),dabs(e(l))) + scale = max(abs(s(m)),abs(s(m-1)),abs(e(m-1)), + * abs(s(l)),dabs(e(l))) sm = s(m)/scale smm1 = s(m-1)/scale emm1 = e(m-1)/scale @@ -443,7 +443,7 @@ subroutine dsvdc(x,ldx,n,p,s,e,u,ldu,v,ldv,work,job,info) c = (sm*emm1)**2 shift = 0.0d0 if (b .eq. 0.0d0 .and. c .eq. 0.0d0) go to 550 - shift = dsqrt(b**2+c) + shift = sqrt(b**2+c) if (b .lt. 0.0d0) shift = -shift shift = c/(b + shift) 550 continue diff --git a/src/appl/dtrco.f b/src/appl/dtrco.f index 48f9e786d35..198d34c5a17 100644 --- a/src/appl/dtrco.f +++ b/src/appl/dtrco.f @@ -50,7 +50,7 @@ subroutine dtrco(t,ldt,n,rcond,z,job) c subroutines and functions c c blas daxpy,dscal,dasum -c fortran dabs,dmax1,dsign +c fortran abs,max,sign c c internal variables c @@ -69,7 +69,7 @@ subroutine dtrco(t,ldt,n,rcond,z,job) if (lower) l = n + 1 - j i1 = 1 if (lower) i1 = j - tnorm = dmax1(tnorm,dasum(l,t(i1,j),1)) + tnorm = max(tnorm,dasum(l,t(i1,j),1)) 10 continue c c rcond = 1/(norm(t)*(estimate of norm(inverse(t)))) . @@ -88,16 +88,16 @@ subroutine dtrco(t,ldt,n,rcond,z,job) do 100 kk = 1, n k = kk if (lower) k = n + 1 - kk - if (z(k) .ne. 0.0d0) ek = dsign(ek,-z(k)) - if (dabs(ek-z(k)) .le. dabs(t(k,k))) go to 30 - s = dabs(t(k,k))/dabs(ek-z(k)) + if (z(k) .ne. 0.0d0) ek = sign(ek,-z(k)) + if (abs(ek-z(k)) .le. abs(t(k,k))) go to 30 + s = abs(t(k,k))/abs(ek-z(k)) call dscal(n,s,z,1) ek = s*ek 30 continue wk = ek - z(k) wkm = -ek - z(k) - s = dabs(wk) - sm = dabs(wkm) + s = abs(wk) + sm = abs(wkm) if (t(k,k) .eq. 0.0d0) go to 40 wk = wk/t(k,k) wkm = wkm/t(k,k) @@ -112,9 +112,9 @@ subroutine dtrco(t,ldt,n,rcond,z,job) j2 = n if (lower) j2 = k - 1 do 60 j = j1, j2 - sm = sm + dabs(z(j)+wkm*t(k,j)) + sm = sm + abs(z(j)+wkm*t(k,j)) z(j) = z(j) + wk*t(k,j) - s = s + dabs(z(j)) + s = s + abs(z(j)) 60 continue if (s .ge. sm) go to 80 w = wkm - wk @@ -136,8 +136,8 @@ subroutine dtrco(t,ldt,n,rcond,z,job) do 130 kk = 1, n k = n + 1 - kk if (lower) k = kk - if (dabs(z(k)) .le. dabs(t(k,k))) go to 110 - s = dabs(t(k,k))/dabs(z(k)) + if (abs(z(k)) .le. abs(t(k,k))) go to 110 + s = abs(t(k,k))/abs(z(k)) call dscal(n,s,z,1) ynorm = s*ynorm 110 continue From 7e3645cfdf829e85219a780772f5f57186dbe74b Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 27 May 2024 08:18:57 +0000 Subject: [PATCH 125/546] corrupted commit git-svn-id: https://svn.r-project.org/R/trunk@86633 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/appl/dqrdc.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appl/dqrdc.f b/src/appl/dqrdc.f index eef24a03ed1..51d5d78c506 100644 --- a/src/appl/dqrdc.f +++ b/src/appl/dqrdc.f @@ -182,7 +182,7 @@ subroutine dqrdc(x,ldx,n,p,qraux,jpvt,work,job) call daxpy(n-l+1,t,x(l,l),1,x(l,j),1) if (j .lt. pl .or. j .gt. pu) go to 150 if (qraux(j) .eq. 0.0d0) go to 150 - tt = 1.0d0 - (aabs(x(l,j))/qraux(j))**2 + tt = 1.0d0 - (abs(x(l,j))/qraux(j))**2 tt = max(tt,0.0d0) t = tt tt = 1.0d0 + 0.05d0*tt*(qraux(j)/work(j))**2 From 5c0e367225ec0ed9e1a95864302a6311708533ee Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 27 May 2024 17:46:17 +0000 Subject: [PATCH 126/546] Add pkgRsyms allPkgsRsyms to tools. git-svn-id: https://svn.r-project.org/R/trunk@86634 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/apitools.R | 67 +++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/apitools.R b/src/library/tools/R/apitools.R index f2edb0b90ef..c92f49152cc 100644 --- a/src/library/tools/R/apitools.R +++ b/src/library/tools/R/apitools.R @@ -20,8 +20,7 @@ ## Work out the function API from information in WRE ## -## eventually either install this or get from svn: -## wreloc <- file.path(R.home("doc"), "R-ext.texi") +## WRE data is now installed in system.file(package = "tools", "wre.txt") ## WRE(newpath) forces a new load with the new path. apidata <- @@ -289,3 +288,67 @@ checkAllPkgsAPI <- function(lib.loc = NULL, priority = NULL, all = FALSE, rownames(val) <- NULL val } + + +## +## Find R entry points and variables used in installed packages +## + + +clear_rownames <- function(val) { + rownames(val) <- NULL + val +} + +rbind_list <- function(args) + clear_rownames(do.call(rbind, args)) + +ofile_syms <- function(fname, keep = c("F", "V", "U")) { + ## this uses nm on Linux/macOS; probably doesn't work on Windows, so bail + stopifnot(isFALSE(.Platform$OS.type == "windows")) + v <- tools:::read_symbols_from_object_file(fname) + if (is.character(v) && nrow(v) == 0) + stop("no symbols; file may have been stripped") + if (is.null(v)) + data.frame(name = character(0), type = character(0)) + else { + match_type <-function(type) + ifelse(type == "T", "F", ifelse(type == "U", "U", "V")) + val <- as.data.frame(v)[c("name", "type")] + val <- val[val$type %in% c("U", "B", "D", "T"), ] + val$type <- match_type(val$type) + val <- val[val$type %in% keep, ] + val + } +} + +Rsyms <- function(keep = c("F", "V")) { + rsyms <- apidata$rsyms + if (is.null(rsyms)) { + ofiles <- c(file.path(R.home("bin"), "exec", "R"), + dir(R.home("lib"), full.names = TRUE), + dir(R.home("modules"), full.names = TRUE)) + rsyms <- rbind_list(lapply(ofiles, ofile_syms, keep)) + apidata$rsyms <- rsyms + } + rsyms +} + +pkgRsyms <- function(pkg, lib.loc = NULL) { + libdir <- system.file("libs", package = pkg, lib.loc = lib.loc) + libs <- Sys.glob(file.path(libdir, "*.so")) + if (length(libs) > 0) { + val <- rbind_list(lapply(libs, ofile_syms, keep = "U")) + val$package <- rep(pkg, nrow(val)) + val$type <- NULL + merge(val, Rsyms()) + } + else NULL +} + +allPkgsRsyms <- function(lib.loc = NULL, + Ncpus = getOption("Ncpus", 1L), + verbose = getOption("verbose")) { + p <- rownames(utils::installed.packages(lib.loc = lib.loc)) + rbind_list(.package_apply(p, pkgRsyms, Ncpus = Ncpus, verbose = verbose)) +} From b396f25313e7870df8662c3b73418e755460d383 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 28 May 2024 06:26:23 +0000 Subject: [PATCH 127/546] Change opts for .fetch_headers_via_curl(). git-svn-id: https://svn.r-project.org/R/trunk@86635 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/urltools.R | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/library/tools/R/urltools.R b/src/library/tools/R/urltools.R index 2a9ea972dbb..30a4852ce3d 100644 --- a/src/library/tools/R/urltools.R +++ b/src/library/tools/R/urltools.R @@ -779,10 +779,7 @@ function(urls, verbose = FALSE, ids = urls) .fetch_headers_via_curl <- function(urls, verbose = FALSE, pool = NULL) { - out <- .curl_multi_run_worker(urls, TRUE, verbose, pool, - c(.curl_handle_default_opts, - list(http_version = 2L, - ssl_enable_alpn = 0L))) + out <- .curl_multi_run_worker(urls, TRUE, verbose, pool) ind <- !vapply(out, inherits, NA, "error") if(any(ind)) out[ind] <- lapply(out[ind], From d65ee8143881f06969bc2eab68f31cc84853d590 Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 28 May 2024 14:34:58 +0000 Subject: [PATCH 128/546] Allow customizing background color for row and column names in data editor on Windows. git-svn-id: https://svn.r-project.org/R/trunk@86636 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/console.c | 5 +++-- src/gnuwin32/guicolors.h | 2 ++ src/gnuwin32/preferences.c | 9 +++++---- src/library/utils/src/windows/dataentry.c | 10 ++++++---- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/gnuwin32/console.c b/src/gnuwin32/console.c index 9429db8ffe6..35c733f64b8 100644 --- a/src/gnuwin32/console.c +++ b/src/gnuwin32/console.c @@ -3,7 +3,7 @@ * file console.c * Copyright (C) 1998--2003 Guido Masarotto and Brian Ripley * Copyright (C) 2004-8 The R Foundation - * Copyright (C) 2004-2023 The R Core Team + * Copyright (C) 2004-2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -314,7 +314,8 @@ rgb guiColors[numGuiColors] = { White, Black, gaRed, /* consolebg, consolefg, consoleuser, */ White, Black, gaRed, /* pagerbg, pagerfg, pagerhighlight, */ White, Black, gaRed, /* dataeditbg, dataeditfg, dataedituser */ - White, Black /* editorbg, editorfg */ + White, Black, /* editorbg, editorfg */ + White /* dataeditnbg */ }; extern int R_HistorySize; /* from Defn.h */ diff --git a/src/gnuwin32/guicolors.h b/src/gnuwin32/guicolors.h index da1fbd4edec..342f4d35043 100644 --- a/src/gnuwin32/guicolors.h +++ b/src/gnuwin32/guicolors.h @@ -2,6 +2,7 @@ * R : A Computer Language for Statistical Data Analysis * file consolestructs.h * Copyright (C) 2008 The R Foundation + * Copyright (C) 2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +28,7 @@ typedef enum { pagerbg, pagerfg, pagerhighlight, dataeditbg, dataeditfg, dataedituser, editorbg, editorfg, + dataeditnbg, numGuiColors } GuiColorIndex; diff --git a/src/gnuwin32/preferences.c b/src/gnuwin32/preferences.c index ab055c3a34f..c54865fc961 100644 --- a/src/gnuwin32/preferences.c +++ b/src/gnuwin32/preferences.c @@ -2,7 +2,7 @@ * R : A Computer Language for Statistical Data Analysis * file preferences.c * Copyright (C) 2000 Guido Masarotto and Brian Ripley - * 2004-2023 R Core Team + * 2004-2024 R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -71,7 +71,7 @@ static const char *FontsList[] = {"Courier", "Courier New", "FixedSys", "FixedFo static const char *GuiElementNames[numGuiColors+1] = {"background", "normaltext", "usertext", "pagerbg", "pagertext", "highlight", "dataeditbg", "dataedittext", "dataedituser", - "editorbg", "editortext", NULL}; + "editorbg", "editortext", "dataeditnbg", NULL}; static const char *BlinkList[] = {"None", "Partial", "Full"}; static window wconfig; static button bApply, bSave, bLoad, bOK, bCancel; @@ -145,6 +145,7 @@ void getDefaults(Gui gui) gui->guiColors[dataedituser] = gaRed; gui->guiColors[editorbg] = White; gui->guiColors[editorfg] = Black; + gui->guiColors[dataeditnbg] = White; gui->prows = 25; gui->pcols = 80; gui->pagerMultiple = 0; @@ -739,11 +740,11 @@ static void cSDI(button b) static rgb whichbg[numGuiColors] = { consolebg, consolebg, consolebg, pagerbg, pagerbg, pagerbg, dataeditbg, dataeditbg, dataeditbg, - editorbg, editorbg }; + editorbg, editorbg, dataeditnbg }; static rgb whichfg[numGuiColors] = { consolefg, consolefg, consoleuser, pagerfg, pagerfg, pagerhighlight, dataeditfg, dataeditfg, dataedituser, - editorfg, editorfg }; + editorfg, editorfg, dataeditfg }; static void clickColor(control c, int argument) { int element = cmatch(gettext(guielement), GuiElementNames); diff --git a/src/library/utils/src/windows/dataentry.c b/src/library/utils/src/windows/dataentry.c index d36029c96b6..0cf50beeda5 100644 --- a/src/library/utils/src/windows/dataentry.c +++ b/src/library/utils/src/windows/dataentry.c @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 1998--2023 The R Core Team + * Copyright (C) 1998--2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -590,7 +590,7 @@ static void drawcol(DEstruct DE, int whichcol) find_coords(DE, 0, col, &src_x, &src_y); cleararea(DE, src_x, src_y, bw, DE->windowHeight, DE->p->guiColors[dataeditbg]); - cleararea(DE, src_x, src_y, bw, DE->box_h, bbg); + cleararea(DE, src_x, src_y, bw, DE->box_h, DE->p->guiColors[dataeditnbg]); for (i = 0; i < DE->nhigh; i++) drawrectangle(DE, src_x, DE->hwidth + i * DE->box_h, bw, DE->box_h, 1, 1); @@ -618,7 +618,8 @@ static void drawrow(DEstruct DE, int whichrow) find_coords(DE, row, 0, &src_x, &src_y); cleararea(DE, src_x, src_y, DE->windowWidth, DE->box_h, - (whichrow > 0) ? DE->p->guiColors[dataeditbg] : bbg); + (whichrow > 0) ? DE->p->guiColors[dataeditbg] : + DE->p->guiColors[dataeditnbg]); drawrectangle(DE, src_x, src_y, DE->boxw[0], DE->box_h, 1, 1); snprintf(rlab, 15, DE->labform, whichrow); @@ -938,7 +939,8 @@ static void printstring(DEstruct DE, const char *ibuf, int buflen, find_coords(DE, row, col, &x_pos, &y_pos); if (col == 0) bw = DE->boxw[0]; else bw = BOXW(col+DE->colmin-1); cleararea(DE, x_pos + 1, y_pos + 1, bw - 1, DE->box_h - 1, - (row==0 || col==0) ? bbg:DE->p->guiColors[dataeditbg]); + (row==0 || col==0) ? + DE->p->guiColors[dataeditnbg]:DE->p->guiColors[dataeditbg]); fw = min(BUFSIZE, (bw - 8)/(DE->p->fw)); bufw = min(fw, buflen); strncpy(buf, ibuf, bufw); From c20629d9433393e4a7ff31f662008e64af060a14 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 28 May 2024 15:11:12 +0000 Subject: [PATCH 129/546] Hide LENGTH_EX and unhide IS_CACHED. git-svn-id: https://svn.r-project.org/R/trunk@86637 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Rinlinedfuns.h | 2 +- src/main/memory.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/include/Rinlinedfuns.h b/src/include/Rinlinedfuns.h index 362805a9b97..cc54b1dd1c4 100644 --- a/src/include/Rinlinedfuns.h +++ b/src/include/Rinlinedfuns.h @@ -211,7 +211,7 @@ INLINE_FUN R_xlen_t XTRUELENGTH(SEXP x) return ALTREP(x) ? ALTREP_TRUELENGTH(x) : STDVEC_TRUELENGTH(x); } -INLINE_FUN int LENGTH_EX(SEXP x, const char *file, int line) +HIDDEN INLINE_FUN int LENGTH_EX(SEXP x, const char *file, int line) { if (x == R_NilValue) return 0; R_xlen_t len = XLENGTH(x); diff --git a/src/main/memory.c b/src/main/memory.c index 5f061ba0d26..23e4fda9b1b 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4724,9 +4724,9 @@ attribute_hidden void (SET_BYTES)(SEXP x) { SET_BYTES(CHK(x)); } attribute_hidden void (SET_LATIN1)(SEXP x) { SET_LATIN1(CHK(x)); } attribute_hidden void (SET_UTF8)(SEXP x) { SET_UTF8(CHK(x)); } attribute_hidden void (SET_ASCII)(SEXP x) { SET_ASCII(CHK(x)); } -int (ENC_KNOWN)(SEXP x) { return ENC_KNOWN(CHK(x)); } +/*attribute_hidden*/ int (ENC_KNOWN)(SEXP x) { return ENC_KNOWN(CHK(x)); } attribute_hidden void (SET_CACHED)(SEXP x) { SET_CACHED(CHK(x)); } -attribute_hidden int (IS_CACHED)(SEXP x) { return IS_CACHED(CHK(x)); } +/*attribute_hidden*/ int (IS_CACHED)(SEXP x) { return IS_CACHED(CHK(x)); } /*******************************************/ /* Non-sampling memory use profiler From cf861c145192c3f2831ff3a0c4dcf69ebd7ea778 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 28 May 2024 16:16:51 +0000 Subject: [PATCH 130/546] Add documentation and API annotation for R_ParseString and R_ParseEvalString. git-svn-id: https://svn.r-project.org/R/trunk@86638 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 29f63509c6b..c016441c147 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14150,7 +14150,7 @@ protected locations and return the answer @code{ans}. @section Parsing R code from C @cindex Parsing R code from C -Suppose an @R{} extension want to accept an @R{} expression from the +Suppose an @R{} extension wants to accept an @R{} expression from the user and evaluate it. The previous section covered evaluation, but the expression will be entered as text and needs to be parsed first. A small part of @R{}'s parse interface is declared in header file @@ -14211,6 +14211,24 @@ attached to the result, containing a list of @code{srcref} objects of the same length as the expression, to allow it to be echoed with its original formatting. +Two higher-level alternatives are @code{R_ParseString} and +@code{R_ParseEvalString}: + +@deftypefun SEXP R_ParseString (const char *@var{str}) +@deftypefunx SEXP R_ParseEvalString (const char *@var{str}, SEXP @var{env}) +@code{R_ParseString} Parses the code in @var{str} and returns the +resulting expression. An error is signaled if parsing @var{str} produces +more than one @R{} expression. @code{R_ParseEvalString } first parses +@code{str}, then evaluates the expression in the environment @var{env}, +and returns the result. +@end deftypefun +@apifun R_ParseString +@apifun R_ParseEvalString +An example from @file{src/main/objects.c}: +@example +call = R_ParseString("base::nameOfClass(X)"); +@end example + @menu * Accessing source references:: @end menu From e46eccd6c28abda468b822b23d0fc2fde73119b4 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 28 May 2024 17:29:28 +0000 Subject: [PATCH 131/546] Document some ALTREP-related functions and mark as @eapifun. git-svn-id: https://svn.r-project.org/R/trunk@86639 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 54 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index c016441c147..bc691876986 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -10845,6 +10845,7 @@ LTO = -flto * External pointers and weak references:: * Vector accessor functions:: * Character encoding issues:: +* Writing compact-representation-friendly code:: @end menu @node Operating system access, Interface functions .C and .Fortran, System and foreign language interfaces, System and foreign language interfaces @@ -14519,7 +14520,7 @@ have to fully materialize the object. @apifun SET_REAL_ELT -@node Character encoding issues, , Vector accessor functions, System and foreign language interfaces +@node Character encoding issues, Writing compact-representation-friendly code, Vector accessor functions, System and foreign language interfaces @section Character encoding issues @apifun translateChar @@ -14596,6 +14597,57 @@ SEXP mkCharLenCE(const char *, int, cetype_t); @noindent to create marked character strings of a given length. +@node Writing compact-representation-friendly code, , Character encoding issues, System and foreign language interfaces + +@section Writing compact-representation-friendly code + +A simple way to iterate in C over the elements of an atomic vector is to +obtain a data pointer and index into that pointer with standard C +indexing. However, if the object has a compact representation, then +obtaining the data pointer will force the object to be fully +materialized. An alternative is to use one of the following functions to +query whether a data pointer is available. + +@deftypefun {const int *} LOGICAL_OR_NULL (SEXP @var{x}) +@deftypefunx {const int *} INTEGER_OR_NULL (SEXP @var{x}) +@deftypefunx {const double *} REAL_OR_NULL (SEXP @var{x}) +@deftypefunx {const Rcomplex *} COMPLEX_OR_NULL (SEXP @var{x}) +@deftypefunx {const Rbyte *} RAW_OR_NULL (SEXP @var{x}) +@comment @deftypefun {const void *} DATAPTR_OR_NULL (SEXP @var{x}) +These functions will return a data pointer if one is available. For +vectors with a compact representation these functions will return +@code{NULL}. +@end deftypefun +@eapifun LOGICAL_OR_NULL +@eapifun INTEGER_OR_NULL +@eapifun REAL_OR_NULL +@eapifun COMPLEX_OR_NULL +@eapifun RAW_OR_NULL + +If a data pointer is not available, then code can access elements one at +a time with functions like @code{REAL_ELT}. This is often sufficient, +but in some cases can be inefficient. An alternative is to request data +for contiguous blocks of elements. For a good choice of block size this +can be nearly as efficient as direct pointer access. + +@deftypefun R_xlen_t INTEGER_GET_REGION (SEXP @var{sx}, R_xlen_t @var{i}, R_xlen_t @var{n}, int *@var{buf}) +@deftypefunx R_xlen_t LOGICAL_GET_REGION (SEXP @var{sx}, R_xlen_t @var{i}, R_xlen_t @var{n}, int *@var{buf}) +@deftypefunx R_xlen_t REAL_GET_REGION (SEXP @var{sx}, R_xlen_t @var{i}, R_xlen_t @var{n}, double *@var{buf}) +@deftypefunx R_xlen_t COMPLEX_GET_REGION (SEXP @var{sx}, R_xlen_t @var{i}, R_xlen_t @var{n}, Rcomplex *@var{buf}) +@deftypefunx R_xlen_t RAW_GET_REGION (SEXP @var{sx}, R_xlen_t @var{i}, R_xlen_t @var{n}, Rbyte *@var{buf}) +These functions copy a contiguous set of up to @code{n} elements +starting with element @code{i} into a buffer @code{buf}. The return +value is the actual number of elements copied, which may be less than +@code{n}. +@end deftypefun +@eapifun INTEGER_GET_REGION +@eapifun LOGICAL_GET_REGION +@eapifun REAL_GET_REGION +@eapifun COMPLEX_GET_REGION +@eapifun RAW_GET_REGION + +Macros in @file{R_ext/Itermacros.h} may help in implementing an +iteration strategy. @node The R API, Generic functions and methods, System and foreign language interfaces, Top @chapter The R @acronym{API}: entry points for C code From aadfa34dbb092ab03db462af48ecc2e0cd725e71 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 29 May 2024 03:11:02 +0000 Subject: [PATCH 132/546] Unhide LENGTH_EX to avoid issues on some clang systems. git-svn-id: https://svn.r-project.org/R/trunk@86640 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Rinlinedfuns.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/Rinlinedfuns.h b/src/include/Rinlinedfuns.h index cc54b1dd1c4..ddda16d34b6 100644 --- a/src/include/Rinlinedfuns.h +++ b/src/include/Rinlinedfuns.h @@ -211,7 +211,7 @@ INLINE_FUN R_xlen_t XTRUELENGTH(SEXP x) return ALTREP(x) ? ALTREP_TRUELENGTH(x) : STDVEC_TRUELENGTH(x); } -HIDDEN INLINE_FUN int LENGTH_EX(SEXP x, const char *file, int line) +/*HIDDEN*/ INLINE_FUN int LENGTH_EX(SEXP x, const char *file, int line) { if (x == R_NilValue) return 0; R_xlen_t len = XLENGTH(x); From 3e873ab9c0e166bcab6b5eb02839a0372200b8c6 Mon Sep 17 00:00:00 2001 From: ripley Date: Wed, 29 May 2024 15:45:51 +0000 Subject: [PATCH 133/546] add some comments on end do git-svn-id: https://svn.r-project.org/R/trunk@86641 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/appl/dqrdc2.f | 14 ++++---- src/library/stats/src/kmns.f | 66 ++++++++++++++++++------------------ 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/appl/dqrdc2.f b/src/appl/dqrdc2.f index 12ac3fa591a..29304f549da 100644 --- a/src/appl/dqrdc2.f +++ b/src/appl/dqrdc2.f @@ -104,7 +104,7 @@ subroutine dqrdc2(x,ldx,n,p,tol,k,qraux,jpvt,work) work(j,1) = qraux(j) work(j,2) = qraux(j) if(work(j,2) .eq. 0.0d0) work(j,2) = 1.0d0 - end do + end do ! j end if c c perform the householder reduction of x. @@ -127,9 +127,9 @@ subroutine dqrdc2(x,ldx,n,p,tol,k,qraux,jpvt,work) t = x(i,l) do j=l+1,p x(i,j-1) = x(i,j) - end do + end do ! j x(i,p) = t - end do + end do ! i i = jpvt(l) t = qraux(l) tt = work(l,1) @@ -139,13 +139,13 @@ subroutine dqrdc2(x,ldx,n,p,tol,k,qraux,jpvt,work) qraux(j-1) = qraux(j) work(j-1,1) = work(j,1) work(j-1,2) = work(j,2) - end do + end do ! j jpvt(p) = i qraux(p) = t work(p,1) = tt work(p,2) = ttt k = k - 1 - end do + end do ! (no index) if (l .ne. n) then c c compute the householder transformation for column l. @@ -178,7 +178,7 @@ subroutine dqrdc2(x,ldx,n,p,tol,k,qraux,jpvt,work) work(j,1) = qraux(j) end if end if - end do + end do ! j end if c c Save the transformation. @@ -187,7 +187,7 @@ subroutine dqrdc2(x,ldx,n,p,tol,k,qraux,jpvt,work) x(l,l) = -nrmxl end if end if - end do + end do ! l k = min(k - 1, n) return end diff --git a/src/library/stats/src/kmns.f b/src/library/stats/src/kmns.f index 8c19e6543ae..4ccb2c9217f 100644 --- a/src/library/stats/src/kmns.f +++ b/src/library/stats/src/kmns.f @@ -38,7 +38,7 @@ SUBROUTINE KMNS(A, M, N, C, K, IC1, IC2, NC, AN1, AN2, NCP, D, C For each point I, find its two closest centres, IC1(I) and C IC2(I). Assign it to IC1(I). C - DO 60 I = 1, M + DO I = 1, M IC1(I) = 1 IC2(I) = 2 DO IL = 1, 2 @@ -46,33 +46,33 @@ SUBROUTINE KMNS(A, M, N, C, K, IC1, IC2, NC, AN1, AN2, NCP, D, DO J = 1, N DA = A(I,J) - C(IL,J) DT(IL) = DT(IL) + DA*DA - end DO + end DO ! J end DO ! IL IF (DT(1) .GT. DT(2)) THEN - IC1(I) = 2 - IC2(I) = 1 - TEMP = DT(1) - DT(1) = DT(2) - DT(2) = TEMP + IC1(I) = 2 + IC2(I) = 1 + TEMP = DT(1) + DT(1) = DT(2) + DT(2) = TEMP END IF - DO 50 L = 3, K - DB = ZERO - DO J = 1, N - DC = A(I,J) - C(L,J) - DB = DB + DC*DC - IF (DB .GE. DT(2)) GO TO 50 - end DO - IF (DB .ge. DT(1)) then - DT(2) = DB - IC2(I) = L - else - DT(2) = DT(1) - IC2(I) = IC1(I) - DT(1) = DB - IC1(I) = L - end IF - 50 CONTINUE - 60 CONTINUE + DO L = 3, K + DB = ZERO + DO J = 1, N + DC = A(I,J) - C(L,J) + DB = DB + DC*DC + IF (DB .GE. DT(2)) GO TO 50 + end DO ! J + IF (DB .ge. DT(1)) then + DT(2) = DB + IC2(I) = L + else + DT(2) = DT(1) + IC2(I) = IC1(I) + DT(1) = DB + IC1(I) = L + end IF + 50 END DO ! L + END DO ! I C C Update cluster centres to be the average of points contained C within them. @@ -81,15 +81,15 @@ SUBROUTINE KMNS(A, M, N, C, K, IC1, IC2, NC, AN1, AN2, NCP, D, NC(L) = 0 DO J = 1, N C(L,J) = ZERO - end DO - end DO + end DO ! J + end DO ! L DO I = 1, M L = IC1(I) NC(L) = NC(L) + 1 DO J = 1, N C(L,J) = C(L,J) + A(I,J) - end DO - end DO + end DO ! J + end DO ! I C C Check to see if there is any empty cluster at this stage C @@ -101,7 +101,7 @@ SUBROUTINE KMNS(A, M, N, C, K, IC1, IC2, NC, AN1, AN2, NCP, D, AA = NC(L) DO J = 1, N C(L,J) = C(L,J) / AA - end DO + end DO ! J C C Initialize AN1, AN2, ITRAN & NCP C AN1(L) = NC(L) / (NC(L) - 1) @@ -118,7 +118,7 @@ SUBROUTINE KMNS(A, M, N, C, K, IC1, IC2, NC, AN1, AN2, NCP, D, IF (AA .GT. ONE) AN1(L) = AA / (AA - ONE) ITRAN(L) = 1 NCP(L) = -1 - end DO + end DO ! I INDX = 0 DO IJ = 1, ITER @@ -425,7 +425,7 @@ SUBROUTINE QTRAN(A, M, N, C, K, IC1, IC2, NC, AN1, AN2, NCP, D, DO J = 1, N C(L1,J) = (C(L1,J) * AL1 - A(I,J)) / ALW C(L2,J) = (C(L2,J) * AL2 + A(I,J)) / ALT - end DO + end DO ! J NC(L1) = NC(L1) - 1 NC(L2) = NC(L2) + 1 AN2(L1) = ALW / AL1 @@ -440,7 +440,7 @@ SUBROUTINE QTRAN(A, M, N, C, K, IC1, IC2, NC, AN1, AN2, NCP, D, C If no re-allocation took place in the last M steps, return. C 60 IF (ICOUN .EQ. M) RETURN - end do + end do ! I call rchkusr() ! allow user interrupt GO TO 10 From 50b7aa0d98df1432bbfb8843fe3001d7561ef50a Mon Sep 17 00:00:00 2001 From: kalibera Date: Wed, 29 May 2024 16:35:01 +0000 Subject: [PATCH 134/546] Visibility fixes. git-svn-id: https://svn.r-project.org/R/trunk@86642 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/Rdll.hide | 5 ++++- src/include/Defn.h | 6 ++++++ src/include/Rinternals.h | 3 --- src/main/memory.c | 2 +- src/main/serialize.c | 4 ++-- src/unix/sys-unix.c | 6 +++--- src/unix/system.c | 2 +- 7 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/gnuwin32/Rdll.hide b/src/gnuwin32/Rdll.hide index 59cbd2077a7..51293e07dc4 100644 --- a/src/gnuwin32/Rdll.hide +++ b/src/gnuwin32/Rdll.hide @@ -146,6 +146,7 @@ R_DevicesSymbol R_DisableNLinBrowser R_DotEnvSymbol + R_EnsureFDLimit R_ErrorCon R_EvalDepth R_ExactSymbol @@ -219,11 +220,13 @@ R_Quiet R_ReadItemDepth R_RecursiveSymbol + R_ReleaseMSet R_RestartStack R_RestartToken R_ReturnedValue R_SaveToFile R_SaveToFileV + R_SerializeInfo R_SessionContext R_SetMaxNSize R_SetMaxVSize @@ -376,7 +379,6 @@ R_tzset R_tzsetwall R_unary - R_unserialize R_vmakeErrorCondition R_warn_partial_match_args R_warn_partial_match_attr @@ -532,6 +534,7 @@ Rf_printwhere Rf_promiseArgs Rf_qchisq_appr + Rf_reEnc3 Rf_readS3VarsFromFrame Rf_regcomp Rf_regerror diff --git a/src/include/Defn.h b/src/include/Defn.h index 21daaf4ae05..9cac3c0b79e 100644 --- a/src/include/Defn.h +++ b/src/include/Defn.h @@ -1473,6 +1473,8 @@ LibExtern int R_PPStackSize INI_as(R_PPSSIZE); /* The stack size (elements) */ LibExtern int R_PPStackTop; /* The top of the stack */ LibExtern SEXP* R_PPStack; /* The pointer protection stack */ +void R_ReleaseMSet(SEXP mset, int keepSize); + /* Evaluation Environment */ extern0 SEXP R_CurrentExpr; /* Currently evaluating expression */ extern0 SEXP R_ReturnedValue; /* Slot for return-ing values */ @@ -2273,6 +2275,7 @@ size_t wcstoutf8(char *s, const wchar_t *wc, size_t n); SEXP Rf_installTrChar(SEXP); const wchar_t *wtransChar(SEXP x); /* from sysutils.c */ +const char *Rf_reEnc3(const char *x, const char *fromcode, const char *tocode, int subst); #define mbs_init(x) memset(x, 0, sizeof(mbstate_t)) size_t Mbrtowc(wchar_t *wc, const char *s, size_t n, mbstate_t *ps); @@ -2295,7 +2298,10 @@ void invalidate_cached_recodings(void); /* from sysutils.c */ void resetICUcollator(Rboolean disable); /* from util.c */ void dt_invalidate_locale(void); /* from Rstrptime.h */ extern int R_OutputCon; /* from connections.c */ + extern int R_InitReadItemDepth, R_ReadItemDepth; /* from serialize.c */ +SEXP R_SerializeInfo(R_inpstream_t ips); + void get_current_mem(size_t *,size_t *,size_t *); /* from memory.c */ unsigned long get_duplicate_counter(void); /* from duplicate.c */ void reset_duplicate_counter(void); /* from duplicate.c */ diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index 9a891ca9014..3b73c80eeac 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -612,7 +612,6 @@ cetype_t Rf_getCharCE(SEXP); SEXP Rf_mkCharCE(const char *, cetype_t); SEXP Rf_mkCharLenCE(const char *, int, cetype_t); const char *Rf_reEnc(const char *x, cetype_t ce_in, cetype_t ce_out, int subst); -const char *Rf_reEnc3(const char *x, const char *fromcode, const char *tocode, int subst); #ifdef __MAIN__ #undef extern @@ -786,7 +785,6 @@ void R_InitConnInPStream(R_inpstream_t stream, Rconnection con, void R_Serialize(SEXP s, R_outpstream_t ops); SEXP R_Unserialize(R_inpstream_t ips); -SEXP R_SerializeInfo(R_inpstream_t ips); /* slot management (in attrib.c) */ SEXP R_do_slot(SEXP obj, SEXP name); @@ -814,7 +812,6 @@ void R_ReleaseObject(SEXP); SEXP R_NewPreciousMSet(int); void R_PreserveInMSet(SEXP x, SEXP mset); void R_ReleaseFromMSet(SEXP x, SEXP mset); -void R_ReleaseMSet(SEXP mset, int keepSize); /* Shutdown actions */ void R_dot_Last(void); /* in main.c */ diff --git a/src/main/memory.c b/src/main/memory.c index 23e4fda9b1b..eebabf498fb 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -3758,7 +3758,7 @@ void R_ReleaseFromMSet(SEXP x, SEXP mset) /* Release all objects from the multi-set, but the multi-set can be used for preserving more objects. */ -void R_ReleaseMSet(SEXP mset, int keepSize) +attribute_hidden void R_ReleaseMSet(SEXP mset, int keepSize) { checkMSet(mset); SEXP store = CAR(mset); diff --git a/src/main/serialize.c b/src/main/serialize.c index 0b1c050b286..ae9b5376423 100644 --- a/src/main/serialize.c +++ b/src/main/serialize.c @@ -2291,7 +2291,7 @@ SEXP R_Unserialize(R_inpstream_t stream) return obj; } -SEXP R_SerializeInfo(R_inpstream_t stream) +attribute_hidden SEXP R_SerializeInfo(R_inpstream_t stream) { int version; int writer_version, min_reader_version, vv, vp, vs; @@ -2975,7 +2975,7 @@ R_serialize(SEXP object, SEXP icon, SEXP ascii, SEXP Sversion, SEXP fun) } -attribute_hidden SEXP R_unserialize(SEXP icon, SEXP fun) +static SEXP R_unserialize(SEXP icon, SEXP fun) { struct R_inpstream_st in; SEXP (*hook)(SEXP, SEXP); diff --git a/src/unix/sys-unix.c b/src/unix/sys-unix.c index c20afe66564..017c575cc7a 100644 --- a/src/unix/sys-unix.c +++ b/src/unix/sys-unix.c @@ -603,7 +603,7 @@ static FILE *R_popen_timeout(const char *cmd, const char *type, int timeout) } } -int R_pclose_timeout(FILE *fp) +static int R_pclose_timeout(FILE *fp) { if (fp != tost.fp) /* should not happen */ @@ -722,7 +722,7 @@ typedef struct ppg_elt { static ppg_t *ppg = NULL; -FILE *R_popen_pg(const char *cmd, const char *type) +attribute_hidden FILE *R_popen_pg(const char *cmd, const char *type) { /* close-on-exec is not supported */ if (!type || type[1] || (type[0] != 'r' && type[0] != 'w')) { @@ -802,7 +802,7 @@ FILE *R_popen_pg(const char *cmd, const char *type) } } -int R_pclose_pg(FILE *fp) +attribute_hidden int R_pclose_pg(FILE *fp) { ppg_t *prev = NULL; for (ppg_t *p = ppg; p != NULL; p = p->next) { diff --git a/src/unix/system.c b/src/unix/system.c index 4ad7971dfda..13122fec99e 100644 --- a/src/unix/system.c +++ b/src/unix/system.c @@ -621,7 +621,7 @@ int R_GetFDLimit(void) { as desired. Returns 'desired' if successful, otherwise a smaller positive number giving the current limit. On error (no limit known), a negative number is returned. */ -int R_EnsureFDLimit(int desired) { +attribute_hidden int R_EnsureFDLimit(int desired) { #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SETRLIMIT) && defined(HAVE_GETRLIMIT) struct rlimit rlim; From 58a76fdede58a7ca0d1106e245816f3865a95006 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 30 May 2024 02:05:16 +0000 Subject: [PATCH 135/546] Hide some entry points not currently used, not in installed headers, and already listed in tools;;;nonAPI. git-svn-id: https://svn.r-project.org/R/trunk@86643 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/RNG.c | 3 +++ src/main/debug.c | 4 ++-- src/main/devices.c | 1 + src/main/main.c | 8 +++++--- src/main/memory.c | 5 +++-- src/main/printvector.c | 2 +- src/main/unique.c | 1 + src/main/util.c | 9 +++++---- 8 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/main/RNG.c b/src/main/RNG.c index 4732bcfaef1..9df8094e1b5 100644 --- a/src/main/RNG.c +++ b/src/main/RNG.c @@ -597,12 +597,15 @@ attribute_hidden SEXP do_setseed (SEXP call, SEXP op, SEXP args, SEXP env) /* The following entry points provide compatibility with S. */ /* These entry points should not be used by new R code. */ +/* These entry points are now hidden */ +attribute_hidden void seed_in(long *ignored) { GetRNGstate(); } +attribute_hidden void seed_out(long *ignored) { PutRNGstate(); diff --git a/src/main/debug.c b/src/main/debug.c index ad4e5cc8950..7cc3d3b738e 100644 --- a/src/main/debug.c +++ b/src/main/debug.c @@ -190,11 +190,11 @@ attribute_hidden NORET SEXP do_untracemem(SEXP call, SEXP op, SEXP args, SEXP rh #endif /* R_MEMORY_PROFILING */ #ifndef R_MEMORY_PROFILING -void memtrace_report(void* old, void *_new) { +attribute_hidden void memtrace_report(void* old, void *_new) { return; } #else -static void memtrace_stack_dump(void) +attribute_hidden static void memtrace_stack_dump(void) { RCNTXT *cptr; diff --git a/src/main/devices.c b/src/main/devices.c index 826eff2af55..ab4f9d1fad6 100644 --- a/src/main/devices.c +++ b/src/main/devices.c @@ -39,6 +39,7 @@ int baseRegisterIndex = -1; +attribute_hidden GPar* dpptr(pGEDevDesc dd) { if (baseRegisterIndex == -1) error(_("the base graphics system is not registered")); diff --git a/src/main/main.c b/src/main/main.c index a940dcf0006..3577aa46289 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -67,6 +67,7 @@ attribute_hidden void nl_Rdummy(void) * in separate platform dependent modules. */ +attribute_hidden void Rf_callToplevelHandlers(SEXP expr, SEXP value, Rboolean succeeded, Rboolean visible); @@ -194,7 +195,7 @@ typedef struct { The "cursor" for the input buffer is moved to the next starting point, i.e. the end of the first line or after the first ;. */ -int +attribute_hidden int Rf_ReplIteration(SEXP rho, int savestack, int browselevel, R_ReplState *state) { int c, browsevalue; @@ -1629,6 +1630,7 @@ static Rboolean Rf_RunningToplevelHandlers = FALSE; since they could be more identified by an invariant (rather than position). */ +attribute_hidden R_ToplevelCallbackEl * Rf_addTaskCallback(R_ToplevelCallback cb, void *data, void (*finalizer)(void *), const char *name, int *pos) @@ -1780,7 +1782,7 @@ R_removeTaskCallback(SEXP which) return ScalarLogical(val); } -SEXP +attribute_hidden SEXP R_getTaskCallbackNames(void) { SEXP ans; @@ -1883,7 +1885,7 @@ static void defineVarInc(SEXP sym, SEXP val, SEXP rho) INCREMENT_NAMED(val); /* in case this is used in a NAMED build */ } -Rboolean +attribute_hidden Rboolean R_taskCallbackRoutine(SEXP expr, SEXP value, Rboolean succeeded, Rboolean visible, void *userData) { diff --git a/src/main/memory.c b/src/main/memory.c index eebabf498fb..66263e54eb5 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -2013,7 +2013,8 @@ static int RunGenCollect(R_size_t size_needed) /* public interface for controlling GC torture settings */ -/* maybe, but in no header */ +/* maybe, but in no header, and now hidden */ +attribute_hidden void R_gc_torture(int gap, int wait, Rboolean inhibit) { if (gap != NA_INTEGER && gap >= 0) @@ -3453,7 +3454,7 @@ void unprotect_ptr(SEXP s) /* Debugging function: is s protected? */ -int Rf_isProtected(SEXP s) +attribute_hidden int Rf_isProtected(SEXP s) { R_CHECK_THREAD; int i = R_PPStackTop; diff --git a/src/main/printvector.c b/src/main/printvector.c index 590d875a343..ba38044827b 100644 --- a/src/main/printvector.c +++ b/src/main/printvector.c @@ -319,7 +319,7 @@ void printRawVectorS(SEXP x, R_xlen_t n, int indx) } -void printVector(SEXP x, int indx, int quote) +attribute_hidden void printVector(SEXP x, int indx, int quote) { /* print R vector x[]; if(indx) print indices; if(quote) quote strings */ R_xlen_t n; diff --git a/src/main/unique.c b/src/main/unique.c index e66c9c00a09..b53a536b920 100644 --- a/src/main/unique.c +++ b/src/main/unique.c @@ -1333,6 +1333,7 @@ static SEXP asUTF8(SEXP x) } // workhorse of R's match() and hence also " ix %in% itable " +static /* or attribute_hidden? */ SEXP match5(SEXP itable, SEXP ix, int nmatch, SEXP incomp, SEXP env) { R_xlen_t n = xlength(ix); diff --git a/src/main/util.c b/src/main/util.c index 74243078a75..67c0426fb46 100644 --- a/src/main/util.c +++ b/src/main/util.c @@ -635,19 +635,19 @@ Rboolean isFree(SEXP val) /* a debugger such as gdb, so you don't have to remember */ /* the names of the data structure components. */ -int dtype(SEXP q) +attribute_hidden int dtype(SEXP q) { return((int)TYPEOF(q)); } -SEXP dcar(SEXP l) +attribute_hidden SEXP dcar(SEXP l) { return(CAR(l)); } -SEXP dcdr(SEXP l) +attribute_hidden SEXP dcdr(SEXP l) { return(CDR(l)); } @@ -1722,7 +1722,7 @@ attribute_hidden SEXP do_validEnc(SEXP call, SEXP op, SEXP args, SEXP rho) /* MBCS-aware versions of common comparisons. Only used for ASCII c */ -char *Rf_strchr(const char *s, int c) +attribute_hidden char *Rf_strchr(const char *s, int c) { char *p = (char *)s; mbstate_t mb_st; @@ -2275,6 +2275,7 @@ double R_strtod5(const char *str, char **endptr, char dec, } +attribute_hidden double R_strtod4(const char *str, char **endptr, char dec, Rboolean NA) { return R_strtod5(str, endptr, dec, NA, FALSE); From dbbaf8b654da3db3a229a3f949c413b6a07b16e2 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 30 May 2024 03:11:30 +0000 Subject: [PATCH 136/546] Unhide Rf_strchr since it is used in tools. git-svn-id: https://svn.r-project.org/R/trunk@86644 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/util.c b/src/main/util.c index 67c0426fb46..ea5fedb20bd 100644 --- a/src/main/util.c +++ b/src/main/util.c @@ -1722,7 +1722,7 @@ attribute_hidden SEXP do_validEnc(SEXP call, SEXP op, SEXP args, SEXP rho) /* MBCS-aware versions of common comparisons. Only used for ASCII c */ -attribute_hidden char *Rf_strchr(const char *s, int c) +char *Rf_strchr(const char *s, int c) { char *p = (char *)s; mbstate_t mb_st; From 5c3010a3b5030508e022e92652a9e51fe5ef7425 Mon Sep 17 00:00:00 2001 From: ripley Date: Thu, 30 May 2024 08:55:49 +0000 Subject: [PATCH 137/546] clarify that some Intel comments are for obsolete compilers git-svn-id: https://svn.r-project.org/R/trunk@86645 00db46b3-68df-0310-9c12-caf00c1e9a41 --- m4/R.m4 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/m4/R.m4 b/m4/R.m4 index d7ea3699119..84eba0c59e6 100644 --- a/m4/R.m4 +++ b/m4/R.m4 @@ -663,7 +663,7 @@ dnl SHLIB_LD=ld for native C compilers (problem with non-PIC 'crt0.o', dnl see 'Individual platform overrides' in section 'DLL stuff' in file dnl 'configure.ac'. dnl -dnl Using the Intel Fortran compiler (ifc) one typically gets incorrect +dnl Using the pre-2023 Intel Fortran compiler (ifc) one typically gets incorrect dnl flags, as the output from _AC_PROG_F77_V_OUTPUT() contains double dnl quoted options, e.g. "-mGLOB_options_string=......", see also e.g. dnl http://www.octave.org/octave-lists/archive/octave-maintainers.2002/msg00038.html. @@ -4147,12 +4147,12 @@ if test "${r_cv_prog_cc_vis}" = yes; then C_VISIBILITY="-fvisibility=hidden" fi fi -dnl Need to exclude Intel compilers, where this does not work correctly. +dnl Need to exclude pre-2023 Intel compilers, where this does not work correctly. dnl The flag is documented and is effective, but also hides dnl unsatisfied references. We cannot test for GCC, as icc passes that test. dnl Seems to work for the revamped icx. case "${CC}" in - ## Intel compiler: note that -c99 may have been appended + ## Obsolete Intel compiler: note that -c99 may have been appended *icc*) C_VISIBILITY= ;; @@ -4173,12 +4173,12 @@ if test "${r_cv_prog_cxx_vis}" = yes; then CXX_VISIBILITY="-fvisibility=hidden" fi fi -dnl Need to exclude Intel compilers, where this does not work correctly. +dnl Need to exclude pre-2023 Intel compilers, where this does not work correctly. dnl The flag is documented and is effective, but also hides dnl unsatisfied references. We cannot test for GCC, as icc passes that test. dnl Seems to work for the revamped icpx. case "${CXX}" in - ## Intel compiler + ## Obsolete Intel compilers *icc*|*icpc*) CXX_VISIBILITY= ;; @@ -4200,9 +4200,9 @@ if test "${r_cv_prog_fc_vis}" = yes; then fi fi dnl flang accepts this but ignores it. -dnl Need to exclude Intel compilers, but ifx seems to work. +dnl Need to exclude pre-2023 Intel compilers, but ifx seems to work. case "${FC}" in - ## Intel compiler + ## Obsolete Intel compilers *ifc|*ifort) F_VISIBILITY= ;; From d47ad66da3420b759782b871986749de97669d7b Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 30 May 2024 11:10:15 +0000 Subject: [PATCH 138/546] Docs update - expand on what is time1 and times in difftime (PR#18734). git-svn-id: https://svn.r-project.org/R/trunk@86646 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/difftime.Rd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/library/base/man/difftime.Rd b/src/library/base/man/difftime.Rd index dc716f25ae1..d40920c32b2 100644 --- a/src/library/base/man/difftime.Rd +++ b/src/library/base/man/difftime.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/difftime.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2023 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{difftime} @@ -65,7 +65,8 @@ as.difftime(tim, format = "\%X", units = "auto", tz = "UTC") } \details{ Function \code{difftime} calculates a difference of two date/time - objects and returns an object of class \code{"difftime"} with an + objects, \code{time1} (end) and \code{time2} (beginning), and + returns an object of class \code{"difftime"} with an attribute indicating the units. The \code{\link[=S3groupGeneric]{Math}} group method provides \code{\link{round}}, \code{\link{signif}}, \code{\link{floor}}, From 118ac36f041c39bb42db4f1116ba94fdcb88f478 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 30 May 2024 13:35:59 +0000 Subject: [PATCH 139/546] Hide more entry points not used and not in installed headers. git-svn-id: https://svn.r-project.org/R/trunk@86647 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/attrib.c | 1 + src/main/coerce.c | 1 + src/main/debug.c | 2 ++ src/main/deparse.c | 1 + src/main/engine.c | 2 +- src/main/envir.c | 2 +- src/main/main.c | 11 +++++------ src/main/memory.c | 3 ++- src/main/raw.c | 1 + src/main/sort.c | 2 +- src/main/sysutils.c | 2 ++ src/main/util.c | 7 ++++--- src/nmath/polygamma.c | 2 +- src/unix/system.c | 1 + 14 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main/attrib.c b/src/main/attrib.c index 603ae178143..6f446d94eda 100644 --- a/src/main/attrib.c +++ b/src/main/attrib.c @@ -1171,6 +1171,7 @@ attribute_hidden SEXP do_dimnames(SEXP call, SEXP op, SEXP args, SEXP env) return ans; } +static /* would need to be in a header if not static */ SEXP R_dim(SEXP call, SEXP op, SEXP args, SEXP env) { SEXP ans; diff --git a/src/main/coerce.c b/src/main/coerce.c index 2c8fb8a0375..adfc4f6742c 100644 --- a/src/main/coerce.c +++ b/src/main/coerce.c @@ -1859,6 +1859,7 @@ int asInteger(SEXP x) return NA_INTEGER; } +attribute_hidden /* would need to be in an installed header if not hidden */ R_xlen_t asXLength(SEXP x) { const R_xlen_t na = -999; /* any negative number should do */ diff --git a/src/main/debug.c b/src/main/debug.c index 7cc3d3b738e..7f955e73126 100644 --- a/src/main/debug.c +++ b/src/main/debug.c @@ -115,7 +115,9 @@ attribute_hidden SEXP do_traceOnOff(SEXP call, SEXP op, SEXP args, SEXP rho) } // GUIs, packages, etc can query: +attribute_hidden /* would need to be in an installed header if not hidden */ Rboolean R_current_debug_state(void) { return GET_DEBUG_STATE; } +attribute_hidden /* would need to be in an installed header if not hidden */ Rboolean R_current_trace_state(void) { return GET_TRACE_STATE; } diff --git a/src/main/deparse.c b/src/main/deparse.c index 1b72bc41a8c..98980690561 100644 --- a/src/main/deparse.c +++ b/src/main/deparse.c @@ -188,6 +188,7 @@ attribute_hidden SEXP do_deparse(SEXP call, SEXP op, SEXP args, SEXP rho) } // deparse1() version *looking* at getOption("deparse.max.lines") +attribute_hidden /* would need to be in an installed header if not hidden */ SEXP deparse1m(SEXP call, Rboolean abbrev, int opts) { Rboolean backtick = TRUE; diff --git a/src/main/engine.c b/src/main/engine.c index 63c6e05f295..4bfc584dab5 100644 --- a/src/main/engine.c +++ b/src/main/engine.c @@ -2888,7 +2888,7 @@ void GEdirtyDevice(pGEDevDesc dd) dd->dirty = TRUE; } -void GEcleanDevice(pGEDevDesc dd) +attribute_hidden void GEcleanDevice(pGEDevDesc dd) { #ifdef R_GE_DEBUG if (getenv("R_GE_DEBUG_dirty")) { diff --git a/src/main/envir.c b/src/main/envir.c index 29c4335e409..f15f10b4fd7 100644 --- a/src/main/envir.c +++ b/src/main/envir.c @@ -3943,7 +3943,7 @@ attribute_hidden SEXP R_getNSValue(SEXP call, SEXP ns, SEXP name, int exported) return NULL; /* not reached */ } -SEXP do_getNSValue(SEXP call, SEXP op, SEXP args, SEXP rho) +attribute_hidden SEXP do_getNSValue(SEXP call, SEXP op, SEXP args, SEXP rho) { checkArity(op, args); SEXP ns = CAR(args); diff --git a/src/main/main.c b/src/main/main.c index 3577aa46289..13fc495a927 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -1630,8 +1630,7 @@ static Rboolean Rf_RunningToplevelHandlers = FALSE; since they could be more identified by an invariant (rather than position). */ -attribute_hidden -R_ToplevelCallbackEl * +attribute_hidden R_ToplevelCallbackEl * Rf_addTaskCallback(R_ToplevelCallback cb, void *data, void (*finalizer)(void *), const char *name, int *pos) { @@ -1686,7 +1685,7 @@ static void removeToplevelHandler(R_ToplevelCallbackEl *e) } } -Rboolean +attribute_hidden Rboolean Rf_removeTaskCallbackByName(const char *name) { R_ToplevelCallbackEl *el = Rf_ToplevelTaskHandlers, *prev = NULL; @@ -1720,7 +1719,7 @@ Rf_removeTaskCallbackByName(const char *name) Remove the top-level task handler/callback identified by its position in the list of callbacks. */ -Rboolean +attribute_hidden Rboolean Rf_removeTaskCallbackByIndex(int id) { R_ToplevelCallbackEl *el = Rf_ToplevelTaskHandlers, *tmp = NULL; @@ -1763,7 +1762,7 @@ Rf_removeTaskCallbackByIndex(int id) @see Rf_RemoveToplevelCallbackByIndex(int) */ -SEXP +attribute_hidden SEXP R_removeTaskCallback(SEXP which) { int id; @@ -1958,7 +1957,7 @@ R_taskCallbackRoutine(SEXP expr, SEXP value, Rboolean succeeded, return(again); } -SEXP +attribute_hidden SEXP R_addTaskCallback(SEXP f, SEXP data, SEXP useData, SEXP name) { SEXP internalData; diff --git a/src/main/memory.c b/src/main/memory.c index 66263e54eb5..faace78fc92 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -2632,6 +2632,7 @@ attribute_hidden SEXP mkPROMISE(SEXP expr, SEXP rho) return s; } +attribute_hidden /* would need to be in an installed header if not hidden */ SEXP R_mkEVPROMISE(SEXP expr, SEXP val) { SEXP prom = mkPROMISE(expr, R_NilValue); @@ -4879,7 +4880,7 @@ void R_FreeStringBuffer(R_StringBuffer *buf) } } -void R_FreeStringBufferL(R_StringBuffer *buf) +attribute_hidden void R_FreeStringBufferL(R_StringBuffer *buf) { if (buf->bufsize > buf->defaultSize) { free(buf->data); diff --git a/src/main/raw.c b/src/main/raw.c index 9e9668bb5eb..b1ddfaf93f4 100644 --- a/src/main/raw.c +++ b/src/main/raw.c @@ -275,6 +275,7 @@ attribute_hidden SEXP do_packBits(SEXP call, SEXP op, SEXP args, SEXP env) } /* Simplified version for RFC3629 definition of UTF-8 */ +attribute_hidden /* would need to be in an installed header if not hidden */ int mbrtoint(int *w, const char *s) { unsigned int byte; diff --git a/src/main/sort.c b/src/main/sort.c index cfaa75d6e3f..28c882259fd 100644 --- a/src/main/sort.c +++ b/src/main/sort.c @@ -434,7 +434,7 @@ attribute_hidden SEXP do_sort(SEXP call, SEXP op, SEXP args, SEXP rho) return(ans); /* wrapping with metadata happens at end of sort.int */ } -Rboolean fastpass_sortcheck(SEXP x, int wanted) { +static Rboolean fastpass_sortcheck(SEXP x, int wanted) { if(!KNOWN_SORTED(wanted)) return FALSE; diff --git a/src/main/sysutils.c b/src/main/sysutils.c index d3c47341aed..7edab602a15 100644 --- a/src/main/sysutils.c +++ b/src/main/sysutils.c @@ -1781,6 +1781,7 @@ const wchar_t *wtransChar(SEXP x) } /* Variant which returns NULL (with a warning) when conversion fails. */ +attribute_hidden /* would need to be in an installed header if not hidden */ const wchar_t *wtransChar2(SEXP x) { CHECK_CHARSXP(x); @@ -2197,6 +2198,7 @@ extern char * mkdtemp (char *template); # include #endif +attribute_hidden /* would need to be in an installed header if not hidden */ void R_reInitTempDir(int die_on_fail) { char *tmp = NULL, *tm; diff --git a/src/main/util.c b/src/main/util.c index ea5fedb20bd..c54adb7935e 100644 --- a/src/main/util.c +++ b/src/main/util.c @@ -552,6 +552,7 @@ SEXP nthcdr(SEXP s, int n) } /* Destructively removes R_NilValue ('NULL') elements from a pairlist. */ +attribute_hidden /* would need to be in an installed header if not hidden */ SEXP R_listCompact(SEXP s, Rboolean keep_initial) { if(!keep_initial) // skip initial NULL values @@ -1481,8 +1482,8 @@ utf8towcs(wchar_t *wc, const char *s, size_t n) return (size_t) res; } -size_t -utf8towcs4(R_wchar_t *wc, const char *s, size_t n) +attribute_hidden /* would need to be in an installed header if not hidden */ +size_t utf8towcs4(R_wchar_t *wc, const char *s, size_t n) { ssize_t m, res = 0; const char *t; @@ -1737,7 +1738,7 @@ char *Rf_strchr(const char *s, int c) return (char *)NULL; } -char *Rf_strrchr(const char *s, int c) +attribute_hidden char *Rf_strrchr(const char *s, int c) { char *p = (char *)s, *plast = NULL; mbstate_t mb_st; diff --git a/src/nmath/polygamma.c b/src/nmath/polygamma.c index 41dd05bb4d6..5e3b0a0f944 100644 --- a/src/nmath/polygamma.c +++ b/src/nmath/polygamma.c @@ -146,7 +146,7 @@ #define n_max (100) // Compute d_n(x) = (d/dx)^n cot(x) ; cot(x) := cos(x) / sin(x) -double d_n_cot(double x, int n) +static double d_n_cot(double x, int n) { if (n == 0) return cos(x)/sin(x); diff --git a/src/unix/system.c b/src/unix/system.c index 13122fec99e..0cd7608fd42 100644 --- a/src/unix/system.c +++ b/src/unix/system.c @@ -591,6 +591,7 @@ int R_EditFiles(int nfile, const char **file, const char **title, /* Returns the limit on the number of open files. On error or when no limit is known, returns a negative number. */ +attribute_hidden /* would need to be in an installed header if not hidden */ int R_GetFDLimit(void) { #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) From ebd3ff626f25cfc389c9047ef3c580524124b476 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 30 May 2024 17:34:52 +0000 Subject: [PATCH 140/546] Hide yet more entry points not used and not in installed headers. git-svn-id: https://svn.r-project.org/R/trunk@86648 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/array.c | 2 +- src/main/coerce.c | 4 ++-- src/main/context.c | 2 +- src/main/memory.c | 5 +++++ src/main/options.c | 4 ++-- src/main/subscript.c | 2 +- src/main/sysutils.c | 3 ++- src/main/util.c | 2 +- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/array.c b/src/main/array.c index e54e4d20073..071c02898ef 100644 --- a/src/main/array.c +++ b/src/main/array.c @@ -313,7 +313,7 @@ SEXP allocArray(SEXPTYPE mode, SEXP dims) /* attribute. Note that this function mutates x. */ /* Duplication should occur before this is called. */ -SEXP DropDims(SEXP x) +attribute_hidden SEXP DropDims(SEXP x) { PROTECT(x); SEXP dims = getAttrib(x, R_DimSymbol); diff --git a/src/main/coerce.c b/src/main/coerce.c index adfc4f6742c..22715bb383c 100644 --- a/src/main/coerce.c +++ b/src/main/coerce.c @@ -1329,7 +1329,7 @@ SEXP coerceVector(SEXP v, SEXPTYPE type) #undef COERCE_ERROR -SEXP CreateTag(SEXP x) +attribute_hidden SEXP CreateTag(SEXP x) { if (isNull(x) || isSymbol(x)) return x; @@ -1786,7 +1786,7 @@ attribute_hidden SEXP do_ascall(SEXP call, SEXP op, SEXP args, SEXP rho) /* return int, not Rboolean, for NA_LOGICAL : */ -int asLogical2(SEXP x, int checking, SEXP call) +attribute_hidden int asLogical2(SEXP x, int checking, SEXP call) { int warn = 0; diff --git a/src/main/context.c b/src/main/context.c index 2785efbce76..35d9fc89e88 100644 --- a/src/main/context.c +++ b/src/main/context.c @@ -528,7 +528,7 @@ attribute_hidden SEXP R_sysfunction(int n, RCNTXT *cptr) /* browser contexts are a bit special because they are transient and for */ /* any closure context with the debug bit set one will be created; so we */ /* need to count those as well */ -int countContexts(int ctxttype, int browser) { +attribute_hidden int countContexts(int ctxttype, int browser) { int n=0; RCNTXT *cptr; diff --git a/src/main/memory.c b/src/main/memory.c index faace78fc92..582b7c54fea 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -3044,26 +3044,31 @@ static SEXP allocFormalsList(int nargs, ...) } +attribute_hidden /* would need to be in an installed header if not hidden */ SEXP allocFormalsList2(SEXP sym1, SEXP sym2) { return allocFormalsList(2, sym1, sym2); } +attribute_hidden /* would need to be in an installed header if not hidden */ SEXP allocFormalsList3(SEXP sym1, SEXP sym2, SEXP sym3) { return allocFormalsList(3, sym1, sym2, sym3); } +attribute_hidden /* would need to be in an installed header if not hidden */ SEXP allocFormalsList4(SEXP sym1, SEXP sym2, SEXP sym3, SEXP sym4) { return allocFormalsList(4, sym1, sym2, sym3, sym4); } +attribute_hidden /* would need to be in an installed header if not hidden */ SEXP allocFormalsList5(SEXP sym1, SEXP sym2, SEXP sym3, SEXP sym4, SEXP sym5) { return allocFormalsList(5, sym1, sym2, sym3, sym4, sym5); } +attribute_hidden /* would need to be in an installed header if not hidden */ SEXP allocFormalsList6(SEXP sym1, SEXP sym2, SEXP sym3, SEXP sym4, SEXP sym5, SEXP sym6) { diff --git a/src/main/options.c b/src/main/options.c index 60077d70e37..724a194ecd2 100644 --- a/src/main/options.c +++ b/src/main/options.c @@ -137,7 +137,7 @@ SEXP GetOption1(SEXP tag) return CAR(opt); } -int FixupWidth(SEXP width, warn_type warn) +attribute_hidden int FixupWidth(SEXP width, warn_type warn) { int w = asInteger(width); if (w == NA_INTEGER || w < R_MIN_WIDTH_OPT || w > R_MAX_WIDTH_OPT) { @@ -155,7 +155,7 @@ int GetOptionWidth(void) return FixupWidth(GetOption1(install("width")), iWARN); } -int FixupDigits(SEXP digits, warn_type warn) +attribute_hidden int FixupDigits(SEXP digits, warn_type warn) { int d = asInteger(digits); if (d == NA_INTEGER || d < R_MIN_DIGITS_OPT || d > R_MAX_DIGITS_OPT) { diff --git a/src/main/subscript.c b/src/main/subscript.c index 771c402d58c..b2add3d4288 100644 --- a/src/main/subscript.c +++ b/src/main/subscript.c @@ -1030,7 +1030,7 @@ int_arraySubscript(int dim, SEXP s, SEXP dims, SEXP x, SEXP call) typedef SEXP AttrGetter(SEXP x, SEXP data); typedef SEXP (*StringEltGetter)(SEXP x, int i); -SEXP +attribute_hidden SEXP arraySubscript(int dim, SEXP s, SEXP dims, AttrGetter dng, StringEltGetter strg, SEXP x) { diff --git a/src/main/sysutils.c b/src/main/sysutils.c index 7edab602a15..6ab9c7faa0a 100644 --- a/src/main/sysutils.c +++ b/src/main/sysutils.c @@ -1470,7 +1470,7 @@ SEXP Rf_installChar(SEXP x) Use for writeLines/Bin/Char, the first only with useBytes = TRUE. */ -const char *translateChar0(SEXP x) +attribute_hidden const char *translateChar0(SEXP x) { CHECK_CHARSXP(x); if(IS_BYTES(x)) return CHAR(x); @@ -1960,6 +1960,7 @@ void reEnc2(const char *x, char *y, int ny, /* A version that works with arbitrary iconv encodings, used for getting escaped invalid characters for error messages. */ +attribute_hidden const char *reEnc3(const char *x, const char *fromcode, const char *tocode, int subst) { diff --git a/src/main/util.c b/src/main/util.c index c54adb7935e..3aad0d6ca8a 100644 --- a/src/main/util.c +++ b/src/main/util.c @@ -621,7 +621,7 @@ void setSVector(SEXP * vec, int len, SEXP val) */ -Rboolean isFree(SEXP val) +attribute_hidden Rboolean isFree(SEXP val) { SEXP t; for (t = R_FreeSEXP; t != R_NilValue; t = CAR(t)) From 573b9271080e65c4e781c19be44cd01517e0a1ef Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 30 May 2024 19:55:32 +0000 Subject: [PATCH 141/546] Rename deparse1line_ to deparse1line_ex and mark as attribute_hidden. git-svn-id: https://svn.r-project.org/R/trunk@86649 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Defn.h | 2 +- src/main/coerce.c | 3 ++- src/main/deparse.c | 5 +++-- src/main/relop.c | 8 ++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/include/Defn.h b/src/include/Defn.h index 9cac3c0b79e..473b77f464e 100644 --- a/src/include/Defn.h +++ b/src/include/Defn.h @@ -2011,7 +2011,7 @@ SEXP deparse1(SEXP,Rboolean,int); SEXP deparse1m(SEXP call, Rboolean abbrev, int opts); SEXP deparse1w(SEXP,Rboolean,int); SEXP deparse1line (SEXP, Rboolean); -SEXP deparse1line_(SEXP, Rboolean, int); +SEXP deparse1line_ex(SEXP, Rboolean, int); SEXP deparse1s(SEXP call); int DispatchAnyOrEval(SEXP, SEXP, const char *, SEXP, SEXP, SEXP*, int, int); int DispatchOrEval(SEXP, SEXP, const char *, SEXP, SEXP, SEXP*, int, int); diff --git a/src/main/coerce.c b/src/main/coerce.c index 22715bb383c..7a40ac77687 100644 --- a/src/main/coerce.c +++ b/src/main/coerce.c @@ -1099,7 +1099,8 @@ static SEXP coerceVectorList(SEXP v, SEXPTYPE type) #endif else SET_STRING_ELT(rval, i, - STRING_ELT(deparse1line_(VECTOR_ELT(v, i), 0, NICE_NAMES), + STRING_ELT(deparse1line_ex(VECTOR_ELT(v, i), + 0, NICE_NAMES), 0)); } } diff --git a/src/main/deparse.c b/src/main/deparse.c index 98980690561..82e125b5776 100644 --- a/src/main/deparse.c +++ b/src/main/deparse.c @@ -320,7 +320,8 @@ static SEXP deparse1WithCutoff(SEXP call, Rboolean abbrev, int cutoff, * This is needed in terms.formula, where we must be able * to deparse a term label into a single line of text so * that it can be reparsed correctly */ -SEXP deparse1line_(SEXP call, Rboolean abbrev, int opts) +attribute_hidden +SEXP deparse1line_ex(SEXP call, Rboolean abbrev, int opts) { Rboolean backtick=TRUE; int lines; @@ -357,7 +358,7 @@ SEXP deparse1line_(SEXP call, Rboolean abbrev, int opts) SEXP deparse1line(SEXP call, Rboolean abbrev) { - return deparse1line_(call, abbrev, SIMPLEDEPARSE); + return deparse1line_ex(call, abbrev, SIMPLEDEPARSE); } diff --git a/src/main/relop.c b/src/main/relop.c index 815efc74984..73da9b8795a 100644 --- a/src/main/relop.c +++ b/src/main/relop.c @@ -272,8 +272,8 @@ attribute_hidden SEXP do_relop_dflt(SEXP call, SEXP op, SEXP x, SEXP y) SEXP tmp = allocVector(STRSXP, 1); PROTECT(tmp); SET_STRING_ELT(tmp, 0, (iS) ? PRINTNAME(x) : - STRING_ELT(deparse1line_(x, 0, - DEFAULTDEPARSE | DIGITS17), + STRING_ELT(deparse1line_ex(x, 0, + DEFAULTDEPARSE | DIGITS17), 0)); REPROTECT(x = tmp, xpi); nx = xlength(x); @@ -283,8 +283,8 @@ attribute_hidden SEXP do_relop_dflt(SEXP call, SEXP op, SEXP x, SEXP y) SEXP tmp = allocVector(STRSXP, 1); PROTECT(tmp); SET_STRING_ELT(tmp, 0, (iS) ? PRINTNAME(y) : - STRING_ELT(deparse1line_(y, 0, - DEFAULTDEPARSE | DIGITS17), + STRING_ELT(deparse1line_ex(y, 0, + DEFAULTDEPARSE | DIGITS17), 0)); REPROTECT(y = tmp, ypi); ny = xlength(y); From 2adf97d0575bbbd6d3faf0aa9654dc2c6f2ae76a Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 30 May 2024 20:05:37 +0000 Subject: [PATCH 142/546] Make the definitions of Rf_XLENGTH and XLENGTH identical. git-svn-id: https://svn.r-project.org/R/trunk@86650 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/memory.c b/src/main/memory.c index 582b7c54fea..6166f048848 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4047,7 +4047,7 @@ attribute_hidden void (SETALTREP)(SEXP x, int v) { SETALTREP(x, v); } #endif /* temporary, to ease transition away from remapping */ -R_xlen_t Rf_XLENGTH(SEXP x) { return XLENGTH(x); } +R_xlen_t Rf_XLENGTH(SEXP x) { return XLENGTH(CHK2(x)); } const char *(R_CHAR)(SEXP x) { if(TYPEOF(x) != CHARSXP) // Han-Tak proposes to prepend 'x && ' From cc257e0b549a7df7d2612250faeaad8e64d2c54f Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 30 May 2024 20:59:35 +0000 Subject: [PATCH 143/546] Clean up tools:::Rfuns result a little. git-svn-id: https://svn.r-project.org/R/trunk@86651 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/apitools.R | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/library/tools/R/apitools.R b/src/library/tools/R/apitools.R index c92f49152cc..3422a8d027d 100644 --- a/src/library/tools/R/apitools.R +++ b/src/library/tools/R/apitools.R @@ -237,6 +237,16 @@ inRfuns <- function(syms) { syms[unmap(syms) %in% unmap(rfuns)] } +cleanRfuns <- function(val) { + ## if Rf_XLENGTH and XLENGTH are both there then keep Rf_XLENGTH + if (any(grepl("^_*Rf_XLENGTH_*$", val)) && + any(grepl("^_*XLENGTH_*$", val))) + val <- val[! grepl("^_*XLENGTH_*$", val)] + + ## drop tre_ stuff if it is there and some others + val[! grepl("tre_|^_*(main|MAIN|start)_*$|yyparse", val)] +} + getRfuns <- function() { pat <- sprintf("(\\.dylib|%s)$", .Platform$dynlib.ext) ofiles <- c(file.path(R.home("bin"), "exec", "R"), @@ -244,7 +254,7 @@ getRfuns <- function() { dir(R.home("modules"), pattern = pat, full.names = TRUE)) data <- do.call(rbind, lapply(ofiles, readFileSyms)) fdata <- data[data$type == "T", ] - fdata$name + cleanRfuns(fdata$name) } Rfuns <- function() { @@ -352,3 +362,4 @@ allPkgsRsyms <- function(lib.loc = NULL, p <- rownames(utils::installed.packages(lib.loc = lib.loc)) rbind_list(.package_apply(p, pkgRsyms, Ncpus = Ncpus, verbose = verbose)) } + From 5dc190e2ec26a242a7b01ceadabcaf8ec632be25 Mon Sep 17 00:00:00 2001 From: pd Date: Thu, 30 May 2024 23:23:05 +0000 Subject: [PATCH 144/546] maintainer-mode changes git-svn-id: https://svn.r-project.org/R/trunk@86652 00db46b3-68df-0310-9c12-caf00c1e9a41 --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 6dcdc106978..52d3a93eea0 100755 --- a/configure +++ b/configure @@ -9129,7 +9129,7 @@ if test "${r_cv_prog_cc_vis}" = yes; then fi fi case "${CC}" in - ## Intel compiler: note that -c99 may have been appended + ## Obsolete Intel compiler: note that -c99 may have been appended *icc*) C_VISIBILITY= ;; @@ -9187,7 +9187,7 @@ if test "${r_cv_prog_cxx_vis}" = yes; then fi fi case "${CXX}" in - ## Intel compiler + ## Obsolete Intel compilers *icc*|*icpc*) CXX_VISIBILITY= ;; @@ -9238,7 +9238,7 @@ if test "${r_cv_prog_fc_vis}" = yes; then fi fi case "${FC}" in - ## Intel compiler + ## Obsolete Intel compilers *ifc|*ifort) F_VISIBILITY= ;; From 67d93cb52a2492212d32faab48c1cb69864fd715 Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 31 May 2024 10:19:18 +0000 Subject: [PATCH 145/546] Improve robustness of the parser to multi-byte inputs. Bounds check. git-svn-id: https://svn.r-project.org/R/trunk@86653 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/gram.c | 47 ++++++++++++++++++++++++++++++++--------------- src/main/gram.y | 27 ++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/src/main/gram.c b/src/main/gram.c index d35b590ac07..39db336d327 100644 --- a/src/main/gram.c +++ b/src/main/gram.c @@ -367,6 +367,7 @@ NORET static void raiseLexError(const char *, int, # include #endif +// FIXME potentially need R_wchar_t with UTF-8 Windows. static int mbcs_get_next(int c, wchar_t *wc) { int i, res, clen = 1; char s[9]; @@ -1127,16 +1128,16 @@ static const yytype_int8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int16 yyrline[] = { - 0, 445, 445, 446, 447, 448, 449, 452, 453, 454, - 457, 458, 461, 462, 463, 464, 465, 467, 468, 470, - 471, 472, 473, 474, 476, 477, 478, 479, 480, 481, - 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, - 492, 493, 494, 495, 496, 497, 498, 500, 501, 502, - 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, - 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, - 526, 529, 532, 536, 537, 538, 539, 540, 541, 544, - 545, 548, 549, 550, 551, 552, 553, 554, 555, 558, - 559, 560, 561, 562, 566 + 0, 446, 446, 447, 448, 449, 450, 453, 454, 455, + 458, 459, 462, 463, 464, 465, 466, 468, 469, 471, + 472, 473, 474, 475, 477, 478, 479, 480, 481, 482, + 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, + 493, 494, 495, 496, 497, 498, 499, 501, 502, 503, + 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, + 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, + 527, 530, 533, 537, 538, 539, 540, 541, 542, 545, + 546, 549, 550, 551, 552, 553, 554, 555, 556, 559, + 560, 561, 562, 563, 567 }; #endif @@ -6029,10 +6030,26 @@ static int token(void) yytext[1] = '\0'; yylval = install(yytext); return c; - default: - yytext[0] = (char) c; - yytext[1] = '\0'; + case '\n': + case ',': + case ';': + yytext[0] = (char) c; + yytext[1] = '\0'; return c; + default: + int clen = 1; + if (mbcslocale) { + // FIXME potentially need R_wchar_t with UTF-8 Windows. + clen = mbcs_get_next(c, &wc); + if (clen == -1) + return END_OF_INPUT; /* EOF whilst reading MBCS char */ + } + DECLARE_YYTEXT_BUFP(yyp); + YYTEXT_PUSH(c, yyp); + for(int i = 1; i < clen ; i++) + YYTEXT_PUSH(xxgetc(), yyp); + YYTEXT_PUSH('\0', yyp); + return (clen == 1) ? c : ERROR; } } @@ -6616,10 +6633,10 @@ static void finalizeData(void){ PROTECT(tokens = allocVector( STRSXP, nloc ) ); for (int i=0; i= 0 && xlat < YYNTOKENS + YYNNTS) SET_STRING_ELT(tokens, i, mkChar(yytname[xlat])); else { /* we have a token which doesn't have a name, e.g. an illegal character as in PR#15518 */ char name[2]; diff --git a/src/main/gram.y b/src/main/gram.y index 233d3ac5503..6a1e7257453 100644 --- a/src/main/gram.y +++ b/src/main/gram.y @@ -299,6 +299,7 @@ NORET static void raiseLexError(const char *, int, # include #endif +// FIXME potentially need R_wchar_t with UTF-8 Windows. static int mbcs_get_next(int c, wchar_t *wc) { int i, res, clen = 1; char s[9]; @@ -3720,10 +3721,26 @@ static int token(void) yytext[1] = '\0'; yylval = install(yytext); return c; - default: - yytext[0] = (char) c; - yytext[1] = '\0'; + case '\n': + case ',': + case ';': + yytext[0] = (char) c; + yytext[1] = '\0'; return c; + default: + int clen = 1; + if (mbcslocale) { + // FIXME potentially need R_wchar_t with UTF-8 Windows. + clen = mbcs_get_next(c, &wc); + if (clen == -1) + return END_OF_INPUT; /* EOF whilst reading MBCS char */ + } + DECLARE_YYTEXT_BUFP(yyp); + YYTEXT_PUSH(c, yyp); + for(int i = 1; i < clen ; i++) + YYTEXT_PUSH(xxgetc(), yyp); + YYTEXT_PUSH('\0', yyp); + return (clen == 1) ? c : ERROR; } } @@ -4307,10 +4324,10 @@ static void finalizeData(void){ PROTECT(tokens = allocVector( STRSXP, nloc ) ); for (int i=0; i= 0 && xlat < YYNTOKENS + YYNNTS) SET_STRING_ELT(tokens, i, mkChar(yytname[xlat])); else { /* we have a token which doesn't have a name, e.g. an illegal character as in PR#15518 */ char name[2]; From 533b5c510e33f04ff95d6933b21d083bb2d54090 Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 31 May 2024 11:04:09 +0000 Subject: [PATCH 146/546] Fix for clang. git-svn-id: https://svn.r-project.org/R/trunk@86654 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/gram.c | 6 +++--- src/main/gram.y | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/gram.c b/src/main/gram.c index 39db336d327..6ba862ca9d8 100644 --- a/src/main/gram.c +++ b/src/main/gram.c @@ -5813,7 +5813,7 @@ static SEXP install_and_save2(char * text, char * savetext) static int token(void) { - int c; + int c, clen, i; wchar_t wc; if (SavedToken) { @@ -6037,7 +6037,7 @@ static int token(void) yytext[1] = '\0'; return c; default: - int clen = 1; + clen = 1; if (mbcslocale) { // FIXME potentially need R_wchar_t with UTF-8 Windows. clen = mbcs_get_next(c, &wc); @@ -6046,7 +6046,7 @@ static int token(void) } DECLARE_YYTEXT_BUFP(yyp); YYTEXT_PUSH(c, yyp); - for(int i = 1; i < clen ; i++) + for(i = 1; i < clen ; i++) YYTEXT_PUSH(xxgetc(), yyp); YYTEXT_PUSH('\0', yyp); return (clen == 1) ? c : ERROR; diff --git a/src/main/gram.y b/src/main/gram.y index 6a1e7257453..83d8451ab10 100644 --- a/src/main/gram.y +++ b/src/main/gram.y @@ -3504,7 +3504,7 @@ static SEXP install_and_save2(char * text, char * savetext) static int token(void) { - int c; + int c, clen, i; wchar_t wc; if (SavedToken) { @@ -3728,7 +3728,7 @@ static int token(void) yytext[1] = '\0'; return c; default: - int clen = 1; + clen = 1; if (mbcslocale) { // FIXME potentially need R_wchar_t with UTF-8 Windows. clen = mbcs_get_next(c, &wc); @@ -3737,7 +3737,7 @@ static int token(void) } DECLARE_YYTEXT_BUFP(yyp); YYTEXT_PUSH(c, yyp); - for(int i = 1; i < clen ; i++) + for(i = 1; i < clen ; i++) YYTEXT_PUSH(xxgetc(), yyp); YYTEXT_PUSH('\0', yyp); return (clen == 1) ? c : ERROR; From 08f4612814bf500d52b7caaf6e2d3b0d5cbddc31 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 31 May 2024 12:02:24 +0000 Subject: [PATCH 147/546] Hide more entry points not used in Base/CRAN/BIOC packages. git-svn-id: https://svn.r-project.org/R/trunk@86655 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/Rdynload.c | 2 +- src/main/attrib.c | 4 ++-- src/main/envir.c | 2 +- src/main/format.c | 7 +++++++ src/main/objects.c | 11 ++++++----- src/main/options.c | 3 ++- src/main/printutils.c | 1 + src/main/serialize.c | 2 ++ src/main/util.c | 2 +- src/unix/sys-std.c | 3 ++- 10 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/main/Rdynload.c b/src/main/Rdynload.c index 767f866d4b0..2c55d708a25 100644 --- a/src/main/Rdynload.c +++ b/src/main/Rdynload.c @@ -321,7 +321,7 @@ R_addExternalRoutine(DllInfo *info, R_init_ is passed the DllInfo reference as an argument. Other routines must explicitly request it using this routine. */ -DllInfo * +attribute_hidden DllInfo * R_getDllInfo(const char *path) { int i; diff --git a/src/main/attrib.c b/src/main/attrib.c index 6f446d94eda..1a7d69c4b70 100644 --- a/src/main/attrib.c +++ b/src/main/attrib.c @@ -744,7 +744,7 @@ static SEXP S4_extends(SEXP klass, Rboolean use_tab) { return(val); } -SEXP R_S4_extends(SEXP klass, SEXP useTable) +attribute_hidden SEXP R_S4_extends(SEXP klass, SEXP useTable) { return S4_extends(klass, asLogical(useTable)); } @@ -1757,7 +1757,7 @@ static SEXP set_data_part(SEXP obj, SEXP rhs) { return(val); } -SEXP S3Class(SEXP obj) +attribute_hidden SEXP S3Class(SEXP obj) { if(!s_dot_S3Class) init_slot_handling(); return getAttrib(obj, s_dot_S3Class); diff --git a/src/main/envir.c b/src/main/envir.c index f15f10b4fd7..07cb5efff02 100644 --- a/src/main/envir.c +++ b/src/main/envir.c @@ -3684,7 +3684,7 @@ SEXP R_PackageEnvName(SEXP rho) return R_NilValue; } -SEXP R_FindPackageEnv(SEXP info) +attribute_hidden SEXP R_FindPackageEnv(SEXP info) { SEXP expr, val; PROTECT(info); diff --git a/src/main/format.c b/src/main/format.c index 109aaeb4b97..d31e177e5d8 100644 --- a/src/main/format.c +++ b/src/main/format.c @@ -102,6 +102,7 @@ void formatStringS(SEXP x, R_xlen_t n, int *fieldwidth, int quote) +attribute_hidden void formatLogical(const int *x, R_xlen_t n, int *fieldwidth) { *fieldwidth = 1; @@ -119,6 +120,7 @@ void formatLogical(const int *x, R_xlen_t n, int *fieldwidth) } } +attribute_hidden void formatLogicalS(SEXP x, R_xlen_t n, int *fieldwidth) { *fieldwidth = 1; int tmpfieldwidth = 1; @@ -151,6 +153,7 @@ void formatLogicalS(SEXP x, R_xlen_t n, int *fieldwidth) { } \ } while(0) +attribute_hidden void formatInteger(const int *x, R_xlen_t n, int *fieldwidth) { int xmin = INT_MAX, xmax = INT_MIN, naflag = 0; @@ -167,6 +170,7 @@ void formatInteger(const int *x, R_xlen_t n, int *fieldwidth) FORMATINT_RETLOGIC; } +attribute_hidden void formatIntegerS(SEXP x, R_xlen_t n, int *fieldwidth) { @@ -426,6 +430,7 @@ scientific(const double *x, int *neg, int *kpower, int *nsig, Rboolean *rounding it is 0 except when called from do_format. */ +/* not hidden: used in graphics/src/plot.c */ void formatReal(const double *x, R_xlen_t n, int *w, int *d, int *e, int nsmall) { Rboolean @@ -507,6 +512,7 @@ void formatReal(const double *x, R_xlen_t n, int *w, int *d, int *e, int nsmall) if (neginf && *w < 4) *w = 4; } +attribute_hidden void formatRealS(SEXP x, R_xlen_t n, int *w, int *d, int *e, int nsmall) { /* @@ -739,6 +745,7 @@ void formatComplex(const Rcomplex *x, R_xlen_t n, +attribute_hidden void formatComplexS(SEXP x, R_xlen_t n, int *wr, int *dr, int *er, int *wi, int *di, int *ei, int nsmall) { diff --git a/src/main/objects.c b/src/main/objects.c index f91c64e5f46..8c6775295b7 100644 --- a/src/main/objects.c +++ b/src/main/objects.c @@ -304,7 +304,7 @@ static int match_to_obj(SEXP arg, SEXP obj) { which should be explicitly converted when an S3 method is applied to an object from an S4 subclass. */ -int isBasicClass(const char *ss) { +attribute_hidden int isBasicClass(const char *ss) { static SEXP s_S3table = NULL; if(!s_S3table) { s_S3table = findVarInFrame3(R_MethodsNamespace, install(".S3MethodsClasses"), TRUE); @@ -320,7 +320,7 @@ int isBasicClass(const char *ss) { /* Note that ./attrib.c 's S4_extends() has an alternative 'sanity check for methods package available' */ -Rboolean R_has_methods_attached(void) { +attribute_hidden Rboolean R_has_methods_attached(void) { return( isMethodsDispatchOn() && // based on unlockBinding() in ../library/methods/R/zzz.R {since 2003}: @@ -1113,6 +1113,7 @@ attribute_hidden SEXP do_inherits(SEXP call, SEXP op, SEXP args, SEXP env) * * @return index of match or -1 for no match */ +attribute_hidden int R_check_class_and_super(SEXP x, const char **valid, SEXP rho) { int ans; @@ -1708,7 +1709,7 @@ SEXP R_do_MAKE_CLASS(const char *what) // similar, but gives NULL instead of an error for a non-existing class // and 'what' is never checked -SEXP R_getClassDef_R(SEXP what) +attribute_hidden SEXP R_getClassDef_R(SEXP what) { static SEXP s_getClassDef = NULL; if(!s_getClassDef) s_getClassDef = install("getClassDef"); @@ -1729,7 +1730,7 @@ SEXP R_getClassDef(const char *what) return ans; } -Rboolean R_isVirtualClass(SEXP class_def, SEXP env) +attribute_hidden Rboolean R_isVirtualClass(SEXP class_def, SEXP env) { if(!isMethodsDispatchOn()) return(FALSE); static SEXP isVCl_sym = NULL; @@ -1743,7 +1744,7 @@ Rboolean R_isVirtualClass(SEXP class_def, SEXP env) return ans; } -Rboolean R_extends(SEXP class1, SEXP class2, SEXP env) +attribute_hidden Rboolean R_extends(SEXP class1, SEXP class2, SEXP env) { if(!isMethodsDispatchOn()) return(FALSE); static SEXP extends_sym = NULL; diff --git a/src/main/options.c b/src/main/options.c index 724a194ecd2..1726252bdcf 100644 --- a/src/main/options.c +++ b/src/main/options.c @@ -168,7 +168,8 @@ attribute_hidden int FixupDigits(SEXP digits, warn_type warn) } return d; } -int GetOptionDigits(void) + +attribute_hidden int GetOptionDigits(void) { return FixupDigits(GetOption1(install("digits")), iWARN); } diff --git a/src/main/printutils.c b/src/main/printutils.c index 10802f7dfd0..3f03215b7d9 100644 --- a/src/main/printutils.c +++ b/src/main/printutils.c @@ -180,6 +180,7 @@ const char *EncodeExtptr(SEXP x) return buf; } +attribute_hidden const char *EncodeReal(double x, int w, int d, int e, char cdec) { char dec[2]; diff --git a/src/main/serialize.c b/src/main/serialize.c index ae9b5376423..ea0205d4827 100644 --- a/src/main/serialize.c +++ b/src/main/serialize.c @@ -2541,6 +2541,7 @@ static void OutCharConn(R_outpstream_t stream, int c) } } +attribute_hidden void R_InitConnOutPStream(R_outpstream_t stream, Rconnection con, R_pstream_format_t type, int version, SEXP (*phook)(SEXP, SEXP), SEXP pdata) @@ -2553,6 +2554,7 @@ void R_InitConnOutPStream(R_outpstream_t stream, Rconnection con, OutCharConn, OutBytesConn, phook, pdata); } +attribute_hidden void R_InitConnInPStream(R_inpstream_t stream, Rconnection con, R_pstream_format_t type, SEXP (*phook)(SEXP, SEXP), SEXP pdata) diff --git a/src/main/util.c b/src/main/util.c index 3aad0d6ca8a..987f4e2386a 100644 --- a/src/main/util.c +++ b/src/main/util.c @@ -672,7 +672,7 @@ static void isort_with_index(int *x, int *indx, int n) // body(x) without attributes "srcref", "srcfile", "wholeSrcref" : // NOTE: Callers typically need PROTECT(R_body_no_src(.)) -SEXP R_body_no_src(SEXP x) { +attribute_hidden SEXP R_body_no_src(SEXP x) { SEXP b = PROTECT(duplicate(BODY_EXPR(x))); /* R's removeSource() works *recursively* on the body() in ../library/utils/R/sourceutils.R but that seems unneeded (?) */ diff --git a/src/unix/sys-std.c b/src/unix/sys-std.c index 3d355238e76..158a8025cfb 100644 --- a/src/unix/sys-std.c +++ b/src/unix/sys-std.c @@ -200,7 +200,7 @@ InputHandler *R_InputHandlers = &BasicInputHandler; Initialize the input source handlers used to check for input on the different file descriptors. */ -InputHandler * initStdinHandler(void) +attribute_hidden InputHandler * initStdinHandler(void) { InputHandler *inputs; @@ -334,6 +334,7 @@ int Rg_wait_usec = 0; static int setSelectMask(InputHandler *, fd_set *); +attribute_hidden fd_set *R_checkActivityEx(int usec, int ignore_stdin, void (*intr)(void)) { int maxfd; From 78ccd1828e342a71ba3aca5df64e8464707316c7 Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 31 May 2024 12:59:33 +0000 Subject: [PATCH 148/546] Improve substr/substring documentation (PR#18732). git-svn-id: https://svn.r-project.org/R/trunk@86656 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/substr.Rd | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/library/base/man/substr.Rd b/src/library/base/man/substr.Rd index cf9d5b6dc58..bac9715cf1c 100644 --- a/src/library/base/man/substr.Rd +++ b/src/library/base/man/substr.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/substr.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2023 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{substr} @@ -18,8 +18,8 @@ substring(text, first, last = 1000000L) <- value } \arguments{ \item{x, text}{a character vector.} - \item{start, first}{integer. The first element to be extracted or replaced.} - \item{stop, last}{integer. The last element to be extracted or replaced.} + \item{start, first}{integer. The first character to be extracted or replaced.} + \item{stop, last}{integer. The last character to be extracted or replaced.} \item{value}{a character vector, recycled if necessary.} } \description{ @@ -32,7 +32,8 @@ substring(text, first, last = 1000000L) <- value length of the longest \emph{provided} none are of zero length. When extracting, if \code{start} is larger than the string length then - \code{""} is returned. + \code{""} is returned. If \code{stop} is larger than the string length + then the portion until the end of the string is returned. For the extraction functions, \code{x} or \code{text} will be converted to a character vector by \code{\link{as.character}} if it is not @@ -43,10 +44,10 @@ substring(text, first, last = 1000000L) <- value replaced is longer than the replacement string, then only the portion the length of the string is replaced. - If any argument is an \code{NA} element, the corresponding element of + If any argument has an \code{NA} element, the corresponding element of the answer is \code{NA}. - Elements of the result will be have the encoding declared as that of + Elements of the result will have the encoding declared as that of the current locale (see \code{\link{Encoding}}) if the corresponding input had a declared Latin-1 or UTF-8 encoding and the current locale is either Latin-1 or UTF-8. @@ -57,7 +58,8 @@ substring(text, first, last = 1000000L) <- value } \value{ For \code{substr}, a character vector of the same length and with the - same attributes as \code{x} (after possible coercion). + same attributes as \code{x} (after possible coercion). \code{start} and + \code{stop} are recycled as necessary. For \code{substring}, a character vector of length the longest of the arguments. This will have names taken from \code{x} (if it has any From ddd72c575d0a5bff3170dcb74b797e444e6b6c96 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 31 May 2024 14:26:01 +0000 Subject: [PATCH 149/546] Try to use objdump when nm fails, probably because file is stripped. Also have checkAllPkgsAPI pass 'all' argument to checkPkgAPI. git-svn-id: https://svn.r-project.org/R/trunk@86657 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/apitools.R | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/library/tools/R/apitools.R b/src/library/tools/R/apitools.R index 3422a8d027d..65f45b7c99f 100644 --- a/src/library/tools/R/apitools.R +++ b/src/library/tools/R/apitools.R @@ -288,7 +288,7 @@ checkAllPkgsAPI <- function(lib.loc = NULL, priority = NULL, all = FALSE, p <- rownames(utils::installed.packages(lib.loc = lib.loc, priority = priority)) checkOne <- function(pkg) { - data <- checkPkgAPI(pkg, lib.loc = lib.loc) + data <- checkPkgAPI(pkg, lib.loc = lib.loc, all = all) if (! is.null(data)) data$pkg <- rep(pkg, nrow(data)) data @@ -317,9 +317,9 @@ ofile_syms <- function(fname, keep = c("F", "V", "U")) { ## this uses nm on Linux/macOS; probably doesn't work on Windows, so bail stopifnot(isFALSE(.Platform$OS.type == "windows")) v <- tools:::read_symbols_from_object_file(fname) - if (is.character(v) && nrow(v) == 0) - stop("no symbols; file may have been stripped") - if (is.null(v)) + if (is.character(v) && nrow(v) == 0) + ofile_syms_od(fname, keep) + else if (is.null(v)) data.frame(name = character(0), type = character(0)) else { match_type <-function(type) @@ -332,6 +332,20 @@ ofile_syms <- function(fname, keep = c("F", "V", "U")) { } } +ofile_syms_od <- function(fpath, keep = c("F", "V", "U")) { + if (Sys.which("objdump") == "") + stop("'objdump' is not on the path") + v <- system(sprintf("objdump -T %s", fpath), intern = TRUE) + v <- grep("\t", v, value = TRUE) ## data lines contain a \t + name <- sub(".*\t.* (.*$)", "\\1", v) ## the name is at the end after the \t + type <- sub(".* (.*)\t.*", "\\1", v) ## the type is right before the \t + ttbl <- + c("*UND*" = "U", ".text" = "F", ".bss" = "V", ".data" = "V", w = "w") + val <- data.frame(name, type = ttbl[match(type, names(ttbl), length(ttbl))]) + val <- val[val$type %in% keep, ] + clear_rownames(val[order(val$name), ]) +} + Rsyms <- function(keep = c("F", "V")) { rsyms <- apidata$rsyms if (is.null(rsyms)) { From 85e76afaf54dc72b72b1dee5c3e36f2fc8844cce Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 31 May 2024 19:40:29 +0000 Subject: [PATCH 150/546] Marked some ALTREP-related entry points as @eapifun. git-svn-id: https://svn.r-project.org/R/trunk@86658 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index bc691876986..5f95f7a45b4 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14649,6 +14649,19 @@ value is the actual number of elements copied, which may be less than Macros in @file{R_ext/Itermacros.h} may help in implementing an iteration strategy. +Some functions useful in implementing new alternate representation +classes, beyond those defined in @code{R_ext/Altrep.h}, include +@code{ALTREP}, @code{ALTREP_CLASS}, @code{R_altrep_data1}, +@code{R_set_altrep_data1}, @code{R_altrep_data2}, and +@code{R_set_altrep_data2}. +@eapifun ALTREP +@eapifun ALTREP_CLASS +@eapifun R_altrep_data1 +@eapifun R_set_altrep_data1 +@eapifun R_set_altrep_data2 +@eapifun R_altrep_data2 +@eapihdr R_ext/Altrep.h + @node The R API, Generic functions and methods, System and foreign language interfaces, Top @chapter The R @acronym{API}: entry points for C code From 6af519483300bef78d7c71c59c9a0ed93a30e9b5 Mon Sep 17 00:00:00 2001 From: ripley Date: Sat, 1 Jun 2024 06:10:53 +0000 Subject: [PATCH 151/546] update comments on F_VISIBILITY git-svn-id: https://svn.r-project.org/R/trunk@86661 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 5f95f7a45b4..d796d87d0da 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -16712,9 +16712,11 @@ flag, and where known the flag is encapsulated in the macros compiler for the default C++ dialect (currently C++11) and not necessarily to other dialects.} and @samp{F_VISIBILITY} for C, C++ and Fortran compilers.@footnote{In some cases Fortran compilers accept the -flag but do not actually hide their symbols.} These are defined in -@file{etc/Makeconf} and so available for normal compilation of package -code. For example, @file{src/Makevars} could include some of +flag but do not actually hide their symbols: at the time of writing that +was true of @command{gfortran}, @command{flang-new} and Intel's +@command{ifx}.} These are defined in @file{etc/Makeconf} and so +available for normal compilation of package code. For example, +@file{src/Makevars} could include some of @example PKG_CFLAGS=$(C_VISIBILITY) From 1c27a04100dbd5bacfe32a96490e657991c2624f Mon Sep 17 00:00:00 2001 From: ripley Date: Sat, 1 Jun 2024 10:57:36 +0000 Subject: [PATCH 152/546] Intel version update git-svn-id: https://svn.r-project.org/R/trunk@86663 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 38ee72d7adf..46ae27b040c 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -5013,7 +5013,8 @@ Standalone installers (which are free-of-charge) are available from @uref{https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html}: they are also part of the @I{oneAPI} Base and HPC (for Fortran) toolkits. -We tried the compilers in @I{oneAPI} 2024.1.0 and 2023.x.y using (the paths +We tried the compilers in @I{oneAPI} 2024.1.x@footnote{2024.1.2 for +C/C++, 2024.1.0 for Fortran.} and 2023.x.y using (the paths do differ by compiler version) @example IP=/path/to/compilers/bin/ @@ -5040,7 +5041,7 @@ MKL="-L$@{MKL_LIB_PATH@} -lmkl_intel_lp64 -lmkl_core -lmkl_sequential" ./configure --with-blas="$MKL" --with-lapack @end example @noindent -and the build passed its checks with @I{MKL} 2023.2.0 (but not 2024.0 on the +and the build passed its checks with @I{MKL} 2023.2.0 (but not 2024.x on the hardware tested). It may also be possible to use a compiler option like @option{-qmkl=sequential}. From 474bf27f4eea920e0b232d724f038ba84dffefde Mon Sep 17 00:00:00 2001 From: ripley Date: Sun, 2 Jun 2024 19:29:07 +0000 Subject: [PATCH 153/546] R >- 4.4.0 requires C++17 unless fudged git-svn-id: https://svn.r-project.org/R/trunk@86665 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index e0f13288300..2f6ead9f54a 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -6120,10 +6120,11 @@ add_dummies <- function(dir, Log) if (std < 17) { noteLog(Log, sprintf(" Specified C++%d: please drop specification unless essential", std)) - } else if (std >= 17) { - resultLog(Log, "OK") - printLog(Log, - sprintf(" Not all R platforms support C++%s\n", std)) + ##Ā sinece R 4.4.0 C++17 support is required. + ## } else if (std >= 17) { + ## resultLog(Log, "OK") + ## printLog(Log, + ## sprintf(" Not all R platforms support C++%s\n", std)) } else resultLog(Log, "OK") } } ## end of case B From 2974c0b8e98e12de2c110554157efcbe0cc34f87 Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 3 Jun 2024 07:26:15 +0000 Subject: [PATCH 154/546] typo in comment git-svn-id: https://svn.r-project.org/R/trunk@86666 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 2f6ead9f54a..abdec6cebfc 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -6120,7 +6120,7 @@ add_dummies <- function(dir, Log) if (std < 17) { noteLog(Log, sprintf(" Specified C++%d: please drop specification unless essential", std)) - ##Ā sinece R 4.4.0 C++17 support is required. + ##Ā since R 4.4.0 C++17 support is required. ## } else if (std >= 17) { ## resultLog(Log, "OK") ## printLog(Log, From 5bd7f5ccdbe33d5fa364c39b029019cd9d0be512 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 3 Jun 2024 13:40:13 +0000 Subject: [PATCH 155/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86667 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index 3d166817268..704b21469e9 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -81,7 +81,7 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Spain (Madrid) [https]",Spain,Madrid,https://cran.rediris.es/,"Spanish National Research Network, Madrid","Jose Manuel Macias ",1,es,"secure_mirror_from_master" "Sweden (UmeĆ„) [https]",Sweden,UmeĆ„,https://mirror.accum.se/mirror/CRAN/,"Academic Computer Club in UmeĆ„, Sweden","",1,se,"secure_mirror_from_master" "Switzerland (Zurich 1) [https]",Switzerland,ZĆ¼rich,https://stat.ethz.ch/CRAN/,"ETH ZĆ¼rich","Martin.Maechler # R-project.org",1,ch,"secure_mirror_from_master" -"Switzerland (Zurich 2) [https]",Switzerland,ZĆ¼rich,https://mirror.metanet.ch/cran/," METNET AG","mirror # metanet.ch",1,ch +"Switzerland (Zurich 2) [https]",Switzerland,ZĆ¼rich,https://mirror.metanet.ch/cran/," METNET AG","mirror # metanet.ch",0,ch "Taiwan (Taipei) [https]",Taiwan,Taipei,https://cran.csie.ntu.edu.tw/,"National Taiwan University, Taipei","b90098 # csie.ntu.edu.tw",1,tw,"secure_mirror_from_master" Thailand,Thailand,Hatyai,http://mirrors.psu.ac.th/pub/cran/,"Prince of Songkla University, Hatyai","wipat.s # psu.ac.th",1,th,"maintainer_address_bounces" "Turkey (Denizli) [https]",Turkey,Denizli,https://cran.pau.edu.tr/,"Pamukkale University, Denizli","Ugur Zeybek ",1,tr,"secure_mirror_from_master" From ed7aaf835760b0fee6840ed2b413cb3ce56eaf57 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 3 Jun 2024 13:40:23 +0000 Subject: [PATCH 156/546] Spelling. git-svn-id: https://svn.r-project.org/R/trunk@86668 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 46ae27b040c..3ef4342743a 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -2359,7 +2359,7 @@ problems} can be specified @emph{via} the environment variable Package developers are encouraged to use this mechanism to enable a reasonable amount of diagnostic messaging (``warnings'') when compiling, such as e.g.@: @option{-Wall -pedantic} for tools from GCC, the GNU -Compiler Collection, and for LLVM (@command{clang} and @command{flang-new}). +Compiler Collection, and for @I{LLVM} (@command{clang} and @command{flang-new}). Note that this mechanism can also be used when it is necessary to change the optimization level whilst installing a particular package. For From 5257ffa4773202fb3c47b6f70430e215cea9dc4b Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 3 Jun 2024 13:40:49 +0000 Subject: [PATCH 157/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86669 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/apitools.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/apitools.R b/src/library/tools/R/apitools.R index 65f45b7c99f..2c42189c92d 100644 --- a/src/library/tools/R/apitools.R +++ b/src/library/tools/R/apitools.R @@ -316,7 +316,7 @@ rbind_list <- function(args) ofile_syms <- function(fname, keep = c("F", "V", "U")) { ## this uses nm on Linux/macOS; probably doesn't work on Windows, so bail stopifnot(isFALSE(.Platform$OS.type == "windows")) - v <- tools:::read_symbols_from_object_file(fname) + v <- read_symbols_from_object_file(fname) if (is.character(v) && nrow(v) == 0) ofile_syms_od(fname, keep) else if (is.null(v)) From bab17c4f294a0452db3b5802dbd9a70349706d2f Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 3 Jun 2024 13:41:23 +0000 Subject: [PATCH 158/546] More ignores for new API tags. git-svn-id: https://svn.r-project.org/R/trunk@86670 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/aspell.R | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library/utils/R/aspell.R b/src/library/utils/R/aspell.R index 66b489a3eb0..a95e1a1aa25 100644 --- a/src/library/utils/R/aspell.R +++ b/src/library/utils/R/aspell.R @@ -470,6 +470,7 @@ aspell_control_R_manuals <- "--add-texinfo-ignore=pkg", "--add-texinfo-ignore=apifun", "--add-texinfo-ignore=apihdr", + "--add-texinfo-ignore=apivar", "--add-texinfo-ignore=comment", "--add-texinfo-ignore=defcodeindex", "--add-texinfo-ignore=eapifun", From cb30bd6ea9e2a794feab05f5bf287780212d9a54 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 3 Jun 2024 13:42:14 +0000 Subject: [PATCH 159/546] Document '.rdata' extension. git-svn-id: https://svn.r-project.org/R/trunk@86671 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/man/data.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/utils/man/data.Rd b/src/library/utils/man/data.Rd index 35e727387ea..71a0da8aea0 100644 --- a/src/library/utils/man/data.Rd +++ b/src/library/utils/man/data.Rd @@ -45,7 +45,7 @@ data(\dots, list = character(), package = NULL, lib.loc = NULL, (\code{data} ensures that the \pkg{utils} package is attached, in case it had been run \emph{via} \code{utils::data}.) - \item files ending \file{.RData} or \file{.rda} are + \item files ending \file{.RData} or \file{.rdata} or \file{.rda} are \code{\link{load}()}ed. \item files ending \file{.tab}, \file{.txt} or \file{.TXT} are read From 1b0ba1080534b00d285f50439789f67069113e14 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 3 Jun 2024 13:44:25 +0000 Subject: [PATCH 160/546] Also say where HTML Tidy can be obtained from (PR#18731, by Ivan Krylov). git-svn-id: https://svn.r-project.org/R/trunk@86672 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index abdec6cebfc..ffcc5c286f0 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -5311,9 +5311,17 @@ add_dummies <- function(dir, Log) if(!OK1) { noteLog(Log) any <- TRUE + txt <- + paste("Please obtain a recent version of HTML Tidy", + "by downloading a binary release", + "or compiling the source code from", + ".") + txt <- paste(strwrap(txt), collapse = "\n") printLog0(Log, c("Skipping checking HTML validation: ", attr(Tidy, "msg"), + ".\n", + txt, "\n")) } if(OK1 && length(errors <- attr(results1, "errors"))) { From 98f27180af78ac30aed433caf19aecaff62c7d64 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 3 Jun 2024 13:44:47 +0000 Subject: [PATCH 161/546] Add check_package_urls(). git-svn-id: https://svn.r-project.org/R/trunk@86673 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/urltools.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/library/tools/R/urltools.R b/src/library/tools/R/urltools.R index 30a4852ce3d..9781d6fc036 100644 --- a/src/library/tools/R/urltools.R +++ b/src/library/tools/R/urltools.R @@ -914,3 +914,10 @@ function(x) .curl_handle_default_opts <- list(cookiesession = 1L, followlocation = 1L) + +check_package_urls <- +function(dir, verbose = FALSE) +{ + db <- url_db_from_package_sources(dir) + check_url_db(db, verbose = verbose, parallel = TRUE) +} From cb693035eae018d45b5f5a6e84b0e85f4713d0b3 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 3 Jun 2024 13:45:06 +0000 Subject: [PATCH 162/546] Add check_package_dois(). git-svn-id: https://svn.r-project.org/R/trunk@86674 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/doitools.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/library/tools/R/doitools.R b/src/library/tools/R/doitools.R index e7d9f96257b..63dee696334 100644 --- a/src/library/tools/R/doitools.R +++ b/src/library/tools/R/doitools.R @@ -255,3 +255,10 @@ function(x, ...) writeLines(paste(format(x), collapse = "\n\n")) invisible(x) } + +check_package_dois <- +function(dir, verbose = FALSE) +{ + db <- doi_db_from_package_sources(dir, Rd = TRUE) + check_doi_db(db, verbose = verbose, parallel = TRUE) +} From e8f0bdba627ffa46fae2779dce023a86e1bf98cd Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 3 Jun 2024 13:45:33 +0000 Subject: [PATCH 163/546] Note bad DESCRIPTION URL field parts in CRAN submission checks. git-svn-id: https://svn.r-project.org/R/trunk@86675 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index f4628ce2f3a..f7fc97757d7 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -7894,6 +7894,11 @@ function(dir, localOnly = FALSE, pkgSize = NA) descr, ignore.case = TRUE))) out$descr_bad_arXiv_ids <- descr[ind] + ## Check URL field + if(!is.na(v <- meta["URL"]) && + length(z <- .bad_DESCRIPTION_URL_field_parts(v))) + out$url_field_parts <- z + skip_dates <- config_val_to_logical(Sys.getenv("_R_CHECK_CRAN_INCOMING_SKIP_DATES_", "FALSE")) @@ -8946,7 +8951,13 @@ function(x, ...) "Please use permanent DOI markup for linking to publications as in ."), collapse = "\n") } - )), + )), + fmt(c(if(length(y <- x$url_field_parts)) { + paste(c("The URL field contains the following bad parts:", + paste0(" ", y), + strwrap("The URL field should be a list of URLs separated by commas or whitespace.")), + collapse = "\n") + })), fmt(c(if(length(x$GNUmake)) { "GNU make is a SystemRequirements." })), @@ -10244,6 +10255,24 @@ function(x, ...) fmt(y))) } +### ** .bad_DESCRIPTION_URL_field_parts + +.bad_DESCRIPTION_URL_field_parts <- +function(s) +{ + if(is.na(s)) return(character()) + y <- .get_urls_from_DESCRIPTION_URL_field(s) + z <- strsplit(s, + "[[:space:]]*(\\([^)]*\\))?([,[:space:]]+|$)")[[1L]] + if(length(y) == length(z)) + character() + else { + z <- z %w/o% y + z[!grepl("^ Date: Mon, 3 Jun 2024 13:46:16 +0000 Subject: [PATCH 164/546] Only use first URL from DESCRIPTION URL field. git-svn-id: https://svn.r-project.org/R/trunk@86676 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 8d25385c84e..46230fabada 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -1442,14 +1442,20 @@ function(package = "base", lib.loc = NULL, auto = NULL) ## WRE: "a list of URLs separated by commas or whitespace". ## Cannot have several URLs in BibTeX and bibentry object URL ## fields (PR #16240). - if(length(urls <- strsplit(url, "[, \n]+")[[1L]]) > 1L) { - ## Show the first URL as the BibTeX url, and add the others - ## to the note (PR#18547). + ## In c84505 we folloed the suggestion of PR#18547: in case + ## of using a URL field with multiple URLs, show the first URL + ## as the BibTeX url, and add the others to the note. However, + ## * typically the noted (secondary) URLs get shown ahead of the + ## primary (first) URL; + ## * showing several URLs generally is "too much" for the + ## bibliographic information; + ## * one can typically use the primary URL to point to the + ## secondary ones, + ## Hence, we no longer add to the note, and only put the primary + ## URL in the url. + urls <- tools:::.get_urls_from_DESCRIPTION_URL_field(meta$URL) + if(length(urls)) z$url <- urls[1L] - z$note <- paste0(c(z$note, sprintf("\\url{%s}", urls[-1L])), - collapse = ", ") - } else - z$url <- url } header <- if(!auto_was_meta) { From 568b99fbee189e5b245c98aa83a806c9918bb895 Mon Sep 17 00:00:00 2001 From: pd Date: Mon, 3 Jun 2024 22:04:05 +0000 Subject: [PATCH 165/546] fixup section header in NEWS git-svn-id: https://svn.r-project.org/R/trunk@86679 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 9256713e267..c21320b46a9 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -94,7 +94,7 @@ } } -\section{\Rlogo CHANGES IN R 4.4.0 patched}{ +\section{\Rlogo CHANGES IN R 4.4.1}{ \subsection{C-LEVEL FACILITIES}{ \itemize{ \item Functions \code{R_atof} and \code{R_strtod} declared in From 3cc89410243a07d047d0c55873899d7d49215b9b Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 4 Jun 2024 05:25:45 +0000 Subject: [PATCH 166/546] Typo. git-svn-id: https://svn.r-project.org/R/trunk@86680 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 46230fabada..ab94b4bc887 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -1442,7 +1442,7 @@ function(package = "base", lib.loc = NULL, auto = NULL) ## WRE: "a list of URLs separated by commas or whitespace". ## Cannot have several URLs in BibTeX and bibentry object URL ## fields (PR #16240). - ## In c84505 we folloed the suggestion of PR#18547: in case + ## In c84505 we followed the suggestion of PR#18547: in case ## of using a URL field with multiple URLs, show the first URL ## as the BibTeX url, and add the others to the note. However, ## * typically the noted (secondary) URLs get shown ahead of the From 4839f872ed7c915e5ce42c55189aaafcb3cf886d Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 4 Jun 2024 07:41:04 +0000 Subject: [PATCH 167/546] still report use of C++20/23 git-svn-id: https://svn.r-project.org/R/trunk@86681 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index ffcc5c286f0..ccb1a49cc64 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -6128,11 +6128,12 @@ add_dummies <- function(dir, Log) if (std < 17) { noteLog(Log, sprintf(" Specified C++%d: please drop specification unless essential", std)) - ##Ā since R 4.4.0 C++17 support is required. - ## } else if (std >= 17) { - ## resultLog(Log, "OK") - ## printLog(Log, - ## sprintf(" Not all R platforms support C++%s\n", std)) + ##Ā since R 4.4.0 C++17 support is required, but + ## C++20/23} support is patchy + } else if (std >= 20) { + resultLog(Log, "OK") + printLog(Log, + sprintf(" Not all R platforms support C++%s\n", std)) } else resultLog(Log, "OK") } } ## end of case B From 7ef1e3ee212182b86387ac43e8c29e24aedf55c3 Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 4 Jun 2024 07:41:58 +0000 Subject: [PATCH 168/546] docuemnt R_NO_REMAP_RMATH with exceptions git-svn-id: https://svn.r-project.org/R/trunk@86682 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 8 ++++++++ src/include/Rinlinedfuns.h | 14 +++++++------- src/include/Rmath.h0.in | 10 +++++----- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index d796d87d0da..002f1b3fac7 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14729,6 +14729,14 @@ headers directly or @emph{via} inclusion from further packages, and may define @code{R_NO_REMAP} with or without including @file{Rinternals.h}.) @apihdr R_ext/Error.h +Some of these entry points are declared in header @file{Rmaht.h}, most +of which are remapped there. That remapping can be eliminated by +defining @code{R_NO_REMAP_RMATH} (before including any @R{} headers) and +prepending @samp{Rf_} to the function names used from that header except +@example +exp_rand norm_rand unif_rand signrank_free wilcox_free +@end example + We can classify the entry points as @table @emph diff --git a/src/include/Rinlinedfuns.h b/src/include/Rinlinedfuns.h index ddda16d34b6..5ade64c4c19 100644 --- a/src/include/Rinlinedfuns.h +++ b/src/include/Rinlinedfuns.h @@ -77,7 +77,7 @@ #include /* for strlen, strcmp */ /* define inline-able functions */ -#if defined(TESTING_WRITE_BARRIER) || defined(COMPILING_R) +#ifdef TESTING_WRITE_BARRIER # define STRICT_TYPECHECK # define CATCH_ZERO_LENGTH_ACCESS #endif @@ -96,7 +96,7 @@ SEXP CAR(SEXP e); #endif #ifdef STRICT_TYPECHECK -HIDDEN INLINE_FUN void CHKVEC(SEXP x) { +INLINE_FUN void CHKVEC(SEXP x) { switch (TYPEOF(x)) { case CHARSXP: case LGLSXP: @@ -320,7 +320,7 @@ INLINE_FUN R_xlen_t XTRUELENGTH(SEXP x) # define CHECK_VECTOR_RAW_ELT(x, i) do { } while(0) #endif -HIDDEN INLINE_FUN int *LOGICAL0(SEXP x) { +INLINE_FUN int *LOGICAL0(SEXP x) { CHECK_STDVEC_LGL(x); return (int *) STDVEC_DATAPTR(x); } @@ -333,7 +333,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_LVAL(SEXP x, Rboolean v) { LOGICAL0(x)[0] = v; } -HIDDEN INLINE_FUN int *INTEGER0(SEXP x) { +INLINE_FUN int *INTEGER0(SEXP x) { CHECK_STDVEC_INT(x); return (int *) STDVEC_DATAPTR(x); } @@ -346,7 +346,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_IVAL(SEXP x, int v) { INTEGER0(x)[0] = v; } -/*HIDDEN*/ INLINE_FUN double *REAL0(SEXP x) { +INLINE_FUN double *REAL0(SEXP x) { CHECK_STDVEC_REAL(x); return (double *) STDVEC_DATAPTR(x); } @@ -359,7 +359,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_DVAL(SEXP x, double v) { REAL0(x)[0] = v; } -/*HIDDEN*/ INLINE_FUN Rcomplex *COMPLEX0(SEXP x) { +INLINE_FUN Rcomplex *COMPLEX0(SEXP x) { CHECK_STDVEC_CPLX(x); return (Rcomplex *) STDVEC_DATAPTR(x); } @@ -372,7 +372,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_CVAL(SEXP x, Rcomplex v) { COMPLEX0(x)[0] = v; } -HIDDEN INLINE_FUN Rbyte *RAW0(SEXP x) { +INLINE_FUN Rbyte *RAW0(SEXP x) { CHECK_STDVEC_RAW(x); return (Rbyte *) STDVEC_DATAPTR(x); } diff --git a/src/include/Rmath.h0.in b/src/include/Rmath.h0.in index 834c046845a..1ea5d8e42e1 100644 --- a/src/include/Rmath.h0.in +++ b/src/include/Rmath.h0.in @@ -359,10 +359,10 @@ double R_pow_di(double, int); /* Random Number Generators */ -double norm_rand(void); -double unif_rand(void); +double norm_rand(void); //not remapped +double unif_rand(void); //not remapped double R_unif_index(double); -double exp_rand(void); +double exp_rand(void); //not remapped #ifdef MATHLIB_STANDALONE void set_seed(unsigned int, unsigned int); void get_seed(unsigned int *, unsigned int *); @@ -554,14 +554,14 @@ double dwilcox(double, double, double, int); double pwilcox(double, double, double, int, int); double qwilcox(double, double, double, int, int); double rwilcox(double, double); -void wilcox_free(void); +void wilcox_free(void); // not remapped /* Wilcoxon Signed Rank Distribution */ double dsignrank(double, double, int); double psignrank(double, double, int, int); double qsignrank(double, double, int, int); double rsignrank(double); -void signrank_free(void); +void signrank_free(void); // not remapped /* Gamma and Related Functions */ double gammafn(double); From 5dad8d4ead0da0ba7717b9b01fc535c6f6376f32 Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 4 Jun 2024 07:44:01 +0000 Subject: [PATCH 169/546] revert for now -- used to test if responsible for segfaults git-svn-id: https://svn.r-project.org/R/trunk@86683 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Rinlinedfuns.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/include/Rinlinedfuns.h b/src/include/Rinlinedfuns.h index 5ade64c4c19..ddda16d34b6 100644 --- a/src/include/Rinlinedfuns.h +++ b/src/include/Rinlinedfuns.h @@ -77,7 +77,7 @@ #include /* for strlen, strcmp */ /* define inline-able functions */ -#ifdef TESTING_WRITE_BARRIER +#if defined(TESTING_WRITE_BARRIER) || defined(COMPILING_R) # define STRICT_TYPECHECK # define CATCH_ZERO_LENGTH_ACCESS #endif @@ -96,7 +96,7 @@ SEXP CAR(SEXP e); #endif #ifdef STRICT_TYPECHECK -INLINE_FUN void CHKVEC(SEXP x) { +HIDDEN INLINE_FUN void CHKVEC(SEXP x) { switch (TYPEOF(x)) { case CHARSXP: case LGLSXP: @@ -320,7 +320,7 @@ INLINE_FUN R_xlen_t XTRUELENGTH(SEXP x) # define CHECK_VECTOR_RAW_ELT(x, i) do { } while(0) #endif -INLINE_FUN int *LOGICAL0(SEXP x) { +HIDDEN INLINE_FUN int *LOGICAL0(SEXP x) { CHECK_STDVEC_LGL(x); return (int *) STDVEC_DATAPTR(x); } @@ -333,7 +333,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_LVAL(SEXP x, Rboolean v) { LOGICAL0(x)[0] = v; } -INLINE_FUN int *INTEGER0(SEXP x) { +HIDDEN INLINE_FUN int *INTEGER0(SEXP x) { CHECK_STDVEC_INT(x); return (int *) STDVEC_DATAPTR(x); } @@ -346,7 +346,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_IVAL(SEXP x, int v) { INTEGER0(x)[0] = v; } -INLINE_FUN double *REAL0(SEXP x) { +/*HIDDEN*/ INLINE_FUN double *REAL0(SEXP x) { CHECK_STDVEC_REAL(x); return (double *) STDVEC_DATAPTR(x); } @@ -359,7 +359,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_DVAL(SEXP x, double v) { REAL0(x)[0] = v; } -INLINE_FUN Rcomplex *COMPLEX0(SEXP x) { +/*HIDDEN*/ INLINE_FUN Rcomplex *COMPLEX0(SEXP x) { CHECK_STDVEC_CPLX(x); return (Rcomplex *) STDVEC_DATAPTR(x); } @@ -372,7 +372,7 @@ HIDDEN INLINE_FUN void SET_SCALAR_CVAL(SEXP x, Rcomplex v) { COMPLEX0(x)[0] = v; } -INLINE_FUN Rbyte *RAW0(SEXP x) { +HIDDEN INLINE_FUN Rbyte *RAW0(SEXP x) { CHECK_STDVEC_RAW(x); return (Rbyte *) STDVEC_DATAPTR(x); } From ccdb33cec9d43513aac53cbc73df1f4a6a404c8a Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 4 Jun 2024 07:57:56 +0000 Subject: [PATCH 170/546] typo git-svn-id: https://svn.r-project.org/R/trunk@86684 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 002f1b3fac7..f1ab0aaaa93 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14729,7 +14729,7 @@ headers directly or @emph{via} inclusion from further packages, and may define @code{R_NO_REMAP} with or without including @file{Rinternals.h}.) @apihdr R_ext/Error.h -Some of these entry points are declared in header @file{Rmaht.h}, most +Some of these entry points are declared in header @file{Rmath.h}, most of which are remapped there. That remapping can be eliminated by defining @code{R_NO_REMAP_RMATH} (before including any @R{} headers) and prepending @samp{Rf_} to the function names used from that header except From dacf4e50fe23a81774dc10545768d053fbc48430 Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 4 Jun 2024 16:04:28 +0000 Subject: [PATCH 171/546] Provide user/domain name in file.info on Windows (related to PR#18736). git-svn-id: https://svn.r-project.org/R/trunk@86686 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/file.info.Rd | 10 +++-- src/main/platform.c | 73 +++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 7 deletions(-) diff --git a/src/library/base/man/file.info.Rd b/src/library/base/man/file.info.Rd index d3048dd9ce6..0779d41d6a2 100644 --- a/src/library/base/man/file.info.Rd +++ b/src/library/base/man/file.info.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/file.info.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2022 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{file.info} @@ -81,6 +81,10 @@ file.size(\dots) \code{"win32"}, \code{"win64"} and \code{"unknown"}. Note that a file (e.g., a script file) can be executable according to the mode bits but not executable in this sense.} + \item{uname:}{character, user name.} + \item{udomain:}{character, user domain name.} + User name and domain will be \code{NA} when they cannot be resolved, + e.g. because of insufficient permissions or a network failure. }} } @@ -92,8 +96,8 @@ file.size(\dots) Entries for non-existent or non-readable files will be \code{NA}. The \code{uid}, \code{gid}, \code{uname} and \code{grname} columns - may not be supplied on a non-POSIX Unix-alike system, and will not be - on Windows. + may not be supplied on a non-POSIX Unix-alike system, and except + \code{uname} will not be on Windows. What is meant by the three file times depends on the OS and file system. On Windows native file systems \code{ctime} is the file diff --git a/src/main/platform.c b/src/main/platform.c index 9d67f7a23f6..6bf3563b963 100644 --- a/src/main/platform.c +++ b/src/main/platform.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1998--2023 The R Core Team + * Copyright (C) 1998--2024 The R Core Team * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka * * This program is free software; you can redistribute it and/or modify @@ -65,6 +65,7 @@ #ifdef Win32 #include +#include /* for GetSecurityInfo */ typedef BOOLEAN (WINAPI *PCSL)(LPWSTR, LPWSTR, DWORD); const char *formatError(DWORD res); /* extra.c */ /* Windows does not have link(), but it does have CreateHardLink() on NTFS */ @@ -805,13 +806,18 @@ attribute_hidden SEXP do_filerename(SEXP call, SEXP op, SEXP args, SEXP rho) attribute_hidden SEXP do_fileinfo(SEXP call, SEXP op, SEXP args, SEXP rho) { SEXP fn, ans, ansnames, fsize, mtime, ctime, atime, isdir, - mode, xxclass; + mode, xxclass, uname = R_NilValue, udomain = R_NilValue; + const void *vmax = vmaxget(); #ifdef UNIX_EXTRAS SEXP uid = R_NilValue, gid = R_NilValue, - uname = R_NilValue, grname = R_NilValue; // silence -Wall + grname = R_NilValue; // silence -Wall #endif #ifdef Win32 SEXP exe = R_NilValue; + char *ubuf = NULL; + DWORD ubuflen = 0; + char *dbuf = NULL; + DWORD dbuflen = 0; struct _stati64 sb; #else struct stat sb; @@ -829,7 +835,7 @@ attribute_hidden SEXP do_fileinfo(SEXP call, SEXP op, SEXP args, SEXP rho) #ifdef UNIX_EXTRAS ncols = 10; #elif defined(Win32) - ncols = 7; + ncols = 9; #endif } PROTECT(ans = allocVector(VECSXP, ncols)); @@ -860,6 +866,10 @@ attribute_hidden SEXP do_fileinfo(SEXP call, SEXP op, SEXP args, SEXP rho) #ifdef Win32 exe = SET_VECTOR_ELT(ans, 6, allocVector(STRSXP, n)); SET_STRING_ELT(ansnames, 6, mkChar("exe")); + uname = SET_VECTOR_ELT(ans, 7, allocVector(STRSXP, n)); + SET_STRING_ELT(ansnames, 7, mkChar("uname")); + udomain = SET_VECTOR_ELT(ans, 8, allocVector(STRSXP, n)); + SET_STRING_ELT(ansnames, 8, mkChar("udomain")); #endif } for (int i = 0; i < n; i++) { @@ -997,6 +1007,60 @@ attribute_hidden SEXP do_fileinfo(SEXP call, SEXP op, SEXP args, SEXP rho) } SET_STRING_ELT(exe, i, mkChar(s)); } + { + HANDLE h; + PSID owner_sid; + SID_NAME_USE suse = SidTypeUnknown; + PSECURITY_DESCRIPTOR sd = NULL; + DWORD saveerr = ERROR_SUCCESS; + int ok = 0; + h = CreateFileW(wfn, GENERIC_READ, + FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + ok = (h != INVALID_HANDLE_VALUE); + + ok = ok && (GetSecurityInfo(h, SE_FILE_OBJECT, + OWNER_SECURITY_INFORMATION, + &owner_sid, + NULL, NULL, NULL, &sd) + == ERROR_SUCCESS); + if (ok) { + DWORD ulen = ubuflen; + DWORD dlen = dbuflen; + ok = LookupAccountSid(NULL, owner_sid, ubuf, &ulen, + dbuf, &dlen, &suse); + if (!ok + && GetLastError() == ERROR_INSUFFICIENT_BUFFER + && (ulen > ubuflen || dlen > dbuflen)) { + + if (ulen > ubuflen) { + ubuf = R_alloc(ulen, 1); + ubuflen = ulen; + } + if (dlen > dbuflen) { + dbuf = R_alloc(dlen, 1); + dbuflen = dlen; + } + ok = LookupAccountSid(NULL, owner_sid, ubuf, &ulen, + dbuf, &dlen, &suse); + } + } + if (!ok) + saveerr = GetLastError(); + if (sd) + LocalFree(sd); + if (h != INVALID_HANDLE_VALUE) + CloseHandle(h); + if (ok) { + SET_STRING_ELT(uname, i, mkChar(ubuf)); + SET_STRING_ELT(udomain, i, mkChar(dbuf)); + } else { + warning(_("cannot resolve owner of file '%ls': %s"), + wfn, formatError(saveerr)); + SET_STRING_ELT(uname, i, NA_STRING); + SET_STRING_ELT(udomain, i, NA_STRING); + } + } #endif } } else { @@ -1022,6 +1086,7 @@ attribute_hidden SEXP do_fileinfo(SEXP call, SEXP op, SEXP args, SEXP rho) setAttrib(ans, R_NamesSymbol, ansnames); PROTECT(xxclass = mkString("octmode")); classgets(mode, xxclass); + vmaxset(vmax); UNPROTECT(3); return ans; } From 856ec5f0d3db5f8d4bc46ba36d7111eaaf8fa8c8 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 4 Jun 2024 18:45:07 +0000 Subject: [PATCH 172/546] Moved allocLang entry to R 4.4.1section of NEWS.Rd. git-svn-id: https://svn.r-project.org/R/trunk@86687 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index c21320b46a9..970482fd3a2 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -74,10 +74,6 @@ embedded API entry points in the rendered versions. This is very preliminary and may be dropped if a better approach emerges. - \item The new function \code{Rf_allocLang} is now available. This - provides an alternative to the idiom of calling - \code{Rf_allocList} followed by \code{SET_TYPEOF}. - \item \code{SET_TYPEOF} now signals an error unless the old and new types have compatible memory structure and content. Use of \code{SET_TYPE} in package C code should be avoided and may be @@ -105,6 +101,10 @@ \code{Rf_StringFalse}, \code{Rf_StringTrue} and \code{Rf_isBlankString} have been added to those reported by \command{R CMD check}. + + \item The new function \code{Rf_allocLang} is now available. This + provides an alternative to the idiom of calling + \code{Rf_allocList} followed by \code{SET_TYPEOF}. } } From f0c588f36e855069f79c18f5b73ab21354084951 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 4 Jun 2024 21:15:14 +0000 Subject: [PATCH 173/546] Mark some more entry points used in packages as in an API. git-svn-id: https://svn.r-project.org/R/trunk@86688 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index f1ab0aaaa93..1cd6fe3e6f4 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -12696,12 +12696,36 @@ and @code{character()}. One distinction is that whereas the @R{} functions always initialize the elements of the vector, @code{allocVector} only does so for lists, expressions and character vectors (the cases where the elements are themselves @R{} objects). +Other useful allocation functions are @code{alloc3DArray}, +@code{allocArray}, and @code{allocMatrix}. +@apifun alloc3DArray +@apifun allocArray +@apifun allocMatrix + +At times it can be useful to allocate a larger initial result vector and +resize it to a shorter length if that is sufficient. The functions +@code{lengthgets} and @code{xlengthgets} accomplish this; they are +analogous to using @code{length(x) <- n} in @R{}. Typically these +functions return a freshly allocated object, but in some cases they may +re-use the supplied object. +@apifun lengthgets +@apifun xlengthgets + +When creating new result objects it can be useful to fill them in with +values from an existing object. The functions @code{copyVector} and +@code{copyMatrix} can be used for this. @code{copyMostAttributes} can +also simplify setting up a result object; is is used internally for +results of arithmetic operations. +@apifun copyVector +@apifun copyMatrix +@apifun copyMostAttrib If storage is required for C objects during the calculations this is best allocating by calling @code{R_alloc}; @pxref{Memory allocation}. All of these memory allocation routines do their own error-checking, so the programmer may assume that they will raise an error and not return if the memory cannot be allocated. +@apifun R_alloc @node Details of R types, Attributes, Allocating storage, Handling R objects in C @subsection Details of R types @@ -13229,6 +13253,7 @@ a test of a length-2 @code{"dim"} attribute. @apifun isList @apifun isOrdered @apifun isUnordered +@apifun isS4 @comment @apifun isNumber @comment @apifun isFrame @example @@ -13250,6 +13275,7 @@ Rboolean isNewList(SEXP); Rboolean isList(SEXP); Rboolean isOrdered(SEXP); Rboolean isUnordered(SEXP); +Rboolean isS4(SEXP); @comment Rboolean isNumber(SEXP); @comment Rboolean isFrame (SEXP); @end group @@ -13661,6 +13687,8 @@ implementation this is also true of @code{NA} as it is a type of re-write the code to handle @code{NA}s using macros defined in @file{R_ext/Arith.h} included by @file{R.h}. @apihdr R_ext/Arith.h +@comment listing this here since it is hard to pick up from R_ext/Arith.h +@apifun R_isnancpp The code changes are the same in any of the versions of @code{convolve2} or @code{convolveE}: @@ -14650,7 +14678,7 @@ Macros in @file{R_ext/Itermacros.h} may help in implementing an iteration strategy. Some functions useful in implementing new alternate representation -classes, beyond those defined in @code{R_ext/Altrep.h}, include +classes, beyond those defined in @file{R_ext/Altrep.h}, include @code{ALTREP}, @code{ALTREP_CLASS}, @code{R_altrep_data1}, @code{R_set_altrep_data1}, @code{R_altrep_data2}, and @code{R_set_altrep_data2}. From 35370a9ebd20ac8e15d92c179e3df27b1e2c92fc Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 5 Jun 2024 12:29:46 +0000 Subject: [PATCH 174/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86689 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index 704b21469e9..3544160ba77 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -97,7 +97,7 @@ Thailand,Thailand,Hatyai,http://mirrors.psu.ac.th/pub/cran/,"Prince of Songkla U "USA (NC) [https]",USA,Durham,https://archive.linux.duke.edu/cran/,"Duke University, Durham, NC","csi-linux-admins # duke.edu",1,us "USA (OH) [https]",USA,Cleveland,https://cran.case.edu/,"Case Western Reserve University, Cleveland, OH","""Alberto H. Santana"" ",1,us,"secure_mirror_from_master" "USA (OR) [https]",USA,Corvallis,https://ftp.osuosl.org/pub/cran/,"Oregon State University","support # Osuosl.org",1,us,"secure_mirror_from_master" -"USA (PA 1)",USA,Pittsburgh,http://lib.stat.cmu.edu/R/CRAN/,"Statlib, Carnegie Mellon University, Pittsburgh, PA","Carl Skipper ",1,us +"USA (PA 1) [https]",USA,Pittsburgh,https://lib.stat.cmu.edu/R/CRAN/,"Statlib, Carnegie Mellon University, Pittsburgh, PA","Carl Skipper ",1,us,"secure_mirror_from_master" "USA (PA 2) [https]",USA,Pittsburgh,https://cran.mirrors.hoobly.com/,"Hoobly Classifieds, Pittsburgh, PA","Peter Grigor ",1,us "USA (TN) [https]",USA,"Oak Ridge",https://mirrors.nics.utk.edu/cran/,"National Institute for Computational Sciences, Oak Ridge, TN","help # nics.utk.edu",1,us,"secure_mirror_from_master" "United Arab Emirates [https]","United Arab Emirates","Abu Dhabi",https://cran.nyuad.nyu.edu/,"New York University in Abu Dhabi","nyuad.cran # nyu.edu",1,ae,"secure_mirror_from_master" From a02897c9af06a9a0c04a51258765eb711936f4d8 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 5 Jun 2024 12:31:34 +0000 Subject: [PATCH 175/546] NEWS for c86675. git-svn-id: https://svn.r-project.org/R/trunk@86690 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 970482fd3a2..e033dd5834c 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -86,6 +86,9 @@ \itemize{ \item \command{R CMD check --as-cran} will compile C++ code with \code{-DR_NO_REMAP}. + + \item \command{R CMD check --as-cran} notes bad parts in + \file{DESCRIPTION} file URL fields. } } } From b74b06275e1eccbcc61366b4cd17e8f30d5c2021 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 5 Jun 2024 13:43:14 +0000 Subject: [PATCH 176/546] Inline R_dim into do_dim to free up the name for possible future use. git-svn-id: https://svn.r-project.org/R/trunk@86691 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/attrib.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/attrib.c b/src/main/attrib.c index 1a7d69c4b70..75b881002cd 100644 --- a/src/main/attrib.c +++ b/src/main/attrib.c @@ -1171,9 +1171,11 @@ attribute_hidden SEXP do_dimnames(SEXP call, SEXP op, SEXP args, SEXP env) return ans; } -static /* would need to be in a header if not static */ -SEXP R_dim(SEXP call, SEXP op, SEXP args, SEXP env) +attribute_hidden SEXP do_dim(SEXP call, SEXP op, SEXP args, SEXP env) { + checkArity(op, args); + check1arg(args, call, "x"); + SEXP ans; /* DispatchOrEval internal generic: dim */ if (DispatchOrEval(call, op, "dim", args, env, &ans, 0, /* argsevald: */ 1)) @@ -1184,13 +1186,6 @@ SEXP R_dim(SEXP call, SEXP op, SEXP args, SEXP env) return ans; } -attribute_hidden SEXP do_dim(SEXP call, SEXP op, SEXP args, SEXP env) -{ - checkArity(op, args); - check1arg(args, call, "x"); - return R_dim(call, op, args, env); -} - attribute_hidden SEXP do_dimgets(SEXP call, SEXP op, SEXP args, SEXP env) { SEXP ans, x; From e71f4b8d710093dc4c054436dcc6a7d8870888ef Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 5 Jun 2024 14:11:14 +0000 Subject: [PATCH 177/546] Add isNumber and topenv to the C API. git-svn-id: https://svn.r-project.org/R/trunk@86692 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 1cd6fe3e6f4..13a3c7a509d 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13254,7 +13254,7 @@ a test of a length-2 @code{"dim"} attribute. @apifun isOrdered @apifun isUnordered @apifun isS4 -@comment @apifun isNumber +@apifun isNumber @comment @apifun isFrame @example @group @@ -13276,7 +13276,7 @@ Rboolean isList(SEXP); Rboolean isOrdered(SEXP); Rboolean isUnordered(SEXP); Rboolean isS4(SEXP); -@comment Rboolean isNumber(SEXP); +Rboolean isNumber(SEXP); @comment Rboolean isFrame (SEXP); @end group @end example @@ -13351,9 +13351,10 @@ Function @code{R_BindingIsLocked} corresponds to @R{}'s @code{bindingIsLocked} @eapifun R_MakeActiveBinding @eapifun R_unLockBinding -The C function @code{inherits} corresponds to the @R{} function of the -same name. +The C functions @code{inherits} and @code{topenv} correspond to the @R{} +functions of the same name. @apifun inherits +@apifun topenv @node Named objects and copying, , Some convenience functions, Handling R objects in C @subsection Named objects and copying From 640573edec8776faa9ec131cfdffae2fe92c3b3a Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 5 Jun 2024 16:13:11 +0000 Subject: [PATCH 178/546] Add R_ExecWithCleanup, R_ToplevelExec, R_tryEvalSilent, and R_tryEval to the API. git-svn-id: https://svn.r-project.org/R/trunk@86693 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 13a3c7a509d..2270fe73324 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -16602,6 +16602,48 @@ the C++ code to be unwound, and then use the continuation token in the a call @code{R_ContinueUnwind(cont)} to resume the non-local transfer of control within R. +An older interface for the simpler @code{R_MakeUnwindCont} usage remains +available: + +@example +SEXP R_ExecWithCleanup(SEXP (*fun)(void *), void *data, + void (*cleanfun)(void *), void *cleandata); +@end example +@apifun R_ExecWithCleanup + +@code{cleanfun} is called on both regular returns and non-local +transfers of control, but without an indication of which form of exit is +occurring. + +The function @code{R_ToplevelExec} can be used to execute code without +allowing any non-local transfers of control, including by user +interrupts or invoking @code{abort} restarts. +@example +Rboolean R_ToplevelExec(void (*fun)(void *), void *data); +@end example +@apifun R_ToplevelExec +The return value is @code{TRUE} if @code{fun} returns normally and +@code{FALSE} if @code{fun} exits with a jump to top level. @code{fun} +is called with a new top-level context. Condition handlers and other +features of the current top level context when @code{R_ToplevelExec} is +called will not be seen by the code in @code{fun}. Two convenience +functions built on @code{R_ToplevelExec} are @code{R_tryEval} and +@code{R_tryEvalSilent}. +@example +SEXP R_tryEval(SEXP e, SEXP env, int *ErrorOccurred); +SEXP R_tryEvalSilent(SEXP e, SEXP env, int *ErrorOccurred) +@end example +@apifun R_tryEvalSilent +@apifun R_tryEval +These return a @code{NULL} pointer if evaluating the expression results +in a jump to top level. + +Using @code{R_ToplevelExec} is usually only appropriate in situations +where one might want to run code in a separate thread if that was an +option. For example, finalizers are run in a separate top level +context. The other functions mentioned in this section will usually be +more appropriate choices. + @node Allowing interrupts, Platform and version information, Condition handling and cleanup code, The R API @section Allowing interrupts @cindex Interrupts From d499fab95b1ba23ee7842293030d4af1e69ae0fe Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 5 Jun 2024 16:40:48 +0000 Subject: [PATCH 179/546] Add VECTOR_PTR_RO for consistency with STRING_PTR_RO. git-svn-id: https://svn.r-project.org/R/trunk@86694 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Defn.h | 1 + src/include/Rinternals.h | 1 + src/main/memory.c | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/src/include/Defn.h b/src/include/Defn.h index 473b77f464e..30dfba5561f 100644 --- a/src/include/Defn.h +++ b/src/include/Defn.h @@ -425,6 +425,7 @@ typedef union { VECTOR_SEXPREC s; double align; } SEXPREC_ALIGN; #define COMPLEX_RO(x) ((const Rcomplex *) DATAPTR_RO(x)) #define REAL_RO(x) ((const double *) DATAPTR_RO(x)) #define STRING_PTR_RO(x)((const SEXP *) DATAPTR_RO(x)) +#define VECTOR_PTR_RO(x)((const SEXP *) DATAPTR_RO(x)) /* List Access Macros */ /* These also work for ... objects */ diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index 3b73c80eeac..90691a89e52 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -292,6 +292,7 @@ void SET_STRING_ELT(SEXP x, R_xlen_t i, SEXP v); SEXP SET_VECTOR_ELT(SEXP x, R_xlen_t i, SEXP v); SEXP *(STRING_PTR)(SEXP x); const SEXP *(STRING_PTR_RO)(SEXP x); +const SEXP *(VECTOR_PTR_RO)(SEXP x); NORET SEXP * (VECTOR_PTR)(SEXP x); R_xlen_t INTEGER_GET_REGION(SEXP sx, R_xlen_t i, R_xlen_t n, int *buf); diff --git a/src/main/memory.c b/src/main/memory.c index 6166f048848..47e295b731e 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4216,6 +4216,14 @@ NORET SEXP * (VECTOR_PTR)(SEXP x) error(_("not safe to return vector pointer")); } +const SEXP *(VECTOR_PTR_RO)(SEXP x) { + if(TYPEOF(x) != VECSXP) + error("%s() can only be applied to a '%s', not a '%s'", + "STRING_PTR_RO", "list", R_typeToChar(x)); + CHKZLN(x); + return VECTOR_PTR_RO(x); +} + void (SET_STRING_ELT)(SEXP x, R_xlen_t i, SEXP v) { if(TYPEOF(CHK(x)) != STRSXP) error("%s() can only be applied to a '%s', not a '%s'", From 63519f2ffc5d20347dbd9c433cc3be2b0f18ee0d Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 5 Jun 2024 16:49:27 +0000 Subject: [PATCH 180/546] Add STRING_PTR_RO and VECTOR_PTR_RO to the API. git-svn-id: https://svn.r-project.org/R/trunk@86695 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 2270fe73324..98d27188aa8 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14524,8 +14524,12 @@ For example, the return type of @code{REAL_RO} is @code{const double *} @apifun LOGICAL_RO @apifun RAW_RO @apifun COMPLEX_RO -These accessor functions check that they are being used on an appropriate -type of @code{SEXP}. +@apifun STRING_PTR_RO +@apifun VECTOR_PTR_RO +These accessor functions check that they are being used on an +appropriate type of @code{SEXP}. For @code{VECSXP} and @code{STRSXP} +objects only read-only pointers are available as modifying their data +directly would violate assumptions the memory manager depends on. Formerly it was possible for packages to obtain internal versions of some accessors by defining @samp{USE_RINTERNALS} before including From c68dbe7ea71c6f785730cb61d9a9d08386c37151 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 6 Jun 2024 08:50:58 +0000 Subject: [PATCH 181/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86696 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index 3544160ba77..182792f7f2b 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -97,7 +97,7 @@ Thailand,Thailand,Hatyai,http://mirrors.psu.ac.th/pub/cran/,"Prince of Songkla U "USA (NC) [https]",USA,Durham,https://archive.linux.duke.edu/cran/,"Duke University, Durham, NC","csi-linux-admins # duke.edu",1,us "USA (OH) [https]",USA,Cleveland,https://cran.case.edu/,"Case Western Reserve University, Cleveland, OH","""Alberto H. Santana"" ",1,us,"secure_mirror_from_master" "USA (OR) [https]",USA,Corvallis,https://ftp.osuosl.org/pub/cran/,"Oregon State University","support # Osuosl.org",1,us,"secure_mirror_from_master" -"USA (PA 1) [https]",USA,Pittsburgh,https://lib.stat.cmu.edu/R/CRAN/,"Statlib, Carnegie Mellon University, Pittsburgh, PA","Carl Skipper ",1,us,"secure_mirror_from_master" +"USA (PA 1) [https]",USA,Pittsburgh,https://lib.stat.cmu.edu/R/CRAN/,"Statlib, Carnegie Mellon University, Pittsburgh, PA","Jacob Gordon ",1,us,"secure_mirror_from_master" "USA (PA 2) [https]",USA,Pittsburgh,https://cran.mirrors.hoobly.com/,"Hoobly Classifieds, Pittsburgh, PA","Peter Grigor ",1,us "USA (TN) [https]",USA,"Oak Ridge",https://mirrors.nics.utk.edu/cran/,"National Institute for Computational Sciences, Oak Ridge, TN","help # nics.utk.edu",1,us,"secure_mirror_from_master" "United Arab Emirates [https]","United Arab Emirates","Abu Dhabi",https://cran.nyuad.nyu.edu/,"New York University in Abu Dhabi","nyuad.cran # nyu.edu",1,ae,"secure_mirror_from_master" From e3bbfa00e694fe7e64000671e62a9f196dafb733 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 6 Jun 2024 08:51:39 +0000 Subject: [PATCH 182/546] NEWS for c86676. git-svn-id: https://svn.r-project.org/R/trunk@86697 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index e033dd5834c..8f2c407299c 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -91,6 +91,13 @@ \file{DESCRIPTION} file URL fields. } } + + \subsection{BUG FIXES}{ + \itemize{ + \item Auto-generated \code{citation()} entries no longer include + (additional) URLs in the \samp{note} field (\PR{18547}). + } + } } \section{\Rlogo CHANGES IN R 4.4.1}{ From 8ff6900eb99a5afa73447f3bd6dbcab000106876 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 6 Jun 2024 13:20:06 +0000 Subject: [PATCH 183/546] Move some things from @apifun to @apivar. git-svn-id: https://svn.r-project.org/R/trunk@86698 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 98d27188aa8..5bdf805fad1 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -15183,9 +15183,9 @@ by something like (fixed-form Fortran 90 code): @apifun ISNAN @apifun R_FINITE @apifun R_IsNaN -@apifun R_PosInf -@apifun R_NegInf -@apifun NA_REAL +@apivar R_PosInf +@apivar R_NegInf +@apivar NA_REAL A set of functions is provided to test for @code{NA}, @code{Inf}, @code{-Inf} and @code{NaN}. These functions are accessed @emph{via} macros: From 31a96aa0b3d04ba57703d5f2e3aadebde94e0584 Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 6 Jun 2024 16:34:16 +0000 Subject: [PATCH 184/546] PROTECT fix. git-svn-id: https://svn.r-project.org/R/trunk@86699 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/bind.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/bind.c b/src/main/bind.c index e0348223279..5dc99eb61ae 100644 --- a/src/main/bind.c +++ b/src/main/bind.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1997--2023 The R Core Team + * Copyright (C) 1997--2024 The R Core Team * Copyright (C) 2002--2020 The R Foundation * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka * @@ -1120,11 +1120,11 @@ attribute_hidden SEXP do_bind(SEXP call, SEXP op, SEXP args, SEXP env) method = findFun(install(generic), R_MethodsNamespace); } if (method != R_NilValue) { // found an S3 or S4 method + PROTECT(method); if (missingDL) args = CDR(args); /* discard 'deparse.level' */ else SET_TAG(args, install("deparse.level")); /* tag 'deparse.level' */ - PROTECT(method); SEXP ans = applyClosure(call, method, args, env, R_NilValue, TRUE); UNPROTECT(2); return ans; From 4ef83b9dc3c6874e774195d329cbb6c11a71c414 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 7 Jun 2024 11:38:54 +0000 Subject: [PATCH 185/546] Rename isFrame to isDataFrame and add to API. For now isFrame remains available, but is non-API. git-svn-id: https://svn.r-project.org/R/trunk@86702 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 11 +++++++++-- src/include/Rinlinedfuns.h | 5 ++++- src/include/Rinternals.h | 2 ++ src/library/stats/src/model.c | 2 +- src/main/coerce.c | 2 +- src/main/print.c | 2 +- src/main/util.c | 6 +++--- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 5bdf805fad1..76aeef993dd 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13255,7 +13255,7 @@ a test of a length-2 @code{"dim"} attribute. @apifun isUnordered @apifun isS4 @apifun isNumber -@comment @apifun isFrame +@apifun isDataFrame @example @group Rboolean isVector(SEXP); @@ -13277,7 +13277,7 @@ Rboolean isOrdered(SEXP); Rboolean isUnordered(SEXP); Rboolean isS4(SEXP); Rboolean isNumber(SEXP); -@comment Rboolean isFrame (SEXP); +Rboolean isDataFrame (SEXP); @end group @end example @@ -13356,6 +13356,13 @@ functions of the same name. @apifun inherits @apifun topenv +Some convenience functions for working with pairlist objects include +@code{copyListMatrix}, @code{VectorToPairList}, and +@code{PairToVectorList} +@eapifun copyListMatrix +@eapifun VectorToPairList +@eapifun PairToVectorList + @node Named objects and copying, , Some convenience functions, Handling R objects in C @subsection Named objects and copying @cindex Copying objects diff --git a/src/include/Rinlinedfuns.h b/src/include/Rinlinedfuns.h index ddda16d34b6..ba378a27f64 100644 --- a/src/include/Rinlinedfuns.h +++ b/src/include/Rinlinedfuns.h @@ -890,7 +890,7 @@ INLINE_FUN Rboolean isVector(SEXP s)/* === isVectorList() or isVectorAtomic() */ } } -INLINE_FUN Rboolean isFrame(SEXP s) +INLINE_FUN Rboolean isDataFrame(SEXP s) { SEXP klass; int i; @@ -901,6 +901,9 @@ INLINE_FUN Rboolean isFrame(SEXP s) } return FALSE; } +/* keep available under old name for now */ +INLINE_FUN Rboolean isFrame(SEXP s) { return isDataFrame(s); } + /* DIFFERENT than R's is.language(.) in ../main/coerce.c [do_is(), case 301:] * which is <=> SYMSXP || LANGSXP || EXPRSXP */ diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index 90691a89e52..5a8839e6835 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -936,6 +936,7 @@ void R_orderVector1(int *indx, int n, SEXP x, Rboolean nalast, Rboolean de #define isArray Rf_isArray #define isBasicClass Rf_isBasicClass #define isComplex Rf_isComplex +#define isDataFrame Rf_isDataFrame #define isEnvironment Rf_isEnvironment #define isExpression Rf_isExpression #define isFactor Rf_isFactor @@ -1060,6 +1061,7 @@ Rboolean Rf_conformable(SEXP, SEXP); SEXP Rf_elt(SEXP, int); Rboolean Rf_inherits(SEXP, const char *); Rboolean Rf_isArray(SEXP); +Rboolean Rf_isDataFrame(SEXP); Rboolean Rf_isFactor(SEXP); Rboolean Rf_isFrame(SEXP); Rboolean Rf_isFunction(SEXP); diff --git a/src/library/stats/src/model.c b/src/library/stats/src/model.c index 6ef57808e5c..bf76dd5bc99 100644 --- a/src/library/stats/src/model.c +++ b/src/library/stats/src/model.c @@ -1794,7 +1794,7 @@ SEXP termsform(SEXP args) a = CDR(a); if (isNull(data) || isEnvironment(data)) framenames = R_NilValue; - else if (isFrame(data)) + else if (isDataFrame(data)) framenames = getAttrib(data, R_NamesSymbol); else error(_("'data' argument is of the wrong type")); diff --git a/src/main/coerce.c b/src/main/coerce.c index 7a40ac77687..532755f5c8a 100644 --- a/src/main/coerce.c +++ b/src/main/coerce.c @@ -2067,7 +2067,7 @@ attribute_hidden SEXP do_is(SEXP call, SEXP op, SEXP args, SEXP rho) break; /* no longer used: is.data.frame is R code case 80: - LOGICAL0(ans)[0] = isFrame(CAR(args)); + LOGICAL0(ans)[0] = isDataFrame(CAR(args)); break; */ diff --git a/src/main/print.c b/src/main/print.c index e37a86eb527..1ad62cc207f 100644 --- a/src/main/print.c +++ b/src/main/print.c @@ -1028,7 +1028,7 @@ static void printAttributes(SEXP s, R_PrintData *data, Rboolean useSlots) if(TAG(a) == R_ClassSymbol) goto nextattr; } - if(isFrame(s)) { + if(isDataFrame(s)) { if(TAG(a) == R_RowNamesSymbol) goto nextattr; } diff --git a/src/main/util.c b/src/main/util.c index 987f4e2386a..541be12a4f0 100644 --- a/src/main/util.c +++ b/src/main/util.c @@ -80,7 +80,7 @@ int nrows(SEXP s) // ~== NROW(.) in R if (t == R_NilValue) return LENGTH(s); return INTEGER(t)[0]; } - else if (isFrame(s)) { + else if (isDataFrame(s)) { return nrows(CAR(s)); } else error(_("object is not a matrix")); @@ -98,7 +98,7 @@ int ncols(SEXP s) // ~== NCOL(.) in R /* This is a 1D (or possibly 0D array) */ return 1; } - else if (isFrame(s)) { + else if (isDataFrame(s)) { return length(s); } else error(_("object is not a matrix")); @@ -539,7 +539,7 @@ attribute_hidden void Rf_check1arg(SEXP arg, SEXP call, const char *formal) SEXP nthcdr(SEXP s, int n) { - if (isList(s) || isLanguage(s) || isFrame(s) || TYPEOF(s) == DOTSXP ) { + if (isList(s) || isLanguage(s) || isDataFrame(s) || TYPEOF(s) == DOTSXP ) { while( n-- > 0 ) { if (s == R_NilValue) error(_("'nthcdr' list shorter than %d"), n); From c61231a748cf7b8f0fabbe217d60b417cde9c2dd Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 7 Jun 2024 19:06:27 +0000 Subject: [PATCH 186/546] Mark GetOption1 and mkNamed as @apifun. git-svn-id: https://svn.r-project.org/R/trunk@86703 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 76aeef993dd..e4cc6587ed3 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -12938,11 +12938,11 @@ need to add a symbol for it @emph{via} a call to @example @group - SEXP version; - version = PROTECT(allocVector(REALSXP, 1)); - REAL(version)[0] = 3.0; - setAttrib(ans, install("version"), version); - UNPROTECT(1); +SEXP version; +version = PROTECT(allocVector(REALSXP, 1)); +REAL(version)[0] = 3.0; +setAttrib(ans, install("version"), version); +UNPROTECT(1); @end group @end example @@ -12954,7 +12954,7 @@ consider code such as @example static SEXP VerSymbol = NULL; ... - if (VerSymbol == NULL) VerSymbol = install("version"); +if (VerSymbol == NULL) VerSymbol = install("version"); @end example @noindent @@ -12964,12 +12964,23 @@ This example can be simplified by another convenience function: @example @group - SEXP version = PROTECT(ScalarReal(3.0)); - setAttrib(ans, install("version"), version); - UNPROTECT(1); +SEXP version = PROTECT(ScalarReal(3.0)); +setAttrib(ans, install("version"), version); +UNPROTECT(1); @end group @end example +If a result is to be a vector with all elements named, then +@code{mkNamed} can be used to allocate a vector of a specified type. +Names are provided as a C vector of strings terminated by an empty +string: +@example +@group +const char *nms[] = @{"xi", "yi", "zi", ""@}; +mkNamed(VECSXP, nms); +@end group +@end example +@apifun mkNamed @node Classes, Handling lists, Attributes, Handling R objects in C @subsection Classes @@ -13352,9 +13363,11 @@ Function @code{R_BindingIsLocked} corresponds to @R{}'s @code{bindingIsLocked} @eapifun R_unLockBinding The C functions @code{inherits} and @code{topenv} correspond to the @R{} -functions of the same name. +functions of the same name. The C function @code{GetOption1} corresponds +to the @R{} function @code{getOption} without specifying a default. @apifun inherits @apifun topenv +@apifun GetOption1 Some convenience functions for working with pairlist objects include @code{copyListMatrix}, @code{VectorToPairList}, and From aaeec31ab399225688245d9bd20266218b59b32d Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 7 Jun 2024 19:39:06 +0000 Subject: [PATCH 187/546] Add section on S4 objects and makr some functions for those as @eapifun. git-svn-id: https://svn.r-project.org/R/trunk@86704 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index e4cc6587ed3..bb55a127d45 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -12982,7 +12982,7 @@ mkNamed(VECSXP, nms); @end example @apifun mkNamed -@node Classes, Handling lists, Attributes, Handling R objects in C +@node Classes, S4 objects, Attributes, Handling R objects in C @subsection Classes @cindex Classes @@ -13013,6 +13013,35 @@ As the value is a character vector, we have to know how to create that from a C character array, which we do using the function @code{mkChar}. +@node S4 objects, Handling lists, Classes, Handling R objects in C +@subsection S4 objects +@cindex S4 objects + +Several functions are available for working with S4 objects and classes +in C, including: + +@comment FIXME: this needs fleshing out +@example +SEXP allocS4Object(void); +SEXP asS4(SEXP, Rboolean, int); +int R_check_class_etc(SEXP x, const char **valid); +SEXP R_do_MAKE_CLASS(const char *what); +SEXP R_do_new_object(SEXP class_def); +SEXP R_do_slot(SEXP obj, SEXP name); +SEXP R_do_slot_assign(SEXP obj, SEXP name, SEXP value); +SEXP R_getClassDef (const char *what); +int R_has_slot(SEXP obj, SEXP name); +@end example +@eapifun allocS4Object +@eapifun asS4 +@eapifun R_check_class_etc +@eapifun R_do_MAKE_CLASS +@eapifun R_do_new_object +@eapifun R_do_slot +@eapifun R_do_slot_assign +@eapifun R_getClassDef +@eapifun R_has_slot + @node Handling lists, Handling character data, Classes, Handling R objects in C @subsection Handling lists @cindex Handling lists From 3fc39f8ea82bd0938f5102508f16f78ab93babdf Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 8 Jun 2024 11:48:57 +0000 Subject: [PATCH 188/546] allocSExp now returns R_NilValue for a NILSXP request. git-svn-id: https://svn.r-project.org/R/trunk@86705 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/memory.c b/src/main/memory.c index 47e295b731e..14df1f14c20 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -2435,6 +2435,9 @@ void *R_realloc_gc(void *p, size_t n) SEXP allocSExp(SEXPTYPE t) { + if (t == NILSXP) + /* R_NilValue should be the only NILSXP object */ + return R_NilValue; SEXP s; if (FORCE_GC || NO_FREE_NODES()) { R_gc_internal(0); From 63aa103ad42eb891e0c2b67821b02b43ef704f6b Mon Sep 17 00:00:00 2001 From: maechler Date: Sat, 8 Jun 2024 16:45:15 +0000 Subject: [PATCH 189/546] graphics :: grid() gains `nintLog` option git-svn-id: https://svn.r-project.org/R/trunk@86706 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 +++- src/library/graphics/R/grid.R | 14 ++++++++------ src/library/graphics/man/grid.Rd | 17 ++++++++++++++++- tests/Examples/graphics-Ex.Rout.save | 21 +++++++++++++++++++-- 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 8f2c407299c..6c0ca605594 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -16,7 +16,9 @@ \itemize{ \item \code{as.integer(rl)} and hence \code{as.raw(rl)} now work for a \code{list} of \code{raw(1)} elements, as proposed by \I{Michael - Chirico}'s \PR{18696}. + Chirico}'s \PR{18696}. + + \item \pkg{graphics}' \code{grid()} gains optional argument \code{nintLog}. } } diff --git a/src/library/graphics/R/grid.R b/src/library/graphics/R/grid.R index 8ae64a00850..4c2e64c9f7d 100644 --- a/src/library/graphics/R/grid.R +++ b/src/library/graphics/R/grid.R @@ -1,7 +1,7 @@ # File src/library/graphics/R/grid.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2023 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,12 +16,12 @@ # A copy of the GNU General Public License is available at # https://www.R-project.org/Licenses/ -.grid.at <- function(side, n, log, equilogs, axp, usr2) { +.grid.at <- function(side, n, log, equilogs, axp, usr2, nintLog = NULL) { ## return 'at' if(is.null(n)) { ## align to tickmarks stopifnot(is.numeric(ax <- axp), length(ax) == 3L) if(log && equilogs && ax[3L] > 0) ax[3L] <- 1 - axTicks(side, axp = ax, usr=usr2, log=log) + axTicks(side, axp = ax, usr=usr2, log=log, nintLog = nintLog) } else if(!is.na(n) && (n <- as.integer(n)) >= 1L) { # equidistant, also from box borders at <- seq.int(usr2[1L], usr2[2L], length.out = n+1L) (if(log) 10^at else at)[-c(1L,n+1L)] @@ -29,13 +29,15 @@ } grid <- function (nx = NULL, ny = nx, col="lightgray", lty="dotted", - lwd = par("lwd"), equilogs = TRUE) + lwd = par("lwd"), equilogs = TRUE, nintLog = NULL) { atx <- if(is.null(nx) || (!is.na(nx) && nx >= 1)) - .grid.at(1L, nx, log = par("xlog"), equilogs, axp = par("xaxp"), usr2 = par("usr")[1:2]) + .grid.at(1L, nx, log = par("xlog"), equilogs, axp = par("xaxp"), usr2 = par("usr")[1:2], + nintLog = nintLog[1]) ## else NULL aty <- if(is.null(ny) || (!is.na(ny) && ny >= 1)) - .grid.at(2L, ny, log = par("ylog"), equilogs, axp = par("yaxp"), usr2 = par("usr")[3:4]) + .grid.at(2L, ny, log = par("ylog"), equilogs, axp = par("yaxp"), usr2 = par("usr")[3:4], + nintLog = nintLog[min(2L, length(nintLog))]) abline(v = atx, h = aty, col = col, lty = lty, lwd = lwd) invisible(list(atx = atx, aty = aty)) } diff --git a/src/library/graphics/man/grid.Rd b/src/library/graphics/man/grid.Rd index a2453050be1..30d85e6a565 100644 --- a/src/library/graphics/man/grid.Rd +++ b/src/library/graphics/man/grid.Rd @@ -12,7 +12,7 @@ } \usage{ grid(nx = NULL, ny = nx, col = "lightgray", lty = "dotted", - lwd = par("lwd"), equilogs = TRUE) + lwd = par("lwd"), equilogs = TRUE, nintLog = NULL) } \arguments{ \item{nx, ny}{number of cells of the grid in x and y direction. When @@ -27,6 +27,9 @@ grid(nx = NULL, ny = nx, col = "lightgray", lty = "dotted", alignment with the axis tick marks are active. Setting \code{equilogs = FALSE} in that case gives \emph{non equidistant} tick aligned grid lines.} + \item{nintLog}{one or two integers (or \code{NULL}), passed to + \code{\link{axTicks}()} when \code{nx} or \code{ny} are to be + determined; effective only with log coordinates.} } \value{ A list of the x (\code{"atx"}) and y (\code{"aty"}) coordinates at @@ -72,5 +75,17 @@ plot(8:270, log="xy") ; grid() # at (1, 10, 100); if preferring "all" grid lines plot(8:270, log="xy") ; grid(equilogs = FALSE) -> grll stopifnot(identical(grll, list(atx = c(1, 2, 5, 10, 20, 50, 100, 200), aty = c( 10, 20, 50, 100, 200)))) + +x <- 2^(-9:70) +plot(log(x) ~ x, log="xy") +grll <- grid(equilogs = FALSE, col = adjustcolor("green", 1/3)) +gr20 <- grid(nintLog = 20) +gr25 <- grid(nintLog = 25, col="thistle") +str(gr25) +stopifnot(exprs = { + grll$aty == c(1, 2, 5, 10, 20, 50) + length(gr20$atx) >= 20 # 24 effectively + all.equal(10^(-3:22), gr25$atx, tol = 1e-15) # even tol = 0 +}) } \keyword{aplot} diff --git a/tests/Examples/graphics-Ex.Rout.save b/tests/Examples/graphics-Ex.Rout.save index 4d6ac37a864..bd9acd71b58 100644 --- a/tests/Examples/graphics-Ex.Rout.save +++ b/tests/Examples/graphics-Ex.Rout.save @@ -1,6 +1,6 @@ -R Under development (unstable) (2023-09-08 r85109) -- "Unsuffered Consequences" -Copyright (C) 2023 The R Foundation for Statistical Computing +R Under development (unstable) (2024-06-08 r86705) -- "Unsuffered Consequences" +Copyright (C) 2024 The R Foundation for Statistical Computing Platform: aarch64-apple-darwin22.6.0 R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -1077,6 +1077,23 @@ List of 2 > stopifnot(identical(grll, list(atx = c(1, 2, 5, 10, 20, 50, 100, 200), + aty = c( 10, 20, 50, 100, 200)))) > +> x <- 2^(-9:70) +> plot(log(x) ~ x, log="xy") +Warning in xy.coords(x, y, xlabel, ylabel, log) : + 10 y values <= 0 omitted from logarithmic plot +> grll <- grid(equilogs = FALSE, col = adjustcolor("green", 1/3)) +> gr20 <- grid(nintLog = 20) +> gr25 <- grid(nintLog = 25, col="thistle") +> str(gr25) +List of 2 + $ atx: num [1:26] 1e-03 1e-02 1e-01 1e+00 1e+01 1e+02 1e+03 1e+04 1e+05 1e+06 ... + $ aty: num [1:2] 1 10 +> stopifnot(exprs = { ++ grll$aty == c(1, 2, 5, 10, 20, 50) ++ length(gr20$atx) >= 20 # 24 effectively ++ all.equal(10^(-3:22), gr25$atx, tol = 1e-15) # even tol = 0 ++ }) +> > > > graphics::par(get("par.postscript", pos = 'CheckExEnv')) From e149c25deb62e21e61370c0da6c58bf4c0ed3124 Mon Sep 17 00:00:00 2001 From: hornik Date: Sat, 8 Jun 2024 17:50:12 +0000 Subject: [PATCH 190/546] Note missing stage23 partal Rd db. git-svn-id: https://svn.r-project.org/R/trunk@86707 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index f7fc97757d7..2dec71a3533 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -7565,7 +7565,7 @@ function(dir, localOnly = FALSE, pkgSize = NA) if(length(containsBuildSexprs)) { built_file <- file.path(dir, "build", "partial.rdb") if(!file.exists(built_file)) - out$missing_manual_rdb <- TRUE + out$missing_partial_rdb <- TRUE else { ## Merge in the partial db: there could be build Sexprs ## giving install/render Sexprs ... @@ -7574,12 +7574,19 @@ function(dir, localOnly = FALSE, pkgSize = NA) Rdb[pos > 0L] <- built[pos] } } - needRefMan <- + containsLaterSexprs <- any(vapply(Rdb, function(Rd) any(.Rd_get_Sexpr_build_time_info(Rd)["later"]), NA)) - if(needRefMan && + if(containsLaterSexprs && + !file.exists(file.path(dir, "build", "stage23.rdb"))) + out$missing_stage23_rdb <- TRUE + ## (Could checks whether this really contain all possibly unsafe + ## install/render Sexprs.) + if(containsLaterSexprs && + config_val_to_logical(Sys.getenv("_R_CHECK_NOTE_MISSING_MANUAL_PDF", + "FALSE")) && !file.exists(file.path(dir, "build", paste0( meta[["Package"]], ".pdf")))) out$missing_manual_pdf <- TRUE @@ -8752,11 +8759,17 @@ function(x, ...) paste0(" ", y)), collapse = "\n") }, - fmt(c(if(length(y <- x$missing_manual_rdb)) { - "Package has help file(s) containing build-stage \\Sexpr{} expressions but no 'build/partial.rdb' file." + fmt(c(if(length(y <- x$missing_partial_rdb)) { + paste(strwrap("Package has help file(s) containing build-stage \\Sexpr{} expressions but no 'build/partial.rdb' file."), + collapse = "\n") + }, + if(length(y <- x$missing_stage23_rdb)) { + paste(strwrap("Package has help file(s) containing later-stage \\Sexpr{} expressions but no 'build/stage23.rdb' file."), + collapse = "\n") }, if(length(y <- x$missing_manual_pdf)) { - "Package has help file(s) containing install/render-stage \\Sexpr{} expressions but no prebuilt PDF manual." + paste(strwrap("Package has help file(s) containing install/render-stage \\Sexpr{} expressions but no prebuilt PDF manual."), + collapse = "\n") })), fmt(c(if(length(y <- x$dotjava)) { "Package installs .java files." From dc3764bd1e53ccb5684f04269d3dedaf0f5a510d Mon Sep 17 00:00:00 2001 From: hornik Date: Sat, 8 Jun 2024 17:50:59 +0000 Subject: [PATCH 191/546] Add as.data.frame() method for citation objects. git-svn-id: https://svn.r-project.org/R/trunk@86708 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/NAMESPACE | 1 + src/library/utils/R/citation.R | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/library/utils/NAMESPACE b/src/library/utils/NAMESPACE index ae2dcfc9a0c..5da0335a632 100644 --- a/src/library/utils/NAMESPACE +++ b/src/library/utils/NAMESPACE @@ -148,6 +148,7 @@ S3method("[", "person") S3method("[[", "bibentry") S3method("[[", "person") S3method("as.data.frame", "bibentry") +S3method("as.data.frame", "citation") S3method("as.data.frame", "person") S3method("c", "bibentry") S3method("c", "person") diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index ab94b4bc887..edf11d68f74 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -1525,9 +1525,17 @@ function(x) } format.citation <- -function(x, style = "citation", ...) format.bibentry(x, style = style, ...) +function(x, style = "citation", ...) + format.bibentry(x, style = style, ...) print.citation <- -function(x, style = "citation", ...) print.bibentry(x, style = style, ...) +function(x, style = "citation", ...) + print.bibentry(x, style = style, ...) + +as.data.frame.citation <- +function(x, row.names = NULL, optional = FALSE, ...) { + x <- as.bibentry(x) + NextMethod() +} as.bibentry <- function(x) From a3508b75d28164b0e5bcb2c87f816ce5169729a4 Mon Sep 17 00:00:00 2001 From: maechler Date: Sat, 8 Jun 2024 18:18:07 +0000 Subject: [PATCH 192/546] add SparseM nonS3methods() {no longer need ugly "workaround" there} git-svn-id: https://svn.r-project.org/R/trunk@86709 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/utils.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index ec0a57a5dc7..6a02ca91964 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -1922,6 +1922,8 @@ nonS3methods <- function(package) "dim.rename.nc", "open.nc", "print.nc"), Rmpfr = c("mpfr.is.0", "mpfr.is.integer"), SMPracticals = "exp.gibbs", + SparseM = c("as.matrix.csc","as.matrix.csr", "as.matrix.ssc", "as.matrix.ssr", "as.matrix.coo", + "is.matrix.csc","is.matrix.csr", "is.matrix.ssc", "is.matrix.ssr", "is.matrix.coo"), TANOVA = "sigma.hat", TeachingDemos = "sigma.test", XML = "text.SAX", From 3133ec359ef3b7af21fa389b16fc0b503db5e53b Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 9 Jun 2024 08:57:03 +0000 Subject: [PATCH 193/546] Document and export check_package_urls() and check_package_dois(). git-svn-id: https://svn.r-project.org/R/trunk@86710 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 7 +++++- src/library/tools/NAMESPACE | 3 +++ src/library/tools/man/doitools.Rd | 35 +++++++++++++++++++++++++++ src/library/tools/man/urltools.Rd | 40 +++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 src/library/tools/man/doitools.Rd create mode 100644 src/library/tools/man/urltools.Rd diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 6c0ca605594..ae863b80624 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -18,7 +18,12 @@ a \code{list} of \code{raw(1)} elements, as proposed by \I{Michael Chirico}'s \PR{18696}. - \item \pkg{graphics}' \code{grid()} gains optional argument \code{nintLog}. + \item \pkg{graphics}' \code{grid()} gains optional argument + \code{nintLog}. + + \item New functions \code{check_package_urls()} and + \code{check_package_dois()} in package \pkg{tools} for checking + URLs and DOIs in package sources. } } diff --git a/src/library/tools/NAMESPACE b/src/library/tools/NAMESPACE index c404ce759c5..2e3d71666eb 100644 --- a/src/library/tools/NAMESPACE +++ b/src/library/tools/NAMESPACE @@ -58,6 +58,9 @@ export("R_user_dir") export(".print.via.format") +export("check_package_urls", + "check_package_dois") + exportPattern("^SIG.+") S3method("[", "check_details_changes") diff --git a/src/library/tools/man/doitools.Rd b/src/library/tools/man/doitools.Rd new file mode 100644 index 00000000000..c2b6b241c55 --- /dev/null +++ b/src/library/tools/man/doitools.Rd @@ -0,0 +1,35 @@ +\name{doitools} +\alias{check_package_dois} +\title{Check Package DOIs} +\description{ + Check DOIs in package sources. +} +\usage{ +check_package_dois(dir, verbose = FALSE) +} +\arguments{ + \item{dir}{a character string specifying the path to a package's root + source directory.} + \item{verbose}{a logical indicating if output should monitor check + progress.} +} +\details{ + Checking DOIs is performed in parallel using \CRANpkg{curl} (so this + must be installed for checking). + + The DOIs checked are extracted from the package \file{DESCRIPTION} + (\samp{} URIs in the \samp{Description} field), Rd and + \file{CITATION} files. + + The DOIs are checked via \samp{HEAD} requests to the DOI system Proxy + Server REST API. +} +\value{ + A data frame inheriting from class \code{check_doi_db} with + information on the DOI check problems found. +} +\note{ + This functionality is still experimental: interfaces may change in + future versions. +} +\keyword{utilities} diff --git a/src/library/tools/man/urltools.Rd b/src/library/tools/man/urltools.Rd new file mode 100644 index 00000000000..2646e8979e3 --- /dev/null +++ b/src/library/tools/man/urltools.Rd @@ -0,0 +1,40 @@ +\name{urltools} +\alias{check_package_urls} +\title{Check Package URLs} +\description{ + Check URLs in package sources. +} +\usage{ +check_package_urls(dir, verbose = FALSE) +} +\arguments{ + \item{dir}{a character string specifying the path to a package's root + source directory.} + \item{verbose}{a logical indicating if output should monitor check + progress.} +} +\details{ + Checking URLs is performed in parallel using \CRANpkg{curl} (so this + must be installed for checking). + + The URLs checked are extracted from the package \file{DESCRIPTION} + (\samp{Description}, \samp{URL} and \samp{BugReports} fields), Rd, + \file{CITATION} and \file{NEWS.md} files, if package \CRANpkg{xml2} is + installed also from the \file{.html} files in \file{inst/doc}, and if + additionally \command{pandoc} is available on the system the + \file{README.md} and \file{NEWS.md} files. + + For efficiency reasons, URLs are first checked using \samp{HEAD} + requests, and the ones with non-OK (200) status codes re-checked via + \samp{GET} requests (unfortunately, \samp{HEAD} requests are not + always honored appropriately). +} +\value{ + A data frame inheriting from class \code{check_url_db} with + information on the URL check problems found. +} +\note{ + This functionality is still experimental: interfaces may change in + future versions. +} +\keyword{utilities} From 4d81523e55d868685448325e07397e844dc114e0 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 9 Jun 2024 10:46:51 +0000 Subject: [PATCH 194/546] Re-fetch in parallel when fetching in parallel. git-svn-id: https://svn.r-project.org/R/trunk@86711 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/urltools.R | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/library/tools/R/urltools.R b/src/library/tools/R/urltools.R index 9781d6fc036..1da0cb43cfc 100644 --- a/src/library/tools/R/urltools.R +++ b/src/library/tools/R/urltools.R @@ -1,7 +1,7 @@ # File src/library/tools/R/urltools.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 2015-2023 The R Core Team +# Copyright (C) 2015-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -529,7 +529,7 @@ function(db, remote = TRUE, verbose = FALSE, parallel = FALSE, pool = NULL) } } ## - if((s != "200") && (use_curl || parallel)) { + if((s != "200") && use_curl) { g <- .curl_fetch_memory_status_code(u) if(g == "200") { s <- g @@ -663,6 +663,22 @@ function(db, remote = TRUE, verbose = FALSE, parallel = FALSE, pool = NULL) ## sub(pat, "\\2", urlspos[ind])) ## but using the parts is considerably faster ... headers <- .fetch_headers(urlspos) + if(parallel && + any(ind <- vapply(headers, + function(e) { + if(inherits(e, "error")) -1L + else attr(e, "status") + }, + 0L) != 200)) { + ## We also re-check non-200 results in .check_http_A(). + ## Not very useful the way we currently show progress: + ## if(verbose) + ## message(sprintf("found %d non-OK responses, re-fetching ...", + ## sum(ind))) + headers[ind] <- + .fetch_headers_via_curl(urlspos[ind], + verbose, pool, FALSE) + } results <- do.call(rbind, Map(.check_http, urlspos, headers)) status <- as.numeric(results[, 1L]) ## 405 is HTTP not allowing HEAD requests @@ -777,9 +793,9 @@ function(urls, verbose = FALSE, ids = urls) urls, verbose, ids) .fetch_headers_via_curl <- -function(urls, verbose = FALSE, pool = NULL) +function(urls, verbose = FALSE, pool = NULL, nobody = TRUE) { - out <- .curl_multi_run_worker(urls, TRUE, verbose, pool) + out <- .curl_multi_run_worker(urls, nobody, verbose, pool) ind <- !vapply(out, inherits, NA, "error") if(any(ind)) out[ind] <- lapply(out[ind], @@ -815,9 +831,11 @@ function(urls, nobody = FALSE, verbose = FALSE, pool = NULL, return() } if (done >= length) { - cat("\r", strrep(" ", nchar(fmt)), "\r", sep = "") + cat("\r", strrep(" ", nchar(fmt)), "\r", sep = "", + file = stderr()) } else { - cat(sprintf(fmt, done, length), sep = "") + cat(sprintf(fmt, done, length), sep = "", + file = stderr()) } } environment(bar$update) <- bar From c296e25f99bfb9b3c4ceaa6c03c70ac9b91fa02a Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 9 Jun 2024 12:57:34 +0000 Subject: [PATCH 195/546] Add R_mkClosure and mark as @apifun. git-svn-id: https://svn.r-project.org/R/trunk@86712 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 5 +++++ doc/manual/R-exts.texi | 16 ++++++++++++++-- src/include/Rinternals.h | 1 + src/main/dstruct.c | 9 +++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index ae863b80624..82d3d93e76a 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -86,6 +86,11 @@ \code{SET_TYPE} in package C code should be avoided and may be deprecated in the near future. It is better to allocate an object of the proper type in the first place. + + \item New API function \code{R_mkClosure}. This checks that its + arguments are valid and should be used instead of + \code{allocSExp(CLOSXP} followed by \code{SET_FORMALS}, + \code{SET_BODY}, and \code{SET_CLOENV}. } } diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index bb55a127d45..f0436794c76 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -12503,7 +12503,9 @@ right type. * Attributes:: * Classes:: * Handling lists:: +* S4 objects:: * Handling character data:: +* Working with closures:: * Finding and setting variables:: * Some convenience functions:: * Named objects and copying:: @@ -13105,7 +13107,7 @@ and enables us to say @end group @end example -@node Handling character data, Finding and setting variables, Handling lists, Handling R objects in C +@node Handling character data, Working with closures, Handling lists, Handling R objects in C @subsection Handling character data @cindex handling character data @@ -13139,7 +13141,17 @@ Note that @R{} character strings are restricted to @code{2^31 - 1} bytes, and hence so should the input to @code{mkChar} be (C allows longer strings on 64-bit platforms). -@node Finding and setting variables, Some convenience functions, Handling character data, Handling R objects in C +@node Working with closures, Finding and setting variables, Handling character data, Handling R objects in C +@subsection Working with closures +@cindex Working with closures + +New function closure objects can be created with @code{R_mkClosure}: +@example +SEXP R_mkClosure(SEXP formals, SEXP body, SEXP rho); +@end example +@apifun R_mkClosure + +@node Finding and setting variables, Some convenience functions, Working with closures, Handling R objects in C @subsection Finding and setting variables @cindex Finding variables @cindex Setting variables diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index 5a8839e6835..ba45fff94c4 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -349,6 +349,7 @@ void (SET_RTRACE)(SEXP x, int v); void SET_FORMALS(SEXP x, SEXP v); void SET_BODY(SEXP x, SEXP v); void SET_CLOENV(SEXP x, SEXP v); +SEXP R_mkClosure(SEXP, SEXP, SEXP); /* Symbol Access Functions */ SEXP (PRINTNAME)(SEXP x); diff --git a/src/main/dstruct.c b/src/main/dstruct.c index e4501a3bbcb..e926d039b48 100644 --- a/src/main/dstruct.c +++ b/src/main/dstruct.c @@ -112,6 +112,15 @@ attribute_hidden SEXP mkCLOSXP(SEXP formals, SEXP body, SEXP rho) return c; } +/* version for the API with more checking */ +SEXP R_mkClosure(SEXP formals, SEXP body, SEXP rho) +{ + CheckFormals(formals, "R_mkClosure"); + if (! isEnvironment(rho)) + error(_("invalid environment")); + return mkCLOSXP(formals, body, rho); +} + /* mkChar - make a character (CHARSXP) variable -- see Rinlinedfuns.h */ /* mkSYMSXP - return a symsxp with the string */ From 9d62b953eeed3258dd1e08ba5f914ac66b99bba1 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 9 Jun 2024 18:14:12 +0000 Subject: [PATCH 196/546] New API functions R_ClosureFormals, R_ClosureBody, and R_ClosureEnv. Also add R_ClosureExpr and R_BytecodeExpr to the API. git-svn-id: https://svn.r-project.org/R/trunk@86713 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 5 +++++ doc/manual/R-exts.texi | 11 +++++++++++ src/include/Rinternals.h | 3 +++ src/main/memory.c | 5 +++++ 4 files changed, 24 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 82d3d93e76a..e008bf42971 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -91,6 +91,11 @@ arguments are valid and should be used instead of \code{allocSExp(CLOSXP} followed by \code{SET_FORMALS}, \code{SET_BODY}, and \code{SET_CLOENV}. + + \item New API functions \code{R_ClosureFormals}, + \code{R_ClosureBody}, and \code{R_ClosureEnv} for extrancting + closure components. The existing functions \code{R_ClosureExpr} + and \code{R_BytecodeExpr} have also been added to the API. } } diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index f0436794c76..d59e8fe1104 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13150,6 +13150,17 @@ New function closure objects can be created with @code{R_mkClosure}: SEXP R_mkClosure(SEXP formals, SEXP body, SEXP rho); @end example @apifun R_mkClosure +The components of a closure can be extracted with +@code{R_ClosureFormals}, @code{R_ClosureBody}, and @code{R_ClosureEnv}. +For a byte compiled closure @code{R_ClosureBody} returns the compiled +body. @code{R_ClosureExpr} returns the body expression for both +compiled and uncompiled closures. The expression for a compiled object +can be obtained with @code{R_BytecodeExpr}. +@apifun R_ClosureFormals +@apifun R_ClosureBody +@apifun R_ClosureEnv +@apifun R_ClosureExpr +@apifun R_BytecodeExpr @node Finding and setting variables, Some convenience functions, Working with closures, Handling R objects in C @subsection Finding and setting variables diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index ba45fff94c4..1e614254764 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -350,6 +350,9 @@ void SET_FORMALS(SEXP x, SEXP v); void SET_BODY(SEXP x, SEXP v); void SET_CLOENV(SEXP x, SEXP v); SEXP R_mkClosure(SEXP, SEXP, SEXP); +SEXP R_ClosureFormals(SEXP); +SEXP R_ClosureBody(SEXP); +SEXP R_ClosureEnv(SEXP); /* Symbol Access Functions */ SEXP (PRINTNAME)(SEXP x); diff --git a/src/main/memory.c b/src/main/memory.c index 14df1f14c20..ed305c9c31f 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4550,6 +4550,11 @@ SEXP (BODY)(SEXP x) { return CHK(BODY(CHK(x))); } SEXP (CLOENV)(SEXP x) { return CHK(CLOENV(CHK(x))); } int (RDEBUG)(SEXP x) { return RDEBUG(CHK(x)); } attribute_hidden int (RSTEP)(SEXP x) { return RSTEP(CHK(x)); } +#define CHKCLOSXP(x) \ + if (TYPEOF(x) != CLOSXP) error(_("argument is not a closure")) +SEXP R_ClosureFormals(SEXP x) { CHKCLOSXP(x); return (FORMALS)(x); } +SEXP R_ClosureBody(SEXP x) { CHKCLOSXP(x); return (BODY)(x); } +SEXP R_ClosureEnv(SEXP x) { CHKCLOSXP(x); return (CLOENV)(x); } void (SET_FORMALS)(SEXP x, SEXP v) { FIX_REFCNT(x, FORMALS(x), v); CHECK_OLD_TO_NEW(x, v); FORMALS(x) = v; } void (SET_BODY)(SEXP x, SEXP v) { FIX_REFCNT(x, BODY(x), v); CHECK_OLD_TO_NEW(x, v); BODY(x) = v; } From 6864cffdb6bc961354a1945295a414f12584b3b9 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 10 Jun 2024 06:59:02 +0000 Subject: [PATCH 197/546] Drop cran.ism.ac.jp. git-svn-id: https://svn.r-project.org/R/trunk@86714 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index 182792f7f2b..89cc5e4c16c 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -60,7 +60,6 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Iran (Mashhad) [https]",Iran,Mashhad,https://cran.um.ac.ir/,"Ferdowsi University of Mashhad","Majid Sarmad ",1,ir,"secure_mirror_from_master" "Italy (Milano) [https]",Italy,Milano,https://cran.mirror.garr.it/CRAN/,"Garr Mirror, Milano","mirror-service # garr.it",1,it,"secure_mirror_from_master" "Italy (Padua) [https]",Italy,Padua,https://cran.stat.unipd.it/,"University of Padua","cran # stat.unipd.it",1,it,"secure_mirror_from_master" -"Japan (Tokyo) [https]",Japan,Tokyo,https://cran.ism.ac.jp/,"The Institute of Statistical Mathematics, Tokyo","Junji Nakano ",1,jp,"secure_mirror_from_master" "Japan (Yonezawa) [https]",Japan,Yonezawa,https://ftp.yz.yamagata-u.ac.jp/pub/cran/,"Yamagata University","www-admin # ftp.yz.yamagata-u.ac.jp",1,jp,"secure_mirror_from_master" "Korea (Gyeongsan-si) [https]",Korea,Gyeongsan-si,https://cran.yu.ac.kr/,"Yeungnam University","sysop # yu.ac.kr",1,kr,"secure_mirror_from_master" "Korea (Ulsan) [https]",Korea,Ulsan,https://cran.biodisk.org/,"The Genome Institute of UNIST (Ulsan National Institute of Science and Technology)","ldsrman # gmail.com",0,kr,"secure_mirror_from_master" From 480d693f8d15b9dbfa2ee214369f1e12bd0562fb Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 10 Jun 2024 21:31:24 +0000 Subject: [PATCH 198/546] Add R_ParentEnv as API version of ENCLOS. git-svn-id: https://svn.r-project.org/R/trunk@86715 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 2 ++ doc/manual/R-exts.texi | 2 ++ src/include/Rinternals.h | 1 + src/main/memory.c | 3 +++ 4 files changed, 8 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index e008bf42971..4366c6d274e 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -96,6 +96,8 @@ \code{R_ClosureBody}, and \code{R_ClosureEnv} for extrancting closure components. The existing functions \code{R_ClosureExpr} and \code{R_BytecodeExpr} have also been added to the API. + + \item New API function \code{R_ParentEnv}. } } diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index d59e8fe1104..30fcfdee7b5 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13405,6 +13405,8 @@ versions of @R{}'s @code{any(duplicated(.))}. Function @code{R_compute_identical} corresponds to @R{}'s @code{identical} function. @eapifun R_compute_identical Function @code{R_BindingIsLocked} corresponds to @R{}'s @code{bindingIsLocked} function. +Function @code{R_ParentEnv} corresponds to @R{}'1 @code{parent.env}. +@apifun R_ParentEnv @eapifun R_ActiveBindingFunction @eapifun R_BindingIsActive @eapifun R_BindingIsLocked diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index 1e614254764..c3e0049eac2 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -365,6 +365,7 @@ SEXP (FRAME)(SEXP x); SEXP (ENCLOS)(SEXP x); SEXP (HASHTAB)(SEXP x); int (ENVFLAGS)(SEXP x); +SEXP R_ParentEnv(SEXP); /* Promise Access Functions */ SEXP (PRCODE)(SEXP x); diff --git a/src/main/memory.c b/src/main/memory.c index ed305c9c31f..3710ae3ce30 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4604,6 +4604,9 @@ SEXP (FRAME)(SEXP x) { return CHK(FRAME(CHK(x))); } SEXP (ENCLOS)(SEXP x) { return CHK(ENCLOS(CHK(x))); } SEXP (HASHTAB)(SEXP x) { return CHK(HASHTAB(CHK(x))); } int (ENVFLAGS)(SEXP x) { return ENVFLAGS(CHK(x)); } +#define CHKENVSXP(x) \ + if (TYPEOF(x) != ENVSXP) error(_("argument is not an environment")) +SEXP R_ParentEnv(SEXP x) { CHKENVSXP(x); return (ENCLOS)(x); } void (SET_FRAME)(SEXP x, SEXP v) { FIX_REFCNT(x, FRAME(x), v); CHECK_OLD_TO_NEW(x, v); FRAME(x) = v; } From a524a48285c82253ea8c79a793593e1a047f37fd Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 10 Jun 2024 23:18:53 +0000 Subject: [PATCH 199/546] Add argument type checking to function versions of FORMALS, BODY, CLOENC, and ENCLOS. git-svn-id: https://svn.r-project.org/R/trunk@86716 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/memory.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/memory.c b/src/main/memory.c index 3710ae3ce30..868fc60b577 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4545,16 +4545,19 @@ attribute_hidden void (SET_MISSING)(SEXP x, int v) { SET_MISSING(CHKCONS(x), v); } /* Closure Accessors */ -SEXP (FORMALS)(SEXP x) { return CHK(FORMALS(CHK(x))); } -SEXP (BODY)(SEXP x) { return CHK(BODY(CHK(x))); } -SEXP (CLOENV)(SEXP x) { return CHK(CLOENV(CHK(x))); } +/* some internals seem to depend on allowing a LISTSXP */ +#define CHKCLOSXP(x) \ + if (TYPEOF(x) != CLOSXP && TYPEOF(x) != LISTSXP) \ + error(_("argument of type %s is not a closure"), \ + sexptype2char(TYPEOF(x))) +SEXP (FORMALS)(SEXP x) { CHKCLOSXP(x); return CHK(FORMALS(CHK(x))); } +SEXP (BODY)(SEXP x) { CHKCLOSXP(x); return CHK(BODY(CHK(x))); } +SEXP (CLOENV)(SEXP x) { CHKCLOSXP(x); return CHK(CLOENV(CHK(x))); } int (RDEBUG)(SEXP x) { return RDEBUG(CHK(x)); } attribute_hidden int (RSTEP)(SEXP x) { return RSTEP(CHK(x)); } -#define CHKCLOSXP(x) \ - if (TYPEOF(x) != CLOSXP) error(_("argument is not a closure")) -SEXP R_ClosureFormals(SEXP x) { CHKCLOSXP(x); return (FORMALS)(x); } -SEXP R_ClosureBody(SEXP x) { CHKCLOSXP(x); return (BODY)(x); } -SEXP R_ClosureEnv(SEXP x) { CHKCLOSXP(x); return (CLOENV)(x); } +SEXP R_ClosureFormals(SEXP x) { return (FORMALS)(x); } +SEXP R_ClosureBody(SEXP x) { return (BODY)(x); } +SEXP R_ClosureEnv(SEXP x) { return (CLOENV)(x); } void (SET_FORMALS)(SEXP x, SEXP v) { FIX_REFCNT(x, FORMALS(x), v); CHECK_OLD_TO_NEW(x, v); FORMALS(x) = v; } void (SET_BODY)(SEXP x, SEXP v) { FIX_REFCNT(x, BODY(x), v); CHECK_OLD_TO_NEW(x, v); BODY(x) = v; } @@ -4600,13 +4603,15 @@ void (SET_INTERNAL)(SEXP x, SEXP v) { attribute_hidden void (SET_DDVAL)(SEXP x, int v) { SET_DDVAL(CHK(x), v); } /* Environment Accessors */ -SEXP (FRAME)(SEXP x) { return CHK(FRAME(CHK(x))); } -SEXP (ENCLOS)(SEXP x) { return CHK(ENCLOS(CHK(x))); } -SEXP (HASHTAB)(SEXP x) { return CHK(HASHTAB(CHK(x))); } -int (ENVFLAGS)(SEXP x) { return ENVFLAGS(CHK(x)); } -#define CHKENVSXP(x) \ - if (TYPEOF(x) != ENVSXP) error(_("argument is not an environment")) -SEXP R_ParentEnv(SEXP x) { CHKENVSXP(x); return (ENCLOS)(x); } +/* looks line R_NilValue is still showing up in internals */ +#define CHKENVSXP(x) \ + if (TYPEOF(x) != ENVSXP && x != R_NilValue) \ + error(_("argument is not an environment or NULL")) +SEXP (FRAME)(SEXP x) { CHKENVSXP(x); return CHK(FRAME(CHK(x))); } +SEXP (ENCLOS)(SEXP x) { CHKENVSXP(x); return CHK(ENCLOS(CHK(x))); } +SEXP (HASHTAB)(SEXP x) { CHKENVSXP(x); return CHK(HASHTAB(CHK(x))); } +int (ENVFLAGS)(SEXP x) { CHKENVSXP(x); return ENVFLAGS(CHK(x)); } +SEXP R_ParentEnv(SEXP x) { return (ENCLOS)(x); } void (SET_FRAME)(SEXP x, SEXP v) { FIX_REFCNT(x, FRAME(x), v); CHECK_OLD_TO_NEW(x, v); FRAME(x) = v; } From 224b0b659e521df5d20c3eae1908582452fb4134 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 10 Jun 2024 23:23:58 +0000 Subject: [PATCH 200/546] Fix comment typo. git-svn-id: https://svn.r-project.org/R/trunk@86717 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/memory.c b/src/main/memory.c index 868fc60b577..36e28291775 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4603,7 +4603,7 @@ void (SET_INTERNAL)(SEXP x, SEXP v) { attribute_hidden void (SET_DDVAL)(SEXP x, int v) { SET_DDVAL(CHK(x), v); } /* Environment Accessors */ -/* looks line R_NilValue is still showing up in internals */ +/* looks like R_NilValue is still showing up in internals */ #define CHKENVSXP(x) \ if (TYPEOF(x) != ENVSXP && x != R_NilValue) \ error(_("argument is not an environment or NULL")) From 6aad84863583f05dbdbbab770c75dd46aa134262 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 11 Jun 2024 01:19:54 +0000 Subject: [PATCH 201/546] Added some more @apifun and @epifun designations. git-svn-id: https://svn.r-project.org/R/trunk@86718 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 30fcfdee7b5..371bf6dd198 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14600,10 +14600,13 @@ For example, the return type of @code{REAL_RO} is @code{const double *} @apifun COMPLEX_RO @apifun STRING_PTR_RO @apifun VECTOR_PTR_RO +@apifun DATAPTR_RO These accessor functions check that they are being used on an appropriate type of @code{SEXP}. For @code{VECSXP} and @code{STRSXP} objects only read-only pointers are available as modifying their data directly would violate assumptions the memory manager depends on. +@code{DATAPTR_RO} returns a generic read-only data pointer for any +vector object. Formerly it was possible for packages to obtain internal versions of some accessors by defining @samp{USE_RINTERNALS} before including @@ -14720,7 +14723,7 @@ query whether a data pointer is available. @deftypefunx {const double *} REAL_OR_NULL (SEXP @var{x}) @deftypefunx {const Rcomplex *} COMPLEX_OR_NULL (SEXP @var{x}) @deftypefunx {const Rbyte *} RAW_OR_NULL (SEXP @var{x}) -@comment @deftypefun {const void *} DATAPTR_OR_NULL (SEXP @var{x}) +@deftypefunx {const void *} DATAPTR_OR_NULL (SEXP @var{x}) These functions will return a data pointer if one is available. For vectors with a compact representation these functions will return @code{NULL}. @@ -14730,6 +14733,7 @@ vectors with a compact representation these functions will return @eapifun REAL_OR_NULL @eapifun COMPLEX_OR_NULL @eapifun RAW_OR_NULL +@eapifun DATAPTR_OR_NULL If a data pointer is not available, then code can access elements one at a time with functions like @code{REAL_ELT}. This is often sufficient, @@ -14769,6 +14773,32 @@ classes, beyond those defined in @file{R_ext/Altrep.h}, include @eapifun R_altrep_data2 @eapihdr R_ext/Altrep.h +For some objects it may be possible to very efficiently determine +whether the object is sorted or contains no @code{NA} values. These +functions can be used to query this information: + +@deftypefun int LOGICAL_NO_NA (SEXP @var{x}) +@deftypefunx int INTEGER_NO_NA (SEXP @var{x}) +@deftypefunx int REAL_NO_NA (SEXP @var{x}) +@deftypefunx int STRING_NO_NA (SEXP @var{x}) +A @code{TRUE} result means it is known that there are no @code{NA} +values. A @code{FALSE} result means it is not known whether there are +any @code{NA} values. +@end deftypefun +@eapifun LOGICAL_NO_NA +@eapifun INTEGER_NO_NA +@eapifun REAL_NO_NA +@eapifun STRING_NO_NA +@deftypefun int INTEGER_IS_SORTED (SEXP @var{x}) +@deftypefunx int REAL_IS_SORTED (SEXP @var{x}) +@deftypefunx int STRING_IS_SORTED (SEXP @var{x}) +These functions return one of @code{SORTED_DECR}, @code{SORTED_INCR}, or +@code{UNKNOWN_SORTEDNESS}. +@end deftypefun +@eapifun INTEGER_IS_SORTED +@eapifun REAL_IS_SORTED +@eapifun STRING_IS_SORTED + @node The R API, Generic functions and methods, System and foreign language interfaces, Top @chapter The R @acronym{API}: entry points for C code From e3fd11c1773facbb5d2d0ad388b8fb27531b3c5b Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 11 Jun 2024 01:21:56 +0000 Subject: [PATCH 202/546] Add promise check to r-unserialize. git-svn-id: https://svn.r-project.org/R/trunk@86719 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/serialize.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/serialize.c b/src/main/serialize.c index ea0205d4827..80b13d7d3b9 100644 --- a/src/main/serialize.c +++ b/src/main/serialize.c @@ -2234,6 +2234,7 @@ static void DecodeVersion(int packed, int *v, int *p, int *s) *s = packed; } +static SEXP checkNotPromise(SEXP); SEXP R_Unserialize(R_inpstream_t stream) { int version; @@ -2288,7 +2289,7 @@ SEXP R_Unserialize(R_inpstream_t stream) } UNPROTECT(1); - return obj; + return checkNotPromise(obj); } attribute_hidden SEXP R_SerializeInfo(R_inpstream_t stream) From e326f9d01fee427c5070229e17e3d302ff200091 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 11 Jun 2024 07:12:33 +0000 Subject: [PATCH 203/546] Improve URLs. git-svn-id: https://svn.r-project.org/R/trunk@86720 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/stats/man/smooth.spline.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/stats/man/smooth.spline.Rd b/src/library/stats/man/smooth.spline.Rd index 0690fa3109a..b2f42d7b5c9 100644 --- a/src/library/stats/man/smooth.spline.Rd +++ b/src/library/stats/man/smooth.spline.Rd @@ -272,7 +272,7 @@ smooth.spline(x, y = NULL, w = NULL, df, spar = NULL, lambda = NULL, cv = FALSE, \source{ This function is based on code in the \code{GAMFIT} Fortran program by T. Hastie and R. Tibshirani (originally taken from - \url{http://lib.stat.cmu.edu/general/gamfit}) + \url{https://lib.stat.cmu.edu/general/gamfit}) which makes use of spline code by Finbarr O'Sullivan. Its design parallels the \code{smooth.spline} function of Chambers & Hastie (1992). } From d2140f127613b71016567ca31b3483f0ae4f2f76 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 11 Jun 2024 07:13:02 +0000 Subject: [PATCH 204/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86721 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/utils.R | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index 6a02ca91964..0abc40a3a33 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -579,7 +579,7 @@ function(file, pdf = FALSE, clean = FALSE, quiet = TRUE, sprintf("^?$", .ORCID_iD_regexp) .ORCID_iD_db_from_package_sources <- -function(dir) +function(dir, add = FALSE) { meta <- .get_package_metadata(dir, FALSE) ids1 <- ids2 <- character() @@ -605,8 +605,15 @@ function(dir) }), use.names = FALSE) } - rbind(if(length(ids1)) cbind(ids1, "DESCRIPTION"), - if(length(ids2)) cbind(ids2, "inst/CITATION")) + + db <- data.frame(ID = c(ids1, ids2), + Parent = c(rep_len("DESCRIPTION", + length(ids1)), + rep_len("inst/CITATION", + length(ids2)))) + if(add) + db$Parent <- file.path(basename(dir), db$Parent) + db } ### ** .vc_dir_names From 4a9d86bf9822c4fe2be7d4d410fd856a7ce84dab Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 11 Jun 2024 07:14:49 +0000 Subject: [PATCH 205/546] More helpers. git-svn-id: https://svn.r-project.org/R/trunk@86722 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/Rd.R | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/library/tools/R/Rd.R b/src/library/tools/R/Rd.R index 38dcadae6a6..7c7e2879b9b 100644 --- a/src/library/tools/R/Rd.R +++ b/src/library/tools/R/Rd.R @@ -1181,6 +1181,32 @@ function(dir) else NULL } +### * .Rd_aliases_db_to_data_frame + +.Rd_aliases_db_to_data_frame <- +function(x) +{ + wrk <- function(a, p) { + cbind(unlist(a, use.names = FALSE), + rep.int(paste0(p, "::", names(a)), lengths(a))) + } + y <- as.data.frame(do.call(rbind, Map(wrk, x, names(x)))) + colnames(y) <- c("Alias", "Source") + y +} + +### * .Rd_rdxrefs_db_to_data_frame + +.Rd_rdxrefs_db_to_data_frame <- +function(x) +{ + wrk <- function(u, p) { + u$Source <- sprintf("%s::%s", p, u$Source) + u + } + do.call(rbind, Map(wrk, lapply(x, as.data.frame), names(x))) +} + ### Local variables: *** ### mode: outline-minor *** ### outline-regexp: "### [*]+" *** From 881801890039529b58f037001c150c442261fc4b Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 11 Jun 2024 20:31:36 +0000 Subject: [PATCH 206/546] More @apifun and such annotations. git-svn-id: https://svn.r-project.org/R/trunk@86723 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 371bf6dd198..89c38ce2581 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13260,6 +13260,9 @@ first. @apifun asReal @apifun asComplex @apifun asChar +The function @code{asCharacterFactor} converts a factor to a character +vector. +@apifun asCharacterFactor To return a length-one real vector we can use @@ -13377,12 +13380,15 @@ the @I{@var{n}-th} position in the pairlist (whose @code{CAR} is the @apifun lastElt @apifun nthcdr -Functions @code{str2type} and @code{type2str} map @R{} -length-one character strings to and from @code{SEXPTYPE} numbers, and +Functions @code{str2type} and @code{type2str} map @R{} length-one +character strings to and from @code{SEXPTYPE} numbers, and @code{type2char} maps numbers to C character strings. +@code{type2str_nowarn} does not issue a warning if the @code{SEXPTYPE} +is invalid. @apifun str2type @apifun type2str @apifun type2char +@apifun type2str_nowarn @comment Want to encourage use of some of the more stable and useful R_* @comment and Rf_* functions: @@ -13422,6 +13428,23 @@ to the @R{} function @code{getOption} without specifying a default. @apifun inherits @apifun topenv @apifun GetOption1 +@code{GetOptionWidth} returns the value of the @code{width} option as an +@code{int}. +@apifun GetOptionWidth +The C function @code{nlevels} returns the number of levels of a factor. +Unlike its @R{} counterpart ir always returns zero for non-factors. +@eapifun nlevels + +For vectors the C function @code{duplicated} returns a logical vector +indicating for each element whether it is duplicated or not. A second +argument specifies the direction of the search. +@eapifun duplicated + +The C function @code{R_lsInternal3} returns a character vector of the +names of variables in an environment. The second and third arguments +specify whether all names are desired and whether the result should be +sorted. +@eapifun R_lsInternal3 Some convenience functions for working with pairlist objects include @code{copyListMatrix}, @code{VectorToPairList}, and @@ -15125,7 +15148,7 @@ void warningcall_immediate(SEXP @var{call}, const char * @var{format}, ...); @apifun warning @apifun errorcall @apifun warningcall -@findex warningcall_immediate +@apifun warningcall_immediate @noindent These have the same call sequences as calls to @code{printf}, but in the @@ -17746,6 +17769,8 @@ void R_CleanUp (SA_TYPE saveact, int status, int RunLast) @embfun CleanEd @embfun R_CleanUp @embfun fpu_setup +@comment FIXME need to mention R_RunPendingFinalizers in text +@embfun R_RunPendingFinalizers These callbacks should never be changed in a running @R{} session (and hence cannot be called from an extension package). From 62ed00ee2bdffb7b49a290fe4a508da4519e75fb Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 12 Jun 2024 16:20:11 +0000 Subject: [PATCH 207/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86724 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/Rd.R | 22 ++++++++++------------ src/library/tools/R/Rd2HTML.R | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/library/tools/R/Rd.R b/src/library/tools/R/Rd.R index 7c7e2879b9b..b7a1d57ac81 100644 --- a/src/library/tools/R/Rd.R +++ b/src/library/tools/R/Rd.R @@ -1147,19 +1147,17 @@ function() rdxrefs } -### * .Rd_xrefs_with_missing_anchors +### * .Rd_xrefs_with_missing_package_anchors -.Rd_xrefs_with_missing_anchors <- -function(dir) +.Rd_xrefs_with_missing_package_anchors <- +function(dir, level = 1) { - ## Find the Rd xrefs with non-anchored targets not in the level 0 or - ## 1 aliases (package itself and standard packages). - - ## Argh. - ## We cannot simply use - ## findHTMLlinks(dir, level = c(0L, 1L)) - ## as this takes level 0 for an *installed* package. - ## So we need the package Rd db for both aliases and rdxrefs. + ## Find the Rd xrefs with non-anchored targets not in the package + ## itself or the installed packages with the given new-style levels + ## (base: 1, recommended: 2, others: 3) + ## Note that we use 'dir' as the path to package sources (and not + ## the installed package), and hence use the package Rd db for both + ## aliases and rdxrefs. db <- Rd_db(dir = dir) if(!length(db)) return() @@ -1175,7 +1173,7 @@ function(dir) rdxrefs[ind, 1L : 2L] <- cbind(sub("^=", "", anchors[ind]), "") rdxrefs <- rdxrefs[!nzchar(rdxrefs[, "Anchor"]), , drop = FALSE] aliases <- c(unlist(aliases, use.names = FALSE), - names(findHTMLlinks(dir, level = 1L))) + names(.find_HTML_links(level = level))) if(any(ind <- is.na(match(rdxrefs[, "Target"], aliases)))) unique(rdxrefs[ind, , drop = FALSE]) else NULL diff --git a/src/library/tools/R/Rd2HTML.R b/src/library/tools/R/Rd2HTML.R index 61aad85f7f0..f0efccb6f87 100644 --- a/src/library/tools/R/Rd2HTML.R +++ b/src/library/tools/R/Rd2HTML.R @@ -1388,6 +1388,37 @@ findHTMLlinks <- function(pkgDir = "", lib.loc = NULL, level = 0:2) gsub("[Rr]d$", "html", Links) } +.find_HTML_links <- +function(pkg.dir, lib.loc = NULL, level = 0 : 3) +{ + ## A variant of the above which splits levels for base and + ## recommended packages, such that + ## Level 0: this package (installed in pkg.dir) + ## Level 1: base packages + ## Level 2: recommended packages + ## Level 3: all packages installed in lib.loc + if (is.null(lib.loc)) lib.loc <- .libPaths() + + Links <- list() + if(3 %in% level) + Links <- c(Links, lapply(lib.loc, .find_HTML_links_in_library)) + if(2 %in% level) + Links <- c(lapply(file.path(.Library, + .get_standard_package_names()$recommended), + .find_HTML_links_in_package), + Links) + if(1 %in% level) + Links <- c(lapply(file.path(.Library, + .get_standard_package_names()$base), + .find_HTML_links_in_package), + Links) + if (0 %in% level && nzchar(pkg.dir)) + Links <- c(list(.find_HTML_links_in_package(pkg.dir)), Links) + Links <- unlist(Links) + Links <- Links[!duplicated(names(Links))] + gsub("[Rr]d$", "html", Links) +} + ## These helper functions can optionally return the absolute path as ## well (in the local file system) From d77add320413cabc40afd51d5e4dddb6e9dc074e Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 12 Jun 2024 16:48:14 +0000 Subject: [PATCH 208/546] Back out r86719 since it breaks lazy loading of a delayed assignment. git-svn-id: https://svn.r-project.org/R/trunk@86725 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/serialize.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/serialize.c b/src/main/serialize.c index 80b13d7d3b9..ea0205d4827 100644 --- a/src/main/serialize.c +++ b/src/main/serialize.c @@ -2234,7 +2234,6 @@ static void DecodeVersion(int packed, int *v, int *p, int *s) *s = packed; } -static SEXP checkNotPromise(SEXP); SEXP R_Unserialize(R_inpstream_t stream) { int version; @@ -2289,7 +2288,7 @@ SEXP R_Unserialize(R_inpstream_t stream) } UNPROTECT(1); - return checkNotPromise(obj); + return obj; } attribute_hidden SEXP R_SerializeInfo(R_inpstream_t stream) From 0b1eeb496d5ba87634a4ced4562d2b016e500aac Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 12 Jun 2024 18:00:19 +0000 Subject: [PATCH 209/546] More @apifun and such annotations. git-svn-id: https://svn.r-project.org/R/trunk@86726 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 120 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 117 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 89c38ce2581..9abad66cb82 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -11880,6 +11880,15 @@ the exact version of @pkg{packA} or there needs to be a mechanism for @pkg{packB} to test at runtime the version of @pkg{packA} it is linked to matches that it was compiled against. +On rare occasions in can be useful for C code in one package to +dynamically look up the address in another package. This can be done +using @code{R_FindSymbol}: +@example +DL_FUNC R_FindSymbol(char const *name, char const *pkg, + R_RegisteredNativeSymbol *symbol); +@end example +@apifun R_FindSymbol + @node Creating shared objects, Interfacing C++ code, Registering native routines, System and foreign language interfaces @section Creating shared objects @cindex Creating shared objects @@ -12984,6 +12993,13 @@ mkNamed(VECSXP, nms); @end example @apifun mkNamed +Symbols can also be installed or retrieved based on a name in a +@code{CHARSXP} object using either @code{Rf_installChar} or +@code{Rf_installTrChar}. These used to differ in handling character +encoding but have been identical since @R{} 4.0.0. +@apifun Rf_installChar +@apifun Rf_installTrChar + @node Classes, S4 objects, Attributes, Handling R objects in C @subsection Classes @cindex Classes @@ -13189,7 +13205,7 @@ SEXP getvar(SEXP name, SEXP rho) @} @end group @end example -@findex installChar +@apifun installChar The main work is done by @findex findVar @@ -13447,12 +13463,34 @@ sorted. @eapifun R_lsInternal3 Some convenience functions for working with pairlist objects include -@code{copyListMatrix}, @code{VectorToPairList}, and +@code{copyListMatrix}, @code{listAppend}, @code{isVectorizable}, @code{VectorToPairList}, and @code{PairToVectorList} @eapifun copyListMatrix +@eapifun listAppend +@eapifun isVectorizable @eapifun VectorToPairList @eapifun PairToVectorList +Some convenience functions for working with name spaces and environments +include @code{R_existsVarInFrame}, @code{R_removeVarFromFrame}, +@code{R_PackageEnvName}, @code{R_IsPackageEnv}, @code{R_FindNamespace}, +@code{R_IsNamespaceEnv}, and @code{R_NamespaceEnvSpec}. +@eapifun R_existsVarInFrame +@eapifun R_removeVarFromFrame +@eapifun R_PackageEnvName +@eapifun R_IsPackageEnv +@eapifun R_FindNamespace +@eapifun R_NamespaceEnvSpec +@eapifun R_IsNamespaceEnv + +The C functions @code{match} and @code{psmatch} correspond to the @R{} functions by the name name. +@eapifun match +@eapifun pmatch + +The C functions @code{R_forceAndCall} and @code{isUnsorted} correspond +to the @R{} functions code{forceAndCall} and @code{is.unsorted}. +@eapifun R_forceAndCall +@eapifun isUnsorted @node Named objects and copying, , Some convenience functions, Handling R objects in C @subsection Named objects and copying @cindex Copying objects @@ -14839,6 +14877,8 @@ These functions return one of @code{SORTED_DECR}, @code{SORTED_INCR}, or * Re-encoding:: * Condition handling and cleanup code:: * Allowing interrupts:: +* C stack checking:: +* Custom serialization input and output:: * Platform and version information:: * Inlining C functions:: * Controlling visibility:: @@ -16805,8 +16845,80 @@ Note that it is possible that the code behind one of the entry points defined here if called from your C or Fortran code could be interruptible or generate an error and so not return to your code. +@node C stack checking, Custom serialization input and output, Allowing interrupts, The R API +@section C stack checking +@cindex C stack checking +@R{} provides a framework for detecting when the amount of C stack is +too low. Two functions are available: +@example +void R_CheckStack(void) +void R_CheckStack2(size_t extra) +@end example +@apifun R_CheckStack +@apifun R_CheckStack2 +These functions signal an error when a low stack condition is detected. + +This mechanism is not always available (@xref{Threading issues}) and it +is best to avoid deep recursions in C and to track recursion depth when +using recursion is not avoidable. C compilers will often optimize tail +recursions to avoid consuming C stack, so it is best to write code in a +tail-recursive form when possible. + + +@node Custom serialization input and output, Platform and version information, C stack checking, The R API +@section Custom serialization input and output +@cindex Serialization + +The internal serialization code uses a framework for serializing from and +to different output media. This framework has been in use internally for +some time, but its use in packages is highly experimental and may need +to be changed or dropped once some experience is gained. Package authors +considering using this framework should keep this in mind. + +Client code will define a persistent stream structure with declarations +like +@example +struct R_outpstream_st out; +struct R_inpstream_st in; +@end example +These are filled in by calling these functions with appropriate arguments: +@example +void R_InitInPStream(R_inpstream_t stream, R_pstream_data_t data, + R_pstream_format_t type, + int (*inchar)(R_inpstream_t), + void (*inbytes)(R_inpstream_t, void *, int), + SEXP (*phook)(SEXP, SEXP), SEXP pdata); +void R_InitOutPStream(R_outpstream_t stream, R_pstream_data_t data, + R_pstream_format_t type, int version, + void (*outchar)(R_outpstream_t, int), + void (*outbytes)(R_outpstream_t, void *, int), + SEXP (*phook)(SEXP, SEXP), SEXP pdata); +@end example +Code should not depend on the fields of the stream structures. Simpler +initializers are available for serializing to or from a file pointer: +@example +void R_InitFileOutPStream(R_outpstream_t stream, FILE *fp, + R_pstream_format_t type, int version, + SEXP (*phook)(SEXP, SEXP), SEXP pdata); +void R_InitFileInPStream(R_inpstream_t stream, FILE *fp, + R_pstream_format_t type, + SEXP (*phook)(SEXP, SEXP), SEXP pdata); +@end example + +Once the stream structures are set up they can be used by calling +@example +void R_Serialize(SEXP s, R_outpstream_t stream) +SEXP R_Unserialize(R_inpstream_t stream) +@end example +Examples can be found in the @R{} sources in @file{src/main/serialize.c}. +@eapifun R_InitFileOutPStream +@eapifun R_InitFileInPStream +@eapifun R_InitInPStream +@eapifun R_Unserialize +@eapifun R_InitOutPStream +@eapifun R_Serialize -@node Platform and version information, Inlining C functions, Allowing interrupts, The R API +@node Platform and version information, Inlining C functions, Custom serialization input and output, The R API @section Platform and version information @cindex Version information from C @cindex @I{OpenMP} @@ -17062,6 +17174,8 @@ packages packages that need to share in the @R{} event loops (not Windows) @end multitable @end quotation +@comment ideally this should get some text: +@eapifun R_GetX11Image The following headers are included by @file{R.h}: From 10bf598c61ef4fe3129b3961f9f24bb17dd07cde Mon Sep 17 00:00:00 2001 From: ripley Date: Thu, 13 Jun 2024 06:06:43 +0000 Subject: [PATCH 210/546] name macOS 15 git-svn-id: https://svn.r-project.org/R/trunk@86727 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/sessionInfo.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/library/utils/R/sessionInfo.R b/src/library/utils/R/sessionInfo.R index 7f990873c22..8c1ff9b63d5 100644 --- a/src/library/utils/R/sessionInfo.R +++ b/src/library/utils/R/sessionInfo.R @@ -78,7 +78,8 @@ "11" = "Big Sur", "12" = "Monterey", "13" = "Ventura", - "14" = "Sonoma"), + "14" = "Sonoma", + "15" = "Sequoia"), ver) else sprintf("macOS %s", ver) From cab247885d44c980baa20f8407b4054578701041 Mon Sep 17 00:00:00 2001 From: maechler Date: Thu, 13 Jun 2024 08:36:51 +0000 Subject: [PATCH 211/546] add head() & tail() methods for "ts"(time series) ==> export .checkHT() utility git-svn-id: https://svn.r-project.org/R/trunk@86728 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 7 +++-- src/library/stats/NAMESPACE | 5 +++- src/library/stats/R/ts.R | 26 ++++++++++++++++- src/library/stats/man/ts.Rd | 18 +++++++++--- src/library/utils/NAMESPACE | 1 + src/library/utils/R/head.R | 18 ++++++------ src/library/utils/man/head.Rd | 15 ++++++++-- tests/Examples/stats-Ex.Rout.save | 48 ++++++++++++++++++++++++------- 8 files changed, 108 insertions(+), 30 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 4366c6d274e..2488ed69e10 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -24,6 +24,9 @@ \item New functions \code{check_package_urls()} and \code{check_package_dois()} in package \pkg{tools} for checking URLs and DOIs in package sources. + + \item New \code{head()} and \code{tail()} methods for class + \code{"ts"} time series, proposed by Spencer Graves on R-devel. } } @@ -85,7 +88,7 @@ new types have compatible memory structure and content. Use of \code{SET_TYPE} in package C code should be avoided and may be deprecated in the near future. It is better to allocate an object - of the proper type in the first place. + of the proper type in the first place. \item New API function \code{R_mkClosure}. This checks that its arguments are valid and should be used instead of @@ -93,7 +96,7 @@ \code{SET_BODY}, and \code{SET_CLOENV}. \item New API functions \code{R_ClosureFormals}, - \code{R_ClosureBody}, and \code{R_ClosureEnv} for extrancting + \code{R_ClosureBody}, and \code{R_ClosureEnv} for extracting closure components. The existing functions \code{R_ClosureExpr} and \code{R_BytecodeExpr} have also been added to the API. diff --git a/src/library/stats/NAMESPACE b/src/library/stats/NAMESPACE index 49b2b71be31..42d71bfe6e2 100644 --- a/src/library/stats/NAMESPACE +++ b/src/library/stats/NAMESPACE @@ -6,7 +6,8 @@ importFrom(grDevices, as.graphicsAnnot, dev.cur, dev.flush, dev.hold, dev.interactive, dev.new, dev.set, devAskNewPage, extendrange, n2mfrow, palette, xy.coords) importFrom('utils', - count.fields, flush.console, modifyList, str, tail) + count.fields, flush.console, modifyList, str, + head, tail, .checkHT) export(.checkMFClasses, .getXlevels, .MFclass, .nknots.smspl, acf, acf2AR, add.scope, @@ -253,6 +254,7 @@ S3method(getInitial, formula) S3method(getInitial, selfStart) S3method(hatvalues, lm) S3method(hatvalues, smooth.spline) +S3method(head, ts) S3method(identify, hclust) S3method(influence, glm) S3method(influence, lm) @@ -495,6 +497,7 @@ S3method(str, logLik) S3method(t, ts) S3method(t.test, default) S3method(t.test, formula) +S3method(tail, ts) S3method(terms, aovlist) S3method(terms, default) S3method(terms, formula) diff --git a/src/library/stats/R/ts.R b/src/library/stats/R/ts.R index e7126e951d8..7d41b08cbad 100644 --- a/src/library/stats/R/ts.R +++ b/src/library/stats/R/ts.R @@ -1,7 +1,7 @@ # File src/library/stats/R/ts.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2023 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -850,3 +850,27 @@ arima.sim <- function(model, n, rand.gen = rnorm, if(d > 0) x <- diffinv(x, differences = d) as.ts(x) } + + +## Originally from Spencer Graves, to R-devel@R-..., 9 Jun 2024 : +head.ts <- function(x, n = 6L, ...) { + .checkHT(n, d <- dim(x)) + tmx <- as.numeric(time(x)) + firstn <- head(tmx, n[1L]) + if(!is.null(d) && length(n) >= 2L) { # matrix + cols <- head(1:d[2], n[2L]) + x <- x[, cols[1L]:tail(cols, 1L), drop=FALSE] + } + window(x, firstn[1L], tail(firstn, 1L)) +} + +tail.ts <- function (x, n = 6L, ...) { + .checkHT(n, d <- dim(x)) + tmx <- as.numeric(time(x)) + lastn <- tail(tmx, n[1L]) + if(!is.null(d) && length(n) >= 2L) { # matrix + cols <- head(1:d[2], n[2L]) + x <- x[, cols[1L]:tail(cols, 1L), drop=FALSE] + } + window(x, lastn[1L], tail(lastn, 1L)) +} diff --git a/src/library/stats/man/ts.Rd b/src/library/stats/man/ts.Rd index 022b9149076..937af96e05c 100644 --- a/src/library/stats/man/ts.Rd +++ b/src/library/stats/man/ts.Rd @@ -1,6 +1,6 @@ % File src/library/stats/man/ts.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2023 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{ts} @@ -14,6 +14,8 @@ \alias{is.mts} \alias{[.ts} \alias{t.ts} +\alias{head.ts} +\alias{tail.ts} \description{ The function \code{ts} is used to create time-series objects. @@ -60,8 +62,7 @@ is.mts(x) \details{ The function \code{ts} is used to create time-series objects. These are vectors or matrices which inherit from class \code{"ts"} (and have - additional - attributes) which represent data which has been sampled at equispaced + additional attributes) which represent data sampled at equispaced points in time. In the matrix case, each column of the matrix \code{data} is assumed to contain a single (univariate) time series. Time series must have at least one observation, and although they need @@ -130,11 +131,20 @@ gnp <- ts(cumsum(1 + round(rnorm(100), 2)), start = c(1954, 7), frequency = 12) plot(gnp) # using 'plot.ts' for time-series plot +\donttest{utils:: methods(class = "ts") # all functions with methods available for "ts"} + +## "ts" methods for head() and tail() +utils:: head(lynx, 4) +utils:: tail(lynx, -7) +\dontshow{ stopifnot(is.ts(head(lynx, -6)), + is.ts(tail(lynx, 3))) +} + ## Multivariate z <- ts(matrix(rnorm(300), 100, 3), start = c(1961, 1), frequency = 12) class(z) is.mts(z) -head(z) # as "matrix" +head(z) # "ts" method ==> incl. times: plot(z) plot(z, plot.type = "single", lty = 1:3) diff --git a/src/library/utils/NAMESPACE b/src/library/utils/NAMESPACE index 5da0335a632..251eb48eb51 100644 --- a/src/library/utils/NAMESPACE +++ b/src/library/utils/NAMESPACE @@ -11,6 +11,7 @@ export("?", .AtNames, .DollarNames, .S3methods, .romans, Rprof, Rprofmem, aspell_write_personal_dictionary_file, available.packages, browseEnv, browseURL, browseVignettes, bug.report, capture.output, changedFiles, charClass, checkCRAN, + .checkHT, chooseBioCmirror, chooseCRANmirror, citation, cite, citeNatbib, citEntry, citHeader, citFooter, close.socket, combn, compareVersion, contrib.url, count.fields, create.post, data, diff --git a/src/library/utils/R/head.R b/src/library/utils/R/head.R index b94509a4d96..31545e637f8 100644 --- a/src/library/utils/R/head.R +++ b/src/library/utils/R/head.R @@ -1,7 +1,7 @@ # File src/library/utils/R/head.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2023 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ ## check for acceptable n, called by several head() and tail() methods -checkHT <- function(n, d) { +.checkHT <- function(n, d) { len <- length(n) msg <- if(len == 0 || all(is.na(n))) gettext("invalid 'n' - must contain at least one non-missing element, got none.") @@ -40,7 +40,7 @@ checkHT <- function(n, d) { gettextf("invalid 'n' - length(n) must be <= length(dim(x)), got %d > %d", len, length(d)) else return(invisible()) - ## report the caller, not checkHT(): + ## report the caller, not .checkHT(): stop(simpleError(msg, call = sys.call(-1L))) } @@ -49,7 +49,7 @@ head <- function(x, ...) UseMethod("head") head.default <- function(x, n = 6L, ...) { - checkHT(n, dx <- dim(x)) + .checkHT(n, dx <- dim(x)) if(!is.null(dx)) head.array(x, n, ...) else if(length(n) == 1L) { @@ -66,7 +66,7 @@ head.matrix <- ## used on arrays (incl. matrices), data frames, .. : head.array <- function(x, n = 6L, ...) { - checkHT(n, d <- dim(x)) + .checkHT(n, d <- dim(x)) args <- rep(alist(x, , drop = FALSE), c(1L, length(d), 1L)) ## non-specified dimensions (ie dims > length(n) or n[i] is NA) will stay missing / empty: ii <- which(!is.na(n[seq_along(d)])) @@ -89,7 +89,7 @@ head.function <- function(x, n = 6L, ...) { ## Do n check while dim(x) is NULL ## not later when dim(lines) is length 2 - checkHT(n, dim(x)) + .checkHT(n, dim(x)) lines <- as.matrix(deparse(x)) dimnames(lines) <- list(seq_along(lines),"") noquote(head(lines, n=n)) @@ -99,7 +99,7 @@ tail <- function(x, ...) UseMethod("tail") tail.default <- function (x, n = 6L, keepnums = FALSE, addrownums, ...) { - checkHT(n, dx <- dim(x)) + .checkHT(n, dx <- dim(x)) if(!is.null(dx)) tail.array(x, n=n, keepnums=keepnums, addrownums=addrownums, ...) else if(length(n) == 1L) { @@ -123,7 +123,7 @@ tail.array <- function(x, n = 6L, keepnums = TRUE, addrownums, ...) keepnums <- addrownums } - checkHT(n, d <- dim(x)) + .checkHT(n, d <- dim(x)) ## non-specified dimensions (ie length(n) < length(d) or n[i] is NA) will stay missing / empty: ii <- which(!is.na(n[seq_along(d)])) sel <- lapply(ii, function(i) { @@ -183,7 +183,7 @@ tail.ftable <- function(x, n = 6L, keepnums = FALSE, addrownums, ...) { tail.function <- function(x, n = 6L, ...) { - checkHT(n, dim(x)) + .checkHT(n, dim(x)) lines <- as.matrix(deparse(x)) dimnames(lines) <- list(seq_along(lines),"") noquote(tail(lines, n=n)) diff --git a/src/library/utils/man/head.Rd b/src/library/utils/man/head.Rd index 900d88d7112..24a69864067 100644 --- a/src/library/utils/man/head.Rd +++ b/src/library/utils/man/head.Rd @@ -1,6 +1,6 @@ % File src/library/utils/man/head.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2022 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{head} @@ -19,15 +19,16 @@ \alias{tail.table} \alias{tail.matrix} \alias{tail.array} +\alias{.checkHT} \description{ Returns the first or last parts of a vector, matrix, table, data frame or function. Since \code{head()} and \code{tail()} are generic - functions, they may also have been extended to other classes. + functions, they have been extended to other classes, including + \code{"\link[stats]{ts}"} from \pkg{stats}. } \usage{ head(x, \dots) \method{head}{default}(x, n = 6L, \dots) -% head.matrix(x, n = 6L, \dots) # <-- gives NOTE, even though exported \method{head}{matrix}(x, n = 6L, \dots) # is exported as head.matrix() ## NB: The methods for 'data.frame' and 'array' are identical to the 'matrix' one @@ -43,6 +44,8 @@ tail(x, \dots) \method{tail}{ftable}(x, n = 6L, keepnums = FALSE, addrownums, \dots) \method{tail}{function}(x, n = 6L, \dots) + +.checkHT(function(n, d) } \arguments{ \item{x}{an object} @@ -63,6 +66,9 @@ tail(x, \dots) instead. Taken as the value of \code{keepnums} if it is explicitly set when \code{keepnums} is not.} \item{\dots}{arguments to be passed to or from other methods.} + \item{d}{typically \code{dim(x)}, hence \code{NULL} or a (typically integer, short) + vector.} + } \details{ For vector/array based objects, \code{head()} (\code{tail()}) returns @@ -102,6 +108,9 @@ tail(x, \dots) As \code{\link{data.frame}} subsetting (\sQuote{indexing}) keeps \code{\link{attributes}}, so do the \code{head()} and \code{tail()} methods for data frames. + + The auxiliary function \code{.checkHT(d, n)} is useful in \code{head(x, n)} or + \code{tail(x, n)} methods, checking validity of \code{d <- dim(x)} and \code{n}. } \value{ An object (usually) like \code{x} but generally smaller. Hence, for diff --git a/tests/Examples/stats-Ex.Rout.save b/tests/Examples/stats-Ex.Rout.save index 0e9cb5cae6f..22cc1dbb0a8 100644 --- a/tests/Examples/stats-Ex.Rout.save +++ b/tests/Examples/stats-Ex.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-02-28 r85996) -- "Unsuffered Consequences" +R Under development (unstable) (2024-06-13 r86727) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -18087,6 +18087,7 @@ Loading required namespace: Matrix > ## Don't show: > if(!hadM) unloadNamespace("Matrix") > ## End(Don't show) +> > ## IGNORE_RDIFF_END > ## scale W to have column sums 1: > W. <- W / sum(wts) @@ -18120,6 +18121,7 @@ Loading required namespace: Matrix > ### Name: ts > ### Title: Time-Series Objects > ### Aliases: ts as.ts as.ts.default is.ts Ops.ts cbind.ts is.mts [.ts t.ts +> ### head.ts tail.ts > ### Keywords: ts > > ### ** Examples @@ -18141,20 +18143,46 @@ Loading required namespace: Matrix + start = c(1954, 7), frequency = 12) > plot(gnp) # using 'plot.ts' for time-series plot > +> +> ## "ts" methods for head() and tail() +> utils:: head(lynx, 4) +Time Series: +Start = 1821 +End = 1824 +Frequency = 1 +[1] 269 321 585 871 +> utils:: tail(lynx, -7) +Time Series: +Start = 1828 +End = 1934 +Frequency = 1 + [1] 5943 4950 2577 523 98 184 279 409 2285 2685 3409 1824 409 151 45 + [16] 68 213 546 1033 2129 2536 957 361 377 225 360 731 1638 2725 2871 + [31] 2119 684 299 236 245 552 1623 3311 6721 4254 687 255 473 358 784 + [46] 1594 1676 2251 1426 756 299 201 229 469 736 2042 2811 4431 2511 389 + [61] 73 39 49 59 188 377 1292 4031 3495 587 105 153 387 758 1307 + [76] 3465 6991 6313 3794 1836 345 382 808 1388 2713 3800 3091 2985 3790 674 + [91] 81 80 108 229 399 1132 2432 3574 2935 1537 529 485 662 1000 1590 +[106] 2657 3396 +> ## Don't show: +> stopifnot(is.ts(head(lynx, -6)), ++ is.ts(tail(lynx, 3))) +> ## End(Don't show) +> > ## Multivariate > z <- ts(matrix(rnorm(300), 100, 3), start = c(1961, 1), frequency = 12) > class(z) [1] "mts" "ts" "matrix" "array" > is.mts(z) [1] TRUE -> head(z) # as "matrix" - Series 1 Series 2 Series 3 -[1,] -0.62036668 0.4094018 0.8936737 -[2,] 0.04211587 1.6888733 -1.0472981 -[3,] -0.91092165 1.5865884 1.9713374 -[4,] 0.15802877 -0.3309078 -0.3836321 -[5,] -0.65458464 -2.2852355 1.6541453 -[6,] 1.76728727 2.4976616 1.5122127 +> head(z) # "ts" method ==> incl. times: + Series 1 Series 2 Series 3 +Jan 1961 -0.62036668 0.4094018 0.8936737 +Feb 1961 0.04211587 1.6888733 -1.0472981 +Mar 1961 -0.91092165 1.5865884 1.9713374 +Apr 1961 0.15802877 -0.3309078 -0.3836321 +May 1961 -0.65458464 -2.2852355 1.6541453 +Jun 1961 1.76728727 2.4976616 1.5122127 > plot(z) > plot(z, plot.type = "single", lty = 1:3) > @@ -19589,7 +19617,7 @@ Number of Fisher Scoring iterations: 6 > cleanEx() > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 6.076 0.149 6.227 0 0 +Time elapsed: 5.428 0.289 5.837 0 0 > grDevices::dev.off() null device 1 From fe2f8e59240aebb8cfb1612cf2f17c37bbcf5014 Mon Sep 17 00:00:00 2001 From: maechler Date: Thu, 13 Jun 2024 09:30:58 +0000 Subject: [PATCH 212/546] add workaround for *installed* S4-head()-method packages: git-svn-id: https://svn.r-project.org/R/trunk@86729 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/head.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/library/utils/R/head.R b/src/library/utils/R/head.R index 31545e637f8..45848da2c88 100644 --- a/src/library/utils/R/head.R +++ b/src/library/utils/R/head.R @@ -27,6 +27,9 @@ ### , 2019 +## TEMPORARY workaround for S4-head() method defining already installed +## packages before they are re-installed: +checkHT <- ## check for acceptable n, called by several head() and tail() methods .checkHT <- function(n, d) { len <- length(n) From beb4c0f6790de5062bf0196be3afb72b31dfae3a Mon Sep 17 00:00:00 2001 From: ripley Date: Thu, 13 Jun 2024 10:30:28 +0000 Subject: [PATCH 213/546] fix texinfo error git-svn-id: https://svn.r-project.org/R/trunk@86730 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 9abad66cb82..ba0e7d5c634 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13488,7 +13488,7 @@ The C functions @code{match} and @code{psmatch} correspond to the @R{} functions @eapifun pmatch The C functions @code{R_forceAndCall} and @code{isUnsorted} correspond -to the @R{} functions code{forceAndCall} and @code{is.unsorted}. +to the @R{} functions @code{forceAndCall} and @code{is.unsorted}. @eapifun R_forceAndCall @eapifun isUnsorted @node Named objects and copying, , Some convenience functions, Handling R objects in C From 442f6c6b2640ae81101318a0df0bde9ad696f941 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 13 Jun 2024 11:05:13 +0000 Subject: [PATCH 214/546] Adjustments to nonAPI. git-svn-id: https://svn.r-project.org/R/trunk@86731 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/sotools.R | 55 ++--------------------------------- 1 file changed, 2 insertions(+), 53 deletions(-) diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 92ae47ee244..fbf086dee99 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -675,8 +675,8 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "SETLENGTH", "SET_TRUELENGTH", "SETLEVELS", "SET_ENVFLAGS", "SET_FRAME", "SET_ENCLOS", "SET_HASHTAB", "SET_PRENV", "SET_PRVALUE", "SET_PRCODE", "STDVEC_DATAPTR", - "IS_GROWABLE", "SET_GROWABLE", "SET_NAMED", - "R_PromiseExpr", "R_ClosureExpr", + "IS_GROWABLE", "SET_GROWABLE_BIT", "SET_NAMED", + "R_PromiseExpr", "R_tryWrap", ## in the non-API header R_ext/Connections.h "R_new_custom_connection", "R_ReadConnection", @@ -688,57 +688,6 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "R_Pretty") ## hidden, so unlikely to be usable ## "optif9") ## used by nlme and pcaPP -## ## non-API header Altrep.h: used by -## ## arrow cli duckdb igraph isotree nanoarrow outliertree readsparse rlas stringfish vctrs vroom -## "R_new_altrep", -## "R_make_altstring_class", "R_make_altinteger_class", -## "R_make_alreal_class", "R_make_altlogical_class", -## "R_make_altraw_class", "R_make_altcomplex_class", -## "R_make_altslist_class", -## "R_altrep_inherits", "R_reinit_altrep_classes", -## "R_altrep_data1", "R_altrep_data2", "R_altrep_inherits", -## "R_set_altcomplex_Elt_method", -## "R_set_altcomplex_Get_region_method", -## "R_set_altinteger_Elt_method", -## "R_set_altinteger_Get_region_method", -## "R_set_altinteger_Is_sorted_method", -## "R_set_altinteger_Max_method", -## "R_set_altinteger_Min_method", -## "R_set_altinteger_No_NA_method", -## "R_set_altinteger_Sum_method", -## "R_set_altlist_Elt_method", -## "R_set_altlist_Set_elt_method", -## "R_set_altlogical_Elt_method", -## "R_set_altlogical_Get_region_method", -## "R_set_altlogical_Is_sorted_method", -## "R_set_altlogical_No_NA_method", -## "R_set_altlogical_Sum_method", -## "R_set_altraw_Elt_method", -## "R_set_altraw_Get_region_method", -## "R_set_altreal_Elt_method", -## "R_set_altreal_Get_region_method", -## "R_set_altreal_Is_sorted_method", -## "R_set_altreal_Max_method", -## "R_set_altreal_Min_method", -## "R_set_altreal_No_NA_method", -## "R_set_altreal_Sum_method", -## "R_set_altrep_Coerce_method", -## "R_set_altrep_DuplicateEX_method", -## "R_set_altrep_Duplicate_method", -## "R_set_altrep_Inspect_method", -## "R_set_altrep_Length_method", -## "R_set_altrep_Serialized_state_method", -## "R_set_altrep_UnserializeEX_method", -## "R_set_altrep_Unserialize_method", -## "R_set_altstring_Elt_method", -## "R_set_altstring_Is_sorted_method", -## "R_set_altstring_No_NA_method", -## "R_set_altstring_Set_elt_method", -## "R_set_altvec_Dataptr_method", -## "R_set_altvec_Dataptr_or_null_method", -## "R_set_altvec_Extract_subset_method" -## ## maybe allow regexps here. - ## grDevices uses R_Home R_InputHandlers R_TempDir R_Visible R_cairoCdynload R_fopen R_gzclose R_gzgets R_gzopen R_isForkedChild Rf_envlength Rf_strIsASCII Rf_utf8towcs Rg_set_col_ptrs Ri18n_wcwidth addInputHandler do_X11 do_contourLines do_getGraphicsEventEnv do_getSnapshot do_playSnapshot do_saveplot locale2charset mbcsToUcs2 ptr_R_ProcessEvents ## graphics uses OutDec R_print Rf_EncodeComplex Rf_EncodeInteger Rf_EncodeLogical Rf_EncodeReal Rf_GPretty Rf_PrintDefaults Rf_envlength Rf_formatComplex Rf_formatReal baseRegisterIndex known_to_be_latin1 max_contour_segments From 7d3f1cc7b384ab3bfb97a47d5322366e3751b4b1 Mon Sep 17 00:00:00 2001 From: maechler Date: Thu, 13 Jun 2024 13:22:27 +0000 Subject: [PATCH 215/546] new low-level qr.influence(); see PR#18739 wishlist, proposed by Luke git-svn-id: https://svn.r-project.org/R/trunk@86732 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 ++++ src/library/stats/NAMESPACE | 1 + src/library/stats/R/lm.influence.R | 16 +++++++------- src/library/stats/man/lm.influence.Rd | 30 ++++++++++++++++++++++----- tests/Examples/stats-Ex.Rout.save | 8 ++++++- 5 files changed, 46 insertions(+), 13 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 2488ed69e10..e1e9d926ecd 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -27,6 +27,10 @@ \item New \code{head()} and \code{tail()} methods for class \code{"ts"} time series, proposed by Spencer Graves on R-devel. + + \item New \code{qr.influence()}, a \dQuote{bare bones} interface to + the \code{lm.influence()} leave-one-out diagnostics computations; + wished for in \PR{18739}. } } diff --git a/src/library/stats/NAMESPACE b/src/library/stats/NAMESPACE index 42d71bfe6e2..145019c7271 100644 --- a/src/library/stats/NAMESPACE +++ b/src/library/stats/NAMESPACE @@ -60,6 +60,7 @@ export(.checkMFClasses, .getXlevels, .MFclass, .nknots.smspl, punif, pweibull, pwilcox, qbeta, qbinom, qcauchy, qchisq, qexp, qf, qgamma, qgeom, qhyper, qlnorm, qlogis, qnbinom, qnorm, qpois, qqline, qqnorm, qqplot, qsignrank, qt, qtukey, quantile, + qr.influence, quasi, quasibinomial, quasipoisson, qunif, qweibull, qwilcox, r2dtable, rbeta, rbinom, rcauchy, rchisq, read.ftable, rect.hclust, reformulate, relevel, reorder, replications, diff --git a/src/library/stats/R/lm.influence.R b/src/library/stats/R/lm.influence.R index 323f70cb7f9..ab6720d4f1e 100644 --- a/src/library/stats/R/lm.influence.R +++ b/src/library/stats/R/lm.influence.R @@ -1,7 +1,7 @@ # File src/library/stats/R/lm.influence.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2020 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -41,6 +41,9 @@ weighted.residuals <- function(obj, drop0 = TRUE) } else r } +qr.influence <- function(qr, res, tol = 10 * .Machine$double.eps) + .Call(C_influence, qr, res, tol) + lm.influence <- function (model, do.coef = TRUE) { wt.res <- weighted.residuals(model) @@ -74,15 +77,14 @@ lm.influence <- function (model, do.coef = TRUE) q <- NCOL(e) ## NB: The following relies on recycling: diag(v) %*% A == A * v ## so we need a for loop for the mlm case - if (is.mlm){ + res$coefficients <- + if(is.mlm) { cf <- array(0, c(n,k,q)) for ( j in seq_len(q) ) cf[,,j] <- invRQtt * ifelse(hat == 1, 0, e[,j]/(1-hat)) - } else - cf <- invRQtt * ifelse(hat == 1, 0, e/(1-hat)) - - - res$coefficients <- cf + cf + } else + invRQtt * ifelse(hat == 1, 0, e/(1-hat)) } diff --git a/src/library/stats/man/lm.influence.Rd b/src/library/stats/man/lm.influence.Rd index b311b7ad7e8..eec9a740950 100644 --- a/src/library/stats/man/lm.influence.Rd +++ b/src/library/stats/man/lm.influence.Rd @@ -1,26 +1,33 @@ % File src/library/stats/man/lm.influence.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2022 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{lm.influence} \title{Regression Diagnostics} +\alias{lm.influence} +\alias{influence} +\alias{influence.lm} +\alias{influence.glm} +\alias{qr.influence} \usage{ influence(model, \dots) \method{influence}{lm}(model, do.coef = TRUE, \dots) \method{influence}{glm}(model, do.coef = TRUE, \dots) lm.influence(model, do.coef = TRUE) + +qr.influence(qr, res, tol = 10 * .Machine$double.eps) } -\alias{lm.influence} -\alias{influence} -\alias{influence.lm} -\alias{influence.glm} \arguments{ \item{model}{an object as returned by \code{\link{lm}} or \code{\link{glm}}.} \item{do.coef}{logical indicating if the changed \code{coefficients} (see below) are desired. These need \eqn{O(n^2 p)} computing time.} \item{\dots}{further arguments passed to or from other methods.} + \item{qr}{typically the result of \code{\link{qr}()}, a \code{\link{list}} + of class \code{"qr"}.} + \item{res}{numerical vector of model residuals.} + \item{tol}{non-negative numerical tolerance.} } \description{ This function provides the basic quantities which are @@ -43,6 +50,10 @@ lm.influence(model, do.coef = TRUE) \code{\link{naresid}} is applied to the results and so will fill in with \code{NA}s it the fit had \code{na.action = na.exclude}. + + \code{qr.influence()} is a \emph{low level} interface to parts of + \code{lm.influence(*, doc.coef = FALSE)} provided for cases where speed + is more important than user safety. } \value{ A list containing the following components of the same length or @@ -61,6 +72,9 @@ lm.influence(model, do.coef = TRUE) GLMs can result in this being \code{NaN}.)} \item{wt.res}{a vector of \emph{weighted} (or for class \code{glm} rather \emph{deviance}) residuals.} + + \code{qr.influence()} returns list with the two components \code{hat} and + \code{sigma}, as above but without \code{\link{names}}. } \note{ The \code{coefficients} returned by the \R version @@ -104,6 +118,12 @@ summary(lm.SR <- lm(sr ~ pop15 + pop75 + dpi + ddpi, correlation = TRUE) utils::str(lmI <- lm.influence(lm.SR)) +qRes <- qr(lm.SR) # == lm.SR $ qr +qrI <- qr.influence(qRes, residuals(lm.SR)) +strip <- function(x) lapply(lapply(x, unname), drop) +stopifnot(identical(strip(qrI), + strip(lmI[c("hat", "sigma")]))) + ## For more "user level" examples, use example(influence.measures) } \keyword{regression} diff --git a/tests/Examples/stats-Ex.Rout.save b/tests/Examples/stats-Ex.Rout.save index 22cc1dbb0a8..575a72f4bd2 100644 --- a/tests/Examples/stats-Ex.Rout.save +++ b/tests/Examples/stats-Ex.Rout.save @@ -9360,7 +9360,7 @@ it = 10 -2.083333 -2.083333 > > ### Name: lm.influence > ### Title: Regression Diagnostics -> ### Aliases: lm.influence influence influence.lm influence.glm +> ### Aliases: lm.influence influence influence.lm influence.glm qr.influence > ### Keywords: regression > > ### ** Examples @@ -9412,6 +9412,12 @@ List of 4 $ wt.res : Named num [1:50] 0.864 0.616 2.219 -0.698 3.553 ... ..- attr(*, "names")= chr [1:50] "Australia" "Austria" "Belgium" "Bolivia" ... > +> qRes <- qr(lm.SR) # == lm.SR $ qr +> qrI <- qr.influence(qRes, residuals(lm.SR)) +> strip <- function(x) lapply(lapply(x, unname), drop) +> stopifnot(identical(strip(qrI), ++ strip(lmI[c("hat", "sigma")]))) +> > ## For more "user level" examples, use example(influence.measures) > > From e475a4e6f67e8b31a8f8e6827c3d6bdb8f9cd660 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 13 Jun 2024 17:12:59 +0000 Subject: [PATCH 216/546] Add some argument type checking. git-svn-id: https://svn.r-project.org/R/trunk@86733 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/sotools.R | 3 +++ src/main/memory.c | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index fbf086dee99..fd0530d491b 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -626,6 +626,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "tql2_", "tqlrat_", "tred1_", "tred2_", "utf8locale", "yylloc", "R_opendir", "R_readdir", "R_closedir", # "signrank_free", "wilcox_free" are API only from 4.2.0 + "ENSURE_NAMEDMAX", "IS_ASCII", "IS_UTF8", ## Rinterface.h, Rembedded.h, R_ext/{RStartup,eventloop}.h "AllDevicesKilled", "R_CStackLimit", "R_CStackStart", @@ -660,6 +661,8 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "ptr_R_savehistory", "ptr_do_dataentry", "ptr_do_dataviewer", "ptr_do_selectlist", "readconsolecfg", "removeInputHandler", "run_Rmainloop", "setup_Rmainloop", + "DDVAL", "NAMED", "INTERNAL", "SYMVALUE", + "REAL0", "COMPLEX0", "LEVELS", "FRAME", "HASHTAB", ## non-API, removed in R 4.5.0 and long deprecated in R_ext/RS.h (and as call_S in S.h) "call_R", diff --git a/src/main/memory.c b/src/main/memory.c index 36e28291775..5497a92b648 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4576,10 +4576,15 @@ void (SET_PRIMOFFSET)(SEXP x, int v) { SET_PRIMOFFSET(CHK(x), v); } #endif /* Symbol Accessors */ -SEXP (PRINTNAME)(SEXP x) { return CHK(PRINTNAME(CHK(x))); } -SEXP (SYMVALUE)(SEXP x) { return CHK(SYMVALUE(CHK(x))); } -SEXP (INTERNAL)(SEXP x) { return CHK(INTERNAL(CHK(x))); } -int (DDVAL)(SEXP x) { return DDVAL(CHK(x)); } +/* looks like R_NilValue is also being passed to tome of these */ +#define CHKSYMSXP(x) \ + if (x != R_NilValue && TYPEOF(x) != SYMSXP) \ + error(_("argument of type %s is not a symbol or NULL"), \ + sexptype2char(TYPEOF(x))) +SEXP (PRINTNAME)(SEXP x) { CHKSYMSXP(x); return CHK(PRINTNAME(CHK(x))); } +SEXP (SYMVALUE)(SEXP x) { CHKSYMSXP(x); return CHK(SYMVALUE(CHK(x))); } +SEXP (INTERNAL)(SEXP x) { CHKSYMSXP(x); return CHK(INTERNAL(CHK(x))); } +int (DDVAL)(SEXP x) { CHKSYMSXP(x); return DDVAL(CHK(x)); } attribute_hidden void (SET_PRINTNAME)(SEXP x, SEXP v) { FIX_REFCNT(x, PRINTNAME(x), v); CHECK_OLD_TO_NEW(x, v); PRINTNAME(x) = v; } From 6a9a5d653923f0a173533bde49a87ae713795164 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 13 Jun 2024 17:33:47 +0000 Subject: [PATCH 217/546] News entry for tools:::nonAPI update. git-svn-id: https://svn.r-project.org/R/trunk@86734 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index e1e9d926ecd..d2fd15c55ea 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -105,6 +105,14 @@ and \code{R_BytecodeExpr} have also been added to the API. \item New API function \code{R_ParentEnv}. + + \item Some non-API entry points have been added to those reported + by \command{R CMD check}: \code{SYMVALUE}, \code{INTERNAL}, + \code{DDVAL}, \code{ENSURE_NAMEDMAX}, \code{NAMED}, + \code{COMPLEX0}, \code{REAL0}, \code{LEVELS}, \code{FRAME}, + \code{HASHTAB}, \code{IS_ASCII}, \code{IS_UTF8}. Any declarations + for these in public header files will be removed in the near + future, and they will be hidden where possible. } } From 6e8dbd8cfd085bde521f655a4c9340f0ad03941d Mon Sep 17 00:00:00 2001 From: ripley Date: Thu, 13 Jun 2024 18:06:59 +0000 Subject: [PATCH 218/546] make commands are usually not echoed git-svn-id: https://svn.r-project.org/R/trunk@86735 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/Makefile.in b/src/library/tools/Makefile.in index f8574402fcc..8a0b0700138 100644 --- a/src/library/tools/Makefile.in +++ b/src/library/tools/Makefile.in @@ -48,7 +48,7 @@ all: Makefile DESCRIPTION mkR: mkR1 $(WRE_DATA): $(WRE_SRC) - grep -E '^@(api|eapi|emb)(fun|var|hdr)' $< > $@ + @grep -E '^@(api|eapi|emb)(fun|var|hdr)' $< > $@ include $(top_srcdir)/share/make/basepkg.mk From 7de4432909cf5ca8d320b0c7e9b0df2d085388e3 Mon Sep 17 00:00:00 2001 From: hornik Date: Fri, 14 Jun 2024 04:59:36 +0000 Subject: [PATCH 219/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86736 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index 0abc40a3a33..8178f27fa33 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -571,7 +571,7 @@ function(file, pdf = FALSE, clean = FALSE, quiet = TRUE, ### ** .ORCID_iD_regexp .ORCID_iD_regexp <- - "([[:digit:]]{4}[-]){3}[[:digit:]]{3}[[:alnum:]]" + "[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[X0-9]$" ### ** .ORCID_iD_variants_regexp From d73dde9bda6a67300fa7b47314c422dfb8afce0c Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 14 Jun 2024 09:54:41 +0000 Subject: [PATCH 220/546] "typo" git-svn-id: https://svn.r-project.org/R/trunk@86741 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/man/head.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/utils/man/head.Rd b/src/library/utils/man/head.Rd index 24a69864067..2813d44b3e6 100644 --- a/src/library/utils/man/head.Rd +++ b/src/library/utils/man/head.Rd @@ -45,7 +45,7 @@ tail(x, \dots) \method{tail}{ftable}(x, n = 6L, keepnums = FALSE, addrownums, \dots) \method{tail}{function}(x, n = 6L, \dots) -.checkHT(function(n, d) +.checkHT(n, d) } \arguments{ \item{x}{an object} From 2afadfbdee1b623daefe8baf5dcb4db6501c7883 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 14 Jun 2024 11:45:48 +0000 Subject: [PATCH 221/546] Add PRSEEN and SET_PRSEEN to tools:::nonAPI. git-svn-id: https://svn.r-project.org/R/trunk@86742 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 13 +++++++------ src/library/tools/R/sotools.R | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index d2fd15c55ea..42f4ad4ed46 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -107,12 +107,13 @@ \item New API function \code{R_ParentEnv}. \item Some non-API entry points have been added to those reported - by \command{R CMD check}: \code{SYMVALUE}, \code{INTERNAL}, - \code{DDVAL}, \code{ENSURE_NAMEDMAX}, \code{NAMED}, - \code{COMPLEX0}, \code{REAL0}, \code{LEVELS}, \code{FRAME}, - \code{HASHTAB}, \code{IS_ASCII}, \code{IS_UTF8}. Any declarations - for these in public header files will be removed in the near - future, and they will be hidden where possible. + by \command{R CMD check}: \code{COMPLEX0}, \code{DDVAL}, + \code{ENSURE_NAMEDMAX}, \code{FRAME}, \code{HASHTAB}, + \code{INTERNAL}, \code{IS_ASCII}, \code{IS_UTF8}, \code{LEVELS}, + \code{NAMED}, \code{PRSEEN}, \code{REAL0}, \code{SET_PRSEEN}, and + \code{SYMVALUE}. Any declarations for these in public header files + will be removed in the near future, and they will be hidden where + possible. } } diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index fd0530d491b..c345ddbc569 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -626,7 +626,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "tql2_", "tqlrat_", "tred1_", "tred2_", "utf8locale", "yylloc", "R_opendir", "R_readdir", "R_closedir", # "signrank_free", "wilcox_free" are API only from 4.2.0 - "ENSURE_NAMEDMAX", "IS_ASCII", "IS_UTF8", + "ENSURE_NAMEDMAX", "IS_ASCII", "IS_UTF8", "SET_PRSEEN", ## Rinterface.h, Rembedded.h, R_ext/{RStartup,eventloop}.h "AllDevicesKilled", "R_CStackLimit", "R_CStackStart", @@ -661,7 +661,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "ptr_R_savehistory", "ptr_do_dataentry", "ptr_do_dataviewer", "ptr_do_selectlist", "readconsolecfg", "removeInputHandler", "run_Rmainloop", "setup_Rmainloop", - "DDVAL", "NAMED", "INTERNAL", "SYMVALUE", + "DDVAL", "NAMED", "INTERNAL", "SYMVALUE", "PRSEEN", "REAL0", "COMPLEX0", "LEVELS", "FRAME", "HASHTAB", ## non-API, removed in R 4.5.0 and long deprecated in R_ext/RS.h (and as call_S in S.h) From 874f8bdf9619e5d16adc18a6978d60bbd56a5600 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 14 Jun 2024 12:39:05 +0000 Subject: [PATCH 222/546] Add ddfind to tools:::nonAPI. git-svn-id: https://svn.r-project.org/R/trunk@86743 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 14 +++++++------- src/library/tools/R/sotools.R | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 42f4ad4ed46..94e04704eb1 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -107,13 +107,13 @@ \item New API function \code{R_ParentEnv}. \item Some non-API entry points have been added to those reported - by \command{R CMD check}: \code{COMPLEX0}, \code{DDVAL}, - \code{ENSURE_NAMEDMAX}, \code{FRAME}, \code{HASHTAB}, - \code{INTERNAL}, \code{IS_ASCII}, \code{IS_UTF8}, \code{LEVELS}, - \code{NAMED}, \code{PRSEEN}, \code{REAL0}, \code{SET_PRSEEN}, and - \code{SYMVALUE}. Any declarations for these in public header files - will be removed in the near future, and they will be hidden where - possible. + by \command{R CMD check}: \code{COMPLEX0}, \code{ddfind}, + \code{DDVAL}, \code{ENSURE_NAMEDMAX}, \code{FRAME}, + \code{HASHTAB}, \code{INTERNAL}, \code{IS_ASCII}, \code{IS_UTF8}, + \code{LEVELS}, \code{NAMED}, \code{PRSEEN}, \code{REAL0}, + \code{SET_PRSEEN}, and \code{SYMVALUE}. Any declarations for these + in public header files will be removed in the near future, and + they will be hidden where possible. } } diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index c345ddbc569..56009b48b45 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -627,6 +627,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "R_opendir", "R_readdir", "R_closedir", # "signrank_free", "wilcox_free" are API only from 4.2.0 "ENSURE_NAMEDMAX", "IS_ASCII", "IS_UTF8", "SET_PRSEEN", + "ddfind", ## Rinterface.h, Rembedded.h, R_ext/{RStartup,eventloop}.h "AllDevicesKilled", "R_CStackLimit", "R_CStackStart", From cd7ed3e7428559c3043e4a21bb9c48a3cd7e93ce Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 14 Jun 2024 15:32:40 +0000 Subject: [PATCH 223/546] Add ENVFLAGS to tools:::nonAPI. git-svn-id: https://svn.r-project.org/R/trunk@86744 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 12 ++++++------ src/library/tools/R/sotools.R | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 94e04704eb1..9ddac6aedf3 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -108,12 +108,12 @@ \item Some non-API entry points have been added to those reported by \command{R CMD check}: \code{COMPLEX0}, \code{ddfind}, - \code{DDVAL}, \code{ENSURE_NAMEDMAX}, \code{FRAME}, - \code{HASHTAB}, \code{INTERNAL}, \code{IS_ASCII}, \code{IS_UTF8}, - \code{LEVELS}, \code{NAMED}, \code{PRSEEN}, \code{REAL0}, - \code{SET_PRSEEN}, and \code{SYMVALUE}. Any declarations for these - in public header files will be removed in the near future, and - they will be hidden where possible. + \code{DDVAL}, \code{ENSURE_NAMEDMAX}, \code{ENVFLAGS}, + \code{FRAME}, \code{HASHTAB}, \code{INTERNAL}, \code{IS_ASCII}, + \code{IS_UTF8}, \code{LEVELS}, \code{NAMED}, \code{PRSEEN}, + \code{REAL0}, \code{SET_PRSEEN}, and \code{SYMVALUE}. Any + declarations for these in public header files will be removed in + the near future, and they will be hidden where possible. } } diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 56009b48b45..62155a31c2b 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -608,7 +608,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "Rf_sortVector", "Rf_strIsASCII", "Rf_strchr", "Rf_strrchr", "Rf_ucstomb", "Rf_utf8towcs", "Rf_wcstoutf8", "Rg_PolledEvents", "Rg_set_col_ptrs", - "Rg_wait_usec", "Ri18n_iswctype", "Ri18n_wcswidth", + "Rf_wait_usec", "Ri18n_iswctype", "Ri18n_wcswidth", "Ri18n_wctype", "Ri18n_wcwidth", "Rsockclose", "Rsockconnect", "Rsocklisten", "Rsockopen", "Rsockread", "Rsockwrite", "Runzip", "UNIMPLEMENTED_TYPE", @@ -662,8 +662,6 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "ptr_R_savehistory", "ptr_do_dataentry", "ptr_do_dataviewer", "ptr_do_selectlist", "readconsolecfg", "removeInputHandler", "run_Rmainloop", "setup_Rmainloop", - "DDVAL", "NAMED", "INTERNAL", "SYMVALUE", "PRSEEN", - "REAL0", "COMPLEX0", "LEVELS", "FRAME", "HASHTAB", ## non-API, removed in R 4.5.0 and long deprecated in R_ext/RS.h (and as call_S in S.h) "call_R", @@ -682,6 +680,9 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "IS_GROWABLE", "SET_GROWABLE_BIT", "SET_NAMED", "R_PromiseExpr", "R_tryWrap", + "DDVAL", "NAMED", "INTERNAL", "SYMVALUE", "PRSEEN", + "REAL0", "COMPLEX0", "LEVELS", "FRAME", "HASHTAB", + "ENVFLAGS", ## in the non-API header R_ext/Connections.h "R_new_custom_connection", "R_ReadConnection", "R_WriteConnection", "R_GetConnection", From 17267c099dd01e43551dc538e1a419336314ab47 Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 14 Jun 2024 20:33:48 +0000 Subject: [PATCH 224/546] r86732 -> "qr.influence" is nonS3method git-svn-id: https://svn.r-project.org/R/trunk@86746 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/utils.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index 8178f27fa33..78f6767c17b 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -605,13 +605,13 @@ function(dir, add = FALSE) }), use.names = FALSE) } - + db <- data.frame(ID = c(ids1, ids2), Parent = c(rep_len("DESCRIPTION", length(ids1)), rep_len("inst/CITATION", length(ids2)))) - if(add) + if(add) db$Parent <- file.path(basename(dir), db$Parent) db } @@ -1980,7 +1980,7 @@ nonS3methods <- function(package) splusTimeDate = "sort.list", splusTimeSeries = "sort.list", stats = c("anova.lmlist", "expand.model.frame", "fitted.values", - "influence.measures", "lag.plot", "t.test", + "influence.measures", "lag.plot", "qr.influence", "t.test", "plot.spec.phase", "plot.spec.coherency"), stremo = "sigma.hat", supclust = c("sign.change", "sign.flip"), From c4d595f1af841c7bab641532a08ed9fe5c34f4ad Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 14 Jun 2024 21:46:34 +0000 Subject: [PATCH 225/546] Add a check for a non-NULL callback in unregisterOne to avoid a segfault. git-svn-id: https://svn.r-project.org/R/trunk@86747 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/engine.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/engine.c b/src/main/engine.c index 4bfc584dab5..0a39572cd8f 100644 --- a/src/main/engine.c +++ b/src/main/engine.c @@ -65,7 +65,8 @@ static GESystemDesc* registeredSystems[MAX_GRAPHICS_SYSTEMS]; */ static void unregisterOne(pGEDevDesc dd, int systemNumber) { - if (dd->gesd[systemNumber] != NULL) { + if (dd->gesd[systemNumber] != NULL && + dd->gesd[systemNumber]->callback != NULL) { (dd->gesd[systemNumber]->callback)(GE_FinaliseState, dd, R_NilValue); free(dd->gesd[systemNumber]); dd->gesd[systemNumber] = NULL; From 78ebe524cfd2058467e5d1699894d5563878f2f5 Mon Sep 17 00:00:00 2001 From: maechler Date: Sat, 15 Jun 2024 09:17:46 +0000 Subject: [PATCH 226/546] on `na.print` (PR#18701) git-svn-id: https://svn.r-project.org/R/trunk@86748 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/print.default.Rd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/library/base/man/print.default.Rd b/src/library/base/man/print.default.Rd index 08df5fd9a6b..cb929f958cd 100644 --- a/src/library/base/man/print.default.Rd +++ b/src/library/base/man/print.default.Rd @@ -51,7 +51,8 @@ \details{ The default for printing \code{NA}s is to print \code{NA} (without quotes) unless this is a character \code{NA} \emph{and} \code{quote = - FALSE}, when \samp{} is printed. + FALSE}, when \samp{} is printed. When \code{na.print} is not \code{NULL}, + it handles how character \code{NA} is displayed, with no interaction with \code{quote}. The same number of decimal places is used throughout a vector. This means that \code{digits} specifies the minimum number of significant From b5d805657449738402244e92f69a403a5ed0f555 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 16 Jun 2024 08:43:59 +0000 Subject: [PATCH 227/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86750 00db46b3-68df-0310-9c12-caf00c1e9a41 --- share/dictionaries/R_manuals.rds | Bin 1334 -> 1345 bytes share/dictionaries/R_manuals.txt | 2 ++ 2 files changed, 2 insertions(+) diff --git a/share/dictionaries/R_manuals.rds b/share/dictionaries/R_manuals.rds index b7327cbe7ba49da40edebd34a091491ff68b788f..ed0e2f68c1704e9fac4e0cbd4225360976fb243d 100644 GIT binary patch literal 1345 zcmV-H1-|+piwFP!00000165buRwFkI&N&JB5A50Z=zVWXv#@l@!Xa$iy>vXDiBCMX z*FOp2Df>v3hq2^b0He>AY)PLb@$Y;v7z_uaEBFmRgTd90*Sp_-hmTM2^WR`Jn8Du( z;~_HTdvVOF%IGZ3m{NwbU|bK(5y)E>EC!bbJpB3ez3*`QDx&9 z@dS9GSt|&Tp=H*h%6J!>TE6wtbQh%x5^p=??NeW2+L&MsGN?G9-uv zNxo0`o;fcYxr z>x{&asjMU3ARu{VR>R#B$I#zeDq&gJXMdCI&pwDYlbI0YU@brLnq>+i!r?O0)vs#iV(c#Uq#kFDq`UtUJqc-Z1|F ztVFK#DmIgH`1SeE?6Rzcf$Q15){nY|K8-!Z|g5P z&<9`-IW#?pGf>@QT9tUasA-c&sSgy8iMkN4K#Xs=X3Qa4j2(zJaWmgv8SjC59&L{m z@Hz@q?<7=j*+C?(=9^_1aWbUejEGzCVn3!PrhI;#ZuvkuS^kPDw%$(>=2?;)Ph zDI9LU+DLu>51uDI7fLZLSWeI8;dO)G+n?K9x7r9ryMOORc2*r8_D(RO@>E}L8a=IV zGjk_TR_NR9ItMI?_m5f8fVBOw&8b~LpV=FoN@}ha3(H(;7)24jNf3m=Nqp% zv8g*?vWL&N=nP9@XC|EWsm0Cb%o{fHA z7UtQn$l&o36#QqpL-6D!hB zaxupw&jpMmW%s`6!cj#S13oS7pO1hDjZ(bNnmfQK(KLavOxY;??RZsM&F^vJG#fT9f@;$mhP`vAdng=Att z1Hna3)z`-zR}7d`BF2{ed;tjDU0S;55}{&LNSOE)VSYek6Tkv%NIbWx(&AAcVo|rd zBKAgX3Q!D1@n~ky->qUL06BO!x==Aj!2l>TXXglDsuFUL)TNV5^WwA@$)bZvu_*bI z?uiIwLNB8EsCPgWVnWm~{ImiG!g&Y4yh(hA{m=z;p(21!^bi*Sq&`x59(Ao)(-0XV zbikC}bX2LC(%BXT5H!H$wks^&$pnPkemKZs2aAuTo?tfI0dfV0vU=Ay892 zLOhJSJba!(if={=7N4ZwD~Ll@O2be0?*>xpxM2Mz!L D+ud{{ literal 1334 zcmV-61*_E=8aJW{*ViX$$` z@FH3M$bM77wE$2Lwijm!ECC!`{O`2a>-BqsEBFmRz24Q2*Sp_-hlfw_^Ivb!o50_Z zsA3X2oW-H2Yim%N2(4`;qV;EBN&p_2i4?82qE@CkLyHWxqEQu`KB4ADRC{NAlrhp(!3JJntTWKj@Y8a(CAGioQfF| zQL*o%YA1Y<5${r2=_|F-Xlq)5+deo^v31)zrNu^R6;FJubtwu~ysoUNRsK|YwIQHe z)v%V?THgv&eBT_bK2UHzRW_L@y)rR@wFCQ|0)!vDDL;u=>EXB*QAX90N3}esmuwLN zYK%EAs|!p0<-;AlR@<%g(o{@{d2Np-h}LPw2FvwRp!W%0U78%$C#^OpeU_?`rj|LF zHmKq{19=b{b>tfa1m8@yaQDnH@^`DWbRzE1-z-QIm86d?0KxlWW%t89n!c4(=k!yh3P5-ZlS9<(=g^%BsUofb9 zUs5U)T?Z}iUEeR33h5MAaW-e21gfM$Vg4>fQ& zNmB15Qg6jxW?tgWP^LJy!Z#f!sp*V?J>o*=EThgM1L0&MbbreG=T=qT3SaFYo-h?W z9lu&BbN>&0PlZZqEsPYHp4G$aik{a$*Vv=l1P%IJ+eLO39UgaH3a0JYTpk)cEpL&f zqbDcL?Rtp;%i{ebDq4`%Kh~Jq8O)TOHMxCaXP7zR^Kd8{?oEau3|@tc_C_#Ih>^>a zfRf#Rz9na$mv@v02LnR7=!*`U#~YM6k;r+`w1Nx)&!Vu4(I`F_v0w3$YpKV_qhr=mHzq;+oh$UK+Au57}S zUr9jmG8F+(@EQVz$$eSguGaYa+DmFjMgM_Fh*)uF8T&jQJl$*rp5&zQ>rSj$Kg-3= zl0BEOew35?rVB@%VCG6<&li$Skqkti zD(=1^Z7MB*NhM-kIlE_oz}=POd(H_e)`E=5UkP>vGByG%iiX8gn>#Ii>O(C0cGtw- zm`xFyp)87K0<+v{Q38;IcWVk2Yc(u;3OPF^fKru_z2b?SW!??PXOS&>*b0l5Kk7La&?{YG;;Zidv zuPxdgXy&?x5r6?9ATW}9chTA=8G%ya#*~3Z!7fGZg%M8Rbq2A@$l5%k0oL7uq!5H| zg`&M3WUxewJF6nh>?<&uX;6(+YV&TDZefaYWJZ8_-tNZ-0Tv>U&;!K7`pb_`5#;zH sQgHUD!cIdRP${oE-9HjUpreNoT>9Ptyi*K*{;_)eAAn6NnBffo07sm9VE_OC diff --git a/share/dictionaries/R_manuals.txt b/share/dictionaries/R_manuals.txt index de2093d497b..5a4a376ccab 100644 --- a/share/dictionaries/R_manuals.txt +++ b/share/dictionaries/R_manuals.txt @@ -59,6 +59,7 @@ hardcopy HPC ideographic initializer +initializers inlining integrand integrators @@ -174,6 +175,7 @@ typedef typedefs unbundle uncomment +uncompiled undefine unescaped unevaluated From ad2e53f5fa576bd627ba0d766dbe1f29bdf16c9e Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 16 Jun 2024 08:44:19 +0000 Subject: [PATCH 228/546] Spelling. git-svn-id: https://svn.r-project.org/R/trunk@86751 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 2 +- doc/manual/R-exts.texi | 2 +- src/library/tools/man/doitools.Rd | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 9ddac6aedf3..7453d4248c2 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -23,7 +23,7 @@ \item New functions \code{check_package_urls()} and \code{check_package_dois()} in package \pkg{tools} for checking - URLs and DOIs in package sources. + URLs and \abbr{DOI}s in package sources. \item New \code{head()} and \code{tail()} methods for class \code{"ts"} time series, proposed by Spencer Graves on R-devel. diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index ba0e7d5c634..05a28c996c9 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13448,7 +13448,7 @@ to the @R{} function @code{getOption} without specifying a default. @code{int}. @apifun GetOptionWidth The C function @code{nlevels} returns the number of levels of a factor. -Unlike its @R{} counterpart ir always returns zero for non-factors. +Unlike its @R{} counterpart it always returns zero for non-factors. @eapifun nlevels For vectors the C function @code{duplicated} returns a logical vector diff --git a/src/library/tools/man/doitools.Rd b/src/library/tools/man/doitools.Rd index c2b6b241c55..dc145b3eecd 100644 --- a/src/library/tools/man/doitools.Rd +++ b/src/library/tools/man/doitools.Rd @@ -1,8 +1,8 @@ \name{doitools} \alias{check_package_dois} -\title{Check Package DOIs} +\title{Check Package \abbr{DOI}s} \description{ - Check DOIs in package sources. + Check \abbr{DOI}s in package sources. } \usage{ check_package_dois(dir, verbose = FALSE) @@ -14,14 +14,14 @@ check_package_dois(dir, verbose = FALSE) progress.} } \details{ - Checking DOIs is performed in parallel using \CRANpkg{curl} (so this + Checking \abbr{DOI}s is performed in parallel using \CRANpkg{curl} (so this must be installed for checking). - The DOIs checked are extracted from the package \file{DESCRIPTION} - (\samp{} URIs in the \samp{Description} field), Rd and + The \abbr{DOI}s checked are extracted from the package \file{DESCRIPTION} + (\samp{} \abbr{URI}s in the \samp{Description} field), Rd and \file{CITATION} files. - The DOIs are checked via \samp{HEAD} requests to the DOI system Proxy + The \abbr{DOI}s are checked via \samp{HEAD} requests to the DOI system Proxy Server REST API. } \value{ From 66292483683487a651e33e5fb9b63bc405e15015 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 16 Jun 2024 08:46:05 +0000 Subject: [PATCH 229/546] Also give DOIs in auto-generated citations for CRAN packages. git-svn-id: https://svn.r-project.org/R/trunk@86752 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index edf11d68f74..96e0f8f674b 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -1388,9 +1388,13 @@ function(package = "base", lib.loc = NULL, auto = NULL) ) ## CRAN-style repositories: CRAN, R-Forge, Bioconductor - if(identical(meta$Repository, "CRAN")) + if(identical(meta$Repository, "CRAN")) { z$url <- sprintf("https://CRAN.R-project.org/package=%s", package) + if(!is.na(d <- meta[["Date/Publication"]]) && + (as.Date(d) <= Sys.Date() - 1L)) + z$doi <- sprintf("10.32614/CRAN.package.%s", package) + } if(identical(meta$Repository, "R-Forge")) { z$url <- if(!is.null(rfp <- meta$"Repository/R-Forge/Project")) From 9f4a06566aaeedf98382086d20d2a852c99ae801 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 16 Jun 2024 10:46:03 +0000 Subject: [PATCH 230/546] Add function name in some argument check error messages. git-svn-id: https://svn.r-project.org/R/trunk@86753 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/memory.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/memory.c b/src/main/memory.c index 5497a92b648..8bee4358200 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4548,8 +4548,8 @@ void (SET_MISSING)(SEXP x, int v) { SET_MISSING(CHKCONS(x), v); } /* some internals seem to depend on allowing a LISTSXP */ #define CHKCLOSXP(x) \ if (TYPEOF(x) != CLOSXP && TYPEOF(x) != LISTSXP) \ - error(_("argument of type %s is not a closure"), \ - sexptype2char(TYPEOF(x))) + error(_("%s: argument of type %s is not a closure"), \ + __func__, sexptype2char(TYPEOF(x))) SEXP (FORMALS)(SEXP x) { CHKCLOSXP(x); return CHK(FORMALS(CHK(x))); } SEXP (BODY)(SEXP x) { CHKCLOSXP(x); return CHK(BODY(CHK(x))); } SEXP (CLOENV)(SEXP x) { CHKCLOSXP(x); return CHK(CLOENV(CHK(x))); } @@ -4579,8 +4579,8 @@ void (SET_PRIMOFFSET)(SEXP x, int v) { SET_PRIMOFFSET(CHK(x), v); } /* looks like R_NilValue is also being passed to tome of these */ #define CHKSYMSXP(x) \ if (x != R_NilValue && TYPEOF(x) != SYMSXP) \ - error(_("argument of type %s is not a symbol or NULL"), \ - sexptype2char(TYPEOF(x))) + error(_("%s: argument of type %s is not a symbol or NULL"), \ + __func__, sexptype2char(TYPEOF(x))) SEXP (PRINTNAME)(SEXP x) { CHKSYMSXP(x); return CHK(PRINTNAME(CHK(x))); } SEXP (SYMVALUE)(SEXP x) { CHKSYMSXP(x); return CHK(SYMVALUE(CHK(x))); } SEXP (INTERNAL)(SEXP x) { CHKSYMSXP(x); return CHK(INTERNAL(CHK(x))); } @@ -4610,8 +4610,9 @@ attribute_hidden void (SET_DDVAL)(SEXP x, int v) { SET_DDVAL(CHK(x), v); } /* Environment Accessors */ /* looks like R_NilValue is still showing up in internals */ #define CHKENVSXP(x) \ - if (TYPEOF(x) != ENVSXP && x != R_NilValue) \ - error(_("argument is not an environment or NULL")) + if (TYPEOF(x) != ENVSXP && x != R_NilValue) \ + error(_("%s: argument of type %s is not an environment or NULL"), \ + __func__, sexptype2char(TYPEOF(x))) SEXP (FRAME)(SEXP x) { CHKENVSXP(x); return CHK(FRAME(CHK(x))); } SEXP (ENCLOS)(SEXP x) { CHKENVSXP(x); return CHK(ENCLOS(CHK(x))); } SEXP (HASHTAB)(SEXP x) { CHKENVSXP(x); return CHK(HASHTAB(CHK(x))); } From 93a50a28d1dc930000ffd1067727e766adbde436 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 16 Jun 2024 12:22:43 +0000 Subject: [PATCH 231/546] Match default case in R_signalErrorConditionEx() more closely to base::stop(). git-svn-id: https://svn.r-project.org/R/trunk@86754 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/errors.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/errors.c b/src/main/errors.c index c6fe27a7ec6..7c81df69e26 100644 --- a/src/main/errors.c +++ b/src/main/errors.c @@ -2654,7 +2654,7 @@ attribute_hidden /* for now */ NORET void R_signalErrorConditionEx(SEXP cond, SEXP call, int exitOnly) { /* caller must make sure that 'cond' and 'call' are protected. */ - R_signalCondition(cond, call, FALSE, exitOnly); + R_signalCondition(cond, call, TRUE, exitOnly); /* the first element of 'cond' must be a scalar string to be used as the error message in default error processing. */ @@ -2664,8 +2664,7 @@ NORET void R_signalErrorConditionEx(SEXP cond, SEXP call, int exitOnly) if (TYPEOF(elt) != STRSXP || LENGTH(elt) != 1) error(_("first element of condition object must be a scalar string")); - /* handler stack has been unwound so this uses the default handler */ - errorcall(call, "%s", CHAR(STRING_ELT(elt, 0))); + errorcall_dflt(call, "%s", translateChar(STRING_ELT(elt, 0))); } attribute_hidden /* for now */ From fe754bc7e7192648c70a16dd8ff64f182ac2cb93 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 16 Jun 2024 14:18:20 +0000 Subject: [PATCH 232/546] Use classed warning for partial matching of arguments and attributes (PR18708). Based on patch provided in PR 18708 by Michael Chirico. git-svn-id: https://svn.r-project.org/R/trunk@86755 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Defn.h | 6 ++++ src/main/attrib.c | 22 ++++++++---- src/main/errors.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++ src/main/match.c | 13 ++++--- 4 files changed, 114 insertions(+), 12 deletions(-) diff --git a/src/include/Defn.h b/src/include/Defn.h index 30dfba5561f..5df339411ac 100644 --- a/src/include/Defn.h +++ b/src/include/Defn.h @@ -2177,6 +2177,7 @@ SEXP R_GetTraceback(int); // including deparse()ing SEXP R_GetTracebackOnly(int);// no deparse()ing NORET void R_signalErrorCondition(SEXP cond, SEXP call); NORET void R_signalErrorConditionEx(SEXP cond, SEXP call, int exitOnly); +void R_signalWarningCondition(SEXP cond); SEXP R_vmakeErrorCondition(SEXP call, const char *classname, const char *subclassname, int nextra, const char *format, va_list ap) @@ -2186,6 +2187,11 @@ SEXP R_makeErrorCondition(SEXP call, const char *classname, const char *subclassname, int nextra, const char *format, ...) R_PRINTF_FORMAT(5,0); +SEXP R_makeWarningCondition(SEXP call, + const char *classname, const char *subclassname, + int nextra, const char *format, ...) + R_PRINTF_FORMAT(5,0); +SEXP R_makePartialMatchWarningCondition(SEXP call, SEXP argument, SEXP formal); void R_setConditionField(SEXP cond, R_xlen_t idx, const char *name, SEXP val); SEXP R_makeNotSubsettableError(SEXP x, SEXP call); diff --git a/src/main/attrib.c b/src/main/attrib.c index 75b881002cd..02597c88e2e 100644 --- a/src/main/attrib.c +++ b/src/main/attrib.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1997--2023 The R Core Team + * Copyright (C) 1997--2024 The R Core Team * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka * * This program is free software; you can redistribute it and/or modify @@ -1524,9 +1524,13 @@ attribute_hidden SEXP do_attr(SEXP call, SEXP op, SEXP args, SEXP env) partial match on "names" */ tag = R_NamesSymbol; PROTECT(t = getAttrib(s, tag)); - if(t != R_NilValue && R_warn_partial_match_attr) - warningcall(call, _("partial match of '%s' to '%s'"), str, - CHAR(PRINTNAME(tag))); + if(t != R_NilValue && R_warn_partial_match_attr) { + SEXP cond = + R_makePartialMatchWarningCondition(call, install(str), tag); + PROTECT(cond); + R_signalWarningCondition(cond); + UNPROTECT(1); + } UNPROTECT(2); return t; } @@ -1547,9 +1551,13 @@ attribute_hidden SEXP do_attr(SEXP call, SEXP op, SEXP args, SEXP env) UNPROTECT(1); return R_NilValue; } - if (match == PARTIAL && R_warn_partial_match_attr) - warningcall(call, _("partial match of '%s' to '%s'"), str, - CHAR(PRINTNAME(tag))); + if (match == PARTIAL && R_warn_partial_match_attr) { + SEXP cond = + R_makePartialMatchWarningCondition(call, install(str), tag); + PROTECT(cond); + R_signalWarningCondition(cond); + UNPROTECT(1); + } ans = getAttrib(s, tag); UNPROTECT(1); diff --git a/src/main/errors.c b/src/main/errors.c index 7c81df69e26..bb7dc0b3b1d 100644 --- a/src/main/errors.c +++ b/src/main/errors.c @@ -2673,6 +2673,22 @@ NORET void R_signalErrorCondition(SEXP cond, SEXP call) R_signalErrorConditionEx(cond, call, FALSE); } +attribute_hidden /* for now */ +void R_signalWarningCondition(SEXP cond) +{ + static SEXP condSym = NULL; + static SEXP expr = NULL; + if (expr == NULL) { + condSym = install("cond"); + expr = R_ParseString("warning(cond)"); + R_PreserveObject(expr); + } + SEXP env = PROTECT(R_NewEnv(R_BaseNamespace, FALSE, 0)); + defineVar(condSym, cond, env); + evalKeepVis(expr, env); + UNPROTECT(1); /* env*/ +} + /* creating internal error conditions */ @@ -2846,6 +2862,75 @@ attribute_hidden SEXP R_getNodeStackOverflowError(void) return R_nodeStackOverflowError; } +attribute_hidden /* for now */ +SEXP R_vmakeWarningCondition(SEXP call, + const char *classname, const char *subclassname, + int nextra, const char *format, va_list ap) +{ + if (call == R_CurrentExpression) + /* behave like warning() */ + call = getCurrentCall(); + PROTECT(call); + int nelem = nextra + 2; + SEXP cond = PROTECT(allocVector(VECSXP, nelem)); + + Rvsnprintf_mbcs(emsg_buf, BUFSIZE, format, ap); + SET_VECTOR_ELT(cond, 0, mkString(emsg_buf)); + SET_VECTOR_ELT(cond, 1, call); + + SEXP names = allocVector(STRSXP, nelem); + setAttrib(cond, R_NamesSymbol, names); + SET_STRING_ELT(names, 0, mkChar("message")); + SET_STRING_ELT(names, 1, mkChar("call")); + + SEXP klass = allocVector(STRSXP, subclassname == NULL ? 3 : 4); + setAttrib(cond, R_ClassSymbol, klass); + if (subclassname == NULL) { + SET_STRING_ELT(klass, 0, mkChar(classname)); + SET_STRING_ELT(klass, 1, mkChar("warning")); + SET_STRING_ELT(klass, 2, mkChar("condition")); + } + else { + SET_STRING_ELT(klass, 0, mkChar(subclassname)); + SET_STRING_ELT(klass, 1, mkChar(classname)); + SET_STRING_ELT(klass, 2, mkChar("warning")); + SET_STRING_ELT(klass, 3, mkChar("condition")); + } + + UNPROTECT(2); /* cond, call */ + + return cond; +} + +attribute_hidden /* for now */ +SEXP R_makeWarningCondition(SEXP call, + const char *classname, const char *subclassname, + int nextra, const char *format, ...) +{ + va_list(ap); + va_start(ap, format); + SEXP cond = R_vmakeWarningCondition(call, classname, subclassname, + nextra, format, ap); + va_end(ap); + return cond; +} + +SEXP R_makePartialMatchWarningCondition(SEXP call, SEXP argument, SEXP formal) +{ + SEXP cond = + R_makeWarningCondition(call, "partialMatchWarning", NULL, 2, + _("partial argument match of '%s' to '%s'"), + CHAR(PRINTNAME(argument)),//EncodeChar?? + CHAR(PRINTNAME(formal)));//EncodeChar?? + PROTECT(cond); + R_setConditionField(cond, 2, "argument", argument); + R_setConditionField(cond, 3, "formal", formal); + // idealy we would want the function/object in a field also + UNPROTECT(1); /* cond */ + return cond; +} + + #define PROT_SO_MSG _("protect(): protection stack overflow") #define EXPR_SO_MSG _("evaluation nested too deeply: infinite recursion / options(expressions=)?") #define NODE_SO_MSG _("node stack overflow") diff --git a/src/main/match.c b/src/main/match.c index 76f74f8766e..dca4533bf43 100644 --- a/src/main/match.c +++ b/src/main/match.c @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 1998-2020 The R Core Team. + * Copyright (C) 1998-2024 The R Core Team. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -274,10 +274,13 @@ attribute_hidden SEXP matchArgs_NR(SEXP formals, SEXP supplied, SEXP call) _("formal argument \"%s\" matched by multiple actual arguments"), CHAR(PRINTNAME(TAG(f)))); if (R_warn_partial_match_args) { - warningcall(call, - _("partial argument match of '%s' to '%s'"), - CHAR(PRINTNAME(TAG(b))), - CHAR(PRINTNAME(TAG(f))) ); + SEXP cond = + R_makePartialMatchWarningCondition(call, + TAG(b), + TAG(f)); + PROTECT(cond); + R_signalWarningCondition(cond); + UNPROTECT(1); } SETCAR(a, CAR(b)); if (CAR(b) != R_MissingArg) SET_MISSING(a, 0); From 9c6d24a940f7503abe0fa503942136005de03b55 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 16 Jun 2024 15:16:54 +0000 Subject: [PATCH 233/546] Added. git-svn-id: https://svn.r-project.org/R/trunk@86756 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/orcidtools.R | 70 ++++++++++++++++++++++++++++++++ src/library/tools/R/utils.R | 48 ---------------------- 2 files changed, 70 insertions(+), 48 deletions(-) create mode 100644 src/library/tools/R/orcidtools.R diff --git a/src/library/tools/R/orcidtools.R b/src/library/tools/R/orcidtools.R new file mode 100644 index 00000000000..28d92e8bdbd --- /dev/null +++ b/src/library/tools/R/orcidtools.R @@ -0,0 +1,70 @@ +# File src/library/tools/R/utils.R +# Part of the R package, https://www.R-project.org +# +# Copyright (C) 2024 The R Core Team +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License is available at +# https://www.R-project.org/Licenses/ + +### ** .ORCID_iD_regexp + +.ORCID_iD_regexp <- + "[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[X0-9]$" + +### ** .ORCID_iD_variants_regexp + +.ORCID_iD_variants_regexp <- + sprintf("^?$", .ORCID_iD_regexp) + +.ORCID_iD_db_from_package_sources <- +function(dir, add = FALSE) +{ + meta <- .get_package_metadata(dir, FALSE) + ids1 <- ids2 <- character() + if(!is.na(aar <- meta["Authors@R"])) { + aar <- tryCatch(utils:::.read_authors_at_R_field(aar), + error = identity) + if(!inherits(aar, "error")) { + ids1 <- unlist(lapply(aar, + function(e) { + e <- e$comment + e[names(e) == "ORCID"] + }), + use.names = FALSE) + } + } + if(file.exists(cfile <- file.path(dir, "inst", "CITATION"))) { + cinfo <- .read_citation_quietly(cfile, meta) + if(!inherits(cinfo, "error")) + ids2 <- unlist(lapply(cinfo$author, + function(e) { + e <- e$comment + e[names(e) == "ORCID"] + }), + use.names = FALSE) + } + + db <- data.frame(ID = c(ids1, ids2), + Parent = c(rep_len("DESCRIPTION", + length(ids1)), + rep_len("inst/CITATION", + length(ids2)))) + if(add) + db$Parent <- file.path(basename(dir), db$Parent) + db +} + +### Local variables: *** +### mode: outline-minor *** +### outline-regexp: "### [*]+" *** +### End: *** diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index 78f6767c17b..cca002e3106 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -568,54 +568,6 @@ function(file, pdf = FALSE, clean = FALSE, quiet = TRUE, ### * Internal utility variables. -### ** .ORCID_iD_regexp - -.ORCID_iD_regexp <- - "[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[X0-9]$" - -### ** .ORCID_iD_variants_regexp - -.ORCID_iD_variants_regexp <- - sprintf("^?$", .ORCID_iD_regexp) - -.ORCID_iD_db_from_package_sources <- -function(dir, add = FALSE) -{ - meta <- .get_package_metadata(dir, FALSE) - ids1 <- ids2 <- character() - if(!is.na(aar <- meta["Authors@R"])) { - aar <- tryCatch(utils:::.read_authors_at_R_field(aar), - error = identity) - if(!inherits(aar, "error")) { - ids1 <- unlist(lapply(aar, - function(e) { - e <- e$comment - e[names(e) == "ORCID"] - }), - use.names = FALSE) - } - } - if(file.exists(cfile <- file.path(dir, "inst", "CITATION"))) { - cinfo <- .read_citation_quietly(cfile, meta) - if(!inherits(cinfo, "error")) - ids2 <- unlist(lapply(cinfo$author, - function(e) { - e <- e$comment - e[names(e) == "ORCID"] - }), - use.names = FALSE) - } - - db <- data.frame(ID = c(ids1, ids2), - Parent = c(rep_len("DESCRIPTION", - length(ids1)), - rep_len("inst/CITATION", - length(ids2)))) - if(add) - db$Parent <- file.path(basename(dir), db$Parent) - db -} - ### ** .vc_dir_names ## Version control directory names: CVS, .svn (Subversion), .arch-ids From 6a2ea9f2328c309a272313ec4faa66d8f28713fd Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 16 Jun 2024 15:18:49 +0000 Subject: [PATCH 234/546] Initialize available.packages() 'fields' arg from 'available_packages_fields' option. git-svn-id: https://svn.r-project.org/R/trunk@86757 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/packages.R | 5 +++-- src/library/utils/man/available.packages.Rd | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/library/utils/R/packages.R b/src/library/utils/R/packages.R index c689628038c..24ec1ec2f41 100644 --- a/src/library/utils/R/packages.R +++ b/src/library/utils/R/packages.R @@ -18,8 +18,9 @@ available.packages <- function(contriburl = contrib.url(repos, type), method, - fields = NULL, type = getOption("pkgType"), - filters = NULL, repos = getOption("repos"), + fields = getOption("available_packages_fields"), + type = getOption("pkgType"), filters = NULL, + repos = getOption("repos"), ignore_repo_cache = FALSE, max_repo_cache_age, quiet = TRUE, ...) { diff --git a/src/library/utils/man/available.packages.Rd b/src/library/utils/man/available.packages.Rd index abba4ed9af2..48c4436c141 100644 --- a/src/library/utils/man/available.packages.Rd +++ b/src/library/utils/man/available.packages.Rd @@ -16,8 +16,9 @@ } \usage{ available.packages(contriburl = contrib.url(repos, type), method, - fields = NULL, type = getOption("pkgType"), - filters = NULL, repos = getOption("repos"), + fields = getOption("available_packages_fields"), + type = getOption("pkgType"), filters = NULL, + repos = getOption("repos"), ignore_repo_cache = FALSE, max_repo_cache_age, quiet = TRUE, \dots) } From ecca3a3cfb7cab466dea3f766ce1c7cf17db9e39 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 16 Jun 2024 16:17:14 +0000 Subject: [PATCH 235/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86758 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/orcidtools.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/orcidtools.R b/src/library/tools/R/orcidtools.R index 28d92e8bdbd..81d37ea5afd 100644 --- a/src/library/tools/R/orcidtools.R +++ b/src/library/tools/R/orcidtools.R @@ -19,7 +19,7 @@ ### ** .ORCID_iD_regexp .ORCID_iD_regexp <- - "[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[X0-9]$" + "[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[X0-9]" ### ** .ORCID_iD_variants_regexp From 110f26cc11a3f2990268434156b0d7768791ee73 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 16 Jun 2024 16:17:48 +0000 Subject: [PATCH 236/546] Optionally note Rd xrefs with missing package anchors. git-svn-id: https://svn.r-project.org/R/trunk@86759 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 2 +- src/library/tools/R/check.R | 41 ++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index 2dec71a3533..8b3248ae6c9 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -8726,7 +8726,7 @@ function(x, ...) "Authors@R field should be a call to person(), or combine such calls." }, if(length(y <- x$authors_at_R_message)) { - paste(c("Authors@R field gives persons with deprecated elements:", + paste(c("Authors@R field gives persons with deprecated or bad elements:", paste0(" ", y)), collapse = "\n") }, diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index ccb1a49cc64..219f6625064 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -2444,13 +2444,52 @@ add_dummies <- function(dir, Log) sprintf("tools:::.check_Rd_xrefs(package = \"%s\")\n", pkgname) else sprintf("tools:::.check_Rd_xrefs(dir = \"%s\")\n", pkgdir)) + any <- FALSE out <- R_runR0(Rcmd, R_opts2, "R_DEFAULT_PACKAGES=NULL") if (length(out)) { if (!all(grepl("(Package[s]? unavailable to check|Unknown package.*in Rd xrefs|Undeclared package.*in Rd xrefs)", out))) warningLog(Log) else noteLog(Log) + any <- TRUE printLog0(Log, paste(c(out, ""), collapse = "\n")) - } else resultLog(Log, "OK") + } + + ## The above checks whether Rd xrefs can be resolved within + ## the package itself, the base and recommended packages, + ## and its Imports and Depends. Nowadays, we prefer that Rd + ## xrefs to aliases not in the package itself and the base + ## packages have package anchors so there is no ambiguity in + ## resolving the xrefs, Hence, at least optionally note the + ## xrefs missing such package anchors. + ## + ## However, .Rd_xrefs_with_missing_package_anchors() uses + ## the package source directory whereas the above uses + ## .Rd_check_xrefs() typically for installed packages, so we + ## do the optional check separately for now. + + if(config_val_to_logical(Sys.getenv("_R_CHECK_XREFS_NOTE_MISSING_PACKAGE_ANCHORS_", + "FALSE"))) { + bad <- tryCatch(.Rd_xrefs_with_missing_package_anchors(pkgdir), + error = identity) + if(!inherits(bad, "error") && length(bad)) { + bad <- split(bad[, "Target"], bad[, "Source"]) + msg <- c(if(any) "", + strwrap("Found the following Rd file(s) with Rd \\link{} targets missing package anchors:"), + sprintf(" %s: %s", + names(bad), + strwrap(vapply(bad, paste, "", + collapse = ", "), + exdent = 4L, indent = 0L)), + strwrap("Please provide package anchors for all Rd \\link{} targets not in the package itself and the base packages.")) + if(!any) { + noteLog(Log) + any <- TRUE + } + printLog0(Log, paste(c(msg, ""), collapse = "\n")) + } + } + if(!any) + resultLog(Log, "OK") } ## Check for missing documentation entries. From 1b7be91fca5da11cfdedceda9f2b8312089a5688 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 16 Jun 2024 17:40:29 +0000 Subject: [PATCH 237/546] Cleanups; use @xref to link to API indices. git-svn-id: https://svn.r-project.org/R/trunk@86760 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 05a28c996c9..7cab37c62b7 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14943,12 +14943,13 @@ We can classify the entry points as @item API Entry points which are documented in this manual and declared in an installed header file. These can be used in distributed packages and -ideally will only be changed after deprecation. +ideally will only be changed after deprecation. @xref{API index}. @item public -Entry points declared in an installed header file that are exported -on all @R{} platforms but are not documented and subject to change -without notice. +Entry points declared in an installed header file that are exported on +all @R{} platforms but are not documented and subject to change without +notice. Do not use these in distributed code. Their declarations will +eventually be moved out of installed header files. @item private Entry points that are used when building @R{} and exported on all @R{} @@ -14963,19 +14964,16 @@ compilers/loaders when using @R{} as a shared library) not exported. Entry points declared in an installed header file that are part of an experimental API, such as @file{R_ext/Altrep.h}. These are subject to change, so package authors wishing to use these should be prepared to -adapt. +adapt. @xref{Experimental API index}. @item embedding Entry points intended primarily for embedding and creating new front-ends. It is not clear that this needs to be a separate category -but it may be useful to keep it separate for now. +but it may be useful to keep it separate for now. @xref{Embedding API +index}. @end table @eapihdr R_ext/Altrep.h -@comment FIXME ideally these should be links: feel free to add -See API index, Experimental API index, Embedding API index for the -classification of entry points in this document. - @comment FIXME be more explicit as: ask on the R-devel mailing list or @comment post a WISHLIST PR @comment FIXME should we reference and link to bugdilla? From 04af1b51903e33a0011ccd3eb2004c36c4e7859c Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 16 Jun 2024 17:55:44 +0000 Subject: [PATCH 238/546] Warn about invalid arguments to person(). git-svn-id: https://svn.r-project.org/R/trunk@86761 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 96e0f8f674b..2d7938ae65d 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -86,8 +86,15 @@ function(given = NULL, family = NULL, middle = NULL, ## to character). ## In principle, all non-NULL arguments whould be character: ## maybe this should be checked for? - .canonicalize <- function(s) - if(.is_not_nonempty_text(s)) NULL else trimws(s) + .canonicalize <- function(s) { + if(.is_not_nonempty_text(s)) NULL + else { + if(!is.character(s)) + warning(gettextf("Arguments of person() should be character or NULL"), + domain = NA) + trimws(s) + } + } given <- .canonicalize(given) family <- .canonicalize(family) email <- .canonicalize(email) From 78781cc53815f315779707aa9b8905822ca2bf0a Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 16 Jun 2024 18:54:16 +0000 Subject: [PATCH 239/546] More tools for working with ORCID iDs. git-svn-id: https://svn.r-project.org/R/trunk@86762 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/orcidtools.R | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/library/tools/R/orcidtools.R b/src/library/tools/R/orcidtools.R index 81d37ea5afd..170155337ab 100644 --- a/src/library/tools/R/orcidtools.R +++ b/src/library/tools/R/orcidtools.R @@ -26,6 +26,43 @@ .ORCID_iD_variants_regexp <- sprintf("^?$", .ORCID_iD_regexp) +### ** .ORCID_iD_canonicalize + +.ORCID_iD_canonicalize <- function(s) + sub(.ORCID_iD_variants_regexp, "\\3", s) + +### ** .ORCID_iD_is_valid + +.ORCID_iD_is_valid <- function(s) { + if(!grepl(.ORCID_iD_variants_regexp, s)) + return(FALSE) + s <- .ORCID_iD_canonicalize(s) + ## Checksum test, see + ## + s <- strsplit(gsub("-", "", s, fixed = TRUE), "")[[1L]] + x <- as.numeric(s[-16L]) + t <- sum(x * 2 ^ (15L : 1L)) + rem <- t %% 11 + res <- (12 - rem) %% 11 + z <- if(res == 10) "X" else as.character(res) + z == s[16L] +} + +### ** .ORCID_iD_is_alive + +.ORCID_iD_is_alive <- function(s) { + ## See +} + +### ** .ORCID_iD_from_person + +.ORCID_iD_from_person <- function(x) + vapply(unclass(x), + function(e) e$comment["ORCID"] %||% NA_character_, + "") + +### ** .ORCID_iD_db_from_package_sources + .ORCID_iD_db_from_package_sources <- function(dir, add = FALSE) { From f369537ff89affe8707b6ce5108162a1cde4dc23 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 16 Jun 2024 18:54:26 +0000 Subject: [PATCH 240/546] More tools for working with persons. git-svn-id: https://svn.r-project.org/R/trunk@86763 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/utils.R | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index cca002e3106..f7434157cd7 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -2093,6 +2093,37 @@ function(file, encoding = NA, keep.source = getOption("keep.source")) }) } +### ** .persons_from_metadata + +.persons_from_metadata <- function(dir) { + meta <- .get_package_metadata(dir) + if(!is.na(aar <- meta["Authors@R"])) { + aar <- tryCatch(utils:::.read_authors_at_R_field(aar), + error = identity) + if(inherits(aar, "person")) + return(aar) + } + NULL +} + +### ** .persons_from_citation + +.persons_from_citation <- function(dir, installed = FALSE) { + meta <- .get_package_metadata(dir, installed = installed) + path <- if(installed) + "CITATION" + else + file.path("inst", "CITATION") + cfile <- file.path(dir, path) + cinfo <- .read_citation_quietly(cfile, meta) + if(!inherits(cinfo, "error")) { + aut <- cinfo$author + if(inherits(aut, "person")) + return(aut) + } + NULL +} + ### ** .read_additional_repositories_field .read_additional_repositories_field <- From d7203e21faee5e1ed9fd03c71b30e1b8f5dee30f Mon Sep 17 00:00:00 2001 From: murrell Date: Mon, 17 Jun 2024 00:57:41 +0000 Subject: [PATCH 241/546] tweak of r86747, plus additional change to defend against calling NULL GESystemDesc callback git-svn-id: https://svn.r-project.org/R/trunk@86764 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/engine.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/engine.c b/src/main/engine.c index 0a39572cd8f..53c06c05c9e 100644 --- a/src/main/engine.c +++ b/src/main/engine.c @@ -65,9 +65,12 @@ static GESystemDesc* registeredSystems[MAX_GRAPHICS_SYSTEMS]; */ static void unregisterOne(pGEDevDesc dd, int systemNumber) { - if (dd->gesd[systemNumber] != NULL && - dd->gesd[systemNumber]->callback != NULL) { - (dd->gesd[systemNumber]->callback)(GE_FinaliseState, dd, R_NilValue); + if (dd->gesd[systemNumber] != NULL) { + /* Defensive */ + if (dd->gesd[systemNumber]->callback != NULL) { + (dd->gesd[systemNumber]->callback)(GE_FinaliseState, dd, + R_NilValue); + } free(dd->gesd[systemNumber]); dd->gesd[systemNumber] = NULL; } @@ -113,13 +116,12 @@ static void registerOne(pGEDevDesc dd, int systemNumber, GEcallback cb) { (GESystemDesc*) calloc(1, sizeof(GESystemDesc)); if (dd->gesd[systemNumber] == NULL) error(_("unable to allocate memory (in GEregister)")); + dd->gesd[systemNumber]->callback = cb; result = cb(GE_InitState, dd, R_NilValue); if (isNull(result)) { /* tidy up */ free(dd->gesd[systemNumber]); error(_("unable to allocate memory (in GEregister)")); - } else { - dd->gesd[systemNumber]->callback = cb; } } From 00d4736b6920932ab511b24abc28d3c7fd497186 Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 17 Jun 2024 10:09:20 +0000 Subject: [PATCH 242/546] avoid warning on non-Windows git-svn-id: https://svn.r-project.org/R/trunk@86765 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/platform.c b/src/main/platform.c index 6bf3563b963..76dee3fefe6 100644 --- a/src/main/platform.c +++ b/src/main/platform.c @@ -806,14 +806,14 @@ attribute_hidden SEXP do_filerename(SEXP call, SEXP op, SEXP args, SEXP rho) attribute_hidden SEXP do_fileinfo(SEXP call, SEXP op, SEXP args, SEXP rho) { SEXP fn, ans, ansnames, fsize, mtime, ctime, atime, isdir, - mode, xxclass, uname = R_NilValue, udomain = R_NilValue; + mode, xxclass, uname = R_NilValue; const void *vmax = vmaxget(); #ifdef UNIX_EXTRAS SEXP uid = R_NilValue, gid = R_NilValue, grname = R_NilValue; // silence -Wall #endif #ifdef Win32 - SEXP exe = R_NilValue; + SEXP exe = R_NilValue, udomain = R_NilValue; char *ubuf = NULL; DWORD ubuflen = 0; char *dbuf = NULL; From 91b7d1ad27873aa556250a1e218a0854d06321a1 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 17 Jun 2024 12:47:34 +0000 Subject: [PATCH 243/546] Add RDEBUG and SET_RDEBUG to tools:::nonAPI. git-svn-id: https://svn.r-project.org/R/trunk@86766 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 7 ++++--- src/library/tools/R/sotools.R | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 7453d4248c2..da67d7a77bd 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -111,9 +111,10 @@ \code{DDVAL}, \code{ENSURE_NAMEDMAX}, \code{ENVFLAGS}, \code{FRAME}, \code{HASHTAB}, \code{INTERNAL}, \code{IS_ASCII}, \code{IS_UTF8}, \code{LEVELS}, \code{NAMED}, \code{PRSEEN}, - \code{REAL0}, \code{SET_PRSEEN}, and \code{SYMVALUE}. Any - declarations for these in public header files will be removed in - the near future, and they will be hidden where possible. + \code{RDEBUG}, \code{REAL0}, \code{SET_PRSEEN}, \code{SET_RDEBUG} + and \code{SYMVALUE}. Any declarations for these in public header + files will be removed in the near future, and they will be hidden + where possible. } } diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 62155a31c2b..2940fd81f3a 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -682,7 +682,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "R_tryWrap", "DDVAL", "NAMED", "INTERNAL", "SYMVALUE", "PRSEEN", "REAL0", "COMPLEX0", "LEVELS", "FRAME", "HASHTAB", - "ENVFLAGS", + "ENVFLAGS", "RDEBUG", "SET_RDEBUG", ## in the non-API header R_ext/Connections.h "R_new_custom_connection", "R_ReadConnection", "R_WriteConnection", "R_GetConnection", From ec46d326b4485e387177dfe24c1b4ece5ee99307 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 17 Jun 2024 16:24:28 +0000 Subject: [PATCH 244/546] Add new section 'Moving into C API compliance' to WRE. git-svn-id: https://svn.r-project.org/R/trunk@86767 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 6 ++ doc/manual/R-exts.texi | 178 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 183 insertions(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index da67d7a77bd..ced10b84240 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -115,6 +115,12 @@ and \code{SYMVALUE}. Any declarations for these in public header files will be removed in the near future, and they will be hidden where possible. + + \item \sQuote{Writing R Extensions} has a new section + \sQuote{Moving into C API compliance} to help package authors move + away from using non-API endpoints. This section will continue to + be updated as work on clarifying and tightening the C API + continues. } } diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 7cab37c62b7..9a869b36381 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14884,6 +14884,7 @@ These functions return one of @code{SORTED_DECR}, @code{SORTED_INCR}, or * Controlling visibility:: * Standalone Mathlib:: * Organization of header files:: +* Moving into C API compliance:: @end menu There are a large number of entry points in the @R{} executable/DLL that @@ -17134,7 +17135,7 @@ get_seed(unsigned int *, unsigned int *) @noindent to read the seeds). -@node Organization of header files, , Standalone Mathlib, The R API +@node Organization of header files, Moving into C API compliance, Standalone Mathlib, The R API @section Organization of header files The header files which @R{} installs are in directory @@ -17219,6 +17220,181 @@ INSTALL} to compile C++ code defining @code{R_NO_REMAP}. @env{_R_CXX_USE_NO_REMAP_} is set by @command{R CMD check --as-cran} and is planned to become the default in future. +@node Moving into C API compliance, , Organization of header files, The R API +@section Moving into C API compliance + +Work is in progress to clarify and tighten the C API for extending R +code. This will help make package C code more robust, and will +facilitate maintaining and improving the R source code without impacting +package space. In the process a number of entry points intended for +internal use will be removed from installed header files or hidden, and +others will be replaced by more robust versions better suited for use in +package C code. This section describes how packages can move from using +non-API entry points to using ones available and supported in the API. + +@strong{Work in progress:} This section is a work in progress and will +be adjusted as changes are made to the API. + +@menu +* Some API replacements for non-API entry points:: +* Creating environments:: +* Creating call expressions:: +* Creating closures:: +* Some backports:: +@end menu + +@node Some API replacements for non-API entry points, Creating environments, , Moving into C API compliance +@subsection Some API replacements for non-API entry points + +Some non-API entry points intended for internal use have long had entry +points in the API that can be used instead. In other cases new entry +point have been added that are more appropriate for use in packages; +typically these include more extensive error checking on arguments. + +This table lists some non-API functions used in packages and the API +functions that should be used instead: + +@table @code +@item EXTPTR_PROT +@itemx EXTPTR_TAG +@itemx EXTPTR_PTR + Use @code{R_ExternalPtrProtected}, @code{R_ExternalPtrTag}, and + @code{R_ExternalPtrAddr}. +@item OBJECT +@itemx IS_S4_OBJECT + Use @code{isObject} and @code{isS4}. +@item GetOption + Use @code{GetOption1}. +@item R_lsInternal + Use @code{R_lsInternal3}. +@item REAL0 +@itemx COMPLEX0 + Use @code{REAL} and @code{COMPLEX}. +@item STRING_PTR +@itemx DATAPTR +@itemx STDVEC_DATAPTR + Use @code{STRING_PTR_RO} and @code{DATAPTR_RO}. Obtaining + writable pointers to these data can violate the memory manager's + integrity assumptions and is not supported. +@item isFrame + Use @code{isDataFrame}, added in @R{} 4.5.0. +@item BODY +@itemx FORMALS +@itemx CLOENV + Use @code{R_ClosureBody}, @code{R_ClosureFormals}, and + @code{R_ClosureEnv}; these were added in @R{} 4.5.0. +@item ENCLOS + Use @code{R_ParentEnv}, added in @R{} 4.5.0. +@end table + +For recently added entry points packages that need to be compiled +under older versions that do not yet contain these entry points can +use back-ported versions defined conditionally. @xref{Some backports}. + +@comment FIXME: need to figure out about allocSExp(DOTSXP) + +@node Creating environments, Creating call expressions, Some API replacements for non-API entry points, Moving into C API compliance +@subsection Creating environments + +An idiom appearing in a number of packages is to create an environment +as + +@example +SEXP env = allocSExp(ENVSXP); +SET_ENCLOS(env, parent); +@end example + +The function @code{allocSExp} and mutation functions like +@code{SET_ENCLOS}, @code{SET_FRAME}, and @code{SET_HASHTAB} are not part +of the API as they expose internal structure that might need to change +in the future. A proper constructor function should be used +instead. The constructor function for environments is @code{R_NewEnv}, +so the new environment should be created as + +@example +SEXP env = R_NewEnv(parent, FALSE, 0); +@end example + +@node Creating call expressions, Creating closures, Creating environments, Moving into C API compliance +@subsection Creating call expressions + +Another idiom used in some packages is to create a call expression with +space for two arguments as + +@example +SEXP expr = allocList(3); +SET_TYPEOF(expr, "LANGSXP"); +@end example + +and then fill in the function and argument expressions. +@code{SET_TYPEOF} will also not be available to packages in the +future. An alternative way to construct the expression that will work in +any @R{} version is + +@example +SEXP expr = LCONS(R_NilValue, allocList(2)); +@end example + +@R{} 4.4.1 adds the constructor @code{allocLang}, so the expression can be +created as + +@example +SEXP env = allocLang(3); +@end example + +@node Creating closures, Some backports, Creating call expressions, Moving into C API compliance +@subsection Creating closures + +Yet another common idiom is to create a new closure as + +@example +SEXP fun = Rf_allocSExp(CLOSXP); +SET_FORMALS(fun, formals); +SET_BODY(fun, body); +SET_CLOENV(fun, env); +@end example + +@R{} 4.5.0 adds the constructor @code{R_mkClosure}; this can be used as + +@example +SEXP fun = R_mkClosure(formals, body, env); +@end example + +@node Some backports, , Creating closures, Moving into C API compliance +@subsection Some backports + +This section lists backports of recently added definitions that can be +used in packages that need to be compiled under older versions of @R{} +that do not yet contain these entry points. + +@example +#if R_VERSION < R_Version(4, 4, 1) +SEXP allocLang(int n) +@{ + if (n > 0) + return LCONS(R_NilValue, allocList(n - 1)); + else + return R_NilValue; +@} +#endif + +#if R_VERSION < R_Version(4, 5, 0) +# define isDataFrame(x) isFrame(x) +# define R_ClosureFormals(x) FORMALS(x) +# define R_ClosureEnv(x) CLOENV(x) +# define R_ParentEnv(x) ENCLOS(x) + +SEXP R_mkClosure(SEXP formals, SEXP body, SEXP env) +@{ + SEXP fun = Rf_allocSExp(CLOSXP); + SET_FORMALS(fun, formals); + SET_BODY(fun, body); + SET_CLOENV(fun, env); + return fun; +@} +#endif +@end example + @node Generic functions and methods, Linking GUIs and other front-ends to R, The R API, Top @chapter Generic functions and methods @cindex Generic functions From 5521fa62273d38f50e7e963337d74ec2f223c532 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 17 Jun 2024 16:47:53 +0000 Subject: [PATCH 245/546] Add STRING_PTR, VECTOR_PTR, SET_FORMALS, SET_BODY, SET_CLOENV to tools:::nonAPI. git-svn-id: https://svn.r-project.org/R/trunk@86768 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 9 +++++---- src/library/tools/R/sotools.R | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index ced10b84240..bdfff8fb4fe 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -111,10 +111,11 @@ \code{DDVAL}, \code{ENSURE_NAMEDMAX}, \code{ENVFLAGS}, \code{FRAME}, \code{HASHTAB}, \code{INTERNAL}, \code{IS_ASCII}, \code{IS_UTF8}, \code{LEVELS}, \code{NAMED}, \code{PRSEEN}, - \code{RDEBUG}, \code{REAL0}, \code{SET_PRSEEN}, \code{SET_RDEBUG} - and \code{SYMVALUE}. Any declarations for these in public header - files will be removed in the near future, and they will be hidden - where possible. + \code{RDEBUG}, \code{REAL0}, \code{SET_BODY}, \code{SET_CLOENV}, + \code{SET_FORMALS}, \code{SET_PRSEEN}, \code{SET_RDEBUG}, + \code{STRING_PTR}, \code{SYMVALUE}, and \code{VECTOR_PTR}. Any + declarations for these in public header files will be removed in + the near future, and they will be hidden where possible. \item \sQuote{Writing R Extensions} has a new section \sQuote{Moving into C API compliance} to help package authors move diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 2940fd81f3a..1adda9f5884 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -683,6 +683,8 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "DDVAL", "NAMED", "INTERNAL", "SYMVALUE", "PRSEEN", "REAL0", "COMPLEX0", "LEVELS", "FRAME", "HASHTAB", "ENVFLAGS", "RDEBUG", "SET_RDEBUG", + "STRING_PTR", "VECTOR_PTR", + "SET_FORMALS", "SET_BODY", "SET_CLOENV", ## in the non-API header R_ext/Connections.h "R_new_custom_connection", "R_ReadConnection", "R_WriteConnection", "R_GetConnection", From 29a2fda1e9a88a531751cfb908053471533a79c4 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 17 Jun 2024 23:35:37 +0000 Subject: [PATCH 246/546] Add R_getVar and R_getVarEx. git-svn-id: https://svn.r-project.org/R/trunk@86769 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Rinternals.h | 2 ++ src/main/envir.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index c3e0049eac2..a91a9c7de8f 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -526,6 +526,8 @@ SEXP Rf_findVar(SEXP, SEXP); SEXP Rf_findVarInFrame(SEXP, SEXP); SEXP Rf_findVarInFrame3(SEXP, SEXP, Rboolean); Rboolean R_existsVarInFrame(SEXP, SEXP); +SEXP R_getVar(SEXP, SEXP, Rboolean); +SEXP R_getVarEx(SEXP, SEXP, Rboolean, SEXP); void R_removeVarFromFrame(SEXP, SEXP); SEXP Rf_getAttrib(SEXP, SEXP); SEXP Rf_GetArrayDimnames(SEXP); diff --git a/src/main/envir.c b/src/main/envir.c index 07cb5efff02..cbd917b3e0d 100644 --- a/src/main/envir.c +++ b/src/main/envir.c @@ -2271,6 +2271,37 @@ attribute_hidden SEXP do_mget(SEXP call, SEXP op, SEXP args, SEXP rho) return(ans); } +SEXP R_getVarEx(SEXP sym, SEXP rho, Rboolean inherits, SEXP ifnotfound) +{ + if (TYPEOF(sym) != SYMSXP) + error(_("first argument to '%s' must be a symbol"), __func__); + if (TYPEOF(rho) != ENVSXP) + error(_("second argument to '%s' must be an environment"), __func__); + + SEXP val = inherits ? findVar(sym, rho) : findVarInFrame(rho, sym); + if (val == R_MissingArg) + error(_("argument \"%s\" is missing, with no default"), + EncodeChar(PRINTNAME(sym))); + else if (val == R_UnboundValue) + return ifnotfound; + else if (TYPEOF(val) == PROMSXP) { + PROTECT(val); + val = eval(val, rho); + UNPROTECT(1); + return val; + } + else return val; +} + +SEXP R_getVar(SEXP sym, SEXP rho, Rboolean inherits) +{ + SEXP val = R_getVarEx(sym, rho, inherits, R_UnboundValue); + if (val == R_UnboundValue) + error(_("object '%s' not found"), EncodeChar(PRINTNAME(sym))); + return val; +} + + /*---------------------------------------------------------------------- do_missing From 56fd0bbe4a2c7a63b177a21548992ee1cbcb78d8 Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 18 Jun 2024 09:04:36 +0000 Subject: [PATCH 247/546] update Top menu (for compatibility with Texinfo < 6.8) git-svn-id: https://svn.r-project.org/R/trunk@86770 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 9a869b36381..d8fd13fe2e8 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -110,6 +110,9 @@ foreign language interfaces, and the @R{} @acronym{API}. * Linking GUIs and other front-ends to R:: * Function and variable index:: * Concept index:: +* API index:: +* Experimental API index:: +* Embedding API index:: @end menu @node Acknowledgements, Creating R packages, Top, Top @@ -12511,8 +12514,8 @@ right type. * Details of R types:: * Attributes:: * Classes:: -* Handling lists:: * S4 objects:: +* Handling lists:: * Handling character data:: * Working with closures:: * Finding and setting variables:: @@ -14769,7 +14772,6 @@ SEXP mkCharLenCE(const char *, int, cetype_t); to create marked character strings of a given length. @node Writing compact-representation-friendly code, , Character encoding issues, System and foreign language interfaces - @section Writing compact-representation-friendly code A simple way to iterate in C over the elements of an atomic vector is to From 8cc245e81f6336b8226c18716b3e30035271b788 Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 18 Jun 2024 09:12:44 +0000 Subject: [PATCH 248/546] spelling git-svn-id: https://svn.r-project.org/R/trunk@86771 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 2 +- doc/manual/R-data.texi | 2 +- doc/manual/R-exts.texi | 16 ++++++++-------- src/library/base/man/UseMethod.Rd | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 3ef4342743a..f38026fcf55 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -3018,7 +3018,7 @@ make uninstall @end example @noindent -will @I{(un)instal}l the header @file{Rmath.h} and shared and static +will @I{(un)install} the header @file{Rmath.h} and shared and static @enindex DESTDIR libraries (if built). Both @code{prefix=} and @env{DESTDIR} are supported, together with more precise control as described for the main diff --git a/doc/manual/R-data.texi b/doc/manual/R-data.texi index 5a0e52f8913..a8367bd9949 100644 --- a/doc/manual/R-data.texi +++ b/doc/manual/R-data.texi @@ -2045,7 +2045,7 @@ sink(zz) example(lm, prompt.echo = "> ") sink() close(zz) -## now `ex.lm.out' contains the output for futher processing. +## now `ex.lm.out' contains the output for further processing. ## Look at it by, e.g., cat(ex.lm.out, sep = "\n") @end example diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index d8fd13fe2e8..6fb206f9516 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -1302,13 +1302,13 @@ C and fixed-form Fortran can be used together, and mixing C, C++ and Fortran usually work for the platform's native compilers. If your code needs to depend on the platform there are certain defines -which can used in C or C++. On all Windows builds (even 64-bit ones) +which can be used in C or C++. On all Windows builds (even 64-bit ones) @samp{_WIN32} will be defined: on 64-bit Windows builds also @samp{_WIN64}. For Windows on ARM, test for @samp{_M_ARM64} or both @samp{_WIN32} and @samp{__aarch64__}. On macOS @samp{__APPLE__} is defined@footnote{There is also @samp{__APPLE_CC__}, but that indicates a compiler with Apple-specific features not the OS, although for -historical reasons is is defined by @I{LLVM} @command{clang}. It is +historical reasons it is defined by @I{LLVM} @command{clang}. It is used in @file{Rinlinedfuns.h}.}; for an `Apple Silicon' platform, test for both @samp{__APPLE__} and @samp{__arm64__}. @@ -5341,7 +5341,7 @@ points in the copy in the package. We have even seen problems with entry point name @code{myprintf}, which is a system entry point@footnote{in @file{libselinux}.} on some Linux systems. -@c example fron package fst on M1 mac in 2022-02. +@c example from package fst on M1 mac in 2022-02. A related issue is the naming of libraries built as part of the package installation. macOS and Windows have case-insensitive file systems, so using @@ -6621,7 +6621,7 @@ The use of @code{DFLOAT}, which was superseded by @code{DBLE} in Fortran similar. @item -Use of what @command{gfprtran} calls `Fortran 2018 deleted features', +Use of what @command{gfortran} calls `Fortran 2018 deleted features', although most were `deleted' in earlier standards: those itemized here were deleted in Fortran 2008. (In the Fortran standards `deleted' means features that compilers are not required to implement.) These include @@ -12728,7 +12728,7 @@ re-use the supplied object. When creating new result objects it can be useful to fill them in with values from an existing object. The functions @code{copyVector} and @code{copyMatrix} can be used for this. @code{copyMostAttributes} can -also simplify setting up a result object; is is used internally for +also simplify setting up a result object; it is used internally for results of arithmetic operations. @apifun copyVector @apifun copyMatrix @@ -13486,7 +13486,7 @@ include @code{R_existsVarInFrame}, @code{R_removeVarFromFrame}, @eapifun R_NamespaceEnvSpec @eapifun R_IsNamespaceEnv -The C functions @code{match} and @code{psmatch} correspond to the @R{} functions by the name name. +The C functions @code{match} and @code{psmatch} correspond to the @R{} functions by the same name. @eapifun match @eapifun pmatch @@ -13968,7 +13968,7 @@ the definition of @code{do_docall} in @file{src/main/coerce.c}. @end example @apifun allocLang @apifun SET_TAG -The function @code{allocLang} is available as of @R{} 4 4.1; for older +The function @code{allocLang} is available as of @R{} 4.4.1; for older versions replace @code{allocLang(3)} with @example LCONS(R_NilValue, allocList(2)) @@ -15752,7 +15752,7 @@ However, recent versions of @command{gfortran} @emph{via} the option @code{int_least32_t *}: `Link-Time Optimization' will report @code{int *} as a mismatch. It is possible to use @code{iso_c_binding} in Fortran 2003 to map LOGICAL variables to the C99 type @code{_Bool}, but it is -usually simpler to pass integers to and fro. +usually simpler to pass integers. @node Passing functions, , Fortran LOGICAL, Calling C from Fortran and vice versa @subsection Passing functions diff --git a/src/library/base/man/UseMethod.Rd b/src/library/base/man/UseMethod.Rd index c56a41a39f8..b79766f63a4 100644 --- a/src/library/base/man/UseMethod.Rd +++ b/src/library/base/man/UseMethod.Rd @@ -175,7 +175,7 @@ NextMethod(generic = NULL, object = NULL, \dots) \seealso{ The draft \sQuote{R Language Definition}. - \code{\link{methods}}, \code{\link{class}} incl \code{\link{.class2}()}; + \code{\link{methods}}, \code{\link{class}} incl.\sspace\code{\link{.class2}}; \code{\link{getS3method}}, \code{\link{is.object}}. } \references{ From fd1ddecd5289d4a24d68b20f127c47efcf046770 Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 18 Jun 2024 09:42:19 +0000 Subject: [PATCH 249/546] Update text to match example. git-svn-id: https://svn.r-project.org/R/trunk@86772 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 6fb206f9516..4361eb13b33 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14252,10 +14252,8 @@ variables. In the @code{for} loop, we first create a symbol corresponding to the @I{@code{i}-th} element of the @code{STRSXP} @code{theta}. Here, @code{STRING_ELT(theta, i)} accesses the @I{@code{i}-th} element of the @code{STRSXP} @code{theta}. -@code{CHAR()} extracts the actual character -representation@footnote{@pxref{Character encoding issues} for why this -might not be what is required.} of it: it returns a pointer. We then -install the name and use @code{findVar} to find its value. +@code{installChar()} installs the element as a name and @code{findVar} +finds its value. @apifun CHAR @comment FIXME in packages CHAR is remapped to R_CHAR; menion that here? @apifun R_CHAR From 811b10ca96f4c511fea9ea7cc920ccb933da7452 Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 18 Jun 2024 10:35:38 +0000 Subject: [PATCH 250/546] let 'make' see texi2any errors git-svn-id: https://svn.r-project.org/R/trunk@86773 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/Makefile.in | 2 +- doc/manual/Makefile.win | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/manual/Makefile.in b/doc/manual/Makefile.in index ea1441ed6f4..e1b2eef58c9 100644 --- a/doc/manual/Makefile.in +++ b/doc/manual/Makefile.in @@ -96,7 +96,7 @@ docs: html $(ECHO) "file $@ will be missing and linked from CRAN"; \ else \ $(ECHO) "creating doc/manual/$@"; \ - $(TEXI2HTML) -D UseExternalXrefs -I$(srcdir) $< -o $@.tmp || touch $@; \ + $(TEXI2HTML) -D UseExternalXrefs -I$(srcdir) $< -o $@.tmp || exit 1; \ SED="$(SED)" $(SHELL) $(srcdir)/texi2html.sh \ $(TEXI2ANY_VERSION_MAJ) $(TEXI2ANY_VERSION_MIN) $@; \ rm -f $@.tmp; \ diff --git a/doc/manual/Makefile.win b/doc/manual/Makefile.win index 52fce0a1543..452f541c3fc 100644 --- a/doc/manual/Makefile.win +++ b/doc/manual/Makefile.win @@ -43,7 +43,6 @@ TEXI2HTML = LC_ALL=C $(TEXI2ANY) $(TEXI2ANY_HTML_OPTS) TEXI2TEXT = LC_ALL=C $(TEXI2ANY) $(TEXI2ANY_TEXT_OPTS) R_PAPERSIZE = a4 -# omit 'hyper' to omit the hyperlinks R_RD4PDF = times,inconsolata,hyper texinputs_BASE = $(R_PKGS_BASE:=-pkg.tex) @@ -62,7 +61,7 @@ all: pdf ifneq "$(TEXI2ANY)" "missing" .texi.html: @$(ECHO) "creating doc/manual/$@" - @$(TEXI2HTML) -D UseExternalXrefs -I$(srcdir) $< -o $@.tmp || touch $@ + @$(TEXI2HTML) -D UseExternalXrefs -I$(srcdir) $< -o $@.tmp || exit 1 @$(SED) -f $(srcdir)/quot.sed $@.tmp > $@ @rm -f $@.tmp From a19a2e64e499173bf9a0995248d54f4608f5e279 Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 18 Jun 2024 13:02:49 +0000 Subject: [PATCH 251/546] update exemplified library() output git-svn-id: https://svn.r-project.org/R/trunk@86774 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-FAQ.texi | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/doc/manual/R-FAQ.texi b/doc/manual/R-FAQ.texi index 56dadf9311e..e8618087077 100644 --- a/doc/manual/R-FAQ.texi +++ b/doc/manual/R-FAQ.texi @@ -1805,41 +1805,42 @@ This produces something like @quotation @cartouche @smallexample -Packages in `/home/me/lib/R': +Packages in library '/home/me/lib/R': mystuff My own R functions, nicely packaged but not documented -Packages in `/usr/local/lib/R/library': +Packages in library '/usr/local/lib/R/library': -KernSmooth Functions for kernel smoothing for Wand & Jones (1995) +KernSmooth Functions for Kernel Smoothing Supporting Wand & Jones (1995) MASS Support Functions and Datasets for Venables and Ripley's MASS Matrix Sparse and Dense Matrix Classes and Methods -base The R Base package -boot Bootstrap R (S-Plus) Functions (Canty) +base The R Base Package boot Bootstrap Functions (Originally by Angelo Canty for S) class Functions for Classification cluster "Finding Groups in Data": Cluster Analysis Extended Rousseeuw et al. codetools Code Analysis Tools for R +compiler The R Compiler Package datasets The R Datasets Package -foreign Read Data Stored by Minitab, S, SAS, SPSS, Stata, Systat, - dBase, ... +foreign Read Data Stored by 'Minitab', 'S', 'SAS', 'SPSS', 'Stata', + 'Systat', 'Weka', 'dBase', ... grDevices The R Graphics Devices and Support for Colours and Fonts graphics The R Graphics Package grid The Grid Graphics Package -lattice Lattice Graphics +lattice Trellis Graphics for R methods Formal Methods and Classes -mgcv GAMs with GCV/AIC/REML smoothness estimation and GAMMs - by PQL +mgcv Mixed GAM Computation Vehicle with Automatic Smoothness + Estimation nlme Linear and Nonlinear Mixed Effects Models -nnet Feed-forward Neural Networks and Multinomial Log-Linear +nnet Feed-Forward Neural Networks and Multinomial Log-Linear Models -rpart Recursive Partitioning +parallel Support for Parallel Computation in R +rpart Recursive Partitioning and Regression Trees spatial Functions for Kriging and Point Pattern Analysis splines Regression Spline Functions and Classes stats The R Stats Package -stats4 Statistical functions using S4 Classes -survival Survival analysis, including penalised likelihood +stats4 Statistical Functions using S4 Classes +survival Survival Analysis tcltk Tcl/Tk Interface tools Tools for Package Development utils The R Utils Package From 812ea3bea175f8f99e1aa2174dd44bbd684471ee Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 18 Jun 2024 13:26:35 +0000 Subject: [PATCH 252/546] tweaks git-svn-id: https://svn.r-project.org/R/trunk@86775 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-FAQ.texi | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/manual/R-FAQ.texi b/doc/manual/R-FAQ.texi index e8618087077..072c698166a 100644 --- a/doc/manual/R-FAQ.texi +++ b/doc/manual/R-FAQ.texi @@ -1861,15 +1861,14 @@ library(help = @var{pkg}) help(package = @var{pkg}) @end example -You can unload the loaded package @var{pkg} by +You can remove the loaded package @var{pkg} from the @code{search()} path by @example -detach("package:@var{pkg}", unload = TRUE) +detach("package:@var{pkg}") @end example @noindent -(where @code{unload = TRUE} is needed only for packages with a -namespace, see @code{?unload}). +(which does not by default unload the namespace, see @code{?detach}). @node How can add-on packages be removed?, How can I create an R package?, How can add-on packages be used?, R Add-On Packages @section How can add-on packages be removed? @@ -3014,7 +3013,7 @@ constructs the path. For example, to save results into files @example for(i in 1:100) @{ ## Calculations constructing "some_object" ... - fp <- file.path("Results", paste("result", i, ".rda", sep = "")) + fp <- file.path("Results", paste0("result", i, ".rda")) save(list = "some_object", file = fp) @} @end example From e36a55d116479a45f0b8e8795c985d20cd05770c Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 18 Jun 2024 14:18:06 +0000 Subject: [PATCH 253/546] update example output git-svn-id: https://svn.r-project.org/R/trunk@86776 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-intro.texi | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/doc/manual/R-intro.texi b/doc/manual/R-intro.texi index 1e7c4f38c13..84a35544e59 100644 --- a/doc/manual/R-intro.texi +++ b/doc/manual/R-intro.texi @@ -4158,15 +4158,14 @@ To see what methods are available we can use @code{methods()} @example > methods(coef) -[1] coef.aov* coef.Arima* coef.default* coef.listof* -[5] coef.nls* coef.summary.nls* - - Non-visible functions are asterisked +[1] coef.aov* coef.Arima* coef.default* coef.listof* coef.maov* +[6] coef.nls* +see '?methods' for accessing help and source code @end example @noindent In this example there are six methods, none of which can be seen by -typing its name. We can read these by either of +typing its name (as indicated by the asterisk). We can read these by either of @findex getAnywhere @findex getS3method @@ -4178,17 +4177,21 @@ It was found in the following places namespace:stats with value -function (object, ...) +function (object, complete = FALSE, ...) @{ - z <- object$coef - z[!is.na(z)] + cf <- object$coefficients + if (complete) + cf + else cf[!is.na(cf)] @} > getS3method("coef", "aov") -function (object, ...) +function (object, complete = FALSE, ...) @{ - z <- object$coef - z[!is.na(z)] + cf <- object$coefficients + if (complete) + cf + else cf[!is.na(cf)] @} @end example From e5524a2b849f83598587d1402221813d62f20327 Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 18 Jun 2024 14:54:54 +0000 Subject: [PATCH 254/546] drop obsolete HTML tweaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Texinfo (even version 5.1) already converts quotation marks to HTML entities (lsquo, etc) by default (USE_ISO => 1), specifically excluding code and math contexts, which these sed expressions would corrupt, e.g., replacing _code_ like {c == '.'} by {c == ā€˜.ā€™}. git-svn-id: https://svn.r-project.org/R/trunk@86777 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/quot.sed | 7 ------- 1 file changed, 7 deletions(-) diff --git a/doc/manual/quot.sed b/doc/manual/quot.sed index 3ac6ac7ba04..038e98860c9 100644 --- a/doc/manual/quot.sed +++ b/doc/manual/quot.sed @@ -1,10 +1,3 @@ -/^\)]\)/ ā€˜\1ā€™\2/g -s/^'\([^`']*\)' /ā€˜\1ā€™ /g - # obsolete for texi2any >= 7.0 with `-c IGNORE_REF_TO_TOP_NODE_UP=1` ///g From ce81c1ace8da69fd659f8024ee65b18fd0e69b58 Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 18 Jun 2024 15:38:12 +0000 Subject: [PATCH 255/546] Make the issues of using CHAR() more visible in R-exts/comments. git-svn-id: https://svn.r-project.org/R/trunk@86778 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 16 +++++++++++++--- src/library/grid/src/util.c | 6 +++--- src/library/stats/src/optim.c | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 4361eb13b33..4f4ca2e189d 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13097,7 +13097,7 @@ one in package @pkg{stats}) is very useful: @example @group -/* get the list element named str, or return NULL */ +/* get the list element named str (ASCII), or return NULL */ SEXP getListElement(SEXP list, const char *str) @{ @@ -13107,6 +13107,7 @@ SEXP getListElement(SEXP list, const char *str) @group for (int i = 0; i < length(list); i++) if(strcmp(CHAR(STRING_ELT(names, i)), str) == 0) @{ + /* ASCII only */ elmt = VECTOR_ELT(list, i); break; @} @@ -13126,6 +13127,9 @@ and enables us to say @end group @end example +This code only works for names that are ASCII (@pxref{Character encoding +issues}). + @node Handling character data, Working with closures, Handling lists, Handling R objects in C @subsection Handling character data @cindex handling character data @@ -13146,6 +13150,10 @@ use). Since @code{CHARSXP}s are immutable, the same @code{CHARSXP} can be shared by any @code{STRSXP} needing an element representing the same string. @R{} maintains a global cache of @code{CHARSXP}s so that there is only ever one @code{CHARSXP} representing a given string in memory. +It most cases it is easier to use @code{translateChar} +or @code{translateCharUTF8} to obtain the C string and it is safer +against potential future changes in R (@pxref{Character encoding +issues}). @apifun mkChar @apifun mkCharLen @@ -13729,10 +13737,11 @@ value of its arguments if they are vector types. @group SEXP showArgs(SEXP args) @{ + void *vmax = vmaxget(); args = CDR(args); /* skip 'name' */ for(int i = 0; args != R_NilValue; i++, args = CDR(args)) @{ const char *name = - isNull(TAG(args)) ? "" : CHAR(PRINTNAME(TAG(args))); + isNull(TAG(args)) ? "" : translateChar(PRINTNAME(TAG(args))); SEXP el = CAR(args); if (length(el) == 0) @{ Rprintf("[%d] '%s' R type, length 0\n", i+1, name); @@ -13762,7 +13771,7 @@ SEXP showArgs(SEXP args) @group case STRSXP: Rprintf("[%d] '%s' %s\n", i+1, name, - CHAR(STRING_ELT(el, 0))); + translateChar(STRING_ELT(el, 0))); break; @end group @group @@ -13770,6 +13779,7 @@ SEXP showArgs(SEXP args) Rprintf("[%d] '%s' R type\n", i+1, name); @} @} + vmaxset(vmax); return R_NilValue; @} @end group diff --git a/src/library/grid/src/util.c b/src/library/grid/src/util.c index 2f323d3af69..ba0b1d35084 100644 --- a/src/library/grid/src/util.c +++ b/src/library/grid/src/util.c @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 2001-3 Paul Murrell - * 2003-8 The R Core Team + * 2003-24 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ SEXP getListElement(SEXP list, char *str) int i; for (i = 0; i < length(list); i++) - if(strcmp(CHAR(STRING_ELT(names, i)), str) == 0) { + if(strcmp(CHAR(STRING_ELT(names, i)), str) == 0) { /* ASCII only */ elmt = VECTOR_ELT(list, i); break; } @@ -44,7 +44,7 @@ void setListElement(SEXP list, char *str, SEXP value) int i; for (i = 0; i < length(list); i++) - if(strcmp(CHAR(STRING_ELT(names, i)), str) == 0) { + if(strcmp(CHAR(STRING_ELT(names, i)), str) == 0) { /* ASCII only */ SET_VECTOR_ELT(list, i, value); break; } diff --git a/src/library/stats/src/optim.c b/src/library/stats/src/optim.c index 28c09adbd74..6b122311858 100644 --- a/src/library/stats/src/optim.c +++ b/src/library/stats/src/optim.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1999-2017 The R Core Team + * Copyright (C) 1999-2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,7 +41,7 @@ SEXP getListElement(SEXP list, char *str) int i; for (i = 0; i < length(list); i++) - if (strcmp(CHAR(STRING_ELT(names, i)), str) == 0) { + if (strcmp(CHAR(STRING_ELT(names, i)), str) == 0) { /* ASCII only */ elmt = VECTOR_ELT(list, i); break; } From 1abb90d39f615b5226365335f8101e9e0049d09e Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 18 Jun 2024 15:56:13 +0000 Subject: [PATCH 256/546] avoid duplicated viewport declaration (that Texinfo >= 6.8 generates) git-svn-id: https://svn.r-project.org/R/trunk@86779 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/quot.sed | 2 -- doc/manual/texi2html.sh | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/manual/quot.sed b/doc/manual/quot.sed index 038e98860c9..e065f1ab01e 100644 --- a/doc/manual/quot.sed +++ b/doc/manual/quot.sed @@ -3,5 +3,3 @@ s/, \(Previous\|Up\): //g s/\ - ${sedscriptuse} + ## Texinfo < 6.8 lacks the viewport declaration + cat "${sedscriptini}" - >"${sedscriptuse}" <<-EOF + s/\\ + - + + Methods may be defined for arguments: x Use showMethods(chol2inv) for currently available ones. > @@ -1009,7 +1009,8 @@ packages. To cite package 'nlme' in publications use: Pinheiro J, Bates D, R Core Team (9999). _nlme: Linear and Nonlinear Mixed - Effects Models_. R package version 3.1-999, + Effects Models_. doi:10.32614/CRAN.package.nlme + , R package version 3.1-999, . Pinheiro JC, Bates DM (2000). _Mixed-Effects Models in S and S-PLUS_. @@ -1021,7 +1022,8 @@ To see these entries in BibTeX format, use 'print(, bibtex=TRUE)', To cite package 'nlme' in publications use: Pinheiro J, Bates D, R Core Team (9999). _nlme: Linear and Nonlinear Mixed - Effects Models_. R package version 3.1-999, + Effects Models_. doi:10.32614/CRAN.package.nlme + , R package version 3.1-999, . Pinheiro JC, Bates DM (2000). _Mixed-Effects Models in S and S-PLUS_. @@ -1030,7 +1032,8 @@ To cite package 'nlme' in publications use: To cite package 'nlme' in publications use: Pinheiro J, Bates D, R Core Team (9999). _nlme: Linear and Nonlinear Mixed - Effects Models_. R package version 3.1-999, + Effects Models_. doi:10.32614/CRAN.package.nlme + , R package version 3.1-999, . A BibTeX entry for LaTeX users is @@ -1041,6 +1044,7 @@ A BibTeX entry for LaTeX users is year = {9999}, note = {R package version 3.1-999}, url = {https://CRAN.R-project.org/package=nlme}, + doi = {10.32614/CRAN.package.nlme}, } Pinheiro JC, Bates DM (2000). _Mixed-Effects Models in S and S-PLUS_. @@ -1081,5 +1085,5 @@ A BibTeX entry for LaTeX users is [1] "https://example.org" > > cat('Time elapsed: ', proc.time(),'\n') -Time elapsed: 2.884 0.14 3.09 0.003 0 +Time elapsed: 2.176 0.139 2.315 0.002 0 > From 3378acfff8cd4a7e90a1a10b8d858ede48f380a2 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 18 Jun 2024 21:39:14 +0000 Subject: [PATCH 258/546] Hack to escalate some non-API NOTEs to WARNINGs. git-svn-id: https://svn.r-project.org/R/trunk@86781 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 219f6625064..33e38b4a263 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -3803,9 +3803,30 @@ add_dummies <- function(dir, Log) haveObjs <- any(grepl("^ *Object", out)) pat <- paste("possibly from", sQuote("(abort|assert|exit|_exit|_Exit|stop)")) + rempat <- "REAL0|COMPLEX0|ddfind|DDVAL|ENSURE_NAMEDMAX|INTERNAL" if(haveObjs && any(grepl(pat, out)) && pkgname %notin% "parallel") ## need _exit in forked child warningLog(Log) + ## Very crude hack to escalete NOTE about some non-API + ## calls to a WARNING. Hopefully this can be dropped again + ## soon. + else if (length(grep("Found non-API", out)) && + any(grepl(rempat, out))) { + warningLog(Log) + if (any(grepl("calls", out))) { + ep <- Filter(function(x) any(grepl(x, out)), + strsplit(rempat, "\\|")[[1]]) + epq <- paste(sQuote(ep), collapse = ", ") + out <- paste(c(out, + "These entry points may be removed soon:", + epq), + collapse = "\n") + } + else + out <- paste(c(out, + "This entry point may be removed soon."), + collapse = "\n") + } else { ## look for Fortran detritus pat1 <- paste("possibly from", sQuote("(open|close|rewind)")) From c8896971cfe60a15b9b58c6d68633a2b30310384 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 19 Jun 2024 06:34:10 +0000 Subject: [PATCH 259/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86782 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/Rd2HTML.R | 4 +-- src/library/tools/R/orcidtools.R | 43 +++++++++++++++++++------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/library/tools/R/Rd2HTML.R b/src/library/tools/R/Rd2HTML.R index f0efccb6f87..5dcb7be570a 100644 --- a/src/library/tools/R/Rd2HTML.R +++ b/src/library/tools/R/Rd2HTML.R @@ -1656,9 +1656,7 @@ function(dir) c(e$family, paste0("<", paste0("https://replace.me.by.orcid.org/", - sub(.ORCID_iD_variants_regexp, - "\\3", - comment[pos])), + .ORCID_iD_canonicalize(comment[pos])), ">")) e$comment <- if(len < length(comment)) comment[-pos] diff --git a/src/library/tools/R/orcidtools.R b/src/library/tools/R/orcidtools.R index 170155337ab..cdf520ee39f 100644 --- a/src/library/tools/R/orcidtools.R +++ b/src/library/tools/R/orcidtools.R @@ -28,30 +28,39 @@ ### ** .ORCID_iD_canonicalize -.ORCID_iD_canonicalize <- function(s) - sub(.ORCID_iD_variants_regexp, "\\3", s) +.ORCID_iD_canonicalize <- function(x) + sub(.ORCID_iD_variants_regexp, "\\3", x) ### ** .ORCID_iD_is_valid -.ORCID_iD_is_valid <- function(s) { - if(!grepl(.ORCID_iD_variants_regexp, s)) - return(FALSE) - s <- .ORCID_iD_canonicalize(s) - ## Checksum test, see - ## - s <- strsplit(gsub("-", "", s, fixed = TRUE), "")[[1L]] - x <- as.numeric(s[-16L]) - t <- sum(x * 2 ^ (15L : 1L)) - rem <- t %% 11 - res <- (12 - rem) %% 11 - z <- if(res == 10) "X" else as.character(res) - z == s[16L] +.ORCID_iD_is_valid <- function(x) { + one <- function(s) { + if(!grepl(.ORCID_iD_variants_regexp, s)) + return(FALSE) + s <- .ORCID_iD_canonicalize(s) + ## Checksum test, see + ## + s <- strsplit(gsub("-", "", s, fixed = TRUE), "")[[1L]] + x <- as.numeric(s[-16L]) + t <- sum(x * 2 ^ (15L : 1L)) + rem <- t %% 11 + res <- (12 - rem) %% 11 + z <- if(res == 10) "X" else as.character(res) + z == s[16L] + } + vapply(x, one, NA) } ### ** .ORCID_iD_is_alive -.ORCID_iD_is_alive <- function(s) { - ## See +.ORCID_iD_is_alive <- function(x) { + ## See + ## + ## Assume all given ids are canonical. + urls <- sprintf("https://orcid.org/%s", x) + hdrs <- list("Accept" = "application/xml") + resp <- .curl_multi_run_worker(urls, nobody = TRUE, hdrs = hdrs) + vapply(resp, .curl_response_status_code, 0L) == 200L } ### ** .ORCID_iD_from_person From a975c35816eee20e5108a9d222205bfb42a51945 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 19 Jun 2024 06:34:38 +0000 Subject: [PATCH 260/546] Allow passing headers to curl multi run worker. git-svn-id: https://svn.r-project.org/R/trunk@86783 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/urltools.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/library/tools/R/urltools.R b/src/library/tools/R/urltools.R index 1da0cb43cfc..8e5dda88d59 100644 --- a/src/library/tools/R/urltools.R +++ b/src/library/tools/R/urltools.R @@ -811,7 +811,7 @@ function(urls, verbose = FALSE, pool = NULL, nobody = TRUE) .curl_multi_run_worker <- function(urls, nobody = FALSE, verbose = FALSE, pool = NULL, - opts = NULL) + opts = NULL, hdrs = NULL) { ## Use 'nobody = TRUE' to fetch only headers. @@ -863,6 +863,8 @@ function(urls, nobody = FALSE, verbose = FALSE, pool = NULL, u <- urls[[i]] h <- curl::new_handle(url = u) curl::handle_setopt(h, .list = opts) + if(length(hdrs)) + curl::handle_setheaders(h, .list = hdrs) if(grepl("^https?://github[.]com", u) && nzchar(a <- Sys.getenv("GITHUB_PAT", ""))) { curl::handle_setheaders(h, "Authorization" = paste("token", a)) From 3ed288a70e18c4bb560656827c26312909b5a9de Mon Sep 17 00:00:00 2001 From: maechler Date: Wed, 19 Jun 2024 09:45:47 +0000 Subject: [PATCH 261/546] speed up example for huge / slow package library git-svn-id: https://svn.r-project.org/R/trunk@86784 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/man/help.search.Rd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/library/utils/man/help.search.Rd b/src/library/utils/man/help.search.Rd index da05d79de17..b6b61c36946 100644 --- a/src/library/utils/man/help.search.Rd +++ b/src/library/utils/man/help.search.Rd @@ -119,7 +119,7 @@ help.search(pattern, fields = c("alias", "concept", "title"), documentation directory are taken as concepts. For standard keyword entries different from \samp{internal}, the corresponding descriptions from file \file{KEYWORDS} are additionally taken as concepts. All - \samp{\concept} entries used as concepts. + \samp{\concept} entries used as concepts. Vignettes are searched as follows. The \code{"name"} and \code{"alias"} are both the base of the vignette filename, and the @@ -156,8 +156,10 @@ help.search(pattern, fields = c("alias", "concept", "title"), \code{\link{apropos}} uses regexps and has nice examples. } \examples{ -help.search("linear models") # In case you forgot how to fit linear - # models +\dontshow{help.search("linear models", lib.loc = .Library) # (limit to "base + Rec." packages)} +\dontrun{ +help.search("linear models") # In case you forgot how to fit linear models +} help.search("non-existent topic") ??utils::help # All the topics matching "help" in the utils package From c1b2a6c1b0281900a61dea76f4f399727596c051 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 19 Jun 2024 13:17:50 +0000 Subject: [PATCH 262/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86785 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index f7434157cd7..48e69dddc64 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -2117,7 +2117,7 @@ function(file, encoding = NA, keep.source = getOption("keep.source")) cfile <- file.path(dir, path) cinfo <- .read_citation_quietly(cfile, meta) if(!inherits(cinfo, "error")) { - aut <- cinfo$author + aut <- do.call(c, lapply(unclass(cinfo), `[[`, "author")) if(inherits(aut, "person")) return(aut) } From 342177f8b2adf8707e86c698ff544084d6797eb9 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 19 Jun 2024 13:18:23 +0000 Subject: [PATCH 263/546] Improve building the ORCID id db. git-svn-id: https://svn.r-project.org/R/trunk@86786 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/orcidtools.R | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/src/library/tools/R/orcidtools.R b/src/library/tools/R/orcidtools.R index cdf520ee39f..ca7e3c7597d 100644 --- a/src/library/tools/R/orcidtools.R +++ b/src/library/tools/R/orcidtools.R @@ -75,32 +75,11 @@ .ORCID_iD_db_from_package_sources <- function(dir, add = FALSE) { - meta <- .get_package_metadata(dir, FALSE) - ids1 <- ids2 <- character() - if(!is.na(aar <- meta["Authors@R"])) { - aar <- tryCatch(utils:::.read_authors_at_R_field(aar), - error = identity) - if(!inherits(aar, "error")) { - ids1 <- unlist(lapply(aar, - function(e) { - e <- e$comment - e[names(e) == "ORCID"] - }), - use.names = FALSE) - } - } - if(file.exists(cfile <- file.path(dir, "inst", "CITATION"))) { - cinfo <- .read_citation_quietly(cfile, meta) - if(!inherits(cinfo, "error")) - ids2 <- unlist(lapply(cinfo$author, - function(e) { - e <- e$comment - e[names(e) == "ORCID"] - }), - use.names = FALSE) - } - - db <- data.frame(ID = c(ids1, ids2), + ids1 <- .ORCID_iD_from_person(.persons_from_metadata(dir)) + ids1 <- ids1[!is.na(ids1)] + ids2 <- .ORCID_iD_from_person(.persons_from_citation(dir)) + ids2 <- ids2[!is.na(ids2)] + db <- data.frame(ID = c(character(), ids1, ids2), Parent = c(rep_len("DESCRIPTION", length(ids1)), rep_len("inst/CITATION", From 076fd48c3b1149383edeaac7ff0969416d9d1057 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 19 Jun 2024 13:18:37 +0000 Subject: [PATCH 264/546] Improve checking the ORCID ids. git-svn-id: https://svn.r-project.org/R/trunk@86787 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index 8b3248ae6c9..e23b89ddb65 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -3896,18 +3896,17 @@ function(aar, strict = FALSE) if(all(has_no_name | vapply(aar, function(e) "aut" %notin% e$role, NA))) out$bad_authors_at_R_field_has_no_author_roles <- TRUE - has_bad_ORCID_identifiers <- - vapply(aar, - function(e) { - e <- e$comment - e <- e[names(e) == "ORCID"] - any(!grepl(.ORCID_iD_variants_regexp, - e)) - }, - NA) - if(any(has_bad_ORCID_identifiers)) + ids <- .ORCID_iD_from_person(aar) + pos <- which(!is.na(ids)) + ids <- ids[pos] + pos <- pos[!.ORCID_iD_is_valid(ids)] + if(length(pos)) out$bad_authors_at_R_field_has_persons_with_bad_ORCID_identifiers <- - format(aar[has_bad_ORCID_identifiers]) + format(aar[pos]) + ids <- ids[duplicated(ids)] + if(length(ids)) + out$bad_authors_at_R_field_has_persons_with_dup_ORCID_identifiers<- + ids } if(strict >= 3L) { non_standard_roles <- @@ -4010,6 +4009,10 @@ function(x) if(length(bad <- x[["bad_authors_at_R_field_has_persons_with_bad_ORCID_identifiers"]])) { c(gettext("Authors@R field gives persons with invalid ORCID identifiers:"), paste0(" ", bad)) + }, + if(length(bad <- x[["bad_authors_at_R_field_has_persons_with_dup_ORCID_identifiers"]])) { + c(gettext("Authors@R field gives persons with duplicated ORCID identifiers:"), + paste0(" ", bad)) } ) } @@ -8131,17 +8134,10 @@ function(dir, localOnly = FALSE, pkgSize = NA) odb <- odb[ind, , drop = FALSE] } if(NROW(odb)) { - ids <- sub(.ORCID_iD_variants_regexp, "\\3", odb[, 1L]) - ini <- "https://orcid.org/" - udb <- url_db(paste0(ini, ids), odb[, 2L]) - bad <- tryCatch(check_url_db(udb, - parallel = - check_urls_in_parallel), - error = identity) - if(!inherits(bad, "error") && length(bad)) - out$bad_ORCID_iDs <- - cbind(substring(bad$URL, nchar(ini) + 1L), - bad[, 2L]) + ids <- .ORCID_iD_canonicalize(odb[, 1L]) + bad <- ids[!.ORCID_iD_is_alive(ids)] + if(length(bad)) + out$bad_ORCID_iDs <- bad } } } From fd08dbc79b5a41ef09758db98b70c36139209d1b Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 19 Jun 2024 13:39:05 +0000 Subject: [PATCH 265/546] Add NEWS entry on upgrading some non-API NOTEs to WARNINGs. git-svn-id: https://svn.r-project.org/R/trunk@86788 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index bdfff8fb4fe..9128556872d 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -116,12 +116,16 @@ \code{STRING_PTR}, \code{SYMVALUE}, and \code{VECTOR_PTR}. Any declarations for these in public header files will be removed in the near future, and they will be hidden where possible. - + \item \sQuote{Writing R Extensions} has a new section \sQuote{Moving into C API compliance} to help package authors move away from using non-API endpoints. This section will continue to be updated as work on clarifying and tightening the C API continues. + + \item Some \samp{NOTE}s for use of non-API entry points have been + upgraded to \samp{WARNING}s in preparation for removing + declarations and, where possible, hiding these entry points. } } From 319175def9bce89e44126a372872bd27c3ed93f7 Mon Sep 17 00:00:00 2001 From: kalibera Date: Wed, 19 Jun 2024 14:51:16 +0000 Subject: [PATCH 266/546] Higher-level functions for encoding information. git-svn-id: https://svn.r-project.org/R/trunk@86789 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 83 +++++++++++++++++++++++++++++++++++++++- src/include/Rinternals.h | 6 +++ src/main/sysutils.c | 26 ++++++++++++- 3 files changed, 112 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 4f4ca2e189d..2c308904659 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14754,6 +14754,46 @@ string is treated as a series of bytes. (See the comments under Function +@eapifun charIsASCII +@example +Rboolean charIsASCII(SEXP); +@end example + +@noindent +can be used to detect whether a given @code{CHARSXP} represents an ASCII +string. The implementation is equivalent to checking individual characters, +but may be faster. + +Function + +@eapifun charIsUTF8 +@example +Rboolean charIsUTF8(SEXP); +@end example + +@noindent +can be used to detect whether the internal representation of a given +@code{CHARSXP} accessed via @code{CHAR} is UTF-8 (including ASCII). This +function is rarely needed and specifically is not needed with +@code{translateCharUTF8}, because such check is already included. However, +when needed, it is better to use it in preference of @code{getCharCE}, as it +is safer against future changes in the semantics of encoding marks. Note +that @code{charIsUTF8()} is not equivalent to @code{getCharCE() == CE_UTF8}. + +Similarly, function + +@eapifun charIsLatin1 +@example +Rboolean charIsLatin1(SEXP); +@end example + +@noindent +can be used to detect whether the internal representation of a given +@code{CHARSXP} accessed via @code{CHAR} is latin1 (including ASCII). It is +not equivalent to to @code{getCharCE() == CE_LATIN1}. + +Function + @apifun reEnc @example const char *reEnc(const char *x, cetype_t ce_in, cetype_t ce_out, @@ -17295,6 +17335,11 @@ functions that should be used instead: @code{R_ClosureEnv}; these were added in @R{} 4.5.0. @item ENCLOS Use @code{R_ParentEnv}, added in @R{} 4.5.0. +@item IS_ASCII + Use @code{charIsASCII}, added in @R{} 4.5.0. +@item IS_UTF8 + Use @code{charIsUTF8}, added in @R{} 4.5.0, and check semantical + differences. @end table For recently added entry points packages that need to be compiled @@ -17352,7 +17397,7 @@ created as SEXP env = allocLang(3); @end example -@node Creating closures, Some backports, Creating call expressions, Moving into C API compliance +@node Creating closures, Querying CHARSXP encoding, Creating call expressions, Moving into C API compliance @subsection Creating closures Yet another common idiom is to create a new closure as @@ -17370,7 +17415,41 @@ SET_CLOENV(fun, env); SEXP fun = R_mkClosure(formals, body, env); @end example -@node Some backports, , Creating closures, Moving into C API compliance +@node Querying CHARSXP encoding, Some backports, Creating closures, Moving into C API compliance +@subsection Querying CHARSXP encoding + +A number of packages query encoding bits set on CHARSXP objects via macros +@code{IS_ASCII} and @code{IS_UTF8}, some packages also via @code{IS_BYTES} +and @code{IS_LATIN1}. These macros are not part of the API and packages +have been copying their definition and directly accessing the bits in +memory. The structure of the object header is, however, internal to @R{} and +may have to change in the future. + +@code{IS_ASCII} can be replaced by @code{charIsASCII}, added in @R{} 4.5.0. +It can also be replaced by code that checks individual characters (bytes). + +Information provided by the other macros is available via function +@code{getCharCE}, which has been part of the API since @R{} 2.7.0. Before +switching to @code{getCharCE}, packages are, however, advised to check +whether the encoding information is really needed and whether it is used +correctly. + +Most code should be able to work with complete CHARSXPs and never look at +the individual bytes. When access to characters and bytes (of strings other +than @code{CE_BYTES}) is needed, one would use @code{translateChar} or +@code{translateCharUTF8}. These functions internally already check the +encoding and whether the string is ASCII and only translate when needed, +which should be rarely since @R{} >= 4.2.0 (UTF-8 is used as native encoding +on most systems running R). + +Several packages use the encoding information to find out whether an +internal string representation visible via @code{CHAR} is UTF-8 or latin1. +@R{} 4.5.0 provides functions @code{charIsUTF8} and @code{charIsLatin1} for +this purpose, which are simpler to use and safer against future changes. +Note that both will be true for ASCII strings and they handle also native +strings when running in the corresponding locale. + +@node Some backports, , Querying CHARSXP encoding, Moving into C API compliance @subsection Some backports This section lists backports of recently added definitions that can be diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index a91a9c7de8f..f020f5e20d1 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -617,6 +617,9 @@ typedef enum { } cetype_t; cetype_t Rf_getCharCE(SEXP); +Rboolean Rf_charIsASCII(SEXP); +Rboolean Rf_charIsUTF8(SEXP); +Rboolean Rf_charIsLatin1(SEXP); SEXP Rf_mkCharCE(const char *, cetype_t); SEXP Rf_mkCharLenCE(const char *, int, cetype_t); const char *Rf_reEnc(const char *x, cetype_t ce_in, cetype_t ce_out, int subst); @@ -893,6 +896,9 @@ void R_orderVector1(int *indx, int n, SEXP x, Rboolean nalast, Rboolean de #define asLogical2 Rf_asLogical2 #define asReal Rf_asReal #define asS4 Rf_asS4 +#define charIsASCII Rf_charIsASCII +#define charIsUTF8 Rf_charIsUTF8 +#define charIsLatin1 Rf_charIsLatin1 #define classgets Rf_classgets #define coerceVector Rf_coerceVector #define conformable Rf_conformable diff --git a/src/main/sysutils.c b/src/main/sysutils.c index 6ab9c7faa0a..2e4f8ec824c 100644 --- a/src/main/sysutils.c +++ b/src/main/sysutils.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1997-2023 The R Core Team + * Copyright (C) 1997-2024 The R Core Team * Copyright (C) 1995-1996 Robert Gentleman and Ross Ihaka * * This program is free software; you can redistribute it and/or modify @@ -921,6 +921,30 @@ cetype_t getCharCE(SEXP x) else return CE_NATIVE; } +Rboolean charIsASCII(SEXP x) +{ + CHECK_CHARSXP(x); + return IS_ASCII(x) ? TRUE : FALSE; +} + +Rboolean charIsUTF8(SEXP x) +{ + CHECK_CHARSXP(x); + if (IS_ASCII(x) || IS_UTF8(x)) return TRUE; + if (IS_LATIN1(x) || IS_BYTES(x) || !utf8locale || x == NA_STRING) + return FALSE; + return TRUE; +} + +Rboolean charIsLatin1(SEXP x) +{ + CHECK_CHARSXP(x); + if (IS_ASCII(x) || IS_LATIN1(x)) return TRUE; + if (!latin1locale || IS_UTF8(x) || IS_BYTES(x) || x == NA_STRING) + return FALSE; + return TRUE; +} + #ifdef __APPLE__ /* Work-around for libiconv in macOS 14.1. When an invalid input byte is encountered while converting, one has to re-set the converter state. From b09b3e879dcf6b1b99b17e5bde4086eb0c097acd Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 19 Jun 2024 17:26:50 +0000 Subject: [PATCH 267/546] Replace used of findVarInFrame3 by findVarInFrame or R_existsVarInFrame. git-svn-id: https://svn.r-project.org/R/trunk@86790 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/grDevices/src/devWindows.c | 2 +- .../methods/src/methods_list_dispatch.c | 4 +-- src/main/builtin.c | 12 +++---- src/main/coerce.c | 4 +-- src/main/connections.c | 7 ++-- src/main/envir.c | 32 +++++++++---------- src/main/eval.c | 2 +- src/main/match.c | 2 +- src/main/objects.c | 19 +++++------ src/main/print.c | 14 ++++---- src/modules/internet/Rhttpd.c | 2 +- 11 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/library/grDevices/src/devWindows.c b/src/library/grDevices/src/devWindows.c index 881b78e04ac..6b08739f121 100644 --- a/src/library/grDevices/src/devWindows.c +++ b/src/library/grDevices/src/devWindows.c @@ -376,7 +376,7 @@ static void init_PS_PDF(void) { SEXP call, initS, grNS=R_FindNamespace(mkString("grDevices")); - initS = findVarInFrame3(grNS, install("initPSandPDFfonts"), TRUE); + initS = findVarInFrame(grNS, install("initPSandPDFfonts")); if(initS == R_UnboundValue) error("missing initPSandPDFfonts() in grDevices namespace: this should not happen"); PROTECT(call = lang1(initS)); diff --git a/src/library/methods/src/methods_list_dispatch.c b/src/library/methods/src/methods_list_dispatch.c index 0a56da4eb8d..bbfde92108a 100644 --- a/src/library/methods/src/methods_list_dispatch.c +++ b/src/library/methods/src/methods_list_dispatch.c @@ -755,14 +755,14 @@ SEXP R_nextMethodCall(SEXP matched_call, SEXP ev) /* for primitive .nextMethod's, suppress further dispatch to avoid * going into an infinite loop of method calls */ - PROTECT(op = findVarInFrame3(ev, R_dot_nextMethod, TRUE)); + PROTECT(op = findVarInFrame(ev, R_dot_nextMethod)); if(op == R_UnboundValue) error("internal error in 'callNextMethod': '.nextMethod' was not assigned in the frame of the method call"); PROTECT(e = shallow_duplicate(matched_call)); prim_case = isPrimitive(op); if (!prim_case) { if (inherits(op, "internalDispatchMethod")) { - SEXP generic = findVarInFrame3(ev, R_dot_Generic, TRUE); + SEXP generic = findVarInFrame(ev, R_dot_Generic); if(generic == R_UnboundValue) error("internal error in 'callNextMethod': '.Generic' was not assigned in the frame of the method call"); PROTECT(generic); diff --git a/src/main/builtin.c b/src/main/builtin.c index 64153329051..82952c4b07c 100644 --- a/src/main/builtin.c +++ b/src/main/builtin.c @@ -215,12 +215,12 @@ attribute_hidden SEXP do_args(SEXP call, SEXP op, SEXP args, SEXP rho) SEXP env, s2; PROTECT_INDEX xp; - PROTECT_WITH_INDEX(env = findVarInFrame3(R_BaseEnv, - install(".ArgsEnv"), TRUE), + PROTECT_WITH_INDEX(env = findVarInFrame(R_BaseEnv, + install(".ArgsEnv")), &xp); if (TYPEOF(env) == PROMSXP) REPROTECT(env = eval(env, R_BaseEnv), xp); - PROTECT(s2 = findVarInFrame3(env, install(nm), TRUE)); + PROTECT(s2 = findVarInFrame(env, install(nm))); if(s2 != R_UnboundValue) { s = duplicate(s2); SET_BODY(s, R_NilValue); @@ -229,10 +229,10 @@ attribute_hidden SEXP do_args(SEXP call, SEXP op, SEXP args, SEXP rho) return s; } UNPROTECT(1); /* s2 */ - REPROTECT(env = findVarInFrame3(R_BaseEnv, install(".GenericArgsEnv"), - TRUE), xp); + REPROTECT(env = findVarInFrame(R_BaseEnv, install(".GenericArgsEnv")), + xp); if (TYPEOF(env) == PROMSXP) REPROTECT(env = eval(env, R_BaseEnv), xp); - PROTECT(s2 = findVarInFrame3(env, install(nm), TRUE)); + PROTECT(s2 = findVarInFrame(env, install(nm))); if(s2 != R_UnboundValue) { s = allocSExp(CLOSXP); SET_FORMALS(s, FORMALS(s2)); diff --git a/src/main/coerce.c b/src/main/coerce.c index 532755f5c8a..483d53be098 100644 --- a/src/main/coerce.c +++ b/src/main/coerce.c @@ -2788,7 +2788,7 @@ SEXP substitute(SEXP lang, SEXP rho) return substitute(PREXPR(lang), rho); case SYMSXP: if (rho != R_NilValue) { - t = findVarInFrame3( rho, lang, TRUE); + t = findVarInFrame( rho, lang); if (t != R_UnboundValue) { if (TYPEOF(t) == PROMSXP) { do { @@ -2832,7 +2832,7 @@ attribute_hidden SEXP substituteList(SEXP el, SEXP rho) if (rho == R_NilValue) h = R_UnboundValue; /* so there is no substitution below */ else - h = findVarInFrame3(rho, CAR(el), TRUE); + h = findVarInFrame(rho, CAR(el)); if (h == R_UnboundValue) h = LCONS(R_DotsSymbol, R_NilValue); else if (h == R_NilValue || h == R_MissingArg) diff --git a/src/main/connections.c b/src/main/connections.c index 0da64528931..0f5dcbf49ca 100644 --- a/src/main/connections.c +++ b/src/main/connections.c @@ -3291,8 +3291,7 @@ static void outtext_close(Rconnection con) int idx = ConnIndex(con); SEXP tmp, env = VECTOR_ELT(OutTextData, idx); - if(this->namesymbol && - findVarInFrame3(env, this->namesymbol, FALSE) != R_UnboundValue) + if(this->namesymbol && R_existsVarInFrame(env, this->namesymbol)) R_unLockBinding(this->namesymbol, env); if(strlen(this->lastline) > 0) { PROTECT(tmp = xlengthgets(this->data, ++this->len)); @@ -3373,8 +3372,8 @@ static int text_vfprintf(Rconnection con, const char *format, va_list ap) PROTECT(tmp = xlengthgets(this->data, ++this->len)); SET_STRING_ELT(tmp, this->len - 1, mkCharLocal(p)); if(this->namesymbol) { - if(findVarInFrame3(env, this->namesymbol, FALSE) - != R_UnboundValue) R_unLockBinding(this->namesymbol, env); + if(R_existsVarInFrame(env, this->namesymbol)) + R_unLockBinding(this->namesymbol, env); defineVar(this->namesymbol, tmp, env); R_LockBinding(this->namesymbol, env); } else { diff --git a/src/main/envir.c b/src/main/envir.c index cbd917b3e0d..89a28d2bb79 100644 --- a/src/main/envir.c +++ b/src/main/envir.c @@ -1155,12 +1155,12 @@ void readS3VarsFromFrame(SEXP rho, slowpath: /* fall back to the slow but general implementation */ - *dotGeneric = findVarInFrame3(rho, R_dot_Generic, TRUE); - *dotClass = findVarInFrame3(rho, R_dot_Class, TRUE); - *dotMethod = findVarInFrame3(rho, R_dot_Method, TRUE); - *dotGroup = findVarInFrame3(rho, R_dot_Group, TRUE); - *dotGenericCallEnv = findVarInFrame3(rho, R_dot_GenericCallEnv, TRUE); - *dotGenericDefEnv = findVarInFrame3(rho, R_dot_GenericDefEnv, TRUE); + *dotGeneric = findVarInFrame(rho, R_dot_Generic); + *dotClass = findVarInFrame(rho, R_dot_Class); + *dotMethod = findVarInFrame(rho, R_dot_Method); + *dotGroup = findVarInFrame(rho, R_dot_Group); + *dotGenericCallEnv = findVarInFrame(rho, R_dot_GenericCallEnv); + *dotGenericDefEnv = findVarInFrame(rho, R_dot_GenericDefEnv); } @@ -1227,7 +1227,7 @@ SEXP findVar(SEXP symbol, SEXP rho) will also handle all frames if rho is a global frame other than R_GlobalEnv */ while (rho != R_GlobalEnv && rho != R_EmptyEnv) { - vl = findVarInFrame3(rho, symbol, TRUE /* get rather than exists */); + vl = findVarInFrame(rho, symbol); if (vl != R_UnboundValue) return (vl); rho = ENCLOS(rho); } @@ -1237,7 +1237,7 @@ SEXP findVar(SEXP symbol, SEXP rho) return R_UnboundValue; #else while (rho != R_EmptyEnv) { - vl = findVarInFrame3(rho, symbol, TRUE); + vl = findVarInFrame(rho, symbol); if (vl != R_UnboundValue) return (vl); rho = ENCLOS(rho); } @@ -1301,7 +1301,7 @@ findVar1(SEXP symbol, SEXP rho, SEXPTYPE mode, int inherits) { SEXP vl; while (rho != R_EmptyEnv) { - vl = findVarInFrame3(rho, symbol, TRUE); + vl = findVarInFrame(rho, symbol); if (vl != R_UnboundValue) { if (mode == ANYSXP) return vl; if (TYPEOF(vl) == PROMSXP) { @@ -1514,7 +1514,7 @@ SEXP dynamicfindVar(SEXP symbol, RCNTXT *cptr) SEXP vl; while (cptr != R_ToplevelContext) { if (cptr->callflag & CTXT_FUNCTION) { - vl = findVarInFrame3(cptr->cloenv, symbol, TRUE); + vl = findVarInFrame(cptr->cloenv, symbol); if (vl != R_UnboundValue) return vl; } cptr = cptr->nextcontext; @@ -1564,9 +1564,9 @@ SEXP findFun3(SEXP symbol, SEXP rho, SEXP call) vl = findGlobalVar(symbol); #endif else - vl = findVarInFrame3(rho, symbol, TRUE); + vl = findVarInFrame(rho, symbol); #else - vl = findVarInFrame3(rho, symbol, TRUE); + vl = findVarInFrame(rho, symbol); #endif if (vl != R_UnboundValue) { if (TYPEOF(vl) == PROMSXP) { @@ -3731,10 +3731,10 @@ Rboolean R_IsNamespaceEnv(SEXP rho) if (rho == R_BaseNamespace) return TRUE; else if (TYPEOF(rho) == ENVSXP) { - SEXP info = findVarInFrame3(rho, R_NamespaceSymbol, TRUE); + SEXP info = findVarInFrame(rho, R_NamespaceSymbol); if (info != R_UnboundValue && TYPEOF(info) == ENVSXP) { PROTECT(info); - SEXP spec = findVarInFrame3(info, install("spec"), TRUE); + SEXP spec = findVarInFrame(info, install("spec")); UNPROTECT(1); if (spec != R_UnboundValue && TYPEOF(spec) == STRSXP && LENGTH(spec) > 0) @@ -3762,10 +3762,10 @@ SEXP R_NamespaceEnvSpec(SEXP rho) if (rho == R_BaseNamespace) return R_BaseNamespaceName; else if (TYPEOF(rho) == ENVSXP) { - SEXP info = findVarInFrame3(rho, R_NamespaceSymbol, TRUE); + SEXP info = findVarInFrame(rho, R_NamespaceSymbol); if (info != R_UnboundValue && TYPEOF(info) == ENVSXP) { PROTECT(info); - SEXP spec = findVarInFrame3(info, install("spec"), TRUE); + SEXP spec = findVarInFrame(info, install("spec")); UNPROTECT(1); if (spec != R_UnboundValue && TYPEOF(spec) == STRSXP && LENGTH(spec) > 0) diff --git a/src/main/eval.c b/src/main/eval.c index 6011e257c14..1670cb7c323 100644 --- a/src/main/eval.c +++ b/src/main/eval.c @@ -2584,7 +2584,7 @@ static SEXP EnsureLocal(SEXP symbol, SEXP rho, R_varloc_t *ploc) { SEXP vl; - if ((vl = findVarInFrame3(rho, symbol, TRUE)) != R_UnboundValue) { + if ((vl = findVarInFrame(rho, symbol)) != R_UnboundValue) { vl = eval(symbol, rho); /* for promises */ if(MAYBE_SHARED(vl)) { /* Using R_shallow_duplicate_attr may defer duplicating diff --git a/src/main/match.c b/src/main/match.c index dca4533bf43..54a84cc4f0d 100644 --- a/src/main/match.c +++ b/src/main/match.c @@ -424,7 +424,7 @@ static R_INLINE void patchArgument(SEXP suppliedSlot, SEXP name, fstype_t *farg, SEXP cloenv) { SEXP value = CAR(suppliedSlot); if (value == R_MissingArg) { - value = findVarInFrame3(cloenv, name, TRUE); + value = findVarInFrame(cloenv, name); if (value == R_MissingArg) { if (farg) *farg = FS_MATCHED_MISSING; return; diff --git a/src/main/objects.c b/src/main/objects.c index 8c6775295b7..035520cea08 100644 --- a/src/main/objects.c +++ b/src/main/objects.c @@ -171,7 +171,7 @@ static SEXP findFunInEnvRange(SEXP symbol, SEXP rho, SEXP target) { SEXP vl; while(rho != R_EmptyEnv) { - vl = findVarInFrame3(rho, symbol, TRUE); + vl = findVarInFrame(rho, symbol); if (vl != R_UnboundValue) { if (TYPEOF(vl) == PROMSXP) { PROTECT(vl); @@ -195,7 +195,7 @@ static SEXP findFunWithBaseEnvAfterGlobalEnv(SEXP symbol, SEXP rho) { SEXP vl; while(rho != R_EmptyEnv) { - vl = findVarInFrame3(rho, symbol, TRUE); + vl = findVarInFrame(rho, symbol); if (vl != R_UnboundValue) { if (TYPEOF(vl) == PROMSXP) { PROTECT(vl); @@ -264,7 +264,7 @@ SEXP R_LookupMethod(SEXP method, SEXP rho, SEXP callrho, SEXP defrho) /* We assume here that no one registered a non-function */ if (!s_S3MethodsTable) s_S3MethodsTable = install(".__S3MethodsTable__."); - SEXP table = findVarInFrame3(defrho, s_S3MethodsTable, TRUE); + SEXP table = findVarInFrame(defrho, s_S3MethodsTable); if (TYPEOF(table) == PROMSXP) { PROTECT(table); table = eval(table, R_BaseEnv); @@ -272,7 +272,7 @@ SEXP R_LookupMethod(SEXP method, SEXP rho, SEXP callrho, SEXP defrho) } if (TYPEOF(table) == ENVSXP) { PROTECT(table); - REPROTECT(val = findVarInFrame3(table, method, TRUE), validx); + REPROTECT(val = findVarInFrame(table, method), validx); UNPROTECT(1); /* table */ if (TYPEOF(val) == PROMSXP) REPROTECT(val = eval(val, rho), validx); @@ -307,7 +307,8 @@ static int match_to_obj(SEXP arg, SEXP obj) { attribute_hidden int isBasicClass(const char *ss) { static SEXP s_S3table = NULL; if(!s_S3table) { - s_S3table = findVarInFrame3(R_MethodsNamespace, install(".S3MethodsClasses"), TRUE); + s_S3table = findVarInFrame(R_MethodsNamespace, + install(".S3MethodsClasses")); if(s_S3table == R_UnboundValue) error(_("no '.S3MethodsClass' table, cannot use S4 objects with S3 methods ('methods' package not attached?)")); if (TYPEOF(s_S3table) == PROMSXP) /* findVar... ignores lazy data */ @@ -315,7 +316,7 @@ attribute_hidden int isBasicClass(const char *ss) { } if(s_S3table == R_UnboundValue) return FALSE; /* too screwed up to do conversions */ - return findVarInFrame3(s_S3table, install(ss), FALSE) != R_UnboundValue; + return R_existsVarInFrame(s_S3table, install(ss)); } /* Note that ./attrib.c 's S4_extends() has an alternative @@ -769,7 +770,7 @@ attribute_hidden SEXP do_nextmethod(SEXP call, SEXP op, SEXP args, SEXP env) s = CADDR(args); /* this is ... and we need to see if it's bound */ if (s == R_DotsSymbol) { - t = findVarInFrame3(env, s, TRUE); + t = findVarInFrame(env, s); if (t != R_NilValue && t != R_MissingArg) { SET_TYPEOF(t, LISTSXP); /* a safe mutation */ s = matchmethargs(matchedarg, t); @@ -1280,11 +1281,11 @@ static SEXP dispatchNonGeneric(SEXP name, SEXP env, SEXP fdef) symbol = installTrChar(asChar(name)); for(rho = ENCLOS(env); rho != R_EmptyEnv; rho = ENCLOS(rho)) { - fun = findVarInFrame3(rho, symbol, TRUE); + fun = findVarInFrame(rho, symbol); if(fun == R_UnboundValue) continue; switch(TYPEOF(fun)) { case CLOSXP: - value = findVarInFrame3(CLOENV(fun), R_dot_Generic, TRUE); + value = findVarInFrame(CLOENV(fun), R_dot_Generic); if(value == R_UnboundValue) break; case BUILTINSXP: case SPECIALSXP: default: diff --git a/src/main/print.c b/src/main/print.c index 1ad62cc207f..74819ca98d8 100644 --- a/src/main/print.c +++ b/src/main/print.c @@ -341,7 +341,7 @@ static void PrintObjectS4(SEXP s, R_PrintData *data) if (methodsNS == R_UnboundValue) error("missing methods namespace: this should not happen"); - SEXP fun = findVarInFrame3(methodsNS, install("show"), TRUE); + SEXP fun = findVarInFrame(methodsNS, install("show")); if (TYPEOF(fun) == PROMSXP) { PROTECT(fun); fun = eval(fun, R_BaseEnv); @@ -788,18 +788,18 @@ static void PrintSpecial(SEXP s, R_PrintData *data) char *nm = PRIMNAME(s); SEXP env, s2; PROTECT_INDEX xp; - PROTECT_WITH_INDEX(env = findVarInFrame3(R_BaseEnv, - install(".ArgsEnv"), TRUE), + PROTECT_WITH_INDEX(env = findVarInFrame(R_BaseEnv, + install(".ArgsEnv")), &xp); if (TYPEOF(env) == PROMSXP) REPROTECT(env = eval(env, R_BaseEnv), xp); - s2 = findVarInFrame3(env, install(nm), TRUE); + s2 = findVarInFrame(env, install(nm)); if(s2 == R_UnboundValue) { - REPROTECT(env = findVarInFrame3(R_BaseEnv, - install(".GenericArgsEnv"), TRUE), + REPROTECT(env = findVarInFrame(R_BaseEnv, + install(".GenericArgsEnv")), xp); if (TYPEOF(env) == PROMSXP) REPROTECT(env = eval(env, R_BaseEnv), xp); - s2 = findVarInFrame3(env, install(nm), TRUE); + s2 = findVarInFrame(env, install(nm)); } if(s2 != R_UnboundValue) { SEXP t; diff --git a/src/modules/internet/Rhttpd.c b/src/modules/internet/Rhttpd.c index 0c83201fca7..a392e0379c5 100644 --- a/src/modules/internet/Rhttpd.c +++ b/src/modules/internet/Rhttpd.c @@ -549,7 +549,7 @@ static SEXP handler_for_path(const char *path) { } /* we only proceed if .httpd.handlers.env really exists */ if (TYPEOF(custom_handlers_env) == ENVSXP) { - SEXP cl = findVarInFrame3(custom_handlers_env, install(fn), TRUE); + SEXP cl = findVarInFrame(custom_handlers_env, install(fn)); if (cl != R_UnboundValue && TYPEOF(cl) == CLOSXP) /* we need a closure */ return cl; } From 9ac7e751924a47f89ac5f5ce3699b866bb8907e4 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 19 Jun 2024 18:54:00 +0000 Subject: [PATCH 268/546] Add findVarInFrame3 to tools:::nonAPI. git-svn-id: https://svn.r-project.org/R/trunk@86791 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 11 ++++++----- src/library/tools/R/sotools.R | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 9128556872d..fb58796b669 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -111,11 +111,12 @@ \code{DDVAL}, \code{ENSURE_NAMEDMAX}, \code{ENVFLAGS}, \code{FRAME}, \code{HASHTAB}, \code{INTERNAL}, \code{IS_ASCII}, \code{IS_UTF8}, \code{LEVELS}, \code{NAMED}, \code{PRSEEN}, - \code{RDEBUG}, \code{REAL0}, \code{SET_BODY}, \code{SET_CLOENV}, - \code{SET_FORMALS}, \code{SET_PRSEEN}, \code{SET_RDEBUG}, - \code{STRING_PTR}, \code{SYMVALUE}, and \code{VECTOR_PTR}. Any - declarations for these in public header files will be removed in - the near future, and they will be hidden where possible. + \code{RDEBUG}, \code{REAL0}, \code{Rf_findVarInFrame3}, + \code{SET_BODY}, \code{SET_CLOENV}, \code{SET_FORMALS}, + \code{SET_PRSEEN}, \code{SET_RDEBUG}, \code{STRING_PTR}, + \code{SYMVALUE}, and \code{VECTOR_PTR}. Any declarations for these + in public header files will be removed in the near future, and + they will be hidden where possible. \item \sQuote{Writing R Extensions} has a new section \sQuote{Moving into C API compliance} to help package authors move diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 1adda9f5884..6eb9239e488 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -684,7 +684,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "REAL0", "COMPLEX0", "LEVELS", "FRAME", "HASHTAB", "ENVFLAGS", "RDEBUG", "SET_RDEBUG", "STRING_PTR", "VECTOR_PTR", - "SET_FORMALS", "SET_BODY", "SET_CLOENV", + "SET_FORMALS", "SET_BODY", "SET_CLOENV", "Rf_findVarInFrame3", ## in the non-API header R_ext/Connections.h "R_new_custom_connection", "R_ReadConnection", "R_WriteConnection", "R_GetConnection", From a86dc9fd982d3a9d85fc9ca7f59d3f1e886666af Mon Sep 17 00:00:00 2001 From: kalibera Date: Wed, 19 Jun 2024 19:02:45 +0000 Subject: [PATCH 269/546] Fix/remove comment. git-svn-id: https://svn.r-project.org/R/trunk@86792 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/envir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/envir.c b/src/main/envir.c index 89a28d2bb79..c6810e46ef1 100644 --- a/src/main/envir.c +++ b/src/main/envir.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1999--2023 The R Core Team. + * Copyright (C) 1999--2024 The R Core Team. * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka * * This program is free software; you can redistribute it and/or modify @@ -1086,7 +1086,6 @@ Rboolean R_existsVarInFrame(SEXP rho, SEXP symbol) SET_HASHASH(c, 1); } hashcode = HASHVALUE(c) % HASHSIZE(HASHTAB(rho)); - /* Will return 'R_UnboundValue' if not found */ return R_HashExists(hashcode, symbol, HASHTAB(rho)); } return FALSE; From a068a0f52b9ae871212779b2c1571a999f23ef81 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 19 Jun 2024 19:30:52 +0000 Subject: [PATCH 270/546] Add somehting on using R_existsVarInFrame instead of findVarInFrame3. git-svn-id: https://svn.r-project.org/R/trunk@86793 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 2c308904659..631f8709bd1 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -17340,6 +17340,8 @@ functions that should be used instead: @item IS_UTF8 Use @code{charIsUTF8}, added in @R{} 4.5.0, and check semantical differences. +@item findVarInFrame3 + Use @code{R_existsVarInFrame} to test for existence. @end table For recently added entry points packages that need to be compiled From 9cd396f39d3ea47884753e0fc5dd0653c8316230 Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 20 Jun 2024 08:13:38 +0000 Subject: [PATCH 271/546] Example for encoding macros. git-svn-id: https://svn.r-project.org/R/trunk@86794 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 631f8709bd1..07e72416230 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14777,7 +14777,8 @@ can be used to detect whether the internal representation of a given function is rarely needed and specifically is not needed with @code{translateCharUTF8}, because such check is already included. However, when needed, it is better to use it in preference of @code{getCharCE}, as it -is safer against future changes in the semantics of encoding marks. Note +is safer against future changes in the semantics of encoding marks and +covers strings internally represented in the native encoding. Note that @code{charIsUTF8()} is not equivalent to @code{getCharCE() == CE_UTF8}. Similarly, function @@ -17338,8 +17339,7 @@ functions that should be used instead: @item IS_ASCII Use @code{charIsASCII}, added in @R{} 4.5.0. @item IS_UTF8 - Use @code{charIsUTF8}, added in @R{} 4.5.0, and check semantical - differences. + Use @code{charIsUTF8}, added in @R{} 4.5.0, or avoid completely. @item findVarInFrame3 Use @code{R_existsVarInFrame} to test for existence. @end table @@ -17447,9 +17447,31 @@ on most systems running R). Several packages use the encoding information to find out whether an internal string representation visible via @code{CHAR} is UTF-8 or latin1. @R{} 4.5.0 provides functions @code{charIsUTF8} and @code{charIsLatin1} for -this purpose, which are simpler to use and safer against future changes. -Note that both will be true for ASCII strings and they handle also native -strings when running in the corresponding locale. +this purpose, which are safer against future changes and handle also native +strings when running in the corresponding locale. Note that both will be +true for ASCII strings. + +A pattern used in several packages is +@example +char *asutf8(SEXP c) +@{ + if (!IS_UTF8(s) && !IS_ASCII(s)) // not compliant + return Rf_translateCharUTF8(s); + else + return CHAR(s); +@} +@end example + +to make this code compliant, simply call +@example +char *asutf8(SEXP c) +@{ + return Rf_translateCharUTF8(s); // compliant +@} +@end example + +as the encoding flags are already checked in @code{translateCharUTF8}. Also +note the non-compliant check doesn't handle native encoding. @node Some backports, , Querying CHARSXP encoding, Moving into C API compliance @subsection Some backports From 204268b015fa98c8df2f5970b7e5077865b81357 Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 20 Jun 2024 17:21:09 +0000 Subject: [PATCH 272/546] Fix memory corruption in writeClipboard on Windows (PR#18747, thanks to Ivan Krylov and Tanguy Barthelemy). git-svn-id: https://svn.r-project.org/R/trunk@86795 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/src/windows/util.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/library/utils/src/windows/util.c b/src/library/utils/src/windows/util.c index a936276dc24..494f750a901 100644 --- a/src/library/utils/src/windows/util.c +++ b/src/library/utils/src/windows/util.c @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * file util.c - * Copyright (C) 2005--2023 The R Core Team + * Copyright (C) 2005--2024 The R Core Team * Copyright (C) 1998--2003 Guido Masarotto and Brian Ripley * Copyright (C) 2004 The R Foundation * @@ -292,15 +292,17 @@ SEXP writeClipboard(SEXP text, SEXP sformat) n = length(text); if(n > 0) { - int len = 1; + int len = 0; if(raw) len = n; - else if (format == CF_UNICODETEXT) + else if (format == CF_UNICODETEXT) { + len = 2; /* terminator */ for(i = 0; i < n; i++) len += 2 * (wcslen(wtransChar(STRING_ELT(text, i))) + 2); - else if (format == CF_TEXT || format == CF_OEMTEXT || format == CF_DIF) + } else if (format == CF_TEXT || format == CF_OEMTEXT || format == CF_DIF) { + len = 1; /* terminator */ for(i = 0; i < n; i++) len += strlen(translateChar(STRING_ELT(text, i))) + 2; - else + } else error("'raw = FALSE' and format is a not a known text format"); if ( (hglb = GlobalAlloc(GHND, len)) && From 09d0da16d0146fecee00bded209e295fb8f97473 Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 21 Jun 2024 13:47:36 +0000 Subject: [PATCH 273/546] as.data.frame.list() keeps `NA` (col.)names; new arg `new.names`; format() new arg `cut.names` git-svn-id: https://svn.r-project.org/R/trunk@86797 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 5 +++++ src/library/base/R/dataframe.R | 7 +++++-- src/library/base/R/format.R | 26 +++++++++++++++----------- src/library/base/man/as.data.frame.Rd | 2 ++ src/library/base/man/format.Rd | 7 +++++-- tests/reg-tests-1e.R | 26 ++++++++++++++++++++++++++ 6 files changed, 58 insertions(+), 15 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index fb58796b669..bbef7524c40 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -144,6 +144,11 @@ \itemize{ \item Auto-generated \code{citation()} entries no longer include (additional) URLs in the \samp{note} field (\PR{18547}). + + \item \code{as.data.frame.list()} gets new option \code{new.names} + and now preserves \code{NA} names, thus fixing the \code{format()} + method for data frames, and also bug \PR{18745}. + Relatedly, the \code{format()} method gets option \code{cut.names}. } } } diff --git a/src/library/base/R/dataframe.R b/src/library/base/R/dataframe.R index 30000ef7d88..3e1837574b3 100644 --- a/src/library/base/R/dataframe.R +++ b/src/library/base/R/dataframe.R @@ -216,12 +216,12 @@ as.data.frame.data.frame <- function(x, row.names = NULL, ...) as.data.frame.list <- function(x, row.names = NULL, optional = FALSE, ..., cut.names = FALSE, col.names = names(x), fix.empty.names = TRUE, + new.names = !missing(col.names), check.names = !optional, stringsAsFactors = FALSE) { ## need to protect names in x. ## truncate any of more than 256 (or cut.names) bytes: - new.nms <- !missing(col.names) if(cut.names) { maxL <- if(is.logical(cut.names)) 256L else as.integer(cut.names) if(any(long <- nchar(col.names, "bytes", keepNA = FALSE) > maxL)) @@ -232,12 +232,15 @@ as.data.frame.list <- ## c("row.names", "check.rows", ...., "stringsAsFactors"), col.names, 0L) if(any.m <- any(m)) col.names[m] <- paste0("..adfl.", col.names[m]) - if(new.nms || any.m || cut.names) names(x) <- col.names + if(Nnms <- new.names || any.m || cut.names) names(x) <- col.names ## data.frame() is picky with its 'row.names': alis <- c(list(check.names = check.names, fix.empty.names = fix.empty.names, stringsAsFactors = stringsAsFactors), if(!missing(row.names)) list(row.names = row.names)) x <- do.call(data.frame, c(x, alis)) + if(Nnms && !identical(col.names, nx <- names(x)) && + length(nx) == length(col.names)) ## e.g. w/ NA_character_ in col.names + names(x) <- col.names if(any.m) names(x) <- sub("^\\.\\.adfl\\.", "", names(x)) x } diff --git a/src/library/base/R/format.R b/src/library/base/R/format.R index c9eee62deb7..63fef83651e 100644 --- a/src/library/base/R/format.R +++ b/src/library/base/R/format.R @@ -1,7 +1,7 @@ # File src/library/base/R/format.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2021 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -80,6 +80,8 @@ format.default <- } } +## Here in base, as used by summary.table()'s printing +## NB: stats ::: format_perc() format.pval <- function(pv, digits = max(1L, getOption("digits") - 2L), eps = .Machine$double.eps, na.form = "NA", ...) { @@ -134,7 +136,8 @@ formatC <- function (x, digits = NULL, width = NULL, } ## sanity check for flags added 2.1.0 flag <- as.character(flag) - if(length(flag) != 1) stop("'flag' must be a string, i.e., of length 1") + if(length(flag) != 1) + stop(gettextf("'%s' must be a character string", "flag"), domain = NA) nf <- strsplit(flag, "")[[1L]] if(!all(nf %in% c("0", "+", "-", " ", "#", "'", "I"))) stop("'flag' should contain only characters from [0+- #'I]") @@ -237,7 +240,7 @@ format.factor <- function (x, ...) dim=dim(x), dimnames=dimnames(x)), ...) -format.data.frame <- function(x, ..., justify = "none") +format.data.frame <- function(x, ..., justify = "none", cut.names = TRUE) { nc <- length(x) if(!nc) return(x) # 0 columns: evade problems, notably for nrow() > 0 @@ -251,13 +254,14 @@ format.data.frame <- function(x, ..., justify = "none") for(i in seq_len(nc)) { len <- NROW(rval[[i]]) if(len == nr) next - if(length(dim(rval[[i]])) == 2L) { - rval[[i]] <- if(len < nr) - rbind(rval[[i]], matrix(NA, nr-len, ncol(rval[[i]]))) - else rval[[i]][seq_len(nr),] - } else { - rval[[i]] <- if(len < nr) c(rval[[i]], rep.int(NA, nr-len)) - else rval[[i]][seq_len(nr)] + rval[[i]] <- + if(length(dim(rval[[i]])) == 2L) { + if(len < nr) + rbind(rval[[i]], matrix(NA, nr-len, ncol(rval[[i]]))) + else rval[[i]][seq_len(nr),] + } else { + if(len < nr) c(rval[[i]], rep.int(NA, nr-len)) + else rval[[i]][seq_len(nr)] } } } @@ -269,7 +273,7 @@ format.data.frame <- function(x, ..., justify = "none") row.names = seq_len(nr), col.names = names(x), optional = TRUE, # <=> check.names = FALSE - fix.empty.names = FALSE, cut.names = TRUE) + fix.empty.names = FALSE, cut.names = cut.names) attr(y, "row.names") <- row.names(x) y } diff --git a/src/library/base/man/as.data.frame.Rd b/src/library/base/man/as.data.frame.Rd index 9d49c838699..5009a50ced0 100644 --- a/src/library/base/man/as.data.frame.Rd +++ b/src/library/base/man/as.data.frame.Rd @@ -29,6 +29,7 @@ as.data.frame(x, row.names = NULL, optional = FALSE, \dots) \method{as.data.frame}{list}(x, row.names = NULL, optional = FALSE, \dots, cut.names = FALSE, col.names = names(x), fix.empty.names = TRUE, + new.names = !missing(col.names), check.names = !optional, stringsAsFactors = FALSE) @@ -62,6 +63,7 @@ is.data.frame(x) \item{col.names}{(optional) character vector of column names.} \item{fix.empty.names}{logical indicating if empty column names, i.e., \code{""} should be fixed up (in \code{\link{data.frame}}) or not.} + \item{new.names}{logical indicating that \code{col.names} should be set explicitly.} \item{check.names}{logical; passed to the \code{\link{data.frame}()} call.} %% matrix method: \item{make.names}{a \code{\link{logical}}, i.e., one of \code{FALSE, NA, TRUE}, diff --git a/src/library/base/man/format.Rd b/src/library/base/man/format.Rd index 8bd1fc8312f..2f3da2a8049 100644 --- a/src/library/base/man/format.Rd +++ b/src/library/base/man/format.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/format.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2023 R Core Team +% Copyright 1995-2024 R Core Team % Copyright 2003-2016 The R Foundation % Distributed under GPL 2 or later @@ -25,7 +25,7 @@ format(x, \dots) decimal.mark = getOption("OutDec"), zero.print = NULL, drop0trailing = FALSE, \dots) -\method{format}{data.frame}(x, \dots, justify = "none") +\method{format}{data.frame}(x, \dots, justify = "none", cut.names = TRUE) \method{format}{factor}(x, \dots) @@ -54,6 +54,9 @@ format(x, \dots) \item{justify}{should a \emph{character} vector be left-justified (the default), right-justified, centred or left alone. Can be abbreviated.} + \item{cut.names}{\code{\link{logical}} passed to the \code{list} method + of \code{\link{as.data.frame}()}.} + \item{width}{\code{default} method: the \emph{minimum} field width or \code{NULL} or \code{0} for no restriction. diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 08bbea1e266..13d21685348 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1410,6 +1410,32 @@ stopifnot(identical(ch0, tools::toTitleCase(ch0))) ## was list() in R <= 4.4.0 +## PR#18745 (+ PR#18702) format.data.frame() -> as.data.frame.list() +x <- setNames(data.frame(TRUE), NA_character_) +(fx <- format(x)) +dN <- data.frame(a = c(1,NA), b = c("a",NA), + c3 = c("NA", NA), c4 = c(NA, FALSE)) +names(dN) <- nms <- c("num", "ch", NA, NA) +(fdN <- format(dN)) +L <- list(A = FALSE); names(L) <- NA + dL1 <- as.data.frame.list(L, col.names = names(L)) + dL2 <- as.data.frame.list(L, col.names = names(L), check.names=FALSE) +str(dL <- as.data.frame.list(L, new.names=TRUE)) +stopifnot(exprs = { + is.na(names(x)) + is.data.frame(fx) + identical(NA_character_, names(x)) + identical(NA_character_, names(fx)) # was "NA" wrongly + identical(NA_character_, names(dL)) + identical(nms, names( dN)) + identical(nms, names(fdN)) # was .. .. "NA" "NA" + identical(dL1, dL2)# was always TRUE + identical(dL, dL1) # was FALSE +}) +## format() and as.data.frame(, col.names=*, check.names=FALSE) *did* +## change NA names() into "NA" for R <= 4.4.1 + + ## keep at end rbind(last = proc.time() - .pt, From c23aff8a64e32164d466ba4bc1bcf72835788bb5 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 21 Jun 2024 14:28:03 +0000 Subject: [PATCH 274/546] Add more entry points to tools:::nonAPI. git-svn-id: https://svn.r-project.org/R/trunk@86798 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 8 ++++++++ src/library/tools/R/sotools.R | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index bbef7524c40..6ed09154afa 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -127,6 +127,14 @@ \item Some \samp{NOTE}s for use of non-API entry points have been upgraded to \samp{WARNING}s in preparation for removing declarations and, where possible, hiding these entry points. + + \item Additional non-API entry points added to those reported by + \command{R CMD check}: \code{IS_LONG_VEC}, \code{PRCODE}, + \code{PRENV}, \code{PRVALUE}, \code{R_nchar}, + \code{Rf_isValidString}, \code{Rf_isValidStringF}, + \code{Rf_NonNullStringMatch}, \code{Rf_StringBlank}, + \code{SET_TYPEOF}, \code{TRUELENGTH}, \code{XLENGTH_EX}, + and \code{XTRUELENGTH}. } } diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 6eb9239e488..0170d1d5666 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -685,6 +685,10 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "ENVFLAGS", "RDEBUG", "SET_RDEBUG", "STRING_PTR", "VECTOR_PTR", "SET_FORMALS", "SET_BODY", "SET_CLOENV", "Rf_findVarInFrame3", + "IS_LONG_VEC", "PRCODE", "PRENV", "PRVALUE", "R_nchar", + "Rf_isValidString", "Rf_isValidStringF", "Rf_NonNullStringMatch", + "Rf_StringBlank", "SET_TYPEOF", "TRUELENGTH", "XLENGTH_EX", + "XTRUELENGTH", ## in the non-API header R_ext/Connections.h "R_new_custom_connection", "R_ReadConnection", "R_WriteConnection", "R_GetConnection", From 01bd984f146c9e2f9f8eb9e04d015ce773b6f7e9 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 21 Jun 2024 15:46:28 +0000 Subject: [PATCH 275/546] Add psmatch as @eapifun. git-svn-id: https://svn.r-project.org/R/trunk@86799 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 5 ++++- src/library/tools/R/sotools.R | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 07e72416230..934d6c01d0f 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13494,9 +13494,12 @@ include @code{R_existsVarInFrame}, @code{R_removeVarFromFrame}, @eapifun R_NamespaceEnvSpec @eapifun R_IsNamespaceEnv -The C functions @code{match} and @code{psmatch} correspond to the @R{} functions by the same name. +The C functions @code{match} and @code{pmatch} correspond to the @R{} +functions by the same name. @eapifun match @eapifun pmatch +The C-level workhorse for partial matching is provided by @code{psmatch}. +@eapifun psmatch The C functions @code{R_forceAndCall} and @code{isUnsorted} correspond to the @R{} functions @code{forceAndCall} and @code{is.unsorted}. diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 0170d1d5666..a61f1e9c292 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -673,7 +673,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", ## not yet, in Rcpp headers "SET_TYPEOF", ## not yet, used in an example in R-exts "SET_OBJECT", "SET_S4_OBJECT", "UNSET_S4_OBJECT", - "R_curErrorBuf", "IS_SCALAR", "Rf_psmatch", + "R_curErrorBuf", "IS_SCALAR", "SETLENGTH", "SET_TRUELENGTH", "SETLEVELS", "SET_ENVFLAGS", "SET_FRAME", "SET_ENCLOS", "SET_HASHTAB", "SET_PRENV", "SET_PRVALUE", "SET_PRCODE", "STDVEC_DATAPTR", From f00a77957512a6a0ea1095dbe44b2da2fe1a7e43 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 21 Jun 2024 16:00:21 +0000 Subject: [PATCH 276/546] Added error checking to external pointer accessors. git-svn-id: https://svn.r-project.org/R/trunk@86800 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/memory.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/memory.c b/src/main/memory.c index 8bee4358200..65edda99409 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -3794,33 +3794,44 @@ SEXP R_MakeExternalPtr(void *p, SEXP tag, SEXP prot) return s; } +#define CHKEXTPTRSXP(x) \ + if (TYPEOF(x) != EXTPTRSXP) \ + error(_("%s: argument of type %s is not an external pointer"), \ + __func__, sexptype2char(TYPEOF(x))) + void *R_ExternalPtrAddr(SEXP s) { + CHKEXTPTRSXP(s); return EXTPTR_PTR(CHK(s)); } SEXP R_ExternalPtrTag(SEXP s) { + CHKEXTPTRSXP(s); return CHK(EXTPTR_TAG(CHK(s))); } SEXP R_ExternalPtrProtected(SEXP s) { + CHKEXTPTRSXP(s); return CHK(EXTPTR_PROT(CHK(s))); } void R_ClearExternalPtr(SEXP s) { + CHKEXTPTRSXP(s); EXTPTR_PTR(s) = NULL; } void R_SetExternalPtrAddr(SEXP s, void *p) { + CHKEXTPTRSXP(s); EXTPTR_PTR(s) = p; } void R_SetExternalPtrTag(SEXP s, SEXP tag) { + CHKEXTPTRSXP(s); FIX_REFCNT(s, EXTPTR_TAG(s), tag); CHECK_OLD_TO_NEW(s, tag); EXTPTR_TAG(s) = tag; @@ -3828,6 +3839,7 @@ void R_SetExternalPtrTag(SEXP s, SEXP tag) void R_SetExternalPtrProtected(SEXP s, SEXP p) { + CHKEXTPTRSXP(s); FIX_REFCNT(s, EXTPTR_PROT(s), p); CHECK_OLD_TO_NEW(s, p); EXTPTR_PROT(s) = p; @@ -3852,6 +3864,7 @@ SEXP R_MakeExternalPtrFn(DL_FUNC p, SEXP tag, SEXP prot) DL_FUNC R_ExternalPtrAddrFn(SEXP s) { + CHKEXTPTRSXP(s); fn_ptr tmp; tmp.p = EXTPTR_PTR(CHK(s)); return tmp.fn; @@ -4537,9 +4550,9 @@ SEXP (SETCAD4R)(SEXP x, SEXP y) return y; } -SEXP (EXTPTR_PROT)(SEXP x) { return EXTPTR_PROT(CHK(x)); } -SEXP (EXTPTR_TAG)(SEXP x) { return EXTPTR_TAG(CHK(x)); } -void *(EXTPTR_PTR)(SEXP x) { return EXTPTR_PTR(CHK(x)); } +SEXP (EXTPTR_PROT)(SEXP x) { CHKEXTPTRSXP(x); return EXTPTR_PROT(CHK(x)); } +SEXP (EXTPTR_TAG)(SEXP x) { CHKEXTPTRSXP(x); return EXTPTR_TAG(CHK(x)); } +void *(EXTPTR_PTR)(SEXP x) { CHKEXTPTRSXP(x); return EXTPTR_PTR(CHK(x)); } attribute_hidden void (SET_MISSING)(SEXP x, int v) { SET_MISSING(CHKCONS(x), v); } From ecce217fa0845e000d8c0285bb8dd8a4b93c30ff Mon Sep 17 00:00:00 2001 From: hornik Date: Fri, 21 Jun 2024 19:50:08 +0000 Subject: [PATCH 277/546] Markup. git-svn-id: https://svn.r-project.org/R/trunk@86801 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 934d6c01d0f..d4d09352ff0 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -17421,9 +17421,9 @@ SEXP fun = R_mkClosure(formals, body, env); @end example @node Querying CHARSXP encoding, Some backports, Creating closures, Moving into C API compliance -@subsection Querying CHARSXP encoding +@subsection Querying @code{CHARSXP} encoding -A number of packages query encoding bits set on CHARSXP objects via macros +A number of packages query encoding bits set on @code{CHARSXP} objects via macros @code{IS_ASCII} and @code{IS_UTF8}, some packages also via @code{IS_BYTES} and @code{IS_LATIN1}. These macros are not part of the API and packages have been copying their definition and directly accessing the bits in @@ -17439,7 +17439,7 @@ switching to @code{getCharCE}, packages are, however, advised to check whether the encoding information is really needed and whether it is used correctly. -Most code should be able to work with complete CHARSXPs and never look at +Most code should be able to work with complete @code{CHARSXP}s and never look at the individual bytes. When access to characters and bytes (of strings other than @code{CE_BYTES}) is needed, one would use @code{translateChar} or @code{translateCharUTF8}. These functions internally already check the From f5364b43c42913096cffd5e206bd8e3afc6fb5af Mon Sep 17 00:00:00 2001 From: hornik Date: Fri, 21 Jun 2024 19:50:34 +0000 Subject: [PATCH 278/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86802 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index e23b89ddb65..0ceed11aee5 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -3857,8 +3857,10 @@ function(aar, strict = FALSE) { out <- list() if(is.na(aar)) return(out) - aar <- tryCatch(utils:::.read_authors_at_R_field(aar), - error = identity) + ## + ## Perhaps better to actually capture warnings? + aar <- suppressWarnings(tryCatch(utils:::.read_authors_at_R_field(aar), + error = identity)) if(inherits(aar, "error")) { out$bad_authors_at_R_field <- conditionMessage(aar) } else { From df29a69a5d74425891d45150744d0ae1a2ec83be Mon Sep 17 00:00:00 2001 From: hornik Date: Fri, 21 Jun 2024 19:51:13 +0000 Subject: [PATCH 279/546] Split level for base and recommended packages. git-svn-id: https://svn.r-project.org/R/trunk@86803 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/Rd2HTML.R | 61 +++++++++++++++--------------- src/library/tools/man/HTMLlinks.Rd | 6 +-- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/library/tools/R/Rd2HTML.R b/src/library/tools/R/Rd2HTML.R index 5dcb7be570a..504b9cb2ab2 100644 --- a/src/library/tools/R/Rd2HTML.R +++ b/src/library/tools/R/Rd2HTML.R @@ -1362,38 +1362,39 @@ Rd2HTML <- ## The following functions return 'relative' links assuming that all ## packages are installed in the same virtual library tree. -findHTMLlinks <- function(pkgDir = "", lib.loc = NULL, level = 0:2) -{ - ## The priority order is - ## This package (level 0) - ## The standard packages (level 1) - ## along lib.loc (level 2) - - if (is.null(lib.loc)) lib.loc <- .libPaths() - - Links <- list() - if (2 %in% level) - Links <- c(Links, lapply(lib.loc, .find_HTML_links_in_library)) - if (1 %in% level) { - base <- unlist(.get_standard_package_names()[c("base", "recommended")], - use.names = FALSE) - Links <- c(lapply(file.path(.Library, base), - .find_HTML_links_in_package), - Links) - } - if (0 %in% level && nzchar(pkgDir)) - Links <- c(list(.find_HTML_links_in_package(pkgDir)), Links) - Links <- unlist(Links) - Links <- Links[!duplicated(names(Links))] - gsub("[Rr]d$", "html", Links) -} - +## findHTMLlinks <- function(pkgDir = "", lib.loc = NULL, level = 0:2) +## { +## ## The priority order is +## ## This package (level 0) +## ## The standard packages (level 1) +## ## along lib.loc (level 2) + +## if (is.null(lib.loc)) lib.loc <- .libPaths() + +## Links <- list() +## if (2 %in% level) +## Links <- c(Links, lapply(lib.loc, .find_HTML_links_in_library)) +## if (1 %in% level) { +## base <- unlist(.get_standard_package_names()[c("base", "recommended")], +## use.names = FALSE) +## Links <- c(lapply(file.path(.Library, base), +## .find_HTML_links_in_package), +## Links) +## } +## if (0 %in% level && nzchar(pkgDir)) +## Links <- c(list(.find_HTML_links_in_package(pkgDir)), Links) +## Links <- unlist(Links) +## Links <- Links[!duplicated(names(Links))] +## gsub("[Rr]d$", "html", Links) +## } + +findHTMLlinks <- .find_HTML_links <- -function(pkg.dir, lib.loc = NULL, level = 0 : 3) +function(pkgDir, lib.loc = NULL, level = 0 : 3) { ## A variant of the above which splits levels for base and ## recommended packages, such that - ## Level 0: this package (installed in pkg.dir) + ## Level 0: this package (installed in pkgDir) ## Level 1: base packages ## Level 2: recommended packages ## Level 3: all packages installed in lib.loc @@ -1412,8 +1413,8 @@ function(pkg.dir, lib.loc = NULL, level = 0 : 3) .get_standard_package_names()$base), .find_HTML_links_in_package), Links) - if (0 %in% level && nzchar(pkg.dir)) - Links <- c(list(.find_HTML_links_in_package(pkg.dir)), Links) + if (0 %in% level && nzchar(pkgDir)) + Links <- c(list(.find_HTML_links_in_package(pkgDir)), Links) Links <- unlist(Links) Links <- Links[!duplicated(names(Links))] gsub("[Rr]d$", "html", Links) diff --git a/src/library/tools/man/HTMLlinks.Rd b/src/library/tools/man/HTMLlinks.Rd index 6a01e098a55..ab2cd5a58e0 100644 --- a/src/library/tools/man/HTMLlinks.Rd +++ b/src/library/tools/man/HTMLlinks.Rd @@ -11,7 +11,7 @@ documentation. } \usage{ -findHTMLlinks(pkgDir = "", lib.loc = NULL, level = 0:2) +findHTMLlinks(pkgDir = "", lib.loc = NULL, level = 0:3) } \arguments{ \item{pkgDir}{the top-level directory of an installed package. The @@ -26,10 +26,10 @@ findHTMLlinks(pkgDir = "", lib.loc = NULL, level = 0:2) \itemize{ \item The package in \code{pkgDir}: this is used when converting HTML help for that package (level 0). - \item The base and recommended packages (level 1). + \item The base and recommended packages (levels 1 and 2). \item Other packages found in the library trees specified by \code{lib.loc} in the order of the trees and alphabetically within a - library tree (level 2). + library tree (level 3). } } \value{ From e07090e4835dc37cc0e2f0215e47261eec994412 Mon Sep 17 00:00:00 2001 From: hornik Date: Fri, 21 Jun 2024 19:51:56 +0000 Subject: [PATCH 280/546] NEWS and docs for c86752. git-svn-id: https://svn.r-project.org/R/trunk@86804 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 6 +++++- src/library/utils/man/citation.Rd | 12 +++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 6ed09154afa..a200bc9117d 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -135,6 +135,10 @@ \code{Rf_NonNullStringMatch}, \code{Rf_StringBlank}, \code{SET_TYPEOF}, \code{TRUELENGTH}, \code{XLENGTH_EX}, and \code{XTRUELENGTH}. + + \item Package \code{citation()} results auto-generated from the + package metadata now also provide package DOIs for CRAN and + Bioconductor packages. } } @@ -156,7 +160,7 @@ \item \code{as.data.frame.list()} gets new option \code{new.names} and now preserves \code{NA} names, thus fixing the \code{format()} method for data frames, and also bug \PR{18745}. - Relatedly, the \code{format()} method gets option \code{cut.names}. + \I{Relatedly}, the \code{format()} method gets option \code{cut.names}. } } } diff --git a/src/library/utils/man/citation.Rd b/src/library/utils/man/citation.Rd index bf46d608d6a..fc6a8fe65bc 100644 --- a/src/library/utils/man/citation.Rd +++ b/src/library/utils/man/citation.Rd @@ -47,11 +47,13 @@ citFooter(...) Execute function \code{citation()} for information on how to cite the base R system in publications. If the name of a non-base package is - given, the function either returns the information contained in the - \file{CITATION} file of the package (using \code{readCitationFile} - with \code{meta} equal to \code{packageDescription(package, lib.loc)}) - or auto-generates citation information from the \file{DESCRIPTION} - file. + given, as controlled by the \code{auto} argument, the function either + returns the information contained in the \file{CITATION} file of the + package (using \code{readCitationFile} with \code{meta} equal to + \code{packageDescription(package, lib.loc)}) or auto-generates + citation information from the \file{DESCRIPTION} file. For CRAN and + Bioconductor packages, auto-generating automatically adds package URLs + and DOIs. Packages can use an \samp{Authors@R} field in their \file{DESCRIPTION} to provide (\R code giving) a From c27557d8f21dced14ff7afc5ff7fb518f9ad7d7b Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 21 Jun 2024 20:03:13 +0000 Subject: [PATCH 281/546] Prevent accidental shell escape in parse continuation. git-svn-id: https://svn.r-project.org/R/trunk@86805 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/main.c b/src/main/main.c index 13fc495a927..a50f79bb369 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -214,7 +214,8 @@ Rf_ReplIteration(SEXP rho, int savestack, int browselevel, R_ReplState *state) state->bufp = state->buf; } #ifdef SHELL_ESCAPE /* not default */ - if (*state->bufp == '!') { + if (*state->bufp == '!' && state->buf == state->bufp + && state->prompt_type == 1) { R_system(&(state->buf[1])); state->buf[0] = '\0'; return(0); From 799e8bdad2c189473e97fb5cfa0d7dd0b1f0931a Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 21 Jun 2024 20:37:11 +0000 Subject: [PATCH 282/546] tweak r86797: as.data.frame.list() now reverts only NA col.names git-svn-id: https://svn.r-project.org/R/trunk@86806 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/dataframe.R | 5 ++--- tests/reg-tests-1e.R | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/library/base/R/dataframe.R b/src/library/base/R/dataframe.R index 3e1837574b3..fadb02a5e53 100644 --- a/src/library/base/R/dataframe.R +++ b/src/library/base/R/dataframe.R @@ -238,9 +238,8 @@ as.data.frame.list <- stringsAsFactors = stringsAsFactors), if(!missing(row.names)) list(row.names = row.names)) x <- do.call(data.frame, c(x, alis)) - if(Nnms && !identical(col.names, nx <- names(x)) && - length(nx) == length(col.names)) ## e.g. w/ NA_character_ in col.names - names(x) <- col.names + if(Nnms && length(names(x)) == length(col.names) && any(naNm <- is.na(col.names))) + names(x)[naNm] <- col.names[naNm] if(any.m) names(x) <- sub("^\\.\\.adfl\\.", "", names(x)) x } diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 13d21685348..3b4ebfc6772 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1421,6 +1421,12 @@ L <- list(A = FALSE); names(L) <- NA dL1 <- as.data.frame.list(L, col.names = names(L)) dL2 <- as.data.frame.list(L, col.names = names(L), check.names=FALSE) str(dL <- as.data.frame.list(L, new.names=TRUE)) +## check.names = TRUE, fix.empty.names = TRUE are default : +prblN <- c("", "var 2") +dp11 <- as.data.frame(setNames(list(1, 23), prblN)) +dp01 <- as.data.frame(setNames(list(1, 23), prblN), check.names=FALSE) +dp00 <- as.data.frame(setNames(list(1, 23), prblN), check.names=FALSE, fix.empty.names=FALSE) +dp10 <- as.data.frame(setNames(list(1, 23), prblN), check.names=TRUE , fix.empty.names=FALSE) stopifnot(exprs = { is.na(names(x)) is.data.frame(fx) @@ -1429,8 +1435,12 @@ stopifnot(exprs = { identical(NA_character_, names(dL)) identical(nms, names( dN)) identical(nms, names(fdN)) # was .. .. "NA" "NA" - identical(dL1, dL2)# was always TRUE - identical(dL, dL1) # was FALSE + identical(dL1, dL2)# was FALSE ("NA vs "NA.") + identical(dL, dL1) # was always TRUE; ditto these {wrong for a couple of hours}: + names(dp11) == c("X1", "var.2") + names(dp01) == c( "1", "var 2") + names(dp00) == c( "" , "var 2") # == prblN + names(dp10) == c( "" , "var.2") }) ## format() and as.data.frame(, col.names=*, check.names=FALSE) *did* ## change NA names() into "NA" for R <= 4.4.1 From e9b8f6112af13e0a0c22f2281bc927f08973758a Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 21 Jun 2024 20:54:04 +0000 Subject: [PATCH 283/546] Move R_isValidString and R_isValidStringF to @apifun. git-svn-id: https://svn.r-project.org/R/trunk@86807 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 1 - doc/manual/R-exts.texi | 4 ++++ src/library/tools/R/sotools.R | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index a200bc9117d..85bcd1bc08c 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -131,7 +131,6 @@ \item Additional non-API entry points added to those reported by \command{R CMD check}: \code{IS_LONG_VEC}, \code{PRCODE}, \code{PRENV}, \code{PRVALUE}, \code{R_nchar}, - \code{Rf_isValidString}, \code{Rf_isValidStringF}, \code{Rf_NonNullStringMatch}, \code{Rf_StringBlank}, \code{SET_TYPEOF}, \code{TRUELENGTH}, \code{XLENGTH_EX}, and \code{XTRUELENGTH}. diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index d4d09352ff0..8a4ab5fdf59 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13349,6 +13349,8 @@ a test of a length-2 @code{"dim"} attribute. @apifun isS4 @apifun isNumber @apifun isDataFrame +@apifun Rf_isValidString +@apifun Rf_isValidStringF @example @group Rboolean isVector(SEXP); @@ -13371,6 +13373,8 @@ Rboolean isUnordered(SEXP); Rboolean isS4(SEXP); Rboolean isNumber(SEXP); Rboolean isDataFrame (SEXP); +Rboolean Rf_isValidString(SEXP); +Rboolean Rf_isValidStringF(SEXP); @end group @end example diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index a61f1e9c292..d0eceb41c0e 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -686,7 +686,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "STRING_PTR", "VECTOR_PTR", "SET_FORMALS", "SET_BODY", "SET_CLOENV", "Rf_findVarInFrame3", "IS_LONG_VEC", "PRCODE", "PRENV", "PRVALUE", "R_nchar", - "Rf_isValidString", "Rf_isValidStringF", "Rf_NonNullStringMatch", + "Rf_NonNullStringMatch", "Rf_StringBlank", "SET_TYPEOF", "TRUELENGTH", "XLENGTH_EX", "XTRUELENGTH", ## in the non-API header R_ext/Connections.h From 70286f56a8a7a45ee2cf4bdbb8ddb397da6d0dbe Mon Sep 17 00:00:00 2001 From: hornik Date: Fri, 21 Jun 2024 20:56:22 +0000 Subject: [PATCH 284/546] Markup. git-svn-id: https://svn.r-project.org/R/trunk@86808 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 2 +- src/library/utils/man/citation.Rd | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 85bcd1bc08c..209868b34a2 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -136,7 +136,7 @@ and \code{XTRUELENGTH}. \item Package \code{citation()} results auto-generated from the - package metadata now also provide package DOIs for CRAN and + package metadata now also provide package \abbr{DOI}s for CRAN and Bioconductor packages. } } diff --git a/src/library/utils/man/citation.Rd b/src/library/utils/man/citation.Rd index fc6a8fe65bc..1be74545a0f 100644 --- a/src/library/utils/man/citation.Rd +++ b/src/library/utils/man/citation.Rd @@ -52,8 +52,8 @@ citFooter(...) package (using \code{readCitationFile} with \code{meta} equal to \code{packageDescription(package, lib.loc)}) or auto-generates citation information from the \file{DESCRIPTION} file. For CRAN and - Bioconductor packages, auto-generating automatically adds package URLs - and DOIs. + Bioconductor packages, auto-generating automatically adds package + \abbr{URL}s and \abbr{DOI}s. Packages can use an \samp{Authors@R} field in their \file{DESCRIPTION} to provide (\R code giving) a From 301aa8e8ed47ec2447ff5cdf52cd7a3b929cca5a Mon Sep 17 00:00:00 2001 From: smeyer Date: Sat, 22 Jun 2024 14:27:54 +0000 Subject: [PATCH 285/546] update menu git-svn-id: https://svn.r-project.org/R/trunk@86809 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 8a4ab5fdf59..22e8e760a81 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -17298,6 +17298,7 @@ be adjusted as changes are made to the API. * Creating environments:: * Creating call expressions:: * Creating closures:: +* Querying CHARSXP encoding:: * Some backports:: @end menu From 182a7d57da4d6502dce6db25c1b8c53126343bef Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 22 Jun 2024 15:52:27 +0000 Subject: [PATCH 286/546] Add IS_SCALAR to list of non-API entry points producing a warning. git-svn-id: https://svn.r-project.org/R/trunk@86810 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 33e38b4a263..ffde3c38447 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -3803,7 +3803,7 @@ add_dummies <- function(dir, Log) haveObjs <- any(grepl("^ *Object", out)) pat <- paste("possibly from", sQuote("(abort|assert|exit|_exit|_Exit|stop)")) - rempat <- "REAL0|COMPLEX0|ddfind|DDVAL|ENSURE_NAMEDMAX|INTERNAL" + rempat <- "REAL0|COMPLEX0|ddfind|DDVAL|ENSURE_NAMEDMAX|INTERNAL|IS_SCALAR" if(haveObjs && any(grepl(pat, out)) && pkgname %notin% "parallel") ## need _exit in forked child warningLog(Log) From 03d6172b07b349567b6f6e6d08ebb7df640da9ca Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 22 Jun 2024 16:43:55 +0000 Subject: [PATCH 287/546] Add 4 getInputHandler, removeInputHandler, and addInputHandler as @eapifun. git-svn-id: https://svn.r-project.org/R/trunk@86811 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 9 +++++++-- src/library/tools/R/sotools.R | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 22e8e760a81..df55ba728ae 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -18270,10 +18270,15 @@ event loops, using types and functions declared in the header @file{src/unix/sys-std.c}. It is possible to add (or remove) an input handler for events on a particular file descriptor, or to set a polling interval (@emph{via} @code{R_wait_usec}) and a function to be called -periodically @emph{via} @code{R_PolledEvents}: the polling mechanism is used by -the @pkg{tcltk} package. +periodically @emph{via} @code{R_PolledEvents}: the polling mechanism is +used by the @pkg{tcltk} package. Input handlers are managed with +@code{addInputHandler},@code{getInputHandler}, and +@code{removeInputHandler}. @embfun R_PolledEvents @embfun R_wait_usec +@embfun addInputHandler +@embfun getInputHandler +@embfun removeInputHandler It is not intended that these facilities are used by packages, but if they are needed exceptionally, the package should ensure that it cleans diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index d0eceb41c0e..39d2c4d8cd7 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -648,9 +648,9 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "R_wait_usec", "RestoreAction", "Rf_CleanEd", "Rf_KillAllDevices", "Rf_endEmbeddedR", "Rf_initEmbeddedR", "Rf_initialize_R", "Rf_jump_to_toplevel", "Rf_mainloop", - "SaveAction", "addInputHandler", "editorcleanall", "fpu_setup", + "SaveAction", "editorcleanall", "fpu_setup", "freeRUser", "free_R_HOME", - "getDLLVersion", "getInputHandler", "getRUser", "get_R_HOME", + "getDLLVersion", "getRUser", "get_R_HOME", "getSelectedHandler", "initStdinHandler", "process_site_Renviron", "process_system_Renviron", "process_user_Renviron", "ptr_R_Busy", "ptr_R_ChooseFile", @@ -660,7 +660,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "ptr_R_ShowMessage", "ptr_R_Suicide", "ptr_R_WriteConsole", "ptr_R_WriteConsoleEx", "ptr_R_addhistory", "ptr_R_loadhistory", "ptr_R_savehistory", "ptr_do_dataentry", "ptr_do_dataviewer", - "ptr_do_selectlist", "readconsolecfg", "removeInputHandler", + "ptr_do_selectlist", "readconsolecfg", "run_Rmainloop", "setup_Rmainloop", ## non-API, removed in R 4.5.0 and long deprecated in R_ext/RS.h (and as call_S in S.h) From 509f5fccf2a08be61e070c67c497062d9f6283ec Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 22 Jun 2024 17:05:31 +0000 Subject: [PATCH 288/546] Remove some predicates from tools:::notAPI and mark as @eapifun. git-svn-id: https://svn.r-project.org/R/trunk@86812 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 19 +++++++++++++++++-- src/library/tools/R/sotools.R | 6 ++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index df55ba728ae..19d224ecab9 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13349,8 +13349,6 @@ a test of a length-2 @code{"dim"} attribute. @apifun isS4 @apifun isNumber @apifun isDataFrame -@apifun Rf_isValidString -@apifun Rf_isValidStringF @example @group Rboolean isVector(SEXP); @@ -13373,8 +13371,25 @@ Rboolean isUnordered(SEXP); Rboolean isS4(SEXP); Rboolean isNumber(SEXP); Rboolean isDataFrame (SEXP); +@end group +@end example +Some additional predicates: +@eapifun Rf_isValidString +@eapifun Rf_isValidStringF +@eapifun isBlankString +@eapifun StringBlank +@eapifun StringFalse +@eapifun StringTrue +@eapifun IS_LONG_VEC +@example +@group Rboolean Rf_isValidString(SEXP); Rboolean Rf_isValidStringF(SEXP); +Rboolean isBlankString(const char *); +Rboolean Rf_StringBlank(SEXP); +Rboolean StringFalse(const char *); +Rboolean StringTrue(const char *); +int IS_LONG_VEC(SEXP); @end group @end example diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 39d2c4d8cd7..27cef7a3fca 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -667,8 +667,6 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "call_R", ## non-API, declared in Defn.h "Rf_setSVector", -## non-API, declared in Utils.h - "Rf_StringFalse", "Rf_StringTrue", "Rf_isBlankString", ## non-API, declared in Rinternals.h ## not yet, in Rcpp headers "SET_TYPEOF", ## not yet, used in an example in R-exts "SET_OBJECT", @@ -685,9 +683,9 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "ENVFLAGS", "RDEBUG", "SET_RDEBUG", "STRING_PTR", "VECTOR_PTR", "SET_FORMALS", "SET_BODY", "SET_CLOENV", "Rf_findVarInFrame3", - "IS_LONG_VEC", "PRCODE", "PRENV", "PRVALUE", "R_nchar", + "PRCODE", "PRENV", "PRVALUE", "R_nchar", "Rf_NonNullStringMatch", - "Rf_StringBlank", "SET_TYPEOF", "TRUELENGTH", "XLENGTH_EX", + "SET_TYPEOF", "TRUELENGTH", "XLENGTH_EX", "XTRUELENGTH", ## in the non-API header R_ext/Connections.h "R_new_custom_connection", "R_ReadConnection", From 3c448caa3ed7ddf79cbee205c6110bda4bc1657b Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 22 Jun 2024 18:51:49 +0000 Subject: [PATCH 289/546] Make version of IS_SCALAR @eapifun to avoid disrupting too mane revdeps. Grrr. git-svn-id: https://svn.r-project.org/R/trunk@86813 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 ++ src/library/tools/R/check.R | 2 +- src/library/tools/R/sotools.R | 2 +- src/main/memory.c | 7 ++++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 19d224ecab9..a922a7cb912 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13381,6 +13381,7 @@ Some additional predicates: @eapifun StringFalse @eapifun StringTrue @eapifun IS_LONG_VEC +@eapifun IS_SCALAR @example @group Rboolean Rf_isValidString(SEXP); @@ -13390,6 +13391,7 @@ Rboolean Rf_StringBlank(SEXP); Rboolean StringFalse(const char *); Rboolean StringTrue(const char *); int IS_LONG_VEC(SEXP); +int IS_SCALAR(SEXP, int); @end group @end example diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index ffde3c38447..33e38b4a263 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -3803,7 +3803,7 @@ add_dummies <- function(dir, Log) haveObjs <- any(grepl("^ *Object", out)) pat <- paste("possibly from", sQuote("(abort|assert|exit|_exit|_Exit|stop)")) - rempat <- "REAL0|COMPLEX0|ddfind|DDVAL|ENSURE_NAMEDMAX|INTERNAL|IS_SCALAR" + rempat <- "REAL0|COMPLEX0|ddfind|DDVAL|ENSURE_NAMEDMAX|INTERNAL" if(haveObjs && any(grepl(pat, out)) && pkgname %notin% "parallel") ## need _exit in forked child warningLog(Log) diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 27cef7a3fca..eee212800a9 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -671,7 +671,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", ## not yet, in Rcpp headers "SET_TYPEOF", ## not yet, used in an example in R-exts "SET_OBJECT", "SET_S4_OBJECT", "UNSET_S4_OBJECT", - "R_curErrorBuf", "IS_SCALAR", + "R_curErrorBuf", "SETLENGTH", "SET_TRUELENGTH", "SETLEVELS", "SET_ENVFLAGS", "SET_FRAME", "SET_ENCLOS", "SET_HASHTAB", "SET_PRENV", "SET_PRVALUE", "SET_PRCODE", "STDVEC_DATAPTR", diff --git a/src/main/memory.c b/src/main/memory.c index 65edda99409..4534322bad5 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -3887,11 +3887,16 @@ int (LEVELS)(SEXP x) { return LEVELS(CHK(x)); } int (REFCNT)(SEXP x) { return REFCNT(CHK(x)); } attribute_hidden int (TRACKREFS)(SEXP x) { return TRACKREFS(CHK(x)); } int (ALTREP)(SEXP x) { return ALTREP(CHK(x)); } -int (IS_SCALAR)(SEXP x, int type) { return IS_SCALAR(CHK(x), type); } void (MARK_NOT_MUTABLE)(SEXP x) { MARK_NOT_MUTABLE(CHK(x)); } int (MAYBE_SHARED)(SEXP x) { return MAYBE_SHARED(CHK(x)); } int (NO_REFERENCES)(SEXP x) { return NO_REFERENCES(CHK(x)); } +// this is NOT a function version of the IS_SCALAR macro! +int (IS_SCALAR)(SEXP x, int type) +{ + return TYPEOF(CHK(x)) == type && XLENGTH(x) == 1; +} + attribute_hidden int (MARK)(SEXP x) { return MARK(CHK(x)); } attribute_hidden void (DECREMENT_REFCNT)(SEXP x) { DECREMENT_REFCNT(CHK(x)); } From 64b1ad2e49c1b638ea565e2dc39cd98103e4a28d Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 22 Jun 2024 19:46:41 +0000 Subject: [PATCH 290/546] Add grepv function in base. git-svn-id: https://svn.r-project.org/R/trunk@86814 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 3 +++ src/library/base/R/grep.R | 5 +++++ src/library/base/man/grep.Rd | 9 ++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 209868b34a2..c3172c3e7af 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -31,6 +31,9 @@ \item New \code{qr.influence()}, a \dQuote{bare bones} interface to the \code{lm.influence()} leave-one-out diagnostics computations; wished for in \PR{18739}. + + \item New function \code{grepv} identical to \code{grep} except + with the default \code{value = TRUE}. } } diff --git a/src/library/base/R/grep.R b/src/library/base/R/grep.R index 7dbb3d3428b..ea91682cdb6 100644 --- a/src/library/base/R/grep.R +++ b/src/library/base/R/grep.R @@ -57,6 +57,11 @@ function(pattern, x, ignore.case = FALSE, perl = FALSE, } } +grepv <- +function(pattern, x, ignore.case = FALSE, perl = FALSE, + value = TRUE, fixed = FALSE, useBytes = FALSE, invert = FALSE) + grep(pattern, x, ignore.case, perl, value, fixed, useBytes, invert) + grepl <- function(pattern, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE) diff --git a/src/library/base/man/grep.Rd b/src/library/base/man/grep.Rd index 0e8a05fca45..06986cb5fb3 100644 --- a/src/library/base/man/grep.Rd +++ b/src/library/base/man/grep.Rd @@ -6,6 +6,7 @@ \name{grep} \title{Pattern Matching and Replacement} \alias{grep} +\alias{grepv} \alias{grepl} \alias{sub} \alias{gsub} @@ -14,7 +15,7 @@ \alias{regexec} \alias{gregexec} \description{ - \code{grep}, \code{grepl}, \code{regexpr}, \code{gregexpr}, + \code{grep}, \code{grepv}, \code{grepl}, \code{regexpr}, \code{gregexpr}, \code{regexec} and \code{gregexec} search for matches to argument \code{pattern} within each element of a character vector: they differ in the format of and amount of detail in the results. @@ -26,6 +27,9 @@ grep(pattern, x, ignore.case = FALSE, perl = FALSE, value = FALSE, fixed = FALSE, useBytes = FALSE, invert = FALSE) +grepv(pattern, x, ignore.case = FALSE, perl = FALSE, value = TRUE, + fixed = FALSE, useBytes = FALSE, invert = FALSE) + grepl(pattern, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE) @@ -108,6 +112,9 @@ gregexec(pattern, text, ignore.case = FALSE, perl = FALSE, it is an error for \code{pattern} to be \code{NA}, otherwise \code{NA} is permitted and gives an \code{NA} match. + \code{grep} and \code{grepv} only differ in the default of the + \code{value} argument. + Both \code{grep} and \code{grepl} take missing values in \code{x} as not matching a non-missing \code{pattern}. From 9bf68b796e99fd6ddeb9fee4ff0ef74dac663fb6 Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 24 Jun 2024 06:06:27 +0000 Subject: [PATCH 291/546] Fix out-of-bounds access on long lines with parse continuation. git-svn-id: https://svn.r-project.org/R/trunk@86815 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/main.c b/src/main/main.c index a50f79bb369..7c91dca6719 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -221,7 +221,8 @@ Rf_ReplIteration(SEXP rho, int savestack, int browselevel, R_ReplState *state) return(0); } #endif /* SHELL_ESCAPE */ - while((c = *state->bufp++)) { + while((c = *state->bufp)) { + state->bufp++; R_IoBufferPutc(c, &R_ConsoleIob); if(c == ';' || c == '\n') break; } From e29a76245fe8ca94ca53986e620ebddd1c2d7c84 Mon Sep 17 00:00:00 2001 From: smeyer Date: Mon, 24 Jun 2024 12:42:46 +0000 Subject: [PATCH 292/546] move towards Texinfo >= 6.1 (auto-generate node pointers and menus) git-svn-id: https://svn.r-project.org/R/trunk@86816 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-lang.texi | 510 +++++++++++++---------------------------- 1 file changed, 153 insertions(+), 357 deletions(-) diff --git a/doc/manual/R-lang.texi b/doc/manual/R-lang.texi index f1b378c8193..c710d874312 100644 --- a/doc/manual/R-lang.texi +++ b/doc/manual/R-lang.texi @@ -49,7 +49,7 @@ This manual is for R, version @value{VERSION}. @c @end ifnothtml @ifnottex -@node Top, Introduction, (dir), (dir) +@node Top @top R Language Definition This is an introduction to the @R{} language, explaining evaluation, @@ -60,24 +60,7 @@ forth. @end ifnottex -@menu -* Introduction:: -* Objects:: -* Evaluation of expressions:: -* Functions:: -* Object-oriented programming:: -* Computing on the language:: -* System and foreign language interfaces:: -* Exception handling:: -* Debugging:: -* Parser:: -* Function and Variable Index:: -* Concept Index:: -* References:: -@end menu - -@node Introduction, Objects, Top, Top -@comment node-name, next, previous, up +@node Introduction @chapter Introduction @R{} is a system for statistical computation and graphics. It @@ -146,9 +129,10 @@ details how to extend @R{} using compiled code. -@node Objects, Evaluation of expressions, Introduction, Top +@node Objects @chapter Objects +@c FIXME: @c needs to be clarified. What is a pointer, what is the pointed object, @c what is the context of the pointed object? In every computer language @@ -255,33 +239,12 @@ doesn't affect the computations, however, when dealing with foreign languages or the operating system it is often necessary to ensure that an object is of the correct type. -@menu -* Basic types:: -* Attributes:: -* Special compound objects:: -@end menu -@node Basic types, Attributes, Objects, Objects -@cindex type +@node Basic types @section Basic types +@cindex type - -@menu -* Vector objects:: -* List objects:: -* Language objects:: -* Expression objects:: -* Function objects:: -* NULL object:: -* Builtin objects and special forms:: -* Promise objects:: -* Dot-dot-dot:: -* Environment objects:: -* Pairlist objects:: -* Any-type:: -@end menu - -@node Vector objects, List objects, Basic types, Basic types +@node Vector objects @subsection Vectors @cindex vector @@ -324,7 +287,7 @@ Thus, an @R{} @emph{string} is internally a @code{STRSXP} with one element, a @code{CHARSXP}.} -@node List objects, Language objects, Vector objects, Basic types +@node List objects @subsection Lists Lists (``generic vectors'') are another kind of data storage. Lists @@ -339,7 +302,7 @@ These are explained in detail in @ref{Indexing}. Lists are vectors, and the basic vector types are referred to as @emph{atomic vectors} where it is necessary to exclude lists. -@node Language objects, Expression objects, List objects, Basic types +@node Language objects @subsection Language objects There are three types of objects that constitute the @R{} language. @@ -372,11 +335,8 @@ Components of the parse tree can be extracted using the standard indexing operations. -@menu -* Symbol objects:: -@end menu -@node Symbol objects, , Language objects, Language objects +@node Symbol objects @subsubsection Symbol objects @@ -402,7 +362,7 @@ using @code{as.character} and @code{as.name}. They naturally appear as atoms of parsed expressions, try e.g.@: @code{as.list(quote(x + y))}. -@node Expression objects, Function objects, Language objects, Basic types +@node Expression objects @subsection Expression objects In @R{} one can have objects of type @code{"expression"}. An @@ -425,7 +385,7 @@ An expression object behaves much like a list and its components should be accessed in the same way as the components of a list. -@node Function objects, NULL object, Expression objects, Basic types +@node Function objects @subsection Function objects @cindex function @@ -485,7 +445,7 @@ structures using @code{as.list} and @code{as.function}. These have been included to provide compatibility with @Sl{} and their use is discouraged. -@node NULL object, Builtin objects and special forms, Function objects, Basic types +@node NULL object @subsection NULL There is a special object called @code{NULL}. It is used whenever there @@ -499,7 +459,7 @@ test for @code{NULL} use @code{is.null}. You cannot set attributes on @code{NULL}. -@node Builtin objects and special forms, Promise objects, NULL object, Basic types +@node Builtin objects and special forms @subsection Builtin objects and special forms These two kinds of object contain the builtin @@ -519,7 +479,7 @@ The @code{is.primitive} function can distinguish them from interpreted @cindex function functions. -@node Promise objects, Dot-dot-dot, Builtin objects and special forms, Basic types +@node Promise objects @subsection Promise objects @cindex promise @@ -550,7 +510,7 @@ expression. There is generally no way in @R{} code to check whether an object is a promise or not, nor is there a way to use @R{} code to determine the environment of a promise. -@node Dot-dot-dot, Environment objects, Promise objects, Basic types +@node Dot-dot-dot @subsection Dot-dot-dot The @code{...} object type is stored as a type of pairlist. The @@ -583,7 +543,7 @@ If a function has @code{...} as a formal argument then any actual arguments that do not match a formal argument are matched with @code{...}. -@node Environment objects, Pairlist objects, Dot-dot-dot, Basic types +@node Environment objects @subsection Environments @cindex environment @@ -627,7 +587,7 @@ environment to several symbols and change one, the others will change too. In particular, assigning attributes to an environment can lead to surprises. -@node Pairlist objects, Any-type, Environment objects, Basic types +@node Pairlist objects @subsection Pairlist objects @cindex pairlist @@ -658,7 +618,7 @@ subsetted) converted to a generic vector. In a very few cases pairlists are user-visible: one is @code{.Options}. -@node Any-type, , Pairlist objects, Basic types +@node Any-type @subsection The ``Any'' type It is not really possible for an object to be of ``Any'' type, but it is @@ -670,7 +630,7 @@ coercion should not be done. @c @node External pointer objects @c @subsection External pointer objects -@node Attributes, Special compound objects, Basic types, Objects +@node Attributes @section Attributes @cindex attributes @@ -685,6 +645,7 @@ of the attributes can be obtained using @code{attributes} and set by individual components are accessed using @code{attr} and @code{attr<-}. @findex attr @findex attr<- +@c FIXME: @c Shouldn't we discuss replacement functions before this? @c This is a bad example: levels<- is generic. @@ -707,16 +668,8 @@ during evaluation. The class structure in @R{} is described in detail in @ref{Object-oriented programming}. -@menu -* Names:: -* Dimensions:: -* Dimnames:: -* Classes:: -* Time series attributes:: -* Copying of attributes:: -@end menu -@node Names, Dimensions, Attributes, Attributes +@node Names @subsection Names A @code{names} attribute, when present, labels the individual elements of @@ -739,7 +692,7 @@ attribute is really constructed from the tags of the list components. For one-dimensional arrays the @code{names} attribute really accesses @code{dimnames[[1]]}. -@node Dimensions, Dimnames, Names, Attributes +@node Dimensions @subsection Dimensions The @code{dim} attribute is used to implement arrays. The content of @@ -754,7 +707,7 @@ A vector is not the same as a one-dimensional array since the latter has a @code{dim} attribute of length one, whereas the former has no @code{dim} attribute. -@node Dimnames, Classes, Dimensions, Attributes +@node Dimnames @subsection Dimnames Arrays may name each dimension separately using the @code{dimnames} @@ -762,7 +715,7 @@ attribute which is a list of character vectors. The @code{dimnames} list may itself have names which are then used for extent headings when printing arrays. -@node Classes, Time series attributes, Dimnames, Attributes +@node Classes @subsection Classes @R{} has an elaborate class system@footnote{actually two, but this draft @@ -779,14 +732,14 @@ available specific creation and @cindex coercion coercion functions should be preferred. -@node Time series attributes, Copying of attributes, Classes, Attributes +@node Time series attributes @subsection Time series attributes The @code{tsp} attribute is used to hold parameters of time series, start, end, and frequency. This construction is mainly used to handle series with periodic substructure such as monthly or quarterly data. -@node Copying of attributes, , Time series attributes, Attributes +@node Copying of attributes @subsection Copying of attributes Whether attributes should be copied when an object is altered is a @@ -813,15 +766,11 @@ The default method for sorting drops all attributes except names, which are sorted along with the object. -@node Special compound objects, , Attributes, Objects +@node Special compound objects @section Special compound objects -@menu -* Factors:: -* Data frame objects:: -@end menu -@node Factors, Data frame objects, Special compound objects, Special compound objects +@node Factors @subsection Factors Factors are used to describe items that can have a finite number of @@ -844,7 +793,7 @@ implementation in order to make some calculations easier. This, however, is an implementation issue and is not guaranteed to hold in all implementations of @R{}. -@node Data frame objects, , Factors, Special compound objects +@node Data frame objects @subsection Data frame objects Data frames are the @R{} structures which most closely mimic the SAS or @@ -862,82 +811,59 @@ writing such arrays are not generally handled correctly. @c FIXME: these details really need to be filled in -@c @node Type checking and coercion, , Special compound objects, Objects +@c @node Type checking and coercion @c @section Type checking and coercion @c For most of the basic data types we can check the type and coerce @c objects of one type to another type. Should we have a table??? -@c @menu -@c * mode/typeof:: -@c * Specific types:: -@c * Metatypes:: -@c @end menu - -@c @node mode/typeof, Specific types, Type checking and coercion, Type checking and coercion +@c @node mode/typeof @c @subsection mode/typeof -@c @node Specific types, Metatypes, mode/typeof, Type checking and coercion +@c @node Specific types @c @subsection Specific types -@c @node Metatypes, , Specific types, Type checking and coercion +@c @node Metatypes @c @subsection Metatypes @c @findex is.numeric @c @findex is.finite @c ------------------------------ -@c @node Data structures, Evaluation of expressions, Objects, Top +@c @node Data structures @c @chapter Data structures -@c @menu -@c * Vectors:: -@c * Lists:: -@c * Arrays:: -@c * Matrices:: -@c * Assignment:: -@c * Matrix operations:: -@c * Data Frames:: -@c @end menu - -@c @node Vectors, Lists, Data structures, Data structures +@c @node Vectors @c @section Vectors -@c @node Lists, Arrays, Vectors, Data structures +@c @node Lists @c @section Lists -@c @node Arrays, Matrices, Lists, Data structures +@c @node Arrays @c @section Arrays -@c @node Matrices, Assignment, Arrays, Data structures +@c @node Matrices @c @section Matrices -@c @node Assignment, Matrix operations, Matrices, Data structures +@c @node Assignment @c @section Assignment -@c @menu -@c * simple:: -@c * indexed:: -@c * function:: -@c @end menu - -@c @node simple, indexed, Assignment, Assignment +@c @node simple @c @subsection simple -@c @node indexed, function, simple, Assignment +@c @node indexed @c @subsection indexed -@c @node function, , indexed, Assignment +@c @node function @c @subsection function -@c @node Matrix operations, Data Frames, Assignment, Data structures +@c @node Matrix operations @c @section Matrix operations -@c @node Data Frames, , Matrix operations, Data structures +@c @node Data Frames @c @section Data Frames -@node Evaluation of expressions, Functions, Objects, Top -@comment node-name, next, previous, up +@node Evaluation of expressions @chapter Evaluation of expressions When a user types a command at the prompt (or when an expression is read @@ -956,25 +882,12 @@ be sufficient documentation. Users can construct expressions and invoke the evaluator on them. -@menu -* Simple evaluation:: -* Control structures:: -* Elementary arithmetic operations:: -* Indexing:: -* Scope of variables:: -@end menu -@node Simple evaluation, Control structures, Evaluation of expressions, Evaluation of expressions +@node Simple evaluation @section Simple evaluation -@menu -* Constants:: -* Symbol lookup:: -* Function calls:: -* Operators:: -@end menu -@node Constants, Symbol lookup, Simple evaluation, Simple evaluation +@node Constants @subsection Constants Any number typed directly at the prompt is a constant and is evaluated. @@ -1015,7 +928,7 @@ e.g.@: @code{12iL} gives an error. Constants are fairly boring and to do more we need symbols. -@node Symbol lookup, Function calls, Constants, Simple evaluation +@node Symbol lookup @subsection Symbol lookup When a new variable is created it must have a @@ -1044,7 +957,7 @@ directly, except when doing ``programming on the language'' @c FIXME: Probably needs to go somewhere, but not here (parser section?) @c FIXME: Up to date info is in the subsection 'Reserved words'. -@c @node Key words, Calling functions, Symbol lookup, Simple evaluation +@c @node Key words @c @subsection Key words @c @R{} contains a number of key words. These are symbols that the parser @@ -1072,7 +985,7 @@ directly, except when doing ``programming on the language'' @c @end quotation -@node Function calls, Operators, Symbol lookup, Simple evaluation +@node Function calls @subsection Function calls Most of the computations carried out in @R{} involve the evaluation of @@ -1127,7 +1040,7 @@ avoid unnecessary data duplication.) @c array, matrix, list, structure (with a warning to use the @c latter with discretion), -@node Operators, , Function calls, Simple evaluation +@node Operators @subsection Operators @R{} allows the use of arithmetic expressions using operators similar to @@ -1260,7 +1173,7 @@ could have used @code{`[`(x, 2)} instead of @code{x[2]}. @R{}'s indexing operations contain many advanced features which are further described in @ref{Indexing}. -@node Control structures, Elementary arithmetic operations, Simple evaluation, Evaluation of expressions +@node Control structures @section Control structures Computation in @R{} consists of sequentially evaluating @@ -1308,16 +1221,8 @@ block. [1] 5 @end example -@menu -* if:: -* Looping:: -* repeat:: -* while:: -* for:: -* switch:: -@end menu -@node if, Looping, Control structures, Control structures +@node if @subsection if The @code{if}/@code{else} statement conditionally evaluates two @@ -1389,7 +1294,7 @@ only be evaluated if @var{statement1} is @code{FALSE} and There is no limit to the number of @code{else if} clauses that are permitted. -@node Looping, repeat, if, Control structures +@node Looping @subsection Looping @R{} has three statements that provide explicit @@ -1415,7 +1320,7 @@ of the loop (if there is one) is then executed. No statement below The value returned by a loop statement is always @code{NULL} and is returned invisibly. -@node repeat, while, Looping, Control structures +@node repeat @subsection repeat @findex repeat @@ -1432,7 +1337,7 @@ When using @code{repeat}, @var{statement} must be a block statement. You need to both perform some computation and test whether or not to break from the loop and usually this requires two statements. -@node while, for, repeat, Control structures +@node while @subsection while @findex while @@ -1448,7 +1353,7 @@ where @var{statement1} is evaluated and if its value is @code{TRUE} then @var{statement2} is evaluated. This process continues until @var{statement1} evaluates to @code{FALSE}. -@node for, switch, while, Control structures +@node for @subsection for @findex for @@ -1467,7 +1372,7 @@ variable @var{name} still exists after the loop has concluded and it has the value of the last element of @var{vector} that the loop was evaluated for. -@node switch, , for, Control structures +@node switch @subsection switch @findex switch @@ -1539,21 +1444,15 @@ may not be the best way to select one for evaluation. It is often better to use @code{eval} and the subset operator, @code{[[}, directly via @code{eval(x[[condition]])}. -@node Elementary arithmetic operations, Indexing, Control structures, Evaluation of expressions +@node Elementary arithmetic operations @section Elementary arithmetic operations -@menu -* Recycling rules:: -* Propagation of names:: -* Dimensional attributes:: -* NA handling:: -@end menu In this section, we discuss the finer points of the rules that apply to basic operation like addition or multiplication of two vectors or matrices. -@node Recycling rules, Propagation of names, Elementary arithmetic operations, Elementary arithmetic operations +@node Recycling rules @subsection Recycling rules If one tries to add two structures with a different number of elements, then the shortest is recycled to length of longest. That is, if for @@ -1564,7 +1463,7 @@ vector is not a multiple of the shorter one, a warning is given. As from @R{} 1.4.0, any arithmetic operation involving a zero-length vector has a zero-length result. -@node Propagation of names, Dimensional attributes, Recycling rules, Elementary arithmetic operations +@node Propagation of names @subsection Propagation of names @cindex name propagation of names (first one wins, I think - also if it has no @@ -1572,13 +1471,13 @@ names?? ---- first one *with names* wins, recycling causes shortest to lose names) -@node Dimensional attributes, NA handling, Propagation of names, Elementary arithmetic operations +@node Dimensional attributes @subsection Dimensional attributes (matrix+matrix, dimensions must match. vector+matrix: first recycle, then check if dims fit, error if not) -@node NA handling, , Dimensional attributes, Elementary arithmetic operations +@node NA handling @subsection NA handling Missing values in the statistical sense, that is, variables whose value @@ -1635,7 +1534,7 @@ deparsing when it is not otherwise possible to identify the type of an There is no @code{NA} value for raw vectors. -@node Indexing, Scope of variables, Elementary arithmetic operations, Evaluation of expressions +@node Indexing @section Indexing @R{} contains several constructs which allow access to individual @@ -1685,14 +1584,8 @@ index. That is, the index is not computable: for cases where you need to evaluate an expression to find the index, use @code{x[[expr]]}. Applying @code{$} to a non-recursive object is an error. -@menu -* Indexing by vectors:: -* Indexing matrices and arrays:: -* Indexing other structures:: -* Subset assignment:: -@end menu -@node Indexing by vectors, Indexing matrices and arrays, Indexing, Indexing +@node Indexing by vectors @subsection Indexing by vectors @R{} allows some powerful constructions using vectors as indices. We @@ -1730,8 +1623,6 @@ length as @code{x}. If it is shorter, then its elements will be recycled as discussed in @ref{Elementary arithmetic operations}. If it is longer, then @code{x} is conceptually extended with @code{NA}s. The selected values of @code{x} are those for which @code{i} is @code{TRUE}. -@c @findex TRUE -@c @findex FALSE @cindex partial matching @item @@ -1782,7 +1673,7 @@ former case, but those for integer indices in the latter. Indexing with @code{[} will also carry out the relevant subsetting of any names attributes. -@node Indexing matrices and arrays, Indexing other structures, Indexing by vectors, Indexing +@node Indexing matrices and arrays @subsection Indexing matrices and arrays @cindex index @@ -1858,7 +1749,7 @@ Some operations such as @code{m[FALSE, ]} result in structures in which a dimension has zero extent. @R{} generally tries to handle these structures sensibly. -@node Indexing other structures, Subset assignment, Indexing matrices and arrays, Indexing +@node Indexing other structures @subsection Indexing other structures The operator @code{[} is a generic function which allows class methods @@ -1886,7 +1777,7 @@ environments. Only character indices are allowed and no partial matching is done. -@node Subset assignment, , Indexing other structures, Indexing +@node Subset assignment @subsection Subset assignment @cindex assignment @cindex complex assignment @@ -2059,7 +1950,7 @@ variable with the same name as the target variable of a @c @end example -@node Scope of variables, , Indexing, Evaluation of expressions +@node Scope of variables @section Scope of variables @cindex scope @@ -2073,14 +1964,8 @@ Pascal. However, @R{} is a @emph{functional programming language} and allows dynamic creation and manipulation of functions and language objects, and has additional features reflecting this fact. -@menu -* Global environment:: -* Lexical environment:: -* Stacks:: -* Search path:: -@end menu -@node Global environment, Lexical environment, Scope of variables, Scope of variables +@node Global environment @subsection Global environment The global @@ -2092,7 +1977,7 @@ object to belong to the global environment. Its enclosing environment is the next environment on the search path, and so on back to the empty environment that is the enclosure of the base environment. -@node Lexical environment, Stacks, Global environment, Scope of variables +@node Lexical environment @subsection Lexical environment Every call to a @@ -2134,7 +2019,7 @@ to the environment of the base package. If the variable is not found there, the search will proceed next to the empty environment, and will fail. -@node Stacks, Search path, Lexical environment, Scope of variables +@node Stacks @subsection The call stack Every time a @@ -2188,7 +2073,7 @@ Calls @code{sys.frames}, @code{sys.parents} and @code{sys.calls}. Get the evaluation frame for the specified parent context. @end table -@node Search path, , Stacks, Scope of variables +@node Search path @subsection Search path In addition to the evaluation @@ -2215,16 +2100,11 @@ masked by objects of the same name in the global environment or in other packages. -@node Functions, Object-oriented programming, Evaluation of expressions, Top +@node Functions @chapter Functions -@menu -* Writing functions:: -* Functions as objects:: -* Evaluation:: -@end menu -@node Writing functions, Functions as objects, Functions, Functions +@node Writing functions @section Writing functions While @R{} can be very useful as a data analysis tool most users very @@ -2245,12 +2125,8 @@ See section `Writing R documentation' in the `Writing R Extensions' manual. @end ifclear -@menu -* Syntax and examples:: -* Arguments:: -@end menu -@node Syntax and examples, Arguments, Writing functions, Writing functions +@node Syntax and examples @subsection Syntax and examples The syntax for writing a @@ -2290,7 +2166,7 @@ Here is a simple function: @code{echo <- function(x) print(x)}. So @code{echo} is a function that takes a single argument and when @code{echo} is invoked it prints its argument. -@node Arguments, , Syntax and examples, Writing functions +@node Arguments @subsection Arguments The formal arguments to the function define the variables whose values @@ -2326,7 +2202,7 @@ function that takes an arbitrary number of arguments. It can be used to absorb some arguments into an intermediate function which can then be extracted by functions called subsequently. -@node Functions as objects, Evaluation, Writing functions, Functions +@node Functions as objects @section Functions as objects Functions are first class objects in @R{}. They can be used anywhere @@ -2334,17 +2210,11 @@ that an @R{} object is required. In particular they can be passed as arguments to functions and returned as values from functions. See @ref{Function objects} for the details. -@node Evaluation, , Functions as objects, Functions +@node Evaluation @section Evaluation -@menu -* Evaluation environment:: -* Argument matching:: -* Argument evaluation:: -* Scope:: -@end menu -@node Evaluation environment, Argument matching, Evaluation, Evaluation +@node Evaluation environment @subsection Evaluation environment When a @@ -2365,7 +2235,7 @@ associated with the function being invoked. This may be different from this does not have to be true and functions defined in packages with namespaces (normally) have the package namespace as their environment. -@node Argument matching, Argument evaluation, Evaluation environment, Evaluation +@node Argument matching @subsection Argument matching This subsection applies to closures but not to primitive functions. The @@ -2417,7 +2287,7 @@ Argument matching is augmented by the functions @code{match.arg}, Access to the partial matching algorithm used by @R{} is via @code{pmatch}. -@node Argument evaluation, Scope, Argument matching, Evaluation +@node Argument evaluation @subsection Argument evaluation One of the most important things to know about the @@ -2520,7 +2390,7 @@ This happens whenever an unevaluated argument is passed as an argument to another function. When forcing a promise, other promises in its expression will also be forced recursively as they are evaluated. -@node Scope, , Argument evaluation, Evaluation +@node Scope @subsection Scope @cindex scope @@ -2610,7 +2480,7 @@ indicating that @code{y} is not found, unless there is a variable @c environment or workspace. These rules are very similar to @c the scoping rules used in the @code{C} language. -@c @node Closures, , Evaluation, Functions +@c @node Closures @c section Closures @c A @emph{closure} is a @@ -2622,14 +2492,14 @@ indicating that @code{y} is not found, unless there is a variable @c See also 'dot-dot-dot' above -@c @node Miscellanea, , Closures, Functions +@c @node Miscellanea @c @section Miscellanea @c - g(...), ..1, @c - Recall() -@node Object-oriented programming, Computing on the language, Functions, Top +@node Object-oriented programming @chapter Object-oriented programming @cindex object-oriented @@ -2704,17 +2574,8 @@ when it exists. @c representation for some of the more common distributions. @c -@menu -* Definition:: -* Inheritance:: -* Method dispatching:: -* UseMethod:: -* NextMethod:: -* Group methods:: -* Writing methods:: -@end menu - -@node Definition, Inheritance, Object-oriented programming, Object-oriented programming + +@node Definition @section Definition Rather than having a full-fledged @@ -2861,7 +2722,7 @@ The bulk of the uses of this methodology are to provide specialized printing for objects of different types; there are about 40 methods for @code{print}. -@node Inheritance, Method dispatching, Definition, Object-oriented programming +@node Inheritance @section Inheritance @cindex evaluation @@ -2873,7 +2734,7 @@ currently being evaluated, finds the next class from the FIXME: something is missing here -@node Method dispatching, UseMethod, Inheritance, Object-oriented programming +@node Method dispatching @section Method dispatching @cindex function, generic @@ -2907,7 +2768,7 @@ any number of elements. Each of these is a string that defines a class. When a generic function is invoked the class of its first argument is examined. -@node UseMethod, NextMethod, Method dispatching, Object-oriented programming +@node UseMethod @section @code{UseMethod} @findex UseMethod @@ -2994,7 +2855,7 @@ the method; these remain as they were in the call to the generic. This is in contrast to @code{NextMethod} where the arguments in the call to the next method can be altered. -@node NextMethod, Group methods, UseMethod, Object-oriented programming +@node NextMethod @section @code{NextMethod} @findex NextMethod @@ -3065,12 +2926,12 @@ Values for lookup: @c what its used for but I don't currently think it's involved in the @c dispatch. -@c @node Implicit dispatching, Group methods, NextMethod, Object-oriented programming +@c @node Implicit dispatching @c @section Implicit dispatching @c What is implicit dispatching???? -@node Group methods, Writing methods, NextMethod, Object-oriented programming +@node Group methods @section Group methods For several types of @@ -3119,7 +2980,7 @@ class that was used to determine the method. Otherwise the corresponding element of @code{.Method} is set to the zero length string, @code{""}. -@node Writing methods, , Group methods, Object-oriented programming +@node Writing methods @section Writing methods Users can easily write their own methods and generic functions. A @@ -3145,20 +3006,16 @@ that output and provides a nice readable version of it. The user then needs only remember that @code{print} or @code{summary} will provide nice output for the results of any analysis. -@c @node Modeling functions, Graphics model, Object-oriented programming, Top +@c @node Modeling functions @c @chapter Modeling functions -@c @node Graphics model, Computing on the language, Modeling functions, Top +@c @node Graphics model @c @chapter Graphics model -@c @menu -@c * Math expressions in text:: -@c @end menu - -@c @node Math expressions in text, , Graphics model, Graphics model +@c @node Math expressions in text @c @section Math expressions in text -@node Computing on the language, System and foreign language interfaces, Object-oriented programming, Top +@node Computing on the language @chapter Computing on the language @R{} belongs to a class of programming languages in which subroutines @@ -3194,16 +3051,8 @@ mathematical expressions. In this chapter, we give an introduction to the set of facilities that are available for computing on the language. -@menu -* Direct manipulation of language objects:: -* Substitutions:: -* More on evaluation:: -* Evaluation of expression objects:: -* Manipulation of function calls:: -* Manipulation of functions:: -@end menu -@node Direct manipulation of language objects, Substitutions, Computing on the language, Computing on the language +@node Direct manipulation of language objects @section Direct manipulation of language objects There are three kinds of language objects that are available for @@ -3323,7 +3172,7 @@ to the original expression (up to rounding error). ...internal storage of flow control constructs...note Splus incompatibility... -@node Substitutions, More on evaluation, Direct manipulation of language objects, Computing on the language +@node Substitutions @section Substitutions It is in fact not often that one wants to modify the innards of an @@ -3474,7 +3323,7 @@ optional argument to compute the values in a different environment. The syntax for @code{bquote} is borrowed from the LISP backquote macro. -@node More on evaluation, Evaluation of expression objects, Substitutions, Computing on the language +@node More on evaluation @section More on evaluation @cindex evaluation @@ -3529,7 +3378,7 @@ This is also true when evaluating in lists, but the original list does not change because one is really working on a copy. -@node Evaluation of expression objects, Manipulation of function calls, More on evaluation, Computing on the language +@node Evaluation of expression objects @section Evaluation of expression objects Objects of mode @code{"expression"} are defined in @ref{Expression @@ -3588,7 +3437,7 @@ I.e., @code{e} and @code{ee} look identical when printed, but one is a call that generates an expression object and the other is the object itself. -@node Manipulation of function calls, Manipulation of functions, Evaluation of expression objects, Computing on the language +@node Manipulation of function calls @section Manipulation of function calls It is possible for a @@ -3748,7 +3597,7 @@ aspects of lazy evaluation and argument substitution in the function itself. A similar remark applies to the @code{call} function. -@node Manipulation of functions, , Manipulation of function calls, Computing on the language +@node Manipulation of functions @section Manipulation of functions It is often useful to be able to manipulate the components of a @@ -3789,16 +3638,11 @@ information is lost when @code{as.list} is used, whereas @code{as.function} has an argument that allows the environment to be set. -@node System and foreign language interfaces, Exception handling, Computing on the language, Top +@node System and foreign language interfaces @chapter System and foreign language interfaces -@menu -* Operating system access:: -* Foreign language interfaces:: -* .Internal and .Primitive:: -@end menu -@node Operating system access, Foreign language interfaces, System and foreign language interfaces, System and foreign language interfaces +@node Operating system access @section Operating system access Access to the operating system shell is via the @R{} function @@ -3884,7 +3728,7 @@ platform-independent way. @end multitable @end quotation -@node Foreign language interfaces, .Internal and .Primitive, Operating system access, System and foreign language interfaces +@node Foreign language interfaces @section Foreign language interfaces @findex .C @findex .Fortran @@ -3910,7 +3754,7 @@ other languages which can generate C interfaces, for example C++. Functions @code{.Call} and @code{.External} provide interfaces which allow compiled code (primarily compiled @C{} code) to manipulate @R{} objects. -@node .Internal and .Primitive, , Foreign language interfaces, System and foreign language interfaces +@node .Internal and .Primitive @section .Internal and .Primitive @findex .Internal @findex .Primitive @@ -3926,7 +3770,7 @@ See section `.Internal vs .Primitive' in the `R Internals' manual. -@node Exception handling, Debugging, System and foreign language interfaces, Top +@node Exception handling @chapter Exception handling The exception handling facilities in @R{} are provided through two @@ -3934,21 +3778,15 @@ mechanisms. Functions such as @code{stop} or @code{warning} can be called directly or options such as @code{"warn"} can be used to control the handling of problems. -@menu -* stop:: -* warning:: -* on.exit:: -* Error options:: -@end menu -@node stop, warning, Exception handling, Exception handling +@node stop @section stop @findex stop A call to @code{stop} halts the evaluation of the current expression, prints the message argument and returns execution to top-level. -@node warning, on.exit, stop, Exception handling +@node warning @section warning @findex warning @findex warnings @@ -3969,7 +3807,7 @@ occurred is printed. In either case @code{last.warning} contains the vector of messages, and @code{warnings} provides a way to access and print it. -@node on.exit, Error options, warning, Exception handling +@node on.exit @section on.exit @findex on.exit @@ -3988,7 +3826,7 @@ immediate jump to top-level without further processing of the @code{on.exit} takes a single argument which is an expression to be evaluated when the function is exited. -@c @node restart, Error options, on.exit, Exception handling +@c @node restart @c @section restart @c @findex restart @@ -4014,7 +3852,7 @@ evaluated when the function is exited. @c that was in effect at the time that the error that triggered the jump @c was signalled. -@node Error options, , on.exit, Exception handling +@node Error options @section Error options There are a number of @code{options} variables that can be used to @@ -4040,7 +3878,7 @@ One can use @code{options(error = expression(q("yes")))} to get @R{} to quit when an error has been signalled. In this case an error will cause @R{} to shut down and the global environment will be saved. -@node Debugging, Parser, Exception handling, Top +@node Debugging @chapter Debugging Debugging code has always been a bit of an art. @R{} provides several @@ -4090,14 +3928,8 @@ statements in that language is provided. Execution will halt on the next statement that is evaluated in @R{}. A symbolic debugger such as @code{gdb} can be used to debug compiled code. -@menu -* browser:: -* debug/undebug:: -* trace/untrace:: -* traceback:: -@end menu -@node browser, debug/undebug, Debugging, Debugging +@node browser @section browser @findex browser @@ -4119,7 +3951,7 @@ Browse[1]> get("c") Browse[1]> @end example -@node debug/undebug, trace/untrace, browser, Debugging +@node debug/undebug @section @code{debug}/@code{undebug} @findex debug @findex undebug @@ -4165,7 +3997,7 @@ exiting from: mean.default(1:10) [1] 5.5 @end example -@node trace/untrace, traceback, debug/undebug, Debugging +@node trace/untrace @section trace/untrace @findex trace @findex untrace @@ -4187,7 +4019,7 @@ removed by calling @code{untrace} with the function as an argument. trace: "[<-"(*tmp*, 3, value = 4) @end example -@node traceback, , trace/untrace, Debugging +@node traceback @section traceback @findex traceback @@ -4197,7 +4029,7 @@ When an error has caused a jump to top-level a special variable called call that was active at the time the error occurred. An examination of @code{.Traceback} can be carried out by a call to @code{traceback}. -@node Parser, Function and Variable Index, Debugging, Top +@node Parser @chapter Parser @cindex parsing @@ -4207,26 +4039,12 @@ causes the specified instructions to be carried out. The internal form is itself an @R{} object and can be saved and otherwise manipulated within the @R{} system. -@menu -* The parsing process:: -* Comments:: -* Tokens:: -* Expressions:: -* Directives:: -@end menu -@node The parsing process, Comments, Parser, Parser -@comment node-name, next, previous, up +@node The parsing process @section The parsing process -@menu -* Modes of parsing:: -* Internal representation:: -* Deparsing:: -@end menu -@node Modes of parsing, Internal representation, The parsing process, The parsing process -@comment node-name, next, previous, up +@node Modes of parsing @subsection Modes of parsing Parsing in @R{} occurs in three different variants: @@ -4261,8 +4079,7 @@ Character strings, or vectors thereof, can be parsed using the @code{text=} argument to @code{parse}. The strings are treated exactly as if they were the lines of an input file. -@node Internal representation, Deparsing, Modes of parsing, The parsing process -@comment node-name, next, previous, up +@node Internal representation @subsection Internal representation @cindex parsing @@ -4279,8 +4096,7 @@ formal and actual arguments. Note that @emph{all} @R{} syntax elements are treated in this way, e.g.@: the assignment @code{x <- 1} is encoded as @code{"<-"(x, 1)}. -@node Deparsing, , Internal representation, The parsing process -@comment node-name, next, previous, up +@node Deparsing @subsection Deparsing Any @R{} object can be converted to an @R{} expression using @@ -4295,8 +4111,7 @@ but there are a couple of awkward exceptions, mostly involving expressions that weren't generated from a textual representation in the first place. -@node Comments, Tokens, The parsing process, Parser -@comment node-name, next, previous, up +@node Comments @section Comments @cindex comments @@ -4311,8 +4126,7 @@ the @code{#} character is inside a quoted string. For example, > y <- " #... but this is not." @end example -@node Tokens, Expressions, Comments, Parser -@comment node-name, next, previous, up +@node Tokens @section Tokens Tokens are the elementary building blocks of a programming language. @@ -4320,19 +4134,9 @@ They are recognised during @emph{lexical analysis} which (conceptually, at least) takes place prior to the syntactic analysis performed by the parser itself. -@menu -* Literal constants:: -* Identifiers:: -* Reserved words:: -* Special operators:: -* Separators:: -* Operator tokens:: -* Grouping:: -* Indexing tokens:: -@end menu - -@node Literal constants, Identifiers, Tokens, Tokens -@comment node-name, next, previous, up + +@c avoid clash with node "Constants" in "Simple evaluation" further above +@node Literal constants @subsection Constants There are five types of constants: integer, logical, numeric, complex and string. @@ -4454,7 +4258,7 @@ A @abbr{NUL} (@code{\0}) is not allowed in a character string, so using warning): further characters up to the closing quote are scanned but ignored. -@node Identifiers, Reserved words, Literal constants, Tokens +@node Identifiers @subsection Identifiers @cindex identifier @@ -4489,7 +4293,7 @@ following pairs are @emph{not} equivalent @end multitable @end quotation -@node Reserved words, Special operators, Identifiers, Tokens +@node Reserved words @subsection Reserved words The following identifiers have a special meaning and cannot be used @@ -4502,7 +4306,7 @@ NA NA_integer_ NA_real_ NA_complex_ NA_character_ ... ..1 ..2 @r{etc.} @end example -@node Special operators, Separators, Reserved words, Tokens +@node Special operators @subsection Special operators @R{} allows user-defined infix operators. These have the form of a @@ -4516,7 +4320,7 @@ Note that the following operators are predefined: %% %*% %/% %in% %o% %x% %||% @end example -@c @node Special symbols, Separators, Special operators, Tokens +@c @node Special symbols @c @subsection Special symbols @c @c (I can't for the life of me remember what I intended here... -pd) @@ -4524,7 +4328,7 @@ Note that the following operators are predefined: @c words" @c FIXME: get this clarified -@node Separators, Operator tokens, Special operators, Tokens +@node Separators @subsection Separators Although not strictly tokens, stretches of whitespace characters @@ -4554,7 +4358,7 @@ incomplete, or invalid as soon as the user presses @key{RET}. The comma (@samp{,}) is used to separate function arguments and multiple indices. -@node Operator tokens, Grouping, Separators, Tokens +@node Operator tokens @subsection Operator tokens @R{} uses the following operator tokens @@ -4574,7 +4378,7 @@ indices. @noindent (Several of the operators have different meaning inside model formulas) -@node Grouping, Indexing tokens, Operator tokens, Tokens +@node Grouping @subsection Grouping Ordinary parentheses---@samp{(} and @samp{)}---are used for explicit @@ -4584,7 +4388,7 @@ function definitions and function calls. Braces---@samp{@{} and @samp{@}}---delimit blocks of expressions in function definitions, conditional expressions, and iterative constructs. -@node Indexing tokens, , Grouping, Tokens +@node Indexing tokens @subsection Indexing tokens Indexing of arrays and vectors is performed using the single and double @@ -4593,7 +4397,7 @@ may be done using the @samp{$} operator. @c ------end of @section Tokens ------------ -@node Expressions, Directives, Tokens, Parser +@node Expressions @section Expressions An @R{} program consists of a sequence of @R{} expressions. An @@ -4604,19 +4408,11 @@ parts (which may themselves be expressions). The following sections detail the various syntactical constructs that are available. -@menu -* Function calls (expressions):: -* Infix and prefix operators:: -* Index constructions:: -* Compound expressions:: -* Flow control elements:: -* Function definitions:: -@end menu @c need "(expressions)" or something to differentiate from node @c "Function calls" (way) above : -@node Function calls (expressions), Infix and prefix operators, Expressions, Expressions +@node Function calls (expressions) @subsection Function calls @cindex function @@ -4653,7 +4449,7 @@ g(tag = value, , 5) (function(x) x^2)(5) @end example -@node Infix and prefix operators, Index constructions, Function calls (expressions), Expressions +@node Infix and prefix operators @subsection Infix and prefix operators The order of precedence (highest first) of the operators is @@ -4716,7 +4512,7 @@ an assignment, as far as the parser is concerned (@code{2 + 2 <- 5} is a valid expression as far as the parser is concerned. The evaluator will object, though). Similar comments apply to the model formula operator. -@node Index constructions, Compound expressions, Infix and prefix operators, Expressions +@node Index constructions @subsection Index constructions @R{} has three indexing constructs, two of which are syntactically @@ -4748,13 +4544,13 @@ Here, @var{object} is as above, whereas @var{tag} is an identifier or a text string. Internally, it is stored as a function call with name @code{"$"} -@c @node Assignments, Model formulae, Index constructions, Expressions +@c @node Assignments @c @subsection Assignments -@c @node Model formulae, Flow control elements, Assignments, Expressions +@c @node Model formulae @c @subsection Model formulae -@node Compound expressions, Flow control elements, Index constructions, Expressions +@node Compound expressions @subsection Compound expressions A compound expression is of the form @@ -4767,7 +4563,7 @@ The semicolons may be replaced by newlines. Internally, this is stored as a function call with @code{"@{"} as the function name and the expressions as arguments. -@node Flow control elements, Function definitions, Compound expressions, Expressions +@node Flow control elements @subsection Flow control elements @R{} contains the following control structures as special syntactic @@ -4800,7 +4596,7 @@ Internally, the constructs are stored as function calls: "next"() @end example -@node Function definitions, , Flow control elements, Expressions +@node Function definitions @subsection Function definitions A @@ -4827,7 +4623,7 @@ the @var{body}. The @var{arglist} is stored as a tagged pairlist where the tags are the argument names and the values are the default expressions. -@node Directives, , Expressions, Parser +@node Directives @section Directives @cindex #line @@ -4856,20 +4652,20 @@ diagnostic messages refer to the original file. @c -- We can probably lose this given the brevity of the section -@c @node Summary , , Syntactic elements, Parser +@c @node Summary @c @section Summary of language -@node Function and Variable Index, Concept Index, Parser, Top +@node Function and Variable Index @unnumbered Function and Variable Index @printindex vr -@node Concept Index, References, Function and Variable Index, Top +@node Concept Index @unnumbered Concept Index @printindex cp -@node References, , Concept Index, Top +@node References @appendix References @I{Richard A.@: Becker}, @I{John M.@: Chambers} and @I{Allan R.@: Wilks} (1988), From b0fdaf8370c9b8ddeb9813af754534981a53ee83 Mon Sep 17 00:00:00 2001 From: smeyer Date: Mon, 24 Jun 2024 13:56:05 +0000 Subject: [PATCH 293/546] update node pointers git-svn-id: https://svn.r-project.org/R/trunk@86817 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index a922a7cb912..b5aedc7916c 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13063,7 +13063,7 @@ int R_has_slot(SEXP obj, SEXP name); @eapifun R_getClassDef @eapifun R_has_slot -@node Handling lists, Handling character data, Classes, Handling R objects in C +@node Handling lists, Handling character data, S4 objects, Handling R objects in C @subsection Handling lists @cindex Handling lists @@ -16889,7 +16889,7 @@ option. For example, finalizers are run in a separate top level context. The other functions mentioned in this section will usually be more appropriate choices. -@node Allowing interrupts, Platform and version information, Condition handling and cleanup code, The R API +@node Allowing interrupts, C stack checking, Condition handling and cleanup code, The R API @section Allowing interrupts @cindex Interrupts @@ -18722,7 +18722,7 @@ to use these should be prepared to adapt. @printindex ae -@node Embedding API index, , API index, Top +@node Embedding API index, , Experimental API index, Top @unnumbered Embedding API index Functions, variables, and header files to support creating alternate From e094fb980983ec4f49825f684a5764bb5797f966 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 24 Jun 2024 14:27:17 +0000 Subject: [PATCH 294/546] Force check WARNING for using PRSEEN, SET_PRSEEN, or SYMVALUE. git-svn-id: https://svn.r-project.org/R/trunk@86818 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 33e38b4a263..66eefb63236 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -3803,7 +3803,7 @@ add_dummies <- function(dir, Log) haveObjs <- any(grepl("^ *Object", out)) pat <- paste("possibly from", sQuote("(abort|assert|exit|_exit|_Exit|stop)")) - rempat <- "REAL0|COMPLEX0|ddfind|DDVAL|ENSURE_NAMEDMAX|INTERNAL" + rempat <- "REAL0|COMPLEX0|ddfind|DDVAL|ENSURE_NAMEDMAX|INTERNAL|PRSEEN|SET_PRSEEN|SYMVALUE" if(haveObjs && any(grepl(pat, out)) && pkgname %notin% "parallel") ## need _exit in forked child warningLog(Log) From 8e2cc184bed7e7e39c22438c331790240e9477e1 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 24 Jun 2024 15:17:56 +0000 Subject: [PATCH 295/546] Add R_findVar and R_findVarInFrame with declarations in Defn.h. Mark as attribute_hidded for now. git-svn-id: https://svn.r-project.org/R/trunk@86819 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/Defn.h | 2 ++ src/main/envir.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/include/Defn.h b/src/include/Defn.h index 5df339411ac..05c4e822a83 100644 --- a/src/include/Defn.h +++ b/src/include/Defn.h @@ -1917,6 +1917,8 @@ SEXP R_GetVarLocValue(R_varloc_t); SEXP R_GetVarLocSymbol(R_varloc_t); Rboolean R_GetVarLocMISSING(R_varloc_t); void R_SetVarLocValue(R_varloc_t, SEXP); +SEXP R_findVar(SEXP, SEXP); +SEXP R_findVarInFrame(SEXP, SEXP); /* deparse option bits: change do_dump if more are added */ diff --git a/src/main/envir.c b/src/main/envir.c index c6810e46ef1..6c221317785 100644 --- a/src/main/envir.c +++ b/src/main/envir.c @@ -1091,11 +1091,16 @@ Rboolean R_existsVarInFrame(SEXP rho, SEXP symbol) return FALSE; } -SEXP findVarInFrame(SEXP rho, SEXP symbol) +attribute_hidden SEXP R_findVarInFrame(SEXP rho, SEXP symbol) { return findVarInFrame3(rho, symbol, TRUE); } +SEXP findVarInFrame(SEXP rho, SEXP symbol) +{ + return R_findVarInFrame(rho, symbol); +} + /*---------------------------------------------------------------------- readS3VarsFromFrame @@ -1211,7 +1216,7 @@ static R_INLINE SEXP findGlobalVar(SEXP symbol) } #endif -SEXP findVar(SEXP symbol, SEXP rho) +attribute_hidden SEXP R_findVar(SEXP symbol, SEXP rho) { SEXP vl; @@ -1244,6 +1249,11 @@ SEXP findVar(SEXP symbol, SEXP rho) #endif } +SEXP findVar(SEXP symbol, SEXP rho) +{ + return R_findVar(symbol, rho); +} + static SEXP findVarLoc(SEXP symbol, SEXP rho) { SEXP vl; From aea94663cf41ab76d66df9992e4c5c392c2a393c Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 24 Jun 2024 16:28:15 +0000 Subject: [PATCH 296/546] Unlimited file length in Rterm/getline (on Windows, PR#18690). git-svn-id: https://svn.r-project.org/R/trunk@86820 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/getline/README | 17 ++++- src/gnuwin32/getline/getline.c | 121 +++++++++++++++++++++++++++------ src/gnuwin32/getline/getline.h | 4 +- src/gnuwin32/system.c | 31 ++++++++- 4 files changed, 147 insertions(+), 26 deletions(-) diff --git a/src/gnuwin32/getline/README b/src/gnuwin32/getline/README index 43c8c5683ad..86caf703af8 100644 --- a/src/gnuwin32/getline/README +++ b/src/gnuwin32/getline/README @@ -43,8 +43,9 @@ Thanks to the following people who have provided enhancements and fixes: PS: I don't have, and don't want to add, a vi mode, sorry. -This version is with modifications by R Core, including a Windows port, support -for multi-byte characters and partial support for Unicode sequences. +This version is with modifications by R Core, including a Windows port, +support for multi-byte characters, support for lines of arbitrary length and +partial support for Unicode sequences. ************************** End-User Interface *************************** @@ -118,7 +119,7 @@ Entering characters by code: The programmer accesses input-edit through these functions, and optionally through three additional function pointer hooks. The four functions are: -int getline(char *prompt, char *buf, int buflen) +int getline(const char *prompt, char *buf, int buflen) Prints the prompt and allows the user to edit the current line. A pointer to a buffer to store the line is passed in "buf" with the @@ -138,6 +139,16 @@ int getline(char *prompt, char *buf, int buflen) (stdio) rather than the slow 1 character read()s that getline uses. Returns non-zero on EOF. +int getline2(const char *prompt, char **buf) + + The same as getline(), but the buffer is allocated dynamically, so + that the line length is unlimited. It has to be freed by the caller + using gl_free(). + +void gl_free(void *ptr) + + Free buffer returned by getline2(). + void gl_setwidth(int width) Set the width of the terminal to the specified width. The default diff --git a/src/gnuwin32/getline/getline.c b/src/gnuwin32/getline/getline.c index 8fa44a7d808..40088284796 100644 --- a/src/gnuwin32/getline/getline.c +++ b/src/gnuwin32/getline/getline.c @@ -58,7 +58,7 @@ extern Rboolean mbcslocale; edit buffer gl_buf. As in the original version, symbols not starting with "w_" hold offsets in bytes. */ -static int BUF_SIZE; /* dimension of the buffer received*/ +static int BUF_SIZE; /* dimension of the buffer received */ static int gl_init_done = -1; /* terminal mode flag */ static int gl_w_termw = 80; /* actual terminal width */ static int gl_w_width = 0; /* net size available for input */ @@ -68,6 +68,7 @@ static int gl_pos, gl_cnt = 0; /* position and size of input */ static int gl_w_pos; static int gl_w_cnt = 0; static char *gl_buf; /* input buffer */ +static int gl_buf_expandable = 0; /* input buffer grows as needed */ static char *gl_killbuf = NULL; /* killed text */ static const char *gl_prompt; /* to save the prompt string */ static int gl_search_mode = 0; /* search mode flag */ @@ -440,6 +441,18 @@ void gl_error(const char *const buf) longjmp(gl_jmp,1); } +static void* +gl_realloc(void *ptr, int olditems, int newitems, size_t itemsize) +{ + void *res; + if (!(res = realloc(ptr, newitems * itemsize))) + gl_error("\n*** Error: getline(): not enough memory.\n"); + memset(((char *)res) + olditems * itemsize, + 0, + (newitems - olditems) * itemsize); + return res; +} + static void gl_init(void) /* set up variables and terminal */ @@ -451,8 +464,8 @@ gl_init(void) } if (isatty(0) == 0 || isatty(1) == 0) gl_error("\n*** Error: getline(): not interactive, use stdio.\n"); - if (!(gl_killbuf=calloc(BUF_SIZE,sizeof(char)))) - gl_error("\n*** Error: getline(): not enough memory.\n"); + + gl_killbuf = gl_realloc(NULL, 0, BUF_SIZE, sizeof(char)); gl_nat_to_ucs = Riconv_open("UCS-4LE", ""); if (gl_nat_to_ucs == (void *)-1) @@ -467,12 +480,10 @@ gl_init(void) gl_oem_to_ucs = Riconv_open(oemname, "UCS-4LE"); if (gl_oem_to_ucs == (void *)-1) gl_error("\n*** Error: getline(): unable to convert from OEM CP.\n"); - if (!(gl_b2w_map = calloc(BUF_SIZE, sizeof(size_t)))) - gl_error("\n*** Error: getline(): not enough memory.\n"); - if (!(gl_w2b_map = calloc(BUF_SIZE, sizeof(size_t)))) - gl_error("\n*** Error: getline(): not enough memory.\n"); - if (!(gl_w2e_map = calloc(BUF_SIZE, sizeof(size_t)))) - gl_error("\n*** Error: getline(): not enough memory.\n"); + + gl_b2w_map = gl_realloc(NULL, 0, BUF_SIZE, sizeof(size_t)); + gl_w2b_map = gl_realloc(NULL, 0, BUF_SIZE, sizeof(size_t)); + gl_w2e_map = gl_realloc(NULL, 0, BUF_SIZE, sizeof(size_t)); gl_char_init(); gl_init_done = 1; @@ -503,6 +514,27 @@ gl_cleanup(void) gl_init_done = 0; } +static void +gl_buf_expand(int needed) +{ + if (needed <= BUF_SIZE || !gl_buf_expandable) + return; + + int newsize = BUF_SIZE * 2; + if (!newsize) + newsize = 128; + while (newsize < needed) + newsize *= 2; + + gl_buf = gl_realloc(gl_buf, BUF_SIZE, newsize, sizeof(char)); + gl_killbuf = gl_realloc(gl_killbuf, BUF_SIZE, newsize, sizeof(char)); + gl_b2w_map = gl_realloc(gl_b2w_map, BUF_SIZE, newsize, sizeof(size_t)); + gl_w2b_map = gl_realloc(gl_w2b_map, BUF_SIZE, newsize, sizeof(size_t)); + gl_w2e_map = gl_realloc(gl_w2e_map, BUF_SIZE, newsize, sizeof(size_t)); + + BUF_SIZE = newsize; +} + void gl_setwidth(int w) { @@ -671,14 +703,12 @@ update_map(size_t change) } /* Returns 1 on EOF */ -int -getline(const char *prompt, char *buf, int buflen) +static int +getline0(const char *prompt) { int c, loc, tmp; + char *stmp; - BUF_SIZE = buflen; - gl_buf = buf; - gl_buf[0] = '\0'; if (setjmp(gl_jmp)) { if (gl_init_done > 0) { gl_newline(); @@ -762,7 +792,9 @@ getline(const char *prompt, char *buf, int buflen) case '\014': gl_redraw(); /* ^L */ break; case '\016': /* ^N, VK_DOWN */ - strncpy(gl_buf, gl_hist_next(), BUF_SIZE-2); + stmp = gl_hist_next(); + gl_buf_expand(strlen(stmp) + 2); + strncpy(gl_buf, stmp, BUF_SIZE-2); gl_buf[BUF_SIZE-2] = '\0'; if (gl_in_hook) gl_in_hook(gl_buf); @@ -771,7 +803,9 @@ getline(const char *prompt, char *buf, int buflen) case '\017': gl_overwrite = !gl_overwrite; /* ^O */ break; case '\020': /* ^P, VK_UP */ - strncpy(gl_buf, gl_hist_prev(),BUF_SIZE-2); + stmp = gl_hist_prev(); + gl_buf_expand(strlen(stmp) + 2); + strncpy(gl_buf, stmp, BUF_SIZE-2); gl_buf[BUF_SIZE-2] = '\0'; if (gl_in_hook) gl_in_hook(gl_buf); @@ -798,14 +832,18 @@ getline(const char *prompt, char *buf, int buflen) if (c == '[') { switch(c = gl_getc()) { case 'A': /* up */ - strncpy(gl_buf, gl_hist_prev(), BUF_SIZE-2); + stmp = gl_hist_prev(); + gl_buf_expand(strlen(stmp) + 2); + strncpy(gl_buf, stmp, BUF_SIZE-2); gl_buf[BUF_SIZE-2] = '\0'; if (gl_in_hook) gl_in_hook(gl_buf); gl_fixup(gl_prompt, 0, BUF_SIZE); break; case 'B': /* down */ - strncpy(gl_buf, gl_hist_next(), BUF_SIZE-2); + stmp = gl_hist_next(); + gl_buf_expand(strlen(stmp) + 2); + strncpy(gl_buf, stmp, BUF_SIZE-2); gl_buf[BUF_SIZE-2] = '\0'; if (gl_in_hook) gl_in_hook(gl_buf); @@ -846,6 +884,44 @@ getline(const char *prompt, char *buf, int buflen) return 0; } +/* returns 1 on eof */ +/* The line is stored into buf of size buflen, attempts to enter a longer line + are ignored with a beep signal. */ +int +getline(const char *prompt, char *buf, int buflen) +{ + BUF_SIZE = buflen; + gl_buf_expandable = 0; + gl_buf = buf; + gl_buf[0] = '\0'; + return getline0(prompt); +} + +/* returns 1 on eof */ +/* The line is stored into a dynamically allocated buffer. The buffer has to + be freed by the caller using gl_free() when no longer needed. */ +int +getline2(const char *prompt, char **buf) +{ + BUF_SIZE = 128; /* initial size */ + gl_buf_expandable = 1; + if (!(gl_buf = malloc(BUF_SIZE * sizeof(char)))) + gl_error("\n*** Error: getline(): not enough memory.\n"); + gl_buf[0] = '\0'; + int res = getline0(prompt); + if (buf) { + *buf = gl_buf; + gl_buf = NULL; + } + return res; +} + +void gl_free(void *ptr) +{ + if (ptr) + free(ptr); +} + /* Adds bytes from s to the current position of the buffer. The input needs to only include complete edit units. */ static void @@ -866,6 +942,7 @@ gl_addbytes(const char *s) } if (len > del) { /* expanding buffer */ + gl_buf_expand(gl_cnt + len - del + 2); if (gl_cnt + len - del >= BUF_SIZE - 1) gl_error("\n*** Error: getline(): input buffer overflow\n"); for (i = gl_cnt; i >= gl_pos + del; i--) @@ -894,6 +971,7 @@ gl_addchar(int c) char *outbuf; int i; + gl_buf_expand(gl_cnt + 3); if (gl_cnt >= BUF_SIZE - 2) gl_putc('\a'); else if (iswprint(c)) { @@ -920,6 +998,7 @@ gl_addchar(int c) left = gl_edit_unit_size_left(); if (left > 0) { + gl_buf_expand(gl_cnt + clen + 2); if (gl_cnt + clen >= BUF_SIZE - 1) gl_error("\n*** Error: getline(): input buffer overflow\n"); @@ -1002,6 +1081,7 @@ gl_newline(void) /* shifts line back to start position */ int loc = gl_b_from_w(gl_w_align_left(gl_w_width - 5)); + gl_buf_expand(gl_cnt + 2); if (gl_cnt >= BUF_SIZE - 1) { gl_error("\n*** Error: getline(): input buffer overflow\n"); } @@ -1583,7 +1663,8 @@ search_addchar(int c) gl_buf[0] = 0; hist_pos = hist_last; } - strncpy(gl_buf, hist_buf[hist_pos],BUF_SIZE-2); + gl_buf_expand(strlen(hist_buf[hist_pos]) + 2); + strncpy(gl_buf, hist_buf[hist_pos], BUF_SIZE-2); gl_buf[BUF_SIZE-2] = '\0' ; } if ((loc = strstr(gl_buf, search_string)) != 0) { @@ -1631,6 +1712,7 @@ search_back(int new_search) gl_fixup(search_prompt, 0, 0); found = 1; } else if ((loc = strstr(p, search_string)) != 0) { + gl_buf_expand(strlen(p) + 2); strncpy(gl_buf, p, BUF_SIZE-2); gl_buf[BUF_SIZE-2] = '\0'; gl_fixup(search_prompt, 0, loc - p); @@ -1665,6 +1747,7 @@ search_forw(int new_search) gl_fixup(search_prompt, 0, 0); found = 1; } else if ((loc = strstr(p, search_string)) != 0) { + gl_buf_expand(strlen(p) + 2); strncpy(gl_buf, p, BUF_SIZE-2); gl_buf[BUF_SIZE-2] = '\0'; gl_fixup(search_prompt, 0, loc - p); diff --git a/src/gnuwin32/getline/getline.h b/src/gnuwin32/getline/getline.h index c7e28eea91a..b8103c89241 100644 --- a/src/gnuwin32/getline/getline.h +++ b/src/gnuwin32/getline/getline.h @@ -6,7 +6,8 @@ typedef size_t (*gl_strwidth_proc)(const char *); /* read a line of input */ -int getline(const char *prompt, char *buf, int maxlen); +int getline(const char *prompt, char *buf, int maxlen); +int getline2(const char *prompt, char **buf); void gl_setwidth(int); /* specify width of screen */ void gl_histadd(const char *); /* adds entries to hist */ @@ -16,6 +17,7 @@ void gl_savehistory(const char *, int size); void gl_hist_init(int, int); /* set up history buffer */ char *gl_hist_next(void); /* return ptr to next item */ char *gl_hist_prev(void); /* return ptr to prev item */ +void gl_free(void *ptr); extern int (*gl_in_hook)(char *); extern int (*gl_out_hook)(char *); diff --git a/src/gnuwin32/system.c b/src/gnuwin32/system.c index 659cc49ef15..bee79abef12 100644 --- a/src/gnuwin32/system.c +++ b/src/gnuwin32/system.c @@ -402,9 +402,34 @@ static int CharReadConsole(const char *prompt, unsigned char *buf, int len, int addtohistory) { - int res = getline(prompt, (char *)buf, len); - if (addtohistory) gl_histadd((char *)buf); - return !res; + /* Long lines are returned in multiple consecutive calls to + CharReadConsole() */ + static char *line = NULL; + static size_t offset = 0; + static size_t remaining = 0; + static int res = 0; + + if (!line) { + res = getline2(prompt, &line); + if (addtohistory) gl_histadd(line); + offset = 0; + remaining = strlen(line); /* may be zero */ + } + + int tocopy = remaining; + if (tocopy > len - 1) tocopy = len - 1; + + memcpy(buf, line + offset, tocopy); + buf[tocopy] = '\0'; + remaining -= tocopy; + offset += tocopy; + + if (!remaining) { + gl_free(line); + line = NULL; + return !res; /* return 0 on EOF */ + } else + return 1; } /*3: (as InThreadReadConsole) and 4: non-interactive */ From 247076fc3050f92b123092ede319676a25048ed1 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 24 Jun 2024 16:50:25 +0000 Subject: [PATCH 297/546] Switch base internals to using R_findVar and R_findVarInFrame. Modules and base packages still use the unhidden Rf versions. git-svn-id: https://svn.r-project.org/R/trunk@86821 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/console.c | 4 +- src/gnuwin32/rt_complete.c | 4 +- src/gnuwin32/rui.c | 2 +- src/main/RNG.c | 4 +- src/main/Rdynload.c | 4 +- src/main/attrib.c | 2 +- src/main/builtin.c | 12 +-- src/main/coerce.c | 4 +- src/main/deparse.c | 2 +- src/main/devices.c | 10 +- src/main/envir.c | 56 +++++------ src/main/errors.c | 2 +- src/main/eval.c | 32 +++--- src/main/gevents.c | 12 +-- src/main/gram.c | 194 ++++++++++++++++++++++++++++++++++++- src/main/gram.y | 4 +- src/main/main.c | 10 +- src/main/match.c | 2 +- src/main/objects.c | 20 ++-- src/main/print.c | 16 +-- src/main/saveload.c | 10 +- src/main/serialize.c | 2 +- src/main/source.c | 3 +- src/main/subset.c | 4 +- src/main/unique.c | 2 +- src/unix/sys-std.c | 4 +- 26 files changed, 306 insertions(+), 115 deletions(-) diff --git a/src/gnuwin32/console.c b/src/gnuwin32/console.c index 35c733f64b8..1395e7abf6a 100644 --- a/src/gnuwin32/console.c +++ b/src/gnuwin32/console.c @@ -963,7 +963,7 @@ static void performCompletion(control c) return; } /* First check if namespace is loaded */ - if(findVarInFrame(R_NamespaceRegistry, install("utils")) + if(R_findVarInFrame(R_NamespaceRegistry, install("utils")) != R_UnboundValue) completion_available = 1; else { /* Then try to load it */ char *p = "try(loadNamespace('utils'), silent=TRUE)"; @@ -974,7 +974,7 @@ static void performCompletion(control c) eval(VECTOR_ELT(cmdexpr, i), R_GlobalEnv); } UNPROTECT(2); - if(findVarInFrame(R_NamespaceRegistry, install("utils")) + if(R_findVarInFrame(R_NamespaceRegistry, install("utils")) != R_UnboundValue) completion_available = 1; else { completion_available = 0; diff --git a/src/gnuwin32/rt_complete.c b/src/gnuwin32/rt_complete.c index 1619a8bd3cb..133f0b17f53 100644 --- a/src/gnuwin32/rt_complete.c +++ b/src/gnuwin32/rt_complete.c @@ -71,7 +71,7 @@ static int rt_completion(char *buf, int offset, int *loc) return gl_tab(buf, offset, loc); } /* First check if namespace is loaded */ - if(findVarInFrame(R_NamespaceRegistry, install("utils")) + if(R_findVarInFrame(R_NamespaceRegistry, install("utils")) != R_UnboundValue) completion_available = 1; else { /* Then try to load it */ char *p = "try(loadNamespace('utils'), silent=TRUE)"; @@ -82,7 +82,7 @@ static int rt_completion(char *buf, int offset, int *loc) eval(VECTOR_ELT(cmdexpr, i), R_GlobalEnv); } UNPROTECT(2); - if(findVarInFrame(R_NamespaceRegistry, install("utils")) + if(R_findVarInFrame(R_NamespaceRegistry, install("utils")) != R_UnboundValue) completion_available = 1; else { completion_available = 0; diff --git a/src/gnuwin32/rui.c b/src/gnuwin32/rui.c index 16e177fc835..0f920e9236c 100644 --- a/src/gnuwin32/rui.c +++ b/src/gnuwin32/rui.c @@ -372,7 +372,7 @@ static void menude(control m) if (!ConsoleAcceptCmd) return; s = askstring(G_("Name of data frame or matrix"), ""); if(s) { - var = findVar(install(s), R_GlobalEnv); + var = R_findVar(install(s), R_GlobalEnv); if (var != R_UnboundValue) { snprintf(cmd, 1024,"fix(%s)", s); consolecmd(RConsole, cmd); diff --git a/src/main/RNG.c b/src/main/RNG.c index 9df8094e1b5..1550e4899c0 100644 --- a/src/main/RNG.c +++ b/src/main/RNG.c @@ -329,7 +329,7 @@ static void RNG_Init(RNGtype kind, Int32 seed) static SEXP GetSeedsFromVar(void) { - SEXP seeds = findVarInFrame(R_GlobalEnv, R_SeedsSymbol); + SEXP seeds = R_findVarInFrame(R_GlobalEnv, R_SeedsSymbol); if (TYPEOF(seeds) == PROMSXP) seeds = eval(R_SeedsSymbol, R_GlobalEnv); return seeds; @@ -449,7 +449,7 @@ void PutRNGstate(void) int len_seed = RNG_Table[RNG_kind].n_seed; int kinds = RNG_kind + 100 * N01_kind + 10000 * Sample_kind; - SEXP seeds = findVarInFrame(R_GlobalEnv, R_SeedsSymbol); + SEXP seeds = R_findVarInFrame(R_GlobalEnv, R_SeedsSymbol); if (NOT_SHARED(seeds) && ATTRIB(seeds) == R_NilValue && TYPEOF(seeds) == INTSXP && XLENGTH(seeds) == len_seed + 1) { /* it is safe to resuse the existing .Random.seed vector */ diff --git a/src/main/Rdynload.c b/src/main/Rdynload.c index 2c55d708a25..4b5e0fea6ea 100644 --- a/src/main/Rdynload.c +++ b/src/main/Rdynload.c @@ -1714,7 +1714,7 @@ static SEXP get_package_CEntry_table(const char *package) R_PreserveObject(CEntryTable); } pname = install(package); - penv = findVarInFrame(CEntryTable, pname); + penv = R_findVarInFrame(CEntryTable, pname); if (penv == R_UnboundValue) { penv = R_NewHashedEnv(R_NilValue, 0); defineVar(pname, penv, CEntryTable); @@ -1738,7 +1738,7 @@ DL_FUNC R_GetCCallable(const char *package, const char *name) { SEXP penv = get_package_CEntry_table(package); PROTECT(penv); - SEXP eptr = findVarInFrame(penv, install(name)); + SEXP eptr = R_findVarInFrame(penv, install(name)); UNPROTECT(1); if (eptr == R_UnboundValue) error(_("function '%s' not provided by package '%s'"), name, package); diff --git a/src/main/attrib.c b/src/main/attrib.c index 02597c88e2e..08930764401 100644 --- a/src/main/attrib.c +++ b/src/main/attrib.c @@ -728,7 +728,7 @@ static SEXP S4_extends(SEXP klass, Rboolean use_tab) { } class = translateChar(STRING_ELT(klass, 0)); /* TODO: include package attr. */ if(use_tab) { - val = findVarInFrame(R_S4_extends_table, install(class)); + val = R_findVarInFrame(R_S4_extends_table, install(class)); vmaxset(vmax); if(val != R_UnboundValue) return val; diff --git a/src/main/builtin.c b/src/main/builtin.c index 82952c4b07c..0ddd8760a63 100644 --- a/src/main/builtin.c +++ b/src/main/builtin.c @@ -215,12 +215,12 @@ attribute_hidden SEXP do_args(SEXP call, SEXP op, SEXP args, SEXP rho) SEXP env, s2; PROTECT_INDEX xp; - PROTECT_WITH_INDEX(env = findVarInFrame(R_BaseEnv, - install(".ArgsEnv")), + PROTECT_WITH_INDEX(env = R_findVarInFrame(R_BaseEnv, + install(".ArgsEnv")), &xp); if (TYPEOF(env) == PROMSXP) REPROTECT(env = eval(env, R_BaseEnv), xp); - PROTECT(s2 = findVarInFrame(env, install(nm))); + PROTECT(s2 = R_findVarInFrame(env, install(nm))); if(s2 != R_UnboundValue) { s = duplicate(s2); SET_BODY(s, R_NilValue); @@ -229,10 +229,10 @@ attribute_hidden SEXP do_args(SEXP call, SEXP op, SEXP args, SEXP rho) return s; } UNPROTECT(1); /* s2 */ - REPROTECT(env = findVarInFrame(R_BaseEnv, install(".GenericArgsEnv")), + REPROTECT(env = R_findVarInFrame(R_BaseEnv, install(".GenericArgsEnv")), xp); if (TYPEOF(env) == PROMSXP) REPROTECT(env = eval(env, R_BaseEnv), xp); - PROTECT(s2 = findVarInFrame(env, install(nm))); + PROTECT(s2 = R_findVarInFrame(env, install(nm))); if(s2 != R_UnboundValue) { s = allocSExp(CLOSXP); SET_FORMALS(s, FORMALS(s2)); @@ -969,7 +969,7 @@ static SEXP expandDots(SEXP el, SEXP rho) while (el != R_NilValue) { if (CAR(el) == R_DotsSymbol) { - SEXP h = PROTECT(findVar(CAR(el), rho)); + SEXP h = PROTECT(R_findVar(CAR(el), rho)); if (TYPEOF(h) == DOTSXP || h == R_NilValue) { while (h != R_NilValue) { SETCDR(tail, CONS(CAR(h), R_NilValue)); diff --git a/src/main/coerce.c b/src/main/coerce.c index 483d53be098..cfd0fcd404c 100644 --- a/src/main/coerce.c +++ b/src/main/coerce.c @@ -2788,7 +2788,7 @@ SEXP substitute(SEXP lang, SEXP rho) return substitute(PREXPR(lang), rho); case SYMSXP: if (rho != R_NilValue) { - t = findVarInFrame( rho, lang); + t = R_findVarInFrame( rho, lang); if (t != R_UnboundValue) { if (TYPEOF(t) == PROMSXP) { do { @@ -2832,7 +2832,7 @@ attribute_hidden SEXP substituteList(SEXP el, SEXP rho) if (rho == R_NilValue) h = R_UnboundValue; /* so there is no substitution below */ else - h = findVarInFrame(rho, CAR(el)); + h = R_findVarInFrame(rho, CAR(el)); if (h == R_UnboundValue) h = LCONS(R_DotsSymbol, R_NilValue); else if (h == R_NilValue || h == R_MissingArg) diff --git a/src/main/deparse.c b/src/main/deparse.c index 82e125b5776..92691c9c512 100644 --- a/src/main/deparse.c +++ b/src/main/deparse.c @@ -460,7 +460,7 @@ attribute_hidden SEXP do_dump(SEXP call, SEXP op, SEXP args, SEXP rho) int nout = 0; for (int i = 0; i < nobjs; i++, o = CDR(o)) { SET_TAG(o, installTrChar(STRING_ELT(names, i))); - SETCAR(o, findVar(TAG(o), source)); + SETCAR(o, R_findVar(TAG(o), source)); if (CAR(o) == R_UnboundValue) warning(_("object '%s' not found"), EncodeChar(PRINTNAME(TAG(o)))); else nout++; diff --git a/src/main/devices.c b/src/main/devices.c index ab4f9d1fad6..91c73f60b00 100644 --- a/src/main/devices.c +++ b/src/main/devices.c @@ -51,7 +51,7 @@ static SEXP R_INLINE getSymbolValue(SEXP symbol) { if (TYPEOF(symbol) != SYMSXP) error("argument to 'getSymbolValue' is not a symbol"); - return findVar(symbol, R_BaseEnv); + return R_findVar(symbol, R_BaseEnv); } /* @@ -144,7 +144,7 @@ pGEDevDesc GEcurrentDevice(void) grDevices need not be in the search path. So we look for it first on the global search path. */ - defdev = findVar(devName, R_GlobalEnv); + defdev = R_findVar(devName, R_GlobalEnv); if(defdev != R_UnboundValue) { PROTECT(defdev = lang1(devName)); eval(defdev, R_GlobalEnv); @@ -155,11 +155,11 @@ pGEDevDesc GEcurrentDevice(void) The option is unlikely to be set if it is not loaded, as the default setting is in grDevices:::.onLoad. */ - SEXP ns = findVarInFrame(R_NamespaceRegistry, - install("grDevices")); + SEXP ns = R_findVarInFrame(R_NamespaceRegistry, + install("grDevices")); PROTECT(ns); if(ns != R_UnboundValue && - findVar(devName, ns) != R_UnboundValue) { + R_findVar(devName, ns) != R_UnboundValue) { PROTECT(defdev = lang1(devName)); eval(defdev, ns); UNPROTECT(1); diff --git a/src/main/envir.c b/src/main/envir.c index 6c221317785..2ae4d417f73 100644 --- a/src/main/envir.c +++ b/src/main/envir.c @@ -869,7 +869,7 @@ attribute_hidden void unbindVar(SEXP symbol, SEXP rho) findVarLocInFrame Look up the location of the value of a symbol in a - single environment frame. Almost like findVarInFrame, but + single environment frame. Almost like R_findVarInFrame, but does not return the value. R_NilValue if not found. Callers set *canCache = TRUE or NULL @@ -978,7 +978,7 @@ void R_SetVarLocValue(R_varloc_t vl, SEXP value) /*---------------------------------------------------------------------- - findVarInFrame + R_findVarInFrame Look up the value of a symbol in a single environment frame. This is the basic building block of all variable lookups. @@ -1159,12 +1159,12 @@ void readS3VarsFromFrame(SEXP rho, slowpath: /* fall back to the slow but general implementation */ - *dotGeneric = findVarInFrame(rho, R_dot_Generic); - *dotClass = findVarInFrame(rho, R_dot_Class); - *dotMethod = findVarInFrame(rho, R_dot_Method); - *dotGroup = findVarInFrame(rho, R_dot_Group); - *dotGenericCallEnv = findVarInFrame(rho, R_dot_GenericCallEnv); - *dotGenericDefEnv = findVarInFrame(rho, R_dot_GenericDefEnv); + *dotGeneric = R_findVarInFrame(rho, R_dot_Generic); + *dotClass = R_findVarInFrame(rho, R_dot_Class); + *dotMethod = R_findVarInFrame(rho, R_dot_Method); + *dotGroup = R_findVarInFrame(rho, R_dot_Group); + *dotGenericCallEnv = R_findVarInFrame(rho, R_dot_GenericCallEnv); + *dotGenericDefEnv = R_findVarInFrame(rho, R_dot_GenericDefEnv); } @@ -1231,7 +1231,7 @@ attribute_hidden SEXP R_findVar(SEXP symbol, SEXP rho) will also handle all frames if rho is a global frame other than R_GlobalEnv */ while (rho != R_GlobalEnv && rho != R_EmptyEnv) { - vl = findVarInFrame(rho, symbol); + vl = R_findVarInFrame(rho, symbol); if (vl != R_UnboundValue) return (vl); rho = ENCLOS(rho); } @@ -1241,7 +1241,7 @@ attribute_hidden SEXP R_findVar(SEXP symbol, SEXP rho) return R_UnboundValue; #else while (rho != R_EmptyEnv) { - vl = findVarInFrame(rho, symbol); + vl = R_findVarInFrame(rho, symbol); if (vl != R_UnboundValue) return (vl); rho = ENCLOS(rho); } @@ -1279,7 +1279,7 @@ static SEXP findVarLoc(SEXP symbol, SEXP rho) return R_NilValue; #else while (rho != R_EmptyEnv) { - vl = findVarInLocFrame(rho, symbol, NULL); + vl = R_findVarInLocFrame(rho, symbol, NULL); if (vl != R_NilValue) return vl; rho = ENCLOS(rho); } @@ -1310,7 +1310,7 @@ findVar1(SEXP symbol, SEXP rho, SEXPTYPE mode, int inherits) { SEXP vl; while (rho != R_EmptyEnv) { - vl = findVarInFrame(rho, symbol); + vl = R_findVarInFrame(rho, symbol); if (vl != R_UnboundValue) { if (mode == ANYSXP) return vl; if (TYPEOF(vl) == PROMSXP) { @@ -1429,7 +1429,7 @@ SEXP ddfind(int i, SEXP rho) if(i <= 0) error(_("indexing '...' with non-positive index %d"), i); /* first look for ... symbol */ - SEXP vl = findVar(R_DotsSymbol, rho); + SEXP vl = R_findVar(R_DotsSymbol, rho); if (vl != R_UnboundValue) { if (length_DOTS(vl) >= i) { vl = nthcdr(vl, i - 1); @@ -1467,7 +1467,7 @@ attribute_hidden SEXP do_dotsElt(SEXP call, SEXP op, SEXP args, SEXP env) attribute_hidden SEXP do_dotsLength(SEXP call, SEXP op, SEXP args, SEXP env) { checkArity(op, args); - SEXP vl = findVar(R_DotsSymbol, env); + SEXP vl = R_findVar(R_DotsSymbol, env); if (vl == R_UnboundValue) error(_("incorrect context: the current call has no '...' to look in")); // else @@ -1477,7 +1477,7 @@ attribute_hidden SEXP do_dotsLength(SEXP call, SEXP op, SEXP args, SEXP env) attribute_hidden SEXP do_dotsNames(SEXP call, SEXP op, SEXP args, SEXP env) { checkArity(op, args); - SEXP vl = findVar(R_DotsSymbol, env); + SEXP vl = R_findVar(R_DotsSymbol, env); PROTECT(vl); if (vl == R_UnboundValue) error(_("incorrect context: the current call has no '...' to look in")); @@ -1523,7 +1523,7 @@ SEXP dynamicfindVar(SEXP symbol, RCNTXT *cptr) SEXP vl; while (cptr != R_ToplevelContext) { if (cptr->callflag & CTXT_FUNCTION) { - vl = findVarInFrame(cptr->cloenv, symbol); + vl = R_findVarInFrame(cptr->cloenv, symbol); if (vl != R_UnboundValue) return vl; } cptr = cptr->nextcontext; @@ -1573,9 +1573,9 @@ SEXP findFun3(SEXP symbol, SEXP rho, SEXP call) vl = findGlobalVar(symbol); #endif else - vl = findVarInFrame(rho, symbol); + vl = R_findVarInFrame(rho, symbol); #else - vl = findVarInFrame(rho, symbol); + vl = R_findVarInFrame(rho, symbol); #endif if (vl != R_UnboundValue) { if (TYPEOF(vl) == PROMSXP) { @@ -2287,7 +2287,7 @@ SEXP R_getVarEx(SEXP sym, SEXP rho, Rboolean inherits, SEXP ifnotfound) if (TYPEOF(rho) != ENVSXP) error(_("second argument to '%s' must be an environment"), __func__); - SEXP val = inherits ? findVar(sym, rho) : findVarInFrame(rho, sym); + SEXP val = inherits ? R_findVar(sym, rho) : R_findVarInFrame(rho, sym); if (val == R_MissingArg) error(_("argument \"%s\" is missing, with no default"), EncodeChar(PRINTNAME(sym))); @@ -3740,10 +3740,10 @@ Rboolean R_IsNamespaceEnv(SEXP rho) if (rho == R_BaseNamespace) return TRUE; else if (TYPEOF(rho) == ENVSXP) { - SEXP info = findVarInFrame(rho, R_NamespaceSymbol); + SEXP info = R_findVarInFrame(rho, R_NamespaceSymbol); if (info != R_UnboundValue && TYPEOF(info) == ENVSXP) { PROTECT(info); - SEXP spec = findVarInFrame(info, install("spec")); + SEXP spec = R_findVarInFrame(info, install("spec")); UNPROTECT(1); if (spec != R_UnboundValue && TYPEOF(spec) == STRSXP && LENGTH(spec) > 0) @@ -3771,10 +3771,10 @@ SEXP R_NamespaceEnvSpec(SEXP rho) if (rho == R_BaseNamespace) return R_BaseNamespaceName; else if (TYPEOF(rho) == ENVSXP) { - SEXP info = findVarInFrame(rho, R_NamespaceSymbol); + SEXP info = R_findVarInFrame(rho, R_NamespaceSymbol); if (info != R_UnboundValue && TYPEOF(info) == ENVSXP) { PROTECT(info); - SEXP spec = findVarInFrame(info, install("spec")); + SEXP spec = R_findVarInFrame(info, install("spec")); UNPROTECT(1); if (spec != R_UnboundValue && TYPEOF(spec) == STRSXP && LENGTH(spec) > 0) @@ -3822,7 +3822,7 @@ attribute_hidden SEXP do_regNS(SEXP call, SEXP op, SEXP args, SEXP rho) checkArity(op, args); name = checkNSname(call, CAR(args)); val = CADR(args); - if (findVarInFrame(R_NamespaceRegistry, name) != R_UnboundValue) + if (R_findVarInFrame(R_NamespaceRegistry, name) != R_UnboundValue) errorcall(call, _("namespace already registered")); defineVar(name, val, R_NamespaceRegistry); return R_NilValue; @@ -3835,7 +3835,7 @@ attribute_hidden SEXP do_unregNS(SEXP call, SEXP op, SEXP args, SEXP rho) int hashcode; checkArity(op, args); name = checkNSname(call, CAR(args)); - if (findVarInFrame(R_NamespaceRegistry, name) == R_UnboundValue) + if (R_findVarInFrame(R_NamespaceRegistry, name) == R_UnboundValue) errorcall(call, _("namespace not registered")); if( !HASHASH(PRINTNAME(name))) hashcode = R_Newhashpjw(CHAR(PRINTNAME(name))); @@ -3853,7 +3853,7 @@ attribute_hidden SEXP do_getRegNS(SEXP call, SEXP op, SEXP args, SEXP rho) checkArity(op, args); name = checkNSname(call, PROTECT(coerceVector(CAR(args), SYMSXP))); UNPROTECT(1); - val = findVarInFrame(R_NamespaceRegistry, name); + val = R_findVarInFrame(R_NamespaceRegistry, name); switch(PRIMVAL(op)) { case 0: // get..() @@ -3877,7 +3877,7 @@ attribute_hidden SEXP do_getNSRegistry(SEXP call, SEXP op, SEXP args, SEXP rho) static SEXP getVarValInFrame(SEXP rho, SEXP sym, int unbound_ok) { - SEXP val = findVarInFrame(rho, sym); + SEXP val = R_findVarInFrame(rho, sym); if (! unbound_ok && val == R_UnboundValue) error(_("object '%s' not found"), EncodeChar(PRINTNAME(sym))); if (TYPEOF(val) == PROMSXP) { @@ -3936,7 +3936,7 @@ attribute_hidden SEXP R_getNSValue(SEXP call, SEXP ns, SEXP name, int exported) PROTECT(ns); else { SEXP pkg = checkNSname(call, ns); - ns = findVarInFrame(R_NamespaceRegistry, pkg); + ns = R_findVarInFrame(R_NamespaceRegistry, pkg); if (ns == R_UnboundValue) ns = callR1(R_loadNamespaceSymbol, pkg); PROTECT(ns); diff --git a/src/main/errors.c b/src/main/errors.c index bb7dc0b3b1d..091f63801e0 100644 --- a/src/main/errors.c +++ b/src/main/errors.c @@ -2370,7 +2370,7 @@ R_GetSrcFilename(SEXP srcref) SEXP srcfile = getAttrib(srcref, R_SrcfileSymbol); if (TYPEOF(srcfile) != ENVSXP) return ScalarString(mkChar("")); - srcfile = findVar(install("filename"), srcfile); + srcfile = R_findVar(install("filename"), srcfile); if (TYPEOF(srcfile) != STRSXP) return ScalarString(mkChar("")); return srcfile; diff --git a/src/main/eval.c b/src/main/eval.c index 1670cb7c323..d718b989b08 100644 --- a/src/main/eval.c +++ b/src/main/eval.c @@ -343,7 +343,7 @@ static void lineprof(profbuf* pb, SEXP srcref) const char *filename; if (!srcfile || TYPEOF(srcfile) != ENVSXP) return; - srcfile = findVar(install("filename"), srcfile); + srcfile = R_findVar(install("filename"), srcfile); if (TYPEOF(srcfile) != STRSXP || !length(srcfile)) return; filename = CHAR(STRING_ELT(srcfile, 0)); @@ -1172,7 +1172,7 @@ SEXP eval(SEXP e, SEXP rho) if( DDVAL(e) ) tmp = ddfindVar(e,rho); else - tmp = findVar(e, rho); + tmp = R_findVar(e, rho); if (tmp == R_UnboundValue) errorcall_cpy(getLexicalCall(rho), _("object '%s' not found"), @@ -1308,7 +1308,7 @@ void SrcrefPrompt(const char * prefix, SEXP srcref) if (TYPEOF(srcref) == VECSXP) srcref = VECTOR_ELT(srcref, 0); SEXP srcfile = getAttrib(srcref, R_SrcfileSymbol); if (TYPEOF(srcfile) == ENVSXP) { - SEXP filename = findVar(install("filename"), srcfile); + SEXP filename = R_findVar(install("filename"), srcfile); if (isString(filename) && length(filename)) { Rprintf(_("%s at %s#%d: "), prefix, CHAR(STRING_ELT(filename, 0)), @@ -2544,14 +2544,14 @@ SEXP R_execMethod(SEXP op, SEXP rho) /* copy the bindings of the special dispatch variables in the top frame of the generic call to the new frame */ - defineVar(R_dot_defined, findVarInFrame(rho, R_dot_defined), newrho); - defineVar(R_dot_Method, findVarInFrame(rho, R_dot_Method), newrho); - defineVar(R_dot_target, findVarInFrame(rho, R_dot_target), newrho); + defineVar(R_dot_defined, R_findVarInFrame(rho, R_dot_defined), newrho); + defineVar(R_dot_Method, R_findVarInFrame(rho, R_dot_Method), newrho); + defineVar(R_dot_target, R_findVarInFrame(rho, R_dot_target), newrho); /* copy the bindings for .Generic and .Methods. We know (I think) that they are in the second frame, so we could use that. */ - defineVar(R_dot_Generic, findVar(R_dot_Generic, rho), newrho); - defineVar(R_dot_Methods, findVar(R_dot_Methods, rho), newrho); + defineVar(R_dot_Generic, R_findVar(R_dot_Generic, rho), newrho); + defineVar(R_dot_Methods, R_findVar(R_dot_Methods, rho), newrho); /* Find the calling context. Should be R_GlobalContext unless profiling has inserted a CTXT_BUILTIN frame. */ @@ -2584,7 +2584,7 @@ static SEXP EnsureLocal(SEXP symbol, SEXP rho, R_varloc_t *ploc) { SEXP vl; - if ((vl = findVarInFrame(rho, symbol)) != R_UnboundValue) { + if ((vl = R_findVarInFrame(rho, symbol)) != R_UnboundValue) { vl = eval(symbol, rho); /* for promises */ if(MAYBE_SHARED(vl)) { /* Using R_shallow_duplicate_attr may defer duplicating @@ -3273,7 +3273,7 @@ attribute_hidden void R_initEvalSymbols(void) static R_INLINE SEXP lookupAssignFcnSymbol(SEXP fun) { - return findVarInFrame(R_ReplaceFunsTable, fun); + return R_findVarInFrame(R_ReplaceFunsTable, fun); } static void enterAssignFcnSymbol(SEXP fun, SEXP val) @@ -3634,7 +3634,7 @@ attribute_hidden SEXP evalList(SEXP el, SEXP rho, SEXP call, int n) * the list of resulting values into the return value. * Anything else bound to a ... symbol is an error */ - PROTECT(h = findVar(CAR(el), rho)); + PROTECT(h = R_findVar(CAR(el), rho)); if (TYPEOF(h) == DOTSXP || h == R_NilValue) { while (h != R_NilValue) { val = eval(CAR(h), rho); @@ -3721,7 +3721,7 @@ attribute_hidden SEXP evalListKeepMissing(SEXP el, SEXP rho) * Anything else bound to a ... symbol is an error */ if (CAR(el) == R_DotsSymbol) { - PROTECT(h = findVar(CAR(el), rho)); + PROTECT(h = R_findVar(CAR(el), rho)); if (TYPEOF(h) == DOTSXP || h == R_NilValue) { while (h != R_NilValue) { if (CAR(h) == R_MissingArg) @@ -3800,7 +3800,7 @@ attribute_hidden SEXP promiseArgs(SEXP el, SEXP rho) the callee */ if (CAR(el) == R_DotsSymbol) { - PROTECT(h = findVar(CAR(el), rho)); + PROTECT(h = R_findVar(CAR(el), rho)); if (TYPEOF(h) == DOTSXP || h == R_NilValue) { while (h != R_NilValue) { if (CAR(h) == R_MissingArg) @@ -4131,7 +4131,7 @@ int DispatchOrEval(SEXP call, SEXP op, const char *generic, SEXP args, arguments, R_NilValue is used. */ for (; args != R_NilValue; args = CDR(args)) { if (CAR(args) == R_DotsSymbol) { - SEXP h = findVar(R_DotsSymbol, rho); + SEXP h = R_findVar(R_DotsSymbol, rho); if (TYPEOF(h) == DOTSXP) { #ifdef DODO /**** any self-evaluating value should be OK; this @@ -5821,7 +5821,7 @@ static R_INLINE SEXP findVarEX(SEXP symbol, SEXP rho, Rboolean dd, return value; } else - return findVar(symbol, rho); + return R_findVar(symbol, rho); } #ifdef IMMEDIATE_PROMISE_VALUES @@ -8025,7 +8025,7 @@ static SEXP bcEval_loop(struct bcEval_locals *ploc) { SEXPTYPE ftype = CALL_FRAME_FTYPE(); if (ftype != SPECIALSXP) { - SEXP h = findVar(R_DotsSymbol, rho); + SEXP h = R_findVar(R_DotsSymbol, rho); if (TYPEOF(h) == DOTSXP || h == R_NilValue) { PROTECT(h); for (; h != R_NilValue; h = CDR(h)) { diff --git a/src/main/gevents.c b/src/main/gevents.c index a95b4a1e3bd..f9ba8ba198b 100644 --- a/src/main/gevents.c +++ b/src/main/gevents.c @@ -40,7 +40,7 @@ static const char * idleHandler = "onIdle"; static void checkHandler(const char * name, SEXP eventEnv) { - SEXP handler = findVar(install(name), eventEnv); + SEXP handler = R_findVar(install(name), eventEnv); if (TYPEOF(handler) == CLOSXP) warning(_("'%s' events not supported in this device"), name); } @@ -182,7 +182,7 @@ do_getGraphicsEvent(SEXP call, SEXP op, SEXP args, SEXP env) if ((gd = GEgetDevice(devNum)) && (dd = gd->dev)) { if (dd->eventEnv != R_NilValue) { if (dd->eventHelper) dd->eventHelper(dd, 2); - result = findVar(install("result"), dd->eventEnv); + result = R_findVar(install("result"), dd->eventEnv); if (result != R_NilValue && result != R_UnboundValue) { break; } @@ -217,7 +217,7 @@ void doMouseEvent(pDevDesc dd, R_MouseEvent event, dd->gettingEvent = FALSE; /* avoid recursive calls */ - PROTECT(handler = findVar(install(mouseHandlers[event]), dd->eventEnv)); + PROTECT(handler = R_findVar(install(mouseHandlers[event]), dd->eventEnv)); if (TYPEOF(handler) == PROMSXP) { handler = eval(handler, dd->eventEnv); UNPROTECT(1); /* handler */ @@ -263,7 +263,7 @@ void doKeybd(pDevDesc dd, R_KeyName rkey, dd->gettingEvent = FALSE; /* avoid recursive calls */ - PROTECT(handler = findVar(install(keybdHandler), dd->eventEnv)); + PROTECT(handler = R_findVar(install(keybdHandler), dd->eventEnv)); if (TYPEOF(handler) == PROMSXP) { handler = eval(handler, dd->eventEnv); UNPROTECT(1); /* handler */ @@ -297,7 +297,7 @@ void doIdle(pDevDesc dd) dd->gettingEvent = FALSE; /* avoid recursive calls */ - PROTECT(handler = findVar(install(idleHandler), dd->eventEnv)); + PROTECT(handler = R_findVar(install(idleHandler), dd->eventEnv)); if (TYPEOF(handler) == PROMSXP) { handler = eval(handler, dd->eventEnv); UNPROTECT(1); /* handler */ @@ -319,7 +319,7 @@ void doIdle(pDevDesc dd) } Rboolean doesIdle(pDevDesc dd) { - SEXP handler = findVar(install(idleHandler), dd->eventEnv); + SEXP handler = R_findVar(install(idleHandler), dd->eventEnv); return (handler != R_UnboundValue) && (handler != R_NilValue); } diff --git a/src/main/gram.c b/src/main/gram.c index 6ba862ca9d8..1437edad1ea 100644 --- a/src/main/gram.c +++ b/src/main/gram.c @@ -67,6 +67,7 @@ /* First part of user prologue. */ +#line 2 "gram.y" /* * R : A Computer Language for Statistical Data Analysis @@ -463,6 +464,7 @@ static int xxvalue(SEXP, int, YYLTYPE *); #define YYSTYPE SEXP +#line 468 "y.tab.c" # ifndef YY_CAST # ifdef __cplusplus @@ -2275,378 +2277,565 @@ yyparse (void) switch (yyn) { case 2: /* prog: END_OF_INPUT */ +#line 446 "gram.y" { Status = 0; YYACCEPT; } +#line 2283 "y.tab.c" break; case 3: /* prog: '\n' */ +#line 447 "gram.y" { Status = 2; yyresult = xxvalue(NULL,2,NULL); YYACCEPT; } +#line 2289 "y.tab.c" break; case 4: /* prog: expr_or_assign_or_help '\n' */ +#line 448 "gram.y" { Status = 3; yyresult = xxvalue(yyvsp[-1],3,&(yylsp[-1])); YYACCEPT; } +#line 2295 "y.tab.c" break; case 5: /* prog: expr_or_assign_or_help ';' */ +#line 449 "gram.y" { Status = 4; yyresult = xxvalue(yyvsp[-1],4,&(yylsp[-1])); YYACCEPT; } +#line 2301 "y.tab.c" break; case 6: /* prog: error */ +#line 450 "gram.y" { Status = 1; YYABORT; } +#line 2307 "y.tab.c" break; case 7: /* expr_or_assign_or_help: expr */ +#line 453 "gram.y" { yyval = yyvsp[0]; } +#line 2313 "y.tab.c" break; case 8: /* expr_or_assign_or_help: expr_or_assign_or_help EQ_ASSIGN expr_or_assign_or_help */ +#line 454 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2319 "y.tab.c" break; case 9: /* expr_or_assign_or_help: expr_or_assign_or_help '?' expr_or_assign_or_help */ +#line 455 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2325 "y.tab.c" break; case 10: /* expr_or_help: expr */ +#line 458 "gram.y" { yyval = yyvsp[0]; } +#line 2331 "y.tab.c" break; case 11: /* expr_or_help: expr_or_help '?' expr_or_help */ +#line 459 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2337 "y.tab.c" break; case 12: /* expr: NUM_CONST */ +#line 462 "gram.y" { yyval = yyvsp[0]; setId((yyloc)); } +#line 2343 "y.tab.c" break; case 13: /* expr: STR_CONST */ +#line 463 "gram.y" { yyval = yyvsp[0]; setId((yyloc)); } +#line 2349 "y.tab.c" break; case 14: /* expr: NULL_CONST */ +#line 464 "gram.y" { yyval = yyvsp[0]; setId((yyloc)); } +#line 2355 "y.tab.c" break; case 15: /* expr: PLACEHOLDER */ +#line 465 "gram.y" { yyval = yyvsp[0]; setId((yyloc)); } +#line 2361 "y.tab.c" break; case 16: /* expr: SYMBOL */ +#line 466 "gram.y" { yyval = yyvsp[0]; setId((yyloc)); } +#line 2367 "y.tab.c" break; case 17: /* expr: '{' exprlist '}' */ +#line 468 "gram.y" { yyval = xxexprlist(yyvsp[-2],&(yylsp[-2]),yyvsp[-1]); setId((yyloc)); } +#line 2373 "y.tab.c" break; case 18: /* expr: '(' expr_or_assign_or_help ')' */ +#line 469 "gram.y" { yyval = xxparen(yyvsp[-2],yyvsp[-1]); setId((yyloc)); } +#line 2379 "y.tab.c" break; case 19: /* expr: '-' expr */ +#line 471 "gram.y" { yyval = xxunary(yyvsp[-1],yyvsp[0]); setId((yyloc)); } +#line 2385 "y.tab.c" break; case 20: /* expr: '+' expr */ +#line 472 "gram.y" { yyval = xxunary(yyvsp[-1],yyvsp[0]); setId((yyloc)); } +#line 2391 "y.tab.c" break; case 21: /* expr: '!' expr */ +#line 473 "gram.y" { yyval = xxunary(yyvsp[-1],yyvsp[0]); setId((yyloc)); } +#line 2397 "y.tab.c" break; case 22: /* expr: '~' expr */ +#line 474 "gram.y" { yyval = xxunary(yyvsp[-1],yyvsp[0]); setId((yyloc)); } +#line 2403 "y.tab.c" break; case 23: /* expr: '?' expr_or_assign_or_help */ +#line 475 "gram.y" { yyval = xxunary(yyvsp[-1],yyvsp[0]); setId((yyloc)); } +#line 2409 "y.tab.c" break; case 24: /* expr: expr ':' expr */ +#line 477 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2415 "y.tab.c" break; case 25: /* expr: expr '+' expr */ +#line 478 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2421 "y.tab.c" break; case 26: /* expr: expr '-' expr */ +#line 479 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2427 "y.tab.c" break; case 27: /* expr: expr '*' expr */ +#line 480 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2433 "y.tab.c" break; case 28: /* expr: expr '/' expr */ +#line 481 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2439 "y.tab.c" break; case 29: /* expr: expr '^' expr */ +#line 482 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2445 "y.tab.c" break; case 30: /* expr: expr SPECIAL expr */ +#line 483 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2451 "y.tab.c" break; case 31: /* expr: expr '~' expr */ +#line 484 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2457 "y.tab.c" break; case 32: /* expr: expr LT expr */ +#line 485 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2463 "y.tab.c" break; case 33: /* expr: expr LE expr */ +#line 486 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2469 "y.tab.c" break; case 34: /* expr: expr EQ expr */ +#line 487 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2475 "y.tab.c" break; case 35: /* expr: expr NE expr */ +#line 488 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2481 "y.tab.c" break; case 36: /* expr: expr GE expr */ +#line 489 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2487 "y.tab.c" break; case 37: /* expr: expr GT expr */ +#line 490 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2493 "y.tab.c" break; case 38: /* expr: expr AND expr */ +#line 491 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2499 "y.tab.c" break; case 39: /* expr: expr OR expr */ +#line 492 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2505 "y.tab.c" break; case 40: /* expr: expr AND2 expr */ +#line 493 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2511 "y.tab.c" break; case 41: /* expr: expr OR2 expr */ +#line 494 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2517 "y.tab.c" break; case 42: /* expr: expr PIPE expr */ +#line 495 "gram.y" { yyval = xxpipe(yyvsp[-2],yyvsp[0],&(yylsp[0])); setId((yyloc)); } +#line 2523 "y.tab.c" break; case 43: /* expr: expr PIPEBIND expr */ +#line 496 "gram.y" { yyval = xxpipebind(yyvsp[-1],yyvsp[-2],yyvsp[0],&(yylsp[-1])); setId((yyloc)); } +#line 2529 "y.tab.c" break; case 44: /* expr: expr LEFT_ASSIGN expr */ +#line 497 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2535 "y.tab.c" break; case 45: /* expr: expr RIGHT_ASSIGN expr */ +#line 498 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[0],yyvsp[-2]); setId((yyloc)); } +#line 2541 "y.tab.c" break; case 46: /* expr: FUNCTION '(' formlist ')' cr expr_or_assign_or_help */ +#line 500 "gram.y" { yyval = xxdefun(yyvsp[-5],yyvsp[-3],yyvsp[0],&(yyloc)); setId((yyloc)); } +#line 2547 "y.tab.c" break; case 47: /* expr: '\\' '(' formlist ')' cr expr_or_assign_or_help */ +#line 501 "gram.y" { yyval = xxdefun(R_FunctionSymbol,yyvsp[-3],yyvsp[0],&(yyloc)); setId((yyloc)); } +#line 2553 "y.tab.c" break; case 48: /* expr: expr '(' sublist ')' */ +#line 502 "gram.y" { yyval = xxfuncall(yyvsp[-3],yyvsp[-1]); setId((yyloc)); modif_token( &(yylsp[-3]), SYMBOL_FUNCTION_CALL ) ; } +#line 2559 "y.tab.c" break; case 49: /* expr: IF ifcond expr_or_assign_or_help */ +#line 503 "gram.y" { yyval = xxif(yyvsp[-2],yyvsp[-1],yyvsp[0]); setId((yyloc)); } +#line 2565 "y.tab.c" break; case 50: /* expr: IF ifcond expr_or_assign_or_help ELSE expr_or_assign_or_help */ +#line 504 "gram.y" { yyval = xxifelse(yyvsp[-4],yyvsp[-3],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2571 "y.tab.c" break; case 51: /* expr: FOR forcond expr_or_assign_or_help */ +#line 505 "gram.y" { yyval = xxfor(yyvsp[-2],yyvsp[-1],yyvsp[0]); setId((yyloc)); } +#line 2577 "y.tab.c" break; case 52: /* expr: WHILE cond expr_or_assign_or_help */ +#line 506 "gram.y" { yyval = xxwhile(yyvsp[-2],yyvsp[-1],yyvsp[0]); setId((yyloc)); } +#line 2583 "y.tab.c" break; case 53: /* expr: REPEAT expr_or_assign_or_help */ +#line 507 "gram.y" { yyval = xxrepeat(yyvsp[-1],yyvsp[0]); setId((yyloc)); } +#line 2589 "y.tab.c" break; case 54: /* expr: expr LBB sublist ']' ']' */ +#line 508 "gram.y" { yyval = xxsubscript(yyvsp[-4],yyvsp[-3],yyvsp[-2]); setId((yyloc)); } +#line 2595 "y.tab.c" break; case 55: /* expr: expr '[' sublist ']' */ +#line 509 "gram.y" { yyval = xxsubscript(yyvsp[-3],yyvsp[-2],yyvsp[-1]); setId((yyloc)); } +#line 2601 "y.tab.c" break; case 56: /* expr: SYMBOL NS_GET SYMBOL */ +#line 510 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); modif_token( &(yylsp[-2]), SYMBOL_PACKAGE ) ; } +#line 2607 "y.tab.c" break; case 57: /* expr: SYMBOL NS_GET STR_CONST */ +#line 511 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); modif_token( &(yylsp[-2]), SYMBOL_PACKAGE ) ; } +#line 2613 "y.tab.c" break; case 58: /* expr: STR_CONST NS_GET SYMBOL */ +#line 512 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2619 "y.tab.c" break; case 59: /* expr: STR_CONST NS_GET STR_CONST */ +#line 513 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2625 "y.tab.c" break; case 60: /* expr: SYMBOL NS_GET_INT SYMBOL */ +#line 514 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); modif_token( &(yylsp[-2]), SYMBOL_PACKAGE ) ;} +#line 2631 "y.tab.c" break; case 61: /* expr: SYMBOL NS_GET_INT STR_CONST */ +#line 515 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); modif_token( &(yylsp[-2]), SYMBOL_PACKAGE ) ;} +#line 2637 "y.tab.c" break; case 62: /* expr: STR_CONST NS_GET_INT SYMBOL */ +#line 516 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2643 "y.tab.c" break; case 63: /* expr: STR_CONST NS_GET_INT STR_CONST */ +#line 517 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2649 "y.tab.c" break; case 64: /* expr: expr '$' SYMBOL */ +#line 518 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2655 "y.tab.c" break; case 65: /* expr: expr '$' STR_CONST */ +#line 519 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2661 "y.tab.c" break; case 66: /* expr: expr '@' SYMBOL */ +#line 520 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); modif_token( &(yylsp[0]), SLOT ) ; } +#line 2667 "y.tab.c" break; case 67: /* expr: expr '@' STR_CONST */ +#line 521 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } +#line 2673 "y.tab.c" break; case 68: /* expr: NEXT */ +#line 522 "gram.y" { yyval = xxnxtbrk(yyvsp[0]); setId((yyloc)); } +#line 2679 "y.tab.c" break; case 69: /* expr: BREAK */ +#line 523 "gram.y" { yyval = xxnxtbrk(yyvsp[0]); setId((yyloc)); } +#line 2685 "y.tab.c" break; case 70: /* cond: '(' expr_or_help ')' */ +#line 527 "gram.y" { yyval = xxcond(yyvsp[-1]); } +#line 2691 "y.tab.c" break; case 71: /* ifcond: '(' expr_or_help ')' */ +#line 530 "gram.y" { yyval = xxifcond(yyvsp[-1]); } +#line 2697 "y.tab.c" break; case 72: /* forcond: '(' SYMBOL IN expr_or_help ')' */ +#line 533 "gram.y" { yyval = xxforcond(yyvsp[-3],yyvsp[-1]); setId((yyloc)); } +#line 2703 "y.tab.c" break; case 73: /* exprlist: %empty */ +#line 537 "gram.y" { yyval = xxexprlist0(); setId((yyloc)); } +#line 2709 "y.tab.c" break; case 74: /* exprlist: expr_or_assign_or_help */ +#line 538 "gram.y" { yyval = xxexprlist1(yyvsp[0], &(yylsp[0])); } +#line 2715 "y.tab.c" break; case 75: /* exprlist: exprlist ';' expr_or_assign_or_help */ +#line 539 "gram.y" { yyval = xxexprlist2(yyvsp[-2], yyvsp[0], &(yylsp[0])); } +#line 2721 "y.tab.c" break; case 76: /* exprlist: exprlist ';' */ +#line 540 "gram.y" { yyval = yyvsp[-1]; setId((yyloc)); } +#line 2727 "y.tab.c" break; case 77: /* exprlist: exprlist '\n' expr_or_assign_or_help */ +#line 541 "gram.y" { yyval = xxexprlist2(yyvsp[-2], yyvsp[0], &(yylsp[0])); } +#line 2733 "y.tab.c" break; case 78: /* exprlist: exprlist '\n' */ +#line 542 "gram.y" { yyval = yyvsp[-1];} +#line 2739 "y.tab.c" break; case 79: /* sublist: sub */ +#line 545 "gram.y" { yyval = xxsublist1(yyvsp[0]); } +#line 2745 "y.tab.c" break; case 80: /* sublist: sublist cr ',' sub */ +#line 546 "gram.y" { yyval = xxsublist2(yyvsp[-3],yyvsp[0]); } +#line 2751 "y.tab.c" break; case 81: /* sub: %empty */ +#line 549 "gram.y" { yyval = xxsub0(); } +#line 2757 "y.tab.c" break; case 82: /* sub: expr_or_help */ +#line 550 "gram.y" { yyval = xxsub1(yyvsp[0], &(yylsp[0])); } +#line 2763 "y.tab.c" break; case 83: /* sub: SYMBOL EQ_ASSIGN */ +#line 551 "gram.y" { yyval = xxsymsub0(yyvsp[-1], &(yylsp[-1])); modif_token( &(yylsp[0]), EQ_SUB ) ; modif_token( &(yylsp[-1]), SYMBOL_SUB ) ; } +#line 2769 "y.tab.c" break; case 84: /* sub: SYMBOL EQ_ASSIGN expr_or_help */ +#line 552 "gram.y" { yyval = xxsymsub1(yyvsp[-2],yyvsp[0], &(yylsp[-2])); modif_token( &(yylsp[-1]), EQ_SUB ) ; modif_token( &(yylsp[-2]), SYMBOL_SUB ) ; } +#line 2775 "y.tab.c" break; case 85: /* sub: STR_CONST EQ_ASSIGN */ +#line 553 "gram.y" { yyval = xxsymsub0(yyvsp[-1], &(yylsp[-1])); modif_token( &(yylsp[0]), EQ_SUB ) ; } +#line 2781 "y.tab.c" break; case 86: /* sub: STR_CONST EQ_ASSIGN expr_or_help */ +#line 554 "gram.y" { yyval = xxsymsub1(yyvsp[-2],yyvsp[0], &(yylsp[-2])); modif_token( &(yylsp[-1]), EQ_SUB ) ; } +#line 2787 "y.tab.c" break; case 87: /* sub: NULL_CONST EQ_ASSIGN */ +#line 555 "gram.y" { yyval = xxnullsub0(&(yylsp[-1])); modif_token( &(yylsp[0]), EQ_SUB ) ; } +#line 2793 "y.tab.c" break; case 88: /* sub: NULL_CONST EQ_ASSIGN expr_or_help */ +#line 556 "gram.y" { yyval = xxnullsub1(yyvsp[0], &(yylsp[-2])); modif_token( &(yylsp[-1]), EQ_SUB ) ; } +#line 2799 "y.tab.c" break; case 89: /* formlist: %empty */ +#line 559 "gram.y" { yyval = xxnullformal(); } +#line 2805 "y.tab.c" break; case 90: /* formlist: SYMBOL */ +#line 560 "gram.y" { yyval = xxfirstformal0(yyvsp[0]); modif_token( &(yylsp[0]), SYMBOL_FORMALS ) ; } +#line 2811 "y.tab.c" break; case 91: /* formlist: SYMBOL EQ_ASSIGN expr_or_help */ +#line 561 "gram.y" { yyval = xxfirstformal1(yyvsp[-2],yyvsp[0]); modif_token( &(yylsp[-2]), SYMBOL_FORMALS ) ; modif_token( &(yylsp[-1]), EQ_FORMALS ) ; } +#line 2817 "y.tab.c" break; case 92: /* formlist: formlist ',' SYMBOL */ +#line 562 "gram.y" { yyval = xxaddformal0(yyvsp[-2],yyvsp[0], &(yylsp[0])); modif_token( &(yylsp[0]), SYMBOL_FORMALS ) ; } +#line 2823 "y.tab.c" break; case 93: /* formlist: formlist ',' SYMBOL EQ_ASSIGN expr_or_help */ +#line 564 "gram.y" { yyval = xxaddformal1(yyvsp[-4],yyvsp[-2],yyvsp[0],&(yylsp[-2])); modif_token( &(yylsp[-2]), SYMBOL_FORMALS ) ; modif_token( &(yylsp[-1]), EQ_FORMALS ) ;} +#line 2829 "y.tab.c" break; case 94: /* cr: %empty */ +#line 567 "gram.y" { EatLines = 1; } +#line 2835 "y.tab.c" break; +#line 2839 "y.tab.c" default: break; } @@ -2875,6 +3064,7 @@ yyparse (void) return yyresult; } +#line 569 "gram.y" @@ -5753,7 +5943,7 @@ static void setParseFilename(SEXP newname) { SEXP class; if (isEnvironment(PS_SRCFILE)) { - SEXP oldname = findVar(install("filename"), PS_SRCFILE); + SEXP oldname = R_findVar(install("filename"), PS_SRCFILE); if (isString(oldname) && length(oldname) > 0 && strcmp(CHAR(STRING_ELT(oldname, 0)), CHAR(STRING_ELT(newname, 0))) == 0) return; @@ -6728,7 +6918,7 @@ static const char* getFilename(void) { SEXP srcfile = PS_SRCFILE; if (!srcfile || TYPEOF(srcfile) != ENVSXP) return ""; - srcfile = findVar(install("filename"), srcfile); + srcfile = R_findVar(install("filename"), srcfile); if (TYPEOF(srcfile) != STRSXP || !strlen(CHAR(STRING_ELT(srcfile, 0)))) return ""; else diff --git a/src/main/gram.y b/src/main/gram.y index 83d8451ab10..a281ddd7587 100644 --- a/src/main/gram.y +++ b/src/main/gram.y @@ -3444,7 +3444,7 @@ static void setParseFilename(SEXP newname) { SEXP class; if (isEnvironment(PS_SRCFILE)) { - SEXP oldname = findVar(install("filename"), PS_SRCFILE); + SEXP oldname = R_findVar(install("filename"), PS_SRCFILE); if (isString(oldname) && length(oldname) > 0 && strcmp(CHAR(STRING_ELT(oldname, 0)), CHAR(STRING_ELT(newname, 0))) == 0) return; @@ -4419,7 +4419,7 @@ static const char* getFilename(void) { SEXP srcfile = PS_SRCFILE; if (!srcfile || TYPEOF(srcfile) != ENVSXP) return ""; - srcfile = findVar(install("filename"), srcfile); + srcfile = R_findVar(install("filename"), srcfile); if (TYPEOF(srcfile) != STRSXP || !strlen(CHAR(STRING_ELT(srcfile, 0)))) return ""; else diff --git a/src/main/main.c b/src/main/main.c index 7c91dca6719..77e614f2f39 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -1076,7 +1076,7 @@ void setup_Rmainloop(void) if (!doneit) { doneit = 1; PROTECT(cmd = install(".OptRequireMethods")); - R_CurrentExpr = findVar(cmd, R_GlobalEnv); + R_CurrentExpr = R_findVar(cmd, R_GlobalEnv); if (R_CurrentExpr != R_UnboundValue && TYPEOF(R_CurrentExpr) == CLOSXP) { PROTECT(R_CurrentExpr = lang1(cmd)); @@ -1143,7 +1143,7 @@ void setup_Rmainloop(void) if (!doneit) { doneit = 1; PROTECT(cmd = install(".First")); - R_CurrentExpr = findVar(cmd, R_GlobalEnv); + R_CurrentExpr = R_findVar(cmd, R_GlobalEnv); if (R_CurrentExpr != R_UnboundValue && TYPEOF(R_CurrentExpr) == CLOSXP) { PROTECT(R_CurrentExpr = lang1(cmd)); @@ -1162,7 +1162,7 @@ void setup_Rmainloop(void) if (!doneit) { doneit = 1; PROTECT(cmd = install(".First.sys")); - R_CurrentExpr = findVar(cmd, baseNSenv); + R_CurrentExpr = R_findVar(cmd, baseNSenv); if (R_CurrentExpr != R_UnboundValue && TYPEOF(R_CurrentExpr) == CLOSXP) { PROTECT(R_CurrentExpr = lang1(cmd)); @@ -1544,7 +1544,7 @@ void R_dot_Last(void) R_GlobalContext = R_ToplevelContext = R_SessionContext = &R_Toplevel; PROTECT(cmd = install(".Last")); - R_CurrentExpr = findVar(cmd, R_GlobalEnv); + R_CurrentExpr = R_findVar(cmd, R_GlobalEnv); if (R_CurrentExpr != R_UnboundValue && TYPEOF(R_CurrentExpr) == CLOSXP) { PROTECT(R_CurrentExpr = lang1(cmd)); R_CurrentExpr = eval(R_CurrentExpr, R_GlobalEnv); @@ -1552,7 +1552,7 @@ void R_dot_Last(void) } UNPROTECT(1); PROTECT(cmd = install(".Last.sys")); - R_CurrentExpr = findVar(cmd, R_BaseNamespace); + R_CurrentExpr = R_findVar(cmd, R_BaseNamespace); if (R_CurrentExpr != R_UnboundValue && TYPEOF(R_CurrentExpr) == CLOSXP) { PROTECT(R_CurrentExpr = lang1(cmd)); R_CurrentExpr = eval(R_CurrentExpr, R_GlobalEnv); diff --git a/src/main/match.c b/src/main/match.c index 54a84cc4f0d..e5c9a0a0d0b 100644 --- a/src/main/match.c +++ b/src/main/match.c @@ -424,7 +424,7 @@ static R_INLINE void patchArgument(SEXP suppliedSlot, SEXP name, fstype_t *farg, SEXP cloenv) { SEXP value = CAR(suppliedSlot); if (value == R_MissingArg) { - value = findVarInFrame(cloenv, name); + value = R_findVarInFrame(cloenv, name); if (value == R_MissingArg) { if (farg) *farg = FS_MATCHED_MISSING; return; diff --git a/src/main/objects.c b/src/main/objects.c index 035520cea08..9569c6ea7f2 100644 --- a/src/main/objects.c +++ b/src/main/objects.c @@ -171,7 +171,7 @@ static SEXP findFunInEnvRange(SEXP symbol, SEXP rho, SEXP target) { SEXP vl; while(rho != R_EmptyEnv) { - vl = findVarInFrame(rho, symbol); + vl = R_findVarInFrame(rho, symbol); if (vl != R_UnboundValue) { if (TYPEOF(vl) == PROMSXP) { PROTECT(vl); @@ -195,7 +195,7 @@ static SEXP findFunWithBaseEnvAfterGlobalEnv(SEXP symbol, SEXP rho) { SEXP vl; while(rho != R_EmptyEnv) { - vl = findVarInFrame(rho, symbol); + vl = R_findVarInFrame(rho, symbol); if (vl != R_UnboundValue) { if (TYPEOF(vl) == PROMSXP) { PROTECT(vl); @@ -264,7 +264,7 @@ SEXP R_LookupMethod(SEXP method, SEXP rho, SEXP callrho, SEXP defrho) /* We assume here that no one registered a non-function */ if (!s_S3MethodsTable) s_S3MethodsTable = install(".__S3MethodsTable__."); - SEXP table = findVarInFrame(defrho, s_S3MethodsTable); + SEXP table = R_findVarInFrame(defrho, s_S3MethodsTable); if (TYPEOF(table) == PROMSXP) { PROTECT(table); table = eval(table, R_BaseEnv); @@ -272,7 +272,7 @@ SEXP R_LookupMethod(SEXP method, SEXP rho, SEXP callrho, SEXP defrho) } if (TYPEOF(table) == ENVSXP) { PROTECT(table); - REPROTECT(val = findVarInFrame(table, method), validx); + REPROTECT(val = R_findVarInFrame(table, method), validx); UNPROTECT(1); /* table */ if (TYPEOF(val) == PROMSXP) REPROTECT(val = eval(val, rho), validx); @@ -307,8 +307,8 @@ static int match_to_obj(SEXP arg, SEXP obj) { attribute_hidden int isBasicClass(const char *ss) { static SEXP s_S3table = NULL; if(!s_S3table) { - s_S3table = findVarInFrame(R_MethodsNamespace, - install(".S3MethodsClasses")); + s_S3table = R_findVarInFrame(R_MethodsNamespace, + install(".S3MethodsClasses")); if(s_S3table == R_UnboundValue) error(_("no '.S3MethodsClass' table, cannot use S4 objects with S3 methods ('methods' package not attached?)")); if (TYPEOF(s_S3table) == PROMSXP) /* findVar... ignores lazy data */ @@ -770,7 +770,7 @@ attribute_hidden SEXP do_nextmethod(SEXP call, SEXP op, SEXP args, SEXP env) s = CADDR(args); /* this is ... and we need to see if it's bound */ if (s == R_DotsSymbol) { - t = findVarInFrame(env, s); + t = R_findVarInFrame(env, s); if (t != R_NilValue && t != R_MissingArg) { SET_TYPEOF(t, LISTSXP); /* a safe mutation */ s = matchmethargs(matchedarg, t); @@ -893,7 +893,7 @@ attribute_hidden SEXP do_nextmethod(SEXP call, SEXP op, SEXP args, SEXP env) */ if (!isFunction(nextfun)) { t = install(sg); - nextfun = findVar(t, env); + nextfun = R_findVar(t, env); if (TYPEOF(nextfun) == PROMSXP) { PROTECT(nextfun); nextfun = eval(nextfun, env); @@ -1281,11 +1281,11 @@ static SEXP dispatchNonGeneric(SEXP name, SEXP env, SEXP fdef) symbol = installTrChar(asChar(name)); for(rho = ENCLOS(env); rho != R_EmptyEnv; rho = ENCLOS(rho)) { - fun = findVarInFrame(rho, symbol); + fun = R_findVarInFrame(rho, symbol); if(fun == R_UnboundValue) continue; switch(TYPEOF(fun)) { case CLOSXP: - value = findVarInFrame(CLOENV(fun), R_dot_Generic); + value = R_findVarInFrame(CLOENV(fun), R_dot_Generic); if(value == R_UnboundValue) break; case BUILTINSXP: case SPECIALSXP: default: diff --git a/src/main/print.c b/src/main/print.c index 74819ca98d8..f771e6b3e6f 100644 --- a/src/main/print.c +++ b/src/main/print.c @@ -341,7 +341,7 @@ static void PrintObjectS4(SEXP s, R_PrintData *data) if (methodsNS == R_UnboundValue) error("missing methods namespace: this should not happen"); - SEXP fun = findVarInFrame(methodsNS, install("show")); + SEXP fun = R_findVarInFrame(methodsNS, install("show")); if (TYPEOF(fun) == PROMSXP) { PROTECT(fun); fun = eval(fun, R_BaseEnv); @@ -627,7 +627,7 @@ static void PrintGenericVector(SEXP s, R_PrintData *data) const char *ss = translateChar(STRING_ELT(klass, 0)); int res = Rsnprintf_mbcs(str, 200, ".__C__%s", ss); if(res > 0 && res < 200 && - findVar(install(str), data->env) != R_UnboundValue) + R_findVar(install(str), data->env) != R_UnboundValue) className = ss; } } @@ -788,18 +788,18 @@ static void PrintSpecial(SEXP s, R_PrintData *data) char *nm = PRIMNAME(s); SEXP env, s2; PROTECT_INDEX xp; - PROTECT_WITH_INDEX(env = findVarInFrame(R_BaseEnv, - install(".ArgsEnv")), + PROTECT_WITH_INDEX(env = R_findVarInFrame(R_BaseEnv, + install(".ArgsEnv")), &xp); if (TYPEOF(env) == PROMSXP) REPROTECT(env = eval(env, R_BaseEnv), xp); - s2 = findVarInFrame(env, install(nm)); + s2 = R_findVarInFrame(env, install(nm)); if(s2 == R_UnboundValue) { - REPROTECT(env = findVarInFrame(R_BaseEnv, - install(".GenericArgsEnv")), + REPROTECT(env = R_findVarInFrame(R_BaseEnv, + install(".GenericArgsEnv")), xp); if (TYPEOF(env) == PROMSXP) REPROTECT(env = eval(env, R_BaseEnv), xp); - s2 = findVarInFrame(env, install(nm)); + s2 = R_findVarInFrame(env, install(nm)); } if(s2 != R_UnboundValue) { SEXP t; diff --git a/src/main/saveload.c b/src/main/saveload.c index 8ec98151c84..a2cd26212a7 100644 --- a/src/main/saveload.c +++ b/src/main/saveload.c @@ -2077,7 +2077,7 @@ attribute_hidden SEXP do_save(SEXP call, SEXP op, SEXP args, SEXP env) t = s; for (j = 0; j < len; j++, t = CDR(t)) { SET_TAG(t, installTrChar(STRING_ELT(CAR(args), j))); - tmp = findVar(TAG(t), source); + tmp = R_findVar(TAG(t), source); if (tmp == R_UnboundValue) error(_("object '%s' not found"), EncodeChar(PRINTNAME(TAG(t)))); if(ep && TYPEOF(tmp) == PROMSXP) { @@ -2255,7 +2255,7 @@ int attribute_hidden R_XDRDecodeInteger(void *buf) void R_SaveGlobalEnvToFile(const char *name) { SEXP sym = install("sys.save.image"); - if (findVar(sym, R_GlobalEnv) == R_UnboundValue) { /* not a perfect test */ + if (R_findVar(sym, R_GlobalEnv) == R_UnboundValue) {/* not a perfect test */ FILE *fp = R_fopen(name, "wb"); /* binary file */ if (!fp) { error(_("cannot save data -- unable to open '%s': %s"), @@ -2276,7 +2276,7 @@ void R_SaveGlobalEnvToFile(const char *name) void R_RestoreGlobalEnvFromFile(const char *name, Rboolean quiet) { SEXP sym = install("sys.load.image"); - if (findVar(sym, R_GlobalEnv) == R_UnboundValue) { /* not a perfect test */ + if (R_findVar(sym, R_GlobalEnv) == R_UnboundValue) {/* not a perfect test */ FILE *fp = R_fopen(name, "rb"); /* binary file */ if(fp != NULL) { R_LoadSavedData(fp, R_GlobalEnv); @@ -2411,8 +2411,8 @@ attribute_hidden SEXP do_saveToConn(SEXP call, SEXP op, SEXP args, SEXP env) t = s; for (j = 0; j < len; j++, t = CDR(t)) { SET_TAG(t, installTrChar(STRING_ELT(list, j))); - SETCAR(t, findVar(TAG(t), source)); - tmp = findVar(TAG(t), source); + SETCAR(t, R_findVar(TAG(t), source)); + tmp = R_findVar(TAG(t), source); if (tmp == R_UnboundValue) error(_("object '%s' not found"), EncodeChar(PRINTNAME(TAG(t)))); if(ep && TYPEOF(tmp) == PROMSXP) { diff --git a/src/main/serialize.c b/src/main/serialize.c index ea0205d4827..a56e1d0b68f 100644 --- a/src/main/serialize.c +++ b/src/main/serialize.c @@ -3225,7 +3225,7 @@ static SEXP R_getVarsFromFrame(SEXP vars, SEXP env, SEXP forcesxp) for (i = 0; i < len; i++) { sym = installTrChar(STRING_ELT(vars, i)); - tmp = findVarInFrame(env, sym); + tmp = R_findVarInFrame(env, sym); if (tmp == R_UnboundValue) { /* PrintValue(env); PrintValue(R_GetTraceback(0)); */ /* DJM debugging */ diff --git a/src/main/source.c b/src/main/source.c index 11e7ba10db5..157fb56cf49 100644 --- a/src/main/source.c +++ b/src/main/source.c @@ -86,7 +86,8 @@ static void getParseFilename(char* buffer, size_t buflen) if (R_ParseErrorFile) { if (isEnvironment(R_ParseErrorFile)) { SEXP filename; - PROTECT(filename = findVar(install("filename"), R_ParseErrorFile)); + PROTECT(filename = R_findVar(install("filename"), + R_ParseErrorFile)); if (isString(filename) && length(filename)) { strncpy(buffer, CHAR(STRING_ELT(filename, 0)), buflen - 1); buffer[buflen - 1] = '\0'; diff --git a/src/main/subset.c b/src/main/subset.c index dbef02b252b..96521f7dec6 100644 --- a/src/main/subset.c +++ b/src/main/subset.c @@ -1005,7 +1005,7 @@ attribute_hidden SEXP do_subset2_dflt(SEXP call, SEXP op, SEXP args, SEXP rho) if( TYPEOF(x) == ENVSXP ) { if( nsubs != 1 || !isString(CAR(subs)) || length(CAR(subs)) != 1 ) errorcall(call, _("wrong arguments for subsetting an environment")); - ans = findVarInFrame(x, installTrChar(STRING_ELT(CAR(subs), 0))); + ans = R_findVarInFrame(x, installTrChar(STRING_ELT(CAR(subs), 0))); if( TYPEOF(ans) == PROMSXP ) { PROTECT(ans); ans = eval(ans, R_GlobalEnv); @@ -1398,7 +1398,7 @@ attribute_hidden SEXP R_subset3_dflt(SEXP x, SEXP input, SEXP call) return R_NilValue; } else if( isEnvironment(x) ){ - y = findVarInFrame(x, installTrChar(input)); + y = R_findVarInFrame(x, installTrChar(input)); if( TYPEOF(y) == PROMSXP ) { PROTECT(y); y = eval(y, R_GlobalEnv); diff --git a/src/main/unique.c b/src/main/unique.c index b53a536b920..0ffff41000b 100644 --- a/src/main/unique.c +++ b/src/main/unique.c @@ -1805,7 +1805,7 @@ static SEXP subDots(SEXP rho) SEXP rval, dots, a, b, t; int len,i; - dots = findVar(R_DotsSymbol, rho); + dots = R_findVar(R_DotsSymbol, rho); if (dots == R_UnboundValue) error(_("... used in a situation where it does not exist")); diff --git a/src/unix/sys-std.c b/src/unix/sys-std.c index 158a8025cfb..41726969c44 100644 --- a/src/unix/sys-std.c +++ b/src/unix/sys-std.c @@ -776,7 +776,7 @@ static void initialize_rlcompletion(void) return; } /* First check if namespace is loaded */ - if(findVarInFrame(R_NamespaceRegistry, install("utils")) + if(R_findVarInFrame(R_NamespaceRegistry, install("utils")) != R_UnboundValue) rcompgen_active = 1; else { /* Then try to load it */ SEXP cmdSexp, cmdexpr; @@ -791,7 +791,7 @@ static void initialize_rlcompletion(void) eval(VECTOR_ELT(cmdexpr, i), R_GlobalEnv); } UNPROTECT(2); - if(findVarInFrame(R_NamespaceRegistry, install("utils")) + if(R_findVarInFrame(R_NamespaceRegistry, install("utils")) != R_UnboundValue) rcompgen_active = 1; else { rcompgen_active = 0; From 2333f33a4158d9bf1f8663664513a26605f4ff8c Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 24 Jun 2024 16:54:43 +0000 Subject: [PATCH 298/546] Fix race condition causing starvation in Windows console (Rterm). git-svn-id: https://svn.r-project.org/R/trunk@86822 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/system.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gnuwin32/system.c b/src/gnuwin32/system.c index bee79abef12..d9806d7a949 100644 --- a/src/gnuwin32/system.c +++ b/src/gnuwin32/system.c @@ -347,7 +347,7 @@ static int ReaderThreadTabHook(char *buf, int offset, int *loc) completionrequest.buf = buf; completionrequest.offset = offset; completionrequest.loc = loc; - SendMessage(ReadMsgWindow, WM_RREADMSG_EVENT, 0, + PostMessage(ReadMsgWindow, WM_RREADMSG_EVENT, 0, (LPARAM) 2 /* completion needed */); WaitForSingleObject(completionrequest.done, INFINITE); return completionrequest.result; @@ -359,7 +359,7 @@ static void __cdecl ReaderThread(void *unused) while(1) { WaitForSingleObject(EhiWakeUp,INFINITE); tlen = InThreadReadConsole(tprompt,tbuf,tlen,thist); - SendMessage(ReadMsgWindow, WM_RREADMSG_EVENT, 0, + PostMessage(ReadMsgWindow, WM_RREADMSG_EVENT, 0, (LPARAM) 1 /* line available */); } } From 6ac2b37c2d4a564c025404a4e4027816563adc7d Mon Sep 17 00:00:00 2001 From: smeyer Date: Mon, 24 Jun 2024 20:30:40 +0000 Subject: [PATCH 299/546] add missing node, drop partial menus git-svn-id: https://svn.r-project.org/R/trunk@86823 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-intro.texi | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/doc/manual/R-intro.texi b/doc/manual/R-intro.texi index 84a35544e59..b0dd3e3fb46 100644 --- a/doc/manual/R-intro.texi +++ b/doc/manual/R-intro.texi @@ -127,17 +127,14 @@ correspondence to @email{R-help@@R-project.org}. @subheading Suggestions to the reader -Most @R{} novices will start with the introductory session in Appendix -A. This should give some familiarity with the style of @R{} sessions +Most @R{} novices will start with @ref{A sample session}. +This should give some familiarity with the style of @R{} sessions and more importantly some instant feedback on what actually happens. Many users will come to @R{} mainly for its graphical facilities. @xref{Graphics}, which can be read at almost any time and need not wait until all the preceding sections have been digested. -@menu -* Introduction and preliminaries:: -@end menu @node Introduction and preliminaries, Simple manipulations numbers and vectors, Preface, Top @chapter Introduction and preliminaries @@ -148,6 +145,7 @@ until all the preceding sections have been digested. * R and statistics:: * R and the window system:: * Using R interactively:: +* An introductory session:: * Getting help:: * R commands; case sensitivity etc:: * Recall and correction of previous commands:: @@ -344,6 +342,7 @@ follow is basically the same. Create a folder as the working directory, and set that in the @file{Start In} field in your @R{} shortcut. Then launch @R{} by double clicking on the icon. +@node An introductory session @section An introductory session Readers wishing to get a feel for @R{} at a computer before proceeding @@ -784,9 +783,6 @@ sqrt(-17+0i) @noindent will do the computations as complex numbers. -@menu -* Generating regular sequences:: -@end menu @node Generating regular sequences, Logical vectors, Vector arithmetic, Simple manipulations numbers and vectors @section Generating regular sequences @@ -1687,10 +1683,6 @@ in this case the dimension vector is ignored. This is not the case, however, if the single index is not a vector but itself an array, as we next discuss. -@menu -* Index matrices:: -* The array() function:: -@end menu @node Index matrices, The array() function, Array indexing, Arrays and matrices @section Index matrices @@ -2828,9 +2820,6 @@ where the @code{header=TRUE} option specifies that the first line is a line of headings, and hence, by implication from the form of the file, that no explicit row labels are given. -@menu -* The scan() function:: -@end menu @node The scan() function, Accessing builtin datasets, The read.table() function, Reading data from files @section The @code{scan()} function @@ -3908,10 +3897,6 @@ area <- function(f, a, b, eps = 1.0e-06, lim = 10) @{ @} @end example -@menu -* Scope:: -* Object orientation:: -@end menu @node Scope, Customizing the environment, More advanced examples, Writing your own functions @section Scope From 7020ad170a2059d3a946c50ddadf506fbbadb5ba Mon Sep 17 00:00:00 2001 From: pd Date: Mon, 24 Jun 2024 23:22:45 +0000 Subject: [PATCH 300/546] maintainer-mode changes git-svn-id: https://svn.r-project.org/R/trunk@86824 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/gram.c | 190 ------------------------------------------------ 1 file changed, 190 deletions(-) diff --git a/src/main/gram.c b/src/main/gram.c index 1437edad1ea..6ed06dbceb3 100644 --- a/src/main/gram.c +++ b/src/main/gram.c @@ -67,7 +67,6 @@ /* First part of user prologue. */ -#line 2 "gram.y" /* * R : A Computer Language for Statistical Data Analysis @@ -464,7 +463,6 @@ static int xxvalue(SEXP, int, YYLTYPE *); #define YYSTYPE SEXP -#line 468 "y.tab.c" # ifndef YY_CAST # ifdef __cplusplus @@ -2277,565 +2275,378 @@ yyparse (void) switch (yyn) { case 2: /* prog: END_OF_INPUT */ -#line 446 "gram.y" { Status = 0; YYACCEPT; } -#line 2283 "y.tab.c" break; case 3: /* prog: '\n' */ -#line 447 "gram.y" { Status = 2; yyresult = xxvalue(NULL,2,NULL); YYACCEPT; } -#line 2289 "y.tab.c" break; case 4: /* prog: expr_or_assign_or_help '\n' */ -#line 448 "gram.y" { Status = 3; yyresult = xxvalue(yyvsp[-1],3,&(yylsp[-1])); YYACCEPT; } -#line 2295 "y.tab.c" break; case 5: /* prog: expr_or_assign_or_help ';' */ -#line 449 "gram.y" { Status = 4; yyresult = xxvalue(yyvsp[-1],4,&(yylsp[-1])); YYACCEPT; } -#line 2301 "y.tab.c" break; case 6: /* prog: error */ -#line 450 "gram.y" { Status = 1; YYABORT; } -#line 2307 "y.tab.c" break; case 7: /* expr_or_assign_or_help: expr */ -#line 453 "gram.y" { yyval = yyvsp[0]; } -#line 2313 "y.tab.c" break; case 8: /* expr_or_assign_or_help: expr_or_assign_or_help EQ_ASSIGN expr_or_assign_or_help */ -#line 454 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2319 "y.tab.c" break; case 9: /* expr_or_assign_or_help: expr_or_assign_or_help '?' expr_or_assign_or_help */ -#line 455 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2325 "y.tab.c" break; case 10: /* expr_or_help: expr */ -#line 458 "gram.y" { yyval = yyvsp[0]; } -#line 2331 "y.tab.c" break; case 11: /* expr_or_help: expr_or_help '?' expr_or_help */ -#line 459 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2337 "y.tab.c" break; case 12: /* expr: NUM_CONST */ -#line 462 "gram.y" { yyval = yyvsp[0]; setId((yyloc)); } -#line 2343 "y.tab.c" break; case 13: /* expr: STR_CONST */ -#line 463 "gram.y" { yyval = yyvsp[0]; setId((yyloc)); } -#line 2349 "y.tab.c" break; case 14: /* expr: NULL_CONST */ -#line 464 "gram.y" { yyval = yyvsp[0]; setId((yyloc)); } -#line 2355 "y.tab.c" break; case 15: /* expr: PLACEHOLDER */ -#line 465 "gram.y" { yyval = yyvsp[0]; setId((yyloc)); } -#line 2361 "y.tab.c" break; case 16: /* expr: SYMBOL */ -#line 466 "gram.y" { yyval = yyvsp[0]; setId((yyloc)); } -#line 2367 "y.tab.c" break; case 17: /* expr: '{' exprlist '}' */ -#line 468 "gram.y" { yyval = xxexprlist(yyvsp[-2],&(yylsp[-2]),yyvsp[-1]); setId((yyloc)); } -#line 2373 "y.tab.c" break; case 18: /* expr: '(' expr_or_assign_or_help ')' */ -#line 469 "gram.y" { yyval = xxparen(yyvsp[-2],yyvsp[-1]); setId((yyloc)); } -#line 2379 "y.tab.c" break; case 19: /* expr: '-' expr */ -#line 471 "gram.y" { yyval = xxunary(yyvsp[-1],yyvsp[0]); setId((yyloc)); } -#line 2385 "y.tab.c" break; case 20: /* expr: '+' expr */ -#line 472 "gram.y" { yyval = xxunary(yyvsp[-1],yyvsp[0]); setId((yyloc)); } -#line 2391 "y.tab.c" break; case 21: /* expr: '!' expr */ -#line 473 "gram.y" { yyval = xxunary(yyvsp[-1],yyvsp[0]); setId((yyloc)); } -#line 2397 "y.tab.c" break; case 22: /* expr: '~' expr */ -#line 474 "gram.y" { yyval = xxunary(yyvsp[-1],yyvsp[0]); setId((yyloc)); } -#line 2403 "y.tab.c" break; case 23: /* expr: '?' expr_or_assign_or_help */ -#line 475 "gram.y" { yyval = xxunary(yyvsp[-1],yyvsp[0]); setId((yyloc)); } -#line 2409 "y.tab.c" break; case 24: /* expr: expr ':' expr */ -#line 477 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2415 "y.tab.c" break; case 25: /* expr: expr '+' expr */ -#line 478 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2421 "y.tab.c" break; case 26: /* expr: expr '-' expr */ -#line 479 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2427 "y.tab.c" break; case 27: /* expr: expr '*' expr */ -#line 480 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2433 "y.tab.c" break; case 28: /* expr: expr '/' expr */ -#line 481 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2439 "y.tab.c" break; case 29: /* expr: expr '^' expr */ -#line 482 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2445 "y.tab.c" break; case 30: /* expr: expr SPECIAL expr */ -#line 483 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2451 "y.tab.c" break; case 31: /* expr: expr '~' expr */ -#line 484 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2457 "y.tab.c" break; case 32: /* expr: expr LT expr */ -#line 485 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2463 "y.tab.c" break; case 33: /* expr: expr LE expr */ -#line 486 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2469 "y.tab.c" break; case 34: /* expr: expr EQ expr */ -#line 487 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2475 "y.tab.c" break; case 35: /* expr: expr NE expr */ -#line 488 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2481 "y.tab.c" break; case 36: /* expr: expr GE expr */ -#line 489 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2487 "y.tab.c" break; case 37: /* expr: expr GT expr */ -#line 490 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2493 "y.tab.c" break; case 38: /* expr: expr AND expr */ -#line 491 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2499 "y.tab.c" break; case 39: /* expr: expr OR expr */ -#line 492 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2505 "y.tab.c" break; case 40: /* expr: expr AND2 expr */ -#line 493 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2511 "y.tab.c" break; case 41: /* expr: expr OR2 expr */ -#line 494 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2517 "y.tab.c" break; case 42: /* expr: expr PIPE expr */ -#line 495 "gram.y" { yyval = xxpipe(yyvsp[-2],yyvsp[0],&(yylsp[0])); setId((yyloc)); } -#line 2523 "y.tab.c" break; case 43: /* expr: expr PIPEBIND expr */ -#line 496 "gram.y" { yyval = xxpipebind(yyvsp[-1],yyvsp[-2],yyvsp[0],&(yylsp[-1])); setId((yyloc)); } -#line 2529 "y.tab.c" break; case 44: /* expr: expr LEFT_ASSIGN expr */ -#line 497 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2535 "y.tab.c" break; case 45: /* expr: expr RIGHT_ASSIGN expr */ -#line 498 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[0],yyvsp[-2]); setId((yyloc)); } -#line 2541 "y.tab.c" break; case 46: /* expr: FUNCTION '(' formlist ')' cr expr_or_assign_or_help */ -#line 500 "gram.y" { yyval = xxdefun(yyvsp[-5],yyvsp[-3],yyvsp[0],&(yyloc)); setId((yyloc)); } -#line 2547 "y.tab.c" break; case 47: /* expr: '\\' '(' formlist ')' cr expr_or_assign_or_help */ -#line 501 "gram.y" { yyval = xxdefun(R_FunctionSymbol,yyvsp[-3],yyvsp[0],&(yyloc)); setId((yyloc)); } -#line 2553 "y.tab.c" break; case 48: /* expr: expr '(' sublist ')' */ -#line 502 "gram.y" { yyval = xxfuncall(yyvsp[-3],yyvsp[-1]); setId((yyloc)); modif_token( &(yylsp[-3]), SYMBOL_FUNCTION_CALL ) ; } -#line 2559 "y.tab.c" break; case 49: /* expr: IF ifcond expr_or_assign_or_help */ -#line 503 "gram.y" { yyval = xxif(yyvsp[-2],yyvsp[-1],yyvsp[0]); setId((yyloc)); } -#line 2565 "y.tab.c" break; case 50: /* expr: IF ifcond expr_or_assign_or_help ELSE expr_or_assign_or_help */ -#line 504 "gram.y" { yyval = xxifelse(yyvsp[-4],yyvsp[-3],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2571 "y.tab.c" break; case 51: /* expr: FOR forcond expr_or_assign_or_help */ -#line 505 "gram.y" { yyval = xxfor(yyvsp[-2],yyvsp[-1],yyvsp[0]); setId((yyloc)); } -#line 2577 "y.tab.c" break; case 52: /* expr: WHILE cond expr_or_assign_or_help */ -#line 506 "gram.y" { yyval = xxwhile(yyvsp[-2],yyvsp[-1],yyvsp[0]); setId((yyloc)); } -#line 2583 "y.tab.c" break; case 53: /* expr: REPEAT expr_or_assign_or_help */ -#line 507 "gram.y" { yyval = xxrepeat(yyvsp[-1],yyvsp[0]); setId((yyloc)); } -#line 2589 "y.tab.c" break; case 54: /* expr: expr LBB sublist ']' ']' */ -#line 508 "gram.y" { yyval = xxsubscript(yyvsp[-4],yyvsp[-3],yyvsp[-2]); setId((yyloc)); } -#line 2595 "y.tab.c" break; case 55: /* expr: expr '[' sublist ']' */ -#line 509 "gram.y" { yyval = xxsubscript(yyvsp[-3],yyvsp[-2],yyvsp[-1]); setId((yyloc)); } -#line 2601 "y.tab.c" break; case 56: /* expr: SYMBOL NS_GET SYMBOL */ -#line 510 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); modif_token( &(yylsp[-2]), SYMBOL_PACKAGE ) ; } -#line 2607 "y.tab.c" break; case 57: /* expr: SYMBOL NS_GET STR_CONST */ -#line 511 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); modif_token( &(yylsp[-2]), SYMBOL_PACKAGE ) ; } -#line 2613 "y.tab.c" break; case 58: /* expr: STR_CONST NS_GET SYMBOL */ -#line 512 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2619 "y.tab.c" break; case 59: /* expr: STR_CONST NS_GET STR_CONST */ -#line 513 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2625 "y.tab.c" break; case 60: /* expr: SYMBOL NS_GET_INT SYMBOL */ -#line 514 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); modif_token( &(yylsp[-2]), SYMBOL_PACKAGE ) ;} -#line 2631 "y.tab.c" break; case 61: /* expr: SYMBOL NS_GET_INT STR_CONST */ -#line 515 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); modif_token( &(yylsp[-2]), SYMBOL_PACKAGE ) ;} -#line 2637 "y.tab.c" break; case 62: /* expr: STR_CONST NS_GET_INT SYMBOL */ -#line 516 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2643 "y.tab.c" break; case 63: /* expr: STR_CONST NS_GET_INT STR_CONST */ -#line 517 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2649 "y.tab.c" break; case 64: /* expr: expr '$' SYMBOL */ -#line 518 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2655 "y.tab.c" break; case 65: /* expr: expr '$' STR_CONST */ -#line 519 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2661 "y.tab.c" break; case 66: /* expr: expr '@' SYMBOL */ -#line 520 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); modif_token( &(yylsp[0]), SLOT ) ; } -#line 2667 "y.tab.c" break; case 67: /* expr: expr '@' STR_CONST */ -#line 521 "gram.y" { yyval = xxbinary(yyvsp[-1],yyvsp[-2],yyvsp[0]); setId((yyloc)); } -#line 2673 "y.tab.c" break; case 68: /* expr: NEXT */ -#line 522 "gram.y" { yyval = xxnxtbrk(yyvsp[0]); setId((yyloc)); } -#line 2679 "y.tab.c" break; case 69: /* expr: BREAK */ -#line 523 "gram.y" { yyval = xxnxtbrk(yyvsp[0]); setId((yyloc)); } -#line 2685 "y.tab.c" break; case 70: /* cond: '(' expr_or_help ')' */ -#line 527 "gram.y" { yyval = xxcond(yyvsp[-1]); } -#line 2691 "y.tab.c" break; case 71: /* ifcond: '(' expr_or_help ')' */ -#line 530 "gram.y" { yyval = xxifcond(yyvsp[-1]); } -#line 2697 "y.tab.c" break; case 72: /* forcond: '(' SYMBOL IN expr_or_help ')' */ -#line 533 "gram.y" { yyval = xxforcond(yyvsp[-3],yyvsp[-1]); setId((yyloc)); } -#line 2703 "y.tab.c" break; case 73: /* exprlist: %empty */ -#line 537 "gram.y" { yyval = xxexprlist0(); setId((yyloc)); } -#line 2709 "y.tab.c" break; case 74: /* exprlist: expr_or_assign_or_help */ -#line 538 "gram.y" { yyval = xxexprlist1(yyvsp[0], &(yylsp[0])); } -#line 2715 "y.tab.c" break; case 75: /* exprlist: exprlist ';' expr_or_assign_or_help */ -#line 539 "gram.y" { yyval = xxexprlist2(yyvsp[-2], yyvsp[0], &(yylsp[0])); } -#line 2721 "y.tab.c" break; case 76: /* exprlist: exprlist ';' */ -#line 540 "gram.y" { yyval = yyvsp[-1]; setId((yyloc)); } -#line 2727 "y.tab.c" break; case 77: /* exprlist: exprlist '\n' expr_or_assign_or_help */ -#line 541 "gram.y" { yyval = xxexprlist2(yyvsp[-2], yyvsp[0], &(yylsp[0])); } -#line 2733 "y.tab.c" break; case 78: /* exprlist: exprlist '\n' */ -#line 542 "gram.y" { yyval = yyvsp[-1];} -#line 2739 "y.tab.c" break; case 79: /* sublist: sub */ -#line 545 "gram.y" { yyval = xxsublist1(yyvsp[0]); } -#line 2745 "y.tab.c" break; case 80: /* sublist: sublist cr ',' sub */ -#line 546 "gram.y" { yyval = xxsublist2(yyvsp[-3],yyvsp[0]); } -#line 2751 "y.tab.c" break; case 81: /* sub: %empty */ -#line 549 "gram.y" { yyval = xxsub0(); } -#line 2757 "y.tab.c" break; case 82: /* sub: expr_or_help */ -#line 550 "gram.y" { yyval = xxsub1(yyvsp[0], &(yylsp[0])); } -#line 2763 "y.tab.c" break; case 83: /* sub: SYMBOL EQ_ASSIGN */ -#line 551 "gram.y" { yyval = xxsymsub0(yyvsp[-1], &(yylsp[-1])); modif_token( &(yylsp[0]), EQ_SUB ) ; modif_token( &(yylsp[-1]), SYMBOL_SUB ) ; } -#line 2769 "y.tab.c" break; case 84: /* sub: SYMBOL EQ_ASSIGN expr_or_help */ -#line 552 "gram.y" { yyval = xxsymsub1(yyvsp[-2],yyvsp[0], &(yylsp[-2])); modif_token( &(yylsp[-1]), EQ_SUB ) ; modif_token( &(yylsp[-2]), SYMBOL_SUB ) ; } -#line 2775 "y.tab.c" break; case 85: /* sub: STR_CONST EQ_ASSIGN */ -#line 553 "gram.y" { yyval = xxsymsub0(yyvsp[-1], &(yylsp[-1])); modif_token( &(yylsp[0]), EQ_SUB ) ; } -#line 2781 "y.tab.c" break; case 86: /* sub: STR_CONST EQ_ASSIGN expr_or_help */ -#line 554 "gram.y" { yyval = xxsymsub1(yyvsp[-2],yyvsp[0], &(yylsp[-2])); modif_token( &(yylsp[-1]), EQ_SUB ) ; } -#line 2787 "y.tab.c" break; case 87: /* sub: NULL_CONST EQ_ASSIGN */ -#line 555 "gram.y" { yyval = xxnullsub0(&(yylsp[-1])); modif_token( &(yylsp[0]), EQ_SUB ) ; } -#line 2793 "y.tab.c" break; case 88: /* sub: NULL_CONST EQ_ASSIGN expr_or_help */ -#line 556 "gram.y" { yyval = xxnullsub1(yyvsp[0], &(yylsp[-2])); modif_token( &(yylsp[-1]), EQ_SUB ) ; } -#line 2799 "y.tab.c" break; case 89: /* formlist: %empty */ -#line 559 "gram.y" { yyval = xxnullformal(); } -#line 2805 "y.tab.c" break; case 90: /* formlist: SYMBOL */ -#line 560 "gram.y" { yyval = xxfirstformal0(yyvsp[0]); modif_token( &(yylsp[0]), SYMBOL_FORMALS ) ; } -#line 2811 "y.tab.c" break; case 91: /* formlist: SYMBOL EQ_ASSIGN expr_or_help */ -#line 561 "gram.y" { yyval = xxfirstformal1(yyvsp[-2],yyvsp[0]); modif_token( &(yylsp[-2]), SYMBOL_FORMALS ) ; modif_token( &(yylsp[-1]), EQ_FORMALS ) ; } -#line 2817 "y.tab.c" break; case 92: /* formlist: formlist ',' SYMBOL */ -#line 562 "gram.y" { yyval = xxaddformal0(yyvsp[-2],yyvsp[0], &(yylsp[0])); modif_token( &(yylsp[0]), SYMBOL_FORMALS ) ; } -#line 2823 "y.tab.c" break; case 93: /* formlist: formlist ',' SYMBOL EQ_ASSIGN expr_or_help */ -#line 564 "gram.y" { yyval = xxaddformal1(yyvsp[-4],yyvsp[-2],yyvsp[0],&(yylsp[-2])); modif_token( &(yylsp[-2]), SYMBOL_FORMALS ) ; modif_token( &(yylsp[-1]), EQ_FORMALS ) ;} -#line 2829 "y.tab.c" break; case 94: /* cr: %empty */ -#line 567 "gram.y" { EatLines = 1; } -#line 2835 "y.tab.c" break; -#line 2839 "y.tab.c" default: break; } @@ -3064,7 +2875,6 @@ yyparse (void) return yyresult; } -#line 569 "gram.y" From d67902d4bb5d0e4151c7c16ba4f839737fc35599 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 25 Jun 2024 09:38:46 +0000 Subject: [PATCH 301/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86825 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/Rd2HTML.R | 4 ++-- src/library/tools/R/toHTML.R | 2 +- src/library/tools/R/urltools.R | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/library/tools/R/Rd2HTML.R b/src/library/tools/R/Rd2HTML.R index 504b9cb2ab2..557bd589b73 100644 --- a/src/library/tools/R/Rd2HTML.R +++ b/src/library/tools/R/Rd2HTML.R @@ -1482,7 +1482,7 @@ function(dir) if(a) { ## URL regexp as in .DESCRIPTION_to_latex(). CRAN uses ## <(URL: *)?((https?|ftp)://[^[:space:]]+)[[:space:]]*> - ## ([^>\"])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/]) + ## ([^>\"?])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/]) ## (also used in toRd.citation(). x <- trfm("<(http://|ftp://|https://)([^[:space:],>]+)>", "\\1\\2", @@ -1723,7 +1723,7 @@ function(dir) ## The above already changed & to & which urlify will ## do once more ... trafo <- function(s) urlify(gsub("&", "&", s)) - desc[f] <- trfm("(^|[^>\"])((https?|ftp)://[^[:space:],]*)", + desc[f] <- trfm("(^|[^>\"?])((https?|ftp)://[^[:space:],]*)", "\\1\\2", desc[f], trafo, diff --git a/src/library/tools/R/toHTML.R b/src/library/tools/R/toHTML.R index 97eb3e29ccf..37d0bca358c 100644 --- a/src/library/tools/R/toHTML.R +++ b/src/library/tools/R/toHTML.R @@ -340,7 +340,7 @@ function(x, header = TRUE, ...) ## Need to ignore results of the above translation ... ## Regexp based on Perl HTML::TextToHTML, note that the dash ## must be last ... - s <- .gsub_with_transformed_matches("([^>\"])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/])", + s <- .gsub_with_transformed_matches("([^>\"?])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/])", "\\1\\2", s, urlify, diff --git a/src/library/tools/R/urltools.R b/src/library/tools/R/urltools.R index 8e5dda88d59..024524f34e2 100644 --- a/src/library/tools/R/urltools.R +++ b/src/library/tools/R/urltools.R @@ -206,7 +206,7 @@ function(v) m <- gregexpr(pattern, v) urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) regmatches(v, m) <- "" - pattern <- "(^|[^>\"])((https?|ftp)://[^[:space:],]*)" + pattern <- "(^|[^>\"?])((https?|ftp)://[^[:space:],]*)" m <- gregexpr(pattern, v) urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) urls @@ -223,7 +223,7 @@ function(v) urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) regmatches(v, m) <- "" pattern <- - "([^>\"])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/])" + "([^>\"?])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/])" m <- gregexpr(pattern, v) urls <- c(urls, .gregexec_at_pos(pattern, v, m, 3L)) regmatches(v, m) <- "" From fab4e958eb9f984592dc154ab1bf4612975b562f Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 25 Jun 2024 09:39:00 +0000 Subject: [PATCH 302/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86826 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index 89cc5e4c16c..afc617bf113 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -80,7 +80,7 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Spain (Madrid) [https]",Spain,Madrid,https://cran.rediris.es/,"Spanish National Research Network, Madrid","Jose Manuel Macias ",1,es,"secure_mirror_from_master" "Sweden (UmeĆ„) [https]",Sweden,UmeĆ„,https://mirror.accum.se/mirror/CRAN/,"Academic Computer Club in UmeĆ„, Sweden","",1,se,"secure_mirror_from_master" "Switzerland (Zurich 1) [https]",Switzerland,ZĆ¼rich,https://stat.ethz.ch/CRAN/,"ETH ZĆ¼rich","Martin.Maechler # R-project.org",1,ch,"secure_mirror_from_master" -"Switzerland (Zurich 2) [https]",Switzerland,ZĆ¼rich,https://mirror.metanet.ch/cran/," METNET AG","mirror # metanet.ch",0,ch +"Switzerland (Zurich 2) [https]",Switzerland,ZĆ¼rich,https://mirror.metanet.ch/cran/," METNET AG","mirror # metanet.ch",1,ch "Taiwan (Taipei) [https]",Taiwan,Taipei,https://cran.csie.ntu.edu.tw/,"National Taiwan University, Taipei","b90098 # csie.ntu.edu.tw",1,tw,"secure_mirror_from_master" Thailand,Thailand,Hatyai,http://mirrors.psu.ac.th/pub/cran/,"Prince of Songkla University, Hatyai","wipat.s # psu.ac.th",1,th,"maintainer_address_bounces" "Turkey (Denizli) [https]",Turkey,Denizli,https://cran.pau.edu.tr/,"Pamukkale University, Denizli","Ugur Zeybek ",1,tr,"secure_mirror_from_master" From f36c203d3a53a74d56a81d4f97a68d24993e0652 Mon Sep 17 00:00:00 2001 From: maechler Date: Tue, 25 Jun 2024 10:25:56 +0000 Subject: [PATCH 303/546] 1-letter typo; thanks to Brennan Ravan git-svn-id: https://svn.r-project.org/R/trunk@86827 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/debug.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/base/man/debug.Rd b/src/library/base/man/debug.Rd index ac42fa15899..8482193d3bc 100644 --- a/src/library/base/man/debug.Rd +++ b/src/library/base/man/debug.Rd @@ -108,7 +108,7 @@ library(methods) \dontrun{ debugonce(sample) ## only the first call will be debugged -sampe(10, 1) +sample(10, 1) sample(10, 1) } } From d99c34a0d4ff375341c169e46f6abf359c67779b Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 25 Jun 2024 17:05:40 +0000 Subject: [PATCH 304/546] Fix problem from c86759. git-svn-id: https://svn.r-project.org/R/trunk@86829 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 66eefb63236..09c6a46af6e 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -2475,11 +2475,11 @@ add_dummies <- function(dir, Log) bad <- split(bad[, "Target"], bad[, "Source"]) msg <- c(if(any) "", strwrap("Found the following Rd file(s) with Rd \\link{} targets missing package anchors:"), - sprintf(" %s: %s", - names(bad), - strwrap(vapply(bad, paste, "", - collapse = ", "), - exdent = 4L, indent = 0L)), + strwrap(sprintf(" %s: %s", + names(bad), + vapply(bad, paste, "", + collapse = ", ")), + exdent = 4L, indent = 2L), strwrap("Please provide package anchors for all Rd \\link{} targets not in the package itself and the base packages.")) if(!any) { noteLog(Log) From 59a290f5775c670009b1aeb18874df2b132d38f8 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 25 Jun 2024 18:44:20 +0000 Subject: [PATCH 305/546] Fix problem from c86787. git-svn-id: https://svn.r-project.org/R/trunk@86830 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index 0ceed11aee5..c700a120e78 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -8137,9 +8137,9 @@ function(dir, localOnly = FALSE, pkgSize = NA) } if(NROW(odb)) { ids <- .ORCID_iD_canonicalize(odb[, 1L]) - bad <- ids[!.ORCID_iD_is_alive(ids)] - if(length(bad)) - out$bad_ORCID_iDs <- bad + pos <- which(!.ORCID_iD_is_alive(ids)) + if(length(pos)) + out$bad_ORCID_iDs <- odb[pos, , drop = FALSE] } } } From 48e02881502dce9eeeefff1bc422bc0968913c04 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 25 Jun 2024 20:24:01 +0000 Subject: [PATCH 306/546] Add Rf_gsetVar to tools:::nonAPI and adjust check message. git-svn-id: https://svn.r-project.org/R/trunk@86831 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 5 ++++- src/library/tools/R/sotools.R | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 09c6a46af6e..49e97737e2f 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -3869,7 +3869,10 @@ add_dummies <- function(dir, Log) "It is good practice to register native routines and to disable symbol search.\n") wrapLog("\n", paste(msg, collapse = " "), "\n", "See 'Writing portable packages'", - "in the 'Writing R Extensions' manual.\n") + "in the 'Writing R Extensions' manual.", + "See section 'Moving into C API compliance' in the ", + "'Writing R Extensions' manual for issues with use ", + "of non-API entry points.\n") } else resultLog(Log, "OK") } diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index eee212800a9..e5f11852519 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -686,7 +686,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "PRCODE", "PRENV", "PRVALUE", "R_nchar", "Rf_NonNullStringMatch", "SET_TYPEOF", "TRUELENGTH", "XLENGTH_EX", - "XTRUELENGTH", + "XTRUELENGTH", "Rf_gsetVar", ## in the non-API header R_ext/Connections.h "R_new_custom_connection", "R_ReadConnection", "R_WriteConnection", "R_GetConnection", From 74fe8409200b77e9ba819495ada31e4d805eae39 Mon Sep 17 00:00:00 2001 From: maechler Date: Wed, 26 Jun 2024 08:10:00 +0000 Subject: [PATCH 307/546] YA tweak to r86797, as.data.frame.list(): keeps `NA` only if `check.names=FALSE` git-svn-id: https://svn.r-project.org/R/trunk@86832 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/dataframe.R | 8 +++---- src/library/base/man/as.data.frame.Rd | 25 +++++++++++++++++--- tests/reg-tests-1e.R | 34 +++++++++++++++++---------- 3 files changed, 48 insertions(+), 19 deletions(-) diff --git a/src/library/base/R/dataframe.R b/src/library/base/R/dataframe.R index fadb02a5e53..93550c1b477 100644 --- a/src/library/base/R/dataframe.R +++ b/src/library/base/R/dataframe.R @@ -221,8 +221,7 @@ as.data.frame.list <- stringsAsFactors = FALSE) { ## need to protect names in x. - ## truncate any of more than 256 (or cut.names) bytes: - if(cut.names) { + if(cut.names) { ## truncate any of more than 256 (or cut.names) bytes: maxL <- if(is.logical(cut.names)) 256L else as.integer(cut.names) if(any(long <- nchar(col.names, "bytes", keepNA = FALSE) > maxL)) col.names[long] <- paste(substr(col.names[long], 1L, maxL - 6L), "...") @@ -232,13 +231,14 @@ as.data.frame.list <- ## c("row.names", "check.rows", ...., "stringsAsFactors"), col.names, 0L) if(any.m <- any(m)) col.names[m] <- paste0("..adfl.", col.names[m]) - if(Nnms <- new.names || any.m || cut.names) names(x) <- col.names + if(new.names || any.m || cut.names) names(x) <- col.names ## data.frame() is picky with its 'row.names': alis <- c(list(check.names = check.names, fix.empty.names = fix.empty.names, stringsAsFactors = stringsAsFactors), if(!missing(row.names)) list(row.names = row.names)) x <- do.call(data.frame, c(x, alis)) - if(Nnms && length(names(x)) == length(col.names) && any(naNm <- is.na(col.names))) + if(new.names && !check.names && length(names(x)) == length(col.names) && + any(naNm <- is.na(col.names))) names(x)[naNm] <- col.names[naNm] if(any.m) names(x) <- sub("^\\.\\.adfl\\.", "", names(x)) x diff --git a/src/library/base/man/as.data.frame.Rd b/src/library/base/man/as.data.frame.Rd index 5009a50ced0..e48d8dcd72d 100644 --- a/src/library/base/man/as.data.frame.Rd +++ b/src/library/base/man/as.data.frame.Rd @@ -63,7 +63,8 @@ is.data.frame(x) \item{col.names}{(optional) character vector of column names.} \item{fix.empty.names}{logical indicating if empty column names, i.e., \code{""} should be fixed up (in \code{\link{data.frame}}) or not.} - \item{new.names}{logical indicating that \code{col.names} should be set explicitly.} + \item{new.names}{logical indicating that \code{col.names} should be used + (and possibly reset to \code{NA}) explicitly.} \item{check.names}{logical; passed to the \code{\link{data.frame}()} call.} %% matrix method: \item{make.names}{a \code{\link{logical}}, i.e., one of \code{FALSE, NA, TRUE}, @@ -129,8 +130,26 @@ is.data.frame(x) eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole. } \seealso{ - \code{\link{data.frame}}, \code{\link{as.data.frame.table}} for the - \code{table} method (which has additional arguments if called directly). + \code{\link{data.frame}} and \code{\link{make.names}}; + \code{\link{as.data.frame.table}} for the \code{table} method (which has + additional arguments). +} +\examples{ +L0 <- list(LETTERS[1:7], c(4L, 2:3, 5:7, 1L)) +L <- L0; names(L) <- nms <- c("nam", "age") + d0 <- as.data.frame(L0, col.names = nms) +(d1 <- as.data.frame(L)) +stopifnot(identical(d0, d1)) + +## showing possibilities on how NA names are handled: +L <- list(A = 1:4); names(L) <- NA +names(dL <- as.data.frame(L)) # "NA." +names(dL1 <- as.data.frame(L, col.names = names(L))) # "NA." +## +names(dL1.<- as.data.frame(L, check.names=FALSE)) # "NA" +## +names(dL2 <- as.data.frame(L, col.names = names(L), check.names=FALSE)) # NA +names(dLn <- as.data.frame(L, new.names = TRUE, check.names=FALSE)) # NA } \keyword{classes} \keyword{methods} diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 3b4ebfc6772..3d05c8ca4e8 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1418,29 +1418,39 @@ dN <- data.frame(a = c(1,NA), b = c("a",NA), names(dN) <- nms <- c("num", "ch", NA, NA) (fdN <- format(dN)) L <- list(A = FALSE); names(L) <- NA - dL1 <- as.data.frame.list(L, col.names = names(L)) - dL2 <- as.data.frame.list(L, col.names = names(L), check.names=FALSE) -str(dL <- as.data.frame.list(L, new.names=TRUE)) -## check.names = TRUE, fix.empty.names = TRUE are default : -prblN <- c("", "var 2") -dp11 <- as.data.frame(setNames(list(1, 23), prblN)) -dp01 <- as.data.frame(setNames(list(1, 23), prblN), check.names=FALSE) -dp00 <- as.data.frame(setNames(list(1, 23), prblN), check.names=FALSE, fix.empty.names=FALSE) -dp10 <- as.data.frame(setNames(list(1, 23), prblN), check.names=TRUE , fix.empty.names=FALSE) +names(dL <- as.data.frame.list(L)) # "NA." +names(dL1 <- as.data.frame.list(L, col.names = names(L))) # "NA." +names(dL2 <- as.data.frame.list(L, col.names = names(L), check.names=FALSE)) # NA (was "NA") +names(dL1.<- as.data.frame.list(L, check.names=FALSE)) # "NA" +names(dLn <- as.data.frame.list(L, new.names = TRUE, check.names=FALSE)) # NA (was "NA") +prblN <- c("", "var 2"); L2 <- `names<-`(list(1, 23), prblN) +## check.names = TRUE, fix.empty.names = TRUE are default : +dp11 <- as.data.frame(L2) +dp01 <- as.data.frame(L2, check.names=FALSE) +dp00 <- as.data.frame(L2, check.names=FALSE, fix.empty.names=FALSE) +dp10 <- as.data.frame(L2, check.names=TRUE , fix.empty.names=FALSE) +L3 <- c(L, list(row.names = 2)) +names(dL3 <- as.data.frame.list(L3)) # "NA." "row.names" +names(dL3n <- as.data.frame.list(L3, check.names=FALSE)) # NA "row.names", was "NA" "rown..." +names(dL3nn<- as.data.frame.list(L3, check.names=FALSE, new.names=FALSE)) # # "NA" "rown..." stopifnot(exprs = { is.na(names(x)) is.data.frame(fx) identical(NA_character_, names(x)) identical(NA_character_, names(fx)) # was "NA" wrongly - identical(NA_character_, names(dL)) + identical(NA_character_, names(dLn))# " " + identical(NA_character_, names(dL2))# " " identical(nms, names( dN)) identical(nms, names(fdN)) # was .. .. "NA" "NA" - identical(dL1, dL2)# was FALSE ("NA vs "NA.") - identical(dL, dL1) # was always TRUE; ditto these {wrong for a couple of hours}: + identical(dLn, dL2) # was always TRUE; ditto these {wrong for a couple of hours}: names(dp11) == c("X1", "var.2") names(dp01) == c( "1", "var 2") names(dp00) == c( "" , "var 2") # == prblN names(dp10) == c( "" , "var.2") + identical(names(L3), names(dL3n)) # now. The next 3 are not new: + identical("NA.", names(dL)) + identical("NA.", names(dL3) [[1]]) + identical("NA" , names(dL3nn)[[1]]) }) ## format() and as.data.frame(, col.names=*, check.names=FALSE) *did* ## change NA names() into "NA" for R <= 4.4.1 From 10e6a5500692fd550749ea129b6d7bae6272ebdd Mon Sep 17 00:00:00 2001 From: smeyer Date: Wed, 26 Jun 2024 08:48:00 +0000 Subject: [PATCH 308/546] texi tweaks/cleanup git-svn-id: https://svn.r-project.org/R/trunk@86833 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-defs.texi | 12 ------------ doc/manual/R-intro.texi | 6 +++--- doc/manual/R-lang.texi | 40 ++++++---------------------------------- 3 files changed, 9 insertions(+), 49 deletions(-) diff --git a/doc/manual/R-defs.texi b/doc/manual/R-defs.texi index c5f5efa63bf..3f9273ed55b 100644 --- a/doc/manual/R-defs.texi +++ b/doc/manual/R-defs.texi @@ -82,16 +82,4 @@ approved by the R Core Team. \s\ @end macro -@c This breaks HTML conversion on texinfo 4.x. -@iftex @hyphenation{name-space name-spaces} -@end iftex - -@set ISBN-FAQ -@set ISBN-admin -@set ISBN-data -@set ISBN-exts -@set ISBN-intro -@set ISBN-lang -@set ISBN-ints - diff --git a/doc/manual/R-intro.texi b/doc/manual/R-intro.texi index b0dd3e3fb46..2e4f0a51300 100644 --- a/doc/manual/R-intro.texi +++ b/doc/manual/R-intro.texi @@ -268,7 +268,7 @@ features of @R{} is a straightforward if somewhat tedious procedure, and will not be considered further here. Users in difficulty should seek local expert help. -@node Using R interactively, Getting help, R and the window system, Introduction and preliminaries +@node Using R interactively, An introductory session, R and the window system, Introduction and preliminaries @section Using R interactively When you use the @R{} program it issues a prompt when it expects input @@ -342,14 +342,14 @@ follow is basically the same. Create a folder as the working directory, and set that in the @file{Start In} field in your @R{} shortcut. Then launch @R{} by double clicking on the icon. -@node An introductory session +@node An introductory session, Getting help, Using R interactively, Introduction and preliminaries @section An introductory session Readers wishing to get a feel for @R{} at a computer before proceeding are strongly advised to work through the introductory session given in @ref{A sample session}. -@node Getting help, R commands; case sensitivity etc, Using R interactively, Introduction and preliminaries +@node Getting help, R commands; case sensitivity etc, An introductory session, Introduction and preliminaries @section Getting help with functions and features @findex help diff --git a/doc/manual/R-lang.texi b/doc/manual/R-lang.texi index c710d874312..055d906c7f1 100644 --- a/doc/manual/R-lang.texi +++ b/doc/manual/R-lang.texi @@ -335,6 +335,11 @@ Components of the parse tree can be extracted using the standard indexing operations. +@c add menu to avoid spurious warning about unreferenced node +@c when making info with Texinfo 6.8 and 7.0 +@menu +* Symbol objects:: +@end menu @node Symbol objects @subsubsection Symbol objects @@ -910,7 +915,7 @@ For example, to create the integer value 1, we might use @example > 1L -[1] +[1] 1 @end example We can use the `L' suffix to qualify any number with the intent of @@ -954,36 +959,6 @@ directly, except when doing ``programming on the language'' [1] 4 @end example -@c FIXME: Probably needs to go somewhere, but not here (parser section?) -@c FIXME: Up to date info is in the subsection 'Reserved words'. - -@c @node Key words -@c @subsection Key words - -@c @R{} contains a number of key words. These are symbols that the parser -@c treats in a special fashion. They are, - -@c @quotation -@c @multitable @columnfractions 0.2 0.7 -@c @item @code{NULL} @tab the null object -@c @item @code{NA} @tab missing value -@c @item @code{TRUE} @tab logical true -@c @item @code{FALSE} @tab logical false -@c @item @code{Inf} @tab infinity -@c @item @code{NaN} @tab not a number -@c @item @code{function} @tab a special form for creating functions -@c @item @code{while} @tab while flow control -@c @item @code{repeat} @tab repeat flow control -@c @item @code{for} @tab for flow control -@c @item @code{if} @tab if--then--else statements -@c @item @code{in} @tab used in flow control -@c @item @code{else} @tab part of the if--then--else construct -@c @item @code{next} @tab flow control -@c @item @code{break} @tab flow control -@c @item @code{...} @tab special argument for functions -@c @end multitable - -@c @end quotation @node Function calls @subsection Function calls @@ -4651,9 +4626,6 @@ typically used by users, but may be used by preprocessors so that diagnostic messages refer to the original file. -@c -- We can probably lose this given the brevity of the section -@c @node Summary -@c @section Summary of language @node Function and Variable Index @unnumbered Function and Variable Index From 60aaadaba4c98d946a82564c001e33aa08f98510 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 26 Jun 2024 09:25:32 +0000 Subject: [PATCH 309/546] Fix problem from c86079. git-svn-id: https://svn.r-project.org/R/trunk@86834 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/htmltools.R | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/library/tools/R/htmltools.R b/src/library/tools/R/htmltools.R index 803b166407c..ec0bf78c980 100644 --- a/src/library/tools/R/htmltools.R +++ b/src/library/tools/R/htmltools.R @@ -63,12 +63,14 @@ function(x, paths = NULL, ignore = character()) { e <- x[i] x <- Filter(length, x[!i]) if(!length(x) && !length(e)) return(NULL) - y <- cbind(path = rep.int(names(x), vapply(x, nrow, 0)), - do.call(rbind, x)) + y <- do.call(rbind, x) if(is.null(y)) { - y <- list() # cannot set an attr on NULL - } else if(length(ignore)) { - y <- y[y[, "msg"] %notin% ignore, , drop = FALSE] + y <- list() # cannot set an attr on NULL + } else { + y <- cbind(path = rep.int(names(x), vapply(x, nrow, 0)), y) + if(length(ignore)) { + y <- y[y[, "msg"] %notin% ignore, , drop = FALSE] + } } if(length(e)) attr(y, "errors") <- e From 3ec62248335fab63ac165e3d09a9a469ca68fd11 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 26 Jun 2024 09:25:48 +0000 Subject: [PATCH 310/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86835 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index c700a120e78..bed0e350683 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -7553,9 +7553,10 @@ function(dir, localOnly = FALSE, pkgSize = NA) } ## Check for missing build/{partial.rdb,pkgname.pdf} - ## copy code from build.R + ## Code similar to build.R, but we really need step = 2 here as this + ## may throw errors ... Rdb <- tryCatch(.build_Rd_db(dir, stages = NULL, - os = c("unix", "windows"), step = 1), + os = c("unix", "windows"), step = 2), error = identity) if(inherits(Rdb, "error")) out$Rd_db_build_error <- conditionMessage(Rdb) @@ -8685,7 +8686,7 @@ function(x, ...) collapse = "\n") }, if(length(y <- x$additional_repositories_analysis_failed_with)) { - paste(c("Using Additional_repositories specification failed with:", + paste(c("Using Additional_repositories specification failed with message:", paste0(" ", y)), collapse = "\n") }, @@ -8753,7 +8754,7 @@ function(x, ...) "Package has a VignetteBuilder field but no prebuilt vignette index." }, if(length(y <- x$Rd_db_build_error)) { - paste(c("Reading Rd files failed with", + paste(c("Reading Rd files failed with message:", paste0(" ", y)), collapse = "\n") }, @@ -8783,12 +8784,12 @@ function(x, ...) }, if(length(y <- x$citation_error_reading_if_installed)) { paste(c("Reading CITATION file fails with", - paste0(" ", y)), + paste0(" ", gsub("\n", "\n ", y))), collapse = "\n") }, if(length(y <- x$citation_error_reading_if_not_installed)) { paste(c("Reading CITATION file fails with", - paste0(" ", y), + paste0(" ", gsub("\n", "\n ", y)), "when package is not installed."), collapse = "\n") }, @@ -8814,7 +8815,7 @@ function(x, ...) fmt(c(if(length(y <- x$bad_urls)) { if(inherits(y, "error")) paste(c("Checking URLs failed with message:", - conditionMessage(y)), + paste0(" ", conditionMessage(y))), collapse = "\n") else paste(c(if(length(y) > 1L) @@ -8833,22 +8834,22 @@ function(x, ...) indv <- grepl("https?://cran.r-project.org/web/views/[[:alnum:]]+[.]html$", ul) paste(c(if(any(indp)) { - c(" The canonical URL of the CRAN page for a package is ", - " https://CRAN.R-project.org/package=pkgname") + c("The canonical URL of the CRAN page for a package is ", + " https://CRAN.R-project.org/package=pkgname") }, if(any(indv)) { - c(" The canonical URL of the CRAN page for a task view is ", - " https://CRAN.R-project.org/view=viewname") + c("The canonical URL of the CRAN page for a task view is ", + " https://CRAN.R-project.org/view=viewname") }, if(any(nzchar(z) & !indp & !indv)) { - " Canonical CRAN.R-project.org URLs use https." + "Canonical CRAN.R-project.org URLs use https." }), collapse = "\n") }, if(length(y) && any(nzchar(y$New)) && config_val_to_logical(Sys.getenv("_R_CHECK_URLS_SHOW_301_STATUS_", "FALSE"))) { - paste(strwrap("For content that is 'Moved Permanently', please change http to https, add trailing slashes, or replace the old by the new URL.", - indent = 2L, exdent = 2L), collapse = "\n") + paste(strwrap("For content that is 'Moved Permanently', please change http to https, add trailing slashes, or replace the old by the new URL."), + collapse = "\n") }, if(length(y) && any(nzchar(y$Spaces))) { " Spaces in an http[s] URL should probably be replaced by %20" @@ -8874,7 +8875,7 @@ function(x, ...) fmt(if(length(y <- x$bad_dois)) { if(inherits(y, "error")) paste(c("Checking DOIs failed with message:", - conditionMessage(y)), + paste0(" ", conditionMessage(y))), collapse = "\n") else paste(c(if(length(y) > 1L) @@ -8929,7 +8930,9 @@ function(x, ...) }, if(length(y <- x$title_case)) { paste(c("The Title field should be in title case. Current version is:", - sQuote(y[1L]), "In title case that is:", sQuote(y[2L])), + paste0(" ", sQuote(y[1L])), + "In title case that is:", + paste0(" ", sQuote(y[2L]))), collapse = "\n") })), fmt(c(if(length(x$descr_bad_initial)) { From d46340e5f9605c11ebd271497cc03cf6464dd920 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 26 Jun 2024 10:21:53 +0000 Subject: [PATCH 311/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86836 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 8 +++++++- src/library/utils/man/citation.Rd | 27 ++++++++++++++++++--------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 2d7938ae65d..81ef80ec8ec 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -1318,7 +1318,13 @@ function(package = "base", lib.loc = NULL, auto = NULL) citfile <- file.path(dir, "inst", "CITATION") test <- file_test("-f", citfile) } - if(is.null(auto)) auto <- !test + if(is.null(auto) || is.na(auto)) + auto <- !test + else if(!auto && !test) + stop(gettextf("package %s has no %s file: only auto-generation is possible", + sQuote(package), + sQuote("CITATION")), + domain = NA) ## if CITATION is available if(!auto) { return(readCitationFile(citfile, meta)) diff --git a/src/library/utils/man/citation.Rd b/src/library/utils/man/citation.Rd index 1be74545a0f..1cb889c678e 100644 --- a/src/library/utils/man/citation.Rd +++ b/src/library/utils/man/citation.Rd @@ -45,16 +45,25 @@ citFooter(...) today. Please give credit where credit is due and cite \R and \R packages when you use them for data analysis. - Execute function \code{citation()} for information on how to cite the - base R system in publications. If the name of a non-base package is - given, as controlled by the \code{auto} argument, the function either - returns the information contained in the \file{CITATION} file of the - package (using \code{readCitationFile} with \code{meta} equal to - \code{packageDescription(package, lib.loc)}) or auto-generates - citation information from the \file{DESCRIPTION} file. For CRAN and - Bioconductor packages, auto-generating automatically adds package - \abbr{URL}s and \abbr{DOI}s. + Use \code{citation()} (without arguments) for information on how to + cite the base R system in publications. + If \code{citation()} is called with \code{package} the name of a + non-base package, as controlled by the \code{auto} argument it either + returns the information contained in the package \file{CITATION} file + or auto-generates citation information from the package + \file{DESCRIPTION} file. By default (\code{auto = NULL}), the + \file{CITATION} file is used if it exists, in which case it is read + via \code{readCitationFile} with \code{meta} equal to + \code{packageDescription(package, lib.loc)}. One can force + auto-generation via \code{auto = TRUE}. + + The auto-generated citation includes \abbr{URL}s for packages + installed from the standard repositories CRAN and Bioconductor and + from development platforms such as \I{GitHub}, \I{GitLab}, or + \I{R-Forge}. In case of CRAN and Bioconductor, \abbr{DOI}s are + included as well. + Packages can use an \samp{Authors@R} field in their \file{DESCRIPTION} to provide (\R code giving) a \code{\link{person}} object with a refined, machine-readable From c98df1559cc605592097065f997be8a4023273a2 Mon Sep 17 00:00:00 2001 From: smeyer Date: Wed, 26 Jun 2024 13:26:43 +0000 Subject: [PATCH 312/546] try using external xrefs unconditionally git-svn-id: https://svn.r-project.org/R/trunk@86837 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-lang.texi | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/doc/manual/R-lang.texi b/doc/manual/R-lang.texi index 055d906c7f1..13c9535845f 100644 --- a/doc/manual/R-lang.texi +++ b/doc/manual/R-lang.texi @@ -111,20 +111,9 @@ preferred usage. Some familiarity with @R{} is assumed. This is not an introduction to @R{} but rather a programmers' reference manual. Other manuals provide complementary information: in particular -@ifset UseExternalXrefs -@ref{Preface, , , R-intro, An Introduction to R} -@end ifset -@ifclear UseExternalXrefs -manual `An Introduction to R' -@end ifclear +@ref{Top, , , R-intro, An Introduction to R} provides an introduction to @R{} and -@ifset UseExternalXrefs @ref{System and foreign language interfaces, , , R-exts, Writing R Extensions} -@end ifset -@ifclear UseExternalXrefs -section `System and foreign language interfaces' in the `Writing R -Extensions' manual -@end ifclear details how to extend @R{} using compiled code. @@ -2092,13 +2081,7 @@ they find more appropriate. @R{} also provides facilities that make it easy to document any functions that you have created. -@ifset UseExternalXrefs @xref{Writing R documentation, , , R-exts, Writing R Extensions}. -@end ifset -@ifclear UseExternalXrefs -See section `Writing R documentation' in the `Writing R Extensions' -manual. -@end ifclear @node Syntax and examples @@ -3710,14 +3693,7 @@ platform-independent way. @findex .Call @findex .External -See -@ifset UseExternalXrefs -@ref{System and foreign language interfaces, , , R-exts, Writing R Extensions} -@end ifset -@ifclear UseExternalXrefs -section `System and foreign language interfaces' in the `Writing R -Extensions' manual -@end ifclear +@xref{System and foreign language interfaces, , , R-exts, Writing R Extensions} for the details of adding functionality to @R{} via compiled code. Functions @code{.C} and @code{.Fortran} provide a standard interface to @@ -3736,12 +3712,7 @@ compiled code (primarily compiled @C{} code) to manipulate @R{} objects. The @code{.Internal} and @code{.Primitive} interfaces are used to call @C{} code compiled into @R{} at build time. -@ifset UseExternalXrefs @xref{.Internal vs .Primitive, , , R-ints, R Internals}. -@end ifset -@ifclear UseExternalXrefs -See section `.Internal vs .Primitive' in the `R Internals' manual. -@end ifclear From 7918d80e5397726a2d901566ae4d5a8ca0c5d0b0 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 26 Jun 2024 13:37:27 +0000 Subject: [PATCH 313/546] Move isValidString and isValidStringF to tools:::nonAPI. git-svn-id: https://svn.r-project.org/R/trunk@86838 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 4 ---- src/library/tools/R/sotools.R | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index b5aedc7916c..ab4527bade9 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13374,8 +13374,6 @@ Rboolean isDataFrame (SEXP); @end group @end example Some additional predicates: -@eapifun Rf_isValidString -@eapifun Rf_isValidStringF @eapifun isBlankString @eapifun StringBlank @eapifun StringFalse @@ -13384,8 +13382,6 @@ Some additional predicates: @eapifun IS_SCALAR @example @group -Rboolean Rf_isValidString(SEXP); -Rboolean Rf_isValidStringF(SEXP); Rboolean isBlankString(const char *); Rboolean Rf_StringBlank(SEXP); Rboolean StringFalse(const char *); diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index e5f11852519..2c6a4519b24 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -687,6 +687,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "Rf_NonNullStringMatch", "SET_TYPEOF", "TRUELENGTH", "XLENGTH_EX", "XTRUELENGTH", "Rf_gsetVar", + "Rf_isValidString", "Rf_isValidStringF", ## in the non-API header R_ext/Connections.h "R_new_custom_connection", "R_ReadConnection", "R_WriteConnection", "R_GetConnection", From c997db25ed36e1e984dd8bc4e60d7e678e43496d Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 26 Jun 2024 16:40:57 +0000 Subject: [PATCH 314/546] Add R_shallow_duplicate_attr to tools:::nonAPI. We may eventually want to support this, but better to shut it down for now. git-svn-id: https://svn.r-project.org/R/trunk@86839 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 3 ++- src/library/tools/R/sotools.R | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index c3172c3e7af..985f2e1074c 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -134,7 +134,8 @@ \item Additional non-API entry points added to those reported by \command{R CMD check}: \code{IS_LONG_VEC}, \code{PRCODE}, \code{PRENV}, \code{PRVALUE}, \code{R_nchar}, - \code{Rf_NonNullStringMatch}, \code{Rf_StringBlank}, + \code{Rf_NonNullStringMatch}, \code{R_shallow_duplicate_attr}, + \code{Rf_StringBlank}, \code{SET_TYPEOF}, \code{TRUELENGTH}, \code{XLENGTH_EX}, and \code{XTRUELENGTH}. diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 2c6a4519b24..b73cdf7cd65 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -688,6 +688,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "SET_TYPEOF", "TRUELENGTH", "XLENGTH_EX", "XTRUELENGTH", "Rf_gsetVar", "Rf_isValidString", "Rf_isValidStringF", + "R_shallow_duplicate_attr", ## in the non-API header R_ext/Connections.h "R_new_custom_connection", "R_ReadConnection", "R_WriteConnection", "R_GetConnection", From 6addc5ff31c2d4f621983568571af5b2e6188826 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 26 Jun 2024 17:12:18 +0000 Subject: [PATCH 315/546] Mark SHALLOW_DUPLICATE_ATTRIB and DUPLICATE_ATTRIB as @apifun. These either are alredy safe or can be made safe without changing the interface. git-svn-id: https://svn.r-project.org/R/trunk@86840 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index ab4527bade9..723d3eb9050 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13548,6 +13548,14 @@ is modified it may suffice to call @code{shallow_duplicate}. @apifun duplicate @apifun shallow_duplicate +@comment FIXME need a separate seciton on attributes +At times it may be necessary to copy attributes from one object to +another. This can be done using @code{DUPLICATE_ATTRIB} or +@code{SHALLOW_DUPLICATE_ATTRIB} +@apifun DUPLICATE_ATTRIB +@apifun SHALLOW_DUPLICATE_ATTRIB + + However, at least some of this copying is unneeded. In the first assignment shown, @code{x <- 1:10}, @R{} first creates an object with value @code{1:10} and then assigns it to @code{x} but if @code{x} is From 03487e8e8d756766864683866f52ecd0b98c2735 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 27 Jun 2024 06:08:23 +0000 Subject: [PATCH 316/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86841 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index bed0e350683..5962aa2d65c 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -8136,7 +8136,7 @@ function(dir, localOnly = FALSE, pkgSize = NA) ind <- grepl(.ORCID_iD_variants_regexp, odb[, 1L]) odb <- odb[ind, , drop = FALSE] } - if(NROW(odb)) { + if(NROW(odb) && requireNamespace("curl", quietly = TRUE)) { ids <- .ORCID_iD_canonicalize(odb[, 1L]) pos <- which(!.ORCID_iD_is_alive(ids)) if(length(pos)) From 77686c81b7a5f72877591d43d12245ddc8f4d9b8 Mon Sep 17 00:00:00 2001 From: smeyer Date: Thu, 27 Jun 2024 09:14:45 +0000 Subject: [PATCH 317/546] use local xrefs for HTML manuals but CRAN links for EPUBs git-svn-id: https://svn.r-project.org/R/trunk@86842 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/Makefile.in | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/doc/manual/Makefile.in b/doc/manual/Makefile.in index e1b2eef58c9..d4aab2bfa13 100644 --- a/doc/manual/Makefile.in +++ b/doc/manual/Makefile.in @@ -96,7 +96,9 @@ docs: html $(ECHO) "file $@ will be missing and linked from CRAN"; \ else \ $(ECHO) "creating doc/manual/$@"; \ - $(TEXI2HTML) -D UseExternalXrefs -I$(srcdir) $< -o $@.tmp || exit 1; \ + $(TEXI2HTML) -D UseExternalXrefs -I$(srcdir) \ + `test $(TEXI2ANY_VERSION_MAJ) -ge 7 && $(ECHO) -c HTMLXREF_MODE=none` \ + $< -o $@.tmp || exit 1; \ SED="$(SED)" $(SHELL) $(srcdir)/texi2html.sh \ $(TEXI2ANY_VERSION_MAJ) $(TEXI2ANY_VERSION_MIN) $@; \ rm -f $@.tmp; \ @@ -213,21 +215,32 @@ version.texi: Makefile $(top_srcdir)/VERSION $(SVN_REV) $(ECHO) "@afourpaper" >> $@ ; \ fi +## https://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Configuration.html +## EPUB cannot link local files and the system htmlxref.cnf lacks R-FAQ +## (for the HTML manuals we use an override to produce only local xrefs) +htmlxref.cnf: + @($(ECHO) "R = https://CRAN.R-project.org/doc/manuals"; \ + for f in $(OBJECTS_HTML); do $(ECHO) $${f%.html} mono '$${R}'/$${f}; done) > $@ + html: $(OBJECTS_HTML) @(cd ../html; $(MAKE) index.html) -R-admin.html: $(texiincludes) $(srcdir)/Rman.css $(srcdir)/texi2html.sh -R-data.html: $(texiincludes) $(srcdir)/Rman.css $(srcdir)/texi2html.sh -R-exts.html: $(texiincludes) $(srcdir)/Rman.css $(srcdir)/texi2html.sh -R-intro.html: stamp-images-html $(texiincludes) $(srcdir)/Rman.css $(srcdir)/texi2html.sh -R-ints.html: $(texiincludes) $(srcdir)/Rman.css $(srcdir)/texi2html.sh -R-lang.html: $(texiincludes) $(srcdir)/Rman.css $(srcdir)/texi2html.sh -R-FAQ.html: $(srcdir)/R-defs.texi $(srcdir)/Rman.css $(srcdir)/texi2html.sh +$(OBJECTS_HTML): htmlxref.cnf $(srcdir)/Rman.css $(srcdir)/texi2html.sh +R-admin.html: $(texiincludes) +R-data.html: $(texiincludes) +R-exts.html: $(texiincludes) +R-intro.html: stamp-images-html $(texiincludes) +R-ints.html: $(texiincludes) +R-lang.html: $(texiincludes) +R-FAQ.html: $(srcdir)/R-defs.texi ebooks: epub mobi epub: $(OBJECTS_EPUB) mobi: $(OBJECTS_MOBI) +$(OBJECTS_EPUB): htmlxref.cnf $(srcdir)/texi2epub.sh +$(OBJECTS_MOBI): htmlxref.cnf + info: $(OBJECTS_INFO) R-admin.info: $(texiincludes) R-data.info: $(texiincludes) @@ -398,7 +411,7 @@ clean: *.ky *.kys *.log *.out *.pdf *.pg *.pgs *.ps *.ps-2 *.tmp \ *.toc *.tp *.vr *.vrs \ *-pkg.tex refman.i?? refman.tex fullrefman.i?? fullrefman.tex \ - version.tex version.texi + version.tex version.texi htmlxref.cnf -@rm -f stamp-* -@rm -f *.epub *.mobi rw-FAQ rw-FAQ.html distclean: clean From 2c4d0df60af486b1f90f67d1157e2a2301222224 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 27 Jun 2024 12:00:31 +0000 Subject: [PATCH 318/546] Cleanups for c86803. git-svn-id: https://svn.r-project.org/R/trunk@86843 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/Rd.R | 2 +- src/library/tools/R/Rd2HTML.R | 27 --------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/library/tools/R/Rd.R b/src/library/tools/R/Rd.R index b7a1d57ac81..e9b79d6b916 100644 --- a/src/library/tools/R/Rd.R +++ b/src/library/tools/R/Rd.R @@ -1173,7 +1173,7 @@ function(dir, level = 1) rdxrefs[ind, 1L : 2L] <- cbind(sub("^=", "", anchors[ind]), "") rdxrefs <- rdxrefs[!nzchar(rdxrefs[, "Anchor"]), , drop = FALSE] aliases <- c(unlist(aliases, use.names = FALSE), - names(.find_HTML_links(level = level))) + names(findHTMLlinks(level = level))) if(any(ind <- is.na(match(rdxrefs[, "Target"], aliases)))) unique(rdxrefs[ind, , drop = FALSE]) else NULL diff --git a/src/library/tools/R/Rd2HTML.R b/src/library/tools/R/Rd2HTML.R index 557bd589b73..2ee5df5ea78 100644 --- a/src/library/tools/R/Rd2HTML.R +++ b/src/library/tools/R/Rd2HTML.R @@ -1362,34 +1362,7 @@ Rd2HTML <- ## The following functions return 'relative' links assuming that all ## packages are installed in the same virtual library tree. -## findHTMLlinks <- function(pkgDir = "", lib.loc = NULL, level = 0:2) -## { -## ## The priority order is -## ## This package (level 0) -## ## The standard packages (level 1) -## ## along lib.loc (level 2) - -## if (is.null(lib.loc)) lib.loc <- .libPaths() - -## Links <- list() -## if (2 %in% level) -## Links <- c(Links, lapply(lib.loc, .find_HTML_links_in_library)) -## if (1 %in% level) { -## base <- unlist(.get_standard_package_names()[c("base", "recommended")], -## use.names = FALSE) -## Links <- c(lapply(file.path(.Library, base), -## .find_HTML_links_in_package), -## Links) -## } -## if (0 %in% level && nzchar(pkgDir)) -## Links <- c(list(.find_HTML_links_in_package(pkgDir)), Links) -## Links <- unlist(Links) -## Links <- Links[!duplicated(names(Links))] -## gsub("[Rr]d$", "html", Links) -## } - findHTMLlinks <- -.find_HTML_links <- function(pkgDir, lib.loc = NULL, level = 0 : 3) { ## A variant of the above which splits levels for base and From f9f31d1f1234a4e94978405b727853c131629d41 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 27 Jun 2024 12:00:41 +0000 Subject: [PATCH 319/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86844 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/sysdata.rda | Bin 9239 -> 9251 bytes src/library/utils/R/sysdata.rda | Bin 16103 -> 16324 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/library/tools/R/sysdata.rda b/src/library/tools/R/sysdata.rda index 5c3acf641f60786bf3afe2bca3599d7ff2c05918..d5a50bfe59e0f95c55e6d67b66297e71c8e34348 100644 GIT binary patch literal 9251 zcmV+;B;4B{iwFP!000001MPija~wCaAV)mJLkD%)l5NRld1h_TOq1-JbZqP{CF-Co zQXDpA&2xvM16_sgu3=rSqnoXW7x5zAFWHap!+zSY`_13qPny|8RUrXXU!*Kr(!5qg zi9jL?NF)-8L}sIKxbxTI@?V!{W@ct*=H}slcxGniUmiWqZO+WhU4YE*X69y=;P3U_ z?fvb>%fsD9pm(TE8%7iGZ$QaKcvb=NUsKFkLP(mNgJh7V=SkCzLM+gUC(?R|@9Ks~ z`e|~B7-nRjgg(JCL%h-QL^8mnX=C+vz`+-ZWB9IVVAk^t5{g#L^>+gf8#S0zj;gS2Zh*0<jYjD)AaakQ3{s=Or@|~1e56*u>szFDlNtuazEY%jk%k?R(}gr^M)Ep=r1xjrA?FbkGk%${Sp00Vk2cw_BzkggHNQavpU+ zoIUEB)X}M^3n$`*mW@;)&sSQJ-U&UHs zMKQV1b`jV0I!Nt&+b3QJYxE6-hs5GzGS?{=6wk9X z3R&mmL=-?8=W3^K_~ec2P%MR6hSSLugJ()A#?*yg6#Ch;B@Cy zGD92H>EB4RDLC~vvC#YtaV{RyzDJPg1q;+M%HW*U^ildP19>;k(!7St7KO#kZTW7S z2=-WF<+DIf^$1RW%R{YYbuBKAU)!+AfmS;3-LA=$Jb@Jet#GYpItHwKYdWzh zYTVzCDqpiBD>OY*KSqMS9Eq!-&Duh7+c-e;wrikbxoEpi+ci*o+AbHAB|FH0aYNDm zxXJ*YXF37QTMHYx3E*@gA6Qr~L)pM8z5+nQH@h^4EM<7q@mbTge8e9Fb1a}WGxfb=0$*YsO3p? zvMKG6u%m#yC?q&nKLLSj#y^c2L%;II9IQ*Qnv}K2dut0br|Cu+6%yb zG{LHX34rzyV?)9N(IYnS9(Bd?#;8zLJsU62?NQ$Yt1p!5@}i~%YYz$stIMa%Y?H=g z7^6PT!c(S7-DY%yS_(;%@sT*Hn57)HOivQm1Q@^!#hMsJ0R{ckktj+4(1J%yPWrtV z4g+Nnzn|8WONCEJ|D9o20SzNriXb0?1ahX|mOwdZkc|~(lQJ#8C6_m?2*lJ4Wl_gM zMS9X4A|Ky>zIpbQj8aYGY? zp2!H-WQ16_rRgIIKyeYhKWwC6ikz4>%*nLyGr2I44Brh$cBcmv4Xd{2`p3X%)KUwq z&@*K53S*@o$g?2~Rei^RF;~n`s9h#Y5hzT?sV)#6;7Z0yx~3mS1lB#U6+OZmT#QRV z$4kng2X>sQ%zGW!<1}4@#@;mrnA2@s%&9TFu zJ!Dd3H!Y#qBeqpW^W5&D0cLll7P_K^Ii@fg1qXK@j){9+N9<Y3;38owX;xy-Rakz0jwqA$&^@M{?gbYNf2?MO<-E36YI#1^9C{=|t#QH2 zb7DP$(+1KOCveFlV6~AqZ+HhUdZaI{#`BQHAztu~^&royTmJj+@&^7yG2&uo9I5A?TX3TH4O^N5~Z|@^K+$Z(q2xP$_riCjH88hHOT=j z0aSu3=Ug|iu+Kg2j+pBaR3vjf+C(=+4}H7~0M?NgEcYkj7LXS9xt@okc|oi%y+G6- z5>&vwzHavVTx{k}gacxQrQ@X=tD8S*nYa&FIk7F@)8(0TNdjSOC${i8oCtB6JMq!g zGJE2q4(!`O8@v3bxV2X1VstUd`D!+pQJw2Er~J!Sitf7brt>_n{z{V1_|;P^bgrj) zRMeT;O|kODd0|pqN&t$tJ%uSQ_p~Au{EJE6SBudDpB8iMt7$gli%+rmes3ktDqi^& znB8E!oBBGs=M(BwAAJf_9QCU*O!C$zERbCGDM0w`Q-F}St0^Gk!C#KSvK#+u3dwo_ zI9NDVW|X!hm;N#W0`+a#xqnLn4LBlBD|y+!UnG@|b=_Y|ab*AfH5n#5@iToCUi?H_ zgeyPE3x7V(ha)IWcqF^@FDDSyudhx5;n?SS3|A!iQ7-A`qMVh-Jj;Y zOgY+-mr>BA2tZn^2m=gP9wG{mz92#Y2|$VmByWgyHboGTfrOKp@Id+&E|Mvd8Yq}i z3Nv8>l~Gcl;0gldXhDi5LI(W(8_1`DxWP*Ljubq&n}Wth5O`atAriIJ%JwT!D1*_2 z8Ra#MCnP)*L4_5b7mD^;3K|G63>SDgwr~mgAc71jmK15o){}HqiZd*x09E3oh{K2) zM6_WU0f922*|!iQzLEuus$l}5YG@&? zO~e;gfD`t*5@bk75|IX8VWM@_SVJOCO28p$LW(-5;vK1a3#+1Ifsu9cHBplNf8h13b9B(fZs`+vNV`#i)u*Z^bXRwuQO=|&0}5=u&t<#^JHfDGR~ zh?vr4o|nDRDbj!sBW+2FE-i6L){8luOLAl>nY;txrE46VjWG@1Z%Cn~glZ9AO7j?G z%2trJG#FpHBo&;D?~fE>N}IErnS7QrDcvI6G-(beqp8G|Qji>6N{Ln?OeqOLh9vZw zB!iy`IHf(4qD~_Sk|R!O&D{*|d#VRl3P4>(fMndO%$4I%$;{3MqtyAD2}cd5T8Tuh z#;STS95r0jq)^oO$bbk!C2cB^DB%SXAt{waB`B3xy2B$=$&jnzDU~Ie@YG@o#61Pl zk_lF+{Y&>E~;4PIT_F<}n?dq(X5 z%tBX3S^Z|9Kx`&r*l1!a)*T4w*jSE-KT5<0RLh$>h*Vgi2g~= zsoZ`DdY0{Ewe4g`GxGB*53gKLqf8no1cz;%P^ZghS-#|FS;q7HUV6l3JeG3uMZ=RX z<6rucABY)`_Uq5dd~@_;ZrkazK#TS;<;@{&!T32k)piHD^y`n(d=bap#&;}x!sc^! z!Ul$s_7j*uz9CCb5IPb$@4k3^GU3s<5i?JxcCe?$#e4wb>pxY(D>X{9Vx&1 zXwQwK4%ME-$9uA*oa&s<{L{6!J?QiKQx+%#8!8;hjr(Iz()AcCeyhVlU+prlac&#N z*f)b?js8{d5Ex?ZM=-|Ns$JmAYm5j+KdPW@0~W+&Y0oYI($S)8yDVe@=zFoj4C2Gp ztjQ}(P3aK^!hh~MY)_puv>gOA3=(rhD82yd(hisxT90)?09G#z*0lQJw(~PG&9hc(uwtxp*8#3 z{%-9>tQ&NwsmaNQvKB0BTAeA-@7LE^3%STQ*H~ix^%|ePXFpH%8IHh#4|D)0vwZ)< zXbg=x-L$7iM+Y@*W#Tz3QQslwkUSVQ7drlXQWF~;i4ImPJMFg56{hZC+t!7 zzqSMBxejFXN0>L~aI|adRT5d$wxiJXVEYBr1$ITgqwU0Qb8U|}&^@;LXfT_?DA1B0 zfJ?`=q(JK*Q^G@6W6Qe+95OBDgil11`OmfFJQ)5u=8*+`_FV@=KQ1PQ;foOD$8$pL zI#(tG#^dzB*z~~I^uXB6^uXBkz}WP_*vE2U?4B@e;`1?Jh(V7A?7s0>>PA62YW6RC z%o*XM#jUwcE~buIjvnc=Lq%XkbV#TXpK45f8_d3SeGQn#jPAc2!gj!jjcH>Y!26FM zYDWa;`Inq9*u3b+tk%D<2vwGT^>Eu)doW{~?uqs?HgU9X_g)_CY#%-PF8i8v?CmQS z>Ri_1e`B2%_v4u8X)sq_)*kIYI?|+*Jzs!{#e^~0DJL7_>~>}7fx5d=UBEiVi2ePe z15L3ml#_OMa37<+3{AGqF^e#=gbVX6&)=*m<_P#y@!zg#eyoI&c zno{kx4X$#( zVrEs$93NEb8Ge57ej3b}?1H(O?7eF2h+($u6lV=TPe}u9X@+L9an7iW`$0m>WXw~X zP`p*^0Cz`hh~+bj*J2G64^*x8d|eFi{aV}sZ9i3Z(%v)E{g3-}<0I)IX2wzEGqWQw!%SjnW1Xq$G0OF1S55qI9VR9$ zt%er=W!3xGE>k~NBu%cnN5YoWBoC9)($~8Zt?W3aMs2p|W$$E2Kh+7%%SS(I4}4IN za{TBthc!QW>6mQ602?S#qlrflUpxEx&3nvG0zCmf#|(@&s>#^2gi(5igPorr#@jsY zvClT_QEQkN{2d(lywfX=7u&n9;8krK_&DI!lWKf-2SjhZqRkrE9UwjF21}BPFCRI& z-}jhMjzjxx&y)V~QR2>FOBnjEW1lZKGzMJXXFPR!=co8!sb)$8pjd^gDZ(KI>7rd^ z`IQu&n*1|rY=7y1LT!!^;&%a9fxafkKE!V+rl2!{mY=4-pZT!JdTY?R%E-A0@i~h5 zduGOmNaSxmcRpsNbsE~=p#m9b?tGQgX?pkJ&7k)$bieJo{8p`)p$w`>O=uASgya=+s?h%+u!Dp%k>@7rH!Kw`w=+@F4k+?2aVdJu}E>N`D$@< zEY|h{d(k^$sOfx&!K+MAYnrs<%a6U5`3k;?e}O5rvy>g z>f47uG)S8|dS4Lh6v8!!hU|ip@7D|Y!bW91zp)`~?=R{PtcV83{l>wA=g%L$t{;%d zYCQJI8%oC#kpa&98v|agKltVU_`m$$#u2f9`QJFE3-#ScwI^q(j*rYk*JmfzoyH#Z zbyJjlSASJ}*my;o+nyIRUb#LyN7s1byOH<0{;&hwZ5+}j^~15`uGgRa^8b9`7`z#I z@FthZL*lf;*Y%p~bxhi*!ALpB)RJZQm^Kbf8u}!7LymcUck7S+U;e}Rb=ww=1(ls0ST|gd z()0@-@$akOeNCqy=0sZ*w^U!mx%)G&)E~Ib#*f5l{6w5lg2G2)hk3$`#v|ymMUJUD z5*t<2Fw1o|?u}X}IrZZUd<&vDsSXD;8y)9ae~~A$-ctZ*j{TqHK`}2@&MbCQ#r9r!W7(j zvDD~Gh68WUtct%X;b^Vo@du%qgEz2a1PR9+_FvWKInH~3SD__OF-KiTs zX@xl(klEM-?CUr=quUgt_t0X;%>tO3L1;4eCLPy?$V+zb{o%4$LP40EvC;wJP=P^!!W7f!J(#wwbXQw#t*{5yusN`2+c>c-hM z`sMl~1IE;M*cS*U>;7V~vZ(+{1u>ATunL066VnG)Q(1RRG%AwH%NuIt)s0f+?1M3K zF}@7)9XW2}$h8U1w%f@B&u{#heP;~(i(SUt)T->g-<{7QC>Q+gezr~Bia$fCdwNx#<&72!K1GYBvS%7L5mA1A9 z0ELl&U#Y=vq(fC>ACAk#AE=$&hf2OuJ$v_)Neg-dS_-{NI5#3uAK%jvC{B-lAJ4s_T@k(}dqwJ}UNwWUtM%0^}U26)6$`82i?8xK1K z6v{hV(#`{OVEZsqRgbn7wEAw_A-V}>jtfenZMtCCvQMBjb{;f#9bGI&&s++Ir)AKl z4}Gyb5ZaO-?kPd~O7e|oY}3)yEveIpp~%BD_&&GFm91glaWztLN*Z#$vufcgK5 zSjUs$i9e!TR2@r&LO~69R<;To;{kFV_fz+Xp}UUV&&8i5lAI&C4cy>-Uw;J5aKo_i zz=yF?-5pM3d#SG>cIzn)p0QlGjs6)JnJDb!T=pR--#kxQ8i-r`wVr%)QF7Kdw*Am- z5goc~vTqf)v%XjLD~%cp8fy79$+uQrL&3XMe`OwruHX2fM?5nyY0uQ(jPctXb(mkT z@su=aI3l3=1$W4GB0v6W))1H0={MeL-H8igYeW6@WVM_h?;%R}#G9qeY$Yo|?|FMOmoGKW;qiP)Q7*0p@{w z97m7F)qgkTaktye^=K2nn3!XqnB+)ThI-+LL(}mP3dq%8Y}a;c4K^1%<1@f!z2Gq+*1C@=}_2fhTx#Yf$9Mfy*4JxtQHW#`%e%YGJ^v#Wu z81HB7<93aQ>`QWz*YQ!eO+iEtSb&Yb0sW!QjY1_q5^y%znAB9cD%J_^6SvcfbAb(A z&DjBAeYFiTe#t3qY-S@Th3ZJas8|gP+CDKYDQG+N=Mo!(+A;ZHXrrb_VQA4N{NDgA z9Kgghqw&7VoAvFcPddZ~S%7|nay=fe0n*q_r8E+7YF-Yl|C@RZ)}|hT?mPu~3rQO^ zRxPA0;<$~Uh^}``-?eZt{3Q1I7q^OHl_`t(&d}0~M?GI22>-TW;qJJtRxbWvW=_Pu zN9&E)iy6yCv6L4Qn7G)V(;kVhg*Y}dLQzu1rdY|J!j3AG%c^h{idA*eR0>r|p=M)I znSm>h2NX6Z{BY|O%jY+-F3SUF>bu+f+u~B2$aiw$I-3d8`G?3cJ0MYw8aXC5*jCw9 z$!3?A!K`p|=~ptD1)z2&Ul_k)uhgHJcH^h0DU?fz*G{@VIX2k`){{?WLhV+3L)B}n zIt}Zn>qB+3f;#(VeXoDq4@u)+Xg2_JiuUOT;?^Aar3#-Om5~@s#Rp&*?!1Yb?B`cw z1-AwUeB=2V2Yi6a}7fN|06!q#{|S(3Cd zE76#uv;07h|KuPR#EnewcLZQ&W|{rG^xq&ceWuU!nLg9!zs55&Gj{?0`(3&y%qJIX z#^()YE~dccmxsIYZ?5qg&&4BZvpX;FL)AMp(0$XBzQ?{$i#Lwk{C-6(tMP*amPaG5 zE%K!66_)UO@|=wQ_>vKowk6-~t#SG;!*hXk;2;0^`@d&9p<5*2o#4P_cDch^i)}$6 z_xH>zx0x~8U>6TIk_~TzeYd<}G-qaJZ$SBMTHF6j@n`cJ8zPw($%07Y_s9zZw;*r} z0=FRJmPE2Fk`^L`gJJ5>1pu6D7HcEllP`YkARHUbL1Mt>r~)dC^*4w3ZjG2a3nEz*$&yHxMY1B2Rgpv*%7SNQ;F&7Ci|lSx z(~0}e z2E~I+#MM}L;~uhGLObk?LK5i6HhVRtSYvnexKSv{X3H|Mb8}C`H6&M`Q>PtvvNhc} z@Z*d9%($7y#I&&J8ovej$aS^n#K+4sF2N#{09};qPhL7fvMj-9@5R?=9Ep2uZXL!K z4zmu|phH2+lzM#q(TT@y;v1wOJHR*g%pe&(njN%TFC8zLZSiG9s$4HTXLn6tzmhhz z9qKVhhl3a0EwMhuGn9||ORwz{gJzj_OJQ23@EWUSk2rl!AzpvM2kj}$C+cgD*?EFs zfV+1={O~eY5HIaHZNp4Gq|8Ua>$;U52eHztJhVr?k9Ut=WqjUc7yK}hMZ#iHe*zk& zhZpAENbe5Pq&9gaDP~5*K4Z%~-W(kdC?EC|vBGG2OQ>9@Jhue{}R{2QTp9ml%zjGOGT* zGx%Hed|Cc6`zQp}-&rWJ2%Nt`K7;!J50XG&`m1faCGISF9`qso&QRi4DC@+3x; zCo!r#iBaWAj4DrJRCyAk%7Rg!jbhZsM2!4IjKV~W;zW$nM2zx8jLJle>O_pqi5L@k zTA0Ywg6ahxP!0ot%~Ex8rK&!ulsC&~1XQbq2|`<$G_xv`W>#g=%&JV9S(QmMtFo4H zKo_>knI{2i zoJl+dbIf3yVGa~90NIN(v4?$Tg;}2IJ6F=iuQMBl85PVVVpb@#KbXzHSjZ#_o-de9 z1Wta-@x-NJm10dM|l1O&!6F8ACXvtX9FI#AuPaC zgr~&V3QrZDO?bYC=fA`AKhl2vFL<`$c>vEtcy{1<1kYo5p2D-6@M4ZL^K|}}&*J?; z!)*=tTmoR@>dbVrI^C>JH>=2?>1K7hS^ao6tIFa!^_b60J?0;y$NcZ?`TrLOdO+>Q F004d4*g*gQ literal 9239 zcmY+FQ*<2wgM?$-wrwYk%^RoTjcq%PZQBhRTenFX+qP|E|Fi$g?wmO@-`hM6X$&0L z{|fTbU(S<=caH3*{-6|M%jz8kKeK1TCv6RQN+Zp;Dq%b*Za?RxlPOwMW~>fxKwK0C&r!(3be>Uj7T^r3WTVEyuOT# z?_MEJPEJ8iUfAzx2^Wj6f3qe1M-vkp&?6rv77iBhUxwS8TiZ)UL|11;vt=lYlQ=uu zLCG;UH4uB>6Kt07$tLOfw9KsW^&qldSwi$)+e`|4vr%fGUV|$JG}O4_t@JwX zC|XMTuSG#}SR<-G_+IHzy4$>RR5p*^wYaiDpdGy6Zm%p!boNdZ_kW0=Of54M!G|40 zTQ;{tdR!ODLBOSGr0G2`M%^VclMK&pb6;jf-`0pzFq!%dgzf-YNS}T|4#z~C2JZ$j zJIYqMgWFvuu)%mQ&89gf(QyE=3DzFrCdk#RO?zG+oS@W!ZiwI3xZns0)z-l5v`-Rd z+DP%v{{TMyFsqD;lAN_1Z18L4CKuuod^Q*Yof$->x?HNUa48LxW-(tCcRN$R&?9r_ zjCD$mBXNnB)1!#`U}%bx^XdM!;Ek^DDwh)9mY~VwWd6HM(~2m!wd6kUA@{d!l>VHt zL4Qop4O>Bc{Bi|r+g+k&^Iy89(sX|*Ya#d;n3J$_Gd@3rU_U&UFL0v=Q}RmvK+Gn+ zoo)gkCSw!P-79t0Txks;V*K~TGFOS{M{v(#P)a*^>ueTd51bhh7s;{5ypYHNhAA)+ zs{-?ZMdm&fagWSRZe9e^sl4qoF!B_^j%~GMu?S)pIDTgkg6~}QmA0yCxCnb;t-pH2 zv+J5oO9=JYxQN1eR=v?;)>Au~rYnhb8oK#b9%E1)J)eWOc$BKzdo6 z=tOFoiR6W7b2tM!x5h(RJcpbFpV>PKG*n2-g}X5MHb3nk19&EzJAZH#Bq&&ECHV-7 zxa9W1Ia_9VwM@*Q&A{3N6+a1Y@Vk+1t&^}q%cS6%5i#sH)Hxe?`A-QZmT%GAnBj*7 z+LcpiLJhXN&D>3d#C>~AYu@R(?(lJ*Fz5+eSi=aoyA@zdlNj$KJVN(nNqM6$kLBMw zBApdcOkya*X&?egDa>46Q1~u6^dru$C=St_GyR_^lmZNRc88>YC5K})) z7d2z&tBw;6EBBhPBl{j63bL-TBaZ|iP@v}F|c084)T$zxVQ}{r&cdirt*v; zJL5w`@IrhYVLj1g4xuxce0zoT5emqBywr6tUY)PhMr;^1i2}ec+vIcA1#pORJ)zM5Q$1a+zI$I zFLZ8eFQQ!n_lPu~A!jQntklNimqK@A`UtV++V}S)mNT+l zYf{WE>uXQ2ur#nrY79-v3=y@Ebez@P@OJgrQ2$yqgOb6(MROvP$jgH9&~v;Be1LMM zJ*ta>Ijq~~^B`CS*5tFh{dDAWWDZ!$Z?;aq+z3mqRO!)9cs)7_W@(IDwhEL>7|8VcWr7Ix(cSPtwGyPUT5Vjy!yeJzAr&PD=RYKbn%V87a>+muYts z8@ciD(M0p(_*m#_UEsgqnK$Ep&vr6@7D}~py5LDsN3Vt${c<<#F~NqDXuTtRDh$k? zY{q?&8p9dLPZpxP zTj63dh98U@N2E;Z!&S4^i%SGqq(;wNFTS0+$|&#VN2efx_4_Oi9J5L%X{IqY12~fq z3lKi>ibTX^Jk=G$!qhne5k0^=IYa5Y0zMj1-n$dC$)h!;Ui6$((hz4wmlGEYo;3|q;1mjN?#tkOnIGo z7r^Reyl%?P$aL)aA-|4Ve>6hNZWD(XkmR{UOUIMg>J6LW2O&-1{h5t=Q>>y~_Ro`~ zk?$YkR|7hZcUlZ6Uu}Irc(sPL)hr-rK?e#vSW4igUK$Or`SYW9#q)KSKD)h_?TGbb zur}G73_d$fJ0O~w(%ivf&^a|I`tn3PImx9p0!f(h5iQw}sIYPproA8+wO@T1qe@9SR2ka+=O5}ZYhZB~`DOPq`%QNPGm-PsWuvDGllXB30I*c2 z*@y;%MhL=t<2h;OP&)@<`OMw8h((Sq>mf`c>K7F&K6G!PzFSiDTE9$9Hm3)a_3Y>e z=scvvE}|{=(|^5huGZ5=Zpa9uA&?lFS&ypb#=*5+9sSjl2Cy~^i7~*vky11};*wjV z?BAWz2$`iGbnXwW45P)O|?eu6lu^D`s32;nYeS+G3f7 zl}hbmje6)>W;q)mhJF}Ea?vx}-$V#pe!g#FD+Uz{xf90Hcj;TTA>c1wgB1yX0 zjtIt+h{N=Zy9=F&^VHFs(Bv&v!}_VZK#Hyb`cxk{D{yJe5=8$B$4*yHcc^jrDzz_K z?Q_{%33ePwc9VlJv89c7V$X&1$QFd3$>H$DC`1u*??*v-b@#Td9a}vCW+N`x@s+$y zTTZ=X)ME9x@3I|x8-Av76}aYE>YV(TzN@TsZTSg2RJiLeZBK>3itvF^?>^I&8hOE; z_bbFHNfBl|TG4K@o7&7bxxL(!Pu3*5W+dA*?*2I>;IlKo_1obEsr+S6+dT6iQALi- z`;arpY0?txucJ1n=#*SvZjiak=OR+__JeEvP00kEy`15@IaKJ`dgJ$3IuyZ;U~by| zUEmKDM&k3lzSP|jmN#1t#i#k>Av&T*`ZhR6|7=_q-~0sW2d=WDi3h5++53|27v4qSzqC3OHJ2kx`$Cx?-ik(4B%U*35Wl_86Q z(=LeVMVx3Mr8;Xx>G)fL{c+Rl4;Pek!p_Il+N^fFRG16cc_Z5k<#b0 zr7$|(LswNsdi7&WFW&{JaVwrw67Y@KV9x%+E(~q@6N)y+62%8m$EMk6Lq&c_LY9&SrPH8$ zJezTT&0Vs-F~l}rq_X}H2EC*+Ver5{7U})n?%(L2fLqbQJp!Dgew+-iV5~0C?EwTH zhJF;#Z)mqf0{2Z~aR(Bq zios|c5WRsspOz7IQjVB?xGxH`VLIRp=42oX*(8XJ-q27;oq>zjk4o486xk#mFskv< z16(|*s)$&0v32Ap4wOkmn4IoT!2lvYceh~S#gISnnY8xler@7mD8AaDS!+lhZh@Uu z){kXCW>Nwff0>Rz>x7e4s-^!NKx=<3MaDu&XxktjB*bugwE|O!@7^F`((Gsbb$@vb zWHUlCMnWD$iq~;jLuyS%9jzgQ88U|=t^SKop7jccoQ@P~ooF2~Y*X*$1v+Y^!%-vD zu(UaWd1piGd$p>Uj0WsPQ%bp{b7sOFBk}$y+h(IVDoo*xL$TardWa)`fb9+QRJ%12LJQ z0{{YYvjvR!qR8L|V}&k6R#^iu8$9$Shd{CY(Q^g#!Wxy&4IceyXmhaLU0KfzJZ$;% zR0#=Qj*-L{)o3QzC@mNCod0SKVwzzqj!YcKU-6ge-%+{LC%1w@e5B~=Vy+bPZakI;-ka=T34Bi~otCFQU zJdQaTKQPr@51!E60M6AwTw7M)wSx}8!$F_QRV?9xM_=8MQQ~jpJ}$3THV&7l=#|#) z;zXZz<`*iLwyYm(?Nyg{GiOs=4r{77psN(k8t3^OGXhvE$1ueBLyT?-=&F>=1~7Vh zwbSRha37T>Q{lSmO$4>Of_e`qRIAkO*kIB;G~gvSQ$=5`764inF^@^$Y%FDSx(JG8 z#5l9RvE#|aHQ+Fut7-^Lp3T4lsT|GVD1d3nTF5_$DLhb+(!Yf1(OXT!JZzPm3CU`V@+u|5VeqRfTLVSX292hPgvebTr|#whaH1 z?hv|9Hd*!u(L!Q8uBXM7B5=dQq-0~6`agT_ar#~$&LqG?WVV|Q~F>a~a zyJM+3H2>k?!DTL#?gEq=z+~JvdJ7>n!%uh`pKkN>e~>U)7dD^8ycCnpkys0Vbw#ea zL;;*;kOsdB!I#I8>U^0^SYDVRDN@2Kw@hSY;6Amv86UmH!@dV3$~E7?k=R-R886A%WFbWfHkRw5QfvlO z_wq&p7;g3%(3D{QtnA6b=Iu5uUSV0ULj80v(*_xrCG+8}1BucmHX(54xZ(zD;P38yjrjYXB1xBTgB2LR>VS#uu_{&_8`k&w1=)JsOS z&Pl@G{FN%sFenfwu&Nv?&p+aZW-?Qhd|lk!WgVkmqBt4qP)s7nOxU9vP(j>4<~S9^%2( zmsAce_6hB5LalpNWJ+p8Hm9r|W&2tHxW{STVM-NKg-#f(M!O?772TBA@snl zB4kq(AzYmw^fcx8kvn^i$7aj!e-vSmhEB!m{_Ct$F;?sP`Co?raq+?Oj}v$87532% zocb*GGg@iHsK>jxEaurP+Q_dJbttYzj;J3$m%3nmJ)n1vy~@{{~VeC zEpBxsP!Q^TThY$al^FD%Kw>2Wb@+j}#lBLFH(ayS*FdJx`+Zi_%=#<})Z2=BqG+&c zc6>4zt1cKJ8~ zyO{Bsgfm zMU+sRbT05{&Gu|^BESyInnbeE=uXz?kCO1~3>3PBBLtcN!XRusTb}@l4}Bnl0It=m z+!JONYV}V?B%cbQJLSw5;>OoH#aPsalxqWzfN}YACjY<~1hc{p&+6PMj!smSkS)&n zo^7d@I6YrWg2zj)FOymx(x9~uG^tx9>@V1v-$q7`Dq`w0SX|Jby<*oRJg;fBZQG&C zhnMaqPK)ng&v@6~qz^e+-Ouze*V;Z?A1jLQ)%MS&Ub zZK(AMj%&Z3w|45PRszfqT}5mv#aez~l}CAI>HsTT&&q60(~wq}GRF47k9`jz@h`Y; zb7V^|)ETvm;voFUi1TR5qpX41ng1=XuBeIVt;#+E=$A#o?DtQ~bE8^At!MCGL2Fu4 z;HmQ1*s66)GYefy8%?n+MXg_<*$Z(JhV>hMy=?|wy={Gy##oiyE>(%i@=_4ew=fk`^3!jwx;bF)H&12?t{V(dkmRAm5|DJhSwv}m(4eyr!WkH z8gnCdJx(FZ9?YLK29~fBaZbdo-C8-}=rjm8f~TYBJj6JX$=UrTI?iitY2oPV#8(wH^L1J<0+L+{#jxn}Ft{xyVhlyG@_pI%}1+xV$`}qo3aQy~Oi3 zFB(7Ezb{sQX-`68tiP26b(g!@(Yk=L0xdz+lkY#i3wDmbt4Yz1kH6zwJ7+fhSG@f4 z&t4{kZXi77HWr_)jCG0+){n;TAU~&fqvi%yP@nEwf&pv# zkf;GJ6yyqjx)i1QQW-OfS1Q~x3ik><67Xl;@82=ke-Fz3^EnM$H$5QemZo(`7ZEwX zfbQ0u-$K$C<3B*77mO@Atuq_mG*~^^3Njj-bS|LUBh0<LcB_3%I}9iHH>3gX)Oerxok*I|$W@FtN)`X$L#1>>u9wDL_*T4wyKneB_@@~cjUf5S`bAN-~ zi+2i-$Mam)0x9p)!zJ4Tk^=dx&Asoqv(RVOVYb1vN9YR?73S?Ar&0_80g)a|4b8Lt zv}=%o-M!|0fT$wj!iq?X1ghZIt?{sZwdo;KcQ1Yc2j`Q)>S||Y z{#n?#e>opdzW5;@{pqwxUDL$Qu2}zLPU^Up>8m8m8MO8rb@6c3vX4V5pCm?p!CR~T z&w}=5jbpA+iIIZ{mx(fDhQGXV;}vU$Z4N>q00XlFp_;5-r~!hEJI#GqvV@|xyR%5k zaJzD0>IXh0?*963CS2aHv0mgvB7v%!w54dwG3TPrtf&Cl3l#Pqi1+Rl-La?aix^0Q zn9vD6;1RsCvt-;AK|q$>Bx<)i-jTrfmp;YT-d27 zYwK>O6_?pI1gy2ek1Bn_z6=4LPa{D^h+6R0-Z{*!mu@d;3)=l=0z-_mg@osTH}sQ@HZ39m2= zx6yq>N|UGN2I{Ue*vG<-xNnT-l9cauOj(n^iY6Z1(b?^^9(El`kcHz)y?ufm$-4vF z8}=BwS?m6o&Fso?<>gvNy&v*wM3UDdQ<}T6Y48vE1Q8tpDxjrSj&i*9N&oL3V@f!+iP*8A6)fX6czz?MyTi>3uIx z!Y~>6LkxIBeBdOZSk*{Nt`9ywkVcuf)q5H0sW%#qa=G?Dku z4YuyVB@ZzCG$@%yubQJK8BxI+USSt0=@YW5u<;jUfZdi9L(zEV zC+>%b_jJ{+ybZiZgzBk1{%d-P;0es@V3Vn74Sai3z5rg2XRDs`BZFERlK3w~yX} ztgH^in{Cp@f5sv`I~@E9Y_9B(EPZ?%N&zZy%hoI;Y7qvC!A2=tMMda3y$`bwVbYBz z2Nur?HtTQCEILF!fS(r%o@7kBGTYv~PboQ~3%$(HhJkU<*BnB)D_~!bb%9@XA7n^5 zp?+vY?Gp~hI<`%!h4~I{?oZCnn|6~E6I(%dt2M3P`Mc9NygZVP zbjj37g9+goP!4iC>HmqL+DJ1^Dq9L&+)*XPbhIKSJ;s=&vEr6StJ?n}A;8={X>f_5 zI4atzm?FC}lIH)S3+B&Ers$>U;+A5oS~@+(|A+F$TgjE$8~OrU_ENV)a`+4N%P8tUcbzvM?@aEuVxp@p2;Jl!=f$jdo=?JU^~3|p+4lP> zIT)qaSNAl}!U07LZBD4xbPl?cLE5OYXbtbA8aHLa9ui_=Y9iI^9xlUm94_OiPa-cR$=E}oww zp(fc0_QM2Yw!587Payh|b_CRG3_&bWBBd5C=BTWHpYEv{pQGUG3xLtj(MCSI$*B`{ z|87v`6e2J*yhz_4MiBMVt@nsI6>9eHX8v5ORgN#<5%E|Wl5Y1T2PMnV?0r=Uj>4@@ z<{5Z=k#${(EMF|v3=?$84#!YN@vgUq{mSuWxqnaXn}2fXYN}2ZuyhPv_b@ zM^*9jFxWCiy~Fe~oko~nEqRsedhCBxw^ndK0=)X{;&-7z45zggU8)xF^XYfTIYhM==(iIPf-9KqyjO78D@lU6^XrtKc zHS745ja7|fV58GGj*8d1eto~!JD~6OV|Ab;LeOg*rO(@TH1#b0S-LedM zWxy1mrSgq{S7Fa;?uKD3WsNR|N18m9mRy5|T!WT;frdO*FgOj0nStT=*qm7PuDceE zS~*7)N19yfZ^dFoa}0Ba6gqX?91vJq%cL9}CY)xTWaSx^xF#)nl|Yp0qFiW|GKGda zMp0D?oF;bYn;TXU4-F8D7MMx{Or-^C&;T`PfeSRi1zMn;@?fUy{G4QVy2kZ&kP9A| zoz__jqvoSrZKtjc zbjzoyw3^%ViEtBXXwIli?6C_}3r;o+j`)ycR}1yOt{JNcH&!=(@YBLxy&=a5Hy`l% z-w@NwH-3=QZ8snI`F)^!ZLbwrilv>^pa^?7g`3pf-)xQj>JgTh`PVzIbvGYvcKY9t z`SxB{1NUJ0#9k!*_i*{NHy7p2nfrr6IemxoW_^Xem*52oaAx{>Sq@qiIg6(j*zjDN mHOjozeR-2rjqS?9N1W;jua2{(Un)-@f%9nG4$MPfVE+Se%+90$ diff --git a/src/library/utils/R/sysdata.rda b/src/library/utils/R/sysdata.rda index ee62dd3d8035732f249a4ff4ea2a5f9217331844..cf23639f111e84910bc72a7526dda78e8cfe9fb1 100644 GIT binary patch delta 16316 zcmV;tKSRLheZ+r%ABzY80000000ZrPYpfkvc9v)Q<+l6bneIs<5=cczj4d5|1VKQE zl<2nm<(c-hWp~d^(zH5ts`fdjeCt$I*RHzPHxL*g0igs)AVf%$k-|$T;-QFukO&cw z@D%U^0YU;Hq=;WZ;s-&9fRwPFd+lB4aqqRAnL)`9`_`#{+O=yx*YjIz-+lE9-+Ji_ zmo8km@Wh2DpMwA4--QcLz5CAV*MHB23r~IðJ@lNX+azc1cCxO?-1-qrcg_8*jU zDEt!KeiHs&fl}9`*u{f+UzJPO%kQTS3Mel>o;fJn7r*U?alNtcUbxwgK(d$Zk?R{* zrgwYSwfzv6g;LWRp1Ik(XqKM2ImY|#=~wfJ30-+LA9A3L(_TME_o1`7ahGRbbtSMP z8+5(VMkN-mDWfS2H#Vnb`Y2TU^{={R?|&S$YQ4s7;<7bRoY0JKl*h288zKu;1LR>C zasMhylOleEZF*E0k+}4#tAQd!O}_Z5>#AZ10}WkBcLo$lM)%^YDHXc(YK63Lh3dv-ZI39o|3Yq75Ru8FvHC`PxNeVVJl8Pk8F0-*?GP6M208uu<=2on_7zA4THkYgD3=j`ru!})RepcMYM;fM>-^9~FZLeV3ry}r+xvRk z+pc;JegR+1+T&;kzYdb35tOH2kAJ=JMov`Y$knY4@wdF;g4|Ixz+=`l$(ipQOinZy z&%BAtENr$X-)zI9D|o$SJ6*n2*W(&EOEeyM3mIj!`END8fKfB%3pa*-B!9*iHQ@3s zAjhyP-En9{bStcaTMbUM5u{t*kGO*7ZK(tK)Tc*~-gS+AI$By&@_Fg4eBM%H_1%~3 z&U6jHqo(vl-Z>DsQi1!)w_L7uKK+)9X652r(DRtQ>F*7~_p!+n(MI&{OyXaIbA5=vx&~lT>KB_|^$-bdx`C!!jScR4Dz} z?YtQmu-V7nC7blQ=s{TKxAT5(5)V|^A3}x6E_?bm{2bTX_1kX9OJ!Mkn3osuetq4g zl;gSERRd~CHbndJ#oN^b?C?YjdG>Z&CSvI`x7#M(?6*e`J1f<#u7B`NAOY}M5b*ls z{wB4&NcW9YUi@s{$KSmCS$7PCyeW*3zx+0CDhHw>QV@8#itZ>F8;=*$2|{?0+5CFNgr@0)iXJ^>L1X4K;;s*yrx7+Nm6W=WZdC-75)5}{KN*5j^#tm_#m$N#XEgl zKnEu4`r@6Gy?p#m&_#)r=S`qz(UYl;7d=WPx|gFTFsHt4V1K5=*hbHyjSOv{F84bu z%EH7AkxAihjwXevq{Me8 z4Exeun01t?$1q%XUD5XCHXybG&SKHnpvdXU2*6k*|PQCz1^G1=O=;H1O~n zxhhO&G6D%}zjSw;_o?1+57<&3>Chj)SD=DkEzpWm#uEH<_lV>r#*wG*k=&u5yH|{L zq{%*a4`!_?lZHPF_kdOAVa%Vt7h5{ul?_YDGxr=(rGM~3{1ARcX1I^vYZt?D-fv22 zFWf`HZbRkcyOY)S%)QP<6yh81u_Twd#R8VK$AuhkB`DrTto?<1I58VCFW*h602T#B ztS@~mTwT5g1MCtp9&W)Z9paIC@!m+=2Y1WLB*}~S#{S5i7&m>#<P z>Szf+{|*e)bYd^V%_+-zx2Zrvfen9>%157rxtx^!`p;E<+&$x$Ki7gdm&NvrXFgvI zjq$}MN`V~D}pjzc4diV)@M(h-{lRB`{uS*^VmZdXoPeDdn*l>T+9(Y*6 zwUdren{dpL4)SB5_7--z3YWH&i{9GcqYsZ(Ai8^GckRPLgnOd2omCFe<=QTtU54dZ zE=s!`?9$3Et+M6PF2j(Nbr|2$dR*GPmEIa@9Ris$T+TZyYX$CGBb%rO>(JbqK7WQ$ zcjaK0gb1&@WOgkTHkta?TzkQBm1b{FlL=C@Xl6A z*N5HG*%Ws3+AghLqp7_SvEGO-h|=LQ$bE2WWo`BK4|2QPSY`H!E_AcEdFzd#^v(*{ z+Ubp~^tQ8lBVxS?Wxa8R-hYL0=#40N>xH*PklU&T9mOugn0fn}cVTqA(KA1kb{U%E zmth>d5q^JcWsPk6(puJq9qShl?5OBedj>h$l%5e9{I)7vg@Yo3Sv44%(vC+Qcd~KJ} z-P$g#hK09FyIX~kJnq6s9{Y(Z^N}kDV)C11i+o+xCo=@pv}`EO#lk3VVN?dmoe!(L z9bq?R^OMZ4(2UjKGkCEe(~+l=D+hPTzFd73I82b2`a-rYuY1M6Rrx??+WhVi|dxHvlaPn=y8j_0vNZlYLD1N!8K~Ti__N@ z3?}qp&65+sBVcXOIMJ|@DTZNp<&EbrW$(V8-E~FPMc|#q&LNUjfTl+eqxt|E(l}3x zj?4%!>Vwb7nSVskGV_^I1ITeo_D5Jc+OeMvU)$Up8{Tu?7VB;bf53PW;Z$ z30y_!h45$*9MQzp!RriMWQbjZOCA=7Qljepn&dSx*48nm$|vpe>!B$F;s z4yk??Og2Ib>ef4?D>z|VtCr5@(C0%xW2;k-rcf$XW*zwuG6W}8w0y!$-pFp}urooD z&Cm^j`ySSGo%@w6gwnBHPgbRNaeaRn$@VMZjdR$ zw!%sX{n(>znXIw6%72P_B!^B;WQ?IKy^HBC(S(Mqk}WO4 z4FBc8x~dvqWx71ejzJNG*=-MD&>TDAK&e8WbZg+1hR6fhbY4gsVIT_SJ^TadsPyn8cbd$~}|t$!IKJ@JDuH9gUVs*}e|g6U#G=(EnXu(+vp zv<-M#ol(R8@+iACEZzd4r^FMPo>yzJ$IBgC019x@jV*j{#-kc`Db4;I_h@A(B_KZN z0)U~9pi9|%P~v@=#W$q(ft^!^)A*S%-W$Ea@o(!|$58xz>qw%_6?zMAKK1*Bk(h?4>RUoe=UL+dC0@ouJOaRZzO=Iu`!!5*Q|pcxg3CBZ(VT@5&+hcG*HR*xFbVAy$T7>- zg!*Fof{b5xi8k@G2f<0avB}qnij+Z`19e9SYupHwJ1B-Fd{24%FF!hcq_t3??-wSg zhbn@HvT9U$##Ollv8u*~A%6=3rkiKzxmUhJ+gUuWGn8#XmdrRV#xY#CA;O1G5q?zF zj(%Ok_AXu1TTQK7!|bxE2vrdp0~K8OF|XUDzjh;g7l;UnLPSYu0KD#>sDG-3<5a_n z0^-}}o@ObCGc;Z~24dkWObSugZg_jE8Z;3kVs5`mcO8tM$OvaOM1SC%L~octV}=0P zf1hqE1i{5P?Ekb+UGOewxixM?Xd6a1!G~CQ!N>$hL^ALICN0!F5K>WsgWcW^wvQC? zQJ>rZdH`jkcq!BineHb0w?do7s+zN01;d7MP^4!mIi^L`1^8XMx&PYEE>4#=?h}j0 z0#Y@gLw*{WMaCjkNPpTvxMAfMGO}iMkztQe1zP*`fqqMxygqZ2iKkOw7>zjZ8-qQF zbZwh}O3@HcX~BiRex7kkgU$rHFvF*gM=x-=0yj!QhKBF0Iy9qaNPGdCa; zIU0?!cUBczH%?GyfR^?xkU})CER?XQDZ;xCM6|Q9qJrrZdtc;7t3iO%3V}s{p8<% ze1EH|YxQnjeK=Mn8)$0`G&iFvEFZQL)@(&mzidVRC*Rf;T6Ag8!fs=e-zx8dnE+qZ zw%^@p7$Z6m>&TQ!g7{NgtMdiaen)CeaJUA`;=kCtih?sQ-TFEf-q^#~qe(^cEgND4-}QgZ?UQHOw}3^ zNbEeR4o9(YjT2tqE^uYx%%a(tRV7C32UB_w6F{b@@jcm&-VI|X)r1eO(YSOYdw(-% zw`+CYX&g5%$HmwScaObLxV>REgETjG%6G&^BQiqpQxGM+kxep0kk6SNhHT!XY4Fyy zWROA2ezjE%d@-U%k9__p!tyI;-u}L;8oPKcLvq!pJI%+q+ zM2@B-V6YgnuDdmOtp{|ei3AD^LA|pg3yEohU6gT~Ze$1gtECBSTt(m9;wlg8qahtc zMpKR8rr?@8$hwZ}ag~D@Mka7WCQQ*94@b#Uc|P6C1+P{aKjLJ@Sui0f?Y zGck^AMC5lPT>i?rWa-FaB!3!X-f-wSY-;3&^LB(CKqglMc^n6`%no!0;Z)SL%bEp} zppbb=8~g7cNva8E+Tg>CxbDe}hM8&G$u(#<@WmyYZeVRsQcl3!Qx)R5B7;2bcD@wq z6Abkj2u@ZJ*!Z&;*FkGYI`=)NAu?(aGI%0J#{5Xym{U+A zU%`g`)kj!rTjd}1y~lDcP+pQ3DEi(g1G@wbs8FNwTcTh~E&`46f_)P_>3`#V+c-i7 ztTEw0=Ie1OIEcDLJAY$I(hiShWEw$*o&;S%JF)QfU=V*d(nTCu-OEg!gh*mwA;?P> zuJ?D()#%{J0GTAuf^F3hc4R0;OJe24Fd>qGk797m^e)b>>p~XEd5gUevT<$nUS zk~N+0#<@)F*|~inWm}8^+CVMnkJQgK=tj_Gfa}UAzb>blK|?@|VaF@V5k6vEsmaT6 z-mWAl`_J!bGAQ^VftOChOzodAj5V~4%=C;DXcz1TLp7o#2p;Y?M&tPiOqti9ACG7NQovge#d7hkI1=h`0izuXF`{gX zA`_=u!t%h+l2w6wHst=0);YN!Rmun-;YCE^b-;Vg@UuiSsE6o#KwT6iS3g`22qYrP ztfS_ITFXHXA7lUYhdLZr{k5%(t|i|;A?!#WqsD;zgMa8#@?y|;iTZ<%mmeeFrhI0z zfKHqV5-Kt0+&^H?C^=Bi#Pz89hu|^##iQhl=Vfh=`t|SIH_#=eEEE66zQGe)JWoog zlOmWonU!*LQnV5CFa*y1+DIDur6&H;uelhZU;V*{+T4_B#j63UklcM@S>LZ6n~f<( zcH^E_dVlj>Q^Dm_Qoha)SruwRvbP{-2D>8rA0xI(UVrob2SAm1@Y&+Pkbqt>hpLIA z^aYiG8hnCcG- z$cz)y?esBBEnc468-li5^*rPENTQLHk5D`GH-LK6ypOtuK6fg}4&M~3>k?%gLPbY5 zg{T8@(^ZyB7*_;X5j+Gew#~-P&#~@RvBBDFc2fm+4ruyb?p#pm9}ivmy`^u{;2WM4NF5;=fPg+Hk7Vak%XazV*)fWnc0R84hp(%y0Dm=Y z21On)LIuXz^%2}Tf5eXmOtRULlKj%&PA^jn*{STU&?L3=7GE^=V*^ofmZqk%dT&0% zg#1nYct3ik1z@Q2iRI~2R#*Z{3?UZ-<05uT*dJkjVg;9B4R1=@UWxTzqy{DW<$R*3 z&cZfR++@7lPA4+7;VJ4zL);dmn|}})ZzaMF@1ydcnv%`TkIy$feW!~>0@~H;qliIj ziCF!$<_*DXcdTHvM=NySaW-PZnMihGby3I%^2Adt4(ME8kI?3d5+nEy;dC(lAFVO+ zXt@qnUR#S5m!(@Qsy+FkQyElIkRgcW{=Qn1UB--PY^MqZU~$Gzb#>A0Qh$>t%T2AU zoFrfdbtc^UO4uw#u*nl}^`D3v@fEgJZf(#HB})QPA9*j7#F9?a9>Vx7Ou6L+{M%Pj zZlFwIGgRg%`}2exL=ksnFn|Vtc(5j#%gL>Q%v7)+0?GQ$gLKV=^wyg%hXrqWu!ETW zt+og)yeH3AAY4JSYK%|WsDJKMC!~Ae3gMKNxJ_eDdBU*Q{*x+XXqC4Pn6C_oV&Xj8 zWD03}VBaUY(pl)7f|AYm9fdyqX>u}B%o-~QOk~LlNwk!cDT)Y3w@F_lp$C+dwmjii zVntvl@VXHwB|ps6Mr{Aj2xtJG*)s# zKcZC>86^I4A>_F_$CDU5LG+NWk%Wk0oN{6Vx|eJh;Y2=c0+A6%OKb+@(Qq;9GIDWh)r~g1Zrx6@`rq5;)wWg2I%K5Xk5v zr|PvK2M5_A4tAQZ{gxx07>kE@BVtK!Xhr|_QRU+})OHpi1uCmh=*}VInPJPIxtK90 zZ6A>h6elIP78NwuO(@(~J;ffP>lo@MtcgUz$2R(RVltHE$$$TYk7K{Ee+eC*2L2bi zPN*L;>`LTsmh;VIroOP>5OL_<0Gc0K5_RbJnmQ=1FYRWu(C=c|-os!%T?^+)S1x@EgprqKnK_x745#aAZRoI>InSv z^E1I5gs1hq-arDNKM_P)^7An!gCJG0hbuN&aKn8Jtbd-jgu~*{X#`ResTD+`P?6gk z89S2H^M7;aCSEaQQbbGE7ZXJ_^b>)DC(>jX&BlDlh7F1I*uduC-m>Q{Y0MC36PF`N ztLwJeiYNWoI|-oY1jdMr%MEo03!VmO(H3J!-&4o@Fy5UMKRGr{Qjpf?VBT4Zq*Z4s zMjJUhC4Yo(zuBVgVB_{}I`%2PFP-{JdsQp;v5`_YavBO}0nCDS6045)xbe|jubWEZ zA4PB!Fd=*Q71U0!v^k>*VDQM{fG+7IQrbk`RAF&?^hwTcH?vpGI6H)#wK0p#Vu|$C z?iX&hgrt~|j%>Hlo@&&5B4|@*iYQCP29SLFkbjS`JlH(x5jM5NlolG9Odekz_Q-Vs zs}x3=s^j71W5-A%-ZqfC1Ljx?B_xGs7zOS>Mo}ce>qtQv@I`nL{3;@|bI(N6w`&*l zHC`o1l?z5r50aUvC8;qFW|8DAK~-y;UsZATn4-VY{By*RJ3~@7lyidx!ko=eJ(|?< z+NNL&y;LVqrcnz1pk{DR5(yAKQ^{CG9B8&k>lZ17T( zn*<2HCG0^um=8%_uUO(Dsi|>wNLSOw$`D4R)-@;jG0%!XPKDJGz#$+hnBHJn1w<-wE{d)~PD*+%pX=5WG;&6DEaAnJ zY>AmkwnAM`!`*R`CsG*cU$Fv!~^#K~D2NN2=-&H1wAEOyg@-YcOO9cY;yf6@>bc-J3=Y)Lg^@v`-g^LbR_>Cc#4DM_KjKcWrh%{9W zq#yXBd#6PC5Rx{rkj^a4k(^|U@foD$WJ_2Foal~o2g+|?Ria$vq*Yw~+}&&XERq-h z^3IW3?l>au#G|q3>KnK2U4Kh57-_1+WlXyw}u#=fEQd*5pU`8&$8*tHL)Y~FBA^!WL8p{kju0zaG z!Y85Y)E0|{0V;%RV1F77Llb)|g2SYFed1(cS~07(lJSDjt>{c)*E<&`HXI#|roI05 z#A=NuMm=;mk3E}<$PtQFEn(Ma6>pq<{bTYI5i|uVQU$=YCDnRp$)i2(`;tFapE1T) zPLzxyi!(hym%=-1uaVS|P8ZXwWsbL~U(2W?X9(GS_?|?0gnuW!cr0ySJ#s7%$D3zu z2*6aFIUn{{rRR2j{?tjYi{j@Q9cnCF4!pT zIcwHv4#oE;=9(C%w8df**+mJ&)o_lcC?{21n||c=DY@nhZ;VLyNuUKm%Q<~n2vzhs ziVA_A9Y2i9Y=7#qppH3lAp+&Ms>3p=Z{_ppIb2^ph@3yW7fT%uQ5C!?Az_*9v6_n6 zF3A&Su7^qX5%-|-X8mUTd`UF}lg~LFHR*R7Sykuz$B0o7O2xPEwLCJB(3U(Bzb5KF z`BB?*YT-Fq!RM5hFu@^Hnm`ikddY2Ax{z6xAy|$Os(&VhGlAb}arT0gS>!h zJIRydov^Do-hv9%Y$yiQOcKN9V$4I{M%f^EjjpSrZ&4GBOohAANk|o-Fd2tyJT_MY z*op#fR)3iILU4@;E9~f2uWDWalQNDGm{Dfc*UwcJ3Rg*`skVAGLN$XZg(or zq&YIA!GF0RU+>lt-fWM4td`!M7V7XgJNUr9`BfRoBadTm%wb_-D|SyFP5$O3JS zt;x5-UHQQ8-}`|Wxf~o$py2_Z5Ms?nOm=ysVSObpwT0|=QA=_qo4OK`q&q*>XUU7cY;=#~)4PWtFPD6MoNcsH4@(rxz zsBsnpJTw-Hho-DB?xEA8px4m}-Wtl30T4L;kK9=(&44Or@c- ze0U4usCY+`whfzh(>0!%PWmw(!#%@86Mu%)3=I%SE2K(=nZ}O2?MUfvAN$r&Th{VR zu^`@iWK@6D{<2y9Tf6Z6a~@P99X zh{Rqu8e8otzI7?85z#or6Esfl2r$h{jf2zhr~1y0Mlm6nSF|M8Z^z z5qbL(Gm8fQ*erYO?HyX+E1YIm5`T}lD61K%2j+c}MdKboJ2=@4#YKCTuPtewr7+R9 z|NLpF|Df{`M6Dv-B3Si9*d!Tuw_pcI#3#$Q!lTH`Mu7wg6zd*(6{s~4UJ`| zEU<8f^=Z|AXTsV-2Si*3&xFe!f6e-=fiyxIdD0R4X7AOkNU5y zWS#ePKIF6zUTuO=&liil!r*}ofOQn=EuY)$I>>B`N{4O=RYQv~j{tX(V&O1;mtZD= z&{)Q}YkS9e&%tJdO{QUQB-J&60e3XcvT2fU&Jd%XlQ8amCCbx4i+}HdhJ7LWic{{T z=R3Vi;nZlcbqF2Z{oG$+w6BV^}a8+xmG zrR=g5Opg872;{KG3w3^XMqA*~U$8-#)l|lcLvCQno*qjiQQ}JfNy~ z+=SHO;^7Lhg*eps?XBMN=?veDqhh2vKYI@UjR__ScK#X>cYlt~6)u{3=|x2f#~_j- z-L_@Wnu3XCQ9=LE*C?b&zy7WJg)O#^mce8^M2vXPkvr->&~SgoqR?K5WhqH>ABC2( zk0qSk{L5z^8wzWqaWz*9Qcv}Z!Ph}>VlisP^o#QdN!SJu-FhU{;?M?YMDSxWUXaty za4@^-B|FkzM1SoORMv@LIVM>u6lM~)9{oQTE_^XX0iCkEjg*maGZQ!4jDm0JLInyX ztGw#Zkv;0?e&W``9NDPr^5)=V-tTq&;(eq&0q>eea)xKXGHw-6-VV{YBO(?iNoqvk zDG1JF(Z3U?(p7VFvKNa%93*io`oR0qd9lnxTbk18d4EOWz|Dfy2DEzUr`|rlk{Fq{ zl023%Xy$v&Zew9FNsO;2p2unS$qB}+C)j%E2k>@EJw^Ha;=~F1opG;7EQv}HvRn;& zLvQcYbj;XdA=ORq8aJUOYSCk%#8)l?cQZBLpNt#w)rrF0Y}6T&SDfn%1WVjNwpkx6 zVOyAkWPkDy;JAcwPzuhew5FH6~*~mP%Wi*$~8y|L&@tC@m?k}VhTqU zzDqJ+!yfUdrW-==esSkgCU{EQ1pmt~eDTM>5Mnid;fr6!9a&a`AV#-J-`F5E=uc#~ zI0l3hRJaSZIWL{(4Z3mC>61a?GDp^$_D<9ISw zJMl2=j#6b0110!PtbE)OZh_GtYL1)(06jW2&zmEB-4BJdK$y9b;QtJIe&YIfs+O|XO?Q&aTW~oVx`fjKeAisL9#nd zZu-@?cEV-}`CysyF$bhBoCsBvZ>e*)^I@BA91Y`DWEW`U7jI{D5(vi}BtEN$wiWh? z<1GF@8&IkycsOu}&HE6T8#|VE`_Dk3Xtul1&HxhMBT-IIRo7bo<8B(rOl&va2Y==` z93{L#5AIW#JL=-P#Cu(l^=58<4M3SoTyOa<=kaHRcEK)n^isL;}S9 zG;y$mNk{q55OQ-fWJi0i===9|(0=$#adxv{b@8*<#p+WrK$wiKfvpNrWNH)V^Ly(> z|32zS^ZNbZ8M|tWQ=;h-)gY{^(|_6P23raT+R}NhPEMUf78S6FQ$OkMI5o|Q5oVcX zH~}UHdrcJTt*P)(&Lf)?x@uMy6^;HC|ik3 z>~cS|cSDdNDb95ws9}uN%sawnNGc7{yZCD%d&Vci15 z3O=4l#6MHej${fWF@s`aM1TK-d3E8S`;dPH@jv4rd4FRo_ZF#-H+&Nt3k|@f7+&6b zoFP##rhX>bXW~b$bI zcy&zta=a!8F;Vrbo5*=U^06;%6`IkFW29`bkHHbYl+=YIfmMBzYQU5}nVPZt5Kg7_2?S9P>8a4g<5yN?vwj+V0HBP5_&n zw0n{K@ujoVJx%YVK~n6Uk~j__8m?hjXeb&7R;arY)68-9R|>7s6DTOIQuj-Qf!LpT zN2A{(B>Uv}O*hByjQx#AQwjwrm=dg@(2y7gij6wo7S5{Ya0pyTEnMw$?&BvIuE zc0wyT81P$D0?}4Nk$jQGty9J9A3BU&Z6nybh z1D!2!gh$fO*dPo|*G^UO`Cg2HfThlji4JZfBLXJ6!J6qf^oY4rp39cgUB;L-S(g-z zBlP=oZ4u|e_|9bcpE+HKVwrVl{#mNMsegT7VlFU{GWjU8tCTCT*26;8gm7&ph&_Z? z*g-NBf7z{CGDpZd*0gzCE9Lx^Bu>maHOjY@1ZsTjYj|OrW-y)U?PjxJ9%6GR;sHg;4c`S8iMQ%M>aDM+*uOX6}A-HSh{G+?H1Z%G9etg!TA?M@UJm4C(# zooV$3h%+sm*aJ<{Gtwj|0_-ng{QvD-!fOg5C#&(vk5 z32)IU8(SD=@!NrH@;<(2PZ0By+!K;KrR-M#Hfw-*J8(L$Qdu*iU3w;%cZ98-eoV1>L($HMd6N-`3r4l$kBvo z0l61Y>~=WRxw0<LXi z*;mH0VhS3EarROB(1f@qUp!BJd{}9ev*Wv`TOU;qoDWu0jS7&C*`Lsy1^|MOqL_B^ z>c^G;a(AT6kB2@~%~7T2h678-Ljwl!(h9X_k>6 zTEF&=@|Cnble!!u=mhuS52I+)eZIJ;3H##KXcI(eg>8PXKVBr$_eRN1k{X@)Qp%C9fAFXRwS* z-aYhhNpNJOU#sngwZ#xxsXMr=78FMmYd%@(VWFwwRPP6zmj^Vl9FZe}FCkeG6}t+ zWR1wmB*E&=L+Jz$mYfKey*EEB-@i5!WDnUlP?6MdPp=1RHO`gB{JwNB0rf=Z#wapz zijGT>KP0JOOn*fZ7m!pG(r?GUv9L!)dO|xWM&V5Pv+dTDH|7FTh>@8gcg7Sgp>k*n zdqGu)&ji-G}#;}+K?j9`DqCKPS1Ww3;P?{t1X!)Fq9Ct zDyM)4#sC7rG>hO*d_}a$Y5L_!e&sz{rMC0`9#9Z$dw*)2TacV+(rA0}PK$XugLv%N zh%O3Z4VLqU1gLWI>PDb08bV;5IZ9`oHi17+=X9lCjkubv5HtpjbEM!w3QvT9KlQFx zw{j%wLFH)b79!Sf@LppV#kqQ&^q%oaaN+dEPwS-=8a~=`H5KAs80~erNSj;wy7h8 zrEm#N#6Xeebl7*3O-}SdX@)9`!ghc9VWcxmsH6evJ17iEFhUyR;+A%47P^F}xZo#9 zvc^VfW+W|S7mgkH$fZ3J`owv33Y>#gkvNFr8wkRZcS0--G>w^o93<0-ca}VY`6bA{>=G3;O(Po8Pjba z9f;8G-rUt={45G%dJxOb5B|jC`=F(EMt=;oZcxSc$R6D|`Ybf_+KzT!xNrqCZb*AC z{D1oQSS1P&8EQSSPSQyqp|`7a@fmB;pi8z7_N^C($W|HM*p79{AkeW3VVP2*s8ajo zSG)UP?Z1CkhhGOsGm$wuj+T&81f)VC6fGiGyLNDT++8@^L=|Cwjli0U&_qE94}U%w zqJxZ1oyD(}sTqQ-J6)8NhqRC+S1e!J~0*TrGHss=2Ys4izD1IJC_tjNy52Ap$u{FcxhN>J3Da5m2s*+cxpPS`hV zt#K1<{q3su_l6})^x04FhGiB)IDe;=f32*nUoU^l=}b*Hs8E=*oQ#rq;}-FxevS0? zH~#*{-(L@Z@1DA+H*qwG?n6O%JA3>Ms+|7)&RYq6qc~K=A+j$@yhLNfIyKctNkKN# z;ao~}cUdf`@T{BOQ3fA{KoVAoT^y-67oS&n@7m<6@^VX-kh@=dvv}djkAGf3p9uec z3K6gV0x3;!i*G)Oy0u>8@W}P$$R48aj~j%GnW%A0mVCJ_EVvyd-DP><36K@_ yvS`=gvRj4A-i6CyZkK9DeI2443cXx3rC!1Y*2`h#!)0G%tN$N8L|fuAG7 zN_5)pp7u<8+OoT6CTUuo+Er`sT|Tv|YHC%T;}Zx>AOWF-kU)r#CL@KLP{c(M2|^-7 zK*CkP0|H)x5K_cbkaz%u2uKP4b^UAAzMOMxXJ&vr*r#@X)v8tN`d`2QU-xc(?prQ> z?$U(|7oNKC^waSFGjMs~nRnlL!;cSLc>2Qg@b~3A2lsA%(7QSx+Wv!b z4uxNV+wjtbD^Tj2rP#%Td0&-F*URr`4hkqQKb|`%^KJ;wopf6U{;0k-A@AJkwaQUDgvZC!ys?e?%@K#y%F6!E|aL-D7gnw1V zwAjT1@2h1K+Ve7#O931-bTF1xo4ICLZQkwrwj6D6o;?_cRcOgK^RKLGvd@n=s!*@b z;Ktw{4p~0;L!TFem(ssOlbZn|Uk!G@Y6fZ=elvOZGL&hTecr7?tH18GYF<}-6UGx} z&K0h7VFI6ht!m0p`U?K4nq^ix8fU%#!fW-|&$HvcvgLRAwYELX@_61}q+64B`Q~IW zU%{IX^5W19)AAq1lNXUf_DSr^%$`zo3fn+b+BiA>s zOz-xtYx^NC3#FztJa@Bq(JVc8bBy=fv$yhy30=9B4>{1rX|G?P`_S3kxXbgmTnX&R z23>EoQHh0X%4iD1jm>G9J_^--?Jc+LoqvN?t=G6sT($;^6Poe$@))*sLu8?9fIJK% z?q6kTQpAt2O^+%g5|?hd8Yn{4SW|hyrUVlc7 z{~G>AU`H_+7*N4K0_T|@)VD}{B`RwZt;ZuR|zL6KcT35Bv z;+Nj2TwPAv{^A=|y`J8@A~*eHCx2X~`z{_;et*JbpU0c){Ln=&_8!^`?CnI``$pT_ zetH3Z0Y}W*<7n@`0WzYIl4swDe|^&@T#zlQ2KdODrZe-MgK3Dm{oI?lpu&cF`pq^x zx`NkRw#?<*bv>?udqh3QTgVKf4Su`v1&og|Shz9tBQdwA0hezB$%UQgj(*)puX9JJZ>QM@{LAymKH_ zr9$=7Z@FCSeD*CDjsL~Bpyx3O)88A!?IV*XrZv!m@be?`bEASQ=>ua~aKCp$BnCpG z3Xp@0*YoetQ}_gMsBL2ATYnYMjZ`qY_|^$-X_GPUz=9sTRPg-BoxB+ru&u}5CEM|Z z=s{S}ck+I2QVmqtA3}x6etPx}{2bTX^*e6JOJz%Wn3tFEetq4gG~$IjRRgL=Hbgt` zc>YdXCZgwaciJZ2)^|n^J1fUi@_4 z$KSmCX?F}HyD5xhzxpr}$yd9C9i+A(JMf>;CUDz3YOwF#`1;!8LH=pRFFUtKy0(us1_JOoK zf7kU3B6Yfe;0AJboPQ%=I8C7&_JzBvb}Fl1xr-}|lsVSGL#-(64%K3zTRPm>lr^T0 zY(L#a-6!tob9eh3M%q3z8FzSIML$0xKe2(NNBK}QK8S06`EK79(1FRizIZofBp%Yrb?3W*z0`F$~u| zSG0Y(jY!B7qp$Z|nIA?>>YiIy4^xT=WsptS5Zp`U^h@_ts64R-c!!(^RKR?lt&HWo znm$QH-%I)|xqp-D6|dTzO^s^fnQDZCIrgkO=V?W6bG#eZ;|_o%-exwNRvj(j7vF(_ znojIxxH)B6?=}@kD6rvAQu*jJFqf0EU;CNLkGp65@@HBQ=d##F@!V&tp)o%A;%D2I z)>SMOUBa8iI9Rv8@v}4t#77HZD>$K`LO9g#q<`3Njf$0}D@h4Q;Xdr5-!d&xqsXYO zd3E|UvT#Lj#zs}0FnbE3&ca6RWA*^_`L1@-9;zCL4%sQvztp(@R6g&+Wni{X}#VnXK1a*q3pZ~W#^?`*2m%UFtDwKwXEs4UG~NHOS|-e_SL}_1(%_3byeHt zV3*FyS^;MToE4bcU2k`N7|D8RAAdID2#i@T*G8b%i_R{sKtH$3FokRD(Aw7I+BW2R zu(A*BZfmdE9IuVat&LHwy_FrqyfwDpnqW$Ks%^q+t&zdDvjVosT3d4M5QtcN9Ljc9 zZ`Xy_x*@mAm6Z+6>H0;uTwB?d6)-;34OZ6ZZ)d~T)lt1xnbFD4#-TF?*ne3!JCij) zaIy?I9vu{4=$~& zt-k(YZg(52%s$bDZuT~By>XG=Spi!+y^)pPc2;kct2arkH+ImwFb=&D1#i9Zwg_@t z)u3P4Wf(JWU-K@EjyHPdhkw#8Lv#ExjDt67?~kpl(Q02>%et^*{o z?jBj^kBsXb8-YHyF*`Qecbu>7GP+yarPWY{F+1+Um>v6xrt+aH2Y+Iin`Mi9UDYQu zgtoM7&dtRRC=Oaw*~qaD>$x3a-(>TX%&*Yc)ZjCCu^yhrK(Y=XKlXc$2mFTK~t~~&+PU7c%RBs^| z3#w{FB_Bo(!5?`BL$q)`4)&TnA2i{=iz-1~*Jn+8JGdt1o zrxxHo=d`t`mQq$YnT@p*zdLjSR}uOOJlgF>G(>gqIztEd*vO78KOpsYKbQa*ghc#X2ekBW`bZmW-6)iR46R);Mht6WJWB2WQ zcO+W3;cKuM>h_q($Jh@agGB~Q35P>#`PQAaApkEIL&mSDbs*5rtb9IByqvrI|VHSO51oK88W9c0pu8>%s{`q-ldm~5uF%8Gg< zw@XfBjG-mHi|H=WgobQ~EiJ(e|K-5Csv2Kqx_>;&jzQ&v*=-MD&>XwUKz%}W01n6bl!a9E(>x=FroFBgirHKUa$-U_Cs zC%RB|@|a05T`UL<*0~lIH?@wo0Z*$lYJd12A7{6Q#akcTcDZ8B01DSj@D_eO7U{M)+L zF%+-dI+AE}#ku?8q;^7ov2(qP<|8IjvW~ZZSy&G2mGY>7kBwJr5{}ujU_L0V$XxE@VJ26$~b5%le6bw413Jf*(|! zRYq{+k>oHHFIZMmK=e#VP(iW?_Phid+oJ$i%23cQrX3pN*|PT*>-K#UQF)=zmnkj- zrH)nAWe9;sa&Y9>^8;I0K{#Es@>w$5q6CTh$VcQ#_bhDpw3-G327aO~zN znzJzC+37v@T1q4nCZWB;EoRx8uvtuBkn!s-(I$TSAh>cjHu)N{i!w-apzi1fjT?b- z2St;F?OP(^S+R*fppxGI+*R@K-rWI@1m^9=p#%6Dixi(hnx zvMtDx8Aqr%hR-%c`0y!$gnz2q(XVUR-lc1LtEqKsm|a#Cp(?^mpn?lO=5@RD*KTC* z0udomh$smSfY<#K^-r~MoN8E6Kz#e$(<}vXhQ=$$kSKhGNg?Xm4R3E%gC>GR%SlWm1iwHO!u@As(--UThU#*GMV!+$s<_z(*(7$e|_ zNCqCjq=lLXLMlpdu-n_g_L1T;>XREl51?!mxrBNl)7@nMR%p{$RdbfBVAwDsiS#Tb z$F!)r0Fp~L_g~xD#p%+W8eglu5A-gDH`G_Ex7R4&ofSG_?I9PX86?c=mic};6^Ek z9LOt(I|e!qU7wvcmK!6eACNZx-dNlBF18Xdx1!C1Drz6w3L-7_tX(#`KX&vv)j-1i zpsvA|01`mNIEi~>UA|-H24o^fqfz$GszU3=3Cax6(!K>!h=1mlg%TDuMR@o5kw_Zu zrK%atL{YkjE?x6qpIAZWP{dFB{*TYK#^y;(9xrj^t5dO%XgWNV^0VZof@*v=dQ{Jl zs^!fIS|12G2f|LowW80;GSHBd=mXN3|90lis2ZBfE-8bJVIcVe_zbL7o^n>Fc&ejC zgtdT_DB4&T!GAcb0Yu&fY=a)>ssSQL)+X#oUXZ!11i?O&m_rimkRnG_h%|;UEQj(+ zj78#B)ojZQ7Qa7`Of{^fX^(*o)UD~>q;{a9OPs65s?jKj7^~HZD7b0^P%+_|Jwn=1 zTOTnKSO=Ip4>0_$7A{!FaE0T8ZOcp4jZ}TwzRGe|Wq*SPgKLYFGF6(0BAI#;7Muwu`n`RDoM&noI!OUp<9!}&Nu7{5jB9@3+N zlxaojl~mMJCslm*Z|XEus5Vkf!PtYCf2s~J}}Wu4Dm9mG_Um2vC0 zO^s5WAAeY5!x}62Lg~=f)C@deR=aMuAKPnRWgE$KmQyxhqnID%6|_$J)BzU(VbI;k zC?v@F;2W|x5;?mb3m$cC+m}w4=J)N_ShL|+X1uS_&4sIJ;<+r^3Pxl~ip&k=S(5J~ z37~Xn_SQz8oUf5{4Wgd3k$qjL){sl)2=ocE0x2!F->=58CJE}(XczgZlKi{K?h!jrs>4w%T;qh-w+mcZIJ0OrW>txC^}&=L!~~Ej zYJ5+&qj$sDNj2evYcww1$leUv?OL688d1&5aWVG7-D58lZf}^)AkB@P@*VNfh<}U_ z{1ik6}5)TzBErB2}muN{EoWd_qGG}UBN492u z1uI6ognsZ>(+|#j_DHu&NA2d9$bZpv1Pm5K$aS{{ul0Z~HIYDpA*gp&WFaw4u!}No z(~ayvf3-A$jjQOJTU_N~eKe$l$Y`n&+!S1M2U*u~J+5*P!^i|~$b>0c_d|cnZ6ZyASOoq8{3J1BjW!N%N0eMHwES}8KdB=zql8BW5z;?R^cQJ0^|_AB&Y01 zm1nyl#?=>N@Oz6VoB|5jKtifuY$nE$jfnhigv(z!mnV3#K1Wnh<}0TpUg zeoGW=$wi<+T(EC~C;e}nZyQI*fHkHC$b3C61qV@=XlE=*+TpQ`Oe3h!lb|bTClP2K8-J(;{gL{)2Hgm{3~*f; z<=5pjGiV5?G3ZpJ&Y+cqPXGBmO$G%&q|(x9n5q2}hOvgWk(r*60_}p` zV5mlv1i{1o#%MerfhqGE^rI4ZEGEZ+)*m+QF;ul=lu8dIEOMPb_o(f2%`!(BQSqBZ z3V7?GST5cbM}I;cE?~4nAx4yKQDowDOIRNGS+Xi{&xYI|(mE&iqe>a!BfN-6ybgG; z8Ge>%2K5kq52%ZxP-{8p;bZKd{=5#yRexZAx}PG+UtoD^-uJPd(zzcG@AeyNGS^cyZl=vRO6 zkv2EwL-A_BDkO`ZSl0Jz$7W-Sk=?kbmEL^kRB$u$B3bgW3hfvXxO(E()+;o-Y62=t)Rs;_Li*2)UGxS2PNGU@*RpZcR zCP<=9^9V0D74~s;lK=1_tY1RXa?J$6Yuo}v>ji2c1tV(&MU2qjnhg)5cZtm{Kv+mW zG=Es2H5$0&Am$d)-A-4zh4beeNTOD@$d+Rph~-+m334&vcor3TSg;OxU64L%c_n;D zHFvC-ry@El+)*~7jR=_SUJ%6Cn~6#leN;*%x`jVnyFng=J-r?q+3WhLKX-;;8`O;0 zp{FaDvVeMphsQpV*rnQQfm7sXcF_!&kbkmjHuy`NS(E|4lvQ-BSzd{uYtXo=w^490l1Kq6pTf56OPyA@r@wdj&FZ5J%g=XOYG))Ulh)!-ukS zsb#x-@$4AIO*H~8;Y=h?u(~MZ19{>p z76){$uSaNeMTrr7hj2QWq>t7Zd9+*yE3d7^ip$b17S*2o(5VcnD98}Ra(`c~$u46? zG`3TP00{-nQDK}6)uNf+Hl!tjj4x)%VG8jMuKs;Cz&E+)HKxQh~ z4}oNT$3ePgLZa!-m&1a$jMPEQ{uWz=7T%L*D-f=rSvAI|Y*cru6Vg3&g>Xtsuck4l zJYm>t|1lLZw94BD%vT0PF@JH!YchqjJ+SW+UFj@zPC?1$`;J1N{xmrmDQ1lo1SYa% zg(Od_3=)625b|7|<4FvjAbLpGNPj}aFittK0o_lw zi*Ogral~8M+L+11-Z0FKPRT zLZIX*akQw5!Nx&3zUnE=5WU1uKfy{Q=sh;azY|lOBt`uneiB=QT}kNUG@QSXa02*{ z4OfDEvz%`xQ~tUANPhG~#(zAhTJeLAJAplIZI&)v zJr>AyEK*nkh-9DfXlw)^ke7N}(1AFrG9>ey)<0l&ScP)a;J7&CacZ~%bv_H5^hehrNU!A5WB3K3r($PTY@OhS`xrw#ZwYe6QPPN+CYmkaL!lyfHj;BB zx#0ii&P}{xbfid;tQsadY3L_n1W%;NFq)0Iiwy=6sei12qrtsp&s);?9?m8%M-oie zZL<|R`mc5pK+hS45d@bTzz!BX4bY-3#*nF}W*a2)@OXDpsN~o*NkLklgE?X;Xjc8E z7+B=&fDXR>W{YNmjoWwVtflzAbm}kd)uPy)M*7>x87G{@Dhsel3^?B7#z)7zZYl|N z6d6%)gMaMESNu95(B=#rfWaf*0(zg5plFkBQ{BYrsUtai*vvFF<3td0_{A);fF*)f zyI-N-5`ALwII`VFd#VBQiA+tMDWZfF8<_F!Lq5XtU`wP&gwztVS7;D2Id^&3BQFK4 zQW#~bj)#}e`Xc3b+d%G)jbnk6Kog!36S)5vFn^K6sUrntY!^X8@T&;I&OH-N->zLy z&3Kg{RW2ALJxCIwmTcU4uz)0Q34mJLd`l(QV+!;}OV1Ib>kKs6P%qxE692PM`^x&O$5t2m32xL5TuEtGGGD_BXL3a2ze)JhQYw{3)bcDIxsZwlU2%YOeNd1AxTYc z63q9O2nXq4J|ro;Vu_2SrpDDFGff+7ReuYW>g~Pcf5^*9bKY}kJ9|t;t zeb}`eyvx}FsFI_NMCpP#zma9{v}F!cqn}r}BIbM`XuO(v@hGTeHQ;&+;z$ytl7Gk| zuRTsG0vbGBMt}d@KJ7S{5(d6@j*e|0v6E^-iy?j?JD|UG&`3reZgnqnLY*xTSb~Nr z*%FJAY=yd>Mz+P>`0uCLRW%}woya8HbM#rywg`#@;U8LiI3o+g!MK6B_$tNk8fUFy zY@AoGC9qap%vut!YdQXCrsgEPL@ic9g^!>-r5D!Nj zu^MQZBgYyvSVLF=K1Pe1q+Sv%mI?&wWMRxj=@vc6&k6a~>k%D%3m2Vg@afa(6k9RK zmmCSw9maCS3CZHn>EE+ctgRZ@VZmxvf{B4+JVN9&BDt0;Ab*UcDsrs{x>ix# z|DGe+e*E+aTG63xjB5*N3(2G;URUft7ji;koF6<4eTBB0jSvdPaBwK4#Oq(Xp{hUw zyvVs1rFDO1KN55Y0#p(yUVmj88v+=wiHxjJ8wu0G<2+Cb3K3?qF|~7feW>Z)pbnek zW;#kf7)?mdo2g@O7Rh-bNgSDdmN@|?yqkiVFe`&@hiVvV+M`W7RVBBmjS04BLwdKk z2n`t)hlwG4Xktf+B!zou!6ads$OwgX%!GTkxAk?n&r6wZ&phVC&-=m`0n>#NLkJCTZTBI2o5#%=)BclpypdIxE<<&4r2gMF)gw zufHv^Iip=qkJrs(&*36+G-6dt*fmit6{E=AOpl7C@PEnLYov0dNX7JOnd2?$*D~tJ8A4(oy(dwg-bpW>NZVJB9c#n! z+*um}92LjSN8VNG>6M>7bGyYr4uQM+X}iKy`MMuY)-{ zTY^1jr5ep)_x{92661ijm`NgIB!Q$F&Vdx=e2Qz+kGwG@*MFQrjS=5I31lGXHm3&* zp@2R|`+lHj$B&|?nvN={UQP^%K=iFTs7&fx`FwgB)t3$;kIU}GQir2N1Q$oEe{9Qq92Rb58e6O4UZz()s=|Vw8bW@hyBUkL(h(C6B~! zhzdu3)b^aZcYjW%=Q-v5OK`rFhL7xDz2puoUC7+Z5GO|nP!oNb!0$BkdO@P`P~}71 zK*YroXCVta8Fz7}wGjyI@RIn0=*^0y6=oyY8a&)J6es1RLX1jmeLy9M*?Z0Q`wa*1 zw9TEJXUXwI*i{^FL0xLL5d%UdiC1&6pdoLgYzw?b*MC*fx2S$a_PO2YAEXLUm@Kk2 z9v-U!VnqQrD@-gQxIu*N^?41mjG9)2)T`yt+Wqj9NreF%V%44ZUbyW9ZrqbSa_nZab|CQDq{O4zD6@6YJbu&bp%Avli*IEG~bwa7Fwb`SR{)| zl#EjBZcW=<576i&JvV8Z7V*i>zqVOkLlqKjVv;P1S6ra`e=L!_EIh<-Ic?yPAlvg3 zi|1d zR~x^?%|!2q9z{=4Vb2MvBkm{U4w-s=ds*l+ryI|qNN1C#JixQMN|dC9h1bz?1CD1UN+ z7;=ND7~|=pSnzBk+3C+dS<4=~Scew)3a7D^#2zln8b<1YxqM{NxQEaVPUb>!$DZYD zOG;-cLbUC_cp9oc=zN3=t4Oy9rt}b&NXFeQ4to;u$=s}%Byw#LP(Q&x-A7Y?wI(QI zl8Q(oIA9tXD5AQi+9HY|`lTnm41eLUVKMg6Q3J{+G_A;X(C3K#jZ#JPytAo7YLkO* zyq-`Ejb%?LuyDrGY1Myw!rDYh749$Epd5oRtn9P}wnejxPNNWm&yQfA{cn6k(@*V} zV|dleuqM_hb28gmO_K;dK2xL`G+!^eNoeJ?oFKlZ6lL*II^;GQ8_7@9(tnu(7?JGi zun7Ld+4o{Edl5|=ctp6M;SfhlBKMLL3ej24qcog+?XV6D#$|ItXANlQ!*dcja5=@^ zR}580{a049&U-o^avBG(Ho<`Bi$z``IDZ4c9EDQL=Qg_zGTWlkp_}5v&?3wuz+I$R zGmMWVY)2q8mXYn+-f`Y@aDNyfi)q*!NhM7Pyd90RY?b5?Gnl65B!_!niSi)O;(MrJ zRS0?Fly>R)N$*m)G8(m2@j`=(@ZJW^Nwf>ec|zG2II0mBuN(<9SN8@7h(!lR?2b2> z5>1MuXC@(#^R`bSFE#?pcXQh)u8U+H_2P(E=bX+Qk-gsLN+nwpGk!Xq0P{` zG(|`yS&3mD&9sXEzyhl3*nN~DXg_|ydnx2BYg)=Fbd=X@mWF>7`0;h#eaEvBvt~5ZaorIaA*S_ zA^0&Fq{nGpI9Ocuk{#(KqV@O=q(lPnO5?TA~C{+|mMzK}w1PFdbY%1F4GiJNUk z!L4+m0)>)QUiIh5&h!gEd3#}wY}9pmb8xck_qu-ZKGL25GR-47!!t@4w+bk4hiKdp z5et(LH6rj7gnuEj=-P=>>8iOo*^9*>4wASPec=7*yjbR;Eluh4JfLu(Wx;9#T0Qhr zZ=YXDjLcg}p2!%f^4(^)u~?KOhSn3$<23f<1Y_0{Y(4Y?csr$bqI`LAVgminxK|{W zM4*Thu7ZW&%o6r)q*soCH%NOCgnSc83PsI)S%0#(tHtGz?A5DWRsU-%O4$g&y)rny!6 z#s;ZDe}5vo#eo+LOmiC{QTSm3BOK=^H?r&?JA&4sKaD>8Z5hR=6U_Sr{q)h`5QGa| zkdosJm3N(lUwD!$B${?MPm)yu!Mw~BnDld=7&`SpZ2UeB9$>E}s(K<{z%b?@up@E` zg(M8f#*?SoiHBi#`W^N#Py*e=%Ev9?78nhp=6^_@edy7taemQBxF~K_Zb4B!`LeD! zj0rWI#RGBHm(>siv%aKRK>|2V&iG>^8dE;^QF@f$`O^I zP$klMXH!e!o`VJ`%~60zL%#%Yzh!_HbQDuw@v&mbd2;cNTUE5058a9Mw{dk8rN*{m z-G7N~pBglNYAg6;i|H=_PG=UjBbn5r*VDj(ts{o+%Go0foaN*>qg2a|vtXDPD~*QQ zk=;TMYTapa)33g@6E;i82g^i{ITm%{M5v;COP#x&58HI(Xc(^|yFeqqcsrw$HW=ui z_^ck;R@f(wv-taLK&hJG;lLd>??W_f?0;C=?LPyBqS@|3I|DL%k3=~=wOnicrQI}; znb>Z;56p2ms&|7PJfPTe)Wvm;ZK)#cUU@;HVHM=1Z?cy+AYY}h?5RHFMCH3`%n#tJ zPbDIWL}mMFVqS?&j`E8kBFd1C~TYnXz z$kZmz=l9l&{(aPu=Jor*Gj`P$r-ZO2szF#+r?b}$wiFJGrSnpqoa%@yDqs<(e$w5+ zVVZLy%reVx0!$9}nkc?nQ_Z2AM>Z*R)vPQOui)$r6-Ixg3N(8a{Pn82PUqwyg@6gi zMJGox%UB&x8=ZE$smCv zPhswHt`V2m<$iAOh9E;yoT)@m!x$i$cZAK5{1u{i@z+A`la0^DSQ^gI9Dj;X!!^*95eU`+i?a>vA{1QU)G2A7g`Tn|}gQjg}}I~%wuWJDo@o*!5t^ySu;aQq6o-x`H3{^6 zHz+ZkE!BBtZ}IAw_~m#_5MrY0SvQgMcI0DU+$uDq8_9>L-hj_Wg8&_7&)H!VrX=8Q zO*GEFt#vy%=qm0(*RNTS!u+yIqEFo{qVx3ePMW~jVdMK?>PjL0(eAEMfMJ11sGm zl!lj|N&UNz2aQx?6j%K*8?;#cq@y^xu?KBJ5-kkQg1_+5wvh#a1=32535g4sW`CpPK#mGSjwz?%x&zUe zl|8K%cS>HGJS}_|kCjC}L|k{^b9OnRa3HU)M^B%pivU(ZdeJcVmeg)o>@Qk#f}RI(yZ zJXEMn{aa`8@>r-9PD`0D+a)hjba-O=)LxKJumlJ7cMhBR0eXk0g~)Q;og*?1+}}8s z#+&IWjRuGZP3Mm+kuZRo1SJ%Y3vZQeEdn6N1>qX?J%8{JZ#%_{I8LXAgxFCj+!EH> z^^i+N%nNVGZv?l$2M>dRVR@iOsqVAs3@hlz^%96cBZsvp00})Uwcw`hG#dI=t{H|t zKL$9>vk4 zWzH-lfPWr#=%fk+lbwdtO$f?1_4C{JXM*&2j_c`ZApgfE60{D8OFpvAAHt}u40VZ_ z$D#v0DP0orlvH!E*uWj}%09bd41dq(c%(Ij3YehW7Bq05y$6zFASeIw z>=rCeBmf)qlf*DXS>n6iKD$!;zaBHBrSf>(KnuRC`nV zz{Ff&AZ7AVW>+aeVXcR8stMuROb~krudst!DE_irwPcQvb*#DSxK_%kE18p+b!wDv zD_P6^tG`C+m)7#Bv!92v~s)poFk$(>)^N+Y4Q|xW*s7mt9lWnJx+$&O$XeE}! zBZWeC@?CG9XiwM4G?EqII#zsq-Uf_Pz2at!ubF5xrEmg z%#M@=>6)HVhPk_fi;cnoLK=hSIu7{6D-~gdH?6;|q^ylyf!ZahZtXDshe&g%k$*IX z>vAr0%MzG8)GnXl;Clgs@`_nIF?psgE6p;CPTAPPFpJ*~WRv&teS3nKpX4U`_FzDz zk>7LXSeRS_J}os`bZDu%kxnyhcbi$;zBCmHljMD+QL0hl;BPh3MtpCajTKNjhyo=)P`6f>;Q z^FXK^lO8jy4fs!|1`4r#^eTe<>$)vO)7-(~lm=d^XNK~|TIr``V z-;MPXf-a+Mhxx)I-&1RmzAiV5xGB{S&b~616;seSjI)p0hbF`|`Qmx%IPtG=BgPd=$mBi&sCXq?5ZNWqu;`p=ypQJ%=u`Xly$rfbAs7 zGfJt29w%T_4rFU|N!-XjL5a8wl4kkzq4jI;C|^n2GpWllf=+NB{xFI*-RFyony^2< zaA%&d%`{>1*}ISBvfMr7KXd->pgAEBNONq^DH**Zl*+cJ+) zQXo9$rY+q@+u7NzK*>KInyw&cQfi{*7Od}Pln;(R_TWs;kpK$zi$Aq)tDd2c7A>Dd z`UC(6dU|C4edwu2Ay4tJQpR{Oat6z|_4Ex1j!U35b)#;3Ts5fZj-=}_8)^6=ba!pD8*FU5lK-7o+w5mK35Fik|l8AQ3BCd zsI0Oem1ahw=7g3=eoDeuK%<>DLe_|^OtPBpJoHWQV1LPpYuS7A!}9%WGeP!{ zeFGIq4fphVU{&K>Y0U472NO_FbS{e`6Q}676!}Av3dU3q$jk4 zVieAlKih6id1Edhg&3I`a%W7@5-NwLuoqNy_{?2BbYTs|oK&dP+{7SKs#IrEMw88v zq75kmou7u#?|<~bg|x80k=<&^Jb|HvxK%mtIxq$h2&P#CfAY(sO-^$jPm&t%(JHl_ z|NDS~VB1sU+=ApplSbQ%cUsKT8N_2}HFQxBYp|R*BtVsuS2qH6(GUXb%ux>Ev3JXfh2^eqQfWsMTEy6W{B_G^~wF|iv*fNDm4C#vBU+5IH>O_ZGi1^|N6dGmU^El$k|aAlUkBcY!3mbV#EBh8dO_>V&%{}Y z^0L%Jk2jhT=OmkO7Z*`|&Vmck`85d%e<(_z|8HaSKIr5UO$3fujeN0H7j zp^^ru@1QUw!3b%Li(A^IS?Cg?;)0(b$r>A_nSYVAke%iFZy#5%oX&KVc)r~|pVbrm zEb?DH@M7l&fAYzF(6ad=Y*yz);T$q88%IoqW?tLT&I=c=favhe(%uXIm;OCgCIVcd z)`P($gYXeLI7%0vWfcv2bh><(7l%km8PL{_b;-CtQ2aC!Pf8S3YO?xDcmFH>_s{C^ z>wf@g@+n6rd=fZ@urqWfIn2e?t{t2nD;Ca>P~FF0BYd8M@{spog83mjFy_=*{A!t+ zA&58AMMPfSj1p5G z4&zm|S0@~@Va_5aJ?aynBJ4k{GpEGJMT4wywesb3|1{ms9>`S<_jzxPhv z%bSo11ahGOyqzunCN)m~e#h;EuBE52t3zOnSf*xmC@G#|I-En zqG&gQrLZ+S731Rb;O<|Wd{tghs$miE_)X)hq+y< iiR`IzDD-mClzIspRxgK@50`z7t^Pk?_$96P;Q#<9y(DG; From 2439e9d23e843b73394c655735f52d1152ff3ba3 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 27 Jun 2024 16:11:19 +0000 Subject: [PATCH 320/546] Cleanup. git-svn-id: https://svn.r-project.org/R/trunk@86845 00db46b3-68df-0310-9c12-caf00c1e9a41 --- m4/R.m4 | 6 ------ 1 file changed, 6 deletions(-) diff --git a/m4/R.m4 b/m4/R.m4 index 84eba0c59e6..ffe97586f53 100644 --- a/m4/R.m4 +++ b/m4/R.m4 @@ -203,12 +203,6 @@ if test "${r_cv_prog_texi2any_v5}" != yes; then else TEXI2ANY="${TEXI2ANY}" fi -if test "${r_cv_prog_texi2any_v7}" != yes; then - HAVE_TEXI2ANY_V7_TRUE='#' -else - HAVE_TEXI2ANY_V7_TRUE= -fi -AC_SUBST(HAVE_TEXI2ANY_V7_TRUE) AC_SUBST([TEXI2ANY_VERSION_MAJ], [${r_cv_prog_texi2any_version_maj}]) AC_SUBST([TEXI2ANY_VERSION_MIN], [${r_cv_prog_texi2any_version_min}]) ])# R_PROG_TEXI2ANY From 87d77216f8fb70b334dad8b68bae26df1be184cd Mon Sep 17 00:00:00 2001 From: smeyer Date: Thu, 27 Jun 2024 20:06:03 +0000 Subject: [PATCH 321/546] update git-svn-id: https://svn.r-project.org/R/trunk@86846 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/demos.Rout.save | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/demos.Rout.save b/tests/demos.Rout.save index 5e2c21c9a8b..c9246a4aa91 100644 --- a/tests/demos.Rout.save +++ b/tests/demos.Rout.save @@ -1,6 +1,6 @@ -R Under development (unstable) (2023-11-02 r85465) -- "Unsuffered Consequences" -Copyright (C) 2023 The R Foundation for Statistical Computing +R Under development (unstable) (2024-06-27 r86845) -- "Unsuffered Consequences" +Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -196,13 +196,13 @@ List of 3 .. ..$ message: chr "3 NA's produced by log(.) + sqrt(.)\n" .. ..$ call : language message(sprintf("%d NA's produced by log(.) + sqrt(.)", sum(is.na(r)))) .. .. ..- attr(*, "srcref")= 'srcref' int [1:8] 78 5 78 88 5 88 78 78 - .. .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' + .. .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' .. ..- attr(*, "class")= chr [1:3] "simpleMessage" "message" "condition" ..$ :List of 2 .. ..$ message: chr "Got +/- Inf from x[4L]\n" .. ..$ call : language message(sprintf("Got +/- Inf from x[%s]", deparse(which(ii)))) .. .. ..- attr(*, "srcref")= 'srcref' int [1:8] 80 5 80 96 5 96 80 80 - .. .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' + .. .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' .. ..- attr(*, "class")= chr [1:3] "simpleMessage" "message" "condition" $ warnings:List of 2 ..$ :List of 2 @@ -245,8 +245,8 @@ List of 3 + "\n\t starting with 'is.' :\t ", + sum(grepl("^is\\.", ls.base[base.is.f])), "\n", sep = "") -Number of all base objects: 1401 -Number of functions from these: 1356 +Number of all base objects: 1402 +Number of functions from these: 1357 starting with 'is.' : 53 > ## R ver.| #{is*()} @@ -1639,5 +1639,5 @@ sm 3 3 3 3 4 4 4 4 2 2 2 > par(op) > > cat("Time elapsed: ", proc.time() - .ptime, "\n") -Time elapsed: 0.653 0.047 0.709 0 0 +Time elapsed: 1.257 0.036 1.302 0 0 > From 71ca3e61cec23e42a8f422be06bc2356c6760ebc Mon Sep 17 00:00:00 2001 From: smeyer Date: Thu, 27 Jun 2024 20:10:12 +0000 Subject: [PATCH 322/546] move and enable encoding-related regression tests git-svn-id: https://svn.r-project.org/R/trunk@86847 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/testing.R | 6 +- tests/Makefile.common | 8 +- tests/reg-encodings.R | 338 ++++++++++++++++++++++++++++++++++ tests/reg-tests-1d.R | 300 ------------------------------ tests/reg-tests-1e.R | 11 -- tests/reg-tests-3.R | 13 +- tests/reg-tests-3.Rout.save | 15 +- 7 files changed, 355 insertions(+), 336 deletions(-) create mode 100644 tests/reg-encodings.R diff --git a/src/library/tools/R/testing.R b/src/library/tools/R/testing.R index b1bb664e36e..1b5d2a5ad42 100644 --- a/src/library/tools/R/testing.R +++ b/src/library/tools/R/testing.R @@ -701,9 +701,8 @@ testInstalledBasic <- function(scope = c("basic", "devel", "both", "internet", " tests2 <- c("complex", "print-tests", "lapack", "datasets", "datetime", "iec60559") ## regression tests (strict specific, too) - tests3 <- c("reg-tests-1a", "reg-tests-1b", "reg-tests-1c", "reg-tests-2", - "reg-tests-1d", - "reg-tests-1e", + tests3 <- c("reg-tests-1a", "reg-tests-1b", "reg-tests-1c", "reg-tests-1d", + "reg-tests-1e", "reg-tests-2", "reg-examples1", "reg-examples2", "reg-packages", "reg-S4-examples", "classes-methods", @@ -830,6 +829,7 @@ testInstalledBasic <- function(scope = c("basic", "devel", "both", "internet", " comparePdf(f) } } + runone("reg-encodings", inC=FALSE) runone("reg-translation", inC=FALSE) runone("reg-tests-3", TRUE) runone("reg-examples3", TRUE) diff --git a/tests/Makefile.common b/tests/Makefile.common index 59f81cb2e8c..ef145a96976 100644 --- a/tests/Makefile.common +++ b/tests/Makefile.common @@ -64,6 +64,8 @@ test-src-reg-1 = array-subset.R \ ## added to in Makefile.win test-src-reg-1e = test-src-reg = $(test-src-reg-1) $(test-src-reg-1e) +## to be run with $(R2), not forcing LC_ALL=C +test-src-reg-enc = reg-encodings.R ## overridden in Makefile if recommended packages are not installed. ## *-src-reg3 are sloppy (*.Rout may differ from *.Rout.save): test-src-reg3 = reg-tests-3.R reg-examples3.R reg-plot-latin1.R @@ -85,6 +87,7 @@ test-out-primitive = $(test-src-primitive:.R=.Rout) test-out-large = $(test-src-large:.R=.Rout) test-out-random = $(test-src-random:.R=.Rout) test-out-reg = $(test-src-reg:.R=.Rout) +test-out-reg-enc = $(test-src-reg-enc:.R=.Rout) test-out-regexp = $(test-src-regexp:.R=.Rout) test-out-reg3 = $(test-src-reg3:.R=.Rout) test-out-segfault = $(test-src-segfault:.R=.Rout) @@ -95,7 +98,7 @@ test-out-misc-dev = $(test-src-misc-dev:.R=.Rout) ## This macro is used only for dependencies and for distclean test-out = $(test-out-strict) $(test-out-sloppy) $(test-out-demo) $(test-out-gct) \ $(test-out-internet) \ - $(test-out-random) $(test-out-reg) $(test-out-reg3) \ + $(test-out-random) $(test-out-reg) $(test-out-reg-enc) $(test-out-reg3) \ $(test-out-segfault) $(test-out-isas) \ $(test-out-internet2) $(test-out-internet-dev) \ $(test-out-CRANtools) $(test-out-large) $(test-out-primitive) $(test-out-dt) \ @@ -324,6 +327,7 @@ test-Reg: else \ $(MK) $(test-out-reg) RVAL_IF_DIFF=1; \ fi + @$(MK) $(test-out-reg-enc) R="$(R2)" @$(MK) $(test-out-reg3) RVAL_IF_DIFF=0 test-Regexp: @@ -538,7 +542,7 @@ INSTFILES = README \ $(test-src-internet-dev) internet.Rout.save \ $(test-src-primitive) \ $(test-src-random) p-r-random-tests.Rout.save \ - $(test-src-reg) $(test-src-reg3) \ + $(test-src-reg) $(test-src-reg-enc) $(test-src-reg3) \ reg-S4.Rout.save \ reg-IO.Rout.save reg-IO2.Rout.save \ reg-plot.pdf.save reg-tests-2.Rout.save reg-tests-3.Rout.save \ diff --git a/tests/reg-encodings.R b/tests/reg-encodings.R new file mode 100644 index 00000000000..de66237f184 --- /dev/null +++ b/tests/reg-encodings.R @@ -0,0 +1,338 @@ +## Encoding-related regression tests (initially from reg-tests-1d.R) + +str(INFO <- l10n_info()) +UTF8 <- INFO[["UTF-8"]] +LATIN1OR9 <- !UTF8 && ( + INFO[["Latin-1"]] || + switch(.Platform$OS.type, + windows = identical(INFO[["codepage"]], 28605L), + unix = tolower(gsub("-", "", INFO[["codeset"]], fixed = TRUE)) == "iso885915") +) +if(!(UTF8 || LATIN1OR9) || + identical(localeToCharset(), "ASCII")) { + ## checking localeToCharset() because on Windows, in C locale, + ## l10n_info() would report Latin-1 when that is the code page + message("SKIPPED: these tests need a UTF-8 or Latin-1 or Latin-9 locale") + q("no") +} + + +### BEGIN FROM reg-tests-1d.R + +## Overriding encoding in parse() +x8 <- "'\uf6'" +x8.2 <- substr(x8, 2, 2) +stopifnot(identical(Encoding(x8), "UTF-8")) +f8 <- tempfile() +writeLines(x8, f8, useBytes=TRUE) # save in UTF-8 +## +chk_x82 <- function(x) stopifnot(identical(Encoding(x), "UTF-8"), + identical(x, x8.2)) +## parse(*, encoding = "UTF-8", ..) : +for(FF in c(function(.) parse(text=., encoding="UTF-8", keep.source=TRUE), + function(.) parse(text=., encoding="UTF-8", keep.source=FALSE) + )) { + x <- eval(FF(x8)) + chk_x82(x) +} +for(K.S in c(TRUE, FALSE)) { + x <- eval(parse(file=f8, encoding="UTF-8", keep.source = K.S)) + chk_x82(x) +} +## latin1 <--> UTF-8 +xl <- iconv(x8, from="UTF-8", to="latin1") +stopifnot(identical(Encoding(xl), "latin1")) +stopifnot(identical(x8, iconv(xl, from="latin1", to="UTF-8"))) +if (UTF8) { + for(x in c(eval(parse(text=x8)), + eval(parse(text=xl, keep.source=TRUE)), + eval(parse(text=xl, keep.source=FALSE)), + eval(parse(file=f8)), + str2lang(x8), + str2expression(x8))) + stopifnot(identical(x, x8.2)) +} +if (LATIN1OR9) { + for(x in c(eval(parse(text=xl)), + eval(parse(text=x8, keep.source=TRUE)), + eval(parse(text=x8, keep.source=FALSE)), + str2lang(x8), + str2expression(x8))) + stopifnot(identical(x, x8.2)) +} +## parse(text=xl) had failed w/ "EOF whilst reading MBCS char at line 2" + + +## UTF-8 truncation tests +if (UTF8) { + ## These tests fail on R < 4.0 + + ## Use .Internal(seterrmessage(old.err)) to trigger truncation via + ## Rsnprintf (mbcsTruncateToValid). + trunc_string <- function(x) { + old.err <- geterrmessage() + on.exit(.Internal(seterrmessage(old.err))) + unname( + vapply( + x, + function(y) { + .Internal(seterrmessage(y)) + geterrmessage() + }, + "" + ) + ) + } + ## limits to detect the internal buffer size for truncation (now 8192) + buff.min <- 8 + buff.max <- 7e4 # > buff.min + buff.size <- nchar( + trunc_string(paste0(rep(0:9, length.out = buff.max), collapse="")), + type='bytes' + ) + stopifnot(buff.size >= buff.min + 1) + if(buff.size == buff.max) { + ## possibly, the buffer is no longer fixed size? + warning('BUFSIZE too large for UTF-8 truncation test?') + } else { + string.base <- paste0( + rep(0:9, length.out = buff.size), + collapse="" + ) + ## Append UTF-8 sequences at the end of strings that are just + ## a bit shorter than the buffer, each one byte longer than the + ## previous. + string.starts <- substr( + rep(string.base, 6), 1, + nchar(string.base) - seq(buff.min, 3, -1) + ) + ## For each of the increasing length string, append 2, 3, and 4 byte + ## (valid) UTF-8 characters. + string.ends <- rep( + c( + '\u00A2', # (cent symbol) + '\u20AC', # <82> (euro symbol) + '\U00010348', # <90><8D><88> (circle with dot) + NULL + ), + each=length(string.starts) + ) + strings <- paste0( + string.starts, + '\U0001F600', # 4 byte grinning face, extra padding char + string.ends + ) + output <- trunc_string(strings) + stopifnot(validUTF8(strings)) # sanity check + stopifnot(validUTF8(output)) + } + + ## These tests fail on R < 4.1 + ## + ## Checking that truncation and `...` concatenation are working + ## correctly in verrorcall_dflt. Prior to 4.1 truncation detection did + ## not work with call set, and multibyte characters could be mangled by + ## the `...`. + ## + ## We assume getttext strings are not translated (or are translated + ## to the same byte-length as the ones in source). + + ## We cannot use `tryCatch` as we're testing the C-level error construction + ## and that is not invoked when signalled errors are caught, hence: + capt_err_msg <- function(expr) { + tmp <- tempfile() + on.exit(unlink(tmp)) + err.con <- getConnection(sink.number(type='message')) + sink(file(tmp, 'w'), type='message') + withRestarts(expr, abort=function() sink(err.con, type='message')) + ## add back newlines consumed by readlines; we assume a trailing one + ## exists, if it doesn't readLines will issue a warning + paste0(c(readLines(tmp), ""), collapse="\n") + } + ## Generate errors with long messages (length buff.size + overflow), ending + ## in `x`, to test truncation. Will need to be updated if buff.size is + ## increased. Function names / etc. are all carefully counted. + long_error <- function(x, overflow=0, buff.size=8192) { + overflow <- as.integer(overflow) + x <- paste0(as.character(x), collapse="") + + ## Compute how many chars needed to fill buffer + call.len <- 51 # nchar of a_really...(stop(x)) - see below + extra.len <- 12 # "Error in : " + extra.ws <- 3 # +2 spaces +1 \n from `tail` + chars.left <- buff.size - call.len - extra.len - extra.ws + chars <- nchar(x, type = 'bytes') + pad.chars <- chars.left - chars + as.integer(overflow) + stopifnot(pad.chars >= 0) + err.msg <- paste0(paste0(rev(rep_len(rev(LETTERS), pad.chars)), + collapse = ""), x) + ## force truncation despite 8170 warn length limit + old.opt <- options(warning.length = 8170, warn=2) + on.exit(options(old.opt)) + a_really_long_function_to_cause_truncation <- function(x) x + f <- function(x) + a_really_long_function_to_cause_truncation(stop(x)) + ## trigger error and capture std.err + capt_err_msg(f(err.msg)) + } + buff.size.2 <- buff.size + 1 # .Internal(seterrmessage) drops 1 byte + + ## 2 byte and 4 byte utf-8 encoded chars, avoid code points between \u00a0 + ## and \u0100 as some iconv implementations will translate them into char + ## values in those ranges instead of into "" in C locales. + utf8.test <- '\u0238\U00010348' + + if(buff.size.2 != 8192) { + warning('These tests assume BUFSIZE = 8192') + } else { + ## Mangled multibyte in R < 4.1 + stopifnot(validUTF8(long_error(utf8.test, overflow=-1))) + + ## Truncation detection fails in R < 4.1, so newline isn't appended, so + ## we get a "incomplete final line" warning (converted to error) + long_error(utf8.test, overflow=0) + + overflow <- c( + -6, # Buffer unambiguosly unfilled for MB_CUR_MAX=6 + -5, # Buffer maybe filled for MB_CUR_MAX=6 + -4, # Buffer full with '...\n\0' + -3, # Lose 4 byte UTF-8 char + -2, + -1, + 0, # 4 byte UTF-8 char exactly replaced by '...\n', buffer full + 1, # Lose 2 byte UTF-8 char + 2, + 3, # Lose first non UTF-8 + # These will need to change if R_ConciseTraceback changes + -87, # Room for traceback; options(showErrorCalls=TRUE) + -86 # No room for traceback. + ) + le.res <- vapply(overflow, long_error, character(1), + buff.size = buff.size.2, x = utf8.test) + stopifnot(validUTF8(utf8.test)) # sanity check + stopifnot(validUTF8(le.res)) + + ## # For first one, before truncation test, we've used 8186 bytes, so we + ## # know there was no truncation. Code adds a trailing newline, which + ## # is why we get 8187. For the second, we add one byte to the + ## # message, which puts us in maybe-truncated state, which adds 3 more + ## # bytes via with "...", so total of 8187 + 1 + 3 == 8191. + ## le.res.nc <- nchar(le.res) + ## data.frame(overflow, + ## bytes=nchar(le.res, type='bytes'), + ## snippet=substr(le.res, le.res.nc - 5, le.res.nc)) + ## + ## overflow bytes snippet + ## 1 -6 8187 XYZČøšˆ\n + ## 2 -5 8191 Čøšˆ...\n + ## 3 -4 8192 Čøšˆ...\n + ## 4 -3 8189 ZČø...\n + ## 5 -2 8190 ZČø...\n + ## 6 -1 8191 ZČø...\n + ## 7 0 8192 ZČø...\n + ## 8 1 8191 YZ...\n + ## 9 2 8192 YZ...\n + ## 10 3 8192 XY...\n + ## 11 -87 8192 ation\n + ## 12 -86 8107 XYZČøšˆ\n + ## test recursive errors in handler, Fails R < 4.0 + + handler_error <- function(x, overflow=0, buff.size=8192) { + overflow <- as.integer(overflow) + x <- paste0(as.character(x), collapse="") + pad.chars <- buff.size - nchar(x, type='bytes') + overflow + err.msg <- paste0( + paste0(rev(rep_len(rev(LETTERS), pad.chars)), collapse=""), x + ) + old.opt <- options( + error=function(...) { + options(error=old.opt[['error']]) + stop(err.msg) + } + ) + capt_err_msg(stop('initial error')) + } + handler.error.trunc <- vapply( + c(0, 1, 5), handler_error, x=utf8.test, "", buff.size=buff.size.2 + ) + stopifnot(validUTF8(handler.error.trunc)) + + ## Test when warning.length is limiting + + short_error <- function(call.=TRUE) { + old.opt <- options(warning.length=100) + on.exit(old.opt) + f <- function() + stop(paste0(rep_len(0:9, 110), collapse=""), call.=call.) + capt_err_msg(f()) + } + ## trailing newline adds 1 + stopifnot(nchar(short_error(call.=FALSE)) == 101L) + } + + ## PrintGenericVector truncations + ## + ## New printing in r78508 needs to account for UTF-8 truncation + grin <- "\U0001F600" + lc1 <- paste0(c(rep(LETTERS, length.out=110), grin), collapse="") + lc2 <- paste0(c(rep(LETTERS, length.out=111), grin), collapse="") + list.mats <- list(matrix(list(structure(1:2, class=lc1))), + matrix(list(structure(1:2, class=lc2)))) + + ## Allowed UTF-8 truncation in R < 4.1 + ls1 <- paste0(c(rep(0:9, length.out=95), "\U0001F600"), collapse="") + ls2 <- paste0(c(rep(0:9, length.out=96), "\U0001F600"), collapse="") + long.strings <- list(matrix(list(ls1)), matrix(list(ls2))) + + ## Invalid UTF-8 output as "\xf0\x9f..." so needs to be parsed to un-escape + capt_parse <- function(x) { + out <- capture.output(print(x)) + eval(parse(text=paste0(c('c(', sprintf("'%s',", out), 'NULL)'), + collapse=""))[[1]]) + } + capt.parsed <- unlist(lapply(c(list.mats, long.strings), capt_parse)) + stopifnot(validUTF8(capt.parsed)) + + ## Allowed MBCS truncation in R < 4.1 + fmt <- paste0(c(rep_len("a", 253), "\U0001f600"), collapse="") + stopifnot(validUTF8(format(as.POSIXlt('2020-01-01'), fmt))) + + f <- file(paste0(c(rep_len("a", 992), "\U0001F600"), collapse="")) + suppressWarnings(g <- gzcon(f)) + stopifnot(!grepl("xf0", capture.output(g)[2])) + +} + + +## TRE grep with unflagged UTF-8 regex +if (UTF8) { + x <- "d\xc3\xa9faut" # "dĆ©faut" flagged as native + stopifnot(grepl("d.faut", x)) # incorrectly FALSE in R < 4.1 +} + + +## in 4.1.0, encodeString() below would return unflagged UTF-8 +## representation of the string +if (LATIN1OR9) { + y <- "\xfc" + stopifnot(y == encodeString(y)) +} + +## END FROM reg-tests-1d.R + + +## str() -- moved from reg-tests-3.R +cc <- "J\xf6reskog" # valid in "latin-1"; invalid multibyte string in UTF-8 +.tmp <- capture.output( + str(cc) # failed in some R-devel versions +) +stopifnot(grepl("chr \"J.*reskog\"", .tmp)) + + +## source() with multiple encodings -- moved from reg-tests-1e.R +writeLines('x <- "fa\xE7ile"', tf <- tempfile(), useBytes = TRUE) +tools::assertError(source(tf, encoding = "UTF-8")) +source(tf, encoding = c("UTF-8", "latin1")) +## in R 4.2.{0,1} gave Warning (that would now be an error): +## 'length(x) = 2 > 1' in coercion to 'logical(1)' +if (UTF8) stopifnot(identical(Encoding(x), "UTF-8")) diff --git a/tests/reg-tests-1d.R b/tests/reg-tests-1d.R index 4564cd5f862..15308a96148 100644 --- a/tests/reg-tests-1d.R +++ b/tests/reg-tests-1d.R @@ -3693,53 +3693,6 @@ stopifnot(identical(tools::assertError(sqrt("a")), ## The former contained the error object twice in R <= 3.6.2 -## Overriding encoding in parse() -if (l10n_info()$"UTF-8" || l10n_info()$"Latin-1") { - x8 <- "'\uf6'" - x8.2 <- substr(x8, 2, 2) - stopifnot(identical(Encoding(x8), "UTF-8")) - f8 <- tempfile() - writeLines(x8, f8, useBytes=TRUE) # save in UTF-8 - ## - chk_x82 <- function(x) stopifnot(identical(Encoding(x), "UTF-8"), - identical(x, x8.2)) - ## parse(*, encoding = "UTF-8", ..) : - for(FF in c(function(.) parse(text=., encoding="UTF-8", keep.source=TRUE), - function(.) parse(text=., encoding="UTF-8", keep.source=FALSE) - )) { - x <- eval(FF(x8)) - chk_x82(x) - } - for(K.S in c(TRUE, FALSE)) { - x <- eval(parse(file=f8, encoding="UTF-8", keep.source = K.S)) - chk_x82(x) - } - ## latin1 <--> UTF-8 - xl <- iconv(x8, from="UTF-8", to="latin1") - stopifnot(identical(Encoding(xl), "latin1")) - stopifnot(identical(x8, iconv(xl, from="latin1", to="UTF-8"))) - unlist(l10n_info()) # to see .. -} -if (l10n_info()$"UTF-8") { - for(x in c(eval(parse(text=x8)), - eval(parse(text=xl, keep.source=TRUE)), - eval(parse(text=xl, keep.source=FALSE)), - eval(parse(file=f8)), - str2lang(x8), - str2expression(x8))) - stopifnot(identical(x, x8.2)) -} -if (l10n_info()$"Latin-1") { - for(x in c(eval(parse(text=xl)), - eval(parse(text=x8, keep.source=TRUE)), - eval(parse(text=x8, keep.source=FALSE)), - str2lang(x8), - str2expression(x8))) - stopifnot(identical(x, x8.2)) -} -## parse(text=xl) had failed w/ "EOF whilst reading MBCS char at line 2" - - ## smoothEnds(, .) - PR#17693 y1 <- as.integer(c(8,5,4,1,1,1,1)) y2 <- y1; y2[3] <- 6L @@ -4084,243 +4037,6 @@ stopifnot(all.equal(fit$null.deviance, fit0$deviance)) proc.time() - .pt; .pt <- proc.time() -## UTF-8 truncation tests -if (l10n_info()$"UTF-8") { - ## These tests fail on R < 4.0 - - ## Use .Internal(seterrmessage(old.err)) to trigger truncation via - ## Rsnprintf (mbcsTruncateToValid). - trunc_string <- function(x) { - old.err <- geterrmessage() - on.exit(.Internal(seterrmessage(old.err))) - unname( - vapply( - x, - function(y) { - .Internal(seterrmessage(y)) - geterrmessage() - }, - "" - ) - ) - } - ## limits to detect the internal buffer size for truncation (now 8192) - buff.min <- 8 - buff.max <- 7e4 # > buff.min - buff.size <- nchar( - trunc_string(paste0(rep(0:9, length.out = buff.max), collapse="")), - type='bytes' - ) - stopifnot(buff.size >= buff.min + 1) - if(buff.size == buff.max) - ## possibly, the buffer is no longer fixed size? - warning('BUFSIZE too large for UTF-8 truncation test?') - else { - string.base <- paste0( - rep(0:9, length.out = buff.size), - collapse="" - ) - ## Append UTF-8 sequences at the end of strings that are just - ## a bit shorter than the buffer, each one byte longer than the - ## previous. - string.starts <- substr( - rep(string.base, 6), 1, - nchar(string.base) - seq(buff.min, 3, -1) - ) - ## For each of the increasing length string, append 2, 3, and 4 byte - ## (valid) UTF-8 characters. - string.ends <- rep( - c( - '\u00A2', # (cent symbol) - '\u20AC', # <82> (euro symbol) - '\U00010348', # <90><8D><88> (circle with dot) - NULL - ), - each=length(string.starts) - ) - strings <- paste0( - string.starts, - '\U0001F600', # 4 byte grinning face, extra padding char - string.ends - ) - output <- trunc_string(strings) - stopifnot(validUTF8(strings)) # sanity check - stopifnot(validUTF8(output)) - } - ## These tests fail on R < 4.1 - ## - ## Checking that truncation and `...` concatenation are working - ## correctly in verrorcall_dflt. Prior to 4.1 truncation detection did - ## not work with call set, and multibyte characters could be mangled by - ## the `...`. - ## - ## We assume getttext strings are not translated (or are translated - ## to the same byte-length as the ones in source). - - ## We cannot use `tryCatch` as we're testing the C-level error construction - ## and that is not invoked when signalled errors are caught, hence: - capt_err_msg <- function(expr) { - tmp <- tempfile() - on.exit(unlink(tmp)) - err.con <- getConnection(sink.number(type='message')) - sink(file(tmp, 'w'), type='message') - withRestarts(expr, abort=function() sink(err.con, type='message')) - ## add back newlines consumed by readlines; we assume a trailing one - ## exists, if it doesn't readLines will issue a warning - paste0(c(readLines(tmp), ""), collapse="\n") - } - ## Generate errors with long messages (length buff.size + overflow), ending - ## in `x`, to test truncation. Will need to be updated if buff.size is - ## increased. Function names / etc. are all carefully counted. - long_error <- function(x, overflow=0, buff.size=8192) { - overflow <- as.integer(overflow) - x <- paste0(as.character(x), collapse="") - - ## Compute how many chars needed to fill buffer - call.len <- 51 # nchar of a_really...(stop(x)) - see below - extra.len <- 12 # "Error in : " - extra.ws <- 3 # +2 spaces +1 \n from `tail` - chars.left <- buff.size - call.len - extra.len - extra.ws - chars <- nchar(x, type = 'bytes') - pad.chars <- chars.left - chars + as.integer(overflow) - stopifnot(pad.chars >= 0) - err.msg <- paste0(paste0(rev(rep_len(rev(LETTERS), pad.chars)), - collapse = ""), x) - ## force truncation despite 8170 warn length limit - old.opt <- options(warning.length = 8170, warn=2) - on.exit(options(old.opt)) - a_really_long_function_to_cause_truncation <- function(x) x - f <- function(x) - a_really_long_function_to_cause_truncation(stop(x)) - ## trigger error and capture std.err - capt_err_msg(f(err.msg)) - } - buff.size.2 <- buff.size + 1 # .Internal(seterrmessage) drops 1 byte - - ## 2 byte and 4 byte utf-8 encoded chars, avoid code points between \u00a0 - ## and \u0100 as some iconv implementations will translate them into char - ## values in those ranges instead of into "" in C locales. - utf8.test <- '\u0238\U00010348' - - if(buff.size.2 != 8192) { - warning('These tests assume BUFSIZE = 8192') - } else { - ## Mangled multibyte in R < 4.1 - stopifnot(validUTF8(long_error(utf8.test, overflow=-1))) - - ## Truncation detection fails in R < 4.1, so newline isn't appended, so - ## we get a "incomplete final line" warning (converted to error) - long_error(utf8.test, overflow=0) - - overflow <- c( - -6, # Buffer unambiguosly unfilled for MB_CUR_MAX=6 - -5, # Buffer maybe filled for MB_CUR_MAX=6 - -4, # Buffer full with '...\n\0' - -3, # Lose 4 byte UTF-8 char - -2, - -1, - 0, # 4 byte UTF-8 char exactly replaced by '...\n', buffer full - 1, # Lose 2 byte UTF-8 char - 2, - 3, # Lose first non UTF-8 - # These will need to change if R_ConciseTraceback changes - -87, # Room for traceback; options(showErrorCalls=TRUE) - -86 # No room for traceback. - ) - le.res <- vapply(overflow, long_error, character(1), - buff.size = buff.size.2, x = utf8.test) - stopifnot(validUTF8(utf8.test)) # sanity check - stopifnot(validUTF8(le.res)) - - ## # For first one, before truncation test, we've used 8186 bytes, so we - ## # know there was no truncation. Code adds a trailing newline, which - ## # is why we get 8187. For the second, we add one byte to the - ## # message, which puts us in maybe-truncated state, which adds 3 more - ## # bytes via with "...", so total of 8187 + 1 + 3 == 8191. - ## le.res.nc <- nchar(le.res) - ## data.frame(overflow, - ## bytes=nchar(le.res, type='bytes'), - ## snippet=substr(le.res, le.res.nc - 5, le.res.nc)) - ## - ## overflow bytes snippet - ## 1 -6 8187 XYZČøšˆ\n - ## 2 -5 8191 Čøšˆ...\n - ## 3 -4 8192 Čøšˆ...\n - ## 4 -3 8189 ZČø...\n - ## 5 -2 8190 ZČø...\n - ## 6 -1 8191 ZČø...\n - ## 7 0 8192 ZČø...\n - ## 8 1 8191 YZ...\n - ## 9 2 8192 YZ...\n - ## 10 3 8192 XY...\n - ## 11 -87 8192 ation\n - ## 12 -86 8107 XYZČøšˆ\n - ## test recursive errors in handler, Fails R < 4.0 - - handler_error <- function(x, overflow=0, buff.size=8192) { - overflow <- as.integer(overflow) - x <- paste0(as.character(x), collapse="") - pad.chars <- buff.size - nchar(x, type='bytes') + overflow - err.msg <- paste0( - paste0(rev(rep_len(rev(LETTERS), pad.chars)), collapse=""), x - ) - old.opt <- options( - error=function(...) { - options(error=old.opt[['error']]) - stop(err.msg) - } - ) - capt_err_msg(stop('initial error')) - } - handler.error.trunc <- vapply( - c(0, 1, 5), handler_error, x=utf8.test, "", buff.size=buff.size.2 - ) - stopifnot(validUTF8(handler.error.trunc)) - - ## Test when warning.length is limiting - - short_error <- function(call.=TRUE) { - old.opt <- options(warning.length=100) - on.exit(old.opt) - f <- function() - stop(paste0(rep_len(0:9, 110), collapse=""), call.=call.) - capt_err_msg(f()) - } - ## trailing newline adds 1 - stopifnot(nchar(short_error(call.=FALSE)) == 101L) - } - ## PrintGenericVector truncations - ## - ## New printing in r78508 needs to account for UTF-8 truncation - grin <- "\U0001F600" - lc1 <- paste0(c(rep(LETTERS, length.out=110), grin), collapse="") - lc2 <- paste0(c(rep(LETTERS, length.out=111), grin), collapse="") - list.mats <- list(matrix(list(structure(1:2, class=lc1))), - matrix(list(structure(1:2, class=lc2)))) - - ## Allowed UTF-8 truncation in R < 4.1 - ls1 <- paste0(c(rep(0:9, length.out=95), "\U0001F600"), collapse="") - ls2 <- paste0(c(rep(0:9, length.out=96), "\U0001F600"), collapse="") - long.strings <- list(matrix(list(ls1)), matrix(list(ls2))) - - ## Invalid UTF-8 output as "\xf0\x9f..." so needs to be parsed to un-escape - capt_parse <- function(x) { - out <- capture.output(print(x)) - eval(parse(text=paste0(c('c(', sprintf("'%s',", out), 'NULL)'), - collapse=""))[[1]]) - } - capt.parsed <- unlist(lapply(c(list.mats, long.strings), capt_parse)) - stopifnot(validUTF8(capt.parsed)) - - ## Allowed MBCS truncation in R < 4.1 - fmt <- paste0(c(rep_len("a", 253), "\U0001f600"), collapse="") - stopifnot(validUTF8(format(as.POSIXlt('2020-01-01'), fmt))) - - f <- file(paste0(c(rep_len("a", 992), "\U0001F600"), collapse="")) - suppressWarnings(g <- gzcon(f)) - stopifnot(!grepl("xf0", capture.output(g)[2])) -} - ## c() generic removes all NULL elements --- *but* the first --- before dispatch c.foobar <- function(...) list("ok", ...) foobar <- structure(list(), class = "foobar") @@ -4753,12 +4469,6 @@ stopifnot(identical(2:3, tools::checkRdaFiles(c(rda2, rda3))$version)) ## gave '3 3' in R <= 4.0.3 -if (l10n_info()$"UTF-8") { - x <- "d\xc3\xa9faut" # "dĆ©faut" flagged as native - stopifnot(grepl("d.faut", x)) # incorrectly FALSE in in R < 4.1 -} - - ## constructing the names() of quantile(): str(L <- lapply(c(2,3,5,7), function(dig) { options(digits = dig) names(quantile(lynx, probs = 1 - 10^(-1:-5))) })) @@ -5031,16 +4741,6 @@ altreal_dup_multicheck(dvec, 0, 0, 0, s3class = "fake_class") proc.time() - .pt; .pt <- proc.time() -## in 4.1.0, encodeString() below would return unflagged UTF-8 -## representation of the string -if (l10n_info()$"Latin-1" && localeToCharset()=="ISO8859-1") { - # checking localeToCharset() because on Windows, in C locale, - # l10n_info() would report Latin-1 when that is the code page - y <- "\xfc" - stopifnot(y == encodeString(y)) -} - - ## seq(from, to, *) i.e. seq.default() *and* seq.int(..) in case of large ## from & to, notably *infinite (to - from) : seq (-1.5e308, 1e308, by=1e307) # gave error in R <= 4.1.0 diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 3d05c8ca4e8..5c7ce7c08c3 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -261,17 +261,6 @@ stopifnot(identical(o1,o2)) ## the ordered() call has failed in R <= 4.2.x -## source() with multiple encodings -if (l10n_info()$"UTF-8" || l10n_info()$"Latin-1") { - writeLines('x <- "fa\xE7ile"', tf <- tempfile(), useBytes = TRUE) - tools::assertError(source(tf, encoding = "UTF-8")) - source(tf, encoding = c("UTF-8", "latin1")) - ## in R 4.2.{0,1} gave Warning (that would now be an error): - ## 'length(x) = 2 > 1' in coercion to 'logical(1)' - if (l10n_info()$"UTF-8") stopifnot(identical(Encoding(x), "UTF-8")) -} - - ## multi-line Rd macro definition rd <- tools::parse_Rd(textConnection(r"( \newcommand{\mylongmacro}{ diff --git a/tests/reg-tests-3.R b/tests/reg-tests-3.R index f6736a636ae..dec085c4338 100644 --- a/tests/reg-tests-3.R +++ b/tests/reg-tests-3.R @@ -201,16 +201,9 @@ nchar(x, "w", allowNA = TRUE) ## str() on large strings -if (l10n_info()$"UTF-8" || l10n_info()$"Latin-1") { - cc <- "J\xf6reskog" # valid in "latin-1"; invalid multibyte string in UTF-8 - .tmp <- capture.output( - str(cc) # failed in some R-devel versions - ) - stopifnot(grepl("chr \"J.*reskog\"", .tmp)) - - print(nchar(L <- strrep(paste(LETTERS, collapse="."), 100000), type="b")) # 5.1 M - print(str(L)) -} +nchar(L <- strrep(paste(LETTERS, collapse="."), 100000), type="b") # 5.1 M +str(L) + if(require("Matrix", .Library)) { M <- Matrix(diag(1:10), sparse=TRUE) # a "ddiMatrix" diff --git a/tests/reg-tests-3.Rout.save b/tests/reg-tests-3.Rout.save index cbf7eafebf8..487de179a9e 100644 --- a/tests/reg-tests-3.Rout.save +++ b/tests/reg-tests-3.Rout.save @@ -887,16 +887,11 @@ Error in nchar(x, "w") : invalid multibyte string, element 10 > > > ## str() on large strings -> if (l10n_info()$"UTF-8" || l10n_info()$"Latin-1") { -+ cc <- "J\xf6reskog" # valid in "latin-1"; invalid multibyte string in UTF-8 -+ .tmp <- capture.output( -+ str(cc) # failed in some R-devel versions -+ ) -+ stopifnot(grepl("chr \"J.*reskog\"", .tmp)) -+ -+ print(nchar(L <- strrep(paste(LETTERS, collapse="."), 100000), type="b")) # 5.1 M -+ print(str(L)) -+ } +> nchar(L <- strrep(paste(LETTERS, collapse="."), 100000), type="b") # 5.1 M +[1] 5100000 +> str(L) + chr "A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.ZA.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.ZA.B.C.D.E"| __truncated__ +> > > if(require("Matrix", .Library)) { + M <- Matrix(diag(1:10), sparse=TRUE) # a "ddiMatrix" From 3595754a0476ac8e59005569de6aac6b10371836 Mon Sep 17 00:00:00 2001 From: pd Date: Thu, 27 Jun 2024 23:22:39 +0000 Subject: [PATCH 323/546] maintainer-mode changes git-svn-id: https://svn.r-project.org/R/trunk@86848 00db46b3-68df-0310-9c12-caf00c1e9a41 --- configure | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/configure b/configure index 52d3a93eea0..d98b6e10ef8 100755 --- a/configure +++ b/configure @@ -935,7 +935,6 @@ TEXI2DVICMD TEXI2DVI TEXI2ANY_VERSION_MIN TEXI2ANY_VERSION_MAJ -HAVE_TEXI2ANY_V7_TRUE INSTALL_INFO TEXI2ANY MAKEINDEX @@ -6048,12 +6047,6 @@ printf "%s\n" "$as_me: WARNING: ${warn_info}" >&2;} else TEXI2ANY="${TEXI2ANY}" fi -if test "${r_cv_prog_texi2any_v7}" != yes; then - HAVE_TEXI2ANY_V7_TRUE='#' -else - HAVE_TEXI2ANY_V7_TRUE= -fi - TEXI2ANY_VERSION_MAJ=${r_cv_prog_texi2any_version_maj} TEXI2ANY_VERSION_MIN=${r_cv_prog_texi2any_version_min} @@ -27459,7 +27452,7 @@ _ACEOF # flags. r_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $r_verb" -(eval echo $as_me:27462: \"$ac_link\") >&5 +(eval echo $as_me:27455: \"$ac_link\") >&5 r_c_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$r_c_v_output" >&5 CFLAGS=$r_save_CFLAGS @@ -27537,7 +27530,7 @@ _ACEOF # flags. r_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $r_cv_prog_c_v" -(eval echo $as_me:27540: \"$ac_link\") >&5 +(eval echo $as_me:27533: \"$ac_link\") >&5 r_c_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$r_c_v_output" >&5 CFLAGS=$r_save_CFLAGS From 71afe1e304b11f7febaa536e96817c63a7c1c7ab Mon Sep 17 00:00:00 2001 From: smeyer Date: Fri, 28 Jun 2024 08:50:59 +0000 Subject: [PATCH 324/546] avoid some partial matching (PR#18710, by Michael Chirico) git-svn-id: https://svn.r-project.org/R/trunk@86849 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/datasets/data/iris.R | 2 +- src/library/datasets/data/state.R | 2 +- src/library/grid/R/group.R | 20 ++++++++++---------- src/library/stats/man/lmfit.Rd | 4 ++-- tests/Examples/stats-Ex.Rout.save | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/library/datasets/data/iris.R b/src/library/datasets/data/iris.R index 68b7f325405..9fdda063082 100644 --- a/src/library/datasets/data/iris.R +++ b/src/library/datasets/data/iris.R @@ -42,4 +42,4 @@ Petal.Width = c(0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 2.2, 2.3, 1.5, 2.3, 2, 2, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2, 2.3, 1.8), -Species = gl(3,50, label = c("setosa", "versicolor", "virginica"))) +Species = gl(3,50, labels = c("setosa", "versicolor", "virginica"))) diff --git a/src/library/datasets/data/state.R b/src/library/datasets/data/state.R index 3388e68bb7f..0e71e1da63b 100644 --- a/src/library/datasets/data/state.R +++ b/src/library/datasets/data/state.R @@ -60,7 +60,7 @@ factor(c(4, 9, 8, 5, 9, 8, 1, 3, 3, 3, 9, 8, 6, 6, 7, 7, 4, 5, factor(c(2, 4, 4, 2, 4, 4, 1, 2, 2, 2, 4, 4, 3, 3, 3, 3, 2, 2, 1, 2, 1, 3, 3, 2, 3, 4, 3, 4, 1, 1, 4, 1, 2, 3, 3, 2, 4, 1, 1, 2, 3, 2, 2, 4, 1, 2, 4, 2, 3, 4), levels=1:4, -label = c("Northeast", "South", "North Central", "West")) +labels = c("Northeast", "South", "North Central", "West")) "state.x77" <- structure(c(3615, 365, 2212, 2110, 21198, 2541, 3100, 579, 8277, 4931, diff --git a/src/library/grid/R/group.R b/src/library/grid/R/group.R index 413ef50af14..d51379a63ee 100644 --- a/src/library/grid/R/group.R +++ b/src/library/grid/R/group.R @@ -26,8 +26,8 @@ finaliseGroup <- function(x) { ## ## Justification of the current viewport must also be preserved ## so that transformation on group use is calculated correctly. - hjust <- resolveHJust(cvp$just, cvp$hjust) - vjust <- resolveVJust(cvp$just, cvp$vjust) + hjust <- resolveHJust(cvp$justification, cvp$hjust) + vjust <- resolveVJust(cvp$justification, cvp$vjust) pushViewport(viewport(hjust, vjust, just=c(hjust, vjust), mask="none", @@ -40,8 +40,8 @@ finaliseGroup <- function(x) { if (is.grob(x$dst)) { destination <- function() { cvp <- current.viewport() - hjust <- resolveHJust(cvp$just, cvp$hjust) - vjust <- resolveVJust(cvp$just, cvp$vjust) + hjust <- resolveHJust(cvp$justification, cvp$hjust) + vjust <- resolveVJust(cvp$justification, cvp$vjust) pushViewport(viewport(hjust, vjust, just=c(hjust, vjust), mask="none", @@ -80,11 +80,11 @@ recordGroup <- function(x, ref) { group <- list(ref=ref, ## Record location, size, angle for re-use in ## different viewport - xy=deviceLoc(unit(resolveHJust(cvp$just, cvp$hjust), "npc"), - unit(resolveVJust(cvp$just, cvp$vjust), "npc"), + xy=deviceLoc(unit(resolveHJust(cvp$justification, cvp$hjust), "npc"), + unit(resolveVJust(cvp$justification, cvp$vjust), "npc"), valueOnly=TRUE, device=TRUE), - xyin=deviceLoc(unit(resolveHJust(cvp$just, cvp$hjust), "npc"), - unit(resolveVJust(cvp$just, cvp$vjust), "npc"), + xyin=deviceLoc(unit(resolveHJust(cvp$justification, cvp$hjust), "npc"), + unit(resolveVJust(cvp$justification, cvp$vjust), "npc"), valueOnly=TRUE, device=FALSE), wh=c(convertX(unit(1, "npc"), "in", valueOnly=TRUE), convertY(unit(1, "npc"), "in", valueOnly=TRUE)), @@ -134,8 +134,8 @@ defnTranslate <- function(group, inverse=FALSE, device=TRUE) { useTranslate <- function(inverse=FALSE, device=TRUE) { cvp <- current.viewport() - xy <- deviceLoc(unit(resolveHJust(cvp$just, cvp$hjust), "npc"), - unit(resolveVJust(cvp$just, cvp$vjust), "npc"), + xy <- deviceLoc(unit(resolveHJust(cvp$justification, cvp$hjust), "npc"), + unit(resolveVJust(cvp$justification, cvp$vjust), "npc"), valueOnly=TRUE, device=device) if (inverse) { groupTranslate(-xy$x, -xy$y) diff --git a/src/library/stats/man/lmfit.Rd b/src/library/stats/man/lmfit.Rd index 412d81c6fef..06469b70f2b 100644 --- a/src/library/stats/man/lmfit.Rd +++ b/src/library/stats/man/lmfit.Rd @@ -95,8 +95,8 @@ str(lm. <- lm.fit (x = X, y = y)) lm.. <- .lm.fit(X,y) lm.w <- .lm.fit(X*sqrt(w), y*sqrt(w)) id <- function(x, y) all.equal(x, y, tolerance = 1e-15, scale = 1) - stopifnot(id(unname(lm.$coef), lm..$coef), - id(unname(lmw$coef), lm.w$coef)) + stopifnot(id(unname(lm.$coefficients), lm..$coefficients), + id(unname(lmw$coefficients), lm.w$coefficients)) } ## fits w/o intercept: all.equal(unname(coef(lm(y ~ X-1))), diff --git a/tests/Examples/stats-Ex.Rout.save b/tests/Examples/stats-Ex.Rout.save index 575a72f4bd2..3223c792851 100644 --- a/tests/Examples/stats-Ex.Rout.save +++ b/tests/Examples/stats-Ex.Rout.save @@ -9516,8 +9516,8 @@ List of 8 > lm.. <- .lm.fit(X,y) > lm.w <- .lm.fit(X*sqrt(w), y*sqrt(w)) > id <- function(x, y) all.equal(x, y, tolerance = 1e-15, scale = 1) -> stopifnot(id(unname(lm.$coef), lm..$coef), -+ id(unname(lmw$coef), lm.w$coef)) +> stopifnot(id(unname(lm.$coefficients), lm..$coefficients), ++ id(unname(lmw$coefficients), lm.w$coefficients)) > ## End(Don't show) > ## fits w/o intercept: > all.equal(unname(coef(lm(y ~ X-1))), From dcec55159e4eceeed93eca7d15be32d8f362180c Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 28 Jun 2024 16:43:48 +0000 Subject: [PATCH 325/546] Add CLEAR_ATTRIB, ANY_ATTRIB, and NO_ATTRIB. git-svn-id: https://svn.r-project.org/R/trunk@86850 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 5 ++++- src/include/Defn.h | 1 + src/include/Rinternals.h | 3 +++ src/main/memory.c | 7 +++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 723d3eb9050..7802ce9ecb3 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13554,7 +13554,10 @@ another. This can be done using @code{DUPLICATE_ATTRIB} or @code{SHALLOW_DUPLICATE_ATTRIB} @apifun DUPLICATE_ATTRIB @apifun SHALLOW_DUPLICATE_ATTRIB - +@code{ANY_ATTRIB} checks whether there are any attributes and +@code{CLEAR_ATTRIB} removes all attributes. +@apifun ANY_ATTRIB +@apifun CLEAR_ATTRIB However, at least some of this copying is unneeded. In the first assignment shown, @code{x <- 1:10}, @R{} first creates an object with diff --git a/src/include/Defn.h b/src/include/Defn.h index 05c4e822a83..11b803b3e05 100644 --- a/src/include/Defn.h +++ b/src/include/Defn.h @@ -234,6 +234,7 @@ typedef union { VECTOR_SEXPREC s; double align; } SEXPREC_ALIGN; #define ALTREP(x) ((x)->sxpinfo.alt) #define SETALTREP(x, v) (((x)->sxpinfo.alt) = (v)) #define SETSCALAR(x, v) (((x)->sxpinfo.scalar) = (v)) +#define ANY_ATTRIB(x) (ATTRIB(x) != R_NilValue) #if defined(COMPUTE_REFCNT_VALUES) # define REFCNT(x) ((x)->sxpinfo.named) diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index f020f5e20d1..517376b19aa 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -265,6 +265,9 @@ void SET_ATTRIB(SEXP x, SEXP v); void DUPLICATE_ATTRIB(SEXP to, SEXP from); void SHALLOW_DUPLICATE_ATTRIB(SEXP to, SEXP from); void (MARK_NOT_MUTABLE)(SEXP x); +void CLEAR_ATTRIB(SEXP x); +int (ANY_ATTRIB)(SEXP x); +#define NO_ATTRIB(x) (! ANY_ATTRIB(x)) /* S4 object testing */ int (IS_S4_OBJECT)(SEXP x); diff --git a/src/main/memory.c b/src/main/memory.c index 4534322bad5..1415531db8d 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -3879,6 +3879,7 @@ DL_FUNC R_ExternalPtrAddrFn(SEXP s) /* General Cons Cell Attributes */ SEXP (ATTRIB)(SEXP x) { return CHK(ATTRIB(CHK(x))); } +int (ANY_ATTRIB)(SEXP x) { return ANY_ATTRIB(CHK(x)); } int (OBJECT)(SEXP x) { return OBJECT(CHK(x)); } int (TYPEOF)(SEXP x) { return TYPEOF(CHK(x)); } int (NAMED)(SEXP x) { return NAMED(CHK(x)); } @@ -3945,6 +3946,12 @@ void SHALLOW_DUPLICATE_ATTRIB(SEXP to, SEXP from) { SET_OBJECT(CHK(to), OBJECT(from)); IS_S4_OBJECT(from) ? SET_S4_OBJECT(to) : UNSET_S4_OBJECT(to); } +void CLEAR_ATTRIB(SEXP x) +{ + SET_ATTRIB(CHK(x), R_NilValue); + SET_OBJECT(x, 0); + UNSET_S4_OBJECT(x); +} NORET static void bad_SET_TYPEOF(int from, int to) { From 0c5ec736690c7bb58a2180298cd5968c404d4203 Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 29 Jun 2024 16:32:29 +0000 Subject: [PATCH 326/546] Add R_getVar and R_getVarEx as @apifun. Change example to use R_getVar instead of findVar. git-svn-id: https://svn.r-project.org/R/trunk@86851 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 7802ce9ecb3..09d52b09f49 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13206,11 +13206,13 @@ SEXP getvar(SEXP name, SEXP rho) @{ SEXP ans; - if(!isString(name) || length(name) != 1) + if (!isString(name) || length(name) != 1) error("name is not a single string"); - if(!isEnvironment(rho)) + if (!isEnvironment(rho)) error("rho should be an environment"); - ans = findVar(installChar(STRING_ELT(name, 0)), rho); + ans = R_getVar(installChar(STRING_ELT(name, 0)), rho, TRUE); + if (TYPEOF(ans) != REALSXP || length(ans) == 0) + error("value is not a numeric vector with at least one element"); Rprintf("first value is %f\n", REAL(ans)[0]); return R_NilValue; @} @@ -13219,13 +13221,20 @@ SEXP getvar(SEXP name, SEXP rho) @apifun installChar The main work is done by -@findex findVar -@code{findVar}, but to use it we need to install @code{name} as a name +@apifun R_getVar +@code{R_getVar}, but to use it we need to install @code{name} as a name in the symbol table. As we wanted the value for internal use, we return @code{NULL}. -Similar functions with syntax +@code{R_getVar} is similar to the @R{} function @code{get}. It signals +an error if there is no binding for the variable in the +environment. @code{R_getVarEx} can be used to return a default value if +no binding is found; this corresponds to the @R{} function @code{get0}. +@apifun R_getVarEx +The third argument to @code{R_getVar} and @code{R_getVarEx} corresponds +to the @code{inherits} argument to the @R{} function @code{get}. +Functions with syntax @example @group void defineVar(SEXP symbol, SEXP value, SEXP rho) From bf654dba3f6133dd2cce78fde038263dc5c65030 Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 29 Jun 2024 17:23:42 +0000 Subject: [PATCH 327/546] Add more non-API replacements. git-svn-id: https://svn.r-project.org/R/trunk@86852 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 09d52b09f49..69066fbd243 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -17381,8 +17381,28 @@ functions that should be used instead: Use @code{charIsASCII}, added in @R{} 4.5.0. @item IS_UTF8 Use @code{charIsUTF8}, added in @R{} 4.5.0, or avoid completely. +@item allocSExp + Use an appropriate constructor. @item findVarInFrame3 Use @code{R_existsVarInFrame} to test for existence. +@item findVar +@itemx findVarInFrame + Use @code{R_getVar} or @code{R_getVarEx}, added in @R{} 4.5.0. + In some cases using @code{eval} may suffice. +@item ATTRIB + Use @code{getAttrib} for individual attributes. To test whether + there are any attributes use @code{ANY_ATTRIB}, added in @R{} + 4.5.0. +@item SET_ATTRIB +@itemx SET_OBJECT + Use @code{setAttrib} for individual attributes, + @code{DUPLICATE_ATTRIB} or @code{SHALLOW_DUPLICATE_ATTRIB} for + copying attributes from one object to another. Use + @code{CLEAR_ATTRIB} for removing all attributes, added in @R{} + 4.5.0. +@item R_GetCurrentEnv + Use @code{environment()} at the @R{} level and pass the result as + an argument to your C function. @end table For recently added entry points packages that need to be compiled From 2cb21d4153296912dd2cf7694e1d8e039e747c94 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 30 Jun 2024 01:03:59 +0000 Subject: [PATCH 328/546] Add some notes on ATTRIB, findVar and such. git-svn-id: https://svn.r-project.org/R/trunk@86853 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 69066fbd243..b1213c3969c 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -17332,6 +17332,8 @@ be adjusted as changes are made to the API. * Creating call expressions:: * Creating closures:: * Querying CHARSXP encoding:: +* Working with attributes:: +* Working with variable bindings:: * Some backports:: @end menu @@ -17534,6 +17536,38 @@ char *asutf8(SEXP c) as the encoding flags are already checked in @code{translateCharUTF8}. Also note the non-compliant check doesn't handle native encoding. +@node Working with attributes, Working with variable bindings, Querying CHARSXP encoding, Moving into C API compliance +@subsection Working with attributes + +The current implementation (@R{} 4.5.0) represents attributes internally +as a linked list. It may be useful to change this at some point, so +external code should not rely on this representation. The low-level +functions @code{ATTRIB} and @code{SET_ATTRIB} reveal this representation +and are therefore not part of the API. Individual attributes can be +accessed and set with @code{getAttrib} and @code{setAttrib}. Attributes +can be copied from one object to another with @code{DUPLICATE_ATTRIB} +and @code{SHALLOW_DUPLICATE_ATTRIB}. The @code{CLEAR_ATTRIB} function +added in @R{} 4.5.0 can be used to remove all attributes. These +functions ensure can that certain consistency requirements are +maintained, such as setting the object bit according to whether a class +attribute is present. + +Some additional functions may be added for working with attributes. + +@node Working with variable bindings, Some backports, Working with attributes, Moving into C API compliance +@subsection Working variable bindings + +The functions @code{findVar} and @code{findVarInFrame} have been used in +a number of packages but are too low level to be part of the API. For +most uses the functions @code{R_getVar} and @code{R_getVarEx} added in +@R{} 4.5.0 will be sufficient. These are analogous to the R functions +@code{get} and @code{get0}. + +In rare cases package @R{} or C code may want to obtain more detailed +information on a binding, such as whether the binding is delayed or +not. This is currently not possible within the API, but is under +consideration. + @node Some backports, , Querying CHARSXP encoding, Moving into C API compliance @subsection Some backports @@ -17566,6 +17600,13 @@ SEXP R_mkClosure(SEXP formals, SEXP body, SEXP env) SET_CLOENV(fun, env); return fun; @} + +void CLEAR_ATTRIB(SEXP x) +@{ + SET_ATTRIB(CHK(x), R_NilValue); + SET_OBJECT(x, 0); + UNSET_S4_OBJECT(x); +@} #endif @end example From b55931dc1f84e70339a5feb26742884588d18f48 Mon Sep 17 00:00:00 2001 From: ripley Date: Sun, 30 Jun 2024 15:56:28 +0000 Subject: [PATCH 329/546] do no give message about non-API when none are detected, grammar, remove duplicatioon git-svn-id: https://svn.r-project.org/R/trunk@86854 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 49e97737e2f..3aa2171ac18 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -3867,12 +3867,12 @@ add_dummies <- function(dir, Log) if(nRS) msg <- c(msg, "It is good practice to register native routines and to disable symbol search.\n") + msg2 <- "See 'Writing portable packages' in the 'Writing R Extensions' manual" + msg3 <- "and section 'Moving into C API compliance' for issues with the use of non-API entry points.\n" wrapLog("\n", paste(msg, collapse = " "), "\n", - "See 'Writing portable packages'", - "in the 'Writing R Extensions' manual.", - "See section 'Moving into C API compliance' in the ", - "'Writing R Extensions' manual for issues with use ", - "of non-API entry points.\n") + if(nAPIs) paste0(msg2, ",\n", msg3) + else paste0(msg2, ".") + ) } else resultLog(Log, "OK") } From a326b9bef86c987279d64477c0a6354124ecccdb Mon Sep 17 00:00:00 2001 From: smeyer Date: Mon, 1 Jul 2024 11:28:07 +0000 Subject: [PATCH 330/546] drop obsolete Texinfo switch 'UseExternalXrefs' git-svn-id: https://svn.r-project.org/R/trunk@86855 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/Makefile.in | 6 +- doc/manual/Makefile.win | 6 +- doc/manual/R-FAQ.texi | 47 ++----------- doc/manual/R-admin.texi | 7 +- doc/manual/R-exts.texi | 149 +++++++++------------------------------- doc/manual/R-intro.texi | 30 ++------ doc/manual/R-ints.texi | 38 ++-------- 7 files changed, 55 insertions(+), 228 deletions(-) diff --git a/doc/manual/Makefile.in b/doc/manual/Makefile.in index d4aab2bfa13..dc06593a3bd 100644 --- a/doc/manual/Makefile.in +++ b/doc/manual/Makefile.in @@ -42,7 +42,7 @@ TEXI2ANY_TEXT_OPTS = --number-sections --fill-column=76 --no-split --no-headers TEXI2HTML = $(TEXI2ANY) $(TEXI2ANY_HTML_OPTS) TEXI2TEXT = $(TEXI2ANY) $(TEXI2ANY_TEXT_OPTS) ## some broken versions of texi2dvi need C collation. -TEXI2DVI = LC_COLLATE=C @TEXI2DVI@ --texinfo="@set UseExternalXrefs " +TEXI2DVI = LC_COLLATE=C @TEXI2DVI@ TEXI2PDF = $(TEXI2DVI) --pdf PDFLATEX = @PDFLATEX@ ## These are used to check if there is a non-empty path to the @@ -96,7 +96,7 @@ docs: html $(ECHO) "file $@ will be missing and linked from CRAN"; \ else \ $(ECHO) "creating doc/manual/$@"; \ - $(TEXI2HTML) -D UseExternalXrefs -I$(srcdir) \ + $(TEXI2HTML) -I$(srcdir) \ `test $(TEXI2ANY_VERSION_MAJ) -ge 7 && $(ECHO) -c HTMLXREF_MODE=none` \ $< -o $@.tmp || exit 1; \ SED="$(SED)" $(SHELL) $(srcdir)/texi2html.sh \ @@ -109,7 +109,7 @@ docs: html $(ECHO) "ERROR: 'texi2any' v5.1 or later needed but missing on your system."; \ exit 1; \ fi - $(TEXI2ANY) --enable-encoding -D UseExternalXrefs -I$(srcdir) $< + $(TEXI2ANY) --enable-encoding -I$(srcdir) $< .texi.pdf: @if test -z "$(TEXI2DVI0)"; then \ diff --git a/doc/manual/Makefile.win b/doc/manual/Makefile.win index 452f541c3fc..ba4ca6f2bf7 100644 --- a/doc/manual/Makefile.win +++ b/doc/manual/Makefile.win @@ -61,12 +61,12 @@ all: pdf ifneq "$(TEXI2ANY)" "missing" .texi.html: @$(ECHO) "creating doc/manual/$@" - @$(TEXI2HTML) -D UseExternalXrefs -I$(srcdir) $< -o $@.tmp || exit 1 + @$(TEXI2HTML) -I$(srcdir) $< -o $@.tmp || exit 1 @$(SED) -f $(srcdir)/quot.sed $@.tmp > $@ @rm -f $@.tmp .texi.info: - LC_ALL=C $(TEXI2ANY) --enable-encoding -D UseExternalXrefs -I$(srcdir) $< + LC_ALL=C $(TEXI2ANY) --enable-encoding -I$(srcdir) $< else .texi.html: @$(ECHO) "texi2any is not available" @@ -83,7 +83,7 @@ ifeq ($(strip $(TEXI2DVI)),) $(PDFTEX) $< else .texi.pdf: - $(TEXI2DVI) --pdf --texinfo="@set UseExternalXrefs " $< + $(TEXI2DVI) --pdf $< endif diff --git a/doc/manual/R-FAQ.texi b/doc/manual/R-FAQ.texi index 072c698166a..56dc2ceb54e 100644 --- a/doc/manual/R-FAQ.texi +++ b/doc/manual/R-FAQ.texi @@ -1903,17 +1903,11 @@ package subdirectory may also contain files @file{INDEX}, @file{NAMESPACE}, @file{configure}, @file{cleanup}, @file{LICENSE}, @file{LICENCE}, @file{COPYING} and @file{NEWS}. -@ifclear UseExternalXrefs -See section ``Creating R packages'' in @cite{Writing R Extensions}, for -details. This manual is included in the R distribution, @pxref{What +@xref{Creating R packages, , , R-exts, Writing R Extensions} +for details. This manual is included in the R distribution, @pxref{What documentation exists for R?}, and gives information on package structure, the configure and cleanup mechanisms, and on automated package checking and building. -@end ifclear -@ifset UseExternalXrefs -@xref{Creating R packages, , Creating R packages, R-exts, Writing R Extensions}, -for details. -@end ifset R version 1.3.0 has added the function @code{package.skeleton()} which will set up directories, save data and code, and create skeleton help @@ -3324,15 +3318,9 @@ cases you don't want anything printed. Roughly speaking, you need to start R inside the debugger, load the code, send an interrupt, and then set the required breakpoints. -@ifclear UseExternalXrefs -See section ``Finding entry points in dynamically loaded code'' in -@cite{Writing R Extensions}. This manual is included in the R -distribution, @pxref{What documentation exists for R?}. -@end ifclear -@ifset UseExternalXrefs @xref{Finding entry points, , Finding entry points in dynamically loaded -code, R-exts, Writing R Extensions}. -@end ifset +code, R-exts, Writing R Extensions}. This manual is included in the R +distribution, @pxref{What documentation exists for R?}. @node How can I inspect R objects when debugging?, How can I change compilation flags?, How can I debug dynamically loaded code?, R Programming @section How can I inspect R objects when debugging? @@ -3340,14 +3328,8 @@ code, R-exts, Writing R Extensions}. The most convenient way is to call @code{R_PV} from the symbolic debugger. -@ifclear UseExternalXrefs -See section ``Inspecting R objects when debugging'' in @cite{Writing R -Extensions}. -@end ifclear -@ifset UseExternalXrefs @xref{Inspecting R objects, , Inspecting R objects when debugging, R-exts, Writing R Extensions}. -@end ifset @node How can I change compilation flags?, How can I debug S4 methods?, How can I inspect R objects when debugging?, R Programming @section How can I change compilation flags? @@ -3358,26 +3340,7 @@ Suppose you have C code file for @I{dynloading} into R, but you want to use Starting with R 2.1.0, users can provide personal @file{Makevars} configuration files in @file{$@env{HOME}/.R} to override the default flags. -@ifclear UseExternalXrefs -See section ``Add-on packages'' in @cite{R Installation and -Administration}. -@end ifclear -@ifset UseExternalXrefs -@xref{Add-on packages, , Add-on packages, R-admin, -R Installation and Administration}. -@end ifset - -@c For earlier versions of R, you could change the file -@c @file{@var{R_HOME}/etc/Makeconf} to reflect your preferences, or (at -@c least for systems using @acronym{GNU} Make) override them by the -@c environment variable @env{MAKEFLAGS}. -@c @ifclear UseExternalXrefs -@c See section ``Creating shared objects'' in @cite{Writing R Extensions}. -@c @end ifclear -@c @ifset UseExternalXrefs -@c @xref{Creating shared objects, , Creating shared objects, R-exts, -@c Writing R Extensions}. -@c @end ifset +@xref{Add-on packages, , , R-admin, R Installation and Administration}. @node How can I debug S4 methods?, , How can I change compilation flags?, R Programming @section How can I debug S4 methods? diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index f38026fcf55..a25a45e975d 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -1810,12 +1810,7 @@ installed version. How to start @R{} and what command-line options are available is discussed in -@ifset UseExternalXrefs -@ref{Invoking R, , Invoking R, R-intro, An Introduction to R}. -@end ifset -@ifclear UseExternalXrefs -section `Invoking R' in the `An Introduction to R' manual. -@end ifclear +@ref{Invoking R, , , R-intro, An Introduction to R}. You should ensure that the shell has set adequate resource limits: @R{} expects a stack size of at least 8MB and to be able to open at least 256 diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index b1213c3969c..1e02313df31 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -152,15 +152,8 @@ Administration'' manual describes what is needed for each OS. Once a source package is created, it must be installed by the command @code{R CMD INSTALL}. -@ifset UseExternalXrefs -@xref{Add-on packages, , Add-on-packages, +@xref{Add-on packages, , , R-admin, R Installation and Administration}. -@end ifset -@ifclear UseExternalXrefs -See section `Add-on-packages' in the `R Installation and Administration' -manual for more information. -@end ifclear - Other types of extensions are supported (but rare): @xref{Package types}. @@ -254,12 +247,7 @@ package are created at installation time and stored in a database in the session at first use. This makes the @R{} session start up faster and use less (virtual) memory. (For technical details, -@ifset UseExternalXrefs -@pxref{Lazy loading, , Lazy loading, R-ints, R Internals}.) -@end ifset -@ifclear UseExternalXrefs -see section `Lazy loading' in the `R Internals' manual.) -@end ifclear +@pxref{Lazy loading, , , R-ints, R Internals}.) @cindex CRAN @@ -2229,14 +2217,9 @@ as @command{clang} which aim to be options-compatible with it). Also, do not set variables such as @code{CPPFLAGS}, @code{CFLAGS} etc.: these should be settable by users (sites) through appropriate personal (site-wide) @file{Makevars} files. -@ifset UseExternalXrefs -@xref{Customizing package compilation, , Customizing package compilation, -R-admin, R Installation and Administration}, -@end ifset -@ifclear UseExternalXrefs -See section `Customizing package compilation' in the `R Installation and -Administration' manual for more information. -@end ifclear +@xref{Customizing package compilation, , , +R-admin, R Installation and Administration} +for more information. There are some macros@footnote{in POSIX parlance: GNU @command{make} calls these `make variables'.} which are set whilst configuring the @@ -3633,13 +3616,7 @@ examples. Each example is run in a `clean' environment (so earlier examples cannot be assumed to have been run), and with the variables @code{T} and @code{F} redefined to generate an error unless they are set in the example: -@ifset UseExternalXrefs -@xref{Logical vectors, , Logical vectors, R-intro, An Introduction to R}. -@end ifset -@ifclear UseExternalXrefs -See section `Logical vectors' in the `An Introduction to R' manual for -more information. -@end ifclear +@xref{Logical vectors, , , R-intro, An Introduction to R}. @item If the package sources contain a @file{tests} directory then the tests @@ -3684,14 +3661,9 @@ set to a false value.) The PDF version of the package's manual is created (to check that the @file{Rd} files can be converted successfully). This needs @LaTeX{} and suitable fonts and @LaTeX{} packages to be installed. -@ifset UseExternalXrefs -@xref{Making the manuals, , Making the manuals, -R-admin, R Installation and Administration}. -@end ifset -@ifclear UseExternalXrefs -See the section `Making the manuals' in the `R Installation and -Administration' manual' for further details. -@end ifclear +@xref{Making the manuals, , , +R-admin, R Installation and Administration} +for further details. @item Optionally (including by @command{R CMD check --as-cran}) the HTML @@ -3713,12 +3685,7 @@ Use @kbd{R CMD check --help} to obtain more information about the usage of the @R{} package checker. A subset of the checking steps can be selected by adding command-line options. It also allows customization by setting environment variables @w{@env{_R_CHECK_*_}} as described in -@ifset UseExternalXrefs -@ref{Tools, , Tools, R-ints, R Internals}: -@end ifset -@ifclear UseExternalXrefs -section `Tools' in the `R Internals' manual: -@end ifclear +@ref{Tools, , , R-ints, R Internals}: a set of these customizations similar to those used by @acronym{CRAN} can be selected by the option @option{--as-cran} (which works best if Internet access is available). Some Windows users may @@ -5133,14 +5100,9 @@ platforms (although it commonly is on macOS to support the GUI), so there need not be a file @file{libR.so} nor @file{libR.dylib}. Users of @command{cmake} or @command{rust} have all too frequently assumed otherwise, so do ensure your package is checked under a vanilla @R{} build. -@ifset UseExternalXrefs -@xref{Configuration options, , Configuration options, -R-admin, R Installation and Administration}. -@end ifset -@ifclear UseExternalXrefs -See the section `Configuration options' in the `R Installation and -Administration' manual for more information. -@end ifclear +@xref{Configuration options, , , +R-admin, R Installation and Administration} +for more information. @item Make use of the abilities of your compilers to check the @@ -5154,14 +5116,9 @@ where @code{g++ -Wall -pedantic} will alert you to the use of some of the GNU extensions which fail to compile on most other C++ compilers. If @R{} was not configured accordingly, one can achieve this @emph{via} personal @file{Makevars} files. -@ifset UseExternalXrefs -@xref{Customizing package compilation, , Customizing package compilation, -R-admin, R Installation and Administration}, -@end ifset -@ifclear UseExternalXrefs -See section `Customizing package compilation' in the `R Installation and -Administration' manual for more information. -@end ifclear +@xref{Customizing package compilation, , , +R-admin, R Installation and Administration} +for more information. Portable C++ code needs to follow all of the 2011, 2014 and 2017 standards (including not using deprecated/removed features) or to @@ -6769,15 +6726,9 @@ in the @file{libs} directory will show what they depend on: watch for any dependencies in @file{/usr/local/lib} or @file{/usr/local/gfortran/lib}, notably @file{libgfortran.?.dylib} and @file{libquadmath.0.dylib}. -@ifset UseExternalXrefs (For ways to fix these, -@pxref{Building binary packages, , Building binary-packages, +@pxref{Building binary packages, , , R-admin, R Installation and Administration}.) -@end ifset -@ifclear UseExternalXrefs -(For ways to fix these, see the section `Building binary packages' in -the `R Installation and Administration' manual'.) -@end ifclear Many people (including the @acronym{CRAN} package repository) will not accept source packages containing binary files as the latter are a @@ -7018,14 +6969,9 @@ in the @file{po} subdirectory of the package with a name that is either @samp{@var{ll}.po} or @samp{R-@var{ll}.po} for translations of the C and @R{} messages respectively to language with code @samp{@var{ll}}. -@ifset UseExternalXrefs -@xref{Localization of messages, , Localization of messages, R-admin, -R Installation and Administration}, for details of language codes. -@end ifset -@ifclear UseExternalXrefs -See `Localization of messages' in the `R Installation and -Administration' manual for details of language codes. -@end ifclear +@xref{Localization of messages, , , +R-admin, R Installation and Administration} +for details of language codes. There is an @R{} function, @code{update_pkg_po} in package @pkg{tools}, to automate much of the maintenance of message translations. See its @@ -8814,13 +8760,8 @@ Although the deparsing cannot do so, we recommend the consistent use of the preferred assignment operator @samp{<-} (rather than @samp{=}) for assignment. Many package authors use a version of Emacs (on a Unix-alike or Windows) to edit @R{} code, using the @I{ESS[S]} mode of the -@acronym{ESS} Emacs package. See -@ifset UseExternalXrefs -@ref{R coding standards, , R coding standards, R-ints, R Internals} -@end ifset -@ifclear UseExternalXrefs -section `R coding standards' in the `R Internals' manual -@end ifclear +@acronym{ESS} Emacs package. +@xref{R coding standards, , , R-ints, R Internals} for style options within the @I{ESS[S]} mode recommended for the source code of @R{} itself. @@ -10707,15 +10648,9 @@ and Fortran. Use this @emph{via} @command{R CMD INSTALL --use-LTO} (but that does not apply if there is a @file{src/Makefile} file or a Windows analogue). -To set up support on a Unix-alike, see -@ifset UseExternalXrefs -@ref{Link-Time Optimization, , Link-Time Optimization, +To set up support on a Unix-alike, +@pxref{Link-Time Optimization, , , R-admin, R Installation and Administration}. -@end ifset -@ifclear UseExternalXrefs -section `Link-Time Optimization' in the `R Installation and -Administration' manual. -@end ifclear On Linux using GCC without building @R{} with @abbr{LTO} support, @c This will not set @abbr{LTO} for linking, but GCC does not seem to need that. it should suffice to set @@ -10726,14 +10661,9 @@ AR = gcc-ar NM = gcc-nm @end example in a personal (or site) @file{Makevars} file: -@ifset UseExternalXrefs -@xref{Customizing package compilation, , Customizing package compilation, -R-admin, R Installation and Administration}, -@end ifset -@ifclear UseExternalXrefs -See `Customizing package compilation' in the `R Installation and -Administration' manual for more information. -@end ifclear +@xref{Customizing package compilation, , , +R-admin, R Installation and Administration} +for more information. For Windows, first edit file @file{etc/$@{R_ARCH@}/Makeconf} to give @code{LTO_OPT} the value @code{-flto} or do so in a personal/site @@ -11948,14 +11878,9 @@ MAKEFLAGS="CFLAGS=-O3" R CMD SHLIB *.c It is also possible to set such variables in personal @file{Makevars} files, which are read after the local @file{Makevars} and the system makefiles or in a site-wide @file{Makevars.site} file. -@ifset UseExternalXrefs -@xref{Customizing package compilation, , Customizing package compilation, -R-admin, R Installation and Administration}, -@end ifset -@ifclear UseExternalXrefs -See `Customizing package compilation' in the `R Installation and -Administration' manual for more information. -@end ifclear +@xref{Customizing package compilation, , , +R-admin, R Installation and Administration} +for more information. Note that as @command{R CMD SHLIB} uses Make, it will not remake a shared object just because the flags have changed, and if @file{test.c} and @@ -12493,12 +12418,7 @@ structure as a @emph{variant type} that can handle all the usual types of @R{} objects, that is vectors of various modes, functions, environments, language objects and so on. The details are given later in this section and in -@ifset UseExternalXrefs -@ref{R Internal Structures, , R Internal Structures, R-ints, R Internals}, -@end ifset -@ifclear UseExternalXrefs -section `R Internal Structures' in the `R Internals' manual, -@end ifclear +@ref{R Internal Structures, , , R-ints, R Internals}, but for most purposes the programmer does not need to know them. Think rather of a model such as that used by Visual Basic, in which @R{} objects are @@ -12775,12 +12695,7 @@ Among the important internal @code{SEXPTYPE}s are @code{LANGSXP}, possible to return objects of internal types, it is unsafe to do so as assumptions are made about how they are handled which may be violated at user-level evaluation.) More details are given in -@ifset UseExternalXrefs -@ref{R Internal Structures, , R Internal Structures, R-ints, R Internals}. -@end ifset -@ifclear UseExternalXrefs -section `R Internal Structures' in the `R Internals' manual. -@end ifclear +@ref{R Internal Structures, , , R-ints, R Internals}. Unless you are very sure about the type of the arguments, the code should check the data types. Sometimes it may also be necessary to diff --git a/doc/manual/R-intro.texi b/doc/manual/R-intro.texi index 2e4f0a51300..4050ef2f0e9 100644 --- a/doc/manual/R-intro.texi +++ b/doc/manual/R-intro.texi @@ -212,13 +212,8 @@ There are now a number of books which describe how to use @R{} for data analysis and statistics, and documentation for @Sl{}/@SPLUS{} can typically be used with @R{}, keeping the differences between the @Sl{} implementations in mind. -@ifset UseExternalXrefs -@xref{What documentation exists for R?, , , R-FAQ, R FAQ}. -@end ifset -@ifclear UseExternalXrefs -See section `What documentation exists for R?' in the `R FAQ' manual for -more information. -@end ifclear +@xref{What documentation exists for R?, , , R-FAQ, R FAQ} +for more information. @node R and statistics, R and the window system, Related software and documentation, Introduction and preliminaries @@ -495,12 +490,7 @@ You can find out how to do this by reading the manual entry for the Alternatively, the Emacs text editor provides more general support mechanisms (via @acronym{ESS}, @emph{Emacs Speaks Statistics}) for working interactively with @R{}. -@ifset UseExternalXrefs -@xref{R and Emacs, , , R-FAQ, R FAQ}. -@end ifset -@ifclear UseExternalXrefs -See section `R and Emacs' in the `R FAQ' manual for more information. -@end ifclear +@xref{R and Emacs, , , R-FAQ, R FAQ} for more information. @node Executing commands from or diverting output to a file, Data permanency and removing objects, Recall and correction of previous commands, Introduction and preliminaries @@ -6405,12 +6395,7 @@ for efficiency (the full list would take more memory and would take longer to search than a subset), and to aid package developers, who are protected from name clashes with other code. The process of developing packages is described in -@ifset UseExternalXrefs -@ref{Creating R packages, , Creating R packages, R-exts, Writing R Extensions}. -@end ifset -@ifclear UseExternalXrefs -section `Creating R packages' in the `Writing R Extensions' manual. -@end ifclear +@ref{Creating R packages, , , R-exts, Writing R Extensions}. Here, we will describe them from a user's point of view. To see which packages are installed at your site, issue the command @@ -6476,12 +6461,7 @@ and the datasets and standard statistical and graphical functions that are described in this manual. They should be automatically available in any @R{} installation. For a complete list, see -@ifset UseExternalXrefs -@ref{Which add-on packages exist for R?, , R packages, R-FAQ, R FAQ}. -@end ifset -@ifclear UseExternalXrefs -section `Which add-on packages exist for R?' in the `R FAQ' manual. -@end ifclear +@ref{Which add-on packages exist for R?, , , R-FAQ, R FAQ}. @node Contributed packages and CRAN, Namespaces, Standard packages, Packages diff --git a/doc/manual/R-ints.texi b/doc/manual/R-ints.texi index cd012eaaa7e..518aefa7bdf 100644 --- a/doc/manual/R-ints.texi +++ b/doc/manual/R-ints.texi @@ -1609,12 +1609,7 @@ override for @code{c}. The rest of @R{} should where possible make use of the allocators made available by file @file{src/main/memory.c}, which are also the methods recommended in -@ifset UseExternalXrefs -@ref{Memory allocation, , Memory allocation, R-exts, Writing R Extensions} -@end ifset -@ifclear UseExternalXrefs -section `Memory allocation' in the `Writing R Extensions' manual -@end ifclear +@ref{Memory allocation, , , R-exts, Writing R Extensions} @findex R_alloc @findex R_Calloc @findex R_Realloc @@ -1840,12 +1835,7 @@ and @code{libtiff} libraries. @subsection Hiding C entry points We make use of the visibility mechanisms discussed in -@ifset UseExternalXrefs -@ref{Controlling visibility, , Controlling visibility, R-exts, Writing R Extensions}, -@end ifset -@ifclear UseExternalXrefs -section `Controlling Visibility' in the `Writing R Extensions' manual, -@end ifclear +@ref{Controlling visibility, , , R-exts, Writing R Extensions}. C entry points not needed outside the main @R{} executable/dynamic library (and in particular in no package nor module) should be prefixed by @code{attribute_hidden}. @@ -2379,12 +2369,7 @@ of these requirements. The process of marking messages (errors, warnings etc) for translation in an @R{} package is described in -@ifset UseExternalXrefs -@ref{Internationalization, , Internationalization, R-exts, Writing R Extensions}, -@end ifset -@ifclear UseExternalXrefs -section `Internationalization' in the `Writing R Extensions' manual, -@end ifclear +@ref{Internationalization, , , R-exts, Writing R Extensions}, and the standard packages included with @R{} have (with an exception in @pkg{grDevices} for the menus of the @code{windows()} device) been internationalized in the same way as other packages. @@ -2511,13 +2496,8 @@ See file @file{po/README} for how to update the message templates and catalogs. * Help:: @end menu -The structure of a @emph{source} packages is described in -@ifset UseExternalXrefs -@ref{Creating R packages, , Creating R packages, R-exts, Writing R Extensions}: -@end ifset -@ifclear UseExternalXrefs -section `Creating R packages' in the `Writing R Extensions' manual: -@end ifclear +The structure of @emph{source} packages is described in +@ref{Creating R packages, , , R-exts, Writing R Extensions}: this chapter is concerned with the structure of @emph{installed} packages. @@ -4312,13 +4292,7 @@ install log for non-portable flags (for example those added to are reported, except @option{-Wall}, @option{-Wextra} and @option{-Weverything}, and flags which appear to be attempts to suppress warnings are highlighted. -See -@ifset UseExternalXrefs -@ref{Writing portable packages, , Writing portable packages, R-exts, Writing R Extensions} -@end ifset -@ifclear UseExternalXrefs -section `Writing portable packages' in the `Writing R Extensions' manual -@end ifclear +@xref{Writing portable packages, , , R-exts, Writing R Extensions} for the rationale of this check (and why even @option{-Werror} is unsafe). From 6c8e146257cdfc8a1a25f27a370c9dfb335cb198 Mon Sep 17 00:00:00 2001 From: smeyer Date: Mon, 1 Jul 2024 11:45:06 +0000 Subject: [PATCH 331/546] update for new indices git-svn-id: https://svn.r-project.org/R/trunk@86856 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/Makefile.in | 3 ++- doc/manual/Makefile.win | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/manual/Makefile.in b/doc/manual/Makefile.in index dc06593a3bd..91969cc7d72 100644 --- a/doc/manual/Makefile.in +++ b/doc/manual/Makefile.in @@ -407,9 +407,10 @@ clean: @if test "$(BUILDDIR_IS_SRCDIR)" = no ; then \ rm -Rf $(INSTFILES) images; \ fi - -@rm -f *.aux *.cp *.cps *.dvi *.en *.ens *.fn *.fns *.html *.info* \ + -@rm -f *.aux *.cp *.cps *.dvi *.fn *.fns *.html *.info* \ *.ky *.kys *.log *.out *.pdf *.pg *.pgs *.ps *.ps-2 *.tmp \ *.toc *.tp *.vr *.vrs \ + R-admin.en* R-exts.ae* R-exts.ap* R-exts.em* \ *-pkg.tex refman.i?? refman.tex fullrefman.i?? fullrefman.tex \ version.tex version.texi htmlxref.cnf -@rm -f stamp-* diff --git a/doc/manual/Makefile.win b/doc/manual/Makefile.win index ba4ca6f2bf7..969dd9d3679 100644 --- a/doc/manual/Makefile.win +++ b/doc/manual/Makefile.win @@ -178,8 +178,9 @@ version.texi: Makefile.win $(top_srcdir)/VERSION $(SVN_REV) mostlyclean: clean clean: @-rm -f *.aux *.toc *refman.i?? *.out *.log - @-rm -f *.cp *.cps *.en *.ens *.fn *.fns *.ky *.kys \ + @-rm -f *.cp *.cps *.fn *.fns *.ky *.kys \ *.out *.pg *.pgs *.tmp *.tp *.vr *.vrs \ + R-admin.en* R-exts.ae* R-exts.ap* R-exts.em* \ version.tex version.texi refman.tex fullrefman.tex *-pkg.tex distclean: clean @-rm -f *.pdf *.info* *.html From 97efe56a8beeb071176c084898cbb5faf1984ea6 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 1 Jul 2024 18:31:36 +0000 Subject: [PATCH 332/546] Fix PR#18750. git-svn-id: https://svn.r-project.org/R/trunk@86857 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/duplicated.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/library/base/R/duplicated.R b/src/library/base/R/duplicated.R index 5921fefd929..70c7ece9e53 100644 --- a/src/library/base/R/duplicated.R +++ b/src/library/base/R/duplicated.R @@ -29,15 +29,19 @@ duplicated.data.frame <- function(x, incomparables = FALSE, fromLast = FALSE, ...) { if(!isFALSE(incomparables)) - .NotYetUsed("incomparables != FALSE") - if(length(x) != 1L) { + .NotYetUsed("incomparables != FALSE") + n <- length(x) + if(!n) + duplicated(logical(nrow(x))) + else if(n == 1L) + duplicated(x[[1L]], fromLast = fromLast, ...) + else { if(any(i <- vapply(x, is.factor, NA))) x[i] <- lapply(x[i], as.numeric) if(any(i <- (lengths(lapply(x, dim)) == 2L))) x[i] <- lapply(x[i], split.data.frame, seq_len(nrow(x))) duplicated(do.call(Map, `names<-`(c(list, x), NULL)), fromLast = fromLast) } - else duplicated(x[[1L]], fromLast = fromLast, ...) } duplicated.matrix <- duplicated.array <- From cffc5edd8d2af9c0ea1c6abfcde443067fef2852 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 2 Jul 2024 10:25:38 +0000 Subject: [PATCH 333/546] Fix PR#18751. git-svn-id: https://svn.r-project.org/R/trunk@86858 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/indices.R | 6 ++++++ tests/reg-tests-1e.R | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/library/utils/R/indices.R b/src/library/utils/R/indices.R index 470a1aaff43..74d407ea936 100644 --- a/src/library/utils/R/indices.R +++ b/src/library/utils/R/indices.R @@ -73,6 +73,12 @@ packageDescription <- } else file <- "" if(nzchar(file)) { + ## Could have found a pkgpath matching pkg ignoring case + ## (PR#18751): + if(is.null(pkgname <- desc[["Package"]]) || (pkgname != pkg)) { + warning(gettextf("no package '%s' was found", pkg), domain = NA) + return(NA) + } ## read the Encoding field if any enc <- desc[["Encoding"]] if(!is.null(enc) && !is.na(encoding)) { diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 5c7ce7c08c3..9c7790a829a 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -425,7 +425,8 @@ options(op) ## handling of invalid Encoding / unsupported conversion in packageDescription() dir.create(pkgpath <- tempfile()) -writeLines(c("Version: 1.0", "Encoding: FTU-8"), # (sic!) +writeLines(c(sprintf("Package: %s", basename(pkgpath)), + "Version: 1.0", "Encoding: FTU-8"), # (sic!) file.path(pkgpath, "DESCRIPTION")) stopifnot(suppressWarnings(packageVersion(basename(pkgpath), dirname(pkgpath))) == "1.0") From 9c40a39ee5525288f7a921f8a8e4a325fb24f739 Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 2 Jul 2024 12:00:47 +0000 Subject: [PATCH 334/546] drop redundant node pointers and menus (requires Texinfo >= 6.1) git-svn-id: https://svn.r-project.org/R/trunk@86859 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-FAQ.texi | 389 +++++++----------- doc/manual/R-admin.texi | 445 ++++++++------------- doc/manual/R-data.texi | 199 ++++------ doc/manual/R-exts.texi | 817 +++++++++++++++----------------------- doc/manual/R-intro.texi | 603 +++++++++++----------------- doc/manual/R-ints.texi | 327 ++++++--------- doc/manual/R-lang.texi | 1 - doc/manual/resources.texi | 31 +- doc/manual/rw-FAQ.texi | 382 ++++++++---------- 9 files changed, 1239 insertions(+), 1955 deletions(-) diff --git a/doc/manual/R-FAQ.texi b/doc/manual/R-FAQ.texi index 56dc2ceb54e..646f27d9bf9 100644 --- a/doc/manual/R-FAQ.texi +++ b/doc/manual/R-FAQ.texi @@ -1,11 +1,8 @@ \input texinfo - @c %**start of header @setfilename R-FAQ.info @settitle R FAQ -@setchapternewpage on -@documentlanguage en -@documentencoding UTF-8 +@paragraphindent 0 @c %**end of header @dircategory Programming @@ -70,7 +67,7 @@ Frequently Asked Questions on R @* @c @end ifnothtml @ifnottex -@node Top, Introduction, (dir), (dir) +@node Top @top R FAQ @c @ifhtml @c @html @@ -84,31 +81,13 @@ This document contains answers to some of the most frequently asked questions about R. @end ifnottex -@menu -* Introduction:: -* R Basics:: -* R and S:: -* R Web Interfaces:: -* R Add-On Packages:: -* R and Emacs:: -* R Miscellanea:: -* R Programming:: -* R Bugs:: -* Acknowledgments:: -@end menu - -@node Introduction, R Basics, Top, Top + + +@node Introduction @chapter Introduction -@menu -* Legalese:: -* Obtaining this document:: -* Citing this document:: -* Notation:: -* Feedback:: -@end menu -@node Legalese, Obtaining this document, Introduction, Introduction +@node Legalese @section Legalese Copyright @copyright{} 1998--2020 @I{Kurt Hornik} @* @@ -131,8 +110,7 @@ available at @url{https://www.R-project.org/Licenses/} @end display - -@node Obtaining this document, Citing this document, Legalese, Introduction +@node Obtaining this document @section Obtaining this document The latest version of this document is always available from @@ -145,7 +123,7 @@ From there, you can obtain versions converted to @url{https://CRAN.R-project.org/doc/manuals/R-FAQ.html,, @HTML{}} and @url{https://CRAN.R-project.org/doc/manuals/R-FAQ.pdf,, PDF}. -@node Citing this document, Notation, Obtaining this document, Introduction +@node Citing this document @section Citing this document In publications, please refer to this @acronym{FAQ} as @I{Hornik} and R Core Team @@ -163,14 +141,13 @@ In publications, please refer to this @acronym{FAQ} as @I{Hornik} and R Core Tea @end group @end example - -@node Notation, Feedback, Citing this document, Introduction +@node Notation @section Notation Everything should be pretty standard. @samp{R>} is used for the R prompt, and a @samp{$} for the shell prompt (where applicable). -@node Feedback, , Notation, Introduction +@node Feedback @section Feedback Feedback via email to @email{R-devel@@R-project.org} is most welcome. @@ -189,27 +166,13 @@ know. @c rw-FAQ versions? @c -@node R Basics, R and S, Introduction, Top + + +@node R Basics @chapter R Basics -@menu -* What is R?:: -* What machines does R run on?:: -* What is the current version of R?:: -* How can R be obtained?:: -* How can R be installed?:: -* Are there Unix-like binaries for R?:: -* What documentation exists for R?:: -* Citing R:: -* What mailing lists exist for R?:: -* What is CRAN?:: -* Can I use R for commercial purposes?:: -* Why is R named R?:: -* What is the R Foundation?:: -* What is R-Forge?:: -@end menu - -@node What is R?, What machines does R run on?, R Basics, R Basics + +@node What is R? @section What is R? R is a system for statistical computation and graphics. It consists of @@ -283,7 +246,7 @@ distributed under a @acronym{GNU}-style official part of the @url{https://www.gnu.org/, @acronym{GNU}} project (``@acronym{GNU} S''). -@node What machines does R run on?, What is the current version of R?, What is R?, R Basics +@node What machines does R run on? @section What machines does R run on? R is being developed for the Unix-like, Windows and Mac families of @@ -324,7 +287,7 @@ platforms including @var{cpu}-linux-gnu for the @I{i386}, If you know about other platforms, please drop us a note. -@node What is the current version of R?, How can R be obtained?, What machines does R run on?, R Basics +@node What is the current version of R? @section What is the current version of R? R uses a `major.minor.patchlevel' numbering scheme. Based on this, @@ -337,7 +300,7 @@ introduced in r-devel, while r-patched is for bug fixes mostly. See @url{https://CRAN.R-project.org/sources.html} for the current versions of r-release, r-patched and r-devel. -@node How can R be obtained?, How can R be installed?, What is the current version of R?, R Basics +@node How can R be obtained? @section How can R be obtained? Sources, binaries and documentation for R can be obtained via @CRAN{}, @@ -380,16 +343,10 @@ versions of R can be found at @c The sources of the development version are also available via anonymous @c CVS. See @url{http://anoncvs.R-project.org} for more information. -@node How can R be installed?, Are there Unix-like binaries for R?, How can R be obtained?, R Basics +@node How can R be installed? @section How can R be installed? -@menu -* How can R be installed (Unix-like):: -* How can R be installed (Windows):: -* How can R be installed (Mac):: -@end menu - -@node How can R be installed (Unix-like), How can R be installed (Windows), How can R be installed?, How can R be installed? +@node How can R be installed (Unix-like) @subsection How can R be installed (Unix-like) If R is already installed, it can be started by typing @kbd{R} at the @@ -466,7 +423,7 @@ To install info and PDF versions of the manuals, use @kbd{make install-info} and @kbd{make install-pdf}, respectively. -@node How can R be installed (Windows), How can R be installed (Mac), How can R be installed (Unix-like), How can R be installed? +@node How can R be installed (Windows) @subsection How can R be installed (Windows) The @file{bin/windows} directory of a @CRAN{} site contains binaries for @@ -483,7 +440,7 @@ versions of R. See the @url{https://CRAN.R-project.org/bin/windows/base/rw-FAQ.html, ``R for Windows @acronym{FAQ}''} for more details. -@node How can R be installed (Mac), , How can R be installed (Windows), How can R be installed? +@node How can R be installed (Mac) @subsection How can R be installed (Mac) The @file{bin/macosx} directory of a @CRAN{} site contains a standard @@ -500,7 +457,8 @@ macOS @acronym{FAQ}''} has more details. Snapshots of the r-patched and r-devel versions of R are available as Apple installer packages at @uref{https://mac.R-project.org}. -@node Are there Unix-like binaries for R?, What documentation exists for R?, How can R be installed?, R Basics + +@node Are there Unix-like binaries for R? @section Are there Unix-like binaries for R? Binary distributions of R are available on many Unix-like OSes: only @@ -552,7 +510,7 @@ information about @abbr{RPM}s for openSUSE. No other binary distributions are currently publicly available via @CRAN{}. -@node What documentation exists for R?, Citing R, Are there Unix-like binaries for R?, R Basics +@node What documentation exists for R? @section What documentation exists for R? Online documentation for most of the functions and variables in R @@ -657,7 +615,7 @@ implementing R is described in @I{Ihaka} & @I{Gentleman} (1996), @emph{Journal of Computational and Graphical Statistics}, @strong{5}, 299--314 (@doi{10.1080/10618600.1996.10474713}). -@node Citing R, What mailing lists exist for R?, What documentation exists for R?, R Basics +@node Citing R @section Citing R To cite R in publications, use @@ -682,7 +640,7 @@ determined as @code{R.version$year}. Citation strings (or Bib@TeX{} entries) for R and R packages can also be obtained by @code{citation()}. -@node What mailing lists exist for R?, What is CRAN?, Citing R, R Basics +@node What mailing lists exist for R? @section What mailing lists exist for R? Thanks to @email{Martin.Maechler@@R-project.org, Martin Maechler}, there @@ -768,7 +726,7 @@ the R mailing lists. @c details on RSS feeds. @c -@node What is CRAN?, Can I use R for commercial purposes?, What mailing lists exist for R?, R Basics +@node What is CRAN? @section What is @acronym{CRAN}? The ``Comprehensive R Archive Network'' (@CRAN{}) is a collection of @@ -807,7 +765,7 @@ Since March 2016, ``old'' material is made available from a central Please always use the @acronym{URL} of the master site when referring to @CRAN{}. -@node Can I use R for commercial purposes?, Why is R named R?, What is CRAN?, R Basics +@node Can I use R for commercial purposes? @section Can I use R for commercial purposes? R is released under the @@ -850,7 +808,7 @@ these may be used or seek the advice of your legal counsel. None of the discussion in this section constitutes legal advice. The R Core Team does not provide legal advice under any circumstances. -@node Why is R named R?, What is the R Foundation?, Can I use R for commercial purposes?, R Basics +@node Why is R named R? @section Why is R named R? The name is partly based on the (first) names of the first two R authors @@ -860,7 +818,7 @@ Bell Labs language `S' (@pxref{What is S?}). @c At the time the name was coined no one expected that the software would @c get used outside of Auckland, so it seemed ok to make a joke of it. -@node What is the R Foundation?, What is R-Forge?, Why is R named R?, R Basics +@node What is the R Foundation? @section What is the R Foundation? The R Foundation is a not for profit organization working in the public @@ -872,7 +830,7 @@ development community, and to hold and administer the copyright of R software and documentation. See @url{https://www.R-project.org/foundation/} for more information. -@node What is R-Forge?, , What is the R Foundation?, R Basics +@node What is R-Forge? @section What is R-Forge? R-Forge (@url{https://R-Forge.R-project.org/}) offers a central platform @@ -887,18 +845,12 @@ development using R-Forge'', @url{https://journal.R-project.org/, , @emph{The R Journal}}, @strong{1}(1):9--14. -@node R and S, R Web Interfaces, R Basics, Top + +@node R and S @chapter R and S -@menu -* What is S?:: -* What is S-PLUS?:: -* What are the differences between R and S?:: -* Is there anything R can do that S-PLUS cannot?:: -* What is R-plus?:: -@end menu -@node What is S?, What is S-PLUS?, R and S, R and S +@node What is S? @section What is S? S is a very high level language and an environment for data analysis and @@ -965,14 +917,14 @@ for further information on the ``Evolution of the S Language''. @c about S''} contains further information about S, but is not @c up-to-date. -@node What is S-PLUS?, What are the differences between R and S?, What is S?, R and S +@node What is S-PLUS? @section What is @sc{S-Plus}? @SPLUS{} is a value-added version of S sold by @url{https://www.tibco.com/, TIBCO Software Inc} as `@I{TIBCO Spotfire S+}'. See @url{https://en.wikipedia.org/wiki/S-PLUS} for more information. -@node What are the differences between R and S?, Is there anything R can do that S-PLUS cannot?, What is S-PLUS?, R and S +@node What are the differences between R and S? @section What are the differences between R and S? We can regard S as a language with three current implementations or @@ -985,13 +937,8 @@ the S language, i.e., the difference between the R and S @emph{engines}. For the remainder of this section, ``S'' refers to the S engines and not the S language. -@menu -* Lexical scoping:: -* Models:: -* Others:: -@end menu -@node Lexical scoping, Models, What are the differences between R and S?, What are the differences between R and S? +@node Lexical scoping @subsection Lexical scoping Contrary to other implementations of the S language, R has adopted an @@ -1248,7 +1195,7 @@ it using @code{ess-transcript-mode}, as well as save source copies of all functions and data used. @end quotation -@node Models, Others, Lexical scoping, What are the differences between R and S? +@node Models @subsection Models There are some differences in the modeling code, such as @@ -1274,7 +1221,7 @@ specifying a model with no intercept. Models with no parameters at all can be specified by @code{y ~ 0}. @end itemize -@node Others, , Models, What are the differences between R and S? +@node Others @subsection Others Apart from lexical scoping and its implications, R follows the S @@ -1483,7 +1430,7 @@ documenting the difference as you see it). Of course, it would be useful if you were to implement the change yourself and make sure it works. -@node Is there anything R can do that S-PLUS cannot?, What is R-plus?, What are the differences between R and S?, R and S +@node Is there anything R can do that S-PLUS cannot? @section Is there anything R can do that @sc{S-Plus} cannot? Since almost anything you can do in R has source code that you could @@ -1502,7 +1449,7 @@ impressive on-line example. More details can be found in @emph{Journal of Computational and Graphical Statistics}, @strong{9}, 582--599 (@doi{10.1080/10618600.2000.10474900}). -@node What is R-plus?, , Is there anything R can do that S-PLUS cannot?, R and S +@node What is R-plus? @section What is R-plus? For a very long time, there was no such thing. @@ -1528,7 +1475,9 @@ See also @url{https://en.wikipedia.org/wiki/R_programming_language#Commercialized_versions_of_R} for pointers to commercialized versions of R. -@node R Web Interfaces, R Add-On Packages, R and S, Top + + +@node R Web Interfaces @chapter R Web Interfaces Please refer to the @CRAN{} task view on ``Web Technologies and @@ -1548,29 +1497,17 @@ and ``Using R via PHP for Teaching Purposes: @I{R-php}'' (@doi{10.18637/jss.v017.i04}). -@node R Add-On Packages, R and Emacs, R Web Interfaces, Top + + +@node R Add-On Packages @chapter R Add-On Packages -@menu -* Which add-on packages exist for R?:: -* How can add-on packages be installed?:: -* How can add-on packages be used?:: -* How can add-on packages be removed?:: -* How can I create an R package?:: -* How can I contribute to R?:: -@end menu -@node Which add-on packages exist for R?, How can add-on packages be installed?, R Add-On Packages, R Add-On Packages +@node Which add-on packages exist for R? @section Which add-on packages exist for R? -@menu -* Add-on packages in R:: -* Add-on packages from CRAN:: -* Add-on packages from Bioconductor:: -* Other add-on packages:: -@end menu -@node Add-on packages in R, Add-on packages from CRAN, Which add-on packages exist for R?, Which add-on packages exist for R? +@node Add-on packages in R @subsection Add-on packages in R The R distribution comes with the following packages: @@ -1619,7 +1556,7 @@ R utility functions. @c recommended package @CRANpkg{MASS}, and package @pkg{mle} moved to @c @pkg{stats4}. -@node Add-on packages from CRAN, Add-on packages from Bioconductor, Add-on packages in R, Which add-on packages exist for R? +@node Add-on packages from CRAN @subsection Add-on packages from @acronym{CRAN} The @CRAN{} @file{src/contrib} area contains a wealth of add-on @@ -1692,7 +1629,7 @@ all packages for special areas of interest. @c D. Ripley. Note that this repository is a default repository for recent @c versions of R for Windows. -@c @node Add-on packages from Omegahat, Add-on packages from Bioconductor, Add-on packages from CRAN, Which add-on packages exist for R? +@c @node Add-on packages from Omegahat @c @subsection Add-on packages from Omegahat @c The @url{http://www.omegahat.net/, Omega Project for Statistical @@ -1703,7 +1640,7 @@ all packages for special areas of interest. @c See @url{http://www.omegahat.net/} for information on most R packages @c available from the Omega project. -@node Add-on packages from Bioconductor, Other add-on packages, Add-on packages from CRAN, Which add-on packages exist for R? +@node Add-on packages from Bioconductor @subsection Add-on packages from Bioconductor @url{https://www.bioconductor.org/, Bioconductor} is an open source and @@ -1720,7 +1657,7 @@ SAGE, sequence, or SNP data. In addition, there are metadata @url{https://bioconductor.org/install/} for available packages and a complete taxonomy via @I{BioC Views}. -@node Other add-on packages, , Add-on packages from Bioconductor, Which add-on packages exist for R? +@node Other add-on packages @subsection Other add-on packages Many more packages are available from places other than the default @@ -1731,7 +1668,7 @@ R-Forge provides a @CRAN{} style repository at More code has been posted to the R-help mailing list, and can be obtained from the mailing list archive. -@node How can add-on packages be installed?, How can add-on packages be used?, Which add-on packages exist for R?, R Add-On Packages +@node How can add-on packages be installed? @section How can add-on packages be installed? (Unix-like only.) The add-on packages on @CRAN{} come as gzipped tar @@ -1788,7 +1725,7 @@ information. @c @code{export} statement is needed or allowed in this file; see the @c on-line help for @code{Startup} for more information.) -@node How can add-on packages be used?, How can add-on packages be removed?, How can add-on packages be installed?, R Add-On Packages +@node How can add-on packages be used? @section How can add-on packages be used? To find out which additional packages are available on your system, type @@ -1870,7 +1807,7 @@ detach("package:@var{pkg}") @noindent (which does not by default unload the namespace, see @code{?detach}). -@node How can add-on packages be removed?, How can I create an R package?, How can add-on packages be used?, R Add-On Packages +@node How can add-on packages be removed? @section How can add-on packages be removed? Use @@ -1892,7 +1829,7 @@ To remove from library @var{lib}, do $ R CMD REMOVE -l @var{lib} @var{pkg_1} @dots{} @var{pkg_n} @end example -@node How can I create an R package?, How can I contribute to R?, How can add-on packages be removed?, R Add-On Packages +@node How can I create an R package? @section How can I create an R package? A package consists of a subdirectory containing a file @@ -1915,7 +1852,7 @@ files for a set of R functions and datasets. @xref{What is CRAN?}, for information on uploading a package to @CRAN{}. -@node How can I contribute to R?, , How can I create an R package?, R Add-On Packages +@node How can I contribute to R? @section How can I contribute to R? R is in active development and there is always a risk of bugs creeping @@ -1928,16 +1865,13 @@ intermediate repository for more or less finalized ideas and plans for the R statistical system. It contains (pointers to) TODO lists, RFCs, various other writeups, ideas lists, and SVN miscellanea. -@node R and Emacs, R Miscellanea, R Add-On Packages, Top + + +@node R and Emacs @chapter R and Emacs -@menu -* Is there Emacs support for R?:: -* Should I run R from within Emacs?:: -* Debugging R from within Emacs:: -@end menu -@node Is there Emacs support for R?, Should I run R from within Emacs?, R and Emacs, R and Emacs +@node Is there Emacs support for R? @section Is there Emacs support for R? There is an Emacs package called @acronym{ESS} (``Emacs Speaks @@ -1984,7 +1918,7 @@ Please send bug reports and suggestions on @acronym{ESS} to within Emacs by typing @kbd{M-x ess-submit-bug-report} or using the @I{[ESS]} or @I{[iESS]} pulldown menus. -@node Should I run R from within Emacs?, Debugging R from within Emacs, Is there Emacs support for R?, R and Emacs +@node Should I run R from within Emacs? @section Should I run R from within Emacs? Yes, instead of just running it in a console, @emph{definitely}. As an @@ -2014,7 +1948,7 @@ To specify command line arguments for the inferior R process, use @c This prompts you for the arguments; in particular, you can increase @c the memory size this way (@pxref{Why does R run out of memory?}). -@node Debugging R from within Emacs, , Should I run R from within Emacs?, R and Emacs +@node Debugging R from within Emacs @section Debugging R from within Emacs To debug R ``from within Emacs'', there are several possibilities. To @@ -2056,57 +1990,13 @@ dir /opt/R/src/nmath dir /opt/R/src/unix @end example -@node R Miscellanea, R Programming, R and Emacs, Top + + +@node R Miscellanea @chapter R Miscellanea -@menu -* How can I set components of a list to NULL?:: -* How can I save my workspace?:: -* How can I clean up my workspace?:: -* How can I get eval() and D() to work?:: -* Why do my matrices lose dimensions?:: -* How does autoloading work?:: -* How should I set options?:: -* How do file names work in Windows?:: -* Why does plotting give a color allocation error?:: -* How do I convert factors to numeric?:: -* Are Trellis displays implemented in R?:: -* What are the enclosing and parent environments?:: -* How can I substitute into a plot label?:: -* What are valid names?:: -* Are GAMs implemented in R?:: -* Why is the output not printed when I source() a file?:: -* Why does outer() behave strangely with my function?:: -* Why does the output from anova() depend on the order of factors in the model?:: -* How do I produce PNG graphics in batch mode?:: -* How can I get command line editing to work?:: -* How can I turn a string into a variable?:: -* Why do lattice/trellis graphics not work?:: -* How can I sort the rows of a data frame?:: -* Why does the help.start() search engine not work?:: -* Why did my .Rprofile stop working when I updated R?:: -* Where have all the methods gone?:: -* How can I create rotated axis labels?:: -* Why is read.table() so inefficient?:: -* What is the difference between package and library?:: -* I installed a package but the functions are not there:: -* Why doesn't R think these numbers are equal?:: -* How can I capture or ignore errors in a long simulation?:: -* Why are powers of negative numbers wrong?:: -* How can I save the result of each iteration in a loop into a separate file?:: -* Why are p-values not displayed when using lmer()?:: -* Why are there unwanted borders:: -* Why does backslash behave strangely inside strings?:: -* How can I put error bars or confidence bands on my plot?:: -* How do I create a plot with two y-axes?:: -* How do I access the source code for a function?:: -* Why does summary() report strange results for the R^2 estimate when I fit a linear model with no intercept?:: -* Why is R apparently not releasing memory?:: -* How can I enable secure https downloads in R?:: -* How can I get CRAN package binaries for outdated versions of R?:: -@end menu - -@c @node Why does R run out of memory?, Why does sourcing a correct file fail?, R Miscellanea, R Miscellanea + +@c @node Why does R run out of memory? @c @section Why does R run out of memory? @c Versions of R prior to 1.2.0 used a @emph{static} memory model. At @@ -2128,14 +2018,14 @@ dir /opt/R/src/unix @c objects cannot be allocated even when there is apparently enough memory @c for them. -@c @node Why does sourcing a correct file fail?, How can I set components of a list to NULL?, Why does R run out of memory?, R Miscellanea +@c @node Why does sourcing a correct file fail? @c @section Why does sourcing a correct file fail? @c Versions of R prior to 1.2.1 may have had problems parsing files not @c ending in a newline. Earlier R versions had a similar problem when @c reading in data files. This should no longer happen. -@node How can I set components of a list to NULL?, How can I save my workspace?, R Miscellanea, R Miscellanea +@node How can I set components of a list to NULL? @section How can I set components of a list to NULL? You can use @@ -2153,7 +2043,7 @@ the list. For dropping the row names of a matrix @code{x}, it may be easier to use @code{rownames(x) <- NULL}, similarly for column names. -@node How can I save my workspace?, How can I clean up my workspace?, How can I set components of a list to NULL?, R Miscellanea +@node How can I save my workspace? @section How can I save my workspace? @code{save.image()} saves the objects in the user's @code{.GlobalEnv} to @@ -2161,7 +2051,7 @@ the file @file{.RData} in the R startup directory. (This is also what happens after @kbd{q("yes")}.) Using @code{save.image(@var{file})} one can save the image under a different name. -@node How can I clean up my workspace?, How can I get eval() and D() to work?, How can I save my workspace?, R Miscellanea +@node How can I clean up my workspace? @section How can I clean up my workspace? To remove all objects in the currently active environment (typically @@ -2175,7 +2065,7 @@ rm(list = ls(all.names = TRUE)) (Without @option{all = TRUE}, only the objects with names not starting with a @samp{.} are removed.) -@node How can I get eval() and D() to work?, Why do my matrices lose dimensions?, How can I clean up my workspace?, R Miscellanea +@node How can I get eval() and D() to work? @section How can I get @code{eval()} and @code{D()} to work? Strange things will happen if you use @code{eval(print(x), envir = e)} @@ -2216,7 +2106,7 @@ g(a * b) See the help page for @code{deriv()} for more examples. -@node Why do my matrices lose dimensions?, How does autoloading work?, How can I get eval() and D() to work?, R Miscellanea +@node Why do my matrices lose dimensions? @section Why do my matrices lose dimensions? When a matrix with a single row or column is created by a subscripting @@ -2251,7 +2141,7 @@ rewritten as somerows <- mat[index, , drop = FALSE] @end example -@node How does autoloading work?, How should I set options?, Why do my matrices lose dimensions?, R Miscellanea +@node How does autoloading work? @section How does autoloading work? Autoloading is rarely used since packages became lazy-loaded. @@ -2269,7 +2159,7 @@ does not occupy memory (yet). See the help page for @code{autoload()} for a very nice example. -@node How should I set options?, How do file names work in Windows?, How does autoloading work?, R Miscellanea +@node How should I set options? @section How should I set options? The function @code{options()} allows setting and examining a variety of @@ -2307,7 +2197,7 @@ using @kbd{options(OPT = VAL)} correctly updates it. Local copies of @code{.Options}, either in @code{.GlobalEnv} or in a function environment (frame), are just silently disregarded. -@node How do file names work in Windows?, Why does plotting give a color allocation error?, How should I set options?, R Miscellanea +@node How do file names work in Windows? @section How do file names work in Windows? As R uses C-style string handling, @samp{\} is treated as an escape @@ -2318,7 +2208,7 @@ When you really need a @samp{\}, you have to escape it with another Thus, in filenames use something like @code{"c:\\data\\money.dat"}. You can also replace @samp{\} by @samp{/} (@code{"c:/data/money.dat"}). -@node Why does plotting give a color allocation error?, How do I convert factors to numeric?, How do file names work in Windows?, R Miscellanea +@node Why does plotting give a color allocation error? @section Why does plotting give a color allocation error? This is about a problem rarely seen with modern X11 installations. @@ -2339,7 +2229,7 @@ You could also set the @code{colortype} of @code{X11()} to @code{"pseudo.cube"} rather than the default @code{"pseudo"}. See the help page for @code{X11()} for more information. -@c @node Is R Y2K-compliant?, How do I convert factors to numeric?, Why does plotting give a color allocation error?, R Miscellanea +@c @node Is R Y2K-compliant? @c @section Is R Y2K-compliant? @c We expect R to be Y2K compliant when compiled and run on a Y2K compliant @@ -2351,7 +2241,7 @@ help page for @code{X11()} for more information. @c R, like any other programming language, can be used to write programs @c and manipulate data in ways that are not Y2K compliant. -@node How do I convert factors to numeric?, Are Trellis displays implemented in R?, Why does plotting give a color allocation error?, R Miscellanea +@node How do I convert factors to numeric? @section How do I convert factors to numeric? It may happen that when reading numeric data into R (usually, when @@ -2373,7 +2263,7 @@ In any case, do not call @code{as.numeric()} or their likes directly for the task at hand (as @code{as.numeric()} or @code{unclass()} give the internal codes). -@node Are Trellis displays implemented in R?, What are the enclosing and parent environments?, How do I convert factors to numeric?, R Miscellanea +@node Are Trellis displays implemented in R? @section Are Trellis displays implemented in R? The recommended package @CRANpkg{lattice} (which is based on base @@ -2391,7 +2281,7 @@ aspect ratio of the plot. use it in R. The name ``lattice'' has been chosen for the R equivalent.) -@node What are the enclosing and parent environments?, How can I substitute into a plot label?, Are Trellis displays implemented in R?, R Miscellanea +@node What are the enclosing and parent environments? @section What are the enclosing and parent environments? Inside a function you may want to access variables in two additional @@ -2440,7 +2330,7 @@ between R and S is to say that in S the enclosing environment is @emph{always} the global workspace, but in R the enclosing environment is wherever the function was created. -@node How can I substitute into a plot label?, What are valid names?, What are the enclosing and parent environments?, R Miscellanea +@node How can I substitute into a plot label? @section How can I substitute into a plot label? Often, it is desired to use the value of an R object in a plot label, @@ -2469,7 +2359,7 @@ values. There are more examples in the mailing list archives. -@node What are valid names?, Are GAMs implemented in R?, How can I substitute into a plot label?, R Miscellanea +@node What are valid names? @section What are valid names? When creating data frames using @code{data.frame()} or @@ -2517,7 +2407,7 @@ to do with names in the language, but it is traditional to call these strings file ``names''. @end enumerate -@node Are GAMs implemented in R?, Why is the output not printed when I source() a file?, What are valid names?, R Miscellanea +@node Are GAMs implemented in R? @section Are GAM@w{s} implemented in R? Package @CRANpkg{gam} from @CRAN{} implements all the Generalized @@ -2530,7 +2420,7 @@ for example). Package @CRANpkg{gss} can fit spline-based GAM@w{s} too. And if you can accept regression splines you can use @code{glm()}. For Gaussian GAM@w{s} you can use @code{bruto()} from package @CRANpkg{mda}. -@node Why is the output not printed when I source() a file?, Why does outer() behave strangely with my function?, Are GAMs implemented in R?, R Miscellanea +@node Why is the output not printed when I source() a file? @section Why is the output not printed when I source() a file? Most R commands do not generate any output. The command @@ -2573,7 +2463,7 @@ print(summary(glm(y~x+z, family=binomial))) @noindent instead, or use @code{source(@var{file}, echo=TRUE)}. -@node Why does outer() behave strangely with my function?, Why does the output from anova() depend on the order of factors in the model?, Why is the output not printed when I source() a file?, R Miscellanea +@node Why does outer() behave strangely with my function? @section Why does outer() behave strangely with my function? As the help for @code{outer()} indicates, it does not work on arbitrary @@ -2614,7 +2504,7 @@ outer(1:4, 1:2, FUN = wrapper, my.fun = foo, happy = 10) Scalar functions can also be vectorized using @code{Vectorize()}. -@node Why does the output from anova() depend on the order of factors in the model?, How do I produce PNG graphics in batch mode?, Why does outer() behave strangely with my function?, R Miscellanea +@node Why does the output from anova() depend on the order of factors in the model? @section Why does the output from @code{anova()} depend on the order of factors in the model? In a model such as @code{~A+B+A:B}, R will report the difference in sums @@ -2640,7 +2530,7 @@ easily. Any two models can be compared with @code{anova(@var{model1}, @var{model2})}, and @code{drop1(@var{model1})} will show the sums of squares resulting from dropping single terms. -@node How do I produce PNG graphics in batch mode?, How can I get command line editing to work?, Why does the output from anova() depend on the order of factors in the model?, R Miscellanea +@node How do I produce PNG graphics in batch mode? @section How do I produce PNG graphics in batch mode? Under a Unix-like, if your installation supports the @@ -2662,7 +2552,7 @@ install), which is an X11 server that does not require a screen. @c ; and there is the @CRANpkg{GDD} package from @CRAN{}, which produces @c PNG, JPEG and GIF bitmaps without X11. -@node How can I get command line editing to work?, How can I turn a string into a variable?, How do I produce PNG graphics in batch mode?, R Miscellanea +@node How can I get command line editing to work? @section How can I get command line editing to work? The Unix-like command-line interface to R can only provide the inbuilt @@ -2674,7 +2564,7 @@ needed: users of Linux binary distributions will need to install packages such as @code{libreadline-dev} (Debian) or @code{readline-devel} (Red Hat). -@node How can I turn a string into a variable?, Why do lattice/trellis graphics not work?, How can I get command line editing to work?, R Miscellanea +@node How can I turn a string into a variable? @section How can I turn a string into a variable? If you have @@ -2737,7 +2627,7 @@ vars[["a"]] @noindent without any of this messing about. -@node Why do lattice/trellis graphics not work?, How can I sort the rows of a data frame?, How can I turn a string into a variable?, R Miscellanea +@node Why do lattice/trellis graphics not work? @section Why do lattice/trellis graphics not work? The most likely reason is that you forgot to tell R to display the @@ -2749,7 +2639,7 @@ interactively at the command line, the result is automatically printed, but in @code{source()} or inside your own functions you will need an explicit @code{print()} statement. -@node How can I sort the rows of a data frame?, Why does the help.start() search engine not work?, Why do lattice/trellis graphics not work?, R Miscellanea +@node How can I sort the rows of a data frame? @section How can I sort the rows of a data frame? To sort the rows within a data frame, with respect to the values in one @@ -2760,7 +2650,7 @@ columns named @code{a} and @code{b}). From R 4.4.0, @code{sort_by()} provides a less verbose alternative with a formula interface (e.g., @code{sort_by(DF, ~a + b)}). -@node Why does the help.start() search engine not work?, Why did my .Rprofile stop working when I updated R?, How can I sort the rows of a data frame?, R Miscellanea +@node Why does the help.start() search engine not work? @section Why does the help.start() search engine not work? Since R 2.10.0, the browser-based search engine in @code{help.start()} @@ -2770,7 +2660,7 @@ function properly, one needed a compatible version of Java installed on the system and linked to the browser, and both Java @emph{and} JavaScript enabled in the browser. -@node Why did my .Rprofile stop working when I updated R?, Where have all the methods gone?, Why does the help.start() search engine not work?, R Miscellanea +@node Why did my .Rprofile stop working when I updated R? @section Why did my @I{.Rprofile} stop working when I updated R? Did you read the @file{NEWS} file? For functions that are not in the @@ -2790,13 +2680,7 @@ grDevices::ps.options(horizontal = FALSE) utils::help.start() @end example -@c -@c 3.0.0 -@noindent -(@code{graphics::ps.options(horizontal = FALSE)} in R 1.9.x). -@c - -@node Where have all the methods gone?, How can I create rotated axis labels?, Why did my .Rprofile stop working when I updated R?, R Miscellanea +@node Where have all the methods gone? @section Where have all the methods gone? Many functions, particularly S3 methods, are now hidden in namespaces. @@ -2815,7 +2699,7 @@ of package @code{"bar"} use @code{bar:::foo}. Don't use these constructions to call unexported functions in your own code---they are probably unexported for a reason and may change without warning. -@node How can I create rotated axis labels?, Why is read.table() so inefficient?, Where have all the methods gone?, R Miscellanea +@node How can I create rotated axis labels? @section How can I create rotated axis labels? To rotate axis labels (using base graphics), you need to use @@ -2851,7 +2735,7 @@ Also see Figure 1 and associated code in ``Integrating grid Graphics Output with Base Graphics Output'', @emph{R News}, @strong{3/2}, 7--12. -@node Why is read.table() so inefficient?, What is the difference between package and library?, How can I create rotated axis labels?, R Miscellanea +@node Why is read.table() so inefficient? @section Why is read.table() so inefficient? By default, @code{read.table()} needs to read in everything as character @@ -2861,7 +2745,7 @@ time and memory. Performance can substantially be improved by using the @code{colClasses} argument to specify the classes to be assumed for the columns of the table. -@node What is the difference between package and library?, I installed a package but the functions are not there, Why is read.table() so inefficient?, R Miscellanea +@node What is the difference between package and library? @section What is the difference between package and library? A @dfn{package} is a standardized collection of material extending R, @@ -2876,7 +2760,7 @@ containing packages. ``R Help Desk: Package Management'', @emph{R News}, @strong{3/3}, 37--39. -@node I installed a package but the functions are not there, Why doesn't R think these numbers are equal?, What is the difference between package and library?, R Miscellanea +@node I installed a package but the functions are not there @section I installed a package but the functions are not there To actually @emph{use} the package, it needs to be @emph{loaded} using @@ -2885,7 +2769,7 @@ To actually @emph{use} the package, it needs to be @emph{loaded} using See @ref{R Add-On Packages} and @ref{What is the difference between package and library?} for more information. -@node Why doesn't R think these numbers are equal?, How can I capture or ignore errors in a long simulation?, I installed a package but the functions are not there, R Miscellanea +@node Why doesn't R think these numbers are equal? @section Why doesn't R think these numbers are equal? The only numbers that can be represented exactly in R's numeric type are @@ -2944,7 +2828,7 @@ R> print(matrix(c(.3, .6, .9, .3 + .6)), digits = 18) @end example -@node How can I capture or ignore errors in a long simulation?, Why are powers of negative numbers wrong?, Why doesn't R think these numbers are equal?, R Miscellanea +@node How can I capture or ignore errors in a long simulation? @section How can I capture or ignore errors in a long simulation? Use @code{try()}, which returns an object of class @code{"try-error"} @@ -2961,7 +2845,7 @@ would return the coefficients if the @code{lm()} call succeeded and would return @code{c(NaN, NaN, NaN, NaN)} if it failed (presumably there are supposed to be 4 coefficients in this example). -@node Why are powers of negative numbers wrong?, How can I save the result of each iteration in a loop into a separate file?, How can I capture or ignore errors in a long simulation?, R Miscellanea +@node Why are powers of negative numbers wrong? @section Why are powers of negative numbers wrong? You are probably seeing something like @@ -2995,7 +2879,7 @@ R> as.list(quote(-2^2)) 2^2 @end example -@node How can I save the result of each iteration in a loop into a separate file?, Why are p-values not displayed when using lmer()?, Why are powers of negative numbers wrong?, R Miscellanea +@node How can I save the result of each iteration in a loop into a separate file? @section How can I save the result of each iteration in a loop into a separate file? One way is to use @code{paste()} (or @code{sprintf()}) to concatenate a @@ -3012,14 +2896,14 @@ for(i in 1:100) @{ @} @end example -@node Why are p-values not displayed when using lmer()?, Why are there unwanted borders, How can I save the result of each iteration in a loop into a separate file?, R Miscellanea +@node Why are p-values not displayed when using lmer()? @section Why are @math{p}-values not displayed when using @code{lmer()}? Doug Bates has kindly provided an extensive response in a post to the r-help list, which can be reviewed at @uref{https://stat.ethz.ch/pipermail/r-help/2006-May/094765.html}. -@node Why are there unwanted borders, Why does backslash behave strangely inside strings?, Why are p-values not displayed when using lmer()?, R Miscellanea +@node Why are there unwanted borders @section Why are there unwanted borders, lines or grid-like artifacts when viewing a plot saved to a PS or PDF file? This can occur when using functions such as @code{polygon()}, @@ -3062,7 +2946,7 @@ Then restart @I{Okular}. Change the final word to @samp{Enabled} to restore the original setting. @end ftable -@node Why does backslash behave strangely inside strings?, How can I put error bars or confidence bands on my plot?, Why are there unwanted borders, R Miscellanea +@node Why does backslash behave strangely inside strings? @section Why does backslash behave strangely inside strings? This question most often comes up in relation to file names (see @@ -3119,7 +3003,7 @@ In versions of R up to 2.4.1 an unknown escape sequence like @samp{\p} was quietly interpreted as just @samp{p}. Current versions of R emit a warning. -@node How can I put error bars or confidence bands on my plot?, How do I create a plot with two y-axes?, Why does backslash behave strangely inside strings?, R Miscellanea +@node How can I put error bars or confidence bands on my plot? @section How can I put error bars or confidence bands on my plot? Some functions will display a particular kind of plot with error bars, @@ -3148,7 +3032,7 @@ displayed with @code{Dotplot()} or @code{xYplot()} in the @CRANpkg{Hmisc} package and @code{segplot()} in the @CRANpkg{latticeExtra} package. -@node How do I create a plot with two y-axes?, How do I access the source code for a function?, How can I put error bars or confidence bands on my plot?, R Miscellanea +@node How do I create a plot with two y-axes? @section How do I create a plot with two y-axes? Creating a graph with two y-axes, i.e., with two sorts of data that are @@ -3164,7 +3048,7 @@ package) automate the process somewhat. @c for more information, including strong arguments against this sort of @c graph. -@node How do I access the source code for a function?, Why does summary() report strange results for the R^2 estimate when I fit a linear model with no intercept?, How do I create a plot with two y-axes?, R Miscellanea +@node How do I access the source code for a function? @section How do I access the source code for a function? In most cases, typing the name of the function will print its source @@ -3173,7 +3057,7 @@ a complete overview on how to access source code, see @I{Uwe Ligges} (2006), ``Help Desk: Accessing the sources'', @emph{R News}, @strong{6/4}, 43--45 (@url{https://CRAN.R-project.org/doc/Rnews/Rnews_2006-4.pdf}). -@node Why does summary() report strange results for the R^2 estimate when I fit a linear model with no intercept?, Why is R apparently not releasing memory?, How do I access the source code for a function?, R Miscellanea +@node Why does summary() report strange results for the R^2 estimate when I fit a linear model with no intercept? @section Why does summary() report strange results for the R^2 estimate when I fit a linear model with no intercept? As described in @code{?summary.lm}, when the intercept is zero (e.g., @@ -3205,7 +3089,7 @@ of the variance, is the model where @math{E[Y]=0} everywhere. (If you don't know @I{a priori} that @math{E[Y]=0} when @math{x=0}, then you probably shouldn't be fitting a line through the origin.) -@node Why is R apparently not releasing memory?, How can I enable secure https downloads in R?, Why does summary() report strange results for the R^2 estimate when I fit a linear model with no intercept?, R Miscellanea +@node Why is R apparently not releasing memory? @section Why is R apparently not releasing memory? This question is often asked in different flavors along the lines of @@ -3260,7 +3144,7 @@ Unix-like systems) it is possible to use the @code{mallinfo} system call query the allocator about the layout of the allocations, including the actually used memory as well as unused memory that cannot be released. -@node How can I enable secure https downloads in R?, How can I get CRAN package binaries for outdated versions of R?, Why is R apparently not releasing memory?, R Miscellanea +@node How can I enable secure https downloads in R? @section How can I enable secure @I{https} downloads in R? From R 4.2.0, @code{"libcurl"} download method is always available and @@ -3271,7 +3155,7 @@ since R 3.3.0 everywhere but Windows where the default method So nothing needs to be done to access @samp{https://} websites in recent versions of R. -@node How can I get CRAN package binaries for outdated versions of R?, , How can I enable secure https downloads in R?, R Miscellanea +@node How can I get CRAN package binaries for outdated versions of R? @section How can I get CRAN package binaries for outdated versions of R? Since March 2016, Windows and macOS binaries of @CRAN{} packages for old @@ -3288,18 +3172,13 @@ local(@{r <- getOption("repos") @noindent (see @code{?options} for more information). -@node R Programming, R Bugs, R Miscellanea, Top + + +@node R Programming @chapter R Programming -@menu -* How should I write summary methods?:: -* How can I debug dynamically loaded code?:: -* How can I inspect R objects when debugging?:: -* How can I change compilation flags?:: -* How can I debug S4 methods?:: -@end menu -@node How should I write summary methods?, How can I debug dynamically loaded code?, R Programming, R Programming +@node How should I write summary methods? @section How should I write summary methods? Suppose you want to provide a summary method for class @code{"foo"}. @@ -3312,7 +3191,7 @@ return something useful, as sometimes you need to grab something computed by @code{summary()} inside a function or similar. In such cases you don't want anything printed. -@node How can I debug dynamically loaded code?, How can I inspect R objects when debugging?, How should I write summary methods?, R Programming +@node How can I debug dynamically loaded code? @section How can I debug dynamically loaded code? Roughly speaking, you need to start R inside the debugger, load the @@ -3322,7 +3201,7 @@ code, send an interrupt, and then set the required breakpoints. code, R-exts, Writing R Extensions}. This manual is included in the R distribution, @pxref{What documentation exists for R?}. -@node How can I inspect R objects when debugging?, How can I change compilation flags?, How can I debug dynamically loaded code?, R Programming +@node How can I inspect R objects when debugging? @section How can I inspect R objects when debugging? The most convenient way is to call @code{R_PV} from the symbolic @@ -3331,7 +3210,7 @@ debugger. @xref{Inspecting R objects, , Inspecting R objects when debugging, R-exts, Writing R Extensions}. -@node How can I change compilation flags?, How can I debug S4 methods?, How can I inspect R objects when debugging?, R Programming +@node How can I change compilation flags? @section How can I change compilation flags? Suppose you have C code file for @I{dynloading} into R, but you want to use @@ -3342,7 +3221,7 @@ Starting with R 2.1.0, users can provide personal @file{Makevars} configuration files in @file{$@env{HOME}/.R} to override the default flags. @xref{Add-on packages, , , R-admin, R Installation and Administration}. -@node How can I debug S4 methods?, , How can I change compilation flags?, R Programming +@node How can I debug S4 methods? @section How can I debug S4 methods? Use the @code{trace()} function with argument @code{signature=} to add @@ -3350,15 +3229,13 @@ calls to the browser or any other code to the method that will be dispatched for the corresponding signature. See @code{?trace} for details. -@node R Bugs, Acknowledgments, R Programming, Top + + +@node R Bugs @chapter R Bugs -@menu -* What is a bug?:: -* How to report a bug:: -@end menu -@node What is a bug?, How to report a bug, R Bugs, R Bugs +@node What is a bug? @section What is a bug? If R executes an illegal instruction, or dies with an operating system @@ -3409,7 +3286,7 @@ See also ``Making sure it's a bug'' in @uref{https://www.r-project.org/bugs.html, Bug Reporting in R} for more information. -@node How to report a bug, , What is a bug?, R Bugs +@node How to report a bug @section How to report a bug When you decide that there is a bug, it is important to report it and to @@ -3502,8 +3379,10 @@ last translator (listed at the top of the appropriate @samp{.po} file) or to the translation team as listed at @url{https://developer.R-project.org/TranslationTeams.html}. -@node Acknowledgments, , R Bugs, Top -@chapter Acknowledgments + + +@node Acknowledgments +@unnumbered Acknowledgments Of course, many many thanks to Robert and Ross for the R system, and to the package writers and porters for adding to it. @@ -3522,8 +3401,10 @@ Special thanks go to @I{Andreas Weingessel} for their comments which helped me improve this @acronym{FAQ}. +@c FIXME: More to come soon @dots{} + @bye @c Local Variables: *** diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index a25a45e975d..2d333ae3479 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -2,9 +2,7 @@ @c %**start of header @setfilename R-admin.info @settitle R Installation and Administration -@setchapternewpage on @defcodeindex en -@documentencoding UTF-8 @c %**end of header @syncodeindex fn vr @@ -47,7 +45,7 @@ This manual is for R, version @value{VERSION}. @c @end ifnothtml @ifnottex -@node Top, Obtaining R, (dir), (dir) +@node Top @top R Installation and Administration This is a guide to installation and administration for R. @@ -56,25 +54,9 @@ This is a guide to installation and administration for R. @end ifnottex -@menu -* Obtaining R:: -* Installing R under Unix-alikes:: -* Installing R under Windows:: -* Installing R under macOS:: -* Running R:: -* Add-on packages:: -* Internationalization:: -* Choosing between 32- and 64-bit builds:: -* The standalone Rmath library:: -* Essential and useful other programs under a Unix-alike:: -* Configuration on a Unix-alike:: -* Platform notes:: -* Function and variable index:: -* Concept index:: -* Environment variable index:: -@end menu -@node Obtaining R, Installing R under Unix-alikes, Top, Top + +@node Obtaining R @chapter Obtaining R @cindex Obtaining R @@ -82,12 +64,8 @@ Sources, binaries and documentation for @R{} can be obtained via @acronym{CRAN}, the ``Comprehensive R Archive Network'' whose current members are listed at @uref{https://CRAN.R-project.org/mirrors.html}. -@menu -* Getting and unpacking the sources:: -* Getting patched and development versions:: -@end menu -@node Getting and unpacking the sources, Getting patched and development versions, Obtaining R, Obtaining R +@node Getting and unpacking the sources @section Getting and unpacking the sources @cindex Sources for R @@ -135,8 +113,7 @@ variable: if more than one option is included they should be separated by spaces.) - -@node Getting patched and development versions, , Getting and unpacking the sources, Obtaining R +@node Getting patched and development versions @section Getting patched and development versions A patched version of the current release, @samp{r-patched}, and the @@ -153,11 +130,14 @@ The tarballs are available from versions) and unpack as described in the previous section. They are built in exactly the same way as distributions of @R{} releases. + +@c Keep this single-item menu to avoid a spurious warning about +@c an unreferenced node when making info with Texinfo 6.8 and 7.0. @menu * Using Subversion and rsync:: @end menu -@node Using Subversion and rsync, , Getting patched and development versions, Getting patched and development versions +@node Using Subversion and rsync @subsection Using Subversion and @I{rsync} @cindex Subversion @@ -220,7 +200,7 @@ wget -r -l1 --no-parent -A\*.gz -nd -P src/library/Recommended \ -@node Installing R under Unix-alikes, Installing R under Windows, Obtaining R, Top +@node Installing R under Unix-alikes @chapter Installing R under Unix-alikes @cindex Installing under Unix-alikes @@ -253,18 +233,8 @@ of this chapter we consider only building from the sources. Cross-building is not possible: installing @R{} builds a minimal version of @R{} and then runs many @R{} scripts to complete the build. -@menu -* Simple compilation:: -* Help options:: -* Making the manuals:: -* Installation:: -* Uninstallation:: -* Sub-architectures:: -* Other Options:: -* Testing a Unix-alike Installation:: -@end menu -@node Simple compilation, Help options, Installing R under Unix-alikes, Installing R under Unix-alikes +@node Simple compilation @section Simple compilation First review the essential and useful tools and libraries in @@ -415,7 +385,8 @@ standard place for a system installation) ahead of @file{/usr/local/bin} (the default place for installation of @R{}) in their default path, and some do not have @file{/usr/local/bin} on the default path. -@node Help options, Making the manuals, Simple compilation, Installing R under Unix-alikes + +@node Help options @section Help options @R{} by default provides help pages as plain text displayed in a pager, @@ -444,7 +415,8 @@ measures will prevent the server from being started, for example if the loopback interface has been disabled. See @code{?tools::startDynamicHelp} for more details. -@node Making the manuals, Installation, Help options, Installing R under Unix-alikes + +@node Making the manuals @section Making the manuals @cindex Manuals @@ -600,7 +572,7 @@ most Linux distributions. If necessary the path to for macOS) or using @command{make -e}. -@node Installation, Uninstallation, Making the manuals, Installing R under Unix-alikes +@node Installation @section Installation @cindex Installation @@ -781,7 +753,7 @@ make install-tests which populates a @file{tests} directory in the installation. -@node Uninstallation, Sub-architectures, Installation, Installing R under Unix-alikes +@node Uninstallation @section @I{Uninstallation} You can uninstall @R{} by @@ -808,7 +780,7 @@ make prefix=/path/to/here uninstall-libR @end example -@node Sub-architectures, Other Options, Uninstallation, Installing R under Unix-alikes +@node Sub-architectures @section Sub-architectures Now 32-bit builds are unsupported, this section is only of historical @@ -883,7 +855,7 @@ within the appropriate @file{bin} directory such as subdirectory is used. -@node Other Options, Testing a Unix-alike Installation, Sub-architectures, Installing R under Unix-alikes +@node Other Options @section Other Options There are many other installation options, most of which are listed by @@ -931,15 +903,8 @@ their values differ between such locales. (Replacing the system functions provides a degree of platform-independence (including to OS updates) but replaces it with a dependence on the @R{} version.) -@menu -* Debugging Symbols:: -* OpenMP Support:: -* C++ Support:: -* C standards:: -* Link-Time Optimization:: -@end menu -@node Debugging Symbols, OpenMP Support, Other Options, Other Options +@node Debugging Symbols @subsection Debugging Symbols By default, @command{configure} adds a flag (usually @option{-g}) to the @@ -966,7 +931,7 @@ reduction in overall size was from 92MB to 66MB. On macOS debugging symbols are not by default included in @file{.dylib} and @file{.so} files, so there is negligible difference. -@node OpenMP Support, C++ Support, Debugging Symbols, Other Options +@node OpenMP Support @subsection @abbr{OpenMP} Support By default @command{configure} searches for suitable flags@footnote{for @@ -1004,7 +969,7 @@ the Fortran runtime always used @abbr{OpenMP}.} of @abbr{OpenMP}). The loading it into the C program of @R{}'s executable. Note that overridden values are not tested. -@node C++ Support, C standards, OpenMP Support, Other Options +@node C++ Support @subsection C++ Support C++ is not used by @R{} itself, but support is provided for installing @@ -1095,7 +1060,7 @@ which versions of common compilers support (parts of) which C++ standards. GCC introduced C++17 support gradually, but version 7 should suffice. -@node C standards, Link-Time Optimization, C++ Support, Other Options +@node C standards @subsection C standards Compiling @R{} requires C99 or later: C11 and C17 are minor updates, but @@ -1117,7 +1082,7 @@ later of Apple clang warn by default in all modes if @option{-Wall} or @option{-pedantic} is used, and may need @option{-Wno-strict-prototypes}. -@node Link-Time Optimization, , C standards, Other Options +@node Link-Time Optimization @subsection Link-Time Optimization There is support for using link-time optimization (@abbr{LTO}) if the toolchain @@ -1161,13 +1126,7 @@ C/C++ compilers, set macro @samp{LTO_FC} (probably to empty). Macro needed. -@menu -* LTO with GCC:: -* LTO with LLVM:: -* LTO for package checking:: -@end menu - -@node LTO with GCC, LTO with LLVM, Link-Time Optimization, Link-Time Optimization +@node LTO with GCC @subsubsection @abbr{LTO} with GCC This has been tested on Linux with @@ -1215,7 +1174,7 @@ been seen on @acronym{CRAN} with GCC 10--14 at the time of writing). Note that @R{} may need to be re-compiled after even a minor update to the compiler (e.g.@: from 13.1 to 13.2). -@node LTO with LLVM, LTO for package checking, LTO with GCC, Link-Time Optimization +@node LTO with LLVM @subsubsection @abbr{LTO} with @I{LLVM} @I{LLVM} supports another type of @abbr{LTO} called `Thin @abbr{LTO}' as well as a similar @@ -1256,8 +1215,7 @@ something like LTO=-flto=thin -flto-jobs=8 @end example - -@node LTO for package checking, , LTO with LLVM, Link-Time Optimization +@node LTO for package checking @subsubsection @abbr{LTO} for package checking @abbr{LTO} effectively compiles all the source code in a package as a single @@ -1287,7 +1245,8 @@ in C. @c with non-default options for BLAS and LAPACK, and `linking' against @c these libraries may be very slow. -@node Testing a Unix-alike Installation, , Other Options, Installing R under Unix-alikes + +@node Testing a Unix-alike Installation @section Testing an Installation Full post-installation testing is possible only if the test files have @@ -1373,7 +1332,8 @@ LANGUAGE=en and use a UTF-8 or Latin-1 locale. -@node Installing R under Windows, Installing R under macOS, Installing R under Unix-alikes, Top + +@node Installing R under Windows @chapter Installing R under Windows @cindex Installing under Windows @@ -1404,13 +1364,8 @@ See the @uref{https://CRAN.R-project.org/bin/windows/base/rw-FAQ.html, R Windows @acronym{FAQ}} for more details on the binary installer and for information on use on older Windows systems. -@menu -* Building from source:: -* Checking the build:: -* Testing a Windows Installation:: -@end menu -@node Building from source, Checking the build, Installing R under Windows, Installing R under Windows +@node Building from source @section Building from source It is possible to use other 64-bit toolchains (including `MSYS2') with @@ -1418,12 +1373,8 @@ It is possible to use other 64-bit toolchains (including `MSYS2') with used for recent binary distributions of @R{}. When using other toolchains, makefiles of @R{} and packages may need to be adapted. -@menu -* The Windows toolset:: -* LaTeX on Windows:: -@end menu -@node The Windows toolset, LaTeX on Windows, Building from source, Building from source +@node The Windows toolset @subsection The Windows toolset The binary distribution of @R{} is currently built with tools @@ -1453,7 +1404,7 @@ porting @R{} to @I{MinGW-w64} is gratefully acknowledged, as well as help from @I{Kai Tietz}, the lead developer of the @I{MinGW-w64} project and from @I{Martin Storsjo}. -@node LaTeX on Windows, , The Windows toolset, Building from source +@node LaTeX on Windows @subsection @LaTeX{} Both building @R{} and checking packages need a distribution of @LaTeX{} @@ -1473,7 +1424,8 @@ It is also possible to use the TeX Live distribution from @uref{https://www.tug.org/texlive/}. (The @acronym{CRAN} package @CRANpkg{tinytex} can install and manage a subset of TeX Live.) -@node Checking the build, Testing a Windows Installation, Building from source, Installing R under Windows + +@node Checking the build @section Checking the build You can test a build by running @@ -1515,7 +1467,8 @@ and @command{make check-recommended}) is possible: see the environment variable @env{TEST_MC_CORES} to the maximum number of processes to be run in parallel. -@node Testing a Windows Installation, , Checking the build, Installing R under Windows + +@node Testing a Windows Installation @section Testing an Installation The Windows installer contains a set of test files used when building @@ -1567,7 +1520,9 @@ cd tests Remember that @LaTeX{} needs to be on the path. -@node Installing R under macOS, Running R, Installing R under Windows, Top + + +@node Installing R under macOS @chapter Installing R under macOS @cindex macOS @@ -1642,14 +1597,7 @@ select @samp{Open With} and @samp{Installer}.) For building @R{} from source, see @ref{macOS}. - -@menu -* Running R under macOS:: -* Uninstalling under macOS:: -* Multiple versions:: -@end menu - -@node Running R under macOS, Uninstalling under macOS, Installing R under macOS, Installing R under macOS +@node Running R under macOS @section Running R under macOS There are two ways to run @R{} on macOS from a @acronym{CRAN} binary @@ -1729,7 +1677,8 @@ setenv FONTCONFIG_PATH /opt/X11/lib/X11/fontconfig Another symptom has been that italic/oblique fonts are replaced by upright ones. -@node Uninstalling under macOS, Multiple versions, Running R under macOS, Installing R under macOS + +@node Uninstalling under macOS @section Uninstalling under macOS @R{} for macOS consists of two parts: the GUI (@Rapp{}) and the R @@ -1788,7 +1737,8 @@ These are paths relative to @file{/}, the root of the file system. If you are not compiling @R{} nor installing packages from source you could remove all of @file{/opt/R/arm64} or @file{/opt/R/x86_64}. -@node Multiple versions, , Uninstalling under macOS, Installing R under macOS + +@node Multiple versions @section Multiple versions The installer will remove any previous version@footnote{More precisely, @@ -1805,7 +1755,9 @@ type. @Rapp{} will always run the `current' version of @R{}, that is the last installed version. -@node Running R, Add-on packages, Installing R under macOS, Top + + +@node Running R @chapter Running R How to start @R{} and what command-line options are available is discussed @@ -1859,20 +1811,13 @@ scripts when installing packages, so if @file{/tmp} has been mounted as @samp{noexec}, @env{TMPDIR} needs to be set to a directory from which execution is allowed. -@node Add-on packages, Internationalization, Running R, Top + + +@node Add-on packages @chapter Add-on packages @cindex Packages @cindex Libraries -@menu -* Default packages:: -* Managing libraries:: -* Installing packages:: -* Updating packages:: -* Removing packages:: -* Setting up a package repository:: -* Checking installed source packages:: -@end menu It is helpful to use the correct terminology. A @emph{package} is loaded from a @emph{library} by the function @code{library()}. Thus a @@ -1883,7 +1828,8 @@ setting the environment variable @env{R_LIBS} or using the @R{} function @code{.libPaths()}. To avoid any confusion you will often see a library directory referred to as a `library tree'. -@node Default packages, Managing libraries, Add-on packages, Add-on packages + +@node Default packages @section Default packages @cindex Packages, default @@ -1911,7 +1857,7 @@ also checks the environment variable @env{R_SCRIPT_DEFAULT_PACKAGES}; if set, this takes precedence over @env{R_DEFAULT_PACKAGES}. -@node Managing libraries, Installing packages, Default packages, Add-on packages +@node Managing libraries @section Managing libraries @cindex Libraries, managing @@ -1953,19 +1899,10 @@ Both @env{R_LIBS_USER} and @env{R_LIBS_SITE} can specify multiple library paths, separated by colons (semicolons on Windows). -@node Installing packages, Updating packages, Managing libraries, Add-on packages +@node Installing packages @section Installing packages @cindex Packages, installing -@menu -* Windows packages:: -* macOS packages:: -* Customizing package compilation:: -* Multiple sub-architectures:: -* Byte-compilation:: -* External software:: -@end menu - Packages may be distributed in source form or compiled binary form. Installing source packages which contain C/C++/Fortran code requires @@ -2084,7 +2021,8 @@ comparable age to your version of @R{}). Naive users sometimes forget that as well as installing a package, they have to use @code{library} to make its functionality available. -@node Windows packages, macOS packages, Installing packages, Installing packages + +@node Windows packages @subsection Windows What @code{install.packages} does by default is different on Unix-alikes @@ -2165,8 +2103,7 @@ help, you can zip up an installation on another OS and install from that zip file on Windows. However, such a package can be installed from the sources on Windows without any additional tools. - -@node macOS packages, Customizing package compilation, Windows packages, Installing packages +@node macOS packages @subsection macOS On macOS @code{install.packages} works as it does on other Unix-alike @@ -2335,8 +2272,7 @@ consistency one can use @c @noindent @c to force @cputype{arm64} code. - -@node Customizing package compilation, Multiple sub-architectures, macOS packages, Installing packages +@node Customizing package compilation @subsection Customizing package compilation The @R{} system and package-specific compilation flags can be overridden @@ -2404,7 +2340,7 @@ Note that these mechanisms do not work with packages which fail to pass settings down to sub-makes, perhaps reading @file{etc/Makeconf} in makefiles in subdirectories. Fortunately such packages are unusual. -@node Multiple sub-architectures, Byte-compilation, Customizing package compilation, Installing packages +@node Multiple sub-architectures @subsection Multiple sub-architectures When installing packages from their sources, there are some extra @@ -2445,14 +2381,14 @@ additional sub-architecture. There is also @command{R CMD INSTALL --merge-multiarch} to build and merge the two architectures, starting with a source tarball. -@node Byte-compilation, External software, Multiple sub-architectures, Installing packages +@node Byte-compilation @subsection Byte-compilation Packages are by default byte-compiled on installation. Byte-compilation can be controlled on a per-package basis by the @samp{ByteCompile} field in the @file{DESCRIPTION} file. -@node External software, , Byte-compilation, Installing packages +@node External software @subsection External software Some @R{} packages contain compiled code which links to external @@ -2513,7 +2449,8 @@ for @env{DYLD_FALLBACK_LIBRARY_PATH} and for @emph{appending} to @env{PATH} on Windows (as it should already contain the system library paths). -@node Updating packages, Removing packages, Installing packages, Add-on packages + +@node Updating packages @section Updating packages @findex update.packages @cindex Packages, updating @@ -2547,7 +2484,7 @@ rgdal rgdal 0.6-27 upgrade @end example -@node Removing packages, Setting up a package repository, Updating packages, Add-on packages +@node Removing packages @section Removing packages @findex remove.packages @cindex Packages, removing @@ -2569,7 +2506,7 @@ From a running @R{} process they can be removed by Finally, one can just remove the package directory from the library. -@node Setting up a package repository, Checking installed source packages, Removing packages, Add-on packages +@node Setting up a package repository @section Setting up a package repository @cindex Repositories @@ -2631,7 +2568,8 @@ Path: @var{path/to/subdirectory} @noindent ---once again @code{write_PACKAGES} is the simplest way to set this up. -@node Checking installed source packages, , Setting up a package repository, Add-on packages + +@node Checking installed source packages @section Checking installed source packages It can be convenient to run @command{R CMD check} on an installed @@ -2671,7 +2609,9 @@ might use .../bin/x64/Rcmd INSTALL -l @var{libdir} @var{tarball} --build > @var{pkg}.log 2>&1 @end example -@node Internationalization, Choosing between 32- and 64-bit builds, Add-on packages, Top + + +@node Internationalization @chapter Internationalization and Localization @cindex Internationalization @cindex Localization @@ -2693,12 +2633,8 @@ perhaps locale-dependent). The other aspect of the internationalization is support for the translation of messages. This is enabled in almost all builds of @R{}. -@menu -* Locales:: -* Localization of messages:: -@end menu -@node Locales, Localization of messages, Internationalization, Internationalization +@node Locales @section Locales @cindex Locale @@ -2742,13 +2678,8 @@ some OSes as separate languages, @code{no} and @code{nn}). third. Note that the charset may be deducible from the language, as some OSes offer only one charset per language. -@menu -* Locales under Unix-alikes:: -* Locales under Windows:: -* Locales under macOS:: -@end menu -@node Locales under Unix-alikes, Locales under Windows, Locales, Locales +@node Locales under Unix-alikes @subsection Locales under Unix-alikes Modern Linux uses the @abbr{XPG}@footnote{`X/Open Portability Guide', which has @@ -2763,7 +2694,7 @@ Note that whereas UTF-8 locales are nowadays almost universally used, locales such as @samp{en_GB} use 8-bit encodings for backwards compatibility. -@node Locales under Windows, Locales under macOS, Locales under Unix-alikes, Locales +@node Locales under Windows @subsection Locales under Windows Windows also uses locales, but specified in a rather less concise way. @@ -2777,7 +2708,7 @@ Some care is needed with Windows' locale names. For example, @code{chinese} is Traditional Chinese and not Simplified Chinese as used in most of the Chinese-speaking world. -@node Locales under macOS, , Locales under Windows, Locales +@node Locales under macOS @subsection Locales under macOS macOS supports locales in its own particular way, but the @R{} GUI tries to @@ -2796,7 +2727,7 @@ other Unix-alikes is that where a character set is not specified it is assumed to be @code{UTF-8}. -@node Localization of messages, , Locales, Internationalization +@node Localization of messages @section Localization of messages The preferred language for messages is by default taken from the locale. @@ -2891,12 +2822,16 @@ Americanisms.} is used. See @uref{https://developer.r-project.org/Translations30.html} for how to prepare and install translation catalogues. -@node Choosing between 32- and 64-bit builds, The standalone Rmath library, Internationalization, Top + + +@node Choosing between 32- and 64-bit builds @chapter Choosing between 32- and 64-bit builds As from @R{} 4.4.0 32-bit builds are unsupported. -@node The standalone Rmath library, Essential and useful other programs under a Unix-alike, Choosing between 32- and 64-bit builds, Top + + +@node The standalone Rmath library @chapter The standalone @I{Rmath} library The routines supporting the distribution and @@ -2966,12 +2901,7 @@ typedef enum @{ (and @samp{USER_NORM} is not available). -@menu -* Unix-alike standalone:: -* Windows standalone:: -@end menu - -@node Unix-alike standalone, Windows standalone, The standalone Rmath library, The standalone Rmath library +@node Unix-alike standalone @section Unix-alikes If @R{} has not already been made in the directory tree, @@ -3031,8 +2961,7 @@ On some systems @samp{make install-strip} will install a stripped shared library. - -@node Windows standalone, , Unix-alike standalone, The standalone Rmath library +@node Windows standalone @section Windows You need to set up@footnote{including copying @file{MkRules.dist} to @@ -3109,7 +3038,8 @@ sure. This is likely to also work with @I{VC++}, @I{Borland} and similar compilers.) -@node Essential and useful other programs under a Unix-alike, Configuration on a Unix-alike, The standalone Rmath library, Top + +@node Essential and useful other programs under a Unix-alike @appendix Essential and useful other programs under a Unix-alike This appendix gives details of programs you will need to build @R{} on @@ -3122,13 +3052,8 @@ package and the development version. The latter usually has the same name but with the extension @samp{-devel} or @samp{-dev}: you need both versions installed. -@menu -* Essential programs and libraries:: -* Useful libraries and programs:: -* Linear algebra:: -@end menu -@node Essential programs and libraries, Useful libraries and programs, Essential and useful other programs under a Unix-alike, Essential and useful other programs under a Unix-alike +@node Essential programs and libraries @section Essential programs and libraries You need a means of compiling C and Fortran 90 (see @ref{Using @@ -3336,7 +3261,8 @@ requires distribution of the licence (included in @R{}'s licensed under GPL (which version(s) of GPL depends on the @code{readline} version). -@node Useful libraries and programs, Linear algebra, Essential programs and libraries, Essential and useful other programs under a Unix-alike + +@node Useful libraries and programs @section Useful libraries and programs The ability to use translated messages makes use of @code{gettext} and @@ -3470,13 +3396,8 @@ pkgconf-pkg-config pcre2 readline tcl tk xz zlib @noindent plus, preferably a TeX installation and Java. -@menu -* Tcl/Tk:: -* Java support:: -* Other compiled languages:: -@end menu -@node Tcl/Tk, Java support, Useful libraries and programs, Useful libraries and programs +@node Tcl/Tk @subsection Tcl/Tk The @pkg{tcltk} package needs Tcl/Tk @geq{} 8.4 installed: the sources are @@ -3508,7 +3429,7 @@ the `Aqua' version of Tk on macOS, but distributions of that include a copy of the X11 files needed.} X11 headers, so you will need X11 and its development files installed. -@node Java support, Other compiled languages, Tcl/Tk, Useful libraries and programs +@node Java support @subsection Java support The build process looks for Java support on the host system, and if it @@ -3585,7 +3506,7 @@ sudo apt install default-jdk @end example @c https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-22-04 -@node Other compiled languages, , Java support, Useful libraries and programs +@node Other compiled languages @subsection Other compiled languages Some add-on packages need a C++ compiler. This is specified by the @@ -3610,15 +3531,11 @@ set. See file @file{config.site} in the @R{} source for more details about these variables. -@node Linear algebra, , Useful libraries and programs, Essential and useful other programs under a Unix-alike + +@node Linear algebra @section Linear algebra @cindex BLAS library -@menu -* BLAS:: -* LAPACK:: -* Caveats:: -@end menu The linear algebra routines in @R{} make use of @acronym{BLAS} (Basic Linear Algebra Subprograms, @uref{https://netlib.org/blas/faq.html}) @@ -3670,7 +3587,7 @@ There is a tendency for re-distributors of @R{} to use `enhanced' linear algebra libraries without explaining their downsides. -@node BLAS, LAPACK, Linear algebra, Linear algebra +@node BLAS @subsection BLAS An external BLAS library has to be explicitly requested at configure @@ -3738,14 +3655,8 @@ running @R{} session by package @CRANpkg{flexiblas}. BLAS implementations which use parallel computations can be non-deterministic: this is known for ATLAS. -@menu -* ATLAS:: -* OpenBLAS and BLIS:: -* MKL:: -* Shared BLAS:: -@end menu -@node ATLAS, OpenBLAS and BLIS, BLAS, BLAS +@node ATLAS @subsubsection ATLAS ATLAS (@uref{https://math-atlas.sourceforge.net/}) is a ``tuned'' @@ -3806,7 +3717,7 @@ virtual core per physical CPU. (For the Fedora libraries the compile-time flag specifies 4 threads.) @c https://math-atlas.sourceforge.net/atlas_install/node21.html -@node OpenBLAS and BLIS, MKL, ATLAS, BLAS +@node OpenBLAS and BLIS @subsubsection @I{OpenBLAS} and @I{BLIS} @I{Dr Kazushige Goto} wrote a tuned @acronym{BLAS} for several processors @@ -3868,7 +3779,7 @@ libbliso.so also be used as a shared BLAS. The Fedora builds do not include LAPACK in the @I{BLIS} libraries. -@node MKL, Shared BLAS, OpenBLAS and @I{BLIS}, BLAS +@node MKL @subsubsection Intel @I{MKL} For Intel processors (and perhaps others) and some distributions of Linux, there is Intel's Math Kernel Library@footnote{Nowadays known as @@ -3968,7 +3879,7 @@ which we have not found necessary. @c @noindent @c worked with the Intel 2015.3 compilers on Centos 6. -@node Shared BLAS, , MKL, BLAS +@node Shared BLAS @subsubsection Shared BLAS The @acronym{BLAS} library will be used for many of the add-on packages @@ -4044,7 +3955,7 @@ the @I{OpenBLAS} distribution contains a copy of LAPACK, it is the latter which is used. -@node LAPACK, Caveats, BLAS, Linear algebra +@node LAPACK @subsection LAPACK @cindex LAPACK library @@ -4136,7 +4047,7 @@ default to select one), consider also using @option{--with-blas} (with a path if an enhanced BLAS is installed). -@node Caveats, , LAPACK, Linear algebra +@node Caveats @subsection Caveats As with all libraries, you need to ensure that they and @R{} were @@ -4193,21 +4104,12 @@ more elements: it is possible that an external LAPACK will not have that support. -@node Configuration on a Unix-alike, Platform notes, Essential and useful other programs under a Unix-alike, Top + +@node Configuration on a Unix-alike @appendix Configuration on a Unix-alike -@menu -* Configuration options:: -* Internationalization support:: -* Configuration variables:: -* Setting the shell:: -* Using make:: -* Using Fortran:: -* Compile and load flags:: -* Maintainer mode:: -@end menu -@node Configuration options, Internationalization support, Configuration on a Unix-alike, Configuration on a Unix-alike +@node Configuration options @section Configuration options @command{configure} has many options: running @@ -4278,7 +4180,8 @@ The @file{configure} script has other generic options added by @command{autoconf} and which are not supported for @R{}: in particular building for one architecture on a different host is not possible. -@node Internationalization support, Configuration variables, Configuration options, Configuration on a Unix-alike + +@node Internationalization support @section Internationalization support Translation of messages is supported via @acronym{GNU} @code{gettext} @@ -4295,7 +4198,7 @@ in an English locale (but not the @code{C} locale) will include in the greeting on starting R. -@node Configuration variables, Setting the shell, Internationalization support, Configuration on a Unix-alike +@node Configuration variables @section Configuration variables @findex configure @@ -4341,14 +4244,8 @@ is a good idea to remove that file (if it exists) before re-configuring. Note that caching is turned @emph{off} by default: use the command line option @option{--config-cache} (or @option{-C}) to enable caching. -@menu -* Setting paper size:: -* Setting the browsers:: -* Compilation flags:: -* Making manuals:: -@end menu -@node Setting paper size, Setting the browsers, Configuration variables, Configuration variables +@node Setting paper size @subsection Setting paper size @enindex R_PAPERSIZE One common variable to change is @env{R_PAPERSIZE}, which defaults to @@ -4366,7 +4263,7 @@ Linux distributions, or the environment variable @env{PAPERSIZE} is set, these are used to produce the default.) -@node Setting the browsers, Compilation flags, Setting paper size, Configuration variables +@node Setting the browsers @subsection Setting the browsers @enindex R_BROWSER @@ -4377,7 +4274,7 @@ or specify a full path. @enindex R_PDFVIEWER Its counterpart for PDF files is @env{R_PDFVIEWER}. -@node Compilation flags, Making manuals, Setting the browsers, Configuration variables +@node Compilation flags @subsection Compilation flags If you have libraries and header files, e.g., for @acronym{GNU} @@ -4412,7 +4309,7 @@ specific @acronym{CPU} family (e.g.@: @samp{-mtune=native} for @command{gcc}) can give worthwhile performance gains, especially on older architectures such as @cputype{ix86}. -@node Making manuals, , Compilation flags, Configuration variables +@node Making manuals @subsection Making manuals @enindex R_RD4PDF @@ -4420,7 +4317,8 @@ older architectures such as @cputype{ix86}. The default settings for making the manuals are controlled by @env{R_RD4PDF} and @env{R_PAPERSIZE}. -@node Setting the shell, Using make, Configuration variables, Configuration on a Unix-alike + +@node Setting the shell @section Setting the shell By default the shell scripts such as @file{R} will be @samp{#!/bin/sh} @@ -4430,7 +4328,8 @@ almost always satisfactory, but on a few systems @file{/bin/sh} is not a setting the configure variable @env{R_SHELL} to a suitable value (a full path to a shell, e.g.@: @file{/usr/local/bin/bash}). -@node Using make, Using Fortran, Setting the shell, Configuration on a Unix-alike + +@node Using make @section Using make @findex make @@ -4447,7 +4346,8 @@ variable @code{MAKE} at configure time, for example ./configure MAKE=gmake @end example -@node Using Fortran, Compile and load flags, Using make, Configuration on a Unix-alike + +@node Using Fortran @section Using Fortran @cindex Fortran @@ -4497,7 +4397,8 @@ an array is expected, or a scalar instead of a length-one array. See @uref{https://gcc.gnu.org/gcc-10/porting_to.html}. @command{gfortran}@tie{}12 errors in more cases of this. -@node Compile and load flags, Maintainer mode, Using Fortran, Configuration on a Unix-alike + +@node Compile and load flags @section Compile and load flags A wide range of flags can be set in the file @file{config.site} or as @@ -4582,7 +4483,8 @@ On some platforms @command{configure} will select additional flags for (and so on). These are for options which are always required, for example to force @acronym{IEC}@tie{}60559 compliance. -@node Maintainer mode, , Compile and load flags, Configuration on a Unix-alike + +@node Maintainer mode @section Maintainer mode There are several files that are part of the @R{} sources but can be @@ -4629,7 +4531,9 @@ sources are only re-created even in maintainer mode if @c (usually called @pkg{autoconf-archive}) in most packaged distributions, @c for example Debian, Fedora, OpenCSW, Homebrew and MacPorts. -@node Platform notes, Function and variable index, Configuration on a Unix-alike, Top + + +@node Platform notes @appendix Platform notes This section provides some notes on building @R{} on different Unix-alike @@ -4679,17 +4583,8 @@ IBM, will define these. Some of the included software uses Apple builds of GCC), but Apple @command{clang} is better identified by the @code{__apple_build_version__} macro. -@menu -* X11 issues:: -* Linux:: -* macOS:: -* FreeBSD:: -* OpenBSD:: -* Cygwin:: -* New platforms:: -@end menu -@node X11 issues, Linux, Platform notes, Platform notes +@node X11 issues @section X11 issues The @samp{X11()} graphics device is the one started automatically on @@ -4778,7 +4673,7 @@ directory or elsewhere, for example, @end example -@node Linux, macOS, X11 issues, Platform notes +@node Linux @section Linux @cindex Linux @@ -4888,13 +4783,8 @@ Use of @code{_GLIBCXX_ASSERTIONS} will link @code{abort} and @code{printf} into almost all C++ code, and @command{R CMD check --as-cran} will warn. -@menu -* Clang:: -* flang:: -* Intel compilers:: -@end menu -@node Clang, flang, Linux, Linux +@node Clang @subsection Clang @R{} has been built with Linux @cputype{ix86} and @cputype{x86_64} C and @@ -4928,7 +4818,7 @@ FPIEFLAGS=-fPIE in @file{config.site}. (@command{configure} tries that value if it is unset.) -@node flang, Intel compilers, Clang, Linux +@node flang @subsection @I{flang} The name @command{flang} has been used for two projects: this is about @@ -4983,8 +4873,7 @@ tested with @R{}. @c binary `releases' were available for that platform (called by them @c @cputype{x86}) and @cputype{ppc64le}. - -@node Intel compilers, , flang, Linux +@node Intel compilers @subsection Intel compilers In late 2020 Intel revamped their C/C++ compilers (and later their @@ -5094,7 +4983,8 @@ Windows). @c x86_64-apple-macos10.12 and arm64-apple-macos11 @c 'Activity monitor' reports the architectures as 'Intel' and 'Apple' -@node macOS, FreeBSD, Linux, Platform notes + +@node macOS @section macOS @cindex macOS @@ -5104,22 +4994,8 @@ The instructions here are for `Apple Silicon' (@cputype{arm64}) or Intel (They may well work on Intel macOS 10.14 or 10.15, but are untested there.) -@menu -* Prerequisites:: -* Fortran compilers:: -* Cairo graphics:: -* Other C/C++ compilers:: -* Other libraries:: -* Tcl/Tk headers and libraries:: -* Java (macOS):: -* Frameworks:: -* Building R.app:: -* Building binary packages:: -* Building for Intel on arm64:: -* Installer:: -@end menu -@node Prerequisites, Fortran compilers, macOS, macOS +@node Prerequisites @subsection Prerequisites The Apple silicon components install into @file{/opt/R/arm64}, the @@ -5371,7 +5247,7 @@ recognize dates with a negative @code{tm_year}, that is dates before notably in Europe in the 1900s and 1940s, even though the Olson database contains the correct information. -@node Fortran compilers, Cairo graphics, Prerequisites, macOS +@node Fortran compilers @subsection Fortran compiler There is a `universal' (@code{arm64} and Intel) build of @@ -5401,7 +5277,7 @@ LDFLAGS="-L/opt/R/arm64/lib -rpath /usr/local/gfortran/lib" in @file{config.site} to ensure the Fortran run-time libraries are found. -@node Cairo graphics, Other C/C++ compilers, Fortran compilers, macOS +@node Cairo graphics @subsection Cairo graphics @cindex Cairo @@ -5470,7 +5346,7 @@ what is missing. At the time of writing using pre-built components @code{harfbuzz}, @code{pango}, @code{pcre}, @code{pixman} and @code{xml2} sufficed. -@node Other C/C++ compilers, Other libraries, Cairo graphics, macOS +@node Other C/C++ compilers @subsection Other C/C++ compilers @c Un May 2024, 18.1.6 was the final release of that series, but the @@ -5533,13 +5409,9 @@ Note that that approach is somewhat fragile as it needs a used---and for example at the time of writing none was offered for the current compilers in @I{Xcode CLT} 14.3 nor 15. -@node Other libraries, Tcl/Tk headers and libraries, Other C/C++ compilers, macOS +@node Other libraries @subsection Other libraries -@menu -* Accelerate:: -* OpenBLAS (macOS):: -@end menu Pre-compiled versions of many of the @ref{Useful libraries and programs} are available from @uref{https://mac.r-project.org/bin//}. @@ -5597,7 +5469,8 @@ downloaded from @uref{https://www.stats.ox.ac.uk/pub/bdr/timeout}: make it executable (@code{chmod 755 timeout}) and put it somewhere on your path. -@node Accelerate, OpenBLAS (macOS), Other libraries, Other libraries + +@node Accelerate @subsubsection @I{Accelerate} @cindex BLAS library @@ -5646,7 +5519,7 @@ of @I{Accelerate} show differences from the reference BLAS (and most others) in the use of @code{NA} @emph{vs} @code{NaN} and a substantial number of @R{} packages fail their checks. -@node OpenBLAS (macOS), , Accelerate, Other libraries +@node OpenBLAS (macOS) @subsubsection @I{OpenBLAS} @R{} has been built on @cputype{arm64} using @I{OpenBLAS} 0.3.24 (sources @@ -5661,7 +5534,8 @@ defaulted to 10 threads (there are 8 `performance' cores and 2 `efficiency cores`) and we saw a 9x speedup over the reference BLAS on a large SVD (which was slightly faster than @I{Accelerate}). -@node Tcl/Tk headers and libraries, Java (macOS), Other libraries, macOS + +@node Tcl/Tk headers and libraries @subsection Tcl/Tk headers and libraries If you plan to use the @code{tcltk} package for @R{}, you will need to @@ -5708,7 +5582,7 @@ Note that some Tcl/Tk extensions only support the X11 interface: this includes @code{Tktable} and the @acronym{CRAN} package @CRANpkg{tkrplot}. -@node Java (macOS), Frameworks, Tcl/Tk headers and libraries, macOS +@node Java (macOS) @subsection Java @c The situation with Java support on macOS is messy,@footnote{For more @@ -5784,8 +5658,7 @@ JAVA_HOME=/path/to/jdk-21.jdk/Contents/Home Note that it is necessary to set the environment variable @env{NOAWT} to @code{1} to install many of the Java-using packages. - -@node Frameworks, Building R.app, Java (macOS), macOS +@node Frameworks @subsection Frameworks The @acronym{CRAN} build of @R{} is installed as a framework, which is @@ -5816,7 +5689,7 @@ non-standard location) and Unix utilities may not support it (e.g.@: the @command{pkg-config} file @file{libR.pc} will be put somewhere unknown to @command{pkg-config}). -@node Building R.app, Building binary packages, Frameworks, macOS +@node Building R.app @subsection Building R.app Building the @Rapp{} GUI console is a separate project, using @I{Xcode}. @@ -5843,7 +5716,7 @@ See also the @file{INSTALL} file in the checkout or directly at icon. This application bundle can be run from anywhere and it is customary to place it in the @file{/Applications} folder. -@node Building binary packages, Building for Intel on arm64, Building R.app, macOS +@node Building binary packages @subsection Building binary packages @acronym{CRAN} macOS binary packages are distributed as tarballs with @@ -5922,7 +5795,7 @@ The @acronym{CRAN} binary packages are built with the Apple compiler on the oldest supported version of macOS, which avoids the first two and any issues with C++ libraries. -@node Building for Intel on arm64, Installer, Building binary packages, macOS +@node Building for Intel on arm64 @subsection Building for Intel on @samp{arm64} Should one want to build @R{} for Intel on an @cputype{arm64} @I{Big Sur} @@ -5947,15 +5820,15 @@ To set the correct architecture (which will be auto-detected as /path/to/configure --build=x86_64-apple-darwin20 @end example - -@node Installer, , Building for Intel on arm64, macOS +@node Installer @subsection Installer The scripts for the @acronym{CRAN} packaging of @R{} can be found under @uref{https://svn.r-project.org/R-dev-web/trunk/QA/Simon/R4/}: start with the @file{README} file in that directory. -@node FreeBSD, OpenBSD, macOS, Platform notes + +@node FreeBSD @section FreeBSD @cindex FreeBSD @@ -5968,7 +5841,8 @@ configured to use GCC. Use of ICU for collation and the @command{configure} option @option{--with-internal-tzcode} are desirable workarounds. -@node OpenBSD, Cygwin, FreeBSD, Platform notes + +@node OpenBSD @section @I{OpenBSD} @cindex @I{OpenBSD} @@ -5978,7 +5852,8 @@ Use of ICU for collation and the @command{configure} option @uref{https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/math/R/}, currently updated for @R{} 4.2.3. -@node Cygwin, New platforms, OpenBSD, Platform notes + +@node Cygwin @section @I{Cygwin} The 32-bit version never worked well enough to pass @R{}'s @command{make @@ -5987,7 +5862,8 @@ check}, and residual support from earlier experiments was removed in The 64-bit version was never supported. -@node New platforms, , Cygwin, Platform notes + +@node New platforms @section New platforms There are a number of sources of problems when installing @R {} on a new @@ -6056,17 +5932,20 @@ C/C++/Fortran calls to entry point names used for @command{R CMD check}. See @uref{https://svn.r-project.org/R-dev-web/trunk/sotools.txt} for how to do so. -@node Function and variable index, Concept index, Platform notes, Top + +@node Function and variable index @unnumbered Function and variable index @printindex vr -@node Concept index, Environment variable index, Function and variable index, Top + +@node Concept index @unnumbered Concept index @printindex cp -@node Environment variable index, , Concept index, Top + +@node Environment variable index @unnumbered Environment variable index @printindex en diff --git a/doc/manual/R-data.texi b/doc/manual/R-data.texi index a8367bd9949..313cb0cebb5 100644 --- a/doc/manual/R-data.texi +++ b/doc/manual/R-data.texi @@ -2,7 +2,6 @@ @c %**start of header @setfilename R-data.info @settitle R Data Import/Export -@setchapternewpage on @c %**end of header @syncodeindex fn vr @@ -45,7 +44,7 @@ This manual is for R, version @value{VERSION}. @c @end ifnothtml @ifnottex -@node Top, Acknowledgements, (dir), (dir) +@node Top @top R Data Import/Export This is a guide to importing and exporting data to and from R. @@ -54,23 +53,9 @@ This is a guide to importing and exporting data to and from R. @end ifnottex -@menu -* Acknowledgements:: -* Introduction:: -* Spreadsheet-like data:: -* Importing from other statistical systems:: -* Relational databases:: -* Binary files:: -* Image files:: -* Connections:: -* Network interfaces:: -* Reading Excel spreadsheets:: -* References:: -* Function and variable index:: -* Concept index:: -@end menu -@node Acknowledgements, Introduction, Top, Top + +@node Acknowledgements @unnumbered Acknowledgements The relational databases part of this manual is based in part on an @@ -152,7 +137,8 @@ principal authors of the packages mentioned are @I{Brian Ripley} is the author of the support for connections. -@node Introduction, Spreadsheet-like data, Acknowledgements, Top + +@node Introduction @chapter Introduction Reading data into a statistical system for analysis and exporting the @@ -201,13 +187,8 @@ This manual was first written in 2000, and the number of scope of @R{} packages has increased a hundredfold since. For specialist data formats it is worth searching to see if a suitable package already exists. -@menu -* Imports:: -* Export to text files:: -* XML:: -@end menu -@node Imports, Export to text files, Introduction, Introduction +@node Imports @section Imports @findex scan @@ -246,11 +227,14 @@ extraction operation can be done directly from an @R{} package: @xref{Relational databases}. Importing data via network connections is discussed in @ref{Network interfaces}. + +@c Keep this single-item menu to avoid a spurious warning about +@c an unreferenced node when making info with Texinfo 6.8 and 7.0. @menu * Encodings:: @end menu -@node Encodings, , Imports, Imports +@node Encodings @subsection Encodings @cindex Encodings @@ -298,7 +282,8 @@ Note that @code{utf8} is not a valid encoding name (@code{UTF-8} is), and @code{macintosh} is the most portable name for what is sometimes called `Mac Roman' encoding. -@node Export to text files, XML, Imports, Introduction + +@node Export to text files @section Export to text files @cindex Exporting to a text file @@ -453,7 +438,8 @@ Function @code{write.foreign} in package @CRANpkg{foreign} uses that will read this text file into another statistical package. There is currently support for export to @code{SAS}, @code{SPSS} and @code{Stata}. -@node XML, , Export to text files, Introduction + +@node XML @section XML @cindex XML @@ -497,25 +483,20 @@ provided by package @CRANpkg{xml2}. emphasis on human-readability: it is supported by package @CRANpkg{yaml}. -@node Spreadsheet-like data, Importing from other statistical systems, Introduction, Top + + +@node Spreadsheet-like data @chapter Spreadsheet-like data @cindex Spreadsheet-like data -@menu -* Variations on read.table:: -* Fixed-width-format files:: -* Data Interchange Format (DIF):: -* Using scan directly:: -* Re-shaping data:: -* Flat contingency tables:: -@end menu In @ref{Export to text files} we saw a number of variations on the format of a spreadsheet-like text file, in which the data are presented in a rectangular grid, possibly with row and column labels. In this section we consider importing such files into @R{}. -@node Variations on read.table, Fixed-width-format files, Spreadsheet-like data, Spreadsheet-like data + +@node Variations on read.table @section Variations on @code{read.table} @findex read.table @@ -768,7 +749,7 @@ rows to be read (and a mild over-estimate is better than not specifying this at all). See the examples in later sections. -@node Fixed-width-format files, Data Interchange Format (DIF), Variations on read.table, Spreadsheet-like data +@node Fixed-width-format files @section Fixed-width-format files @cindex Fixed-width-format files @@ -786,12 +767,12 @@ recommend using the facilities of a language like @code{perl} to pre-process the file. @cindex @I{perl} - @findex read.fortran Function @code{read.fortran} is a similar function for fixed-format files, using Fortran-style column specifications. -@node Data Interchange Format (DIF), Using scan directly, Fixed-width-format files, Spreadsheet-like data + +@node Data Interchange Format (DIF) @section Data Interchange Format (DIF) @cindex Data Interchange Format (DIF) @@ -808,7 +789,8 @@ from there directly. It is slightly more robust than @code{read.table("clipboard")} in handling spreadsheets with empty cells. -@node Using scan directly, Re-shaping data, Data Interchange Format (DIF), Spreadsheet-like data + +@node Using scan directly @section Using @code{scan} directly @findex scan @@ -896,7 +878,7 @@ basic reads in Windows take at least as twice as long as these Linux times) and on the precise state of the garbage collector. -@node Re-shaping data, Flat contingency tables, Using scan directly, Spreadsheet-like data +@node Re-shaping data @section Re-shaping data @cindex Re-shaping data @@ -978,7 +960,8 @@ than the one column in this example. With @code{direction="wide"}, Some people prefer the tools in packages @CRANpkg{reshape}, @CRANpkg{reshape2} and @CRANpkg{plyr}. -@node Flat contingency tables, , Re-shaping data, Spreadsheet-like data + +@node Flat contingency tables @section Flat contingency tables @cindex Flat contingency tables @@ -1031,7 +1014,8 @@ in the data, and create the contingency table from this using @code{xtabs}. -@node Importing from other statistical systems, Relational databases, Spreadsheet-like data, Top + +@node Importing from other statistical systems @chapter Importing from other statistical systems @cindex Importing from other statistical systems @@ -1044,12 +1028,8 @@ specific versions of the other system (often in the early 2000s), and have not necessarily been updated for the most recent versions of the other system. -@menu -* EpiInfo Minitab SAS S-PLUS SPSS Stata Systat:: -* Octave:: -@end menu -@node EpiInfo Minitab SAS S-PLUS SPSS Stata Systat, Octave, Importing from other statistical systems, Importing from other statistical systems +@node EpiInfo Minitab SAS S-PLUS SPSS Stata Systat @section @I{EpiInfo}, @I{Minitab}, S-PLUS, SAS, SPSS, @I{Stata}, @I{Systat} The recommended package @CRANpkg{foreign} provides import facilities for @@ -1139,7 +1119,7 @@ machines (such as from Windows). These have extension @file{.sys} or (more recently) @file{.syd}. -@node Octave, , EpiInfo Minitab SAS S-PLUS SPSS Stata Systat, Importing from other statistical systems +@node Octave @section Octave @cindex Octave @findex read.octave @@ -1153,19 +1133,16 @@ most of the common types of variables, including the standard atomic ranges, and boolean scalars and matrices) and recursive (structs, cells, and lists) ones. -@node Relational databases, Binary files, Importing from other statistical systems, Top + + +@node Relational databases @chapter Relational databases @cindex Relational databases @cindex DBMS -@menu -* Why use a database?:: -* Overview of RDBMSs:: -* R interface packages:: -@end menu -@node Why use a database?, Overview of RDBMSs, Relational databases, Relational databases +@node Why use a database? @section Why use a database? There are limitations on the types of data that @R{} handles well. @@ -1219,7 +1196,8 @@ is used by KDE4 to store personal information. Several macOS applications, including Mail and Address Book, use SQLite. @c https://www.actualtech.com/sqlite_applications.php -@node Overview of RDBMSs, R interface packages, Why use a database?, Relational databases + +@node Overview of RDBMSs @section Overview of RDBMSs Traditionally there had been large (and expensive) commercial @abbr{RDBMS}s @@ -1254,12 +1232,7 @@ sometimes pronounced `sequel': see Bowman @emph{@I{et al.}@:} 1996 and Kline and Kline 2001) which these @abbr{DBMS}s support to varying degrees. -@menu -* SQL queries:: -* Data types:: -@end menu - -@node SQL queries, Data types, Overview of RDBMSs, Overview of RDBMSs +@node SQL queries @subsection @acronym{SQL} queries @cindex SQL queries @@ -1330,7 +1303,7 @@ DELETE or UPDATE data. A table is destroyed by a DROP TABLE `query'. Kline and Kline (2001) discuss the details of the implementation of SQL in Microsoft SQL Server 2000, Oracle, MySQL and PostgreSQL. -@node Data types, , SQL queries, Overview of RDBMSs +@node Data types @subsection Data types Data can be stored in a database in various data types. The range of @@ -1369,7 +1342,8 @@ timezone}. Other types widely implemented are @code{text} and The more comprehensive of the @R{} interface packages hide the type conversion issues from the user. -@node R interface packages, , Overview of RDBMSs, Relational databases + +@node R interface packages @section R interface packages There are several packages available on @acronym{CRAN} to help @R{} @@ -1401,13 +1375,7 @@ which are queried using JavaScript rather than SQL. Package @CRANpkg{mongolite} is another client using @pkg{mongodb}'s C driver. -@menu -* DBI:: -* RODBC:: -@end menu - - -@node DBI, RODBC, R interface packages, R interface packages +@node DBI @subsection Packages using DBI @cindex MySQL database system @@ -1498,7 +1466,7 @@ Arkansas 8.8 190 50 19.5 > dbDisconnect(con) @end smallexample -@node RODBC, , DBI, R interface packages +@node RODBC @subsection Package @pkg{RODBC} @cindex ODBC @cindex Open Database Connectivity @@ -1655,7 +1623,7 @@ differences. -@c @node RPgSQL, , RODBC, R interface packages +@c @node RPgSQL @c @subsection Package RPgSQL @c @cindex PostgreSQL database system @@ -1773,21 +1741,16 @@ differences. @c within a data frame and PostgreSQL types. -@node Binary files, Image files, Relational databases, Top + +@node Binary files @chapter Binary files @cindex Binary files -@menu -* Binary data formats:: -* dBase files (DBF):: -@end menu - Binary connections (@ref{Connections}) are now the preferred way to handle binary files. - -@node Binary data formats, dBase files (DBF), Binary files, Binary files +@node Binary data formats @section Binary data formats @findex hdf5 @cindex Hierarchical Data Format @@ -1816,7 +1779,8 @@ version 3 files. The availability of software to support these formats is somewhat limited by platform, especially on Windows. -@node dBase files (DBF), , Binary data formats, Binary files + +@node dBase files (DBF) @section @I{dBase} files (@I{DBF}) @cindex @I{dBase} @@ -1846,7 +1810,9 @@ comprehensive facilities to read @abbr{DBF} files @emph{via} Microsoft's @I{dBas @code{odbcDriverConnect}). @findex odbcConnectDbase -@node Image files, Connections, Binary files, Top + + +@node Image files @chapter Image files A particular class of binary files are those representing images, and a @@ -1887,7 +1853,8 @@ different format from JPEG, and not currently supported in the macOS nor Windows binary versions of @CRANpkg{rgdal}). -@node Connections, Network interfaces, Image files, Top + +@node Connections @chapter Connections @cindex Connections @@ -1896,16 +1863,7 @@ Ripley (2001), a set of functions to replace the use of file names by a flexible interface to file-like objects. -@menu -* Types of connections:: -* Output to connections:: -* Input from connections:: -* Listing and manipulating connections:: -* Binary connections:: -@end menu - - -@node Types of connections, Output to connections, Connections, Connections +@node Types of connections @section Types of connections @cindex Connections @@ -1995,7 +1953,7 @@ Sockets can also be used as connections via function read from, and both client and server sockets can be used. -@node Output to connections, Input from connections, Types of connections, Connections +@node Output to connections @section Output to connections @cindex Connections @@ -2050,7 +2008,8 @@ close(zz) cat(ex.lm.out, sep = "\n") @end example -@node Input from connections, Listing and manipulating connections, Output to connections, Connections + +@node Input from connections @section Input from connections @findex scan @@ -2089,11 +2048,14 @@ For convenience, if the @code{file} argument specifies a FTP, HTTP or @abbr{HTTPS} @acronym{URL}, the @acronym{URL} is opened for reading via @code{url}. Specifying files via @samp{file://foo.bar} is also allowed. + +@c Keep this single-item menu to avoid a spurious warning about +@c an unreferenced node when making info with Texinfo 6.8 and 7.0. @menu * Pushback:: @end menu -@node Pushback, , Input from connections, Input from connections +@node Pushback @subsection @I{Pushback} @findex pushBack. @@ -2130,7 +2092,8 @@ Read 4 items @I{Pushback} is only available for connections opened for input in text mode. -@node Listing and manipulating connections, Binary connections, Input from connections, Connections + +@node Listing and manipulating connections @section Listing and manipulating connections @cindex Connections @@ -2155,7 +2118,7 @@ writing at its current position. It works only for @code{file} connections, and is not implemented on all platforms. -@node Binary connections, , Listing and manipulating connections, Connections +@node Binary connections @section Binary connections @cindex Binary files @@ -2218,11 +2181,13 @@ of bytes terminated by a zero byte. Functions @code{readChar} and @code{writeChar} provide greater flexibility. +@c Keep this single-item menu to avoid a spurious warning about +@c an unreferenced node when making info with Texinfo 6.8 and 7.0. @menu * Special values:: @end menu -@node Special values, , Binary connections, Binary connections +@node Special values @subsection Special values Functions @code{readBin} and @code{writeBin} will pass missing and @@ -2254,18 +2219,15 @@ provision to recognize character values as missing (as this can be done by re-assigning them once read). -@node Network interfaces, Reading Excel spreadsheets, Connections, Top -@chapter Network interfaces -@menu -* Reading from sockets:: -* Using download.file:: -@end menu +@node Network interfaces +@chapter Network interfaces Some limited facilities are available to exchange data at a lower level across network connections. -@node Reading from sockets, Using download.file, Network interfaces, Network interfaces + +@node Reading from sockets @section Reading from sockets @cindex Sockets @@ -2285,7 +2247,7 @@ The earlier low-level interface is given by functions @code{make.socket}, @code{read.socket}, @code{write.socket} and @code{close.socket}. -@node Using download.file, , Reading from sockets, Network interfaces +@node Using download.file @section Using @code{download.file} Function @code{download.file} is provided to read a file from a Web @@ -2296,7 +2258,8 @@ Often this can be avoided, as functions such as @code{read.table} and as the @code{file} argument. -@node Reading Excel spreadsheets, References, Network interfaces, Top + +@node Reading Excel spreadsheets @chapter Reading Excel spreadsheets @findex .xls @@ -2373,8 +2336,10 @@ Package @CRANpkg{XLConnect} can read, write and manipulate both Excel Package @CRANpkg{readxl} can read both Excel 97--2003 and Excel 2007/10 spreadsheets, using an included C library. -@node References, Function and variable index, Reading Excel spreadsheets, Top -@appendix References + + +@node References +@unnumbered References @noindent @I{R.@: A.@: Becker}, @I{J.@: M.@: Chambers} and @I{A.@: R.@: Wilks} (1988), @@ -2429,12 +2394,14 @@ Connections. @emph{@I{MySQL & mSQL}}. @I{O'Reilly}. -@node Function and variable index, Concept index, References, Top + +@node Function and variable index @unnumbered Function and variable index @printindex vr -@node Concept index, , Function and variable index, Top + +@node Concept index @unnumbered Concept index @printindex cp diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 1e02313df31..7b08c37e0ff 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -2,7 +2,6 @@ @c %**start of header @setfilename R-exts.info @settitle Writing R Extensions -@setchapternewpage on @documentencoding UTF-8 @defcodeindex ap @defcodeindex ae @@ -87,7 +86,7 @@ This manual is for R, version @value{VERSION}. @c @end ifnothtml @ifnottex -@node Top, Acknowledgements, (dir), (dir) +@node Top @top Writing R Extensions This is a guide to extending @R{}, describing the process of creating @@ -98,24 +97,9 @@ foreign language interfaces, and the @R{} @acronym{API}. @end ifnottex -@menu -* Acknowledgements:: -* Creating R packages:: -* Writing R documentation files:: -* Tidying and profiling R code:: -* Debugging:: -* System and foreign language interfaces:: -* The R API:: -* Generic functions and methods:: -* Linking GUIs and other front-ends to R:: -* Function and variable index:: -* Concept index:: -* API index:: -* Experimental API index:: -* Embedding API index:: -@end menu -@node Acknowledgements, Creating R packages, Top, Top + +@node Acknowledgements @unnumbered Acknowledgements @@ -124,7 +108,9 @@ The contributions to early versions of this manual by @I{Saikat DebRoy} @code{.External}) and @I{Adrian Trapletti} (who provided information on the C++ interface) are gratefully acknowledged. -@node Creating R packages, Writing R documentation files, Acknowledgements, Top + + +@node Creating R packages @chapter Creating R packages @cindex Packages @cindex Creating packages @@ -258,21 +244,7 @@ packages to @acronym{CRAN}: current instructions are linked from @uref{https://CRAN.R-project.org/banner.shtml#submitting}. -@menu -* Package structure:: -* Configure and cleanup:: -* Checking and building packages:: -* Writing package vignettes:: -* Package namespaces:: -* Writing portable packages:: -* Diagnostic messages:: -* Internationalization:: -* CITATION files:: -* Package types:: -* Services:: -@end menu - -@node Package structure, Configure and cleanup, Creating R packages, Creating R packages +@node Package structure @section Package structure @cindex Package structure @@ -365,18 +337,8 @@ even if they are listed. The @R{} function @code{package.skeleton} can help to create the structure for a new package: see its help page for details. -@menu -* The DESCRIPTION file:: -* Licensing:: -* Package Dependencies:: -* The INDEX file:: -* Package subdirectories:: -* Data in packages:: -* Non-R scripts in packages:: -* Specifying URLs:: -@end menu -@node The DESCRIPTION file, Licensing, Package structure, Package structure +@node The DESCRIPTION file @subsection The @file{DESCRIPTION} file @cindex DESCRIPTION file @@ -756,9 +718,7 @@ email address from a @code{Contact} field if there is no use. Some repositories (including @acronym{CRAN} and R-forge) add their own fields. - - -@node Licensing, Package Dependencies, The DESCRIPTION file, Package structure +@node Licensing @subsection Licensing Licensing for a package which might be distributed is an important but @@ -888,7 +848,7 @@ information is @samp{COPYRIGHT HOLDER}, this must give the actual legal entities (not something vague like `Name-of-package authors'): if more than one they should be listed in decreasing order of contribution. -@node Package Dependencies, The INDEX file, Licensing, Package structure +@node Package Dependencies @subsection Package Dependencies @c DESCRIPTION field Depends @@ -1084,11 +1044,13 @@ found. It is currently used by @command{R CMD check} to check that the packages can be found, at least as source packages (which can be installed on any platform). + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Suggested packages:: @end menu -@node Suggested packages, , Package Dependencies, Package Dependencies +@node Suggested packages @subsubsection Suggested packages Note that someone wanting to run the examples/tests/vignettes may not @@ -1157,7 +1119,8 @@ to your package, for the namespaces of your suggested packages will also be loaded whenever any package which imports yours is installed and so may be captured there. -@node The INDEX file, Package subdirectories, Package Dependencies, Package structure + +@node The INDEX file @subsection The @file{INDEX} file @cindex INDEX file @@ -1176,7 +1139,7 @@ information about the package into an overview help page (@pxref{Documenting packages}) and/or a vignette (@pxref{Writing package vignettes}). -@node Package subdirectories, Data in packages, The INDEX file, Package structure +@node Package subdirectories @subsection Package subdirectories @cindex Package subdirectories @@ -1459,10 +1422,10 @@ should be included in @file{inst}. Note that if the named exceptions also occur in @file{inst}, the version in @file{inst} will be that seen in the installed package. -@findex CITATION -@cindex citation -@findex NEWS.Rd -@cindex news +@cindex CITATION file +@findex citation +@cindex NEWS.Rd file +@findex news Things you might like to add to @file{inst} are a @file{CITATION} file for use by the @code{citation} function, and a @file{NEWS.Rd} file for use by the @code{news} function. See its help page for the specific @@ -1531,8 +1494,7 @@ needed during configuration, and also for sources need to re-create scripts (e.g.@: M4 files for @command{autoconf}: some prefer to put those in a subdirectory @file{m4} of @file{tools}). - -@node Data in packages, Non-R scripts in packages, Package subdirectories, Package structure +@node Data in packages @subsection Data in packages The @file{data} subdirectory is for data files, either to be made @@ -1654,7 +1616,7 @@ the default is @code{xz} for files bigger than 1MB otherwise Lazy-loading is not supported for very large datasets (those which when serialized exceed 2GB, the limit for the format on 32-bit platforms). -@node Non-R scripts in packages, Specifying URLs, Data in packages, Package structure +@node Non-R scripts in packages @subsection Non-R scripts in packages Code which needs to be compiled (C, C++, Fortran @dots{}) @@ -1739,7 +1701,7 @@ a system installation of Tk you may need to install @samp{Tktable} as @samp{root} as on e.g.@: Fedora all the locations on @code{auto_path} are owned by @samp{root}. -@node Specifying URLs, , Non-R scripts in packages, Package structure +@node Specifying URLs @subsection Specifying URLs URLs in many places in the package documentation will be converted to @@ -1766,7 +1728,8 @@ https://cran.r-project.org/package=@var{pkgname} and not a version starting @samp{https://cran.r-project.org/web/packages/@var{pkgname}}. -@node Configure and cleanup, Checking and building packages, Package structure, Creating R packages + +@node Configure and cleanup @section Configure and cleanup Note that most of this section is specific to Unix-alikes: see the @@ -2158,24 +2121,10 @@ safe to assume this is installed on users' machines, so the extension should be shipped with the package (taking care to comply with its licence). -@menu -* Using Makevars:: -* Configure example:: -* Using modern Fortran code:: -* Using C++ code:: -* C standards:: -* Using @command{cmake}:: -@end menu -@node Using Makevars, Configure example, Configure and cleanup, Configure and cleanup +@node Using Makevars @subsection Using @file{Makevars} -@menu -* OpenMP support:: -* Using pthreads:: -* Compiling in sub-directories:: -@end menu - Sometimes writing your own @file{configure} script can be avoided by supplying a file @file{Makevars}: also one of the most common uses of a @file{configure} script is to make @file{Makevars} from @@ -2476,9 +2425,9 @@ using DLLs is unavoidable we normally arrange (@emph{via} @file{configure.win} or @file{configure.ucrt}) to ship them in the same directory as the package DLL. -@node OpenMP support, Using pthreads, Using Makevars, Using Makevars -@subsubsection @abbr{OpenMP} support +@node OpenMP support +@subsubsection @abbr{OpenMP} support @cindex @I{OpenMP} There is some support for packages which wish to use @@ -2652,7 +2601,7 @@ process or before any use of @abbr{OpenMP} (which might be by another process or @R{} itself). Also, implementation-specific variables such as @env{KMP_THREAD_LIMIT} might take precedence. -@node Using pthreads, Compiling in sub-directories, OpenMP support, Using Makevars +@node Using pthreads @subsubsection Using @I{pthreads} There is no direct support for the POSIX threads (more commonly known as @@ -2701,7 +2650,7 @@ See also the comments on thread-safety and performance under @abbr{OpenMP}: on all known @R{} platforms @abbr{OpenMP} is implemented @emph{via} @code{pthreads} and the known performance issues are in the latter. -@node Compiling in sub-directories, , Using pthreads, Using Makevars +@node Compiling in sub-directories @subsubsection Compiling in sub-directories Package authors fairly often want to organize code in sub-directories of @@ -2762,7 +2711,8 @@ We really do not recommend using @file{src/Makefile} instead of @file{src/Makevars}, and as the example above shows, it is not necessary. -@node Configure example, Using modern Fortran code, Using Makevars, Configure and cleanup + +@node Configure example @subsection Configure example It may be helpful to give an extended example of using a @@ -2893,7 +2843,7 @@ R CMD INSTALL \ or by setting the environment variables @code{ODBC_INCLUDE} and @code{ODBC_LIBS}. -@node Using modern Fortran code, Using C++ code, Configure example, Configure and cleanup +@node Using modern Fortran code @subsection Using modern Fortran code @R{} assumes that source files with extension @file{.f} are fixed-form @@ -2973,7 +2923,7 @@ define a module of the same name in multiple source files. @c As was done by frailtypack in 2018-12: gfortran accepted this, ODS @c on Solaris did not. -@node Using C++ code, C standards, Using modern Fortran code, Configure and cleanup +@node Using C++ code @subsection Using C++ code @R{} can be built without a C++ compiler although one is available (but @@ -3215,7 +3165,7 @@ there are any top-level C++ files in @file{src}, but not if these are all in subdirectories. The simplest way to force linking by the C++ compiler is to include an empty C++ file in @file{src}.. -@node C standards, Using @command{cmake}, Using C++ code, Configure and cleanup +@node C standards @subsection C standards C has had standards C89/C90, C99, C11, C17 (also known as C18), and C23 @@ -3271,7 +3221,7 @@ End users can specify a standard by something like @command{R CMD INSTALL --use-C17}. This overrides the @samp{SystemRequirements} field, but not for any @command{configure} file. -@node Using @command{cmake}, , C standards, Configure and cleanup +@node Using @command{cmake} @subsection Using @command{cmake} Packages often wish to include the sources of other software and compile @@ -3401,18 +3351,14 @@ and for the second approach to substitute @env{CMAKE} into @file{src/Makevars}. This also applies to the ancillary command @command{ctest}, if used. -@node Checking and building packages, Writing package vignettes, Configure and cleanup, Creating R packages + +@node Checking and building packages @section Checking and building packages Before using these tools, please check that your package can be installed. @code{R CMD check} will @emph{@I{inter alia}} do this, but you may get more detailed error messages doing the install directly. -@menu -* Checking packages:: -* Building package tarballs:: -* Building binary packages:: -@end menu If your package specifies an encoding in its @file{DESCRIPTION} file, you should run these tools in a locale which makes use of that encoding: @@ -3449,7 +3395,7 @@ not). @end quotation -@node Checking packages, Building package tarballs, Checking and building packages, Checking and building packages +@node Checking packages @subsection Checking packages @cindex Checking packages @@ -3747,7 +3693,7 @@ package is the one checked. If you know for sure only one copy is installed you can use @option{--install=skip}: this is used for @R{} installation's @command{make check-recommended}.) -@node Building package tarballs, Building binary packages, Checking packages, Checking and building packages +@node Building package tarballs @subsection Building package tarballs @cindex Building source packages @@ -3880,7 +3826,7 @@ created when the package is installed, including index information on the vignettes and, rarely, information on the help pages and perhaps a copy of the PDF reference manual (see above). -@node Building binary packages, , Building package tarballs, Checking and building packages +@node Building binary packages @subsection Building binary packages @cindex Building binary packages @@ -3948,16 +3894,12 @@ packages from (checked) source code: @I{WinBuilder} (see developers on other platforms who do not have access to Windows but wish to provide binaries for the Windows platform. -@node Writing package vignettes, Package namespaces, Checking and building packages, Creating R packages + +@node Writing package vignettes @section Writing package vignettes @cindex vignettes @cindex Sweave -@menu -* Encodings and vignettes:: -* Non-Sweave vignettes:: -@end menu - In addition to the help files in @file{Rd} format, @R{} packages allow the inclusion of documents in arbitrary other formats. The standard location for these is subdirectory @file{inst/doc} of a source package, @@ -4109,7 +4051,7 @@ Perl-like regular expressions on one or more lines. (See the description of the @file{.Rinstignore} file for full details.) -@node Encodings and vignettes, Non-Sweave vignettes, Writing package vignettes, Writing package vignettes +@node Encodings and vignettes @subsection Encodings and vignettes Vignettes will in general include descriptive text, @R{} input, @R{} @@ -4182,7 +4124,7 @@ current encoding, so @file{fortunes.tex} will be in UTF-8 in any locale. Had @code{read.table} been told the data were UTF-8, @file{fortunes.tex} would have been in the locale's encoding. -@node Non-Sweave vignettes, , Encodings and vignettes, Writing package vignettes +@node Non-Sweave vignettes @subsection Non-Sweave vignettes Vignettes in formats other than Sweave are supported @emph{via} @@ -4240,7 +4182,7 @@ it supports other input formats.) See the @code{?tools::vignetteEngine} help topic for details on engine registration. -@node Package namespaces, Writing portable packages, Writing package vignettes, Creating R packages +@node Package namespaces @section Package namespaces @cindex namespaces @@ -4285,17 +4227,7 @@ then the normal search path (so the base namespace precedes the normal search rather than being at the end of it). -@menu -* Specifying imports and exports:: -* Registering S3 methods:: -* Load hooks:: -* useDynLib:: -* An example:: -* Namespaces with S4 classes and methods:: -@end menu - - -@node Specifying imports and exports, Registering S3 methods, Package namespaces, Package namespaces +@node Specifying imports and exports @subsection Specifying imports and exports Exports are specified using the @code{export} directive in the @@ -4398,7 +4330,7 @@ unexported objects. This is generally not recommended, as the existence or semantics of unexported objects may be changed by the package author in routine maintenance. -@node Registering S3 methods, Load hooks, Specifying imports and exports, Package namespaces +@node Registering S3 methods @subsection Registering S3 methods The standard method for S3-style @code{UseMethod} dispatching might fail @@ -4449,7 +4381,7 @@ situations where the method is not ``immediately'' needed, and having to pre-load the namespace of @code{pkg} (and all its strong dependencies) in order to perform immediate registration is considered too onerous. -@node Load hooks, useDynLib, Registering S3 methods, Package namespaces +@node Load hooks @subsection Load hooks @findex .onLoad @@ -4498,7 +4430,7 @@ It is good practice for these functions to be quiet. Any messages should use @code{packageStartupMessage} so users (include check scripts) can suppress them if desired. -@node useDynLib, An example, Load hooks, Package namespaces +@node useDynLib @subsection @code{useDynLib} A @file{NAMESPACE} file can contain one or more @code{useDynLib} @@ -4684,8 +4616,7 @@ native symbols merely slows down the package loading (although many check that the corresponding @R{} variables are not accidentally exported by a pattern in the @file{NAMESPACE} file. - -@node An example, Namespaces with S4 classes and methods, useDynLib, Package namespaces +@node An example @subsection An example As an example consider two packages named @pkg{foo} and @pkg{bar}. The @@ -4757,7 +4688,7 @@ in @pkg{bar} the function @code{c} is defined to be equivalent to @code{sum}, but in @pkg{foo} the variable @code{c} refers to the standard function @code{c} in @pkg{base}. -@node Namespaces with S4 classes and methods, , An example, Package namespaces +@node Namespaces with S4 classes and methods @subsection Namespaces with S4 classes and methods Some additional steps are needed for packages which make use of formal @@ -4880,21 +4811,14 @@ implicit generic. But it is better practice to make use of the generics exported by @pkg{stats4} as this enables multiple packages to unambiguously set methods on those generics. -@node Writing portable packages, Diagnostic messages, Package namespaces, Creating R packages + +@node Writing portable packages @section Writing portable packages This section contains advice on writing packages to be used on multiple platforms or for distribution (for example to be submitted to a package repository such as @acronym{CRAN}). -@menu -* PDF size:: -* Check timing:: -* Encoding issues:: -* Portable C and C++ code:: -* Portable Fortran code:: -* Binary distribution:: -@end menu Portable packages should have simple file names: use only alphanumeric @acronym{ASCII} characters and period (@code{.}), and avoid those names @@ -5717,7 +5641,8 @@ and @samp{Pacific/Kiritimati}(no DST, more than 12 hours ahead of UTC). @end itemize -@node PDF size, Check timing, Writing portable packages, Writing portable packages + +@node PDF size @subsection PDF size There are a several tools available to reduce the size of PDF files: @@ -5778,7 +5703,7 @@ value @samp{qpdf}: use @samp{both} to try harder to reduce the size, provided you have Ghostscript available (see the help for @code{tools::compactPDF}). -@node Check timing, Encoding issues, PDF size, Writing portable packages +@node Check timing @subsection Check timing There are several ways to find out where time is being spent in the @@ -5805,8 +5730,7 @@ corresponding log file: note that log files for successful vignette runs are only retained if environment variable @env{_R_CHECK_ALWAYS_LOG_VIGNETTE_OUTPUT_} is set to a true value. - -@node Encoding issues, Portable C and C++ code, Check timing, Writing portable packages +@node Encoding issues @subsection Encoding issues The issues in this subsection have been much alleviated by the change in @@ -5894,14 +5818,9 @@ is equivalent to the value UTF-8 then the package code is translated to UTF-8 for syntax checking, so it is strongly recommended to check in a UTF-8 locale. -@node Portable C and C++ code, Portable Fortran code, Encoding issues, Writing portable packages +@node Portable C and C++ code @subsection Portable C and C++ code -@menu -* Common symbols:: -* C++17 issues:: -@end menu - Writing portable C and C++ code is mainly a matter of observing the standards (C99, C++14 or where declared C++11/17/20) and testing that extensions (such as POSIX functions) are supported. Do make maximal use @@ -6451,7 +6370,8 @@ Some additional information for C++ is available at @uref{https://journal.r-project.org/archive/2011-2/RJournal_2011-2_Plummer.pdf} by @I{Martyn Plummer}. -@node Common symbols, C++17 issues, Portable C and C++ code, Portable C and C++ code + +@node Common symbols @subsubsection Common symbols Most OSes (including all those commonly used for @R{}) have the concept @@ -6492,7 +6412,7 @@ versions of @command{gcc} and @command{clang}. This is not pertinent to C++ which does not permit tentative definitions. -@node C++17 issues, , Common symbols, Portable C and C++ code +@node C++17 issues @subsubsection C++17 issues @R{} 4.3.0 and later default to C++17 when compiling C++, and that @@ -6555,7 +6475,8 @@ Another build for Windows which may be sufficiently compatible with @code{Rtools} can be found at @uref{https://github.com/mstorsjo/llvm-mingw}: this uses @code{libc++}. -@node Portable Fortran code, Binary distribution, Portable C and C++ code, Writing portable packages + +@node Portable Fortran code @subsection Portable Fortran code For many years almost all known @R{} platforms used @command{gfortran} @@ -6701,7 +6622,7 @@ Specific (rather than generic) names for intrinsic functions. @code{gfortran} with option @option{-std=f2018} will warn about these: @R{} will report only in the installation log. -@node Binary distribution, , Portable Fortran code, Writing portable packages +@node Binary distribution @subsection Binary distribution If you want to distribute a binary version of a package on Windows or @@ -6757,7 +6678,7 @@ sources for the additional components (and will if your package has a GPL-like license). -@node Diagnostic messages, Internationalization, Writing portable packages, Creating R packages +@node Diagnostic messages @section Diagnostic messages Diagnostic messages can be made available for translation, so it is @@ -6856,7 +6777,8 @@ in another language one might need to say @end itemize -@node Internationalization, CITATION files, Diagnostic messages, Creating R packages + +@node Internationalization @section Internationalization There are mechanisms to translate the @R{}- and C-level error and warning @@ -6869,13 +6791,8 @@ part of @acronym{GNU} @code{gettext} and this will need to be installed: @cputype{x86_64} Windows users can find pre-compiled binaries at @uref{https://www.stats.ox.ac.uk/pub/Rtools/goodies/gettext-tools.zip}. -@menu -* C-level messages:: -* R messages:: -* Preparing translations:: -@end menu -@node C-level messages, R messages, Internationalization, Internationalization +@node C-level messages @subsection C-level messages The process of enabling translations is @@ -6933,7 +6850,7 @@ xgettext --keyword=_ -o @var{pkg}.pot *.c The file @file{src/@var{pkg}.pot} is the template file, and conventionally this is shipped as @file{po/@var{pkg}.pot}. -@node R messages, Preparing translations, C-level messages, Internationalization +@node R messages @subsection R messages Mechanisms are also available to support the automatic translation of @@ -6959,8 +6876,7 @@ safest to use @code{domain="R-@var{pkg}"} explicitly in calls to @code{ngettext}, and necessary for earlier versions of @R{} unless they are calls directly from a function in the package. - -@node Preparing translations, , R messages, Internationalization +@node Preparing translations @subsection Preparing translations Once the template files have been created, translations can be made. @@ -7014,10 +6930,10 @@ This function needs the GNU @command{gettext-tools} installed and on the path: see its help page. -@findex CITATION -@cindex citation -@node CITATION files, Package types, Internationalization, Creating R packages +@node CITATION files @section CITATION files +@findex citation +@cindex CITATION file An installed file named @file{CITATION} will be used by the @code{citation()} function. (It should be in the @file{inst} @@ -7075,7 +6991,8 @@ It is desirable (and essential for @acronym{CRAN}) that the @code{packageDescription} which assume the package is installed in a library tree on the package search path. -@node Package types, Services, CITATION files, Creating R packages + +@node Package types @section Package types The @file{DESCRIPTION} file has an optional field @code{Type} which if @@ -7083,11 +7000,13 @@ missing is assumed to be @samp{Package}, the sort of extension discussed so far in this chapter. Currently one other type is recognized; there used also to be a @samp{Translation} type. + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Frontend:: @end menu -@node Frontend, , Package types, Package types +@node Frontend @subsection @I{Frontend} This is a rather general mechanism, designed for adding new front-ends @@ -7104,7 +7023,8 @@ CMD check} will check the type and skip it. Many packages of this type need write permission for the @R{} installation directory. -@node Services, , Package types, Creating R packages + +@node Services @section Services Several members of the @R{} project have set up services to assist those @@ -7127,30 +7047,13 @@ or wikis provide @I{useRs} with convenient instruments for discussions and for exchanging information between developers and/or interested @I{useRs}. -@node Writing R documentation files, Tidying and profiling R code, Creating R packages, Top + +@node Writing R documentation files @chapter Writing R documentation files @cindex Documentation, writing -@menu -* Rd format:: -* Sectioning:: -* Marking text:: -* Lists and tables:: -* Cross-references:: -* Mathematics:: -* Figures:: -* Insertions:: -* Indices:: -* Platform-specific sections:: -* Conditional text:: -* Dynamic pages:: -* User-defined macros:: -* Encoding:: -* Processing documentation files:: -* Editing Rd files:: -@end menu -@node Rd format, Sectioning, Writing R documentation files, Writing R documentation files +@node Rd format @section Rd format @R{} objects are documented in files written in ``@R{} documentation'' @@ -7271,14 +7174,8 @@ always do, except in the `verbatim' variant. For the complete list of macros and rules for escapes, see @uref{https://developer.r-project.org/parseRd.pdf, ``Parsing Rd files''}. -@menu -* Documenting functions:: -* Documenting data sets:: -* Documenting S4 classes and methods:: -* Documenting packages:: -@end menu -@node Documenting functions, Documenting data sets, Rd format, Rd format +@node Documenting functions @subsection Documenting functions The basic markup commands used for documenting @R{} objects (in @@ -7640,8 +7537,7 @@ values: however the `Search Engine & Keywords' @HTML{} page accessed pre-defined list of keywords. @end table - -@node Documenting data sets, Documenting S4 classes and methods, Documenting functions, Rd format +@node Documenting data sets @subsection Documenting data sets The structure of @file{Rd} files which document @R{} data sets is slightly @@ -7714,7 +7610,7 @@ If @code{@var{bar}} is a data frame, documenting it as a data set can be initiated @emph{via} @code{prompt(@var{bar})}. Otherwise, the @code{promptData} function may be used. -@node Documenting S4 classes and methods, Documenting packages, Documenting data sets, Rd format +@node Documenting S4 classes and methods @subsection Documenting S4 classes and methods There are special ways to use the @samp{?} operator, namely @@ -7768,7 +7664,7 @@ See @code{help("Documentation", package = "methods")} for more information on using and creating on-line documentation for S4 classes and methods. -@node Documenting packages, , Documenting S4 classes and methods, Rd format +@node Documenting packages @subsection Documenting packages Packages may have an overview help page with an @code{\alias} @@ -7794,7 +7690,8 @@ placed into a package vignette (@pxref{Writing package vignettes}) and referenced from this page, or into individual man pages for the functions, datasets, or classes. -@node Sectioning, Marking text, Rd format, Writing R documentation files + +@node Sectioning @section Sectioning To begin a new paragraph or leave a blank line in an example, just @@ -7836,7 +7733,7 @@ examples), no matter where they appear in the input (but in the same order amongst themselves as in the input). -@node Marking text, Lists and tables, Sectioning, Writing R documentation files +@node Marking text @section Marking text @cindex Marking text in documentation @@ -7987,7 +7884,7 @@ Indicates an abbreviation. @LaTeX{}-like. @end table -@node Lists and tables, Cross-references, Marking text, Writing R documentation files +@node Lists and tables @section Lists and tables @cindex Lists and tables in documentation @@ -8051,7 +7948,8 @@ alignments in the first argument, and they must be non-empty (but can contain only spaces). (There is no whitespace between @code{\tabular} and the first argument, nor between the two arguments.) -@node Cross-references, Mathematics, Lists and tables, Writing R documentation files + +@node Cross-references @section Cross-references @cindex Cross-references in documentation @@ -8108,7 +8006,8 @@ Packages referred to by these `other forms' should be declared in the @file{DESCRIPTION} file, in the @samp{Depends}, @samp{Imports}, @samp{Suggests} or @samp{Enhances} fields. -@node Mathematics, Figures, Cross-references, Writing R documentation files + +@node Mathematics @section Mathematics @cindex Mathematics in documentation @findex \eqn @@ -8173,7 +8072,8 @@ Note that only basic @LaTeX{} can be used, there being no provision to specify @LaTeX{} style files, but @abbr{AMS} extensions are supported as from @R{} 4.2.2. -@node Figures, Insertions, Mathematics, Writing R documentation files + +@node Figures @section Figures @cindex Figures in documentation @findex \figure @@ -8215,7 +8115,8 @@ PDF format will not display in most @HTML{} browsers, but might be the best choice in reference manuals.) Specify the filename relative to @file{man/figures} in the @code{\figure} directive. -@node Insertions, Indices, Figures, Writing R documentation files + +@node Insertions @section Insertions @findex \R @@ -8262,7 +8163,8 @@ the text conversion in locales that cannot represent the encoded form). (This is intended to be used for individual words, not whole sentences or paragraphs.) -@node Indices, Platform-specific sections, Insertions, Writing R documentation files + +@node Indices @section Indices @cindex Indices @@ -8300,7 +8202,7 @@ If you want to cross reference such items from other help files @emph{via} @code{\link}, you need to use @code{\alias} and not @code{\concept}. -@node Platform-specific sections, Conditional text, Indices, Writing R documentation files +@node Platform-specific sections @section Platform-specific documentation @cindex Platform-specific documentation @@ -8337,7 +8239,8 @@ If the differences between platforms are extensive or the @R{} objects documented are only relevant to one platform, platform-specific @file{Rd} files can be put in a @file{unix} or @file{windows} subdirectory. -@node Conditional text, Dynamic pages, Platform-specific sections, Writing R documentation files + +@node Conditional text @section Conditional text @cindex conditionals @findex \if @@ -8371,7 +8274,8 @@ the following to output the markup necessary to display the Greek letter in \ifelse@{latex@}@{\out@{$\alpha$@}@}@{\ifelse@{html@}@{\out@{α@}@}@{alpha@}@} @end example -@node Dynamic pages, User-defined macros, Conditional text, Writing R documentation files + +@node Dynamic pages @section Dynamic pages @cindex dynamic pages @findex \Sexpr @@ -8472,7 +8376,8 @@ to following uses of @code{\Sexpr}. For more details, see the online document @uref{https://developer.r-project.org/parseRd.pdf, ``Parsing Rd files''}. -@node User-defined macros, Encoding, Dynamic pages, Writing R documentation files + +@node User-defined macros @section User-defined macros @cindex user-defined macros @findex \newcommand @@ -8556,8 +8461,7 @@ the other package in the @samp{RdMacros} field in the @file{DESCRIPTION} file. - -@node Encoding, Processing documentation files, User-defined macros, Writing R documentation files +@node Encoding @section Encoding @cindex encoding @@ -8622,8 +8526,7 @@ Note that this mechanism works best with Latin letters: the coverage of UTF-8 in @LaTeX{} is quite low. - -@node Processing documentation files, Editing Rd files, Encoding, Writing R documentation files +@node Processing documentation files @section Processing documentation files @cindex Processing Rd format @@ -8660,7 +8563,8 @@ the tools to build packages from source as described in the ``R Installation and Administration'' manual, although typically all that is needed is a @LaTeX{} installation. -@node Editing Rd files, , Processing documentation files, Writing R documentation files + +@node Editing Rd files @section Editing Rd files @cindex Editing Rd files @@ -8685,22 +8589,19 @@ rather similar to @LaTeX{} files. Some @R{} front-ends provide editing support for @file{.Rd} files, for example @I{RStudio} (@uref{https://posit.co/}). -@node Tidying and profiling R code, Debugging, Writing R documentation files, Top + + +@node Tidying and profiling R code @chapter Tidying and profiling R code -@menu -* Tidying R code:: -* Profiling R code for speed:: -* Profiling R code for memory use:: -* Profiling compiled code:: -@end menu @R{} code which is worth preserving in a package and perhaps making available for others to use is worth documenting, tidying up and perhaps optimizing. The last two of these activities are the subject of this chapter. -@node Tidying R code, Profiling R code for speed, Tidying and profiling R code, Tidying and profiling R code + +@node Tidying R code @section Tidying R code @cindex Tidying R code @@ -8766,8 +8667,7 @@ for style options within the @I{ESS[S]} mode recommended for the source code of @R{} itself. - -@node Profiling R code for speed, Profiling R code for memory use, Tidying R code, Tidying and profiling R code +@node Profiling R code for speed @section Profiling R code for speed @cindex Profiling @findex Rprof @@ -8882,7 +8782,8 @@ More detailed analysis of the output can be achieved by the tools in the @acronym{CRAN} packages @CRANpkg{proftools} and @CRANpkg{profr}: in particular these allow call graphs to be studied. -@node Profiling R code for memory use, Profiling compiled code, Profiling R code for speed, Tidying and profiling R code + +@node Profiling R code for memory use @section Profiling R code for memory use @cindex Profiling @cindex Memory use @@ -8939,13 +8840,8 @@ The main reason that memory-use profiling is difficult is garbage collection. Memory is allocated at well-defined times in an @R{} program, but is freed whenever the garbage collector happens to run. -@menu -* Memory statistics from Rprof:: -* Tracking memory allocations:: -* Tracing copies of an object:: -@end menu -@node Memory statistics from Rprof, Tracking memory allocations, Profiling R code for memory use, Profiling R code for memory use +@node Memory statistics from Rprof @subsection Memory statistics from @code{Rprof} @findex Rprof @findex summaryRprof @@ -8964,7 +8860,7 @@ little memory. Running under @code{gctorture} helps with both problems: it slows down the code to effectively increase the sampling frequency and it makes each garbage collection release a smaller amount of memory. -@node Tracking memory allocations, Tracing copies of an object, Memory statistics from Rprof, Profiling R code for memory use +@node Tracking memory allocations @subsection Tracking memory allocations @findex Rprofmem @@ -8987,7 +8883,7 @@ Running the example from the previous section with shows that apart from some initial and final work in @code{boot} there are no vector allocations over 1000 bytes. -@node Tracing copies of an object, , Tracking memory allocations, Profiling R code for memory use +@node Tracing copies of an object @subsection Tracing copies of an object @findex tracemem @findex untracemem @@ -9038,7 +8934,8 @@ Data frames are slower than matrices and this is an example of why. Using @code{tracemem(st$Viscosity)} does not reveal any additional copying. -@node Profiling compiled code, , Profiling R code for memory use, Tidying and profiling R code + +@node Profiling compiled code @section Profiling compiled code @cindex Profiling @@ -9050,13 +8947,8 @@ libraries/objects as used by @R{} packages. This chapter is based on reports from users and the information may not be current. -@menu -* Profilong on Linux:: -* Profiling on macOS:: -* Profiling on Windows:: -@end menu -@node Profilong on Linux, Profiling on macOS, Profiling compiled code, Profiling compiled code +@node Profilong on Linux @subsection Profiling on Linux Options include using @command{sprof} for a shared object, and @@ -9218,14 +9110,14 @@ rm /var/tmp/path/to/R_HOME/library/stats/libs/stats.so.profile It is possible that root access will be needed to create the directories used for the profile data. -@node Profiling on macOS, Profiling on Windows, Profilong on Linux, Profiling compiled code +@node Profiling on macOS @subsection Profiling on macOS Developers have recommended @command{Instruments} (part of @code{Xcode}, see @uref{https://help.apple.com/instruments/mac/current/}), This had a command-line version prior to macOS 12. -@node Profiling on Windows, , Profiling on macOS, Profiling compiled code +@node Profiling on Windows @subsection Profiling on Windows @command{Very Sleepy} @@ -9236,23 +9128,17 @@ included function names were obtained by attaching the profiler to an existing @command{Rterm} process, either via GUI or using @option{/a:} (@abbr{PID} obtained via @command{Sys.getpid()}). -@node Debugging, System and foreign language interfaces, Tidying and profiling R code, Top + + +@node Debugging @chapter Debugging This chapter covers the debugging of @R{} extensions, starting with the ways to get useful error information and moving on to how to deal with errors that crash @R{}. -@menu -* Browsing:: -* Debugging R code:: -* Checking memory access:: -* Debugging compiled code:: -* Using Link-time Optimization:: -@end menu - -@node Browsing, Debugging R code, Debugging, Debugging +@node Browsing @section Browsing @findex browser @@ -9331,7 +9217,8 @@ really necessary, objects can be assigned to the workspace from the browser prompt (by using @code{<<-} if the name is not already in scope). -@node Debugging R code, Checking memory access, Browsing, Debugging + +@node Debugging R code @section Debugging R code @findex traceback @@ -9648,7 +9535,7 @@ temporary code, but @code{trace} can help with functions in a namespace @code{trace(,edit=TRUE)} to insert code visually. -@node Checking memory access, Debugging compiled code, Debugging R code, Debugging +@node Checking memory access @section Checking memory access Errors in memory allocation and reading/writing outside arrays are very @@ -9669,18 +9556,8 @@ and memory allocated by @code{malloc}, @code{calloc} and @code{realloc} by @code{free}. Some platforms will tolerate mismatches (perhaps with memory leaks) but others will segfault. -@menu -* Using gctorture:: -* Using valgrind:: -* Using Address Sanitizer:: -* Using Undefined Behaviour Sanitizer:: -* Other analyses with `clang':: -* Other analyses with `gcc':: -* Using `Dr. Memory':: -* Fortran array bounds checking:: -@end menu -@node Using gctorture, Using valgrind, Checking memory access, Checking memory access +@node Using gctorture @subsection Using @code{gctorture} @findex gctorture @@ -9748,8 +9625,7 @@ to be used as @code{@var{n}}. Used with a debugger and with @code{gctorture} or @code{gctorture2} this mechanism can be helpful in isolating memory protect problems. - -@node Using valgrind, Using Address Sanitizer, Using gctorture, Checking memory access +@node Using valgrind @subsection Using @I{Valgrind} If you have access to Linux on a common CPU type or supported versions @@ -9872,7 +9748,7 @@ This section has described the use of @command{memtest}, the default described in its documentation: @command{helgrind} can be useful for threaded programs. -@node Using Address Sanitizer, Using Undefined Behaviour Sanitizer, Using valgrind, Checking memory access +@node Using Address Sanitizer @subsection Using the Address Sanitizer @c https://github.com/google/sanitizers/wiki/AddressSanitizer @@ -9999,11 +9875,13 @@ problems in the system software and not the package nor @R{}. A couple of reports have been of `heap-use-after-free' errors in the X11 libraries called from Tcl/Tk. + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Using Leak Sanitizer:: @end menu -@node Using Leak Sanitizer, , Using Address Sanitizer, Using Address Sanitizer +@node Using Leak Sanitizer @subsubsection Using the Leak Sanitizer For @code{x86_64} Linux there is a leak sanitizer, `@abbr{LSan}': see @@ -10037,7 +9915,8 @@ setenv ASAN_OPTIONS 'alloc_dealloc_mismatch=0:detect_leaks=0:detect_odr_violatio @abbr{LSan} also has a `stand-alone' mode where it is compiled in using @option{-fsanitize=leak} and avoids the run-time overhead of @abbr{ASan}. -@node Using Undefined Behaviour Sanitizer, Other analyses with `clang', Using Address Sanitizer, Checking memory access + +@node Using Undefined Behaviour Sanitizer @subsection Using the Undefined Behaviour Sanitizer `Undefined behaviour' is where the language standard does not require @@ -10198,7 +10077,7 @@ provided @code{UBSAN_DIR} is added to the runtime library path (as shown or using @env{LD_LIBRARY_PATH}). @strong{N.B.}: The details, especially the paths used, have changed several times recently. -@node Other analyses with `clang', Other analyses with `gcc', Using Undefined Behaviour Sanitizer, Checking memory access +@node Other analyses with `clang' @subsection Other analyses with `clang' Recent versions of @command{clang} on @cputype{x86_64} Linux have @@ -10212,7 +10091,7 @@ provide similar functionality to tools in @command{valgrind}. @command{clang} has a `Static Analyzer' which can be run on the source files during compilation: see @uref{https://clang-analyzer.llvm.org/}. -@node Other analyses with `gcc', Using `Dr. Memory', Other analyses with `clang', Checking memory access +@node Other analyses with `gcc' @subsection Other analyses with `@I{gcc}' GCC 10 introduced a new flag @option{-fanalyzer} which does static @@ -10228,7 +10107,7 @@ See (or the documentation for your version of @command{gcc} if later) and @uref{https://developers.redhat.com/blog/2020/03/26/static-analysis-in-gcc-10} -@node Using `Dr. Memory', Fortran array bounds checking, Other analyses with `gcc', Checking memory access +@node Using `Dr. Memory' @subsection Using `Dr. Memory' `Dr. Memory' from @uref{https://drmemory.org/} is a memory checker for @@ -10237,7 +10116,7 @@ See works better if inlining and frame pointer optimizations are disabled.} and detects memory access errors, uninitialized reads and memory leaks. -@node Fortran array bounds checking, , Using `Dr. Memory', Checking memory access +@node Fortran array bounds checking @subsection Fortran array bounds checking Most of the Fortran compilers used with @R{} allow code to be compiled @@ -10268,7 +10147,7 @@ passed, particularly when Fortran subroutines are called from C code and character lengths are not passed (@pxref{Fortran character strings}). -@node Debugging compiled code, Using Link-time Optimization, Checking memory access, Debugging +@node Debugging compiled code @section Debugging compiled code @cindex Debugging @@ -10396,13 +10275,8 @@ so its state can be examined: use @code{continue} to resume execution. Some ``tricks'' worth knowing follow: -@menu -* Finding entry points:: -* Inspecting R objects:: -* Debugging on macOS:: -@end menu -@node Finding entry points, Inspecting R objects, Debugging compiled code, Debugging compiled code +@node Finding entry points @subsection Finding entry points in dynamically loaded code Under most compilation environments, compiled code dynamically loaded @@ -10430,8 +10304,7 @@ Continue execution of @R{} by typing @kbd{signal 0@key{RET}}. Under Windows signals may not be able to be used, and if so the procedure is more complicated. See the @I{rw-FAQ}. - -@node Inspecting R objects, Debugging on macOS, Finding entry points, Debugging compiled code +@node Inspecting R objects @subsection Inspecting R objects when debugging @cindex Inspecting R objects when debugging @@ -10570,7 +10443,7 @@ parameters: maximum depth and the maximal number of elements that will be printed for scalar vectors. The defaults in @code{R_inspect} are currently -1 (no limit) and 5 respectively. -@node Debugging on macOS, , Inspecting R objects, Debugging compiled code +@node Debugging on macOS @subsection Debugging on macOS To debug code in a package it is easiest to unpack it in a directory and @@ -10639,7 +10512,7 @@ and then return to the @R{} console. For non-interactive use, one may need @command{lldb --batch}. -@node Using Link-time Optimization, , Debugging compiled code, Debugging +@node Using Link-time Optimization @section Using Link-time Optimization Where supported, @emph{link time optimization} provides a comprehensive @@ -10759,29 +10632,12 @@ LTO = -flto @end example -@node System and foreign language interfaces, The R API, Debugging, Top + +@node System and foreign language interfaces @chapter System and foreign language interfaces -@menu -* Operating system access:: -* Interface functions .C and .Fortran:: -* dyn.load and dyn.unload:: -* Registering native routines:: -* Creating shared objects:: -* Interfacing C++ code:: -* Fortran I/O:: -* Linking to other packages:: -* Handling R objects in C:: -* Interface functions .Call and .External:: -* Evaluating R expressions from C:: -* Parsing R code from C:: -* External pointers and weak references:: -* Vector accessor functions:: -* Character encoding issues:: -* Writing compact-representation-friendly code:: -@end menu -@node Operating system access, Interface functions .C and .Fortran, System and foreign language interfaces, System and foreign language interfaces +@node Operating system access @section Operating system access @cindex Operating system access @@ -10805,7 +10661,8 @@ The function @code{system.time} is available for timing. Timing on child processes is only available on Unix-alikes, and may not be reliable there. -@node Interface functions .C and .Fortran, dyn.load and dyn.unload, Operating system access, System and foreign language interfaces + +@node Interface functions .C and .Fortran @section Interface functions @code{.C} and @code{.Fortran} @cindex Interfaces to compiled code @@ -10988,7 +10845,8 @@ Fortran support the Fortran 2003 module @code{iso_c_binding}, a better way to interface modern Fortran code to @R{} is to use @code{.C} and write a C interface using @code{use iso_c_binding}. -@node dyn.load and dyn.unload, Registering native routines, Interface functions .C and .Fortran, System and foreign language interfaces + +@node dyn.load and dyn.unload @section @code{dyn.load} and @code{dyn.unload} @cindex Dynamic loading @@ -11121,15 +10979,10 @@ argument to @code{dyn.load}. This is (by default) used by Intel) in the DLL search path. -@node Registering native routines, Creating shared objects, dyn.load and dyn.unload, System and foreign language interfaces +@node Registering native routines @section Registering native routines @cindex Registering native routines -@menu -* Speed considerations:: -* Converting a package to use registration:: -* Linking to native routines in other packages:: -@end menu By `native' routine, we mean an entry point in compiled code. @@ -11374,7 +11227,7 @@ package, for example for debugging, they can use @code{.Call(mypkg:::C_reg)}.) -@node Speed considerations, Converting a package to use registration, Registering native routines, Registering native routines +@node Speed considerations @subsection Speed considerations Sometimes registering native routines or using a @code{PACKAGE} argument @@ -11458,7 +11311,7 @@ still took about 0.80 us. Using registration in a package reduced this to 0.55 us and @code{foo3()} took 0.40 us, times which were unchanged when further packages were loaded. -@node Converting a package to use registration, Linking to native routines in other packages, Speed considerations, Registering native routines +@node Converting a package to use registration @subsection Example: converting a package to use registration The @pkg{splines} package was converted to use symbol registration in @@ -11742,7 +11595,7 @@ R_init_splines(DllInfo *dll) @end itemize -@node Linking to native routines in other packages, , Converting a package to use registration, Registering native routines +@node Linking to native routines in other packages @subsection Linking to native routines in other packages In addition to registering C routines to be called by @R{}, it can at @@ -11822,7 +11675,8 @@ DL_FUNC R_FindSymbol(char const *name, char const *pkg, @end example @apifun R_FindSymbol -@node Creating shared objects, Interfacing C++ code, Registering native routines, System and foreign language interfaces + +@node Creating shared objects @section Creating shared objects @cindex Creating shared objects @findex R CMD SHLIB @@ -11941,7 +11795,8 @@ packages no longer work. In particular, undocumented environment or @command{make} variables are not for use by package writers and are subject to change without notice. -@node Interfacing C++ code, Fortran I/O, Creating shared objects, System and foreign language interfaces + +@node Interfacing C++ code @section Interfacing C++ code @cindex Interfacing C++ code @cindex C++ code, interfacing @@ -12103,7 +11958,7 @@ build or packaged separately and so users installing from package sources are less likely to already have them installed. -@node Fortran I/O, Linking to other packages, Interfacing C++ code, System and foreign language interfaces +@node Fortran I/O @section Fortran I/O We have already warned against the use of C++ @I{iostreams} not least @@ -12141,7 +11996,7 @@ void R_init_mypkgname(DllInfo *dll) in the file used for native symbol registration.) -@node Linking to other packages, Handling R objects in C, Fortran I/O, System and foreign language interfaces +@node Linking to other packages @section Linking to other packages It is not in general possible to link a DLL in package @pkg{packA} to a @@ -12158,12 +12013,8 @@ backwards-compatible. Shipping a static library in package @pkg{packB} for other packages to link to avoids most of the difficulties. -@menu -* Unix-alikes:: -* Windows:: -@end menu -@node Unix-alikes, Windows, Linking to other packages, Linking to other packages +@node Unix-alikes @subsection Unix-alikes It is possible to link a shared object in package @pkg{packA} to a @@ -12236,8 +12087,7 @@ Making headers provided by package @pkg{packB} available to the code to be compiled in package @pkg{packA} can be done by the @code{LinkingTo} mechanism (@pxref{Registering native routines}). - -@node Windows, , Unix-alikes, Linking to other packages +@node Windows @subsection Windows Suppose package @pkg{packA} wants to make use of compiled code provided @@ -12315,7 +12165,8 @@ variable @env{PATH}. @end itemize -@node Handling R objects in C, Interface functions .Call and .External, Linking to other packages, System and foreign language interfaces + +@node Handling R objects in C @section Handling R objects in C @cindex Handling R objects in C @@ -12428,22 +12279,8 @@ numerical calculations, only when it is needed. As in interpreted @R{} code, much use is made of coercion to force the variant object to the right type. -@menu -* Garbage Collection:: -* Allocating storage:: -* Details of R types:: -* Attributes:: -* Classes:: -* S4 objects:: -* Handling lists:: -* Handling character data:: -* Working with closures:: -* Finding and setting variables:: -* Some convenience functions:: -* Named objects and copying:: -@end menu -@node Garbage Collection, Allocating storage, Handling R objects in C, Handling R objects in C +@node Garbage Collection @subsection Handling the effects of garbage collection @cindex Garbage collection @@ -12615,7 +12452,7 @@ subject to change, so relying on that may be fragile. @code{PROTECT} and @code{PROTECT_WITH_INDEX} can be safely called with unprotected arguments and @code{UNPROTECT} does not allocate. -@node Allocating storage, Details of R types, Garbage Collection, Handling R objects in C +@node Allocating storage @subsection Allocating storage @cindex Allocating storage @@ -12661,7 +12498,7 @@ the programmer may assume that they will raise an error and not return if the memory cannot be allocated. @apifun R_alloc -@node Details of R types, Attributes, Allocating storage, Handling R objects in C +@node Details of R types @subsection Details of R types @cindex Details of R types @@ -12749,7 +12586,7 @@ These can suffice to take us a long way in interfacing @R{} objects to numerical algorithms, but we may need to know a little more to create useful return objects. -@node Attributes, Classes, Details of R types, Handling R objects in C +@node Attributes @subsection Attributes @cindex Attributes @@ -12918,7 +12755,7 @@ encoding but have been identical since @R{} 4.0.0. @apifun Rf_installChar @apifun Rf_installTrChar -@node Classes, S4 objects, Attributes, Handling R objects in C +@node Classes @subsection Classes @cindex Classes @@ -12949,7 +12786,7 @@ As the value is a character vector, we have to know how to create that from a C character array, which we do using the function @code{mkChar}. -@node S4 objects, Handling lists, Classes, Handling R objects in C +@node S4 objects @subsection S4 objects @cindex S4 objects @@ -12978,7 +12815,7 @@ int R_has_slot(SEXP obj, SEXP name); @eapifun R_getClassDef @eapifun R_has_slot -@node Handling lists, Handling character data, S4 objects, Handling R objects in C +@node Handling lists @subsection Handling lists @cindex Handling lists @@ -13045,7 +12882,7 @@ and enables us to say This code only works for names that are ASCII (@pxref{Character encoding issues}). -@node Handling character data, Working with closures, Handling lists, Handling R objects in C +@node Handling character data @subsection Handling character data @cindex handling character data @@ -13083,7 +12920,7 @@ Note that @R{} character strings are restricted to @code{2^31 - 1} bytes, and hence so should the input to @code{mkChar} be (C allows longer strings on 64-bit platforms). -@node Working with closures, Finding and setting variables, Handling character data, Handling R objects in C +@node Working with closures @subsection Working with closures @cindex Working with closures @@ -13104,7 +12941,7 @@ can be obtained with @code{R_BytecodeExpr}. @apifun R_ClosureExpr @apifun R_BytecodeExpr -@node Finding and setting variables, Some convenience functions, Working with closures, Handling R objects in C +@node Finding and setting variables @subsection Finding and setting variables @cindex Finding variables @cindex Setting variables @@ -13184,7 +13021,7 @@ SEXP R_NewEnv(SEXP enclos, int hash, int size) @end example @apifun R_NewEnv -@node Some convenience functions, Named objects and copying, Finding and setting variables, Handling R objects in C +@node Some convenience functions @subsection Some convenience functions Some operations are done so frequently that there are convenience @@ -13360,11 +13197,14 @@ is invalid. @comment Want to encourage use of some of the more stable and useful R_* @comment and Rf_* functions: + + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Semi-internal convenience functions:: @end menu -@node Semi-internal convenience functions, , Some convenience functions, Some convenience functions +@node Semi-internal convenience functions @subsubsection Semi-internal convenience functions There is quite a collection of functions that may be used in your C code @@ -13446,7 +13286,9 @@ The C functions @code{R_forceAndCall} and @code{isUnsorted} correspond to the @R{} functions @code{forceAndCall} and @code{is.unsorted}. @eapifun R_forceAndCall @eapifun isUnsorted -@node Named objects and copying, , Some convenience functions, Handling R objects in C + + +@node Named objects and copying @subsection Named objects and copying @cindex Copying objects @@ -13550,7 +13392,8 @@ support future changes, package code should use @code{NO_REFERENCES}, @apifun MAYBE_SHARED @apifun MARK_NOT_MUTABLE -@node Interface functions .Call and .External, Evaluating R expressions from C, Handling R objects in C, System and foreign language interfaces + +@node Interface functions .Call and .External @section Interface functions @code{.Call} and @code{.External} @cindex Interfaces to compiled code @@ -13561,13 +13404,8 @@ based on the interface of the same name in @Sl{} version 4, and @code{.External} is based on @R{}'s @code{.Internal}. @code{.External} is more complex but allows a variable number of arguments. -@menu -* Calling .Call:: -* Calling .External:: -* Missing and special values:: -@end menu -@node Calling .Call, Calling .External, Interface functions .Call and .External, Interface functions .Call and .External +@node Calling .Call @subsection Calling @code{.Call} @findex .Call @@ -13608,7 +13446,7 @@ SEXP convolve2(SEXP a, SEXP b) @end group @end example -@node Calling .External, Missing and special values, Calling .Call, Interface functions .Call and .External +@node Calling .External @subsection Calling @code{.External} @findex .External @@ -13775,7 +13613,7 @@ These components can be modified with @code{SETCAR}, @code{SETCDR}, @apifun SETCADDDR @apifun SETCAD4R -@node Missing and special values, , Calling .External, Interface functions .Call and .External +@node Missing and special values @subsection Missing and special values @cindex Missing values @cindex IEEE special values @@ -13824,7 +13662,8 @@ character strings can be tested by equality to the constants The constants @code{R_NaN}, @code{R_PosInf} and @code{R_NegInf} can be used to set @code{double}s to the special values. -@node Evaluating R expressions from C, Parsing R code from C, Interface functions .Call and .External, System and foreign language interfaces + +@node Evaluating R expressions from C @section Evaluating R expressions from C @cindex Evaluating R expressions from C @@ -13961,12 +13800,8 @@ the C code may need to obtain the current evaluation environment which can be done via @code{R_GetCurrentEnv()} function. @findex R_GetCurrentEnv -@menu -* Zero-finding:: -* Calculating numerical derivatives:: -@end menu -@node Zero-finding, Calculating numerical derivatives, Evaluating R expressions from C, Evaluating R expressions from C +@node Zero-finding @subsection Zero-finding @cindex Zero-finding @@ -14049,7 +13884,7 @@ SEXP zero(SEXP f, SEXP guesses, SEXP stol, SEXP rho) @end group @end example -@node Calculating numerical derivatives, , Zero-finding, Evaluating R expressions from C +@node Calculating numerical derivatives @subsection Calculating numerical derivatives @cindex Numerical derivatives @@ -14277,7 +14112,8 @@ having the symbol @code{R_DimNamesSymbol}. Finally we set the gradient matrix as the gradient attribute of @code{ans}, unprotect the remaining protected locations and return the answer @code{ans}. -@node Parsing R code from C, External pointers and weak references, Evaluating R expressions from C, System and foreign language interfaces + +@node Parsing R code from C @section Parsing R code from C @cindex Parsing R code from C @@ -14360,11 +14196,13 @@ An example from @file{src/main/objects.c}: call = R_ParseString("base::nameOfClass(X)"); @end example + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Accessing source references:: @end menu -@node Accessing source references, , Parsing R code from C, Parsing R code from C +@node Accessing source references @subsection Accessing source references The source references added by the parser are recorded by @R{}'s evaluator @@ -14394,7 +14232,8 @@ This function extracts the filename from the source reference for display, returning a length 1 character vector containing the filename. If no name is found, @code{""} is returned. -@node External pointers and weak references, Vector accessor functions, Parsing R code from C, System and foreign language interfaces + +@node External pointers and weak references @section External pointers and weak references The @code{SEXPTYPE}s @code{EXTPTRSXP} and @code{WEAKREFSXP} can be @@ -14545,11 +14384,12 @@ done more directly. At the time of writing no @acronym{CRAN} or Bioconductor package uses weak references. +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * An external pointer example:: @end menu -@node An external pointer example, , External pointers and weak references, External pointers and weak references +@node An external pointer example @subsection An example Package @CRANpkg{RODBC} uses external pointers to maintain its @@ -14601,7 +14441,8 @@ possibility of attempting to close an already-closed channel. in that case purely to be able to use a finalizer to close and destroy the connection if it is no longer is use. -@node Vector accessor functions, Character encoding issues, External pointers and weak references, System and foreign language interfaces + +@node Vector accessor functions @section Vector accessor functions The vector accessors like @code{REAL}, @code{INTEGER}, @code{LOGICAL}, @@ -14657,7 +14498,7 @@ have to fully materialize the object. @apifun SET_REAL_ELT -@node Character encoding issues, Writing compact-representation-friendly code, Vector accessor functions, System and foreign language interfaces +@node Character encoding issues @section Character encoding issues @apifun translateChar @@ -14775,7 +14616,8 @@ SEXP mkCharLenCE(const char *, int, cetype_t); @noindent to create marked character strings of a given length. -@node Writing compact-representation-friendly code, , Character encoding issues, System and foreign language interfaces + +@node Writing compact-representation-friendly code @section Writing compact-representation-friendly code A simple way to iterate in C over the elements of an atomic vector is to @@ -14866,32 +14708,10 @@ These functions return one of @code{SORTED_DECR}, @code{SORTED_INCR}, or @eapifun REAL_IS_SORTED @eapifun STRING_IS_SORTED -@node The R API, Generic functions and methods, System and foreign language interfaces, Top -@chapter The R @acronym{API}: entry points for C code -@menu -* Memory allocation:: -* Error signaling:: -* Random numbers:: -* Missing and IEEE values:: -* Printing:: -* Calling C from Fortran and vice versa:: -* Numerical analysis subroutines:: -* Optimization:: -* Integration:: -* Utility functions:: -* Re-encoding:: -* Condition handling and cleanup code:: -* Allowing interrupts:: -* C stack checking:: -* Custom serialization input and output:: -* Platform and version information:: -* Inlining C functions:: -* Controlling visibility:: -* Standalone Mathlib:: -* Organization of header files:: -* Moving into C API compliance:: -@end menu + +@node The R API +@chapter The R @acronym{API}: entry points for C code There are a large number of entry points in the @R{} executable/DLL that can be called from C code (and some that can be called from Fortran @@ -14999,15 +14819,11 @@ identify headers in the API. This could be used for programmatic extraction, but the specific format is work in progress and even the way this document is produced is subject to change. -@node Memory allocation, Error signaling, The R API, The R API + +@node Memory allocation @section Memory allocation @cindex Memory allocation from C -@menu -* Transient storage allocation:: -* User-controlled memory:: -@end menu - There are two types of memory allocation available to the C programmer, one in which @R{} manages the clean-up and the other in which users have full control (and responsibility). @@ -15015,7 +14831,8 @@ have full control (and responsibility). These functions are declared in header @file{R_ext/RS.h} which is included by @file{R.h}. -@node Transient storage allocation, User-controlled memory, Memory allocation, Memory allocation + +@node Transient storage allocation @subsection Transient storage allocation @apifun R_alloc @apifun R_allocLD @@ -15100,7 +14917,7 @@ double} pointers on some platforms. These functions should only be used in code called by @code{.C} etc, never from front-ends. They are not thread-safe. -@node User-controlled memory, , Transient storage allocation, Memory allocation +@node User-controlled memory @subsection User-controlled memory The other form of memory allocation is an interface to @code{malloc}, @@ -15173,7 +14990,8 @@ for the @code{nul} terminator. @code{Memcpy} and @code{Memzero} take @code{n} items from array @code{p} and copy them to array @code{q} or zero them respectively. -@node Error signaling, Random numbers, Memory allocation, The R API + +@node Error signaling @section Error signaling @cindex Error signaling from C @@ -15204,11 +15022,13 @@ or might otherwise be interpreted as a format.) These are defined in header @file{R_ext/Error.h} included by @file{R.h}. + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Error signaling from Fortran:: @end menu -@node Error signaling from Fortran, , Error signaling, Error signaling +@node Error signaling from Fortran @subsection Error signaling from Fortran @cindex Error signaling from Fortran @@ -15228,7 +15048,7 @@ subroutine rwarn(@var{message}) Messages of more than 255 characters are truncated, with a warning. -@node Random numbers, Missing and IEEE values, Error signaling, The R API +@node Random numbers @section Random number generation @cindex Random numbers in C @apifun unif_rand @@ -15282,11 +15102,13 @@ including the header file @file{Rmath.h}; @xref{Distribution functions}. Those calls should also be preceded and followed by calls to @code{GetRNGstate} and @code{PutRNGstate}. + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Random-number generation from Fortran:: @end menu -@node Random-number generation from Fortran, , Random numbers, Random numbers +@node Random-number generation from Fortran @subsection Random-number generation from Fortran It was explained earlier that Fortran random-number generators should @@ -15347,7 +15169,7 @@ by something like (fixed-form Fortran 90 code): @end example -@node Missing and IEEE values, Printing, Random numbers, The R API +@node Missing and IEEE values @section Missing and @acronym{IEEE} special values @cindex Missing values @cindex IEEE special values @@ -15393,7 +15215,8 @@ which can used to set or test for missingness. These are defined in header @file{R_ext/Arith.h} included by @file{R.h}. -@node Printing, Calling C from Fortran and vice versa, Missing and IEEE values, The R API + +@node Printing @section Printing @cindex Printing from C @apifun Rprintf @@ -15423,11 +15246,13 @@ Another circumstance when it may be important to use these functions is when using parallel computation on a cluster of computational nodes, as their output will be re-directed/logged appropriately. + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Printing from Fortran:: @end menu -@node Printing from Fortran, , Printing, Printing +@node Printing from Fortran @subsection Printing from Fortran @cindex Printing from Fortran @@ -15482,7 +15307,8 @@ zero. @strong{NB:} There is no check on the type of @var{data} or @code{intpr} works with zero @var{ndata} so can be used to print a label in earlier versions of @R{}. -@node Calling C from Fortran and vice versa, Numerical analysis subroutines, Printing, The R API + +@node Calling C from Fortran and vice versa @section Calling C from Fortran and vice versa @cindex Calling C from Fortran and vice versa @@ -15566,13 +15392,8 @@ vsom.f90:20:33: note: 'vsom' was previously declared here shows that a subroutine has been registered with 9 arguments (as that is what the @code{.Fortran} call used) but only has 8. -@menu -* Fortran character strings:: -* Fortran LOGICAL:: -* Passing functions:: -@end menu -@node Fortran character strings, Fortran LOGICAL, Calling C from Fortran and vice versa, Calling C from Fortran and vice versa +@node Fortran character strings @subsection Fortran character strings Passing character strings from C to Fortran or @emph{vice versa} is @@ -15745,7 +15566,7 @@ It is strongly recommended that packages which call from C/C++ BLAS/LAPACK routines with character arguments adopt this approach: packages not using will fail to install as from @R{} 4.3.0. -@node Fortran LOGICAL, Passing functions, Fortran character strings, Calling C from Fortran and vice versa +@node Fortran LOGICAL @subsection Fortran LOGICAL Passing Fortran LOGICAL variables to/from C/C++ is potentially @@ -15758,7 +15579,7 @@ However, recent versions of @command{gfortran} @emph{via} the option 2003 to map LOGICAL variables to the C99 type @code{_Bool}, but it is usually simpler to pass integers. -@node Passing functions, , Fortran LOGICAL, Calling C from Fortran and vice versa +@node Passing functions @subsection Passing functions A number of packages call C functions passed as arguments to Fortran @@ -15790,7 +15611,8 @@ agreeing on calling conventions: this have been seen to fail. The most portable solution seems to be to convert the Fortran code to C, perhaps using @command{f2c}. -@node Numerical analysis subroutines, Optimization, Calling C from Fortran and vice versa, The R API + +@node Numerical analysis subroutines @section Numerical analysis subroutines @cindex Numerical analysis subroutines from C @@ -15816,14 +15638,8 @@ C interfaces to the code behind @R{} functions, so the @R{} function documentation may give further details. @apihdr Rmath.h -@menu -* Distribution functions:: -* Mathematical functions:: -* Numerical Utilities:: -* Mathematical constants:: -@end menu -@node Distribution functions, Mathematical functions, Numerical analysis subroutines, Numerical analysis subroutines +@node Distribution functions @subsection Distribution functions @cindex Distribution functions from C @@ -15985,8 +15801,7 @@ Note that @code{dbinom_raw()} returns both @eqn{p, p} and @eqn{q = 1-p, q = 1-p} which may be advantageous when one of them is close to @eqn{1, 1}. - -@node Mathematical functions, Numerical Utilities, Distribution functions, Numerical analysis subroutines +@node Mathematical functions @subsection Mathematical functions @cindex Gamma function @@ -16056,8 +15871,7 @@ Bessel functions of types I, J, K and Y with index @var{nu}. For values.) @end deftypefun - -@node Numerical Utilities, Mathematical constants, Mathematical functions, Numerical analysis subroutines +@node Numerical Utilities @subsection Numerical Utilities There are a few other numerical utility functions available as entry points. @@ -16232,7 +16046,7 @@ Returns the value of @var{x} truncated (to an integer value) towards zero. @end deftypefun -@node Mathematical constants, , Numerical Utilities, Numerical analysis subroutines +@node Mathematical constants @subsection Mathematical constants @apivar M_E @apivar M_PI @@ -16292,7 +16106,8 @@ order to provide a way of using ``logical'' variables in C consistently. This can conflict with other software: for example it conflicts with the headers in @I{IJG}'s @code{jpeg-9} (but not earlier versions). -@node Optimization, Integration, Numerical analysis subroutines, The R API + +@node Optimization @section Optimization @cindex optimization @@ -16381,7 +16196,7 @@ be found from the help page for @code{optim}: see the source code specifies which bounds are to be used. -@node Integration, Utility functions, Optimization, The R API +@node Integration @section Integration @cindex integration @@ -16469,7 +16284,7 @@ The comments in the source code in @file{src/appl/integrate.c} give more details, particularly about reasons for failure (@code{ier >= 1}). -@node Utility functions, Re-encoding, Integration, The R API +@node Utility functions @section Utility functions @cindex Sort functions from C @@ -16658,7 +16473,8 @@ the original functions by Fox, Hall and @I{Schryer} on @I{Netlib} at @apifun d1mach @apifun i1mach -@node Re-encoding, Condition handling and cleanup code, Utility functions, The R API + +@node Re-encoding @section Re-encoding @R{} has its own C-level interface to the encoding conversion @@ -16695,7 +16511,7 @@ Free the resources of an encoding object. @end deftypefun -@node Condition handling and cleanup code, Allowing interrupts, Re-encoding, The R API +@node Condition handling and cleanup code @section Condition handling and cleanup code @cindex Condition handling @cindex Cleanup code @@ -16820,7 +16636,8 @@ option. For example, finalizers are run in a separate top level context. The other functions mentioned in this section will usually be more appropriate choices. -@node Allowing interrupts, C stack checking, Condition handling and cleanup code, The R API + +@node Allowing interrupts @section Allowing interrupts @cindex Interrupts @@ -16850,9 +16667,11 @@ Note that it is possible that the code behind one of the entry points defined here if called from your C or Fortran code could be interruptible or generate an error and so not return to your code. -@node C stack checking, Custom serialization input and output, Allowing interrupts, The R API + +@node C stack checking @section C stack checking @cindex C stack checking + @R{} provides a framework for detecting when the amount of C stack is too low. Two functions are available: @example @@ -16870,7 +16689,7 @@ recursions to avoid consuming C stack, so it is best to write code in a tail-recursive form when possible. -@node Custom serialization input and output, Platform and version information, C stack checking, The R API +@node Custom serialization input and output @section Custom serialization input and output @cindex Serialization @@ -16923,7 +16742,8 @@ Examples can be found in the @R{} sources in @file{src/main/serialize.c}. @eapifun R_InitOutPStream @eapifun R_Serialize -@node Platform and version information, Inlining C functions, Custom serialization input and output, The R API + +@node Platform and version information @section Platform and version information @cindex Version information from C @cindex @I{OpenMP} @@ -16984,7 +16804,8 @@ use which may have a conflicting definition), which suffices for known @R{} platforms. -@node Inlining C functions, Controlling visibility, Platform and version information, The R API + +@node Inlining C functions @section Inlining C functions @apivar R_INLINE @@ -17012,7 +16833,8 @@ single C file with the compiler used to build @R{}. We recommend that packages making extensive use of inlining include their own configure code. -@node Controlling visibility, Standalone Mathlib, Inlining C functions, The R API + +@node Controlling visibility @section Controlling visibility @cindex Visibility @@ -17090,7 +16912,8 @@ EXPORTS R_init_stats @end example -@node Standalone Mathlib, Organization of header files, Controlling visibility, The R API + +@node Standalone Mathlib @section Using these functions in your own C code It is possible to build @code{Mathlib}, the @R{} set of mathematical @@ -17141,7 +16964,8 @@ get_seed(unsigned int *, unsigned int *) @noindent to read the seeds). -@node Organization of header files, Moving into C API compliance, Standalone Mathlib, The R API + +@node Organization of header files @section Organization of header files The header files which @R{} installs are in directory @@ -17226,7 +17050,8 @@ INSTALL} to compile C++ code defining @code{R_NO_REMAP}. @env{_R_CXX_USE_NO_REMAP_} is set by @command{R CMD check --as-cran} and is planned to become the default in future. -@node Moving into C API compliance, , Organization of header files, The R API + +@node Moving into C API compliance @section Moving into C API compliance Work is in progress to clarify and tighten the C API for extending R @@ -17241,18 +17066,8 @@ non-API entry points to using ones available and supported in the API. @strong{Work in progress:} This section is a work in progress and will be adjusted as changes are made to the API. -@menu -* Some API replacements for non-API entry points:: -* Creating environments:: -* Creating call expressions:: -* Creating closures:: -* Querying CHARSXP encoding:: -* Working with attributes:: -* Working with variable bindings:: -* Some backports:: -@end menu -@node Some API replacements for non-API entry points, Creating environments, , Moving into C API compliance +@node Some API replacements for non-API entry points @subsection Some API replacements for non-API entry points Some non-API entry points intended for internal use have long had entry @@ -17328,7 +17143,7 @@ use back-ported versions defined conditionally. @xref{Some backports}. @comment FIXME: need to figure out about allocSExp(DOTSXP) -@node Creating environments, Creating call expressions, Some API replacements for non-API entry points, Moving into C API compliance +@node Creating environments @subsection Creating environments An idiom appearing in a number of packages is to create an environment @@ -17350,7 +17165,7 @@ so the new environment should be created as SEXP env = R_NewEnv(parent, FALSE, 0); @end example -@node Creating call expressions, Creating closures, Creating environments, Moving into C API compliance +@node Creating call expressions @subsection Creating call expressions Another idiom used in some packages is to create a call expression with @@ -17377,7 +17192,7 @@ created as SEXP env = allocLang(3); @end example -@node Creating closures, Querying CHARSXP encoding, Creating call expressions, Moving into C API compliance +@node Creating closures @subsection Creating closures Yet another common idiom is to create a new closure as @@ -17395,7 +17210,7 @@ SET_CLOENV(fun, env); SEXP fun = R_mkClosure(formals, body, env); @end example -@node Querying CHARSXP encoding, Some backports, Creating closures, Moving into C API compliance +@node Querying CHARSXP encoding @subsection Querying @code{CHARSXP} encoding A number of packages query encoding bits set on @code{CHARSXP} objects via macros @@ -17451,7 +17266,7 @@ char *asutf8(SEXP c) as the encoding flags are already checked in @code{translateCharUTF8}. Also note the non-compliant check doesn't handle native encoding. -@node Working with attributes, Working with variable bindings, Querying CHARSXP encoding, Moving into C API compliance +@node Working with attributes @subsection Working with attributes The current implementation (@R{} 4.5.0) represents attributes internally @@ -17469,7 +17284,7 @@ attribute is present. Some additional functions may be added for working with attributes. -@node Working with variable bindings, Some backports, Working with attributes, Moving into C API compliance +@node Working with variable bindings @subsection Working variable bindings The functions @code{findVar} and @code{findVarInFrame} have been used in @@ -17483,7 +17298,7 @@ information on a binding, such as whether the binding is delayed or not. This is currently not possible within the API, but is under consideration. -@node Some backports, , Querying CHARSXP encoding, Moving into C API compliance +@node Some backports @subsection Some backports This section lists backports of recently added definitions that can be @@ -17525,7 +17340,9 @@ void CLEAR_ATTRIB(SEXP x) #endif @end example -@node Generic functions and methods, Linking GUIs and other front-ends to R, The R API, Top + + +@node Generic functions and methods @chapter Generic functions and methods @cindex Generic functions @cindex Method functions @@ -17655,11 +17472,13 @@ scale <- function(x, ...) UseMethod("scale") Only add parameters and defaults to the generic if they make sense in all possible methods implementing it. + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Adding new generics:: @end menu -@node Adding new generics, , Generic functions and methods, Generic functions and methods +@node Adding new generics @section Adding new generics When creating a new generic function, bear in mind that its argument @@ -17699,7 +17518,9 @@ patched or updated. The same idea can be applied for functions in other packages. -@node Linking GUIs and other front-ends to R, Function and variable index, Generic functions and methods, Top + + +@node Linking GUIs and other front-ends to R @chapter Linking GUIs and other front-ends to R There are a number of ways to build front-ends to @R{}: we take this to @@ -17717,12 +17538,8 @@ conventional package (although packages may contain alternative front-ends). Conversely some of the functions from the API (such as @code{R_alloc}) should not be used in front-ends. -@menu -* Embedding R under Unix-alikes:: -* Embedding R under Windows:: -@end menu -@node Embedding R under Unix-alikes, Embedding R under Windows, Linking GUIs and other front-ends to R, Linking GUIs and other front-ends to R +@node Embedding R under Unix-alikes @section Embedding R under Unix-alikes @R{} can be built as a shared library@footnote{In the parlance of macOS @@ -17877,15 +17694,8 @@ It is the user's responsibility to attempt to initialize only once. To protect the @R{} interpreter, @code{Rf_initialize_R} will exit the process if re-initialization is attempted. -@menu -* Compiling against the R library:: -* Setting R callbacks:: -* Registering symbols:: -* Meshing event loops:: -* Threading issues:: -@end menu -@node Compiling against the R library, Setting R callbacks, Embedding R under Unix-alikes, Embedding R under Unix-alikes +@node Compiling against the R library @subsection Compiling against the R library Suitable flags to compile and link against the @R{} (shared or static) @@ -17966,7 +17776,7 @@ those libraries, but some platforms need the executable also linked against them. @c E.g. it seems current Linux needs the executable linked against -lm. -@node Setting R callbacks, Registering symbols, Compiling against the R library, Embedding R under Unix-alikes +@node Setting R callbacks @subsection Setting R callbacks For Unix-alikes there is a public header file @file{Rinterface.h} that @@ -18202,8 +18012,7 @@ matrices and data frames), @code{View} and @code{select.list}. These can be changed if they are not currently in use. @end deftypefun - -@node Registering symbols, Meshing event loops, Setting R callbacks, Embedding R under Unix-alikes +@node Registering symbols @subsection Registering symbols An application embedding @R{} needs a different way of registering @@ -18224,8 +18033,7 @@ The native routines defined by @code{cMethods} and @code{callMethods} should be present in the embedding application. See @ref{Registering native routines} for details on registering symbols in general. - -@node Meshing event loops, Threading issues, Registering symbols, Embedding R under Unix-alikes +@node Meshing event loops @subsection Meshing event loops One of the most difficult issues in interfacing @R{} to a front-end is @@ -18306,8 +18114,7 @@ events whilst waiting for input, and to ensure that it is not frozen out during events of the second type. The ability to add a polled handler as @code{R_timeout_handler} is used by the @pkg{tcltk} package. - -@node Threading issues, , Meshing event loops, Embedding R under Unix-alikes +@node Threading issues @subsection Threading issues Embedded @R{} is designed to be run in the main thread, and all the @@ -18352,7 +18159,8 @@ Note that these variables must not be changed by an @R{} @strong{package}: a package should not call @R{} internals which makes use of the stack-checking mechanism on a secondary thread. -@node Embedding R under Windows, , Embedding R under Unix-alikes, Linking GUIs and other front-ends to R + +@node Embedding R under Windows @section Embedding R under Windows This section is only about @cputype{x86_64} Windows. @@ -18361,13 +18169,8 @@ All Windows interfaces to @R{} call entry points in the DLL @file{R.dll}, directly or indirectly. Simpler applications may find it easier to use the indirect route @emph{via} @acronym{(D)COM}. -@menu -* Using (D)COM:: -* Calling R.dll directly:: -* Finding R_HOME:: -@end menu -@node Using (D)COM, Calling R.dll directly, Embedding R under Windows, Embedding R under Windows +@node Using (D)COM @subsection Using (D)COM @acronym{(D)COM} is a standard Windows mechanism used for communication @@ -18398,7 +18201,7 @@ Recent versions have usage restrictions. @c @uref{http://www.omegahat.net/RDCOMServer/Docs/Paradigm.html} and is @c very different from the purpose of this section. @end itemize -@node Calling R.dll directly, Finding R_HOME, Using (D)COM, Embedding R under Windows +@node Calling R.dll directly @subsection Calling @file{R.dll} directly The @code{R} DLL is mainly written in C and has @code{_cdecl} entry @@ -18623,7 +18426,7 @@ and opt in for UTF-8 as the active code page in their manifest, as all frontends shipped with @R{} do. This will allow the embedded @R{} to use UTF-8 as its native encoding on recent Windows systems. -@node Finding R_HOME, , Calling R.dll directly, Embedding R under Windows +@node Finding R_HOME @subsection Finding R_HOME Both applications which embed @R{} and those which use a @code{system} @@ -18685,17 +18488,20 @@ algorithm as @code{2.11.0 patched > 2.11.0 > 2.11.0 alpha > 2.8.1}) and use its value for @code{InstallPath}. @end itemize -@node Function and variable index, Concept index, Linking GUIs and other front-ends to R, Top + +@node Function and variable index @unnumbered Function and variable index @printindex vr -@node Concept index, API index, Function and variable index, Top + +@node Concept index @unnumbered Concept index @printindex cp -@node API index, Experimental API index, Concept index, Top + +@node API index @unnumbered API index Entry points and variables listed in this index and in header files @@ -18704,7 +18510,8 @@ will only be changed after deprecation. @printindex ap -@node Experimental API index, Embedding API index, API index, Top + +@node Experimental API index @unnumbered Experimental API index Entry points and variables listed in this index and in header files @@ -18714,7 +18521,8 @@ to use these should be prepared to adapt. @printindex ae -@node Embedding API index, , Experimental API index, Top + +@node Embedding API index @unnumbered Embedding API index Functions, variables, and header files to support creating alternate @@ -18722,6 +18530,7 @@ front ends and other forms of embedding @R{}. @printindex em + @bye @c Local Variables: *** diff --git a/doc/manual/R-intro.texi b/doc/manual/R-intro.texi index 4050ef2f0e9..efee497aad7 100644 --- a/doc/manual/R-intro.texi +++ b/doc/manual/R-intro.texi @@ -2,14 +2,13 @@ @c %**start of header @setfilename R-intro.info @settitle An Introduction to R -@setchapternewpage on @c %**end of header @c Authors: If you edit/add @example(s) , please keep @c ./R-intro.R up-to-date ! @c ~~~~~~~~~~~ -@syncodeindex fn vr +@syncodeindex fn vr @dircategory Programming @direntry @@ -35,19 +34,6 @@ Copyright @copyright{} 1997, 1998 M.@: Maechler@* @end quotation @end copying - -@c -@c Apparently AUCTeX 11.06 has a problem with '@appendixsection' entries -@c when updating nodes---the equivalent '@appendixsec' seems to work. -@c Hence changed (temporarily?) ... -@c - -@c -@c Conversion to PDF fails if sectioning titles contain (user-defined) -@c macros such as @R{}. Hence in section titles we changed @R{} to R. -@c Revert when this is fixed. -@c - @titlepage @title An Introduction to R @subtitle Notes on @R{}: A Programming Environment for Data Analysis and Graphics @@ -66,7 +52,7 @@ Copyright @copyright{} 1997, 1998 M.@: Maechler@* @contents @ifnottex -@node Top, Preface, (dir), (dir) +@node Top @top An Introduction to R This is an introduction to R (``GNU S''), a language and environment for @@ -85,31 +71,9 @@ statistical modelling and graphics. @end ifnottex -@menu -* Preface:: -* Introduction and preliminaries:: -* Simple manipulations numbers and vectors:: -* Objects:: -* Factors:: -* Arrays and matrices:: -* Lists and data frames:: -* Reading data from files:: -* Probability distributions:: -* Loops and conditional execution:: -* Writing your own functions:: -* Statistical models in R:: -* Graphics:: -* Packages:: -* OS facilities:: -* A sample session:: -* Invoking R:: -* The command-line editor:: -* Function and variable index:: -* Concept index:: -* References:: -@end menu -@node Preface, Introduction and preliminaries, Top, Top + +@node Preface @unnumbered Preface This introduction to @R{} is derived from an original set of notes @@ -136,24 +100,12 @@ Many users will come to @R{} mainly for its graphical facilities. until all the preceding sections have been digested. -@node Introduction and preliminaries, Simple manipulations numbers and vectors, Preface, Top + +@node Introduction and preliminaries @chapter Introduction and preliminaries -@menu -* The R environment:: -* Related software and documentation:: -* R and statistics:: -* R and the window system:: -* Using R interactively:: -* An introductory session:: -* Getting help:: -* R commands; case sensitivity etc:: -* Recall and correction of previous commands:: -* Executing commands from or diverting output to a file:: -* Data permanency and removing objects:: -@end menu -@node The R environment, Related software and documentation, Introduction and preliminaries, Introduction and preliminaries +@node The R environment @section The R environment @R{} is an integrated suite of software facilities for data @@ -189,7 +141,8 @@ large collection of @emph{packages}. However, most programs written in @R{} are essentially ephemeral, written for a single piece of data analysis. -@node Related software and documentation, R and statistics, The R environment, Introduction and preliminaries + +@node Related software and documentation @section Related software and documentation @R{} can be regarded as an implementation of the @Sl{} language which @@ -216,7 +169,7 @@ implementations in mind. for more information. -@node R and statistics, R and the window system, Related software and documentation, Introduction and preliminaries +@node R and statistics @section R and statistics @cindex Packages @@ -243,7 +196,8 @@ copious output from a regression or discriminant analysis, @R{} will give minimal output and store the results in a fit object for subsequent interrogation by further @R{} functions. -@node R and the window system, Using R interactively, R and statistics, Introduction and preliminaries + +@node R and the window system @section R and the window system The most convenient way to use @R{} is at a graphics workstation running @@ -263,7 +217,8 @@ features of @R{} is a straightforward if somewhat tedious procedure, and will not be considered further here. Users in difficulty should seek local expert help. -@node Using R interactively, An introductory session, R and the window system, Introduction and preliminaries + +@node Using R interactively @section Using R interactively When you use the @R{} program it issues a prompt when it expects input @@ -337,14 +292,16 @@ follow is basically the same. Create a folder as the working directory, and set that in the @file{Start In} field in your @R{} shortcut. Then launch @R{} by double clicking on the icon. -@node An introductory session, Getting help, Using R interactively, Introduction and preliminaries + +@node An introductory session @section An introductory session Readers wishing to get a feel for @R{} at a computer before proceeding are strongly advised to work through the introductory session given in @ref{A sample session}. -@node Getting help, R commands; case sensitivity etc, An introductory session, Introduction and preliminaries + +@node Getting help @section Getting help with functions and features @findex help @@ -422,7 +379,8 @@ Windows versions of @R{} have other optional help systems: use @noindent for further details. -@node R commands; case sensitivity etc, Recall and correction of previous commands, Getting help, Introduction and preliminaries + +@node R commands; case sensitivity etc @section R commands, case sensitivity, etc. Technically @R{} is an @emph{expression language} with a very simple @@ -471,7 +429,8 @@ consoles will not allow you to enter more, and amongst those which do some will silently discard the excess and some will use it as the start of the next line.} to about 4095 bytes (not characters). -@node Recall and correction of previous commands, Executing commands from or diverting output to a file, R commands; case sensitivity etc, Introduction and preliminaries + +@node Recall and correction of previous commands @section Recall and correction of previous commands Under many versions of UNIX and on Windows, @R{} provides a mechanism @@ -493,7 +452,7 @@ working interactively with @R{}. @xref{R and Emacs, , , R-FAQ, R FAQ} for more information. -@node Executing commands from or diverting output to a file, Data permanency and removing objects, Recall and correction of previous commands, Introduction and preliminaries +@node Executing commands from or diverting output to a file @section Executing commands from or diverting output to a file @cindex Diverting input and output @@ -525,7 +484,8 @@ will divert all subsequent output from the console to an external file, @noindent restores it to the console once again. -@node Data permanency and removing objects, , Executing commands from or diverting output to a file, Introduction and preliminaries + +@node Data permanency and removing objects @section Data permanency and removing objects The entities that @R{} creates and manipulates are known as @@ -575,22 +535,14 @@ are often meaningful in the context of a single analysis, but it can be quite hard to decide what they might be when the several analyses have been conducted in the same directory. -@node Simple manipulations numbers and vectors, Objects, Introduction and preliminaries, Top + + +@node Simple manipulations numbers and vectors @chapter Simple manipulations; numbers and vectors @cindex Vectors -@menu -* Vectors and assignment:: -* Vector arithmetic:: -* Generating regular sequences:: -* Logical vectors:: -* Missing values:: -* Character vectors:: -* Index vectors:: -* Other types of objects:: -@end menu -@node Vectors and assignment, Vector arithmetic, Simple manipulations numbers and vectors, Simple manipulations numbers and vectors +@node Vectors and assignment @section Vectors and assignment @R{} operates on named @emph{data structures}. The simplest such @@ -666,7 +618,8 @@ The further assignment would create a vector @code{y} with 11 entries consisting of two copies of @code{x} with a zero in the middle place. -@node Vector arithmetic, Generating regular sequences, Vectors and assignment, Simple manipulations numbers and vectors + +@node Vector arithmetic @section Vector arithmetic Vectors can be used in arithmetic expressions, in which case the @@ -774,7 +727,7 @@ sqrt(-17+0i) will do the computations as complex numbers. -@node Generating regular sequences, Logical vectors, Vector arithmetic, Simple manipulations numbers and vectors +@node Generating regular sequences @section Generating regular sequences @cindex Regular sequences @@ -857,7 +810,8 @@ useful version is which repeats each element of @code{x} five times before moving on to the next. -@node Logical vectors, Missing values, Generating regular sequences, Simple manipulations numbers and vectors + +@node Logical vectors @section Logical vectors As well as numerical vectors, @R{} allows manipulation of logical @@ -906,7 +860,8 @@ and @code{TRUE} becoming @code{1}. However there are situations where logical vectors and their coerced numeric counterparts are not equivalent, for example see the next subsection. -@node Missing values, Character vectors, Logical vectors, Simple manipulations numbers and vectors + +@node Missing values @section Missing values @cindex Missing values @@ -963,7 +918,8 @@ and @code{NaN} values. To differentiate these, @code{is.nan(xx)} is only Missing values are sometimes printed as @code{} when character vectors are printed without quotes. -@node Character vectors, Index vectors, Missing values, Simple manipulations numbers and vectors + +@node Character vectors @section Character vectors @cindex Character vectors @@ -1015,7 +971,8 @@ arguments into a single character string putting @var{ss} in between, e.g., @code{ss <- "|"}. There are more tools for character manipulation, see the help for @code{sub} and @code{substring}.} -@node Index vectors, Other types of objects, Character vectors, Simple manipulations numbers and vectors + +@node Index vectors @section Index vectors; selecting and modifying subsets of a data set @cindex Indexing vectors @@ -1138,7 +1095,8 @@ has the same effect as > y <- abs(y) @end example -@node Other types of objects, , Index vectors, Simple manipulations numbers and vectors + +@node Other types of objects @section Other types of objects Vectors are the most important type of object in @R{}, but there are @@ -1176,7 +1134,9 @@ extend @R{}. @xref{Writing your own functions}. @end itemize -@node Objects, Factors, Simple manipulations numbers and vectors, Top + + +@node Objects @chapter Objects, their modes and attributes @cindex Objects @cindex Attributes @@ -1187,14 +1147,8 @@ extend @R{}. @xref{Writing your own functions}. @c are for S compatibility mostly. Hence in particular, there is no @c intrinsic attribute `mode'. -@menu -* The intrinsic attributes mode and length:: -* Changing the length of an object:: -* Getting and setting attributes:: -* The class of an object:: -@end menu -@node The intrinsic attributes mode and length, Changing the length of an object, Objects, Objects +@node The intrinsic attributes mode and length @section Intrinsic attributes: mode and length The entities @R{} operates on are technically known as @emph{objects}. @@ -1282,7 +1236,8 @@ consult the different help files to become familiar with them. @c -@node Changing the length of an object, Getting and setting attributes, The intrinsic attributes mode and length, Objects + +@node Changing the length of an object @section Changing the length of an object An ``empty'' object may still have a mode. For example @@ -1330,7 +1285,8 @@ then retain just the first three values by @noindent and vectors can be extended (by missing values) in the same way. -@node Getting and setting attributes, The class of an object, Changing the length of an object, Objects + +@node Getting and setting attributes @section Getting and setting attributes @findex attr @findex attributes @@ -1360,7 +1316,8 @@ change an existing one. For example @noindent allows @R{} to treat @code{z} as if it were a 10-by-10 matrix. -@node The class of an object, , Getting and setting attributes, Objects + +@node The class of an object @section The class of an object @cindex Classes @@ -1403,7 +1360,8 @@ to terms with the idea of class and generic functions. Generic functions and classes will be discussed further in @ref{Object orientation}, but only briefly. -@node Factors, Arrays and matrices, Objects, Top + +@node Factors @chapter Ordered and unordered factors @cindex Factors @cindex Ordered factors @@ -1460,12 +1418,8 @@ used. [1] "act" "nsw" "nt" "qld" "sa" "tas" "vic" "wa" @end example -@menu -* The function tapply() and ragged arrays:: -* Ordered factors:: -@end menu -@node The function tapply() and ragged arrays, Ordered factors, Factors, Factors +@node The function tapply() and ragged arrays @section The function @code{tapply()} and ragged arrays @findex tapply @@ -1560,7 +1514,7 @@ indexing may be done implicitly and much more efficiently, as we see in the next section. -@node Ordered factors, , The function tapply() and ragged arrays, Factors +@node Ordered factors @section Ordered factors @findex ordered @@ -1577,23 +1531,12 @@ ordering of the levels, but the contrasts generated for them in fitting linear models are different. -@node Arrays and matrices, Lists and data frames, Factors, Top + +@node Arrays and matrices @chapter Arrays and matrices -@menu -* Arrays:: -* Array indexing:: -* Index matrices:: -* The array() function:: -* The outer product of two arrays:: -* Generalized transpose of an array:: -* Matrix facilities:: -* Forming partitioned matrices:: -* The concatenation function c() with arrays:: -* Frequency tables from factors:: -@end menu -@node Arrays, Array indexing, Arrays and matrices, Arrays and matrices +@node Arrays @section Arrays @cindex Arrays @cindex Matrices @@ -1638,7 +1581,8 @@ Arrays can be one-dimensional: such arrays are usually treated in the same way as vectors (including when printing), but the exceptions can cause confusion. -@node Array indexing, Index matrices, Arrays, Arrays and matrices + +@node Array indexing @section Array indexing. Subsections of an array @cindex Indexing of and by arrays @@ -1674,7 +1618,7 @@ however, if the single index is not a vector but itself an array, as we next discuss. -@node Index matrices, The array() function, Array indexing, Arrays and matrices +@node Index matrices @section Index matrices As well as an index vector in any subscript position, a matrix may be @@ -1766,7 +1710,8 @@ Index matrices must be numerical: any other form of matrix (e.g.@: a logical or character matrix) supplied as a matrix is treated as an indexing vector. -@node The array() function, The outer product of two arrays, Index matrices, Arrays and matrices + +@node The array() function @section The @code{array()} function @findex array @@ -1827,11 +1772,13 @@ the given element-by-element operations. However the precise rule concerning mixed array and vector calculations has to be considered a little more carefully. + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * The recycling rule:: @end menu -@node The recycling rule, , The array() function, The array() function +@node The recycling rule @subsection Mixed vector and array arithmetic. The recycling rule @cindex Recycling rule @@ -1857,7 +1804,8 @@ been precipitated, the result is an array structure with the common @code{dim} attribute of its array operands. @end itemize -@node The outer product of two arrays, Generalized transpose of an array, The array() function, Arrays and matrices + +@node The outer product of two arrays @section The outer product of two arrays @cindex Outer products of arrays @@ -1929,7 +1877,8 @@ to be impractical. It is also perhaps surprising that about 1 in 20 such matrices is singular. -@node Generalized transpose of an array, Matrix facilities, The outer product of two arrays, Arrays and matrices + +@node Generalized transpose of an array @section Generalized transpose of an array @cindex Generalized transpose of an array @@ -1954,7 +1903,8 @@ function @code{t()} @findex t is available, so we could have used @code{B <- t(A)}. -@node Matrix facilities, Forming partitioned matrices, Generalized transpose of an array, Arrays and matrices + +@node Matrix facilities @section Matrix facilities @iftex @@ -1988,15 +1938,8 @@ number of rows and columns in the matrix @code{A} respectively. @findex nrow @findex ncol -@menu -* Multiplication:: -* Linear equations and inversion:: -* Eigenvalues and eigenvectors:: -* Singular value decomposition and determinants:: -* Least squares fitting and the QR decomposition:: -@end menu -@node Multiplication, Linear equations and inversion, Matrix facilities, Matrix facilities +@node Multiplication @subsection Matrix multiplication @cindex Matrix multiplication @@ -2056,7 +1999,7 @@ vector as the diagonal entries. On the other hand @code{diag(M)}, where numeric value then @code{diag(k)} is the @code{k} by @code{k} identity matrix! -@node Linear equations and inversion, Eigenvalues and eigenvectors, Multiplication, Matrix facilities +@node Linear equations and inversion @subsection Linear equations and inversion @cindex Linear equations @@ -2101,7 +2044,7 @@ of the solution of @eqn{By = x, By = x} , perhaps using the Cholesky or eigendecomposition of @eqn{A, A}. } @code{x %*% solve(A,x)}, rather than computing the inverse of @code{A}. -@node Eigenvalues and eigenvectors, Singular value decomposition and determinants, Linear equations and inversion, Matrix facilities +@node Eigenvalues and eigenvectors @subsection Eigenvalues and eigenvectors @cindex Eigenvalues and eigenvectors @@ -2142,8 +2085,7 @@ eigenvectors if they are not needed by using the expression > evals <- eigen(Sm, only.values = TRUE)$values @end example - -@node Singular value decomposition and determinants, Least squares fitting and the QR decomposition, Eigenvalues and eigenvectors, Matrix facilities +@node Singular value decomposition and determinants @subsection Singular value decomposition and determinants @cindex Singular value decomposition @@ -2189,7 +2131,7 @@ and modulus (optionally on log scale), @c Functions will be discussed formally later in these notes. -@node Least squares fitting and the QR decomposition, , Singular value decomposition and determinants, Matrix facilities +@node Least squares fitting and the QR decomposition @subsection Least squares fitting and the QR decomposition @cindex Least squares fitting @cindex QR decomposition @@ -2239,7 +2181,7 @@ generally be replaced by the statistical models features, as will be discussed in @ref{Statistical models in R}. -@node Forming partitioned matrices, The concatenation function c() with arrays, Matrix facilities, Arrays and matrices +@node Forming partitioned matrices @section Forming partitioned matrices, @code{cbind()} and @code{rbind()} @findex cbind @findex rbind @@ -2284,7 +2226,8 @@ Hence @code{cbind(x)} and @code{rbind(x)} are possibly the simplest ways explicitly to allow the vector @code{x} to be treated as a column or row matrix respectively. -@node The concatenation function c() with arrays, Frequency tables from factors, Forming partitioned matrices, Arrays and matrices + +@node The concatenation function c() with arrays @section The concatenation function, @code{c()}, with arrays It should be noted that whereas @code{cbind()} and @code{rbind()} are @@ -2313,7 +2256,8 @@ There are slight differences between the two, but ultimately the choice between them is largely a matter of style (with the former being preferable). -@node Frequency tables from factors, , The concatenation function c() with arrays, Arrays and matrices + +@node Frequency tables from factors @section Frequency tables from factors @cindex Tabulation @@ -2364,16 +2308,13 @@ incomef act nsw nt qld sa tas vic wa Extension to higher-way frequency tables is immediate. -@node Lists and data frames, Reading data from files, Arrays and matrices, Top + + +@node Lists and data frames @chapter Lists and data frames -@menu -* Lists:: -* Constructing and modifying lists:: -* Data frames:: -@end menu -@node Lists, Constructing and modifying lists, Lists and data frames, Lists and data frames +@node Lists @section Lists @cindex Lists @@ -2454,7 +2395,8 @@ The vector of names is in fact simply an attribute of the list like any other and may be handled as such. Other structures besides lists may, of course, similarly be given a @emph{names} attribute also. -@node Constructing and modifying lists, Data frames, Lists, Lists and data frames + +@node Constructing and modifying lists @section Constructing and modifying lists New lists may be formed from existing objects by the function @@ -2479,11 +2421,13 @@ additional components. For example > Lst[5] <- list(matrix=Mat) @end example + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Concatenating lists:: @end menu -@node Concatenating lists, , Constructing and modifying lists, Constructing and modifying lists +@node Concatenating lists @subsection Concatenating lists @cindex Concatenating lists @@ -2502,7 +2446,7 @@ In this case all other attributes, such as @code{dim} attributes, are discarded. -@node Data frames, , Constructing and modifying lists, Lists and data frames +@node Data frames @section Data frames @cindex Data frames @@ -2527,15 +2471,8 @@ possibly of differing modes and attributes. It may be displayed in matrix form, and its rows and columns extracted using matrix indexing conventions. -@menu -* Making data frames:: -* attach() and detach():: -* Working with data frames:: -* Attaching arbitrary lists:: -* Managing the search path:: -@end menu -@node Making data frames, attach() and detach(), Data frames, Data frames +@node Making data frames @subsection Making data frames Objects satisfying the restrictions placed on the columns (components) @@ -2557,7 +2494,7 @@ The simplest way to construct a data frame from scratch is to use the external file. This is discussed further in @ref{Reading data from files}. -@node attach() and detach(), Working with data frames, Making data frames, Data frames +@node attach() and detach() @subsection @code{attach()} and @code{detach()} @findex attach @findex detach @@ -2622,7 +2559,7 @@ You can alter the attached values @emph{via} @code{assign}, but the original list or data frame is unchanged. @end quotation -@node Working with data frames, Attaching arbitrary lists, attach() and detach(), Data frames +@node Working with data frames @subsection Working with data frames A useful convention that allows you to work with many different problems @@ -2649,7 +2586,7 @@ In this way it is quite simple to work with many problems in the same directory, all of which have variables named @code{x}, @code{y} and @code{z}, for example. -@node Attaching arbitrary lists, Managing the search path, Working with data frames, Data frames +@node Attaching arbitrary lists @subsection Attaching arbitrary lists @code{attach()} is a generic function that allows not only directories @@ -2664,7 +2601,7 @@ attached in the same way: Anything that has been attached can be detached by @code{detach}, by position number or, preferably, by name. -@node Managing the search path, , Attaching arbitrary lists, Data frames +@node Managing the search path @subsection Managing the search path @findex search @cindex Search path @@ -2703,7 +2640,9 @@ the search path. [1] ".GlobalEnv" "Autoloads" "package:base" @end example -@node Reading data from files, Probability distributions, Lists and data frames, Top + + +@node Reading data from files @chapter Reading data from files @cindex Reading data from files @@ -2724,14 +2663,8 @@ function, @code{scan()}, that can be called directly. For more details on importing data into @R{} and also exporting data, see the @emph{R Data Import/Export} manual. -@menu -* The read.table() function:: -* The scan() function:: -* Accessing builtin datasets:: -* Editing data:: -@end menu -@node The read.table() function, The scan() function, Reading data from files, Reading data from files +@node The read.table() function @section The @code{read.table()} function @findex read.table @@ -2811,7 +2744,7 @@ line of headings, and hence, by implication from the form of the file, that no explicit row labels are given. -@node The scan() function, Accessing builtin datasets, The read.table() function, Reading data from files +@node The scan() function @section The @code{scan()} function @findex scan @@ -2863,7 +2796,8 @@ dummy value. There are more elaborate input facilities available and these are detailed in the manuals. -@node Accessing builtin datasets, Editing data, The scan() function, Reading data from files + +@node Accessing builtin datasets @section Accessing builtin datasets @cindex Accessing builtin datasets @findex data @@ -2907,7 +2841,8 @@ automatically included in the search. User-contributed packages can be a rich source of datasets. -@node Editing data, , Accessing builtin datasets, Reading data from files + +@node Editing data @section Editing data @findex edit @@ -2935,17 +2870,13 @@ Use to enter new data via the spreadsheet interface. -@node Probability distributions, Loops and conditional execution, Reading data from files, Top + +@node Probability distributions @chapter Probability distributions @cindex Probability distributions -@menu -* R as a set of statistical tables:: -* Examining the distribution of a set of data:: -* One- and two-sample tests:: -@end menu -@node R as a set of statistical tables, Examining the distribution of a set of data, Probability distributions, Probability distributions +@node R as a set of statistical tables @section R as a set of statistical tables One convenient use of @R{} is to provide a comprehensive set of @@ -3022,7 +2953,8 @@ Here are some examples See the on-line help on @code{RNG} for how random-number generation is done in @R{}. -@node Examining the distribution of a set of data, One- and two-sample tests, R as a set of statistical tables, Probability distributions + +@node Examining the distribution of a set of data @section Examining the distribution of a set of data Given a (univariate) set of data we can examine its distribution in a @@ -3182,7 +3114,8 @@ alternative hypothesis: two.sided have estimated the parameters of the normal distribution from the same sample.) -@node One- and two-sample tests, , Examining the distribution of a set of data, Probability distributions + +@node One- and two-sample tests @section One- and two-sample tests @cindex One- and two-sample tests @@ -3340,16 +3273,14 @@ Warning message: cannot compute correct p-values with ties in: ks.test(A, B) @end example -@node Loops and conditional execution, Writing your own functions, Probability distributions, Top + + +@node Loops and conditional execution @chapter Grouping, loops and conditional execution @cindex Loops and conditional execution -@menu -* Grouped expressions:: -* Control statements:: -@end menu -@node Grouped expressions, Control statements, Loops and conditional execution, Loops and conditional execution +@node Grouped expressions @section Grouped expressions @cindex Grouped expressions @@ -3365,16 +3296,13 @@ is the result of the last expression in the group evaluated. Since such a group is also an expression it may, for example, be itself included in parentheses and used as part of an even larger expression, and so on. -@node Control statements, , Grouped expressions, Loops and conditional execution + +@node Control statements @section Control statements @cindex Control statements -@menu -* Conditional execution:: -* Repetitive execution:: -@end menu -@node Conditional execution, Repetitive execution, Control statements, Control statements +@node Conditional execution @subsection Conditional execution: @code{if} statements @findex if @@ -3405,8 +3333,7 @@ b)} and returns a vector of the same length as @code{condition}, with elements @code{a[i]} if @code{condition[i]} is true, otherwise @code{b[i]} (where @code{a} and @code{b} are recycled as necessary). - -@node Repetitive execution, , Conditional execution, Control statements +@node Repetitive execution @subsection Repetitive execution: @code{for} loops, @code{repeat} and @code{while} @findex for @@ -3485,7 +3412,8 @@ Control statements are most often used in connection with functions}, and where more examples will emerge. -@node Writing your own functions, Statistical models in R, Loops and conditional execution, Top + +@node Writing your own functions @chapter Writing your own functions @cindex Writing functions @@ -3518,19 +3446,8 @@ A call to the function then usually takes the form @code{@var{name}(@var{expr_1}, @var{expr_2}, @dots{})} and may occur anywhere a function call is legitimate. -@menu -* Simple examples:: -* Defining new binary operators:: -* Named arguments and defaults:: -* The three dots argument:: -* Assignment within functions:: -* More advanced examples:: -* Scope:: -* Customizing the environment:: -* Object orientation:: -@end menu -@node Simple examples, Defining new binary operators, Writing your own functions, Writing your own functions +@node Simple examples @section Simple examples As a first example, consider a function to calculate the two sample @@ -3606,7 +3523,8 @@ part isolated in a simple to use function if it is going to be in frequent use. If so, we may wish to make it a matrix binary operator for even more convenient use. -@node Defining new binary operators, Named arguments and defaults, Simple examples, Writing your own functions + +@node Defining new binary operators @section Defining new binary operators @cindex Binary operators @@ -3635,7 +3553,8 @@ The matrix multiplication operator, @code{%*%}, and the outer product matrix operator @code{%o%} are other examples of binary operators defined in this way. -@node Named arguments and defaults, The three dots argument, Defining new binary operators, Writing your own functions + +@node Named arguments and defaults @section Named arguments and defaults @cindex Named arguments @cindex Default values @@ -3696,11 +3615,9 @@ It is important to note that defaults may be arbitrary expressions, even involving other arguments to the same function; they are not restricted to be constants as in our simple example here. -@node The three dots argument, Assignment within functions, Named arguments and defaults, Writing your own functions -@section The @samp{@dots{}} argument -@c The ?Reserved topic links here, so please update it -@c if changing the node name. +@node The three dots argument +@section The @samp{@dots{}} argument Another frequent requirement is to allow one function to pass on argument settings to another. For example many graphics functions use @@ -3726,7 +3643,8 @@ arguments and returns them in a named list, while @code{..1}, @code{..2}, etc. evaluate them one at a time, with @samp{..n} returning the @I{n-th} unmatched argument. -@node Assignment within functions, More advanced examples, The three dots argument, Writing your own functions + +@node Assignment within functions @section Assignments within functions Note that @emph{any ordinary assignments done within the function are @@ -3745,16 +3663,12 @@ either the `@I{superassignment}' operator, @code{<<-} or the function @c @SPLUS{} users should be aware that @code{<<-} has different semantics @c in @R{}. These are discussed further in @ref{Scope}. -@node More advanced examples, Scope, Assignment within functions, Writing your own functions + +@node More advanced examples @section More advanced examples -@menu -* Efficiency factors in block designs:: -* Dropping all names in a printed array:: -* Recursive numerical integration:: -@end menu -@node Efficiency factors in block designs, Dropping all names in a printed array, More advanced examples, More advanced examples +@node Efficiency factors in block designs @subsection Efficiency factors in block designs As a more complete, if a little pedestrian, example of a function, @@ -3800,7 +3714,7 @@ factors as the first component, but also the block and variety canonical contrasts, since sometimes these give additional useful qualitative information. -@node Dropping all names in a printed array, Recursive numerical integration, Efficiency factors in block designs, More advanced examples +@node Dropping all names in a printed array @subsection Dropping all names in a printed array For printing purposes with large matrices or arrays, it is often useful @@ -3843,7 +3757,7 @@ using This is particularly useful for large integer arrays, where patterns are the real interest rather than the values. -@node Recursive numerical integration, , Dropping all names in a printed array, More advanced examples +@node Recursive numerical integration @subsection Recursive numerical integration Functions may be recursive, and may themselves define functions within @@ -3888,7 +3802,7 @@ area <- function(f, a, b, eps = 1.0e-06, lim = 10) @{ @end example -@node Scope, Customizing the environment, More advanced examples, Writing your own functions +@node Scope @section Scope @cindex Scope @@ -4013,7 +3927,8 @@ ross$balance() ross$withdraw(500) @end example -@node Customizing the environment, Object orientation, Scope, Writing your own functions + +@node Customizing the environment @section Customizing the environment @cindex Customizing the environment @@ -4072,7 +3987,8 @@ at the very end of the session. An example is given below. @end example @findex .Last -@node Object orientation, , Customizing the environment, Writing your own functions + +@node Object orientation @section Classes, generic functions and object orientation @cindex Classes @cindex Generic functions @@ -4178,7 +4094,8 @@ The reader is referred to the @emph{R Language Definition} for a more complete discussion of this mechanism. -@node Statistical models in R, Graphics, Writing your own functions, Top + +@node Statistical models in R @chapter Statistical models in R @cindex Statistical models @@ -4197,18 +4114,8 @@ statistical models very simple. As we mention in the introduction, the basic output is minimal, and one needs to ask for the details by calling extractor functions. -@menu -* Formulae for statistical models:: -* Linear models:: -* Generic functions for extracting model information:: -* Analysis of variance and model comparison:: -* Updating fitted models:: -* Generalized linear models:: -* Nonlinear least squares and maximum likelihood models:: -* Some non-standard models:: -@end menu -@node Formulae for statistical models, Linear models, Statistical models in R, Statistical models in R +@node Formulae for statistical models @section Defining statistical models; formulae @cindex Formulae @@ -4398,11 +4305,13 @@ of the model matrix}, the specification of the parameters being implicit. This is not the case in other contexts, for example in specifying nonlinear models. + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Contrasts:: @end menu -@node Contrasts, , Formulae for statistical models, Formulae for statistical models +@node Contrasts @subsection Contrasts @cindex Contrasts @@ -4462,7 +4371,7 @@ with an interaction but not the corresponding main effects will in general lead to surprising results, and is for experts only. -@node Linear models, Generic functions for extracting model information, Formulae for statistical models, Statistical models in R +@node Linear models @section Linear models @cindex Linear models @@ -4490,7 +4399,8 @@ should come first from the @code{production} @emph{data frame}. @emph{This is the case regardless of whether data frame @code{production} has been attached on the search path or not}. -@node Generic functions for extracting model information, Analysis of variance and model comparison, Linear models, Statistical models in R + +@node Generic functions for extracting model information @section Generic functions for extracting model information The value of @code{lm()} is a fitted model object; technically a list of @@ -4576,7 +4486,8 @@ Returns the variance-covariance matrix of the main parameters of a fitted model object. @end table -@node Analysis of variance and model comparison, Updating fitted models, Generic functions for extracting model information, Statistical models in R + +@node Analysis of variance and model comparison @section Analysis of variance and model comparison @cindex Analysis of variance @@ -4615,11 +4526,13 @@ would typically be used to describe an experiment with mean model @code{v + n*p*k} and three error strata, namely ``between farms'', ``within farms, between blocks'' and ``within blocks''. + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * ANOVA tables:: @end menu -@node ANOVA tables, , Analysis of variance and model comparison, Analysis of variance and model comparison +@node ANOVA tables @subsection ANOVA tables Note also that the analysis of variance table (or tables) are for a @@ -4648,7 +4561,8 @@ would usually be an hierarchical sequence, of course. This does not give different information to the default, but rather makes it easier to comprehend and control. -@node Updating fitted models, Generalized linear models, Analysis of variance and model comparison, Statistical models in R + +@node Updating fitted models @section Updating fitted models @cindex Updating fitted models @@ -4702,7 +4616,8 @@ Other functions for exploring incremental sequences of models are The names of these give a good clue to their purpose, but for full details see the on-line help. -@node Generalized linear models, Nonlinear least squares and maximum likelihood models, Updating fitted models, Statistical models in R + +@node Generalized linear models @section Generalized linear models @cindex Generalized linear models @@ -4783,12 +4698,8 @@ least approximately. The reader is referred to any of the current reference works on the subject for full details, such as @I{McCullagh & Nelder} (1989) or @I{Dobson} (1990). -@menu -* Families:: -* The glm() function:: -@end menu -@node Families, The glm() function, Generalized linear models, Generalized linear models +@node Families @subsection Families @cindex Families @@ -4821,7 +4732,7 @@ The combination of a response distribution, a link function and various other pieces of information that are needed to carry out the modeling exercise is called the @emph{family} of the generalized linear model. -@node The glm() function, , Families, Generalized linear models +@node The glm() function @subsection The @code{glm()} function @findex glm @@ -5056,7 +4967,8 @@ non-linear regression as The reader is referred to the manual and the help document for further information, as needed. -@node Nonlinear least squares and maximum likelihood models, Some non-standard models, Generalized linear models, Statistical models in R + +@node Nonlinear least squares and maximum likelihood models @section Nonlinear least squares and maximum likelihood models @cindex Nonlinear least squares @@ -5078,12 +4990,8 @@ All the methods require initial guesses about what parameter values to try, and convergence may depend critically upon the quality of the starting values. -@menu -* Least squares:: -* Maximum likelihood:: -@end menu -@node Least squares, Maximum likelihood, Nonlinear least squares and maximum likelihood models, Nonlinear least squares and maximum likelihood models +@node Least squares @subsection Least squares One way to fit a nonlinear model is by minimizing the sum of the squared @@ -5173,7 +5081,7 @@ Correlation of Parameter Estimates: K 0.7651 @end example -@node Maximum likelihood, , Least squares, Nonlinear least squares and maximum likelihood models +@node Maximum likelihood @subsection Maximum likelihood @cindex Maximum likelihood @@ -5219,7 +5127,8 @@ parameters. To obtain the approximate @abbr{SE}s of the estimates we do: A 95% confidence interval would be the parameter estimate @eqn{\pm, +/-} 1.96 SE. -@node Some non-standard models, , Nonlinear least squares and maximum likelihood models, Statistical models in R + +@node Some non-standard models @section Some non-standard models We conclude this chapter with just a brief mention of some of the other @@ -5302,7 +5211,9 @@ packages @CRANpkg{rpart} and @CRANpkg{tree}. @end itemize -@node Graphics, Packages, Statistical models in R, Top + + +@node Graphics @chapter Graphical procedures Graphical facilities are an important and extremely versatile component @@ -5348,17 +5259,8 @@ it is more powerful but harder to use. There is a recommended package @CRANpkg{lattice} which builds on @pkg{grid} and provides ways to produce multi-panel plots akin to those in the @emph{Trellis} system in @Sl{}. -@menu -* High-level plotting commands:: -* Low-level plotting commands:: -* Interacting with graphics:: -* Using graphics parameters:: -* Graphics parameters:: -* Device drivers:: -* Dynamic graphics:: -@end menu -@node High-level plotting commands, Low-level plotting commands, Graphics, Graphics +@node High-level plotting commands @section High-level plotting commands High-level plotting functions are designed to generate a complete plot @@ -5367,14 +5269,8 @@ axes, labels and titles are automatically generated (unless you request otherwise.) High-level plotting commands always start a new plot, erasing the current plot if necessary. -@menu -* The plot() function:: -* Displaying multivariate data:: -* Display graphics:: -* Arguments to high-level plotting functions:: -@end menu -@node The plot() function, Displaying multivariate data, High-level plotting commands, High-level plotting commands +@node The plot() function @subsection The @code{plot()} function @findex plot @@ -5415,7 +5311,7 @@ frame (first form) or of a number of named objects (second form). The third form plots @var{y} against every object named in @var{expr}. @end table -@node Displaying multivariate data, Display graphics, The plot() function, High-level plotting commands +@node Displaying multivariate data @subsection Displaying multivariate data @R{} provides two very useful functions for representing multivariate @@ -5471,7 +5367,7 @@ two vectors @code{x} and @code{y} as the value of @code{panel=} you can produce any type of plot you wish. An example panel function useful for @I{coplots} is @code{panel.smooth()}. -@node Display graphics, Arguments to high-level plotting functions, Displaying multivariate data, High-level plotting commands +@node Display graphics @subsection Display graphics Other high-level graphics functions produce different types of plots. @@ -5528,7 +5424,7 @@ plot draws contour lines to represent the value of @code{z}, and the @code{persp} plot draws a 3D surface. @end table -@node Arguments to high-level plotting functions, , Display graphics, High-level plotting commands +@node Arguments to high-level plotting functions @subsection Arguments to high-level plotting functions There are a number of arguments which may be passed to high-level @@ -5588,7 +5484,8 @@ Figure title, placed at the top of the plot in a large font. Sub-title, placed just below the @math{x}-axis in a smaller font. @end table -@node Low-level plotting commands, Interacting with graphics, High-level plotting commands, Graphics + +@node Low-level plotting commands @section Low-level plotting commands Sometimes the high-level plotting functions don't produce exactly the @@ -5692,12 +5589,8 @@ sufficient to supply a single argument being a list with elements named valid input. In this way functions such as @code{locator()} (see below) may be used to specify positions on a plot interactively. -@menu -* Mathematical annotation:: -* Hershey vector fonts:: -@end menu -@node Mathematical annotation, Hershey vector fonts, Low-level plotting commands, Low-level plotting commands +@node Mathematical annotation @subsection Mathematical annotation In some cases, it is useful to add mathematical symbols and formulae to a @@ -5719,7 +5612,7 @@ obtained from within @R{} using the commands: > demo(plotmath) @end example -@node Hershey vector fonts, , Mathematical annotation, Low-level plotting commands +@node Hershey vector fonts @subsection Hershey vector fonts It is possible to specify Hershey vector fonts for rendering text when using @@ -5748,7 +5641,8 @@ within @R{} using the commands: > demo(Japanese) @end example -@node Interacting with graphics, Using graphics parameters, Low-level plotting commands, Graphics + +@node Interacting with graphics @section Interacting with graphics @R{} also provides functions which allow users to extract or add @@ -5815,7 +5709,8 @@ terminated (see above), @code{identify()} returns the indices of the selected points; you can use these indices to extract the selected points from the original vectors @code{x} and @code{y}. -@node Using graphics parameters, Graphics parameters, Interacting with graphics, Graphics + +@node Using graphics parameters @section Using graphics parameters When creating graphics, particularly for presentation or publication @@ -5833,12 +5728,8 @@ initialized. Graphics parameters can be set in two ways: either permanently, affecting all graphics functions which access the current device; or temporarily, affecting only a single graphics function call. -@menu -* The par() function:: -* Arguments to graphics functions:: -@end menu -@node The par() function, Arguments to graphics functions, Using graphics parameters, Using graphics parameters +@node The par() function @subsection Permanent changes: The @code{par()} function @findex par @cindex Graphics parameters @@ -5892,8 +5783,7 @@ only.} graphical parameters use > par(oldpar) @end example - -@node Arguments to graphics functions, , The par() function, Using graphics parameters +@node Arguments to graphics functions @subsection Temporary changes: Arguments to graphics functions Graphics parameters may also be passed to (almost) any graphics function @@ -5914,7 +5804,7 @@ sometimes necessary to set and reset graphics parameters using @code{par()}. -@node Graphics parameters, Device drivers, Using graphics parameters, Graphics +@node Graphics parameters @section Graphics parameters list The following sections detail many of the commonly-used graphical @@ -5935,14 +5825,8 @@ setting the parameter. Note that @code{axes} is @strong{not} a graphics parameter but an argument to a few @code{plot} methods: see @code{xaxt} and @code{yaxt}. -@menu -* Graphical elements:: -* Axes and tick marks:: -* Figure margins:: -* Multiple figure environment:: -@end menu -@node Graphical elements, Axes and tick marks, Graphics parameters, Graphics parameters +@node Graphical elements @subsection Graphical elements @R{} plots are made up of points, lines, text and polygons (filled @@ -6036,7 +5920,7 @@ The character expansion to be used for axis annotation, @math{x} and @math{y} labels, main and sub-titles, respectively. @end table -@node Axes and tick marks, Figure margins, Graphical elements, Graphics parameters +@node Axes and tick marks @subsection Axes and tick marks Many of @R{}'s high-level plots have axes, and you can construct axes @@ -6090,10 +5974,9 @@ leaves a small amount of space at the edges. @c series of fixed-scale plots. @end table -@node Figure margins, Multiple figure environment, Axes and tick marks, Graphics parameters +@node Figure margins @subsection Figure margins - A single plot in @R{} is known as a @code{figure} and comprises a @emph{plot region} surrounded by margins (possibly containing axis labels, titles, etc.) and (usually) bounded by the axes themselves. @@ -6127,7 +6010,7 @@ with the @code{height=4} argument will result in a plot which is about multiple figures are in use (see below) the margins are reduced, however this may not be enough when many figures share the same page. -@node Multiple figure environment, , Figure margins, Graphics parameters +@node Multiple figure environment @subsection Multiple figure environment @R{} allows you to create an @math{n} by @math{m} array of figures on a @@ -6193,7 +6076,8 @@ More complicated arrangements of multiple figures can be produced by the @code{split.screen()} and @code{layout()} functions, as well as by the @pkg{grid} and @CRANpkg{lattice} packages. -@node Device drivers, Dynamic graphics, Graphics parameters, Graphics + +@node Device drivers @section Device drivers @cindex Graphics device drivers @@ -6254,12 +6138,8 @@ of hardcopy devices this ensures that every page is completed and has been sent to the printer. (This will happen automatically at the normal end of a session.) -@menu -* PostScript diagrams for typeset documents:: -* Multiple graphics devices:: -@end menu -@node PostScript diagrams for typeset documents, Multiple graphics devices, Device drivers, Device drivers +@node PostScript diagrams for typeset documents @subsection PostScript diagrams for typeset documents By passing the @code{file} argument to the @code{postscript()} device @@ -6294,8 +6174,7 @@ specification). Thus to produce a plot for inclusion use something like height=8, width=6, pointsize=10) @end example - -@node Multiple graphics devices, , PostScript diagrams for typeset documents, Device drivers +@node Multiple graphics devices @subsection Multiple graphics devices In advanced use of @R{} it is often useful to have several graphics @@ -6364,7 +6243,8 @@ printing hardcopies, are immediately performed. Terminate all graphics devices on the list, except the null device. @end table -@node Dynamic graphics, , Device drivers, Graphics + +@node Dynamic graphics @section Dynamic graphics @cindex Dynamic graphics @@ -6385,7 +6265,9 @@ and these can be accessed from @R{} via the package @CRANpkg{rggobi}, described Also, package @CRANpkg{rgl} provides ways to interact with 3D plots, for example of surfaces. -@node Packages, OS facilities, Graphics, Top + + +@node Packages @chapter Packages @cindex Packages @@ -6446,13 +6328,8 @@ use to start the @HTML{} help system, and then navigate to the package listing in the @code{Reference} section. -@menu -* Standard packages:: -* Contributed packages and CRAN:: -* Namespaces:: -@end menu -@node Standard packages, Contributed packages and CRAN, Packages, Packages +@node Standard packages @section Standard packages The standard (or @emph{base}) packages are considered part of the @R{} @@ -6464,7 +6341,7 @@ For a complete list, see @ref{Which add-on packages exist for R?, , , R-FAQ, R FAQ}. -@node Contributed packages and CRAN, Namespaces, Standard packages, Packages +@node Contributed packages and CRAN @section Contributed packages and @acronym{CRAN} @cindex CRAN @@ -6481,7 +6358,8 @@ The @emph{R FAQ} contains a list of CRAN packages current at the time of release, but the collection of available packages changes very frequently. -@node Namespaces, , Contributed packages and CRAN, Packages + +@node Namespaces @section Namespaces @cindex Namespace @findex :: @@ -6516,7 +6394,9 @@ cause automatic loading of the associated package. When packages with namespaces are loaded automatically they are not added to the search list. -@node OS facilities, A sample session, Packages, Top + + +@node OS facilities @chapter OS facilities @R{} has quite extensive facilities to access the OS under which it is @@ -6527,14 +6407,8 @@ Because @R{}'s own scripts need to work across all platforms, considerable effort has gone into make the scripting facilities as platform-independent as is feasible. -@menu -* Files and directories:: -* Filepaths:: -* System commands:: -* Compression and Archives:: -@end menu -@node Files and directories, Filepaths, OS facilities, OS facilities +@node Files and directories @section Files and directories There are many functions to manipulate files and directories. Here are @@ -6579,7 +6453,7 @@ There is some support for @emph{links} in the filesystem: see functions @code{file.link} and @code{Sys.readlink}. -@node Filepaths, System commands, Files and directories, OS facilities +@node Filepaths @section Filepaths With a few exceptions, @R{} relies on the underlying OS functions to @@ -6654,7 +6528,8 @@ session) are recognized. Access Control Lists (@abbr{ACL}s) are employed on several filesystems, but do not have an agreed standard and @R{} has no facilities to control them. Use @code{Sys.chmod} to change permissions. -@node System commands, Compression and Archives, Filepaths, OS facilities + +@node System commands @section System commands Functions @code{system} and @code{system2} are used to invoke a system @@ -6674,7 +6549,8 @@ standard OS service). Function @code{shQuote} will quote filepaths as needed for commands in the current OS. -@node Compression and Archives, , System commands, OS facilities + +@node Compression and Archives @section Compression and Archives Recent versions of @R{} have extensive facilities to read and write @@ -6704,7 +6580,9 @@ most common ones being `tarballs' and zip files as used to distribute and @code{unzip}) and create both (for @command{zip} with the help of an external program). -@node A sample session, Invoking R, OS facilities, Top + + +@node A sample session @appendix A sample session The following session is intended to introduce to you some features of @@ -6936,20 +6814,16 @@ workspace, and for an exploratory session like this, you probably do not want to save it. @end table -@node Invoking R, The command-line editor, A sample session, Top + + +@node Invoking R @appendix Invoking R Users of @R{} on Windows or macOS should read the OS-specific section first, but command-line use is also supported. -@menu -* Invoking R from the command line:: -* Invoking R under Windows:: -* Invoking R under macOS:: -* Scripting with R:: -@end menu -@node Invoking R from the command line, Invoking R under Windows, Invoking R, Invoking R +@node Invoking R from the command line @appendixsec Invoking R from the command line When working at a command line on UNIX or Windows, the command @samp{R} @@ -7280,8 +7154,7 @@ or the specific commands run under, for example to run @command{ldd} or batch file, or if it has extension @code{.sh} or @code{.pl} the appropriate interpreter (if available) is called to run it. - -@node Invoking R under Windows, Invoking R under macOS, Invoking R from the command line, Invoking R +@node Invoking R under Windows @appendixsec Invoking R under Windows There are two ways to run @R{} under Windows. Within a terminal window @@ -7351,7 +7224,7 @@ will run @LaTeX{} on @file{mydoc.tex}, with the path to @R{}'s this does not help with the @I{MiKTeX} build of @LaTeX{}, but @command{R CMD texify mydoc} will work in that case.) -@node Invoking R under macOS, Scripting with R, Invoking R under Windows, Invoking R +@node Invoking R under macOS @appendixsec Invoking R under macOS There are two ways to run @R{} under macOS. Within a @code{Terminal.app} @@ -7367,7 +7240,7 @@ current working directory are set as the user's home directory unless a different startup directory is given in the Preferences window accessible from within the GUI. -@node Scripting with R, , Invoking R under macOS, Invoking R +@node Scripting with R @appendixsec Scripting with R If you just want to run a file @file{foo.R} of @R{} commands, the @@ -7477,7 +7350,8 @@ Note that on a Unix-alike the input filename (such as @file{foo.R}) should not contain spaces nor shell metacharacters. -@node The command-line editor, Function and variable index, Invoking R, Top + +@node The command-line editor @appendix The command-line editor @appendixsection Preliminaries @@ -7621,18 +7495,10 @@ $if R $endif @end example -@node Function and variable index, Concept index, The command-line editor, Top -@appendix Function and variable index - -@printindex vr - -@node Concept index, References, Function and variable index, Top -@appendix Concept index -@printindex cp -@node References, , Concept index, Top -@appendix References +@node References +@unnumbered References @I{D.@: M.@: Bates} and @I{D.@: G.@: Watts} (1988), @emph{Nonlinear Regression Analysis and Its Applications.} @@ -7681,4 +7547,17 @@ Second edition. @I{Duxbury Press}, Belmont, CA. @emph{Statistical Inference.} Penguin, London. + +@node Function and variable index +@unnumbered Function and variable index + +@printindex vr + + +@node Concept index +@unnumbered Concept index + +@printindex cp + + @bye diff --git a/doc/manual/R-ints.texi b/doc/manual/R-ints.texi index 518aefa7bdf..d9a48a61e58 100644 --- a/doc/manual/R-ints.texi +++ b/doc/manual/R-ints.texi @@ -2,7 +2,6 @@ @c %**start of header @setfilename R-ints.info @settitle R Internals -@setchapternewpage on @c %**end of header @syncodeindex fn vr @@ -45,7 +44,7 @@ This manual is for R, version @value{VERSION}. @c @end ifnothtml @ifnottex -@node Top, R Internal Structures, (dir), (dir) +@node Top @top R Internals This is a guide to the internal structures of @R{} and coding standards for @@ -55,25 +54,9 @@ the core team working on @R{} itself. @end ifnottex -@menu -* R Internal Structures:: -* .Internal vs .Primitive:: -* Internationalization in the R sources:: -* Package Structure:: -* Files:: -* Graphics Devices:: -* GUI consoles:: -* Tools:: -* R coding standards:: -* Testing R code:: -* Use of TeX dialects:: -* Current and future directions:: -* Function and variable index:: -* Concept index:: -@end menu -@c Could have (autogenerated) @detailmenu here .. -@node R Internal Structures, .Internal vs .Primitive, Top, Top + +@node R Internal Structures @chapter R Internal Structures This chapter is the beginnings of documentation about @R{} internal @@ -85,27 +68,8 @@ version of the source code. Versions for @R{} 2.x.y contain historical comments about when features were introduced: this version is for the 3.x.y series. -@menu -* SEXPs:: -* Environments and variable lookup:: -* Attributes:: -* Contexts:: -* Argument evaluation:: -* Autoprinting:: -* The write barrier:: -* Serialization Formats:: -* Encodings for CHARSXPs:: -* The CHARSXP cache:: -* Warnings and errors:: -* S4 objects:: -* Memory allocators:: -* Internal use of global and base environments:: -* Modules:: -* Visibility:: -* Lazy loading:: -@end menu -@node SEXPs, Environments and variable lookup, R Internal Structures, R Internal Structures +@node SEXPs @section @I{SEXPs} @cindex @I{SEXP} @@ -134,14 +98,8 @@ bytes (depending on alignment constraints). The first five bits of the @code{sxpinfo} header specify one of up to 32 @code{SEXPTYPE}s. -@menu -* SEXPTYPEs:: -* Rest of header:: -* The 'data':: -* Allocation classes:: -@end menu -@node SEXPTYPEs, Rest of header, SEXPs, SEXPs +@node SEXPTYPEs @subsection @I{SEXPTYPE}s @cindex @I{SEXPTYPE} @@ -219,8 +177,7 @@ have formals, body and environment. The @code{SEXPTYPE} @code{OBJSXP} is for S4 and other objects which do not consist solely of a simple type such as an atomic vector or function. - -@node Rest of header, The 'data', SEXPTYPEs, SEXPs +@node Rest of header @subsection Rest of header Note that the size and structure of the header changed in @R{} 3.5.0: @@ -267,12 +224,15 @@ debugging. @findex SET_NAMED @cindex copying semantics The @code{named} field is set and accessed by the @code{SET_NAMED} and -@code{NAMED} macros, and take values @code{0}, @code{1} and @code{2}, or +@code{NAMED} macros, and takes values @code{0}, @code{1} and @code{2}, or possibly higher if @code{NAMEDMAX} is set to a higher value. @R{} has a `call by value' illusion, so an assignment like + @example b <- a @end example + +@c FIXME: [The @code{NAMED} mechanism has been replaced by reference counting.] @noindent @@ -303,8 +263,7 @@ a <- `dim<-`(a, c(7, 2)) @noindent but for no longer, and so some primitive functions can be optimized to -avoid a copy in this case. [This mechanism is scheduled to be replaced -in @R{} 4.0.0.] +avoid a copy in this case. The @code{gp} bits are by definition `general purpose'. We label these from 0 to 15. Bits 0--5 and bits 14--15 have been used as described below @@ -377,7 +336,7 @@ that is @code{NA_STRING} or is in the @code{CHARSXP} cache (this is not serialized). Only exceptionally is a @code{CHARSXP} not hashed, and this should never happen in end-user code. -@node The 'data', Allocation classes, Rest of header, SEXPs +@node The 'data' @subsection The `data' A @code{SEXPREC} is a C structure containing the 64-bit header as @@ -519,7 +478,7 @@ and the @samp{finalizer} is a function or @code{NULL}. two unused pointers and a tag. @end table -@node Allocation classes, , The 'data', SEXPs +@node Allocation classes @subsection Allocation classes @cindex allocation classes @@ -536,7 +495,7 @@ since their memory semantics is not under R's control and may be non-standard (e.g., memory could be partially shared across nodes). -@node Environments and variable lookup, Attributes, SEXPs, R Internal Structures +@node Environments and variable lookup @section Environments and variable lookup @cindex environment @@ -581,13 +540,8 @@ that.} which have been @code{attach}ed. When an environment is either from the cache. The cache is used whenever searching for variables from the global environment (possibly as part of a recursive search). -@menu -* Search paths:: -* Namespaces:: -* Hash table:: -@end menu -@node Search paths, Namespaces, Environments and variable lookup, Environments and variable lookup +@node Search paths @subsection Search paths @cindex search path @@ -616,7 +570,7 @@ the empty environment, but with an optimization to stop at the base environment.) So the `search path' describes the chain of environments which is traversed once the search reaches the global environment. -@node Namespaces, Hash table, Search paths, Environments and variable lookup +@node Namespaces @subsection Namespaces @cindex namespace @@ -649,7 +603,7 @@ enclosure is the global environment rather than the empty environment: the internal code diverts lookups in its frame to the global symbol table. -@node Hash table, , Namespaces, Environments and variable lookup +@node Hash table @subsection Hash table Environments in @R{} usually have a hash table, and nowadays that is the @@ -675,7 +629,7 @@ added to but rarely deleted from, so items are not actually deleted but have their value set to @code{R_UnboundValue}. -@node Attributes, Contexts, Environments and variable lookup, R Internal Structures +@node Attributes @section Attributes @cindex attributes @@ -780,7 +734,7 @@ attr(,"comm") @end example -@node Contexts, Argument evaluation, Attributes, R Internal Structures +@node Contexts @section Contexts @cindex context @@ -880,7 +834,7 @@ errors, e.g.@: free buffers) and within the error handling code (to raise the C stack limit and reset some variables). -@node Argument evaluation, Autoprinting, Contexts, R Internal Structures +@node Argument evaluation @section Argument evaluation @cindex argument evaluation @@ -958,12 +912,8 @@ allowing only one argument, some having two (with a default for the second) and @code{trunc} allows one or more but the default method only accepts one. -@menu -* Missingness:: -* Dot-dot-dot arguments:: -@end menu -@node Missingness, Dot-dot-dot arguments, Argument evaluation, Argument evaluation +@node Missingness @subsection Missingness @cindex missingness @@ -1008,7 +958,7 @@ case (e.g.@: @code{log}) that is why they are special and not builtin. This is usually done by testing if an argument's value is @code{R_MissingArg}. -@node Dot-dot-dot arguments, , Missingness, Argument evaluation +@node Dot-dot-dot arguments @subsection Dot-dot-dot arguments @cindex ... argument @@ -1036,7 +986,8 @@ Special primitives may need to handle @code{...} arguments: see for example the internal code of @code{switch} in file @file{src/main/builtin.c}. -@node Autoprinting, The write barrier, Argument evaluation, R Internal Structures + +@node Autoprinting @section @I{Autoprinting} @cindex @I{autoprinting} @@ -1091,7 +1042,7 @@ for objects without a class the internal code of @code{print.default} is called. -@node The write barrier, Serialization Formats, Autoprinting, R Internal Structures +@node The write barrier @section The write barrier and the garbage collector @cindex write barrier @@ -1136,7 +1087,8 @@ For background papers see @uref{https://homepage.stat.uiowa.edu/~luke/R/barrier.html} and @uref{https://homepage.stat.uiowa.edu/~luke/R/gengcnotes.html}. -@node Serialization Formats, Encodings for CHARSXPs, The write barrier, R Internal Structures + +@node Serialization Formats @section Serialization Formats @cindex serialization @@ -1250,7 +1202,8 @@ serialization of @code{ALTREP} framework objects. It also stores the current native encoding at serialization time, so that unflagged strings can be converted if unserialized in R running under different native encoding. -@node Encodings for CHARSXPs, The CHARSXP cache, Serialization Formats, R Internal Structures + +@node Encodings for CHARSXPs @section Encodings for @code{CHARSXP}s Character data in @R{} are stored in the @code{SEXPTYPE} @code{CHARSXP}. @@ -1360,7 +1313,8 @@ the native encoding cannot be UTF-8. R 4.2 requires @abbr{UCRT} to work, but @ab can be installed on Windows since Vista SP2 and Windows Server 2008 SP2. It is shipped with Windows since Windows 10 and Windows Server 2016. -@node The CHARSXP cache, Warnings and errors, Encodings for CHARSXPs, R Internal Structures + +@node The CHARSXP cache @section The @code{CHARSXP} cache @findex mkChar @@ -1379,7 +1333,7 @@ requests to create a @code{CHARSXP} should be @emph{via} a call to be ignored if the string's bytes are all @acronym{ASCII} characters. -@node Warnings and errors, S4 objects, The CHARSXP cache, R Internal Structures +@node Warnings and errors @section Warnings and errors @findex warning @@ -1428,22 +1382,16 @@ should be used. (The results for @code{.Internal} replacement functions such as @code{substr<-} are not ideal.) - -@node S4 objects, Memory allocators, Warnings and errors, R Internal Structures +@node S4 objects @section S4 objects +@c FIXME: [This section is currently a preliminary draft and should not be taken as definitive. The description assumes that @env{R_NO_METHODS_TABLES} has not been set.] -@menu -* Representation of S4 objects:: -* S4 classes:: -* S4 methods:: -* Mechanics of S4 dispatch:: -@end menu -@node Representation of S4 objects, S4 classes, S4 objects, S4 objects +@node Representation of S4 objects @subsection Representation of S4 objects S4 objects can be of any @code{SEXPTYPE}. They are either an object of @@ -1464,7 +1412,7 @@ have a class attribute, the @code{OBJECT} bit is set. It is currently unclear what should happen if the class attribute is removed from an S4 object, or if this should be allowed. -@node S4 classes, S4 methods, Representation of S4 objects, S4 objects +@node S4 classes @subsection S4 classes S4 classes are stored as @R{} objects in the environment in which they @@ -1481,7 +1429,7 @@ objects. The directives @code{importClassesFrom} and objects without needing to know their internal `@I{metaname}' (although @code{exportClasses} does a little sanity checking via @code{isClass}). -@node S4 methods, Mechanics of S4 dispatch, S4 classes, S4 objects +@node S4 methods @subsection S4 methods Details of the methods are stored in environments (typically hidden in the @@ -1531,8 +1479,7 @@ When a package is attached @code{methods:::cacheMetaData} is called to update the internal tables: only the visible methods will be cached. - -@node Mechanics of S4 dispatch, , S4 methods, S4 objects +@node Mechanics of S4 dispatch @subsection Mechanics of S4 dispatch This subsection does not discuss how S4 methods are chosen: see @@ -1600,7 +1547,8 @@ generics and a short exceptions list in file @file{BasicFunsList.R}: this currently contains the subsetting and @I{subassignment} operators and an override for @code{c}. -@node Memory allocators, Internal use of global and base environments, S4 objects, R Internal Structures + +@node Memory allocators @section Memory allocators @R{}'s memory allocation is almost all done via routines in file @@ -1709,11 +1657,12 @@ static R_StringBuffer ex_buff = @{NULL, 0, MAXELTSIZE@}; @end example +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Internals of R_alloc:: @end menu -@node Internals of R_alloc, , Memory allocators, Memory allocators +@node Internals of R_alloc @subsection Internals of @code{R_alloc} The memory used by @code{R_alloc} is allocated as @R{} vectors, of type @@ -1734,18 +1683,15 @@ value that has previously be obtained @emph{via} @code{vmaxget}: allocations after the value was obtained will no longer be protected and hence available for garbage collection. -@node Internal use of global and base environments, Modules, Memory allocators, R Internal Structures + +@node Internal use of global and base environments @section Internal use of global and base environments This section notes known use by the system of these environments: the intention is to minimize or eliminate such uses. -@menu -* Base environment:: -* Global environment:: -@end menu -@node Base environment, Global environment, Internal use of global and base environments, Internal use of global and base environments +@node Base environment @subsection Base environment @cindex base environment @@ -1772,7 +1718,7 @@ appears as a variable in the base environment. Errors can give rise to objects @code{.Traceback} and @code{last.warning} in the base environment. -@node Global environment, , Base environment, Internal use of global and base environments +@node Global environment @subsection Global environment @cindex global environment @@ -1791,7 +1737,7 @@ to store display lists of saved plots for later display. This is regarded as a variable created by the user. -@node Modules, Visibility, Internal use of global and base environments, R Internal Structures +@node Modules @section Modules @cindex modules @@ -1822,16 +1768,13 @@ the @code{X11}, @code{pango}, @code{cairo}, @code{jpeg}, @code{libpng} and @code{libtiff} libraries. @end table -@node Visibility, Lazy loading, Modules, R Internal Structures + +@node Visibility @section Visibility @cindex visibility -@menu -* Hiding C entry points:: -* Variables in Windows DLLs:: -@end menu -@node Hiding C entry points, Variables in Windows DLLs, Visibility, Visibility +@node Hiding C entry points @subsection Hiding C entry points We make use of the visibility mechanisms discussed in @@ -1877,7 +1820,7 @@ Unix-alike can be made by something like nm -g libR.so | grep ' [BCDT] ' | cut -b20- @end example -@node Variables in Windows DLLs, , Hiding C entry points, Visibility +@node Variables in Windows DLLs @subsection Variables in Windows DLLs Windows is unique in that it conventionally treats importing variables @@ -1904,7 +1847,8 @@ other Windows compiler suites. It is only possible to check if this has been handled correctly by compiling the @R{} sources on Windows. -@node Lazy loading, , Visibility, R Internal Structures + +@node Lazy loading @section Lazy loading Lazy loading is always used for code in packages but is optional @@ -1976,7 +1920,9 @@ The same database mechanism is used to store parsed @file{Rd} files. One or all of the parsed objects is fetched by a call to @code{tools:::fetchRdDB}. -@node .Internal vs .Primitive, Internationalization in the R sources, R Internal Structures, Top + + +@node .Internal vs .Primitive @chapter @code{.Internal} vs @code{.Primitive} @findex .Internal @@ -2231,14 +2177,8 @@ end-user use @emph{as functions} is done in the same way as for interpreted functions except for the six exceptions where positional matching is required. -@menu -* Special primitives:: -* Special internals:: -* Prototypes for primitives:: -* Adding a primitive:: -@end menu -@node Special primitives, Special internals, .Internal vs .Primitive, .Internal vs .Primitive +@node Special primitives @section Special primitives A small number of primitives are @emph{specials} rather than @@ -2264,7 +2204,8 @@ arguments.) @code{UseMethod} is special to avoid the additional contexts added to calls to builtins. -@node Special internals, Prototypes for primitives, Special primitives, .Internal vs .Primitive + +@node Special internals @section Special internals There are also special @code{.Internal} functions: @code{NextMethod}, @@ -2272,7 +2213,8 @@ There are also special @code{.Internal} functions: @code{NextMethod}, for the @code{deparse.level} argument), @code{eapply}, @code{lapply} and @code{vapply}. -@node Prototypes for primitives, Adding a primitive, Special internals, .Internal vs .Primitive + +@node Prototypes for primitives @section Prototypes for primitives Prototypes are available for the primitive functions and operators, and @@ -2331,7 +2273,8 @@ this can fail for other reasons). However, there is no certain way to know that if other @code{.Internal} or primitive functions are not internally generic except by reading the source code. -@node Adding a primitive, , Prototypes for primitives, .Internal vs .Primitive + +@node Adding a primitive @section Adding a primitive [For R-core use: reverse this procedure to remove a primitive. Most @@ -2364,7 +2307,9 @@ for those with a single argument, add argument-name checking. Do ensure that @command{make check-devel} has been run: that tests most of these requirements. -@node Internationalization in the R sources, Package Structure, .Internal vs .Primitive, Top + + +@node Internationalization in the R sources @chapter Internationalization in the R sources The process of marking messages (errors, warnings etc) for translation @@ -2374,15 +2319,8 @@ and the standard packages included with @R{} have (with an exception in @pkg{grDevices} for the menus of the @code{windows()} device) been internationalized in the same way as other packages. -@menu -* R code:: -* Main C code:: -* Windows-GUI-specific code:: -* macOS GUI:: -* Updating:: -@end menu -@node R code, Main C code, Internationalization in the R sources, Internationalization in the R sources +@node R code @section R code Internationalization for @R{} code is done in exactly the same way as @@ -2399,7 +2337,8 @@ compiled translations under @file{inst/po} for installation to package directory @file{po} in the installed package. This also applies to C code in packages. -@node Main C code, Windows-GUI-specific code, R code, Internationalization in the R sources + +@node Main C code @section Main C code The main C code (e.g.@: that in files @file{src/*/*.c} and in @@ -2445,7 +2384,7 @@ The macro @code{_("msg")} can safely be used in directory translation. (This does not apply to @code{N_} or @code{P_}). -@node Windows-GUI-specific code, macOS GUI, Main C code, Internationalization in the R sources +@node Windows-GUI-specific code @section Windows-GUI-specific code Messages for the Windows GUI are in a separate domain @samp{RGui}. This @@ -2476,25 +2415,23 @@ The template and message catalogs for the @samp{RGui} domain are in the top-level @file{po} directory of package @pkg{base}. -@node macOS GUI, Updating, Windows-GUI-specific code, Internationalization in the R sources +@node macOS GUI @section macOS GUI This is handled separately: see @uref{https://developer.r-project.org/Translations30.html}. -@node Updating, , macOS GUI, Internationalization in the R sources +@node Updating @section Updating See file @file{po/README} for how to update the message templates and catalogs. -@node Package Structure, Files, Internationalization in the R sources, Top + + +@node Package Structure @chapter Structure of an Installed Package -@menu -* Metadata:: -* Help:: -@end menu The structure of @emph{source} packages is described in @ref{Creating R packages, , , R-exts, Writing R Extensions}: @@ -2543,7 +2480,8 @@ copied from the sources. Subdirectory @file{po} contains (in subdirectories) compiled message catalogs. -@node Metadata, Help, Package Structure, Package Structure + +@node Metadata @section Metadata Directory @file{Meta} contains several files in @code{.rds} format, that @@ -2615,7 +2553,7 @@ present), @samp{Depends}, @samp{Keywords} and @samp{R} (the pathless file name of the installed @R{} code, if present). -@node Help, , Metadata, Package Structure +@node Help @section Help All installed packages, whether they had any @file{.Rd} files or not, @@ -2641,7 +2579,9 @@ File @file{aliases.rds} is the same information as @file{AnIndex} as a named character vector (names the topics, values the file basename), for faster access. -@node Files, Graphics Devices, Package Structure, Top + + +@node Files @chapter Files @R{} provides many functions to work with files and directories: many of @@ -2727,7 +2667,8 @@ path specifications (the last being the current directory on drive @c unlink Wchar ~ -@node Graphics Devices, GUI consoles, Files, Top + +@node Graphics Devices @chapter Graphics @R{}'s graphics internals were re-designed to enable multiple graphics @@ -2848,14 +2789,8 @@ for use with @pkg{grid}, and hence has been transferred from package @pkg{graphics} to @pkg{grDevices}. This is principally concerned with the handling of colours and recording and replaying plots. -@menu -* Graphics devices:: -* Colours:: -* Base graphics:: -* Grid graphics:: -@end menu -@node Graphics devices, Colours, Graphics Devices, Graphics Devices +@node Graphics devices @section Graphics Devices @R{} ships with several graphics devices, and there is support for @@ -2863,17 +2798,8 @@ third-party packages to provide additional devices---several packages now do. This section describes the device internals from the viewpoint of a would-be writer of a graphics device. -@menu -* Device structures:: -* Device capabilities:: -* Handling text:: -* Conventions:: -* 'Mode':: -* Graphics events:: -* Specific devices:: -@end menu -@node Device structures, Device capabilities, Graphics devices, Graphics devices +@node Device structures @subsection Device structures There are two types used internally which are pointers to structures @@ -2989,7 +2915,7 @@ there is no need for a device driver to use not make use of callbacks from an API version above the version that is supported by the device. -@node Device capabilities, Handling text, Device structures, Graphics devices +@node Device capabilities @subsection Device capabilities The following `capabilities' can be defined for the device's @@ -3128,7 +3054,7 @@ component of the list of capabilities. It is valid (if unhelpful) for the device driver to return the list of capabilities unaltered. -@node Handling text, Conventions, Device capabilities, Graphics devices +@node Handling text @subsection Handling text Handling text is probably the hardest task for a graphics device, and @@ -3301,7 +3227,7 @@ This instructs the device to draw a specific glyph within a given font, where the font is specified by filename (and index), with font family, weight, and style also provided as fallbacks. -@node Conventions, 'Mode', Handling text, Graphics devices +@node Conventions @subsection Conventions The aim is to make the (default) output from graphics devices as similar @@ -3355,8 +3281,7 @@ in the header @file{GraphicsEngine.h} and in the help for @code{par}: note that `scale' of the pattern should be proportional to the line width (at least for widths above the default). - -@node 'Mode', Graphics events, Conventions, Graphics devices +@node 'Mode' @subsection `Mode' One of the device callbacks is a function @code{mode}, documented in @@ -3387,7 +3312,7 @@ activity: it updates the screen after @emph{ca} 100ms of inactivity. This callback need not be supplied if it does nothing. -@node Graphics events, Specific devices, 'Mode', Graphics devices +@node Graphics events @subsection Graphics events Graphics devices may be designed to handle user interaction: not all are. @@ -3409,7 +3334,7 @@ provided to call the R event handlers @code{onMouseDown}, called again with @code{init=false} to inform the devices that the loop is done, and the result is returned to the user. -@node Specific devices, , Graphics events, Graphics devices +@node Specific devices @subsection Specific devices Specific devices are mostly documented by comments in their sources, @@ -3417,12 +3342,7 @@ although for devices of many years' standing those comments can be in need of updating. This subsection is a repository of notes on design decisions. -@menu -* X11():: -* windows():: -@end menu - -@node X11(), windows(), Specific devices, Specific devices +@node X11() @subsubsection X11() The @code{X11(type="Xlib")} device dates back to the mid 1990's and was @@ -3467,8 +3387,7 @@ and text. @I{Pango}'s font management is based on @code{fontconfig} and somewhat mysterious, but it seems mainly to use Type 1 and @I{TrueType} fonts on the machine running @R{} and send grayscale bitmaps to @I{cairo}. - -@node windows(), , X11(), Specific devices +@node windows() @subsubsection windows() The @code{windows()} device is a family of devices: it supports plotting @@ -3543,7 +3462,7 @@ available then we could add a full alpha channel, but this is dependent on the graphics hardware and undocumented properties of @abbr{GDI}. -@node Colours, Base graphics, Graphics devices, Graphics Devices +@node Colours @section Colours Devices receive colours as a @code{typedef} @code{rcolor} (an @@ -3631,7 +3550,8 @@ which takes a colour name (a C string) and returns a value of type @code{rcolor}. This handles @code{"NA"}, @code{"transparent"} and the 657 colours known to the @R{} function @code{colors()}. -@node Base graphics, Grid graphics, Colours, Graphics Devices + +@node Base graphics @section Base graphics The base graphics system was migrated to package @pkg{graphics} in @R{} @@ -3680,11 +3600,13 @@ high-level graphics calls (handled by @code{ProcessInlinePars}). Snapshots of the base subsystem record the `saved device copy' of the @code{GPar} structure. + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * Arguments and parameters:: @end menu -@node Arguments and parameters, , Base graphics, Base graphics +@node Arguments and parameters @subsection Arguments and parameters There is an unfortunate confusion between some of the graphical @@ -3724,12 +3646,16 @@ the graphics engine (but for example the handling of @code{lwd = 0} remains device-specific, with some interpreting it as a `thinnest possible' line). -@node Grid graphics, , Base graphics, Graphics Devices + +@node Grid graphics @section Grid graphics +@c FIXME: [At least pointers to documentation.] -@node GUI consoles, Tools, Graphics Devices, Top + + +@node GUI consoles @chapter GUI consoles The standard @R{} front-ends are programs which run in a terminal, but @@ -3751,11 +3677,13 @@ program which runs embedded @R{}: this is done by @command{Rgui.exe} on Windows and @command{R.app} on macOS. The first is an integral part of @R{} and the code for the console is currently in @file{R.dll}. + +@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @menu * R.app:: @end menu -@node R.app, , GUI consoles, GUI consoles +@node R.app @section R.app @command{R.app} is a macOS application which provides a console. Its @@ -3890,7 +3818,7 @@ ignored. (It seems that in 2003, @samp{r27492}, this was added by Finder.) -@node Tools, R coding standards, GUI consoles, Top +@node Tools @chapter Tools The behavior of @command{R CMD check} can be controlled through a @@ -4768,7 +4696,9 @@ Default: true (false only for special applications, which analyze native code of packages). @end vtable -@node R coding standards, Testing R code, Tools, Top + + +@node R coding standards @chapter R coding standards @cindex coding standards @@ -4899,7 +4829,9 @@ their startup files, and using customization to set the which has been determined not to display the structure clearly enough when using narrow fonts.) -@node Testing R code, Use of TeX dialects, R coding standards, Top + + +@node Testing R code @chapter Testing R code When you (as @R{} developer) add new functions to the R base (all the @@ -4910,10 +4842,13 @@ computer). If the new function, for example, accesses the Internet, or requires @acronym{GUI} interaction, please add its name to the ``stop list'' in @file{tests/no-segfault.Rin}. +@c FIXME: [To be revised: use @command{make check-devel}, check the write barrier if you change internal structures.] -@node Use of TeX dialects, Current and future directions, Testing R code, Top + + +@node Use of TeX dialects @chapter Use of TeX dialects Various dialects of TeX are used for different purposes in @R{}. The @@ -4957,20 +4892,16 @@ at run time. The latter can be important for binary distributions: one does not want to be tied to, for example, TeX Live 2007. -@node Current and future directions, Function and variable index, Use of TeX dialects, Top + +@node Current and future directions @chapter Current and future directions This chapter is for notes about possible in-progress and future changes to @R{}: there is no commitment to release such changes, let alone to a timescale. -@menu -* Long vectors:: -* 64-bit types:: -* Large matrices:: -@end menu -@node Long vectors, 64-bit types, Current and future directions, Current and future directions +@node Long vectors @section Long vectors Vectors in @R{} 2.x.y were limited to a length of 2^31 - 1 elements @@ -5036,7 +4967,8 @@ to @code{.C}/@code{.Fortran} should checks for an @code{NA} result. @end itemize -@node 64-bit types, Large matrices, Long vectors, Current and future directions + +@node 64-bit types @section 64-bit types There is also some desire to be able to store larger integers in @R{}, @@ -5085,10 +5017,10 @@ uses.} The current approach is to keep these returning 32-bit lengths and introduce `long' versions @code{xlength} and @code{XLENGTH} which return @code{R_xlen_t} values. - See also @uref{https://homepage.cs.uiowa.edu/~luke/talks/useR10.pdf}. -@node Large matrices, , 64-bit types, Current and future directions + +@node Large matrices @section Large matrices Matrices are stored as vectors and so were also limited to 2^31-1 @@ -5120,17 +5052,18 @@ machine with a lot of RAM (100s of gigabytes), many cores and a multi-threaded @acronym{BLAS}. - -@node Function and variable index, Concept index, Current and future directions, Top +@node Function and variable index @unnumbered Function and variable index @printindex vr -@node Concept index, , Function and variable index, Top + +@node Concept index @unnumbered Concept index @printindex cp + @bye @c Local Variables: *** diff --git a/doc/manual/R-lang.texi b/doc/manual/R-lang.texi index 13c9535845f..397db4c3fc7 100644 --- a/doc/manual/R-lang.texi +++ b/doc/manual/R-lang.texi @@ -2,7 +2,6 @@ @c %**start of header @setfilename R-lang.info @settitle R Language Definition -@setchapternewpage on @c %**end of header @syncodeindex fn vr diff --git a/doc/manual/resources.texi b/doc/manual/resources.texi index 0418b9059e7..18c1a47b511 100644 --- a/doc/manual/resources.texi +++ b/doc/manual/resources.texi @@ -2,9 +2,8 @@ @c %**start of header @setfilename resources.info @settitle R Resources -@c %**end of header - @paragraphindent 0 +@c %**end of header @c NOTE: @c This file is currently written for standalone usage only. @@ -14,9 +13,9 @@ @c @ifinfo +@node Top @sp 1 -@c Original header was centered, hence the @w{}. Argh. -@w{ }AVAILABLE R RESOURCES +@center AVAILABLE R RESOURCES @sp 1 @end ifinfo @@ -30,19 +29,11 @@ @end html @end ifhtml -@node Top, FAQ, (dir), (dir) - -@menu -* FAQ:: -* Mailing lists:: -* Archives:: -* Bug-tracking system:: -@end menu -@node FAQ, Mailing lists, Top, Top +@node FAQ @chapter FAQ -A collection of @uref{faq.html, , Frequently Asked Questions} and their +A collection of Frequently Asked Questions and their answers is maintained by @email{Kurt.Hornik@@R-project.org, Kurt Hornik} and can be found at the @acronym{URL} @@ -52,11 +43,12 @@ and can be found at the @acronym{URL} @ifinfo A text version is in file @file{FAQ} in this directory, and an -@acronym{HTML} version is available as file @file{doc/html/faq.html} and +@acronym{HTML} version is available as file @file{doc/manual/R-FAQ.html} and via the on-line help (on the index page given by @code{help.start()}). @end ifinfo -@node Mailing lists, Archives, FAQ, Top + +@node Mailing lists @chapter Mailing lists Thanks to @email{Martin.Maechler@@R-project.org, Martin Maechler} there @@ -69,7 +61,8 @@ See for details. -@node Archives, Bug-tracking system, Mailing lists, Top + +@node Archives @chapter Archives The Comprehensive R Archive Network (@acronym{CRAN}) is a collection of @@ -82,7 +75,8 @@ information on daily mirrors available from @uref{https://CRAN.R-project.org/mirrors.html} @end quotation -@node Bug-tracking system, , Archives, Top + +@node Bug-tracking system @chapter Bug-tracking system R has a bug-tracking system (or perhaps a bug-filing system is a more @@ -92,6 +86,7 @@ precise description) available on the net at @uref{https://bugs.R-project.org/} @end quotation + @bye @c Local Variables: *** diff --git a/doc/manual/rw-FAQ.texi b/doc/manual/rw-FAQ.texi index e5fe7f30ee4..37a6a72ddb5 100644 --- a/doc/manual/rw-FAQ.texi +++ b/doc/manual/rw-FAQ.texi @@ -2,12 +2,10 @@ @c %**start of header @setfilename rw-FAQ.info @settitle R for Windows FAQ -@setchapternewpage on @set VERSION @RWVER@ @set RVERSION @RVER@ +@paragraphindent 0 @c %**end of header -@documentlanguage en -@documentencoding utf-8 @finalout @@ -40,40 +38,27 @@ B. D. Ripley and D. J. Murdoch, updates by @I{T. Kalibera} @* @sp 2 @end ifinfo -@ifhtml -@html -

Version for @value{VERSION}

-
B. D. Ripley and D. J. Murdoch, updates by @I{T. Kalibera}
-
-@end html -@end ifhtml - -@paragraphindent 0 - @contents @ifinfo @sp 1 @end ifinfo - -@node Top, Introduction, (dir), (dir) +@node Top @top R for Windows FAQ -@menu -* Introduction:: -* Installation and Usage:: -* Languages and Internationalization:: -* Packages:: -* Windows Features:: -* Workspaces:: -* The R Console:: -* Building from Source:: -@end menu +@ifhtml +@html +

Version for @value{VERSION}

+
B. D. Ripley and D. J. Murdoch, updates by @I{T. Kalibera}
+
+@end html +@end ifhtml + @newchap{} -@node Introduction, Installation and Usage, Top, Top +@node Introduction @chapter Introduction This FAQ is for the Windows port of R: it describes features specific to @@ -89,44 +74,13 @@ builds of R are provided. R 4.4.0 has experimental native support for Windows on 64-bit ARM. + @newchap{} -@node Installation and Usage, Languages and Internationalization, Introduction, Top +@node Installation and Usage @chapter Installation and Usage -@menu -* Where can I find the latest version?:: -* How do I install R for Windows?:: -* How do I check an installation?:: -* Can I customize the installation?:: -* How do I run it?:: -* Can I run R from a CD or USB drive?:: -* How do I UNinstall R?:: -* What's the best way to upgrade?:: -* How can I keep workspaces for different projects in different directories?:: -* How do I print from R?:: -* Can I use R CMD BATCH?:: -* Can I use @RWVER@ with ESS and Emacs?:: -* What are HOME and working directories?:: -* How do I set environment variables?:: -* R can't find my file:: -* Does R use the Registry?:: -* Does R support automation?:: -* The Internet download functions fail.:: -* Entering certain characters crashes Rgui.:: -* What does 'DLL attempted to change FPU control word' mean?:: -* Other strange crashes.:: -* Why does R never use more than 50% of my CPU?:: -* Does R run under Windows 7?:: -* Quotes don't come out right on the console/terminal/pager:: -* There is no tilde on my keyboard:: -* Can I use R on 64-bit Windows?:: -* Should I run 32-bit or 64-bit R?:: -* Can both 32- and 64-bit R be installed on the same machine?:: -* Rcmd is not found in my PATH!:: -@end menu - - -@node Where can I find the latest version?, How do I install R for Windows?, Installation and Usage, Installation and Usage + +@node Where can I find the latest version? @section Where can I find the latest version? Go to any CRAN site (see @uref{https://CRAN.R-project.org/@/mirrors.html} @@ -142,7 +96,8 @@ as changes that are planned to eventually make it into the next @samp{x.y.0} release. @samp{r-devel} is less stable and likely to contain bugs, be careful if you use it. -@node How do I install R for Windows?, How do I check an installation?, Where can I find the latest version?, Installation and Usage + +@node How do I install R for Windows? @section How do I install R for Windows? Current binary versions of R are known to run on Windows 7 or later. R 4.1 @@ -254,12 +209,13 @@ messages are in (American) English, @code{LANGUAGE=en}. @c see the `R Installation and Administration Manual'. -@node How do I check an installation?, Can I customize the installation?, How do I install R for Windows?, Installation and Usage +@node How do I check an installation? @section How do I check an installation is not corrupt? Relates to earlier installers, removed in R 2.11.0. -@node Can I customize the installation?, How do I run it?, How do I check an installation?, Installation and Usage + +@node Can I customize the installation? @section Can I customize the installation? The normal way to customize the installation is by selecting components @@ -305,7 +261,8 @@ A successful installation has exit code 0: unsuccessful ones may give 1, @c particular to add packages to the installer. See the `R Installation @c and Administration' manual in the subsection `Building the installers'. -@node How do I run it?, Can I run R from a CD or USB drive?, Can I customize the installation?, Installation and Usage + +@node How do I run it? @section How do I run it? Just double-click on the shortcut you prepared at installation. @@ -322,7 +279,8 @@ executables are not by default added to the @env{PATH}.) People running from a terminal usually prefer to run @command{Rterm.exe} and not @command{Rgui.exe}. -@node Can I run R from a CD or USB drive?, How do I UNinstall R?, How do I run it?, Installation and Usage + +@node Can I run R from a CD or USB drive? @section Can I run R from a CD or USB drive? Yes, with care. A basic R installation is relocatable, so you can burn @@ -336,7 +294,7 @@ of Windows, but otherwise does mean that it may not be possible to run R without creating a shortcut starting in a writable folder. -@node How do I UNinstall R?, What's the best way to upgrade?, Can I run R from a CD or USB drive?, Installation and Usage +@node How do I UNinstall R? @section How do I @I{UNinstall} R? Normally you can do this from the @samp{Programs and Features} group in @@ -353,7 +311,7 @@ If all else fails, you can just delete the whole directory in which R was installed. -@node What's the best way to upgrade?, How do I UNinstall R?, Installation and Usage +@node What's the best way to upgrade? @section What's the best way to upgrade? That's a matter of taste. For most people the best thing to do is to @@ -376,7 +334,8 @@ for the personal library and the old personal library will be left intact should not be copied from the old library to the new one, because they may be incompatible with the new version of R. -@node How can I keep workspaces for different projects in different directories?, How do I print from R?, Installation and Usage + +@node How can I keep workspaces for different projects in different directories? @section How can I keep workspaces for different projects in different directories? Create a separate shortcut for each project: see Q2.5. All the paths to @@ -390,7 +349,7 @@ file with extension @file{.RData} onto an R shortcut. In either case, the working directory will be set to that containing the file. -@node How do I print from R?, Can I use R CMD BATCH?, How can I keep workspaces for different projects in different directories?, Installation and Usage +@node How do I print from R? @section How do I print from R? It depends what you want to print. @@ -415,7 +374,7 @@ can print help files by @code{help(fn_name, help_type="PDF")}. @end itemize -@node Can I use R CMD BATCH?, Can I use @RWVER@ with ESS and Emacs?, How do I print from R?, Installation and Usage +@node Can I use R CMD BATCH? @section Can I use @code{R CMD BATCH}? Yes: use @code{R CMD BATCH --help} or @code{?BATCH} for full details. @@ -434,7 +393,7 @@ The purpose of @code{2>&1} is to redirect warnings and errors to the same file as normal output. -@node Can I use @RWVER@ with ESS and Emacs?, What are HOME and working directories?, Can I use R CMD BATCH?, Installation and Usage +@node Can I use @RWVER@ with ESS and Emacs? @section Can I use @RWVER@ with @I{ESS} and Emacs? Yes. @I{ESS} has for a long time supported R under Windows: it does so by @@ -444,7 +403,7 @@ For help with @I{ESS}, please send email to @email{ESS-help@@stat.ethz.ch}, not the R mailing lists. -@node What are HOME and working directories?, How do I set environment variables?, Can I use @RWVER@ with ESS and Emacs?, Installation and Usage +@node What are HOME and working directories? @section What are HOME and working directories? Several places in the documentation use these terms. @@ -481,7 +440,8 @@ The R home directory is the directory where R was installed. You can find this from R code by @code{R.home()} or @code{Sys.getenv("R_HOME")}. From outside R, you can find it by invoking @code{R RHOME}. -@node How do I set environment variables?, R can't find my file, What are HOME and working directories?, Installation and Usage + +@node How do I set environment variables? @section How do I set environment variables? Environment variables can be set for @command{Rgui.exe} and @@ -527,7 +487,7 @@ which these options are listed, that is the command line then @file{.Renviron} then the inherited environment. -@node R can't find my file, Does R use the Registry?, How do I set environment variables?, Installation and Usage +@node R can't find my file @section R can't find my file, but I know it is there! How did you specify it? Backslashes have to be doubled in R character @@ -563,7 +523,8 @@ to @code{1}. Long paths still may not always work reliably: some applications or packages may not be able to work with them and Windows cannot execute an application with long path as the current directory. -@node Does R use the Registry?, Does R support automation?, R can't find my file, Installation and Usage + +@node Does R use the Registry? @section Does R use the Registry? Not when R itself is running. @@ -599,7 +560,7 @@ administrative privileges unless run with argument @code{/Personal} and neither sets up nor removes the file associations. -@node Does R support automation?, The Internet download functions fail., Does R use the Registry?, Installation and Usage +@node Does R support automation? @section Does R support automation (OLE, COM)? Directly, no. See packages such as @code{RDCOMClient} from Omegahat @@ -609,7 +570,8 @@ source and binary packages for earlier versions of R available from @c @uref{https://www.omegahat.net/} and the non-Free project at @uref{https://www.autstat.com/}. -@node The Internet download functions fail., Entering certain characters crashes Rgui., Does R support automation?, Installation and Usage + +@node The Internet download functions fail. @section The Internet download functions fail. for example @code{update.packages()} and the menu items on the Packages menu. @@ -630,7 +592,7 @@ best effort revocation checks via an environment variable: see @code{?download.file}. -@node Entering certain characters crashes Rgui., What does 'DLL attempted to change FPU control word' mean?, The Internet download functions fail., Installation and Usage +@node Entering certain characters crashes Rgui. @section Entering certain characters crashes @I{RGui}. This has not been reported for many years, but used to happen @@ -643,7 +605,8 @@ caused by desktop switcher and keyboard macro programs, for example R 4.2 and later use @abbr{UCRT} as the C runtime instead of @abbr{MSVCRT}. No such problems have been reported so far. -@node What does 'DLL attempted to change FPU control word' mean?, Other strange crashes., Entering certain characters crashes Rgui., Installation and Usage + +@node What does 'DLL attempted to change FPU control word' mean? @section What does '@I{DLL attempted to change FPU control word}' mean? This is a @emph{warning} which indicates that R has taken action to @@ -665,7 +628,8 @@ builds of R on ARM. See also @code{?dyn.load}. -@node Other strange crashes., Why does R never use more than 50% of my CPU?, What does 'DLL attempted to change FPU control word' mean?, Installation and Usage + +@node Other strange crashes. @section Other strange crashes. Some users have found that @code{Rgui.exe} fails to start, exiting with @@ -683,7 +647,8 @@ beyond the measures already taken. The only solution we know of is for the user to replace the buggy system component that is causing the error. -@node Why does R never use more than 50% of my CPU?, Does R run under Windows 7?, Other strange crashes., Installation and Usage + +@node Why does R never use more than 50% of my CPU? @section Why does R never use more than 50% of my CPU? This is a misreading of Windows' confusing Task Manager. R's @@ -702,7 +667,7 @@ packages, which needs to be selected by user. Some contributed R packages use multiple CPUs or multiple threads. -@node Does R run under Windows 7?, Quotes don't come out right on the console/terminal/pager, Why does R never use more than 50% of my CPU?, Installation and Usage +@node Does R run under Windows 7? @section Does R run under Windows 7/8/10/11/Server 2012/2016/2022? R 4.4 code base still conservatively uses features of Windows 7 and @@ -815,7 +780,7 @@ more reliable with these OSes (but still not 100% correct). @c this on for all programs. R runs correctly with DEP enabled. -@node Quotes don't come out right on the console/terminal/pager, There is no tilde on my keyboard, Does R run under Windows 7?, Installation and Usage +@node Quotes don't come out right on the console/terminal/pager @section Quotes don't come out right on the console/terminal/pager. R 4.2 and later use UTF-8 as the native encoding on recent Windows (see Q2.2) and @@ -869,7 +834,8 @@ Western European locale) @noindent or their use suppressed by @code{options(useFancyQuotes=FALSE)}. -@node There is no tilde on my keyboard, Can I use R on 64-bit Windows?, Quotes don't come out right on the console/terminal/pager, Installation and Usage + +@node There is no tilde on my keyboard @section There is no tilde on my keyboard! Where tilde does not appear on the main keyboard, it can normally be @@ -884,7 +850,8 @@ On all Windows versions you should be able to get tilde by holding the down the left Alt key and typing 0126 on the numeric keypad (if you have one), then releasing the Alt key. -@node Can I use R on 64-bit Windows?, Should I run 32-bit or 64-bit R?, There is no tilde on my keyboard, Installation and Usage + +@node Can I use R on 64-bit Windows? @section Can I use R on 64-bit Windows? Yes, and this is the primarily used and the only tested option now. Since R @@ -903,7 +870,8 @@ When R 4.1 and earlier is installed on 64-bit Windows there is the option of ins using the 32-bit build, replace @samp{x64} by @samp{i386} in the examples in this FAQ. -@node Should I run 32-bit or 64-bit R?, Can both 32- and 64-bit R be installed on the same machine?, Can I use R on 64-bit Windows?, Installation and Usage + +@node Should I run 32-bit or 64-bit R? @section Should I run 32-bit or 64-bit R? Since R 4.2.0, 32-bit builds are no longer provided. With older versions of @@ -937,7 +905,8 @@ installed 64-bit Microsoft Office you can only install the 64-bit drivers and so need to use 64-bit @code{RODBC} and hence R. (And similarly for 32-bit Microsoft Office.) -@node Can both 32- and 64-bit R be installed on the same machine?, Rcmd is not found in my PATH!, Should I run 32-bit or 64-bit R?, Installation and Usage + +@node Can both 32- and 64-bit R be installed on the same machine? @section Can both 32- and 64-bit R be installed on the same machine? Since R 4.2.0, 32-bit builds are no longer provided. @@ -956,7 +925,7 @@ safest way is to edit the Registry entry and replace @samp{x64} by @samp{i386} or @emph{vice versa}. -@node Rcmd is not found in my PATH!, , Can both 32- and 64-bit R be installed on the same machine?, Installation and Usage +@node Rcmd is not found in my PATH! @section @I{Rcmd} is not found in my PATH! This has often been reported after an upgrade. @@ -1003,21 +972,13 @@ CMD /K setpath.bat @end example + @newchap{} -@node Languages and Internationalization, Packages, Installation and Usage, Top +@node Languages and Internationalization @chapter Languages and Internationalization -@menu -* The installer does not offer my language:: -* I want R in English!:: -* I want to run R in Chinese/Japanese/Korean:: -* I selected English for installation but R runs in Chinese:: -* I would like to be able to use Japanese fonts:: -* I don't see characters with accents at the R console:: -* The dialog buttons are not translated:: -@end menu - -@node The installer does not offer my language, I want R in English!, Languages and Internationalization, Languages and Internationalization + +@node The installer does not offer my language @section The installer does not offer my language. Only a limited range of languages is supported, currently @@ -1044,7 +1005,8 @@ Slovenian, Spanish (Spain) and Ukrainian. -@node I want R in English!, I want to run R in Chinese/Japanese/Korean, The installer does not offer my language, Languages and Internationalization + +@node I want R in English! @section I want R in English (and not in French/Chinese/...)! The default behaviour of R is to try to run in the language you run @@ -1056,7 +1018,8 @@ Windows in their native language, but not R. To do so, set @code{LANGUAGE=en} as discussed in Q2.2 and Q2.15, or in the @file{Rconsole} file. -@node I want to run R in Chinese/Japanese/Korean, I selected English for installation but R runs in Chinese, I want R in English!, Languages and Internationalization + +@node I want to run R in Chinese/Japanese/Korean @section I want to run R in Chinese/Japanese/Korean. Suitable versions of Windows support what it calls `East Asian' @@ -1108,7 +1071,8 @@ up to use a suitable font (e.g. @code{Lucida Console} or and later on recent versions of Windows where UTF-8 is the native encoding, @command{Rterm} will automatically switch the console codepage to UTF-8. -@node I selected English for installation but R runs in Chinese, I would like to be able to use Japanese fonts, I want to run R in Chinese/Japanese/Korean, Languages and Internationalization + +@node I selected English for installation but R runs in Chinese @section I selected English for installation but R runs in Chinese. Precisely, you selected English @strong{for installation}! The language @@ -1117,12 +1081,14 @@ is completely standard Windows practice (and necessary as different users of the computer may use different languages). The language R uses for menus and messages is determined by the -@emph{locale}: please read the appropriate manual (`R Installation and -Administration') for the details. You can ensure that R uses English +@emph{locale}: please read the appropriate manual +(@ref{, , , R-admin, R Installation and Administration}) +for the details. You can ensure that R uses English messages by appending @code{LANGUAGE=en} to the shortcut you use to start R, or setting it in the @file{Rconsole} file. -@node I would like to be able to use Japanese fonts, I don't see characters with accents at the R console, I selected English for installation but R runs in Chinese, Languages and Internationalization + +@node I would like to be able to use Japanese fonts @section I would like to be able to use Japanese fonts. for example, in the console and to annotate graphs. Similar comments @@ -1145,7 +1111,8 @@ device to display Japanese characters. To use non-Latin-1 characters in the @code{postscript} graphics device, see its help page (which also applies to @code{pdf}). -@node I don't see characters with accents at the R console, The dialog buttons are not translated, I would like to be able to use Japanese fonts, Languages and Internationalization + +@node I don't see characters with accents at the R console @section I don't see characters with accents at the R console, for example in ?text. You need to specify a font in @file{Rconsole} (see Q5.2) that supports @@ -1158,7 +1125,8 @@ codepage settings) within which it is run as well as the font used by the terminal window. Those are usually on legacy DOS settings and need to altered (see Q3.3). -@node The dialog buttons are not translated, , I don't see characters with accents at the R console, Languages and Internationalization + +@node The dialog buttons are not translated @section The dialog buttons are not translated. In most cases they actually are, but by Windows. Setting the locale or @@ -1174,31 +1142,14 @@ handles internationalization slightly odd. @c For further details see @c @uref{http://msdn.microsoft.com/@/library/@/default.asp?url=/@/library/@/en-us/@/intl/@/nls_0ddl.asp}. + + @newchap{} -@node Packages, Windows Features, Languages and Internationalization, Top +@node Packages @chapter Packages -@menu -* Can I install packages into libraries in this version?:: -* I don't have permission to write to the @RWVER@\library directory:: -* The packages I installed do not appear in the HTML help system:: -* My functions are not found by the HTML help search system.:: -* Loading a package fails.:: -* Package TclTk does not work.:: -* Hyperlinks in HTML do not work.:: -* update.packages() fails:: -* How do I add to the list of repositories?:: -* Help is not shown for some of the packages:: -* How do I get static HTML pages?:: -* How can I get a binary version of a package?:: -* Package xxx is out of date for Windows:: -* No binary packages appear to be available for my version of R:: -* How do I build my package for both 32- and 64-bit R?:: -@end menu - - -@node Can I install packages into libraries in this version?, I don't have permission to write to the @RWVER@\library directory, Packages, Packages +@node Can I install packages into libraries in this version? @section Can I install packages into libraries in this version? Yes, but you will need a lot of tools to do so, unless the author or the @@ -1220,19 +1171,21 @@ so for R 4.4.? the files are in @file{bin/windows/contrib/4.4}. @c which also gives the locations of a few other binary packages. If there is no binary package or that is not up-to-date or you prefer -compiling from source, read the `R Installation and Administration' -manual section on `Add-on Packages'. Source packages which contain no +compiling from source, +@pxref{Add-on packages, , , R-admin, R Installation and Administration}. +Source packages which contain no C/C++/Fortran code which needs compilation can simply be installed by @code{install.packages(type = "source")} or @command{R CMD INSTALL -pkgname} at a Windows command prompt. For packages with code that needs +@var{pkgname}} at a Windows command prompt. For packages with code that needs compilation you will need to collect and install several tools: you can download them via the portal at @uref{https://CRAN.R-project.org/bin/windows/Rtools/} and check for more detailed instructions there. Once you have done -so, just run @command{R CMD INSTALL pkgname} at a Windows command +so, just run @command{R CMD INSTALL @var{pkgname}} at a Windows command prompt. To check the package (including running all the examples on its help pages and in its test suite, if any) use @command{R CMD check -pkgname}: see the @emph{`Writing R Extensions'} manual. +@var{pkgname}}: +@pxref{Checking and building packages, , , R-exts, Writing R Extensions}. Note that setting up Windows to install a source package that needs compilation is rather tricky; please do ensure that you have followed @@ -1246,7 +1199,8 @@ documented at @url{https://win-builder.R-project.org}. The native (default) builds of R 4.4.0 for Windows on ARM only install packages from source. This may be changed in the future. -@node I don't have permission to write to the @RWVER@\library directory, The packages I installed do not appear in the HTML help system, Can I install packages into libraries in this version?, Packages + +@node I don't have permission to write to the @RWVER@\library directory @section I don't have permission to write to the @file{@RWVER@\library} directory. You can install packages anywhere and use the environment variable @@ -1295,21 +1249,22 @@ There can be additional security issues under Windows Vista and later: @c under Vista, so we recommend that you do create a personal directory @c yourself. -@node The packages I installed do not appear in the HTML help system, My functions are not found by the HTML help search system., I don't have permission to write to the @RWVER@\library directory, Packages + +@node The packages I installed do not appear in the HTML help system @section The packages I installed do not appear in the HTML help system. This question applied to the pre-2.10.0 HTML help system, which has been replaced. -@node My functions are not found by the HTML help search system., Loading a package fails., The packages I installed do not appear in the HTML help system, Packages +@node My functions are not found by the HTML help search system. @section My functions are not found by the HTML help search system. This question applied to the pre-2.10.0 search system, which has been replaced. -@node Loading a package fails., Package TclTk does not work., My functions are not found by the HTML help search system., Packages +@node Loading a package fails. @section Loading a package fails. Is the package installed for this version of R? Packages need to have @@ -1326,7 +1281,7 @@ listing of some of these packages (notably @code{RGtk2}, @code{cairoDevice}, @code{rggobi}, @code{rJava}, @code{rjags} and some of the packages connecting to databases). -@node Package TclTk does not work., Hyperlinks in HTML do not work., Loading a package fails., Packages +@node Package TclTk does not work. @section Package @I{TclTk} does not work. For package @code{tcltk} to work (try @code{demo(tkdensity)} or @@ -1363,7 +1318,8 @@ now also 64-bit only. The older combined 32-bit/64-bit bundle for R 4.1 cannot be used with R 4.2 and later, because it has a different directory layout even for the 64-bit part. -@node Hyperlinks in HTML do not work., update.packages() fails, Package TclTk does not work., Packages + +@node Hyperlinks in HTML do not work. @section Hyperlinks in HTML sometimes do not work. This question was much more relevant prior to version 2.10.0. @@ -1371,7 +1327,8 @@ This question was much more relevant prior to version 2.10.0. They may still not work between packages installed in different libraries if the HTTP server has been disabled: the remedy is not to do that! -@node update.packages() fails, How do I add to the list of repositories?, Hyperlinks in HTML do not work., Packages + +@node update.packages() fails @section @code{update.packages()} fails. You may not be able to update a package which is in use: Windows `locks' @@ -1388,7 +1345,7 @@ installation process by preventing the renaming of temporary files, @emph{Google Desktop} being a known example. -@node How do I add to the list of repositories?, Help is not shown for some of the packages, update.packages() fails, Packages +@node How do I add to the list of repositories? @section How do I add to the list of repositories? as shown in the @code{Select repositories...} item on the @@ -1398,13 +1355,15 @@ This reads from the tab-delimited file @file{R_HOME\etc\repositories}, which you can edit, or put a modified copy at @file{.R\repositories} in your HOME directory (@pxref{What are HOME and working directories?}). -@node Help is not shown for some of the packages, How do I get static HTML pages?, How do I add to the list of repositories?, Packages + +@node Help is not shown for some of the packages @section Help is not shown for some of the packages This was about Compiled HTML help, which has not been supported since R 2.10.0. -@node How do I get static HTML pages?, How can I get a binary version of a package?, Help is not shown for some of the packages, Packages + +@node How do I get static HTML pages? @section How do I get static HTML pages? We presume you want to do this for some special purpose: R's help system @@ -1436,7 +1395,8 @@ BUILD_HTML = NO and them all packages installed by that build of R will (by default) be installed with static HTML pages. -@node How can I get a binary version of a package?, Package xxx is out of date for Windows, How do I get static HTML pages?, Packages + +@node How can I get a binary version of a package? @section How can I get a binary version of a package? Presumably one not available on CRAN, @abbr{BioC} or a similar repository. @@ -1459,7 +1419,8 @@ difficult (it is simple if the package contains no compiled code), so please attempt that for yourself before requesting help from the busy volunteers. See also Q4.1. -@node Package xxx is out of date for Windows, No binary packages appear to be available for my version of R, How can I get a binary version of a package?, Packages + +@node Package xxx is out of date for Windows @section Package xxx is out of date for Windows Here are three possible reasons: @@ -1480,7 +1441,8 @@ is current, but building stops once 4.(x+2) reaches alpha (pre-release, about a month before release). You can always try installing from the sources. -@node No binary packages appear to be available for my version of R, How do I build my package for both 32- and 64-bit R?, Package xxx is out of date for Windows, Packages + +@node No binary packages appear to be available for my version of R @section No binary packages appear to be available for my version of R How old is it? The CRAN policy is to archive binary packages two years @@ -1492,7 +1454,7 @@ but you do also have the option of installing packages from their source. -@node How do I build my package for both 32- and 64-bit R?, , No binary packages appear to be available for my version of R, Packages +@node How do I build my package for both 32- and 64-bit R? @section How do I build my package for both 32- and 64-bit R? Since R 4.2.0, 32-bit builds are no longer provided. The following @@ -1525,20 +1487,14 @@ components were selected when R was installed and option @option{--compile-both} is given. Obviously, only the 32-bit installation can be tested. + + @newchap{} -@node Windows Features, Workspaces, Packages, Top +@node Windows Features @chapter Windows Features -@menu -* What should I expect to behave differently from the Unix version:: -* I hear about some nifty features.:: -* Circles appear as ovals on screen:: -* How do I move focus to a graphics window or the console?:: -* What does TAB completion do?:: -@end menu - -@node What should I expect to behave differently from the Unix version, I hear about some nifty features., Windows Features, Windows Features +@node What should I expect to behave differently from the Unix version @section What should I expect to behave differently from the Unix version of R? @itemize @bullet @@ -1561,7 +1517,7 @@ of @code{shell()}. @end itemize -@node I hear about some nifty features., Circles appear as ovals on screen, What should I expect to behave differently from the Unix version, Windows Features +@node I hear about some nifty features. @section I hear about some nifty features: please tell me about them! You have read the file @file{README.@RWVER@}? There are file menus on @@ -1600,7 +1556,7 @@ There is a GUI preferences editor invoked from the @code{Edit} menu which can be used to edit the file @file{Rconsole}. -@node Circles appear as ovals on screen, How do I move focus to a graphics window or the console?, I hear about some nifty features., Windows Features +@node Circles appear as ovals on screen @section Circles appear as ovals on screen. The graphics system asks Windows for the number of pixels per inch in @@ -1619,7 +1575,8 @@ modes. In fact it was a 21" monitor and 400mm x 300mm! This is less common with LCD screens but not unknown, particularly if they are not running at their native resolution. -@node How do I move focus to a graphics window or the console?, What does TAB completion do?, Circles appear as ovals on screen, Windows Features + +@node How do I move focus to a graphics window or the console? @section How do I move focus to a graphics window or the console? You may want to do this from within a function, for example when calling @@ -1633,7 +1590,7 @@ graphics windows from @command{Rterm.exe} (although Windows may not always act on it). -@node What does TAB completion do?, , How do I move focus to a graphics window or the console?, Windows Features +@node What does TAB completion do? @section What does TAB completion do? Both @command{Rgui} and @command{Rterm} support @kbd{TAB} completion. @@ -1672,25 +1629,20 @@ This feature is very similar to the completion available in the @code{readline}-based command line interface on Unix-alikes: the macOS GUI @code{R.app} has a different completion scheme. -@newchap{} -@node Workspaces, The R Console, Windows Features, Top -@chapter Workspaces -@menu -* My workspace gets saved in a strange place. How do I stop this?:: -* How do I store my workspace in a different place?:: -* Can I load workspaces saved under Unix/GNU-Linux or macOS?:: -@end menu +@newchap{} +@node Workspaces +@chapter Workspaces -@node My workspace gets saved in a strange place. How do I stop this?, How do I store my workspace in a different place?, Workspaces, Workspaces +@node My workspace gets saved in a strange place. How do I stop this? @section My workspace gets saved in a strange place: how do I stop this? Have you changed the working directory?: see Q6.2. -@node How do I store my workspace in a different place?, Can I load workspaces saved under Unix/GNU-Linux or macOS?, My workspace gets saved in a strange place. How do I stop this?, Workspaces +@node How do I store my workspace in a different place? @section How do I store my workspace in a different place? Use the `File | Change Dir...' menu item to select a new working @@ -1702,7 +1654,7 @@ From the command line you can change the working directory by the function @code{setwd}: see its help page. -@node Can I load workspaces saved under Unix/GNU-Linux or macOS?, , How do I store my workspace in a different place?, Workspaces +@node Can I load workspaces saved under Unix/GNU-Linux or macOS? @section Can I load workspaces saved under Unix/GNU-Linux or Mac macOS? Yes. All ports of R use the same format for saved workspaces, so they @@ -1734,20 +1686,14 @@ or confuse some software. As of R 4.2, when running on recent Windows, the native encoding is UTF-8 and so these problems should disappear. -@newchap{} -@node The R Console, Building from Source, Workspaces, Top -@chapter The R Console - - -@menu -* The output to the console seems to be delayed:: -* Long lines seem to be truncated.:: -@end menu +@newchap{} +@node The R Console +@chapter The R Console -@node The output to the console seems to be delayed, Long lines seem to be truncated., The R Console, The R Console +@node The output to the console seems to be delayed @section When using @I{RGui} the output to the console seems to be delayed. This is deliberate: the console output is buffered and re-written in @@ -1760,7 +1706,7 @@ option. A call to the R function @code{flush.console()} will write out the buffer and so update the console. -@node Long lines seem to be truncated., , The output to the console seems to be delayed, The R Console +@node Long lines seem to be truncated. @section Long lines in the console or pager are truncated. They only @strong{seem} to be truncated: that $ at the end indicates you @@ -1771,28 +1717,18 @@ horizontally. (The @key{left/right arrow} keys work in the pager too.) @newchap{} -@node Building from Source, , The R Console, Top +@node Building from Source @chapter Building from Source -@menu -* How can I compile R from source?:: -* Can I use a fast BLAS?:: -* How do I include compiled C code?:: -* How do I debug code that I have compiled and dyn.load-ed?:: -* How do I include C++ code?:: -* The output from my C code disappears.:: -* The output from my Fortran code disappears.:: -* The console freezes when my compiled code is running:: -@end menu - -@node How can I compile R from source?, Can I use a fast BLAS?, Building from Source, Building from Source +@node How can I compile R from source? @section How can I compile R from source? -See the `R Installation and Administration' manual (for the version of R -you want to install). +@xref{, , , R-admin, R Installation and Administration} +(for the version of R you want to install). -@node Can I use a fast BLAS?, How do I include compiled C code?, How can I compile R from source?, Building from Source + +@node Can I use a fast BLAS? @section Can I use a fast BLAS? Fast BLAS (Basic Linear Algebra Subprograms, @@ -1807,10 +1743,12 @@ matrices may run slower. BLAS support is supplied by the single DLL @file{R_HOME\bin\x64\Rblas.dll}, and you can add a fast BLAS just by -replacing that. Replacements for 32-bit R and some of the older common -chips are available on CRAN in directory -@file{bin/windows/contrib/ATLAS}. See the R Installation and -Administration' manual for how to build an ATLAS @file{Rblas.dll} tuned +replacing that. +@c Replacements for 32-bit R and some of the older common +@c chips are available on CRAN in directory +@c @file{bin/windows/contrib/ATLAS}. +@xref{, , , R-admin, R Installation and Administration} +for how to build an ATLAS @file{Rblas.dll} tuned to your system using the R sources. Unfortunately the process has been less successful when tried for the common current CPUs. @@ -1830,13 +1768,16 @@ With a native build of R on ARM, exclude @file{\x64} from the above. Note that fast BLAS implementations may give different (and often slightly less accurate) results than the reference BLAS included in R. -@node How do I include compiled C code?, How do I debug code that I have compiled and dyn.load-ed?, Can I use a fast BLAS?, Building from Source + +@node How do I include compiled C code? @section How do I include compiled C code? We strongly encourage you to do this @emph{via} building an R package: -see the @emph{`Writing R Extensions'} manual. In any event you should -get and install the tools and toolchain mentioned in the `R Installation -and Administration' manual. Then you can use +@pxref{, , , R-exts, Writing R Extensions}. +In any event you should +get and install the tools and toolchain mentioned in +@ref{, , , R-admin, R Installation and Administration}. +Then you can use @example ...\bin\x64\R CMD SHLIB foo.c bar.f @end example @@ -1849,8 +1790,7 @@ With a native build of R on ARM, exclude @file{\x64} from the above. @c appropriate section in @file{README.packages}. - -@node How do I debug code that I have compiled and dyn.load-ed?, How do I include C++ code?, How do I include compiled C code?, Building from Source +@node How do I debug code that I have compiled and dyn.load-ed? @section How do I debug code that I have compiled and @code{dyn.load}-ed? @c Debugging under Windows is often a fraught process, and sometimes does @@ -1875,7 +1815,8 @@ Rcmd INSTALL --debug mypkg @end example @noindent -See the `R Installation and Administration' manual (for the version of R you +@xref{, , , R-admin, R Installation and Administration} +(for the version of R you want to install) and @uref{https://CRAN.R-project.org/bin/windows/Rtools/} for links to detailed information on how to build R and R packages from source using corresponding versions of @I{Rtools} and for additional hints for @@ -1941,7 +1882,7 @@ drop control back to the debugger does not work with a MinGW version of @end itemize -@node How do I include C++ code?, The output from my C code disappears., How do I debug code that I have compiled and dyn.load-ed?, Building from Source +@node How do I include C++ code? @section How do I include C++ code? You need to do two things: @@ -1975,7 +1916,7 @@ Note that you will not see the messages from this example in the GUI console: see the next section. -@node The output from my C code disappears., The output from my Fortran code disappears., How do I include C++ code?, Building from Source +@node The output from my C code disappears. @section The output from my C code disappears. Why? The @command{Rgui.exe} console is a Windows application: writing to @@ -1989,12 +1930,12 @@ console seems to be delayed}), so that you will not normally see any output before returning to the R prompt. -@node The output from my Fortran code disappears., The console freezes when my compiled code is running, The output from my C code disappears., Building from Source +@node The output from my Fortran code disappears. @section The output from my Fortran code disappears. Why? Writing to Fortran output writes to a file, not the @command{Rgui} console. -Use one of the subroutines @code{dblepr}, @code{intpr} or @code{realpr} -documented in the @emph{`Writing R Extensions'} manual. +Use one of the subroutines @code{dblepr}, @code{intpr} or @code{realpr}, +@pxref{Printing from Fortran, , , R-exts, Writing R Extensions}. Note that output from the console is delayed (@pxref{The output to the console seems to be delayed}), so that you will not normally see any @@ -2002,7 +1943,7 @@ output before returning to the R prompt even when using the @code{xxxpr} subroutines. -@node The console freezes when my compiled code is running, , The output from my Fortran code disappears., Building from Source +@node The console freezes when my compiled code is running @section The console freezes when my compiled code is running. The console, pagers and graphics window all run in the same thread @@ -2011,7 +1952,8 @@ call @code{R_ProcessEvents()} periodically from your compiled code. If you want output to be updated on the console, call @code{R_FlushConsole()} and then @code{R_ProcessEvents()}. -@set LASTEDIT 2022-04-12 + +@set LASTEDIT 2024-04-05 @ifhtml @html
@@ -2023,7 +1965,7 @@ Last edited @value{LASTEDIT}: comments to @end ifhtml @ifinfo @sp 2 -Last edited @value{LASTEDIT}: comments to +Last edited @value{LASTEDIT}: comments to @email{R-windows@@R-project.org} @end ifinfo @bye From 066f9d61413885e4075c6e93b6847530dff6158e Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 2 Jul 2024 14:32:15 +0000 Subject: [PATCH 335/546] require Texinfo >= 6.1 to build HTML versions of the R manuals git-svn-id: https://svn.r-project.org/R/trunk@86860 00db46b3-68df-0310-9c12-caf00c1e9a41 --- config.site | 2 +- doc/NEWS.Rd | 3 +++ doc/manual/Makefile.in | 14 +++++++------- doc/manual/R-FAQ.texi | 7 +++---- doc/manual/R-admin.texi | 25 ++++++++++++++----------- doc/manual/R-ints.texi | 4 ++-- m4/R.m4 | 24 ++++++++++++------------ src/gnuwin32/MkRules.dist | 4 ++-- src/library/tools/R/utils.R | 6 +----- src/library/tools/man/texi2dvi.Rd | 7 +++---- 10 files changed, 48 insertions(+), 48 deletions(-) diff --git a/config.site b/config.site index 22837d702a9..851cb9c55a9 100644 --- a/config.site +++ b/config.site @@ -389,7 +389,7 @@ ## Some claim Solaris needs -lsocket -lnsl ## INTERNET_LIBS= -## Script from texinfo 5.1 or later. +## Script from Texinfo 6.1 or later. ## Usually the full path to texi2any. ## TEXI2ANY= diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 985f2e1074c..3688ef73bb6 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -41,6 +41,9 @@ \itemize{ \item The minimum \command{autoconf} requirement for a maintainer build has been increased to \command{autoconf}\sspace{}2.72. + + \item Building the HTML (and Info) versions of the R manuals now + requires \command{texi2any} from \I{Texinfo} 6.1 or later. } } diff --git a/doc/manual/Makefile.in b/doc/manual/Makefile.in index 91969cc7d72..74194bb0d6c 100644 --- a/doc/manual/Makefile.in +++ b/doc/manual/Makefile.in @@ -92,7 +92,7 @@ docs: html .texi.html: @if test -z "$(TEXI2ANY)"; then \ - $(ECHO) "'texi2any' v5.1 or later needed to make HTML docs but missing on your system." ; \ + $(ECHO) "'texi2any' v6.1 or later needed to make HTML docs but missing on your system." ; \ $(ECHO) "file $@ will be missing and linked from CRAN"; \ else \ $(ECHO) "creating doc/manual/$@"; \ @@ -106,7 +106,7 @@ docs: html .texi.info: @if test -z "$(TEXI2ANY)"; then \ - $(ECHO) "ERROR: 'texi2any' v5.1 or later needed but missing on your system."; \ + $(ECHO) "ERROR: 'texi2any' v6.1 or later needed but missing on your system."; \ exit 1; \ fi $(TEXI2ANY) --enable-encoding -I$(srcdir) $< @@ -354,7 +354,7 @@ install-images-pdf: installdirs @-for f in $(srcdir)/images/*.pdf; do \ $(INSTALL_DATA) $${f} "$(DESTDIR)$(rdocdir)/manual/images"; \ done -## if there is no makeinfo >= 5.1 then there are no html pages +## if there is no makeinfo >= 6.1 then there are no html pages install-html: installdirs @for f in $(OBJECTS_HTML); do \ if test -f $${f} ; then \ @@ -431,7 +431,7 @@ distdir: $(DISTFILES) || exit 1; \ done @if test -z "$(TEXI2ANY)"; then \ - $(ECHO) "ERROR: 'texi2any' v5.1 or later needed but missing on your system."; \ + $(ECHO) "ERROR: 'texi2any' v6.1 or later needed but missing on your system."; \ exit 1; \ fi # $(distdir)/doc/html has already been created @@ -443,7 +443,7 @@ front-matter: ${top_builddir}/doc/RESOURCES ${top_builddir}/doc/FAQ ${top_builddir}/doc/RESOURCES: $(srcdir)/resources.texi @if test -z "$(TEXI2ANY)"; then \ - $(ECHO) "'texi2any' v5.1 or later needed to make HTML docs but missing on your system." ; \ + $(ECHO) "'texi2any' v6.1 or later needed to make HTML docs but missing on your system." ; \ $(ECHO) "file doc/RESOURCES will be missing"; \ else \ $(ECHO) "creating RESOURCES"; \ @@ -452,7 +452,7 @@ ${top_builddir}/doc/RESOURCES: $(srcdir)/resources.texi ${top_builddir}/doc/FAQ: $(srcdir)/R-FAQ.texi $(srcdir)/R-defs.texi @if test -z "$(TEXI2ANY)"; then \ - $(ECHO) "'texi2any' v5.1 or later needed to make HTML docs but missing on your system." ; \ + $(ECHO) "'texi2any' v6.1 or later needed to make HTML docs but missing on your system." ; \ $(ECHO) "file doc/FAQ will be missing"; \ else \ $(ECHO) "creating FAQ"; \ @@ -463,7 +463,7 @@ html-non-svn: ../html/resources.html ../html/resources.html: $(srcdir)/resources.texi @if test -z "$(TEXI2ANY)"; then \ - $(ECHO) "'texi2any' v5.1 or later needed to make HTML docs but missing on your system." ; \ + $(ECHO) "'texi2any' v6.1 or later needed to make HTML docs but missing on your system." ; \ $(ECHO) "file doc/html/resources.html will be missing"; \ else \ $(ECHO) "creating doc/html/resources.html"; \ diff --git a/doc/manual/R-FAQ.texi b/doc/manual/R-FAQ.texi index 646f27d9bf9..9c62e93572a 100644 --- a/doc/manual/R-FAQ.texi +++ b/doc/manual/R-FAQ.texi @@ -380,15 +380,14 @@ directory. You can copy the script to a place where users can invoke it, for example to @file{/usr/local/bin}. In addition, @HTML{} versions of the R manuals (e.g., @file{R-exts.html}, the ``Writing R Extensions'' manual) are built in the @file{doc/manual} -subdirectory. +subdirectory (if a suitable @command{texi2any} program was found). Use @kbd{make pdf} to build PDF (Portable Document Format) versions of the R manuals, including @file{fullrefman.pdf} (an R object reference index). Manuals written in the -@acronym{GNU} @I{Texinfo} system can also be converted to info files +@acronym{GNU} @I{Texinfo} system can also be converted to @file{.info} files suitable for reading online with Emacs or stand-alone @acronym{GNU} -Info; use @kbd{make info} to create these versions (note that this -requires @I{Makeinfo} version 4.5). +Info; use @kbd{make info} to create these files. Finally, use @kbd{make check} to find out whether your R system works correctly. diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 2d333ae3479..078f919ceeb 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -425,10 +425,10 @@ There is a set of manuals that can be built from the sources, @table @samp @item fullrefman Printed versions of all the help pages for base and recommended packages -(around 3750 pages). +(around 3900 pages). @item refman Printed versions of the help pages for selected base packages (around -2200 pages) +2300 pages) @item R-FAQ R @acronym{FAQ} @item R-intro @@ -439,6 +439,8 @@ R @acronym{FAQ} ``R Installation and Administration'', this manual. @item R-exts ``Writing R Extensions''. +@item R-ints +``R Internals''. @item R-lang ``The R Language Definition''. @end table @@ -446,17 +448,18 @@ R @acronym{FAQ} @noindent To make these (with @samp{fullrefman} rather than @samp{refman}), use +@c FIXME: mention HTML versions built by default from make docs @example make pdf @r{to create PDF versions} make info @r{to create info files (not @samp{refman} nor @samp{fullrefman}).} @end example -@c texi2any from Mar 2013. +@c texi2any from Feb 2016. You will not be able to build any of these unless you have -@command{texi2any} version 5.1 or later installed, and for PDF you must +@command{texi2any} version 6.1 or later installed, and for PDF you must have @command{texi2dvi} and @file{texinfo.tex} installed (which are part -of the @acronym{GNU} @pkg{texinfo} distribution but are, especially -@file{texinfo.tex}, often made part of the @TeX{} package in +of the @acronym{GNU} @I{Texinfo} distribution but are, especially +@file{texinfo.tex}, often made part of the @TeX{} package @pkg{texinfo} in re-distributions). The path to @command{texi2any} can be set by macro @samp{TEXI2ANY} in @file{config.site}. NB: @command{texi2any} requires @command{perl}. @@ -3189,12 +3192,12 @@ looking in @file{/usr/xpg4/bin} which is used on some commercial Unixes). You will not be able to build most of the manuals unless you have -@command{texi2any} version 5.1 or later installed (which requires +@command{texi2any} version 6.1 or later installed (which requires @command{perl}), and if not most of the @HTML{} manuals will be linked to a version on @acronym{CRAN}. To make PDF versions of the manuals you will also need file @file{texinfo.tex} installed (which is part of the -@acronym{GNU} @pkg{texinfo} distribution but is often made part of the -@TeX{} package in re-distributions) as well as +@acronym{GNU} @I{Texinfo} distribution but is often made part of the +@TeX{} package @pkg{texinfo} in re-distributions) as well as @command{texi2dvi}.@footnote{@command{texi2dvi} is normally a shell script. Some of the issues which have been observed with broken versions of @command{texi2dvi} can be circumvented by setting the @@ -5113,13 +5116,13 @@ Support for Cairo-based graphics devices. @xref{Cairo graphics}. A TeX installation. @xref{Other libraries}. @item -@command{texi2any} from a @samp{texinfo} distribution, which requires +@command{texi2any} from a @I{Texinfo} distribution, which requires @command{perl} (currently a default part of macOS but it has been announced that it may not be in future). @c macOS 10.15 release notes, but is in 11 @c https://developer.apple.com/documentation/macos-release-notes/macos-catalina-10_15-release-notes A version of @command{texi2any} has been included in the binary -distribution of @R{} and there is a @code{texinfo} component at +distribution of @R{} and there is a @samp{texinfo} component at @uref{https://mac.r-project.org/bin/}. @end itemize diff --git a/doc/manual/R-ints.texi b/doc/manual/R-ints.texi index d9a48a61e58..b5702274ed1 100644 --- a/doc/manual/R-ints.texi +++ b/doc/manual/R-ints.texi @@ -4777,10 +4777,10 @@ Perl version 5 is needed for the maintainer-only script @findex Perl @item -@command{texinfo} version 5.1 or later is needed to build the HTML, PDF +@command{texi2any} version 6.1 or later is needed to build the HTML and Info files for the @R{} manuals written in the @acronym{GNU} @I{Texinfo} system. And that requires Perl. -@findex makeinfo +@findex texi2any @end itemize It is also important that code is written in a way that allows others to diff --git a/m4/R.m4 b/m4/R.m4 index ffe97586f53..f5ba5ee6891 100644 --- a/m4/R.m4 +++ b/m4/R.m4 @@ -196,7 +196,7 @@ if test -n "${TEXI2ANY}"; then false) AC_SUBST(INSTALL_INFO) fi -if test "${r_cv_prog_texi2any_v5}" != yes; then +if test "${r_cv_prog_texi2any_v6}" != yes; then warn_info="you cannot build info or HTML versions of the R manuals" AC_MSG_WARN([${warn_info}]) TEXI2ANY="" @@ -209,8 +209,8 @@ AC_SUBST([TEXI2ANY_VERSION_MIN], [${r_cv_prog_texi2any_version_min}]) ## _R_PROG_TEXI2ANY_VERSION ## ------------------------ -## Building the R Texinfo manuals requires texinfo v5.1 or later. -## Set shell variable r_cv_prog_texi2any_v5 to 'yes' if a recent +## Building the R manuals requires Texinfo v6.1 or later. +## Set shell variable r_cv_prog_texi2any_v6 to 'yes' if a recent ## enough texi2any aka makeinfo is found, and to 'no' otherwise. ## If you change the minimum version here, also change it in ## doc/manual/Makefile.in and doc/manual/R-admin.texi. @@ -224,24 +224,24 @@ AC_CACHE_VAL([r_cv_prog_texi2any_version_maj], AC_CACHE_VAL([r_cv_prog_texi2any_version_min], [r_cv_prog_texi2any_version_min=`echo ${r_cv_prog_texi2any_version} | \ cut -f2 -d. | tr -dc '0123456789.'`]) -AC_CACHE_CHECK([whether texi2any version is at least 5.1], - [r_cv_prog_texi2any_v5], +AC_CACHE_CHECK([whether texi2any version is at least 6.1], + [r_cv_prog_texi2any_v6], [if test -z "${r_cv_prog_texi2any_version_maj}" \ || test -z "${r_cv_prog_texi2any_version_min}"; then - r_cv_prog_texi2any_v5=no -elif test ${r_cv_prog_texi2any_version_maj} -gt 5; then - r_cv_prog_texi2any_v5=yes -elif test ${r_cv_prog_texi2any_version_maj} -lt 5 \ + r_cv_prog_texi2any_v6=no +elif test ${r_cv_prog_texi2any_version_maj} -gt 6; then + r_cv_prog_texi2any_v6=yes +elif test ${r_cv_prog_texi2any_version_maj} -lt 6 \ || test ${r_cv_prog_texi2any_version_min} -lt 1; then - r_cv_prog_texi2any_v5=no + r_cv_prog_texi2any_v6=no else - r_cv_prog_texi2any_v5=yes + r_cv_prog_texi2any_v6=yes fi]) ## Also record whether texi2any is at least 7 to appropriately handle ## HTML and EPUB output changes, see ## . AC_CACHE_VAL([r_cv_prog_texi2any_v7], -[if test ${r_cv_prog_texi2any_v5} = yes \ +[if test ${r_cv_prog_texi2any_v6} = yes \ && test ${r_cv_prog_texi2any_version_maj} -ge 7; then r_cv_prog_texi2any_v7=yes else diff --git a/src/gnuwin32/MkRules.dist b/src/gnuwin32/MkRules.dist index 69f17cbc1b7..014e98c1a24 100644 --- a/src/gnuwin32/MkRules.dist +++ b/src/gnuwin32/MkRules.dist @@ -5,7 +5,7 @@ ## Customize by copying to MkRules.local and uncommenting and editing ## some of the definitions there. The values are tailored to Rtools44, the -## currently recommented toolchain using gcc 13, MinGW-w64 11, 64-bit only, +## currently recommended toolchain using gcc 13, MinGW-w64 11, 64-bit only, ## UCRT. R is only intended to be built for 64-bit UCRT as of R 4.2. The ## values also work with Rtools44 on aarch64 (LLVM 17, clang/flang-new, lld, ## libc++) via USE_LLVM=1 and WIN=. @@ -134,7 +134,7 @@ # with the currently recommended toolchain, Msys2 texi2dvi is used, but needs a workaround for a bug # TEXI2DVI = env COMSPEC= texi2dvi -# for texinfo >= 5.1. If the texinfo files are installed at /packages/texinfo, +# For Texinfo >= 6.1. If the texinfo files are installed at /packages/texinfo, # TEXI2ANY = /path/to/perl -I/packages/texinfo /packages/texinfo/texi2any # if you do not have texinfo (default), # TEXI2ANY = missing diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index 48e69dddc64..e1af33bb9d6 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -356,7 +356,7 @@ function(file, pdf = FALSE, clean = FALSE, quiet = TRUE, on.exit(Sys.unsetenv("TEXINDY"), add = TRUE) opt_pdf <- if(pdf) "--pdf" else "" opt_quiet <- if(quiet) "--quiet" else "" - opt_extra <- "" + opt_extra <- "--max-iterations=20" out <- .system_with_capture(texi2dvi, "--help") if(length(grep("--no-line-error", out$stdout))) @@ -365,10 +365,6 @@ function(file, pdf = FALSE, clean = FALSE, quiet = TRUE, ## error messages in log files should work for both regular and ## file line error indicators.) - ## This is present in texinfo after late 2009, so really >= 5.0. - if(any(grepl("--max-iterations=N", out$stdout))) - opt_extra <- c(opt_extra, "--max-iterations=20") - ## and work around a bug in texi2dvi ## https://stat.ethz.ch/pipermail/r-devel/2011-March/060262.html ## That has [A-Za-z], earlier versions [A-z], both of which may be diff --git a/src/library/tools/man/texi2dvi.Rd b/src/library/tools/man/texi2dvi.Rd index d458f5317a5..ee708f3cf91 100644 --- a/src/library/tools/man/texi2dvi.Rd +++ b/src/library/tools/man/texi2dvi.Rd @@ -86,8 +86,8 @@ texi2pdf(file, clean = FALSE, quiet = TRUE, \note{ %% configure just looks for a texi2dvi command and does not check its - %% version. Howvever, it is normally distributed with texinfo, and - %% that is checked to be >= 5.1. + %% version. However, it is normally distributed with texinfo, and + %% that is checked to be >= 6.1. %% The macOS distribution by default installs /usr/local/bin/texi2dvi, %% but that is optional and macOS has /usr/bin/texi2dvi stuck at 4.8. There are various versions of the \command{texi2dvi} script on @@ -104,8 +104,7 @@ texi2pdf(file, clean = FALSE, quiet = TRUE, exist but the other two approaches do not (and may get confused by such files). - Where supported (\command{texi2dvi} 5.0 and later; - \command{texify.exe} from \I{MiKTeX}), option \option{--max-iterations=20} + Option \option{--max-iterations=20} is used to avoid infinite retries. The emulation mode supports \code{quiet = TRUE} from \R 3.2.3 only. From a2be02f56623acb304dbafdd5c8c3e59047d7c77 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 2 Jul 2024 15:43:38 +0000 Subject: [PATCH 336/546] R CMD check --as-cran now notes Rd xrefs with missing package anchors. git-svn-id: https://svn.r-project.org/R/trunk@86861 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 3aa2171ac18..2d6a57f73fd 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -7128,6 +7128,7 @@ add_dummies <- function(dir, Log) Sys.setenv("_R_CHECK_MBCS_CONVERSION_FAILURE_" = "TRUE") Sys.setenv("_R_CHECK_VALIDATE_UTF8_" = "TRUE") Sys.setenv("_R_CXX_USE_NO_REMAP_" = "TRUE") + Sys.setenv("_R_CHECK_XREFS_NOTE_MISSING_PACKAGE_ANCHORS_" = "TRUE") R_check_vc_dirs <- TRUE R_check_executables_exclusions <- FALSE R_check_doc_sizes2 <- TRUE From ed35fb66735b5b7316bd50d4b46c5262faee988e Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 2 Jul 2024 16:30:19 +0000 Subject: [PATCH 337/546] report GCC 14 and rustc warnings git-svn-id: https://svn.r-project.org/R/trunk@86862 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 2d6a57f73fd..85e26f37165 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -5832,9 +5832,13 @@ add_dummies <- function(dir, Log) "\\[-W#warnings\\]", "\\[-Wrange-loop-construct\\]", "\\[-Warray-parameter=\\]", + ## GCC 14's C++ stdlib (as seen for TMB headers) + "\\[-Wtemplate-id-cdtor\\]", ## clang version (not Apple clang) "\\[-Warray-parameter\\]", - "\\[-Wuse-after-free\\]" + "\\[-Wuse-after-free\\]", + ## rustc + "^warning: use of deprecated" ) ## warning most seen with -D_FORTIFY_SOURCE From b4033dc54396d6f30d98f320ba46a9da7ce24e89 Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 2 Jul 2024 17:00:13 +0000 Subject: [PATCH 338/546] grammar and markup git-svn-id: https://svn.r-project.org/R/trunk@86863 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 3688ef73bb6..d9fbc22d938 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -28,11 +28,11 @@ \item New \code{head()} and \code{tail()} methods for class \code{"ts"} time series, proposed by Spencer Graves on R-devel. - \item New \code{qr.influence()}, a \dQuote{bare bones} interface to - the \code{lm.influence()} leave-one-out diagnostics computations; - wished for in \PR{18739}. + \item New \code{qr.influence()} function, a \dQuote{bare bones} + interface to the \code{lm.influence()} leave-one-out diagnostics + computations; wished for in \PR{18739}. - \item New function \code{grepv} identical to \code{grep} except + \item New function \code{grepv()} identical to \code{grep()} except with the default \code{value = TRUE}. } } @@ -153,8 +153,8 @@ \item \command{R CMD check --as-cran} will compile C++ code with \code{-DR_NO_REMAP}. - \item \command{R CMD check --as-cran} notes bad parts in - \file{DESCRIPTION} file URL fields. + \item \command{R CMD check --as-cran} notes bad parts in the + \file{DESCRIPTION} file's URL fields. } } @@ -163,10 +163,10 @@ \item Auto-generated \code{citation()} entries no longer include (additional) URLs in the \samp{note} field (\PR{18547}). - \item \code{as.data.frame.list()} gets new option \code{new.names} + \item \code{as.data.frame.list()} gets a new option \code{new.names} and now preserves \code{NA} names, thus fixing the \code{format()} method for data frames, and also bug \PR{18745}. - \I{Relatedly}, the \code{format()} method gets option \code{cut.names}. + \I{Relatedly}, the \code{format()} method gets an option \code{cut.names}. } } } From 278bf99f891bbb09691d1e958a6c88363331f9d9 Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 2 Jul 2024 18:27:56 +0000 Subject: [PATCH 339/546] update for c86213 git-svn-id: https://svn.r-project.org/R/trunk@86864 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 078f919ceeb..cf0fa16d1bd 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -4499,7 +4499,7 @@ in the rest of this section. File @file{configure} is created from @file{configure.ac} and the files under @file{m4} by @command{autoconf} and @command{aclocal} (part of the @pkg{automake} package). There is a formal version requirement on -@command{autoconf} of 2.71 or later, but it is unlikely that anything +@command{autoconf} of 2.72 or later, but it is unlikely that anything other than the most recent versions@footnote{at the time of revision of this para in early 2024, @pkg{autoconf-2.72} and @pkg{automake-1.16.5}. Previously @pkg{autoconf-2.71} was used.} From e4dd22295857fd7632d39c0604fa9f95f055e236 Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 2 Jul 2024 19:19:56 +0000 Subject: [PATCH 340/546] more xrefs to link manuals git-svn-id: https://svn.r-project.org/R/trunk@86865 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 5 +++-- doc/manual/R-exts.texi | 5 +++-- doc/manual/R-intro.texi | 4 ++-- doc/manual/R-ints.texi | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index cf0fa16d1bd..760ddd49e5b 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -1054,8 +1054,9 @@ Clang 13 and @code{-std=c++23} from Clang 17. Apple Clang supports `Standards' for @command{g++} starting with @samp{gnu} enable `GNU extensions': what those are is hard to track down. -For the use of C++ in @R{} packages see the `Writing R -Extensions' manual. Prior to @R{} 3.6.0 the default C++ standard was +For the use of C++ in @R{} packages, +@pxref{, , , R-exts, Writing R Extensions}. +Prior to @R{} 3.6.0 the default C++ standard was that of the compiler used: currently it is C++17. @uref{https://en.cppreference.com/w/cpp/compiler_support} indicates diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 7b08c37e0ff..75dc904a6ec 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -3380,8 +3380,9 @@ using these utilities. @end quotation @quotation Note to Windows users -@code{R CMD build} may make use of the Windows toolset (see the ``R -Installation and Administration'' manual) if present and in your path, +@code{R CMD build} may make use of the Windows toolset +(@pxref{The Windows toolset, , , R-admin, R Installation and Administration}) +if present and in your path, and it is required for packages which need it to install (including those with @file{configure.win}, @file{cleanup.win}, @file{configure.ucrt} or @file{cleanup.ucrt} scripts or a diff --git a/doc/manual/R-intro.texi b/doc/manual/R-intro.texi index efee497aad7..2c31d3b4dae 100644 --- a/doc/manual/R-intro.texi +++ b/doc/manual/R-intro.texi @@ -2661,7 +2661,7 @@ the @code{read.table()} function. There is also a more primitive input function, @code{scan()}, that can be called directly. For more details on importing data into @R{} and also exporting data, -see the @emph{R Data Import/Export} manual. +@pxref{, , , R-data, R Data Import/Export}. @node The read.table() function @@ -4090,7 +4090,7 @@ A function named @code{@var{gen}.@var{cl}} will be invoked by the generic @code{@var{gen}} for class @code{@var{cl}}, so do not name functions in this style unless they are intended to be methods. -The reader is referred to the @emph{R Language Definition} for a more +The reader is referred to the @ref{, , , R-lang, R Language Definition} for a more complete discussion of this mechanism. diff --git a/doc/manual/R-ints.texi b/doc/manual/R-ints.texi index b5702274ed1..e79ce0a2cf4 100644 --- a/doc/manual/R-ints.texi +++ b/doc/manual/R-ints.texi @@ -4735,7 +4735,7 @@ A simple @command{make}, considering the features of @command{make} in @samp{%}, the automatic variable @samp{$^}, the @samp{+=} syntax to append to the value of a variable, the (``safe'') inclusion of makefiles with no error, conditional execution, and many more, must not be used -(see Chapter ``Features'' in the @cite{@acronym{GNU} Make Manual} for +(@pxref{Features, , , make, The @acronym{GNU} Make Manual} for more information). On the other hand, building @R{} in a separate directory (not containing the sources) should work provided that @command{make} supports the @code{VPATH} mechanism. @@ -4761,8 +4761,8 @@ are available at Under Windows, most users will not have these tools installed, and you should not require their presence for the operation of your package. However, users who install your package from source will have them, as -they can be assumed to have followed the instructions in ``the Windows -toolset'' appendix of the ``R Installation and Administration'' manual +they can be assumed to have followed the instructions in +@ref{The Windows toolset, , , R-admin, R Installation and Administration} to obtain them. Redirection cannot be assumed to be available via @command{system} as this does not use a standard shell (let alone a @I{Bourne} shell). From a3760806d470a7e4016783bfbf84d66310152a80 Mon Sep 17 00:00:00 2001 From: smeyer Date: Tue, 2 Jul 2024 20:06:24 +0000 Subject: [PATCH 341/546] tweak c86865 for HTMLXREF_MODE=none git-svn-id: https://svn.r-project.org/R/trunk@86866 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-ints.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-ints.texi b/doc/manual/R-ints.texi index e79ce0a2cf4..1de60ca86d6 100644 --- a/doc/manual/R-ints.texi +++ b/doc/manual/R-ints.texi @@ -4735,7 +4735,7 @@ A simple @command{make}, considering the features of @command{make} in @samp{%}, the automatic variable @samp{$^}, the @samp{+=} syntax to append to the value of a variable, the (``safe'') inclusion of makefiles with no error, conditional execution, and many more, must not be used -(@pxref{Features, , , make, The @acronym{GNU} Make Manual} for +(see Chapter ``Features'' in the @cite{@acronym{GNU} Make Manual} for more information). On the other hand, building @R{} in a separate directory (not containing the sources) should work provided that @command{make} supports the @code{VPATH} mechanism. From 7648f7c54b0ed0ac28321c8ad37f9b3a3247f771 Mon Sep 17 00:00:00 2001 From: pd Date: Tue, 2 Jul 2024 23:22:48 +0000 Subject: [PATCH 342/546] maintainer-mode changes git-svn-id: https://svn.r-project.org/R/trunk@86867 00db46b3-68df-0310-9c12-caf00c1e9a41 --- configure | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/configure b/configure index d98b6e10ef8..dd6287fab3c 100755 --- a/configure +++ b/configure @@ -5947,27 +5947,27 @@ else case e in #( esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether texi2any version is at least 5.1" >&5 -printf %s "checking whether texi2any version is at least 5.1... " >&6; } -if test ${r_cv_prog_texi2any_v5+y} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether texi2any version is at least 6.1" >&5 +printf %s "checking whether texi2any version is at least 6.1... " >&6; } +if test ${r_cv_prog_texi2any_v6+y} then : printf %s "(cached) " >&6 else case e in #( e) if test -z "${r_cv_prog_texi2any_version_maj}" \ || test -z "${r_cv_prog_texi2any_version_min}"; then - r_cv_prog_texi2any_v5=no -elif test ${r_cv_prog_texi2any_version_maj} -gt 5; then - r_cv_prog_texi2any_v5=yes -elif test ${r_cv_prog_texi2any_version_maj} -lt 5 \ + r_cv_prog_texi2any_v6=no +elif test ${r_cv_prog_texi2any_version_maj} -gt 6; then + r_cv_prog_texi2any_v6=yes +elif test ${r_cv_prog_texi2any_version_maj} -lt 6 \ || test ${r_cv_prog_texi2any_version_min} -lt 1; then - r_cv_prog_texi2any_v5=no + r_cv_prog_texi2any_v6=no else - r_cv_prog_texi2any_v5=yes + r_cv_prog_texi2any_v6=yes fi ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $r_cv_prog_texi2any_v5" >&5 -printf "%s\n" "$r_cv_prog_texi2any_v5" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $r_cv_prog_texi2any_v6" >&5 +printf "%s\n" "$r_cv_prog_texi2any_v6" >&6; } ## Also record whether texi2any is at least 7 to appropriately handle ## HTML and EPUB output changes, see ## . @@ -5975,7 +5975,7 @@ if test ${r_cv_prog_texi2any_v7+y} then : printf %s "(cached) " >&6 else case e in #( - e) if test ${r_cv_prog_texi2any_v5} = yes \ + e) if test ${r_cv_prog_texi2any_v6} = yes \ && test ${r_cv_prog_texi2any_version_maj} -ge 7; then r_cv_prog_texi2any_v7=yes else @@ -6039,7 +6039,7 @@ test -n "$INSTALL_INFO" || INSTALL_INFO="false" fi -if test "${r_cv_prog_texi2any_v5}" != yes; then +if test "${r_cv_prog_texi2any_v6}" != yes; then warn_info="you cannot build info or HTML versions of the R manuals" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: ${warn_info}" >&5 printf "%s\n" "$as_me: WARNING: ${warn_info}" >&2;} From 48c9bacf1277c4cfefc7866c25a9cd3c5887f39f Mon Sep 17 00:00:00 2001 From: smeyer Date: Wed, 3 Jul 2024 11:09:42 +0000 Subject: [PATCH 343/546] fix Up target git-svn-id: https://svn.r-project.org/R/trunk@86868 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/Makefile.in | 1 + doc/manual/Makefile.win | 4 +++- doc/manual/quot.sed | 4 ---- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/manual/Makefile.in b/doc/manual/Makefile.in index 74194bb0d6c..54664622a2d 100644 --- a/doc/manual/Makefile.in +++ b/doc/manual/Makefile.in @@ -97,6 +97,7 @@ docs: html else \ $(ECHO) "creating doc/manual/$@"; \ $(TEXI2HTML) -I$(srcdir) \ + -c TOP_NODE_UP_URL=../html/index.html \ `test $(TEXI2ANY_VERSION_MAJ) -ge 7 && $(ECHO) -c HTMLXREF_MODE=none` \ $< -o $@.tmp || exit 1; \ SED="$(SED)" $(SHELL) $(srcdir)/texi2html.sh \ diff --git a/doc/manual/Makefile.win b/doc/manual/Makefile.win index 969dd9d3679..da1caef6ed9 100644 --- a/doc/manual/Makefile.win +++ b/doc/manual/Makefile.win @@ -61,7 +61,9 @@ all: pdf ifneq "$(TEXI2ANY)" "missing" .texi.html: @$(ECHO) "creating doc/manual/$@" - @$(TEXI2HTML) -I$(srcdir) $< -o $@.tmp || exit 1 + @$(TEXI2HTML) -I$(srcdir) \ + -c TOP_NODE_UP_URL=../html/index.html \ + $< -o $@.tmp || exit 1 @$(SED) -f $(srcdir)/quot.sed $@.tmp > $@ @rm -f $@.tmp diff --git a/doc/manual/quot.sed b/doc/manual/quot.sed index e065f1ab01e..c126735254f 100644 --- a/doc/manual/quot.sed +++ b/doc/manual/quot.sed @@ -1,5 +1 @@ -# obsolete for texi2any >= 7.0 with `-c IGNORE_REF_TO_TOP_NODE_UP=1` -///g - s/
Date: Wed, 3 Jul 2024 18:36:26 +0000 Subject: [PATCH 344/546] updates git-svn-id: https://svn.r-project.org/R/trunk@86869 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 75dc904a6ec..f6f3ea99fae 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -3105,9 +3105,9 @@ The discussion above is about the standard @R{} ways of compiling C++: it will not apply to packages using @file{src/Makefile} or building in a subdirectory that do not set the C++ standard. And compilers' default C++ standards varies widely and gets changed frequently by vendors -- -for example Apple clang up to at least 15 defaults to C++98, @I{LLVM} +for example Apple clang up to at least 16 defaults to C++98, @I{LLVM} clang 14--15 to C++14, @I{LLVM} clang 16--18 to C++17 and @command{g++} -11--13 to C++17. +11--14 to C++17. For a package with a @file{src/Makefile} (or a Windows analogue), a non-default C++ compiler can be selected by including something like @@ -3169,7 +3169,7 @@ compiler is to include an empty C++ file in @file{src}.. @subsection C standards C has had standards C89/C90, C99, C11, C17 (also known as C18), and C23 -is in final draft and expected to be published in early 2024. C11 was a +is in final draft and expected to be published in 2024. C11 was a minor change to C99 which introduced some new features and made others optional, and C17 is a `bug-fix' update to C11. On the other hand, C23 makes extensive changes, including making @code{bool}, @code{true} and From e4a335e5f92910ec44ce72354f29c9f6a783c980 Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 4 Jul 2024 08:05:15 +0000 Subject: [PATCH 345/546] Add declaration for R_findVarInFrame. git-svn-id: https://svn.r-project.org/R/trunk@86871 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/console.c | 2 ++ src/gnuwin32/rt_complete.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gnuwin32/console.c b/src/gnuwin32/console.c index 1395e7abf6a..ceb80c4fb8f 100644 --- a/src/gnuwin32/console.c +++ b/src/gnuwin32/console.c @@ -70,6 +70,8 @@ extern void R_WaitEvent(void); # define alloca(x) __builtin_alloca((x)) #endif +#include + static void performCompletion(control c); diff --git a/src/gnuwin32/rt_complete.c b/src/gnuwin32/rt_complete.c index 133f0b17f53..6613ffa2634 100644 --- a/src/gnuwin32/rt_complete.c +++ b/src/gnuwin32/rt_complete.c @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * file rt_complete.c - * Copyright (C) 2007-2022 The R Core Team. + * Copyright (C) 2007-2024 The R Core Team. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,6 +34,7 @@ #include #include +#include static int completion_available = -1; From 0c6619b89c8a2734cfc1ef3e1fce6447d45b0324 Mon Sep 17 00:00:00 2001 From: smeyer Date: Thu, 4 Jul 2024 20:28:45 +0000 Subject: [PATCH 346/546] fix header git-svn-id: https://svn.r-project.org/R/trunk@86872 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/htmltools.R | 2 +- src/library/tools/R/orcidtools.R | 2 +- src/library/tools/R/toHTML.R | 14 +++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/library/tools/R/htmltools.R b/src/library/tools/R/htmltools.R index ec0bf78c980..9573864ef43 100644 --- a/src/library/tools/R/htmltools.R +++ b/src/library/tools/R/htmltools.R @@ -1,4 +1,4 @@ -# File src/library/tools/R/CRANtools.R +# File src/library/tools/R/htmltools.R # Part of the R package, https://www.R-project.org # # Copyright (C) 2022-2024 The R Core Team diff --git a/src/library/tools/R/orcidtools.R b/src/library/tools/R/orcidtools.R index ca7e3c7597d..c698d4a5a0e 100644 --- a/src/library/tools/R/orcidtools.R +++ b/src/library/tools/R/orcidtools.R @@ -1,4 +1,4 @@ -# File src/library/tools/R/utils.R +# File src/library/tools/R/orcidtools.R # Part of the R package, https://www.R-project.org # # Copyright (C) 2024 The R Core Team diff --git a/src/library/tools/R/toHTML.R b/src/library/tools/R/toHTML.R index 37d0bca358c..22e2a11c93c 100644 --- a/src/library/tools/R/toHTML.R +++ b/src/library/tools/R/toHTML.R @@ -1,7 +1,9 @@ -toHTML <- function(x, ...) UseMethod("toHTML") - +# File src/library/tools/R/toHTML.R +# Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2021 The R Core Team +# Copyright (C) 1995-2024 The R Core Team + +toHTML <- function(x, ...) UseMethod("toHTML") HTMLheader <- function(title="R", logo=TRUE, @@ -539,9 +541,3 @@ HTMLcomponents <- function(title = "R", logo = FALSE, return(list(header = header, footer = footer)) } - - - - - - From f398b61032fe9248638bc38fac77cfa4a9b151e5 Mon Sep 17 00:00:00 2001 From: smeyer Date: Thu, 4 Jul 2024 21:36:32 +0000 Subject: [PATCH 347/546] fix browsing subsets of R-devel news() git-svn-id: https://svn.r-project.org/R/trunk@86873 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/toHTML.R | 6 +++--- src/library/utils/man/news.Rd | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/library/tools/R/toHTML.R b/src/library/tools/R/toHTML.R index 22e2a11c93c..d75a3aff362 100644 --- a/src/library/tools/R/toHTML.R +++ b/src/library/tools/R/toHTML.R @@ -122,9 +122,9 @@ function(x, ...) vchunks <- split(x, x$Version) vchunks <- - vchunks[order(as.numeric_version(sub(" *patched", ".1", - names(vchunks))), - decreasing = TRUE)] + vchunks[order(numeric_version(sub(" *patched", ".1", names(vchunks)), + strict = FALSE), # "R-devel" -> NA + na.last = FALSE, decreasing = TRUE)] dates <- vapply(vchunks, function(v) v$Date[1L], "") vheaders <- sprintf("

Changes in version %s%s

", names(vchunks), diff --git a/src/library/utils/man/news.Rd b/src/library/utils/man/news.Rd index 073bcfdaec1..13320816261 100644 --- a/src/library/utils/man/news.Rd +++ b/src/library/utils/man/news.Rd @@ -1,6 +1,6 @@ % File src/library/utils/man/news.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2023 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{news} @@ -143,6 +143,7 @@ db <- news() \dontshow{ vv <- capture.output(print(db, doBrowse=FALSE)) # without an error stopifnot(is.character(vv), length(vv) >= 3) # was wrong (for weeks during devel.) + html <- tools::toHTML(subset(db, is.na(Version))) # emulate doBrowse with query } ## Bug fixes with PR number in 4.0.0. db4 <- news(Version == "4.0.0" & grepl("^BUG", Category) & grepl("PR#", Text), From d878dbbaa3de0f6b3885511e3ad613dc92409e1b Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 5 Jul 2024 22:43:25 +0000 Subject: [PATCH 348/546] fprec() & fround(): swap back to correct descriptions (PR#18755) git-svn-id: https://svn.r-project.org/R/trunk@86874 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index f6f3ea99fae..62bdc5a3fbe 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -16026,16 +16026,16 @@ Performs ``transfer of sign'' and is defined as @eqn{|x| * @apifun fprec @deftypefun double fprec (double @var{x}, double @var{digits}) -Returns the value of @var{x} rounded to @var{digits} decimal digits -(after the decimal point). +Returns the value of @var{x} rounded to @var{digits} @emph{significant} +decimal digits. This is the function used by @R{}'s @code{signif()}. @end deftypefun @apifun fround @deftypefun double fround (double @var{x}, double @var{digits}) -Returns the value of @var{x} rounded to @var{digits} @emph{significant} -decimal digits. +Returns the value of @var{x} rounded to @var{digits} decimal digits +(after the decimal point). This is the function used by @R{}'s @code{round()}. (Note that C99/C++11 provide a @code{round} function but C++98 need not.) From 4c237447db6ec810fc17e3e133f3e3831c772f94 Mon Sep 17 00:00:00 2001 From: maechler Date: Sun, 7 Jul 2024 10:21:53 +0000 Subject: [PATCH 349/546] add info about change of is.atomic(NULL) [PR#18752] git-svn-id: https://svn.r-project.org/R/trunk@86876 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/is.recursive.Rd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/library/base/man/is.recursive.Rd b/src/library/base/man/is.recursive.Rd index 05da75ad183..82fdeeaa5cd 100644 --- a/src/library/base/man/is.recursive.Rd +++ b/src/library/base/man/is.recursive.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/is.recursive.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2023 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{is.recursive} @@ -14,6 +14,7 @@ is.recursive(x) \description{ \code{is.atomic} returns \code{TRUE} if \code{x} is of an atomic type and \code{FALSE} otherwise. + \code{is.atomic(NULL) returns \code{FALSE} since \R version 4.4.0. \code{is.recursive} returns \code{TRUE} if \code{x} has a recursive (list-like) structure and \code{FALSE} otherwise. @@ -60,6 +61,10 @@ is.a.r(y ~ x) # FALSE TRUE is.a.r(expression(x+1)) # FALSE TRUE is.a.r(quote(exp)) # FALSE FALSE is.a.r(NULL) # FALSE FALSE + +# Reproduce pre-4.4 behavior of is.atomic() +is.atomicN <- function(x) is.atomic(x) || is.null(x) +is.atomicN(NULL) # TRUE } \keyword{programming} \keyword{classes} From 485093dde57352bc9644b4d56a9cef871b4796df Mon Sep 17 00:00:00 2001 From: maechler Date: Sun, 7 Jul 2024 12:28:10 +0000 Subject: [PATCH 350/546] + '}' git-svn-id: https://svn.r-project.org/R/trunk@86878 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/is.recursive.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/base/man/is.recursive.Rd b/src/library/base/man/is.recursive.Rd index 82fdeeaa5cd..6b3fa4cbc0f 100644 --- a/src/library/base/man/is.recursive.Rd +++ b/src/library/base/man/is.recursive.Rd @@ -14,7 +14,7 @@ is.recursive(x) \description{ \code{is.atomic} returns \code{TRUE} if \code{x} is of an atomic type and \code{FALSE} otherwise. - \code{is.atomic(NULL) returns \code{FALSE} since \R version 4.4.0. + \code{is.atomic(NULL)} returns \code{FALSE} since \R version 4.4.0. \code{is.recursive} returns \code{TRUE} if \code{x} has a recursive (list-like) structure and \code{FALSE} otherwise. From 6eca907cce2eb2c5c91845bb9713f501be68045e Mon Sep 17 00:00:00 2001 From: smeyer Date: Sun, 7 Jul 2024 16:31:47 +0000 Subject: [PATCH 351/546] amend help(ave) (PR#17753) git-svn-id: https://svn.r-project.org/R/trunk@86880 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/stats/man/ave.Rd | 43 +++++++++++++++++++------------ tests/Examples/stats-Ex.Rout.save | 9 ++++++- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/library/stats/man/ave.Rd b/src/library/stats/man/ave.Rd index f92912d848f..4342eca2003 100644 --- a/src/library/stats/man/ave.Rd +++ b/src/library/stats/man/ave.Rd @@ -1,31 +1,38 @@ % File src/library/stats/man/ave.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2007 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{ave} +\alias{ave} \title{Group Averages Over Level Combinations of Factors} +\description{ + A function is applied to subsets of a vector \code{x}, where each + subset consists of those observations with the same factor levels. + The \code{\link{mean}} function is applied by default, + replacing the values in each group by the group \emph{ave}rage. +} \usage{ ave(x, \dots, FUN = mean) } -\alias{ave} \arguments{ - \item{x}{A numeric.} - \item{\dots}{Grouping variables, typically factors, all of the same - \code{length} as \code{x}.} - \item{FUN}{Function to apply for each factor level combination.} -} -\description{ - Subsets of \code{x[]} are averaged, where each subset consist of those - observations with the same factor levels. + \item{x}{a vector, typically numeric.} + \item{\dots}{grouping variables, typically factors, all of the same + length as \code{x}. Groups are defined by the + \code{\link{interaction}} of these variables.} + \item{FUN}{a function to apply for each factor level combination. + (NOTE: If given, this argument must be named.)} } \value{ - A numeric vector, say \code{y} of length \code{length(x)}. - If \code{\dots} is \code{g1, g2}, e.g., - \code{y[i]} is equal to \code{FUN(x[j]}, for all \code{j} with - \code{g1[j] == g1[i]} and \code{g2[j] == g2[i])}. + A vector, say \code{y}, of the same length as \code{x}. + If grouping variables are missing, all elements of \code{y} are equal + to \code{FUN(x)}. Otherwise, if, e.g., \code{\dots} is \code{g1, g2}, + \code{y[i]} is equal to \code{FUN(x[sub])} with \code{sub} comprising all + \code{j} for which \code{g1[j] == g1[i]} and \code{g2[j] == g2[i]}. +} +\seealso{ + \code{\link{mean}}, \code{\link{split}}, \code{\link{tapply}}. } -\seealso{\code{\link{mean}}, \code{\link{median}}.} \examples{ require(graphics) @@ -42,6 +49,10 @@ lines(ave(breaks, wool, tension, FUN = median), type = "s", col = "green") legend(40, 70, c("mean", "median"), lty = 1, col = c("blue","green"), bg = "gray90") detach() + +# Running index per group +(g <- sample(c("u","s","e","R"), 24, replace = TRUE)) +ave(seq_along(g), g, FUN = seq_along) } \keyword{univar} - +\keyword{category} diff --git a/tests/Examples/stats-Ex.Rout.save b/tests/Examples/stats-Ex.Rout.save index 3223c792851..5c8e7f58c65 100644 --- a/tests/Examples/stats-Ex.Rout.save +++ b/tests/Examples/stats-Ex.Rout.save @@ -4074,7 +4074,7 @@ sigma^2 estimated as 0.4566: log likelihood = -101.2, aic = 212.4 > ### Name: ave > ### Title: Group Averages Over Level Combinations of Factors > ### Aliases: ave -> ### Keywords: univar +> ### Keywords: univar category > > ### ** Examples > @@ -4115,6 +4115,13 @@ sigma^2 estimated as 0.4566: log likelihood = -101.2, aic = 212.4 + col = c("blue","green"), bg = "gray90") > detach() > +> # Running index per group +> (g <- sample(c("u","s","e","R"), 24, replace = TRUE)) + [1] "u" "R" "e" "u" "s" "u" "e" "e" "s" "s" "e" "e" "u" "u" "u" "s" "s" "s" "s" +[20] "e" "u" "e" "u" "u" +> ave(seq_along(g), g, FUN = seq_along) + [1] 1 1 1 2 1 3 2 3 2 3 4 5 4 5 6 4 5 6 7 6 7 7 8 9 +> > > > cleanEx() From b94e919c84531106fcf97972fff9764fa664fa7d Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 8 Jul 2024 08:12:05 +0000 Subject: [PATCH 352/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86881 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index afc617bf113..7900b6e0756 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -9,7 +9,7 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Belgium (Antwerp) [https]",Belgium,Antwerp,https://www.freestatistics.org/cran/,"Patrick Wessa","patrick # wessa.net",1,be "Belgium (Brussels) [https]",Belgium,Brussels,https://ftp.belnet.be/mirror/CRAN/,"Belnet, the Belgian research and education network","ftpmaint # belnet.be",1,be,"secure_mirror_from_master" "Brazil (PR) [https]",Brazil,Curitiba,https://cran-r.c3sl.ufpr.br/,"Universidade Federal do Parana","root # c3sl.ufpr.br",1,br,"secure_mirror_from_master" -"Brazil (RJ) [https]",Brazil,"Rio de Janeiro",https://cran.fiocruz.br/,"Oswaldo Cruz Foundation, Rio de Janeiro","oswaldo.cruz # fiocruz.br",1,br,"secure_mirror_from_master" +"Brazil (RJ) [https]",Brazil,"Rio de Janeiro",https://cran.fiocruz.br/,"Oswaldo Cruz Foundation, Rio de Janeiro","oswaldo.cruz # fiocruz.br",0,br,"secure_mirror_from_master" "Brazil (SP 1) [https]",Brazil,"Sao Paulo",https://vps.fmvz.usp.br/CRAN/,"University of Sao Paulo, Sao Paulo","Fernando Ferreira ",1,br,"secure_mirror_from_master" "Brazil (SP 2) [https]",Brazil,Piracicaba,https://brieger.esalq.usp.br/CRAN/,"University of Sao Paulo, Piracicaba","A Augusto F Garcia , augusto.garcia # usp.br",1,br,"secure_mirror_from_master" "Bulgaria [https]",Bulgaria,Sofia,https://ftp.uni-sofia.bg/CRAN/,"Sofia University","Alexander Velin ",1,bg,"secure_mirror_from_master" From c7a5168d9875c693d1c4d54c7ba9d9d859098e73 Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 8 Jul 2024 08:18:23 +0000 Subject: [PATCH 353/546] tweaks - stress using Rf_error in C++ code - modernize some Fortran - mention ways to compute Fortran module dependencies. git-svn-id: https://svn.r-project.org/R/trunk@86882 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 62bdc5a3fbe..8c279a3b02f 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -2918,6 +2918,11 @@ cmi.o dmi.o: iface.o @end example @noindent +Some maintainers have found it difficult to find @emph{all} the module +dependencies which leads to hard-to-reproduce installation failures. +There are tools available to find these, including the Intel compiler's +flag @option{-gen-dep} and @code{makedepf90}. + Note that it is not portable (although some platforms do accept it) to define a module of the same name in multiple source files. @c As was done by frailtypack in 2018-12: gfortran accepted this, ODS @@ -12557,7 +12562,7 @@ indicate @var{TRUE} or @var{FALSE}. What happens if the @code{SEXP} is not of the correct type? Sometimes you have no other option except to generate an error. You can use the -function @code{error} for this. It is usually better to coerce the +function @code{Rf_error} for this. It is usually better to coerce the object to the correct type. For example, if you find that an @code{SEXP} is of the type @code{INTEGER}, but you need a @code{REAL} object, you can change the type by using @@ -15020,8 +15025,9 @@ simplest case can be called with a single character string argument giving the error message. (Don't do this if the string contains @samp{%} or might otherwise be interpreted as a format.) -These are defined in header @file{R_ext/Error.h} included by -@file{R.h}. +These are defined in header @file{R_ext/Error.h} included by @file{R.h}. +@strong{NB}: when @code{R_NO_REMAP} is defined (as is recommeneded for +C++ code), @code{Rf_error} etc must be used. @c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0 @@ -15033,8 +15039,8 @@ These are defined in header @file{R_ext/Error.h} included by @subsection Error signaling from Fortran @cindex Error signaling from Fortran -There are two interface function provided to call @code{error} and -@code{warning} from Fortran code, in each case with a simple character +There are two interface function provided to call @code{Rf_error} and +@code{Rf_warning} from Fortran code, in each case with a simple character string argument. They are defined as @example @@ -15157,7 +15163,7 @@ by something like (fixed-form Fortran 90 code): subroutine putRNGseed() bind(C, name = "PutRNGstate") end subroutine putRNGseed end interface - end module + end module rngfuncs subroutine testit use rngfuncs @@ -15166,7 +15172,7 @@ by something like (fixed-form Fortran 90 code): X = unifRand() print *, X call putRNGSeed() - end + end subroutine testit @end example @@ -16551,7 +16557,7 @@ These are currently implemented using the R-level @code{tryCatch} mechanism so are subject to some overhead. @code{R_withCallingErrorHandler} establishes a calling handler for -conditions inheriting form class @code{error}. It establishes the +conditions inheriting from class @code{error}. It establishes the handler without calling back into @R{} and will therefore be more efficient. From 86b758a93839f2297d567438be74b202849efaa6 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 8 Jul 2024 10:08:31 +0000 Subject: [PATCH 354/546] Improvements by Ivan Krylov. git-svn-id: https://svn.r-project.org/R/trunk@86884 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-FAQ.texi | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/doc/manual/R-FAQ.texi b/doc/manual/R-FAQ.texi index 9c62e93572a..93483261dc9 100644 --- a/doc/manual/R-FAQ.texi +++ b/doc/manual/R-FAQ.texi @@ -503,9 +503,6 @@ Extra Packages for Enterprise Linux (@abbr{EPEL}) project @abbr{RPM}s for @I{RedHat Enterprise Linux} and compatible distributions (e.g., @I{Centos}, Scientific Linux, Oracle Linux). -See @url{https://CRAN.R-project.org/bin/linux/suse/README.html} for -information about @abbr{RPM}s for openSUSE. - No other binary distributions are currently publicly available via @CRAN{}. @@ -2624,7 +2621,32 @@ vars[["a"]] @end example @noindent -without any of this messing about. +without any of this messing about. This becomes especially true if you +are finding yourself creating and trying to programmatically access +groups of related variables such as @code{result1}, @code{result2}, +@code{result3}, and so on: instead of fighting against the language to +use + +@example +assign(paste0("result", i), process(get(paste0("dataset", i)))) +@end example + +@noindent +it is much easier to put the related variables in lists and use + +@example +result[[i]] <- process(dataset[[i]]) +@end example + +@noindent +and, eventually, + +@example +result <- lapply(dataset, process) +@end example + +@noindent +which is easy to replace with @code{parLapply} for parallel processing. @node Why do lattice/trellis graphics not work? @section Why do lattice/trellis graphics not work? From 1f537a2469956b505ad10135eeee282fe33a8475 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 8 Jul 2024 13:10:50 +0000 Subject: [PATCH 355/546] =?UTF-8?q?Improvements=20by=20I=C3=B1aki=20Ucar.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.r-project.org/R/trunk@86885 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-FAQ.texi | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/doc/manual/R-FAQ.texi b/doc/manual/R-FAQ.texi index 93483261dc9..2268d968cd1 100644 --- a/doc/manual/R-FAQ.texi +++ b/doc/manual/R-FAQ.texi @@ -483,25 +483,27 @@ provided by @I{Michael Rutter}, see @url{https://CRAN.R-project.org/bin/linux/ubuntu/index.html} for instructions. -R binaries for Fedora, maintained by @I{Tom ``Spot'' Callaway}, are provided -as part of the Fedora distribution and can be accessed through -@command{yum}, the @abbr{RPM} installer/updater. Note that the ``Software'' -application (gnome-software), which is the default @acronym{GUI} for -software installation in Fedora 20, cannot be used to install R. It is -therefore recommended to use the yum command line tool. -The Fedora R @abbr{RPM} is a ``meta-package'' which installs all the user and -developer components of R (available separately as @code{R-core} and -@code{R-devel}), as well as @code{R-java}, which ensures that R is -configured for use with Java. The R @abbr{RPM} also installs the standalone R -math library (@code{libRmath} and @code{libRmath-devel}), although this -is not necessary to use R. When a new version of R is released, there -may be a delay of up to 2 weeks until the Fedora @abbr{RPM} becomes publicly -available, as it must pass through the Fedora review process. -@abbr{RPM}s for a selection of R packages are also provided by Fedora. The -Extra Packages for Enterprise Linux (@abbr{EPEL}) project -(@url{https://docs.fedoraproject.org/en-US/epel/}) provides ports of the Fedora -@abbr{RPM}s for @I{RedHat Enterprise Linux} and compatible distributions (e.g., -@I{Centos}, Scientific Linux, Oracle Linux). +R binaries for Fedora, maintained by @I{Tom ``Spot'' Callaway} and +@I{IƱaki Ucar}, are provided as part of the Fedora distribution and can +be accessed through @command{dnf}, the @abbr{RPM} installer/updater. +The Fedora R @abbr{RPM} is a ``meta-package'' which installs all the +user and developer components of R (available separately as +@code{R-core} and @code{R-core-devel}), as well as @code{R-java} and +@code{R-java-devel}, which ensures that R is configured for use with +Java. The R @abbr{RPM} also installs the standalone R math library +(@code{libRmath} and @code{libRmath-devel}), although this is not +necessary to use R. When a new version of R is released, there may be a +delay of up to 2 weeks until the Fedora @abbr{RPM} becomes publicly +available, as it must pass through the Fedora update process. +The Extra Packages for Enterprise Linux (@abbr{EPEL}) project +(@url{https://docs.fedoraproject.org/en-US/epel/}) provides ports of the +Fedora @abbr{RPM}s for @I{RedHat Enterprise Linux} and compatible +distributions (e.g., @I{CentOS Stream}, @I{Scientific Linux}, @I{Oracle +Linux}, @I{AlmaLinux}, or @I{Rocky Linux} among others). +@abbr{RPM}s for selection of R packages are also provided by Fedora. +Additional @abbr{RPM}s for R packages are maintained by @I{IƱaki Ucar} +on @I{Fedora Copr}. See @url{https://CRAN.R-project.org/bin/linux/fedora/} +for further details and installation instructions. No other binary distributions are currently publicly available via @CRAN{}. From e0f5c5e1c60bca2b7b2044eb0b4770e287cd770e Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 8 Jul 2024 13:10:59 +0000 Subject: [PATCH 356/546] Spelling. git-svn-id: https://svn.r-project.org/R/trunk@86886 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 8c279a3b02f..cc88fe68e2b 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -15026,7 +15026,7 @@ giving the error message. (Don't do this if the string contains @samp{%} or might otherwise be interpreted as a format.) These are defined in header @file{R_ext/Error.h} included by @file{R.h}. -@strong{NB}: when @code{R_NO_REMAP} is defined (as is recommeneded for +@strong{NB}: when @code{R_NO_REMAP} is defined (as is recommended for C++ code), @code{Rf_error} etc must be used. From 53bbd920926a6263bf0e870fa142c6171f37ec01 Mon Sep 17 00:00:00 2001 From: smeyer Date: Wed, 10 Jul 2024 18:30:16 +0000 Subject: [PATCH 357/546] drop outdated note git-svn-id: https://svn.r-project.org/R/trunk@86887 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/cbind.Rd | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/library/base/man/cbind.Rd b/src/library/base/man/cbind.Rd index 3a621dca115..0065db8eefa 100644 --- a/src/library/base/man/cbind.Rd +++ b/src/library/base/man/cbind.Rd @@ -93,9 +93,7 @@ rbind(\dots, deparse.level = 1) \section{Data frame methods}{ The \code{cbind} data frame method is just a wrapper for \code{\link{data.frame}(..., check.names = FALSE)}. This means that - it will split matrix columns in data frame arguments, and convert - character columns to factors unless \code{stringsAsFactors = FALSE} is - specified. + it will split matrix columns in data frame arguments. The \code{rbind} data frame method first drops all zero-column and zero-row arguments. (If that leaves none, it returns the first From 4fbc3b91bbef4927e61a6db55d566a56ee03c2e3 Mon Sep 17 00:00:00 2001 From: smeyer Date: Wed, 10 Jul 2024 21:05:16 +0000 Subject: [PATCH 358/546] tweak c81891 git-svn-id: https://svn.r-project.org/R/trunk@86888 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/Rd.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/Rd.R b/src/library/tools/R/Rd.R index e9b79d6b916..82ead53dab7 100644 --- a/src/library/tools/R/Rd.R +++ b/src/library/tools/R/Rd.R @@ -626,7 +626,7 @@ function(x, predicate) ## Determine whether Rd has \Sexprs which R CMD build needs to handle at ## build stage (expand into the partial Rd db), "later" (build ## refman.pdf) or "never" (\Sexprs from \PR or \doi can always safely -## be expanded). +## be expanded). Needs unprocessed install \Sexprs. .Rd_get_Sexpr_build_time_info <- function(x) @@ -649,7 +649,7 @@ function(x) function(e) { flags <- getDynamicFlags(e) if(flags["build"]) - "build" + return("build") else if(flags["install"]) { s <- trimws(paste(as.character(e), collapse = "")) From e0b704c160183d283f7aa381446c7994dc365085 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 11 Jul 2024 06:42:01 +0000 Subject: [PATCH 359/546] Drop R_InputHanders from tools:::nonAPI. git-svn-id: https://svn.r-project.org/R/trunk@86889 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/sotools.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index b73cdf7cd65..e3dfca7156a 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -635,7 +635,7 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "R_DefCallbacks", "R_DefParams", "R_DefParamsEx", "R_DirtyImage", "R_GUIType", "R_GlobalContext", "R_HistoryFile", "R_HistorySize", "R_Home", "R_HomeDir", - "R_InputHandlers", "R_Interactive", "R_Outputfile", + "R_Interactive", "R_Outputfile", "R_PolledEvents", "R_ReplDLLdo1", "R_ReplDLLinit", "R_RestoreGlobalEnv", "R_RestoreGlobalEnvFromFile", "R_RestoreHistory", "R_RunExitFinalizers", "R_SaveGlobalEnv", From 09f3acb92dcc180636a7c4e257491302e9a22ae8 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 11 Jul 2024 07:34:14 +0000 Subject: [PATCH 360/546] Mark R_InputHandlers as @embvar. git-svn-id: https://svn.r-project.org/R/trunk@86890 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index cc88fe68e2b..c84c34b8ca2 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -18097,12 +18097,14 @@ interval (@emph{via} @code{R_wait_usec}) and a function to be called periodically @emph{via} @code{R_PolledEvents}: the polling mechanism is used by the @pkg{tcltk} package. Input handlers are managed with @code{addInputHandler},@code{getInputHandler}, and -@code{removeInputHandler}. +@code{removeInputHandler}. The handlers are held in a linked list +@code{R_InputHandlers}. @embfun R_PolledEvents @embfun R_wait_usec @embfun addInputHandler @embfun getInputHandler @embfun removeInputHandler +@embvar R_InputHandlers It is not intended that these facilities are used by packages, but if they are needed exceptionally, the package should ensure that it cleans From 64d4bdf18c3a7b3459769c4cbd2b39c311bd8355 Mon Sep 17 00:00:00 2001 From: urbaneks Date: Fri, 12 Jul 2024 12:00:27 +0000 Subject: [PATCH 361/546] fix Quartz segfault due to spaces in font paths (PR#18758) git-svn-id: https://svn.r-project.org/R/trunk@86891 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/grDevices/src/devQuartz.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/library/grDevices/src/devQuartz.c b/src/library/grDevices/src/devQuartz.c index 8358fc29d86..9cabea16ff3 100644 --- a/src/library/grDevices/src/devQuartz.c +++ b/src/library/grDevices/src/devQuartz.c @@ -3002,14 +3002,12 @@ void RQuartz_glyph(int n, int *glyphs, double *x, double *y, Rboolean grouping = QuartzBegin(&ctx, &layer, xd); - char url[501]; - snprintf(url, 500, "file://%s", R_GE_glyphFontFile(font)); - CFStringRef cfFontFileName = - CFStringCreateWithCString(NULL, url, kCFStringEncodingUTF8); - CFURLRef cfFontURL = CFURLCreateWithString(NULL, cfFontFileName, NULL); + const char* path = R_GE_glyphFontFile(font); + CFURLRef cfFontURL = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8*)path, strlen(path), false); + if (!cfFontURL) + error(_("Invalid font path: \"%s\""), path); CFArrayRef cfFontDescriptors = CTFontManagerCreateFontDescriptorsFromURL(cfFontURL); - CFRelease(cfFontFileName); CFRelease(cfFontURL); int n_fonts = CFArrayGetCount(cfFontDescriptors); if (n_fonts > 0) { From 9010044532fc616f9b5c3d5d3517dbb161820ec3 Mon Sep 17 00:00:00 2001 From: urbaneks Date: Fri, 12 Jul 2024 12:10:59 +0000 Subject: [PATCH 362/546] update NEWS git-svn-id: https://svn.r-project.org/R/trunk@86892 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index d9fbc22d938..e4f68294a2d 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -233,6 +233,10 @@ result and no explanation in \file{00check.log}) for a package which declares an invalid \code{VignetteBuilder} in \file{DESCRIPTION} but has no vignettes. + + \item The Quartz device could segfault in cases where paths with + spaces are used in the new glyph drawing API. Thanks to Tomek + Gieorgijewski (\PR{18758}). } } } From 1cd78c0d0a2ba61b719622b5c45b2701c2a55934 Mon Sep 17 00:00:00 2001 From: smeyer Date: Fri, 12 Jul 2024 14:24:42 +0000 Subject: [PATCH 363/546] tweak @key markup (PR#18756) git-svn-id: https://svn.r-project.org/R/trunk@86893 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 4 ++-- doc/manual/rw-FAQ.texi | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index c84c34b8ca2..d5722b930f9 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -9186,7 +9186,7 @@ also accepted @itemize @bullet @item @code{n} -Enter `step-through' mode. In this mode, hitting return executes the +Enter `step-through' mode. In this mode, hitting the return key (@key{RET}) executes the next line of code (more precisely one line and any continuation lines). Typing @code{c} will continue to the end of the current context, e.g.@: to the end of the current loop or function. @@ -10304,7 +10304,7 @@ prompt. @item Set the breakpoints in your code. @item -Continue execution of @R{} by typing @kbd{signal 0@key{RET}}. +Continue execution of @R{} by typing @kbd{signal 0} and hitting return (@key{RET}). @end itemize Under Windows signals may not be able to be used, and if so the procedure is diff --git a/doc/manual/rw-FAQ.texi b/doc/manual/rw-FAQ.texi index 37a6a72ddb5..335aabc7c6e 100644 --- a/doc/manual/rw-FAQ.texi +++ b/doc/manual/rw-FAQ.texi @@ -1500,8 +1500,8 @@ installation can be tested. @itemize @bullet @item R commands can be interrupted by @key{Esc} in @command{Rgui.exe} -and @key{Ctrl-break} or @key{Ctrl-C} in @command{Rterm.exe}: -@key{Ctrl-C} is used for copying in @command{Rgui.exe}. +and @kbd{Ctrl-break} or @kbd{Ctrl-C} in @command{Rterm.exe}: +@kbd{Ctrl-C} is used for copying in @command{Rgui.exe}. @item Command-line editing is always available, but is somewhat simpler than the @@ -1593,12 +1593,12 @@ act on it). @node What does TAB completion do? @section What does TAB completion do? -Both @command{Rgui} and @command{Rterm} support @kbd{TAB} completion. -Hitting @kbd{TAB} whilst entering a command line completes the current -`word' as far as is unambiguously possible. Hitting @kbd{TAB} a second +Both @command{Rgui} and @command{Rterm} support @key{TAB} completion. +Hitting @key{TAB} whilst entering a command line completes the current +`word' as far as is unambiguously possible. Hitting @key{TAB} a second time then shows a list of possible completions (or the first few if there are many): the user can then enter one or more characters and hit -@kbd{TAB} again. +@key{TAB} again. What is it `completing'? There are two modes: within an unterminated (single- or double-) quoted expression it completes file @@ -1607,7 +1607,7 @@ file paths, but can complete most relative or absolute file paths, including drives and spaces. Relative paths on drives are not handled, for example.} Otherwise, it is completing R expressions: most obviously it will match visible R object names and keywords, so @kbd{apr} followed -by @kbd{TAB} will (in a vanilla session) complete to @code{apropos}. +by @key{TAB} will (in a vanilla session) complete to @code{apropos}. After a function name and parenthesis (e.g.@: @kbd{apropos(}) it will complete argument names (and @kbd{=}), and after @kbd{$} or @kbd{@@} it will complete list components or slot names respectively. @@ -1698,7 +1698,7 @@ and so these problems should disappear. This is deliberate: the console output is buffered and re-written in chunks to be faster and less distracting. You can turn buffering off or -on from the `Misc' menu or the right-click menu: @key{Ctrl-W} toggles +on from the `Misc' menu or the right-click menu: @kbd{Ctrl-W} toggles the setting. If you are sourcing R code or writing from a function, there is another @@ -1711,7 +1711,7 @@ the buffer and so update the console. They only @strong{seem} to be truncated: that $ at the end indicates you can scroll the window to see the rest of the line. Use the horizontal -scrollbar or the @key{CTRL + left/right arrow} keys to scroll +scrollbar or the @kbd{@key{CTRL} + left/right arrow} keys to scroll horizontally. (The @key{left/right arrow} keys work in the pager too.) From 112a6e790033257b8276c39db2f9e9b852d87848 Mon Sep 17 00:00:00 2001 From: smeyer Date: Sat, 13 Jul 2024 15:42:10 +0000 Subject: [PATCH 364/546] provide PDF metadata options 'author', 'timestamp' and 'producer' git-svn-id: https://svn.r-project.org/R/trunk@86894 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 5 +++ src/library/grDevices/R/postscript.R | 14 +++++-- src/library/grDevices/man/pdf.Rd | 12 +++++- src/library/grDevices/man/pdf.options.Rd | 16 ++++---- src/library/grDevices/src/devPS.c | 50 ++++++++++++++++++------ src/library/grDevices/src/grDevices.h | 5 ++- src/library/grDevices/src/init.c | 4 +- src/library/grDevices/tests/grDev-tsts.R | 11 ++++++ tests/Examples/grDevices-Ex.Rout.save | 7 +++- 9 files changed, 93 insertions(+), 31 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index e4f68294a2d..1a80cdac882 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -34,6 +34,11 @@ \item New function \code{grepv()} identical to \code{grep()} except with the default \code{value = TRUE}. + + \item \code{pdf()} gains an \code{author} argument to set the + corresponding metadata field, and logical arguments + \code{timestamp} and \code{producer} to optionally omit the + respective metadata. (Thanks to Edzer Pebesma.) } } diff --git a/src/library/grDevices/R/postscript.R b/src/library/grDevices/R/postscript.R index 3192f50983e..d4e40a8e894 100644 --- a/src/library/grDevices/R/postscript.R +++ b/src/library/grDevices/R/postscript.R @@ -303,7 +303,8 @@ xfig <- function (file = if(onefile) "Rplots.fig" else "Rplot%03d.fig", pdf <- function(file = if(onefile) "Rplots.pdf" else "Rplot%03d.pdf", width, height, onefile, family, title, fonts, version, paper, encoding, bg, fg, pointsize, pagecentre, colormodel, - useDingbats, useKerning, fillOddEven, compress) + useDingbats, useKerning, fillOddEven, compress, + timestamp, producer, author) { ## do initialization if needed initPSandPDFfonts() @@ -327,6 +328,9 @@ pdf <- function(file = if(onefile) "Rplots.pdf" else "Rplot%03d.pdf", if(!missing(useKerning)) new$useKerning <- useKerning if(!missing(fillOddEven)) new$fillOddEven <- fillOddEven if(!missing(compress)) new$compress <- compress + if(!missing(timestamp)) new$timestamp <- timestamp + if(!missing(producer)) new$producer <- producer + if(!missing(author)) new$author <- author old <- check.options(new, name.opt = ".PDF.Options", envir = .PSenv) @@ -378,7 +382,8 @@ pdf <- function(file = if(onefile) "Rplots.pdf" else "Rplot%03d.pdf", old$width, old$height, old$pointsize, onefile, old$pagecentre, old$title, old$fonts, version[1L], version[2L], old$colormodel, old$useDingbats, old$useKerning, - old$fillOddEven, old$compress) + old$fillOddEven, old$compress, + old$timestamp, old$producer, old$author) invisible() } @@ -686,7 +691,10 @@ assign(".PDF.Options", useDingbats = FALSE, useKerning = TRUE, fillOddEven = FALSE, - compress = TRUE), envir = .PSenv) + compress = TRUE, + timestamp = TRUE, + producer = TRUE, + author = ""), envir = .PSenv) assign(".PDF.Options.default", get(".PDF.Options", envir = .PSenv), envir = .PSenv) diff --git a/src/library/grDevices/man/pdf.Rd b/src/library/grDevices/man/pdf.Rd index 5d040bbf3a2..532dc208e30 100644 --- a/src/library/grDevices/man/pdf.Rd +++ b/src/library/grDevices/man/pdf.Rd @@ -17,7 +17,8 @@ pdf(file = if(onefile) "Rplots.pdf" else "Rplot\%03d.pdf", width, height, onefile, family, title, fonts, version, paper, encoding, bg, fg, pointsize, pagecentre, colormodel, - useDingbats, useKerning, fillOddEven, compress) + useDingbats, useKerning, fillOddEven, compress, + timestamp, producer, author) } \arguments{ \item{file}{a character string giving the file path. @@ -33,7 +34,8 @@ pdf(file = if(onefile) "Rplots.pdf" else "Rplot\%03d.pdf", character string. See the section \sQuote{Families}. Defaults to \code{"Helvetica"}.} \item{title}{title string to embed as the \samp{/Title} field in the - file. Defaults to \code{"R Graphics Output"}.} + document metadata. Defaults to \code{"R Graphics Output"}; + use an empty string (\code{""}) to omit the field.} \item{fonts}{a character vector specifying \R graphics font family names for additional fonts which will be included in the PDF file. Defaults to \code{NULL}.} @@ -99,6 +101,12 @@ pdf(file = if(onefile) "Rplots.pdf" else "Rplot\%03d.pdf", \code{\link{polygon}} for details. Defaults to \code{FALSE}.} \item{compress}{logical. Should PDF streams be generated with \I{Flate} compression? Defaults to \code{TRUE}.} + \item{timestamp}{logical. If \code{FALSE}, omit the \samp{/CreationDate} + and \samp{/ModDate} metadata fields. Defaults to \code{TRUE}.} + \item{producer}{logical. If \code{FALSE}, omit the \samp{/Producer} + metadata field. Defaults to \code{TRUE}.} + \item{author}{author string to embed as the \samp{/Author} field in the + document metadata. Defaults to \code{""}, omitting the field.} } \details{ All arguments except \code{file} default to values given by diff --git a/src/library/grDevices/man/pdf.options.Rd b/src/library/grDevices/man/pdf.options.Rd index 7c12acf4bc0..e8f6b9fb32e 100644 --- a/src/library/grDevices/man/pdf.options.Rd +++ b/src/library/grDevices/man/pdf.options.Rd @@ -1,14 +1,14 @@ % File src/library/grDevices/man/pdf.options.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{pdf.options} \alias{pdf.options} -\title{Auxiliary Function to Set/View Defaults for Arguments of pdf} +\title{Auxiliary Function to Set/View Defaults for Arguments of \code{pdf}} \description{ The auxiliary function \code{pdf.options} can be used to set or view - (if called without arguments) the default values for some of the + (if called without arguments) the default values for most of the arguments to \code{\link{pdf}}. \code{pdf.options} needs to be called before calling \code{pdf}, @@ -20,10 +20,12 @@ pdf.options(\dots, reset = FALSE) } \arguments{ \item{\dots}{arguments \code{width}, \code{height}, \code{onefile}, - \code{family}, \code{title}, \code{fonts}, \code{paper}, - \code{encoding}, \code{pointsize}, \code{bg}, \code{fg}, - \code{pagecentre}, \code{useDingbats}, \code{colormodel}, - \code{fillOddEven} and \code{compress} can be supplied.} + \code{family}, \code{title}, \code{fonts}, \code{version}, \code{paper}, + \code{encoding}, \code{bg}, \code{fg}, \code{pointsize}, + \code{pagecentre}, \code{colormodel}, \code{useDingbats}, + \code{useKerning}, \code{fillOddEven}, \code{compress}, + \code{timestamp}, \code{producer} and \code{author} + can be supplied.} \item{reset}{logical: should the defaults be reset to their \sQuote{factory-fresh} values?} } diff --git a/src/library/grDevices/src/devPS.c b/src/library/grDevices/src/devPS.c index 1032e3b020b..e8d758ebedc 100644 --- a/src/library/grDevices/src/devPS.c +++ b/src/library/grDevices/src/devPS.c @@ -3259,7 +3259,7 @@ PSDeviceDriver(pDevDesc dd, const char *file, const char *paper, /* initialise postscript device description */ strcpy(pd->filename, file); - strcpy(pd->papername, paper); + safestrcpy(pd->papername, paper, 64); strncpy(pd->title, title, 1023); pd->title[1023] = '\0'; if (streql(colormodel, "grey")) strcpy(pd->colormodel, "grey"); @@ -5113,7 +5113,7 @@ XFigDeviceDriver(pDevDesc dd, const char *file, const char *paper, /* initialize xfig device description */ strcpy(pd->filename, file); - strcpy(pd->papername, paper); + safestrcpy(pd->papername, paper, 64); pd->fontnum = XFigBaseNum(family); /* this might have changed the family, so update */ if(pd->fontnum == 16) family = "Helvetica"; @@ -5893,6 +5893,9 @@ typedef struct { Rboolean dingbats, useKern; Rboolean fillOddEven; /* polygon fill mode */ Rboolean useCompression; + Rboolean timestamp; + Rboolean producer; + char author[1024]; char tmpname[R_PATH_MAX]; /* used before compression */ /* @@ -7765,7 +7768,8 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper, const char *title, SEXP fonts, int versionMajor, int versionMinor, const char *colormodel, int dingbats, int useKern, - Rboolean fillOddEven, Rboolean useCompression) + Rboolean fillOddEven, Rboolean useCompression, + Rboolean timestamp, Rboolean producer, const char *author) { /* If we need to bail out with some sort of "error" */ /* then we must free(dd) */ @@ -7830,7 +7834,7 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper, strcpy(pd->filename, file); else strcpy(pd->filename, "nullPDF"); - strcpy(pd->papername, paper); + safestrcpy(pd->papername, paper, 64); strncpy(pd->title, title, 1023); pd->title[1023] = '\0'; memset(pd->fontUsed, 0, 100*sizeof(Rboolean)); @@ -7840,6 +7844,9 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper, pd->useKern = (useKern != 0); pd->fillOddEven = fillOddEven; pd->useCompression = useCompression; + pd->timestamp = timestamp; + pd->producer = producer; + safestrcpy(pd->author, author, 1024); if(useCompression && pd->versionMajor == 1 && pd->versionMinor < 2) { pd->versionMinor = 2; warning(_("increasing the PDF version to 1.2")); @@ -8571,17 +8578,24 @@ static void PDF_startfile(PDFDesc *pd) ct = time(NULL); ltm = localtime(&ct); - fprintf(pd->pdffp, - "1 0 obj\n<<\n/CreationDate (D:%04d%02d%02d%02d%02d%02d)\n", + fprintf(pd->pdffp, "1 0 obj\n<<\n"); + if (pd->timestamp) { + fprintf(pd->pdffp, + "/CreationDate (D:%04d%02d%02d%02d%02d%02d)\n", 1900 + ltm->tm_year, ltm->tm_mon+1, ltm->tm_mday, ltm->tm_hour, ltm->tm_min, ltm->tm_sec); - fprintf(pd->pdffp, + fprintf(pd->pdffp, "/ModDate (D:%04d%02d%02d%02d%02d%02d)\n", 1900 + ltm->tm_year, ltm->tm_mon+1, ltm->tm_mday, ltm->tm_hour, ltm->tm_min, ltm->tm_sec); - fprintf(pd->pdffp, "/Title (%s)\n", pd->title); - fprintf(pd->pdffp, "/Producer (R %s.%s)\n/Creator (R)\n>>\nendobj\n", - R_MAJOR, R_MINOR); + } + if (strlen(pd->title) > 0) + fprintf(pd->pdffp, "/Title (%s)\n", pd->title); + if (strlen(pd->author) > 0) + fprintf(pd->pdffp, "/Author (%s)\n", pd->author); + if (pd->producer) + fprintf(pd->pdffp, "/Producer (R %s.%s)\n", R_MAJOR, R_MINOR); + fprintf(pd->pdffp, "/Creator (R)\n>>\nendobj\n"); /* Object 2 is the Catalog, pointing to pages list in object 3 (at end) */ @@ -10979,6 +10993,7 @@ SEXP XFig(SEXP args) * height = height in inches * ps = pointsize * onefile = {TRUE: normal; FALSE: single page per file} + * pagecentre * title * fonts * versionMajor @@ -10987,6 +11002,7 @@ SEXP XFig(SEXP args) * useDingbats * forceLetterSpacing * fillOddEven + * ... */ SEXP PDF(SEXP args) @@ -10994,10 +11010,11 @@ SEXP PDF(SEXP args) pGEDevDesc gdd; const void *vmax; const char *file, *paper, *encoding, *family = NULL /* -Wall */, - *bg, *fg, *title, call[] = "PDF", *colormodel; + *bg, *fg, *title, call[] = "PDF", *colormodel, *author; const char *afms[5]; double height, width, ps; - int i, onefile, pagecentre, major, minor, dingbats, useKern, useCompression; + int i, onefile, pagecentre, major, minor, dingbats, useKern, useCompression, + timestamp, producer; SEXP fam, fonts; Rboolean fillOddEven; @@ -11043,6 +11060,13 @@ SEXP PDF(SEXP args) useCompression = asLogical(CAR(args)); args = CDR(args); if (useCompression == NA_LOGICAL) error(_("invalid value of '%s'"), "useCompression"); + timestamp = asLogical(CAR(args)); args = CDR(args); + if (timestamp == NA_LOGICAL) + error(_("invalid value of '%s'"), "timestamp"); + producer = asLogical(CAR(args)); args = CDR(args); + if (producer == NA_LOGICAL) + error(_("invalid value of '%s'"), "producer"); + author = translateChar(asChar(CAR(args))); args = CDR(args); R_GE_checkVersionOrDie(R_GE_version); R_CheckDeviceAvailable(); @@ -11054,7 +11078,7 @@ SEXP PDF(SEXP args) width, height, ps, onefile, pagecentre, title, fonts, major, minor, colormodel, dingbats, useKern, fillOddEven, - useCompression)) { + useCompression, timestamp, producer, author)) { /* we no longer get here: error is thrown in PDFDeviceDriver */ error(_("unable to start %s() device"), "pdf"); } diff --git a/src/library/grDevices/src/grDevices.h b/src/library/grDevices/src/grDevices.h index 8303ad09419..db8b6c75104 100644 --- a/src/library/grDevices/src/grDevices.h +++ b/src/library/grDevices/src/grDevices.h @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2004-23 The R Core Team. + * Copyright (C) 2004-2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -61,7 +61,8 @@ Rboolean PDFDeviceDriver(pDevDesc, const char *, const char *, const char *, const char **, const char *, const char *, const char *, double, double, double, int, int, const char*, SEXP, - int, int, const char *, int, int, Rboolean, Rboolean); + int, int, const char *, int, int, Rboolean, Rboolean, + Rboolean, Rboolean, const char *); #ifdef _WIN32 SEXP devga(SEXP); diff --git a/src/library/grDevices/src/init.c b/src/library/grDevices/src/init.c index 8ebf48b3e97..0a419e80b8e 100644 --- a/src/library/grDevices/src/init.c +++ b/src/library/grDevices/src/init.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2004-2017 The R Core Team. + * Copyright (C) 2004-2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -92,7 +92,7 @@ static const R_ExternalMethodDef ExtEntries[] = { EXTDEF(PicTeX, 6), EXTDEF(PostScript, 19), EXTDEF(XFig, 14), - EXTDEF(PDF, 20), + EXTDEF(PDF, 23), EXTDEF(devCairo, 12), EXTDEF(devcap, 1), EXTDEF(devcapture, 1), diff --git a/src/library/grDevices/tests/grDev-tsts.R b/src/library/grDevices/tests/grDev-tsts.R index 30772510faf..da9f9f1063b 100644 --- a/src/library/grDevices/tests/grDev-tsts.R +++ b/src/library/grDevices/tests/grDev-tsts.R @@ -5,3 +5,14 @@ suppressWarnings(xy.coords(-2:10, log = "y"), classes="log_le_0") -> xy stopifnot(identical(xy$y, c(rep(NA_real_,3), 1:10))) options(op) # (reverting) tools::assertWarning(xy.coords(-2:10, log = "y"), verbose=TRUE) + +## PDF metadata +oopt <- pdf.options(author = "useR", timestamp = FALSE, producer = FALSE) +pdf(f <- tempfile(), title = "test", compress = FALSE); plot.new(); dev.off() +pdflines <- readLines(f) +stopifnot(c("/Title (test)", "/Author (useR)") %in% pdflines, + !startsWith(pdflines, "/CreationDate"), + !startsWith(pdflines, "/ModDate"), + !startsWith(pdflines, "/Producer")) +pdf.options(reset = TRUE) +stopifnot(identical(oopt, pdf.options())) diff --git a/tests/Examples/grDevices-Ex.Rout.save b/tests/Examples/grDevices-Ex.Rout.save index 2986fbe4515..077b67d4b30 100644 --- a/tests/Examples/grDevices-Ex.Rout.save +++ b/tests/Examples/grDevices-Ex.Rout.save @@ -2886,7 +2886,7 @@ Sturges Scott FD > flush(stderr()); flush(stdout()) > > ### Name: pdf.options -> ### Title: Auxiliary Function to Set/View Defaults for Arguments of pdf +> ### Title: Auxiliary Function to Set/View Defaults for Arguments of 'pdf' > ### Aliases: pdf.options > ### Keywords: device > @@ -2894,7 +2894,7 @@ Sturges Scott FD > > pdf.options(bg = "pink") > utils::str(pdf.options()) -List of 18 +List of 21 $ width : num 7 $ height : num 7 $ onefile : logi TRUE @@ -2913,6 +2913,9 @@ List of 18 $ useKerning : logi TRUE $ fillOddEven: logi FALSE $ compress : logi TRUE + $ timestamp : logi TRUE + $ producer : logi TRUE + $ author : chr "" > pdf.options(reset = TRUE) # back to factory-fresh > > From 210ca9f7fd372d8714c7070b22bbaa823cab7a44 Mon Sep 17 00:00:00 2001 From: smeyer Date: Sat, 13 Jul 2024 16:24:56 +0000 Subject: [PATCH 365/546] fixup c86894 for Windows git-svn-id: https://svn.r-project.org/R/trunk@86895 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/grDevices/src/devWindows.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/library/grDevices/src/devWindows.c b/src/library/grDevices/src/devWindows.c index 6b08739f121..1a25065e2aa 100644 --- a/src/library/grDevices/src/devWindows.c +++ b/src/library/grDevices/src/devWindows.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2004-2023 The R Core Team + * Copyright (C) 2004--2024 The R Core Team * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka * Copyright (C) 1998--2003 Guido Masarotto and Brian Ripley * Copyright (C) 2004 The R Foundation @@ -464,6 +464,9 @@ static void SaveAsPDF(pDevDesc dd, const char *fn) char family[256], encoding[256], bg[256], fg[256]; const char **afmpaths = NULL; Rboolean useCompression = FALSE; + Rboolean timestamp = TRUE; + Rboolean producer = TRUE; + const char *author = ""; if (!ndd) { R_ShowMessage(_("Not enough memory to copy graphics window")); @@ -506,7 +509,8 @@ static void SaveAsPDF(pDevDesc dd, const char *fn) GE_INCHES, gdd), ((gadesc*) dd->deviceSpecific)->basefontsize, 1, 0, "R Graphics Output", R_NilValue, 1, 4, - "rgb", TRUE, TRUE, xd->fillOddEven, useCompression)) + "rgb", TRUE, TRUE, xd->fillOddEven, useCompression, + timestamp, producer, author)) PrivateCopyDevice(dd, ndd, "PDF"); } From 097738f552f315eccc656cddf8861e0dc903855a Mon Sep 17 00:00:00 2001 From: maechler Date: Sun, 14 Jul 2024 16:13:36 +0000 Subject: [PATCH 366/546] methods(:::) now reports methods of hidden generics git-svn-id: https://svn.r-project.org/R/trunk@86896 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 7 +++++-- src/library/graphics/src/stem.c | 23 ++++++++++++++++------- tests/reg-tests-2.R | 4 ++++ tests/reg-tests-2.Rout.save | 13 +++++++++++++ 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 1a80cdac882..3ad0bbf450d 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -33,7 +33,10 @@ computations; wished for in \PR{18739}. \item New function \code{grepv()} identical to \code{grep()} except - with the default \code{value = TRUE}. + with the default \code{value = TRUE}. + + \item \code{methods(:::)} now does report methods when + neither the generic nor the methods have been exported. \item \code{pdf()} gains an \code{author} argument to set the corresponding metadata field, and logical arguments @@ -128,7 +131,7 @@ \code{SYMVALUE}, and \code{VECTOR_PTR}. Any declarations for these in public header files will be removed in the near future, and they will be hidden where possible. - + \item \sQuote{Writing R Extensions} has a new section \sQuote{Moving into C API compliance} to help package authors move away from using non-API endpoints. This section will continue to diff --git a/src/library/graphics/src/stem.c b/src/library/graphics/src/stem.c index cf55c24c3f2..b389359ed4a 100644 --- a/src/library/graphics/src/stem.c +++ b/src/library/graphics/src/stem.c @@ -47,6 +47,11 @@ static void stem_print(int close, int dist, int ndigits) Rprintf(" %*d | ", ndigits, close/10); } +static double rnd(double u, double c) +{ + return ((u < 0) ? (u*c - .5) : (u*c + .5)); +} + static Rboolean stem_leaf(double *x, int n, double scale, int width, double atom) { @@ -82,14 +87,19 @@ stem_leaf(double *x, int n, double scale, int width, double atom) } /* Find the print width of the stem. */ - - lo = floor(x[0]*c/mu)*mu; - hi = floor(x[n-1]*c/mu)*mu; - ldigits = (lo < 0) ? (int) floor(log10(-(double)lo)) + 1 : 0; - hdigits = (hi > 0) ? (int) floor(log10((double)hi)): 0; + double + xlow = rnd(x[0], c), + xhigh = rnd(x[n-1], c), + lo_nd = floor(xlow/mu)*mu, + hi_nd = floor(xhigh/mu)*mu; + + ldigits = (lo_nd < 0) ? (int) floor(log10(-lo_nd)) + 1 : 0; + hdigits = (hi_nd > 0) ? (int) floor(log10(hi_nd)): 0; ndigits = (ldigits < hdigits) ? hdigits : ldigits; /* Starting cell */ + lo = floor(x[0]*c/mu)*mu; + hi = floor(x[n-1]*c/mu)*mu; if(lo < 0 && floor(x[0]*c) == lo) lo = lo - mu; hi = lo + mu; @@ -116,8 +126,7 @@ stem_leaf(double *x, int n, double scale, int width, double atom) stem_print((int)lo, (int)hi, ndigits); j = 0; do { - if(x[i] < 0)xi = (int) (x[i]*c - .5); - else xi = (int) (x[i]*c + .5); + xi = (int) rnd(x[i], c); if( (hi == 0 && x[i] >= 0)|| (lo < 0 && xi > hi) || diff --git a/tests/reg-tests-2.R b/tests/reg-tests-2.R index 248964deeb5..d828f430743 100644 --- a/tests/reg-tests-2.R +++ b/tests/reg-tests-2.R @@ -1192,6 +1192,10 @@ stem(c(rep(1, 10), 1+1.e-9)) stem(c(rep(1, 10), 1+1.e-10), atom=0) # integer-overflow is avoided. ## had integer overflows in 1.8.1, and silly shifts of decimal point +## PR#8934 stem() with correct width +stem(c(8.48, 9.58, 9.96)) +## wrongly indented '10 |' since even before R 1.0.0 + ## PR#6633 warnings with vector op matrix, and more set.seed(1) diff --git a/tests/reg-tests-2.Rout.save b/tests/reg-tests-2.Rout.save index 4e300d02765..5be8047efd7 100644 --- a/tests/reg-tests-2.Rout.save +++ b/tests/reg-tests-2.Rout.save @@ -3861,6 +3861,19 @@ Residuals 42 29204 695.3 > ## had integer overflows in 1.8.1, and silly shifts of decimal point > +> ## PR#8934 stem() with correct width +> stem(c(8.48, 9.58, 9.96)) + + The decimal point is at the | + + 8 | + 8 | 5 + 9 | + 9 | 6 + 10 | 0 + +> ## wrongly indented '10 |' since even before R 1.0.0 +> > > ## PR#6633 warnings with vector op matrix, and more > set.seed(1) From 95ae48ef63352fb4f58ef6a6795696fa0184398f Mon Sep 17 00:00:00 2001 From: maechler Date: Sun, 14 Jul 2024 16:20:52 +0000 Subject: [PATCH 367/546] fixing stem() indentation, PR#8934 -- belongs to rev 86896 git-svn-id: https://svn.r-project.org/R/trunk@86897 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 3ad0bbf450d..69401ea9ad2 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -175,6 +175,10 @@ and now preserves \code{NA} names, thus fixing the \code{format()} method for data frames, and also bug \PR{18745}. \I{Relatedly}, the \code{format()} method gets an option \code{cut.names}. + + \item \code{stem()} correctly formats also in cases where rounding + up, e.g., from 9.96 to 10 needs more digits; thanks to Ella Kaye and + Kelly Bodwin, fixing \PR{8934} during \sQuote{R Dev Day} at useR!2024. } } } From 33122ae743198865330e0a1ff20f068ab3174dfc Mon Sep 17 00:00:00 2001 From: maechler Date: Sun, 14 Jul 2024 16:23:24 +0000 Subject: [PATCH 368/546] e.g. methods(car:::term.names) -- via new `useEnv = TRUE` arg for .S3methods() [NEWS wrongly in r86896 git-svn-id: https://svn.r-project.org/R/trunk@86898 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/objects.R | 16 ++++++++++++---- src/library/utils/man/methods.Rd | 7 +++++-- tests/Pkgs/pkgC/R/f.R | 10 ++++++++++ tests/reg-packages.R | 26 +++++++++++++++++++++----- 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/library/utils/R/objects.R b/src/library/utils/R/objects.R index fd698a9ee31..2215fac0b7c 100644 --- a/src/library/utils/R/objects.R +++ b/src/library/utils/R/objects.R @@ -69,7 +69,7 @@ function() c(names(.knownS3Generics), tools:::.get_internal_S3_generics()) .S3methods <- -function(generic.function, class, envir=parent.frame(), all.names = FALSE, dropPath = FALSE) +function(generic.function, class, envir=parent.frame(), all.names = FALSE, dropPath = FALSE, useEnv = FALSE) { rbindSome <- function(df, nms, msg) { ## rbind.data.frame() -- dropping rows with duplicated names @@ -88,9 +88,14 @@ function(generic.function, class, envir=parent.frame(), all.names = FALSE, dropP S3MethodsStopList <- tools::nonS3methods(NULL) knownGenerics <- getKnownS3generics() - sp <- search() - if(dropPath) sp <- sp[c(1L, length(sp))] methods.called <- identical(sys.call(-1)[[1]], as.symbol("methods")) + if(useEnv) { + attach(envir, pos = 2L, warn.conflicts = FALSE) + if(methods.called) message("some methods may be unavailable outside of their namespace") + on.exit(detach(2L)) + } + sp <- search() + if(dropPath) sp <- sp[c(if(useEnv) 1:2 else 1L, length(sp))] an <- lapply(sp, ls, all.names = all.names) lens <- lengths(an) an <- unlist(an, use.names=FALSE) @@ -211,6 +216,7 @@ methods <- function(generic.function, class, all.names = FALSE, dropPath = FALSE) { envir <- parent.frame() + useNS <- FALSE if(!missing(generic.function) && !is.character(generic.function)) { what <- substitute(generic.function) generic.function <- @@ -219,6 +225,7 @@ function(generic.function, class, all.names = FALSE, dropPath = FALSE) (deparse(what[[1L]], nlines=1L) %in% c("::", ":::"))) { what <- as.character(what[2:3]) envir <- asNamespace(what[[1L]]) + useNS <- TRUE what[[2L]] } else deparse(what) @@ -227,7 +234,8 @@ function(generic.function, class, all.names = FALSE, dropPath = FALSE) if (!missing(class) && !is.character(class)) class <- deparse1(substitute(class)) - s3 <- .S3methods(generic.function, class, envir, all.names=all.names, dropPath=dropPath) + s3 <- .S3methods(generic.function, class, envir, all.names=all.names, dropPath=dropPath, + useEnv = useNS) s4 <- if(.isMethodsDispatchOn()) methods::.S4methods(generic.function, class) .MethodsFunction(s3, s4, missing(generic.function)) diff --git a/src/library/utils/man/methods.Rd b/src/library/utils/man/methods.Rd index f141afd4adc..cf317e1f95f 100644 --- a/src/library/utils/man/methods.Rd +++ b/src/library/utils/man/methods.Rd @@ -1,6 +1,6 @@ % File src/library/utils/man/methods.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2023 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{methods} @@ -16,7 +16,7 @@ \usage{% --> ../R/objects.R : methods(generic.function, class, all.names = FALSE, dropPath = FALSE) .S3methods(generic.function, class, envir = parent.frame(), - all.names = FALSE, dropPath = FALSE) + all.names = FALSE, dropPath = FALSE, useEnv = FALSE) \S3method{format}{MethodsFunction}(x, byclass = attr(x, "byclass"), \dots) \S3method{print}{MethodsFunction}(x, byclass = attr(x, "byclass"), \dots) @@ -39,6 +39,9 @@ back compatible and typically desired for \I{\code{print()}ing}, with or without asterisk; \code{dropPath=TRUE} has been hard coded in \R 4.3.0 and is faster for non-small \code{\link{search}()} paths.} + \item{useEnv}{a \code{\link{logical}} indicating if \code{envir} should + be searched in addition to the (much reduced in case of \code{dropPath=TRUE}) + \code{\link{search}()} path.} \item{x}{typically the result of \code{methods(..)}, an \R object of S3 class \code{"MethodsFunction"}, see \sQuote{Value} below.} \item{byclass}{an optional \code{\link{logical}} allowing to override diff --git a/tests/Pkgs/pkgC/R/f.R b/tests/Pkgs/pkgC/R/f.R index 46a691b9d1d..24d3adf2a0b 100644 --- a/tests/Pkgs/pkgC/R/f.R +++ b/tests/Pkgs/pkgC/R/f.R @@ -7,6 +7,16 @@ Cfun <- function(x) { cbind(x, b=x+2)) } + +## S3 generic and method -- both *not* exported; -- methods(pkgC:::foobar) should still work: +foobar <- function(x) { UseMethod("foobar") } +foobar.default <- function(x) { cat("foobar.default(x):, x="); str(x) } +foobar.Date <- function(x) { + r <- x + 1 + cat("foobar.Date(.): next day is: ", format(r), "\n") + invisible(r) +} + ## Pkg 'ecd' had ## setClassUnion("numericMpfr", c("numeric", "mpfr", "mpfrArray")) ## diff --git a/tests/reg-packages.R b/tests/reg-packages.R index 6c9a3e5ae0a..82a15f0d73b 100644 --- a/tests/reg-packages.R +++ b/tests/reg-packages.R @@ -92,7 +92,7 @@ unlink("myLib", recursive = TRUE) dir.create("myLib") install.packages("myTst", lib = "myLib", repos=NULL, type = "source") print(installed.packages(lib.loc= "myLib", priority= "NA"))## (PR#13332) -stopifnot(require("myTst",lib = "myLib")) +stopifnot(require("myTst", lib.loc = "myLib")) sm <- findMethods(show, where= as.environment("package:myTst")) stopifnot(sm@names == "foo") unlink("myTst_*") @@ -400,10 +400,14 @@ if(okA) { if(interactive()) { ## << "FIXME!" This (sink(.) ..) fails, when run via 'make'. ## install.packages() should give "the correct" error but we cannot catch it ## One level lower is not much better, needing sink() as capture.output() fails - ftf <- file(tf <- tempfile("inst_pkg"), open = "wt") - sink(ftf); sink(ftf, type = "message")# "message" should be sufficient - eval(instEXPR) - sink(type="message"); sink()## ; close(ftf); rm(ftf)# end sink() + tryInst <- function(tfile) { + ftf <- file(tfile, open = "wt") + sink(ftf); sink(ftf, type = "message")# "message" should be sufficient + on.exit({ sink(type="message"); sink(); close(ftf) }) + eval(instEXPR) + } + tf <- tempfile("inst_pkg") + instR <- tryInst(tf) writeLines(paste(" ", msgs <- readLines(tf))) message(err <- grep("^ERROR:", msgs, value=TRUE)) stopifnot(exprs = { @@ -418,6 +422,18 @@ if(okA) { } else message("pkgA/DESCRIPTION not available") showProc.time() +require(PkgC, lib.loc = "myLib") +(r <- methods(PkgC:::foobar))# "should" return non-empty even when neither S3 generic nor method was exported +meths <- paste("foobar", c("Date", "default"), sep = ".") +try(PkgC:::foobar(pi)) # -> foobar.default is *not* 'found' +PkgC:::foobar(Sys.Date()) # -> foobar.Date *is* found b/c S3method(.) +stopifnot(exprs = { + inherits(r, "MethodsFunction") + r == meths # may change if add an extra star + nrow(mi <- attr(r, "info")) == 2 + identical(meths, rownames(mi)) +}) +## failed up to R 4.4.x ## R CMD check should *not* warn about \Sexpr{} built sections in Rd (PR#17479): writeLines(msg <- capture.output( From af9301822defe5805ae2daa992cfba588ecfe5f9 Mon Sep 17 00:00:00 2001 From: maechler Date: Sun, 14 Jul 2024 17:30:15 +0000 Subject: [PATCH 369/546] not calling foobar() for now git-svn-id: https://svn.r-project.org/R/trunk@86899 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/reg-packages.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/reg-packages.R b/tests/reg-packages.R index 82a15f0d73b..8dc8bbfdab6 100644 --- a/tests/reg-packages.R +++ b/tests/reg-packages.R @@ -426,6 +426,7 @@ require(PkgC, lib.loc = "myLib") (r <- methods(PkgC:::foobar))# "should" return non-empty even when neither S3 generic nor method was exported meths <- paste("foobar", c("Date", "default"), sep = ".") try(PkgC:::foobar(pi)) # -> foobar.default is *not* 'found' +if(FALSE) # not working when run via `make` PkgC:::foobar(Sys.Date()) # -> foobar.Date *is* found b/c S3method(.) stopifnot(exprs = { inherits(r, "MethodsFunction") From c01a0a1fce87a7f2f9e08e19954c03732eb871dd Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 15 Jul 2024 07:20:22 +0000 Subject: [PATCH 370/546] make "Mb", "Gb" .. _arguments_ of memory messages git-svn-id: https://svn.r-project.org/R/trunk@86900 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 11 ++++++++--- src/main/memory.c | 32 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 69401ea9ad2..55f7a823663 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -32,6 +32,10 @@ interface to the \code{lm.influence()} leave-one-out diagnostics computations; wished for in \PR{18739}. + \item Package \code{citation()} results auto-generated from the + package metadata now also provide package \abbr{DOI}s for CRAN and + Bioconductor packages. + \item New function \code{grepv()} identical to \code{grep()} except with the default \code{value = TRUE}. @@ -150,9 +154,10 @@ \code{SET_TYPEOF}, \code{TRUELENGTH}, \code{XLENGTH_EX}, and \code{XTRUELENGTH}. - \item Package \code{citation()} results auto-generated from the - package metadata now also provide package \abbr{DOI}s for CRAN and - Bioconductor packages. + \item Memory allocation messages now use the (non-standard notation) + \code{"Mb"}, \code{"Gb"} , \dots, and \code{"Mbytes"} strings as + \emph{arguments} instead of as part of the (translatable format) + string. This is one step for \PR{18297}; from Henrik Bengtsson. } } diff --git a/src/main/memory.c b/src/main/memory.c index 1415531db8d..d02a01bec91 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -2327,13 +2327,13 @@ char *R_alloc(size_t nelem, int eltsize) #ifdef LONG_VECTOR_SUPPORT /* 64-bit platform: previous version used REALSXPs */ if(dsize > R_XLEN_T_MAX) /* currently 4096 TB */ - error(_("cannot allocate memory block of size %0.f Tb"), - dsize/R_pow_di(1024.0, 4)); + error(_("cannot allocate memory block of size %0.f %s"), + dsize/R_pow_di(1024.0, 4), "Tb"); s = allocVector(RAWSXP, size + 1); #else if(dsize > R_LEN_T_MAX) /* must be in the Gb range */ - error(_("cannot allocate memory block of size %0.1f Gb"), - dsize/R_pow_di(1024.0, 3)); + error(_("cannot allocate memory block of size %0.1f %s"), + dsize/R_pow_di(1024.0, 3), "Gb"); s = allocVector(RAWSXP, size + 1); #endif ATTRIB(s) = R_VStack; @@ -2912,16 +2912,16 @@ SEXP allocVector3(SEXPTYPE type, R_xlen_t length, R_allocator_t *allocator) R_VSize = old_R_VSize; if(dsize > 1024.0*1024.0) errorcall(R_NilValue, - _("cannot allocate vector of size %0.1f Gb"), - dsize/1024.0/1024.0); + _("cannot allocate vector of size %0.1f %s"), + dsize/1024.0/1024.0, "Gb"); if(dsize > 1024.0) errorcall(R_NilValue, - _("cannot allocate vector of size %0.1f Mb"), - dsize/1024.0); + _("cannot allocate vector of size %0.1f %s"), + dsize/1024.0, "Mb"); else errorcall(R_NilValue, - _("cannot allocate vector of size %0.f Kb"), - dsize); + _("cannot allocate vector of size %0.f %s"), + dsize, "Kb"); } s->sxpinfo = UnmarkedNodeTemplate.sxpinfo; INIT_REFCNT(s); @@ -3260,13 +3260,13 @@ static void R_gc_internal(R_size_t size_needed) nfrac = (100.0 * ncells) / R_NSize; /* We try to make this consistent with the results returned by gc */ ncells = 0.1*ceil(10*ncells * sizeof(SEXPREC)/Mega); - REprintf("\n%.1f Mbytes of cons cells used (%d%%)\n", - ncells, (int) (nfrac + 0.5)); + REprintf("\n%.1f %s of cons cells used (%d%%)\n", + ncells, "Mbytes", (int) (nfrac + 0.5)); vcells = R_VSize - VHEAP_FREE(); vfrac = (100.0 * vcells) / R_VSize; vcells = 0.1*ceil(10*vcells * vsfac/Mega); - REprintf("%.1f Mbytes of vectors used (%d%%)\n", - vcells, (int) (vfrac + 0.5)); + REprintf("%.1f %s of vectors used (%d%%)\n", + vcells, "Mbytes", (int) (vfrac + 0.5)); } #ifdef IMMEDIATE_FINALIZERS @@ -4925,8 +4925,8 @@ void *R_AllocStringBuffer(size_t blen, R_StringBuffer *buf) if(!buf->data) { buf->bufsize = 0; /* don't translate internal error message */ - error("could not allocate memory (%u Mb) in C function 'R_AllocStringBuffer'", - (unsigned int) blen/1024/1024); + error("could not allocate memory (%u %s) in C function 'R_AllocStringBuffer'", + (unsigned int) blen/1024/1024, "Mb"); } return buf->data; } From cd556f5b4264b89e8691cf08bd7b8e20d36fe75a Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 15 Jul 2024 14:37:53 +0000 Subject: [PATCH 371/546] toTitlecase() "small- and large-scale" fix + examples git-svn-id: https://svn.r-project.org/R/trunk@86901 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 ++++ src/library/tools/R/utils.R | 4 +++- src/library/tools/man/toTitleCase.Rd | 18 +++++++++++--- tests/Examples/tools-Ex.Rout.save | 36 ++++++++++++++++++++++++++-- tests/reg-tests-1e.R | 8 +++++++ 5 files changed, 64 insertions(+), 6 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 55f7a823663..bcc0f01ac34 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -184,6 +184,10 @@ \item \code{stem()} correctly formats also in cases where rounding up, e.g., from 9.96 to 10 needs more digits; thanks to Ella Kaye and Kelly Bodwin, fixing \PR{8934} during \sQuote{R Dev Day} at useR!2024. + + \item \pkg{tools}' \code{toTitleCase()} now works better, fixing + \PR{18674}, thanks to Shannon Pileggi, Sarah Zeller, Reiko Okamoto, + and Hugo Gruson's \sQuote{R Dev Day} effort. } } } diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index e1af33bb9d6..89625e6a44f 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -2688,13 +2688,15 @@ function(text) ## do not remove capitalization immediately after ": " or "- " ind <- grep("[-:]$", xx); ind <- ind[ind + 2L <= length(l)] ind <- ind[(xx[ind + 1L] == " ") & grepl("^['[:alnum:]]", xx[ind + 2L])] + # don't capitalize lpat words after hyphenation + ind <- ind[!(xx[ind] == "-" & grepl(lpat, xx[ind + 2L]))] l[ind + 2L] <- FALSE ## Also after " (e.g. "A Book Title") ind <- which(xx == '"'); ind <- ind[ind + 1L <= length(l)] l[ind + 1L] <- FALSE xx[l] <- tolower(xx[l]) keep <- havecaps | l | (nchar(xx) == 1L) | alone - xx[!keep] <- sapply(xx[!keep], do1) + xx[!keep] <- vapply(xx[!keep], do1, "") paste(xx, collapse = "") } if(typeof(text) != "character") diff --git a/src/library/tools/man/toTitleCase.Rd b/src/library/tools/man/toTitleCase.Rd index 8f9391859d2..2e7a5fa0772 100644 --- a/src/library/tools/man/toTitleCase.Rd +++ b/src/library/tools/man/toTitleCase.Rd @@ -1,13 +1,13 @@ % File src/library/tools/man/toTitleCase.Rd % Part of the R package, https://www.R-project.org -% Copyright 2015 R Core Team +% Copyright 2015--2024 R Core Team % Distributed under GPL 2 or later \name{toTitleCase} \alias{toTitleCase} \title{Convert Titles to Title Case} \description{ - Convert a character vector to title case, especially package titles. + Convert a character vector to title case for English, especially package titles. } \usage{ toTitleCase(text) @@ -18,7 +18,7 @@ toTitleCase(text) \details{ This is intended for English text only. - No definition of\sQuote{title case} is universally accepted: all agree + No definition of \sQuote{title case} is universally accepted: all agree that \sQuote{principal} words are capitalized and common words like \sQuote{for} are not, but not which words fall into each category. @@ -33,3 +33,15 @@ toTitleCase(text) \value{ A character vector of the same length as \code{text}, without names. } +\examples{ +toTitleCase("bayesian network modeling and analysis") +toTitleCase("ensemble tool for predictions from species distribution models") +## Treatment after "-": +toTitleCase("small- and large-scale analysis") # lowercase "and" + +toTitleCase("a small fox is jumping") # "a Small Fox is .." (the 'a' may change)% i.e. BUG +toTitleCase("is a small fox jumping?") # "Is a Small Fox .." (fine) +## After ":", start a new sentence +toTitleCase("a pangram: the quick brown fox jumps over the lazy dog") +toTitleCase("asking -- 'is a small fox jumping?'") # ".. -- Is a Small ..." (fine) +} diff --git a/tests/Examples/tools-Ex.Rout.save b/tests/Examples/tools-Ex.Rout.save index ae441b81be5..ba9a319efd1 100644 --- a/tests/Examples/tools-Ex.Rout.save +++ b/tests/Examples/tools-Ex.Rout.save @@ -1,7 +1,7 @@ -R Under development (unstable) (2024-03-31 r86238) -- "Unsuffered Consequences" +R Under development (unstable) (2024-07-15 r86900) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing -Platform: aarch64-apple-darwin23.4.0 +Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -993,6 +993,38 @@ An illustration of lexical scoping. > > > cleanEx() +> nameEx("toTitleCase") +> ### * toTitleCase +> +> flush(stderr()); flush(stdout()) +> +> ### Name: toTitleCase +> ### Title: Convert Titles to Title Case +> ### Aliases: toTitleCase +> +> ### ** Examples +> +> toTitleCase("bayesian network modeling and analysis") +[1] "Bayesian Network Modeling and Analysis" +> toTitleCase("ensemble tool for predictions from species distribution models") +[1] "Ensemble Tool for Predictions from Species Distribution Models" +> ## Treatment after "-": +> toTitleCase("small- and large-scale analysis") # lowercase "and" +[1] "Small- and Large-Scale Analysis" +> +> toTitleCase("a small fox is jumping") # "a Small Fox is .." (the 'a' may change)% i.e. BUG +[1] "a Small Fox is Jumping" +> toTitleCase("is a small fox jumping?") # "Is a Small Fox .." (fine) +[1] "Is a Small Fox Jumping?" +> ## After ":", start a new sentence +> toTitleCase("a pangram: the quick brown fox jumps over the lazy dog") +[1] "a Pangram: The Quick Brown Fox Jumps over the Lazy Dog" +> toTitleCase("asking -- 'is a small fox jumping?'") # ".. -- Is a Small ..." (fine) +[1] "Asking -- 'Is a Small Fox Jumping?'" +> +> +> +> cleanEx() > nameEx("undoc") > ### * undoc > diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 9c7790a829a..0dcbdc12d78 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1394,6 +1394,14 @@ stopifnot(!isdebugged(summary.factor)) unloadNamespace("stats4") +## PR#18674 - toTitleCase() incorrectly capitalizes conjunctions +## (e.g. 'and') when using suspensive hyphenation +stopifnot(exprs = { + identical(tools::toTitleCase("pre and post estimation"), "Pre and Post Estimation") + identical(tools::toTitleCase("pre- and post estimation"), "Pre- and Post Estimation") + identical(tools::toTitleCase("pre- and post-estimation"), "Pre- and Post-Estimation") +}) + ## PR#18724 - toTitleCase(character(0)) ch0 <- character(0L) stopifnot(identical(ch0, tools::toTitleCase(ch0))) From 0211b7df7d3093cf1a7da167f70a855f5181a950 Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 15 Jul 2024 19:36:49 +0000 Subject: [PATCH 372/546] `max.print` for printing matrices now also affects columns git-svn-id: https://svn.r-project.org/R/trunk@86902 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 6 +++++ src/main/printarray.c | 54 ++++++++++++++++++++----------------- tests/print-tests.R | 17 ++++++++++++ tests/print-tests.Rout.save | 51 +++++++++++++++++++++++++++++++++-- 4 files changed, 102 insertions(+), 26 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index bcc0f01ac34..4c1ee175c34 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -188,6 +188,12 @@ \item \pkg{tools}' \code{toTitleCase()} now works better, fixing \PR{18674}, thanks to Shannon Pileggi, Sarah Zeller, Reiko Okamoto, and Hugo Gruson's \sQuote{R Dev Day} effort. + + \item Printing matrices (typically with many rows and or columns) now + also omits columns when desirable according to option \code{max.print}, + or argument \code{max}, respectively. This is primarily the work of + Lorena Abad, Ekaterina Akimova, Hanne Oberman, Abhishek Ulayil, and + Lionel Henry at the \sQuote{R Dev Day}, thus fixing \PR{15027}. } } } diff --git a/src/main/printarray.c b/src/main/printarray.c index b159c50fdab..a11972d95d0 100644 --- a/src/main/printarray.c +++ b/src/main/printarray.c @@ -1,8 +1,8 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 2000--2023 The R Core Team + * Copyright (C) 2000--2024 The R Core Team * Copyright (C) 2001--2012 The R Foundation + * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -217,7 +217,6 @@ static void printLogicalMatrix(SEXP sx, int offset, int r_pr, int r, int c, _PRINT_MATRIX_( , STD_ColumnLabels, Rprintf("%s", EncodeLogical(x[i + j * (R_xlen_t) r], w[j]))); - } static void printIntegerMatrix(SEXP sx, int offset, int r_pr, int r, int c, @@ -243,11 +242,11 @@ static void printRealMatrix(SEXP sx, int offset, int r_pr, int r, int c, *e = (int *) R_alloc(c, sizeof(int)); _COMPUTE_W_( formatReal(&x[j * (R_xlen_t) r], (R_xlen_t) r, &w[j], - &d[j], &e[j], 0) ); + &d[j], &e[j], 0) ); _PRINT_MATRIX_( , STD_ColumnLabels, Rprintf("%s", EncodeReal0(x[i + j * (R_xlen_t) r], - w[j], d[j], e[j], OutDec)) ); + w[j], d[j], e[j], OutDec)) ); } static void printComplexMatrix(SEXP sx, int offset, int r_pr, int r, int c, @@ -334,7 +333,7 @@ void printMatrix(SEXP x, int offset, SEXP dim, int quote, int right, const void *vmax = vmaxget(); const int *pdim = INTEGER_RO(dim); int r = pdim[0]; - int c = pdim[1], r_pr; + int c = pdim[1]; /* PR#850 */ if ((rl != R_NilValue) && (r > length(rl))) error(_("too few row labels")); @@ -344,44 +343,51 @@ void printMatrix(SEXP x, int offset, SEXP dim, int quote, int right, Rprintf("<0 x 0 matrix>\n"); return; } - r_pr = r; + + int r_pr = r, + /* Make sure we don't display more columns than max elements, see PR#15027 */ + c_pr = c > R_print.max ? R_print.max : c; + if(c > 0 && R_print.max / c < r) /* avoid integer overflow */ /* using floor(), not ceil(), since 'c' could be huge: */ r_pr = R_print.max / c; + /* Display at least one row in case of truncation */ + if (c > c_pr && r_pr < 1 && r > 0) + r_pr = 1; switch (TYPEOF(x)) { case LGLSXP: - printLogicalMatrix(x, offset, r_pr, r, c, rl, cl, rn, cn, TRUE); + printLogicalMatrix(x, offset, r_pr, r, c_pr, rl, cl, rn, cn, TRUE); break; case INTSXP: - printIntegerMatrix(x, offset, r_pr, r, c, rl, cl, rn, cn, TRUE); + printIntegerMatrix(x, offset, r_pr, r, c_pr, rl, cl, rn, cn, TRUE); break; case REALSXP: - printRealMatrix (x, offset, r_pr, r, c, rl, cl, rn, cn, TRUE); + printRealMatrix (x, offset, r_pr, r, c_pr, rl, cl, rn, cn, TRUE); break; case CPLXSXP: - printComplexMatrix(x, offset, r_pr, r, c, rl, cl, rn, cn, TRUE); + printComplexMatrix(x, offset, r_pr, r, c_pr, rl, cl, rn, cn, TRUE); break; case STRSXP: if (quote) quote = '"'; - printStringMatrix (x, offset, r_pr, r, c, quote, right, rl, cl, rn, cn, TRUE); + printStringMatrix (x, offset, r_pr, r, c_pr, quote, right, rl, cl, rn, cn, TRUE); break; case RAWSXP: - printRawMatrix (x, offset, r_pr, r, c, rl, cl, rn, cn, TRUE); + printRawMatrix (x, offset, r_pr, r, c_pr, rl, cl, rn, cn, TRUE); break; default: UNIMPLEMENTED_TYPE("printMatrix", x); } -#ifdef ENABLE_NLS - if(r_pr < r) // number of formats must be consistent here - Rprintf(ngettext(" [ reached getOption(\"max.print\") -- omitted %d row ]\n", - " [ reached getOption(\"max.print\") -- omitted %d rows ]\n", - r - r_pr), - r - r_pr); -#else - if(r_pr < r) - Rprintf(" [ reached getOption(\"max.print\") -- omitted %d rows ]\n", - r - r_pr); -#endif + if (r_pr < r || c_pr < c) { + Rprintf(" [ reached getOption(\"max.print\") -- omitted"); + if (r_pr < r) { + Rprintf(ngettext(" %d row", " %d rows", r - r_pr), r - r_pr); + } + if (c_pr < c) { + if (r_pr < r) Rprintf(_(" and")); + Rprintf(ngettext(" %d column", " %d columns", c - c_pr), c - c_pr); + } + Rprintf(" ]\n"); + } vmaxset(vmax); } diff --git a/tests/print-tests.R b/tests/print-tests.R index bcafe7e8976..806c7ffd400 100644 --- a/tests/print-tests.R +++ b/tests/print-tests.R @@ -339,5 +339,22 @@ as.complex(1:10) as.raw(1:10) options(o) +## print() max.print and max for matrices (w/ many columns) -- PR#15027 +## whenever the columns are larger than max.print, no values inside the matrix are displayed +print(matrix(nrow = 100, ncol = 4), max = 5) +print(matrix(nrow = 100, ncol = 100), max = 40) # omitting rows and columns +print(matrix(nrow = 10, ncol = 4), max = 3) # (ditto) +print(matrix(nrow = 0, ncol = 4), max = 3) # omitting 1 column +print(matrix(nrow = 10, ncol = 2), max = 5) # omitting rows +print(matrix(nrow = 1, ncol = 6), max = 5) # omitting cols, at least one row prints +## ----- "higher" arrays ("rank >= 3"): -------- +## FIXME: in R 4.4.0 there should be a warning for omitted rows +print(array(dim = c(2, 2, 1)), max = 2) +## FIXME: this does not print anything but it should show +## at least one element according to the logic of max.print +print(array(dim = c(2, 2, 1)), max = 1) + + + ## Cleanup rm(print.foo, obj, a, b, c, d, o) diff --git a/tests/print-tests.Rout.save b/tests/print-tests.Rout.save index 34d914e6ca1..12d41190040 100644 --- a/tests/print-tests.Rout.save +++ b/tests/print-tests.Rout.save @@ -1,6 +1,6 @@ -R Under development (unstable) (2023-08-31 r85038) -- "Unsuffered Consequences" -Copyright (C) 2023 The R Foundation for Statistical Computing +R Under development (unstable) (2024-07-15 r86901) -- "Unsuffered Consequences" +Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -941,6 +941,53 @@ NULL [ reached getOption("max.print") -- omitted 5 entries ] > options(o) > +> ## print() max.print and max for matrices (w/ many columns) -- PR#15027 +> ## whenever the columns are larger than max.print, no values inside the matrix are displayed +> print(matrix(nrow = 100, ncol = 4), max = 5) + [,1] [,2] [,3] [,4] + [1,] NA NA NA NA + [ reached getOption("max.print") -- omitted 99 rows ] +> print(matrix(nrow = 100, ncol = 100), max = 40) # omitting rows and columns + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] + [1,] NA NA NA NA NA NA NA NA NA NA NA NA NA + [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] + [1,] NA NA NA NA NA NA NA NA NA NA NA NA + [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] + [1,] NA NA NA NA NA NA NA NA NA NA NA NA + [,38] [,39] [,40] + [1,] NA NA NA + [ reached getOption("max.print") -- omitted 99 rows and 60 columns ] +> print(matrix(nrow = 10, ncol = 4), max = 3) # (ditto) + [,1] [,2] [,3] + [1,] NA NA NA + [ reached getOption("max.print") -- omitted 9 rows and 1 column ] +> print(matrix(nrow = 0, ncol = 4), max = 3) # omitting 1 column + [,1] [,2] [,3] + [ reached getOption("max.print") -- omitted 1 column ] +> print(matrix(nrow = 10, ncol = 2), max = 5) # omitting rows + [,1] [,2] + [1,] NA NA + [2,] NA NA + [ reached getOption("max.print") -- omitted 8 rows ] +> print(matrix(nrow = 1, ncol = 6), max = 5) # omitting cols, at least one row prints + [,1] [,2] [,3] [,4] [,5] +[1,] NA NA NA NA NA + [ reached getOption("max.print") -- omitted 1 column ] +> ## ----- "higher" arrays ("rank >= 3"): -------- +> ## FIXME: in R 4.4.0 there should be a warning for omitted rows +> print(array(dim = c(2, 2, 1)), max = 2) +, , 1 + + [,1] [,2] +[1,] NA NA + +> ## FIXME: this does not print anything but it should show +> ## at least one element according to the logic of max.print +> print(array(dim = c(2, 2, 1)), max = 1) + [ reached getOption("max.print") -- omitted 1 matrix slice(s) ] +> +> +> > ## Cleanup > rm(print.foo, obj, a, b, c, d, o) > From 07b728cb951bda77c3a44260c381ba0a399f9e38 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 17 Jul 2024 17:13:04 +0000 Subject: [PATCH 373/546] Markup. git-svn-id: https://svn.r-project.org/R/trunk@86903 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 4c1ee175c34..ecf5a2b0a22 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -45,7 +45,7 @@ \item \code{pdf()} gains an \code{author} argument to set the corresponding metadata field, and logical arguments \code{timestamp} and \code{producer} to optionally omit the - respective metadata. (Thanks to Edzer Pebesma.) + respective metadata. (Thanks to \I{Edzer Pebesma}.) } } @@ -157,7 +157,7 @@ \item Memory allocation messages now use the (non-standard notation) \code{"Mb"}, \code{"Gb"} , \dots, and \code{"Mbytes"} strings as \emph{arguments} instead of as part of the (translatable format) - string. This is one step for \PR{18297}; from Henrik Bengtsson. + string. This is one step for \PR{18297}; from \I{Henrik Bengtsson}. } } @@ -182,18 +182,22 @@ \I{Relatedly}, the \code{format()} method gets an option \code{cut.names}. \item \code{stem()} correctly formats also in cases where rounding - up, e.g., from 9.96 to 10 needs more digits; thanks to Ella Kaye and - Kelly Bodwin, fixing \PR{8934} during \sQuote{R Dev Day} at useR!2024. + up, e.g., from 9.96 to 10 needs more digits; thanks to + \I{Ella Kaye} and \I{Kelly Bodwin}, fixing \PR{8934} during + \sQuote{\I{R Dev Day}} at \I{useR!2024}. \item \pkg{tools}' \code{toTitleCase()} now works better, fixing - \PR{18674}, thanks to Shannon Pileggi, Sarah Zeller, Reiko Okamoto, - and Hugo Gruson's \sQuote{R Dev Day} effort. - - \item Printing matrices (typically with many rows and or columns) now - also omits columns when desirable according to option \code{max.print}, - or argument \code{max}, respectively. This is primarily the work of - Lorena Abad, Ekaterina Akimova, Hanne Oberman, Abhishek Ulayil, and - Lionel Henry at the \sQuote{R Dev Day}, thus fixing \PR{15027}. + \PR{18674}, thanks to \I{Shannon Pileggi}, \I{Sarah Zeller}, + \I{Reiko Okamoto}, and \I{Hugo Gruson}'s \sQuote{\I{R Dev Day}} + effort. + + \item Printing matrices (typically with many rows and or columns) + now also omits columns when desirable according to option + \code{max.print}, or argument \code{max}, respectively. + This is primarily the work of \I{Lorena Abad}, + \I{Ekaterina Akimova}, \I{Hanne Oberman}, \I{Abhishek Ulayil}, + and \I{Lionel Henry} at the \sQuote{\I{R Dev Day}}, thus fixing + \PR{15027}. } } } @@ -262,8 +266,8 @@ \file{DESCRIPTION} but has no vignettes. \item The Quartz device could segfault in cases where paths with - spaces are used in the new glyph drawing API. Thanks to Tomek - Gieorgijewski (\PR{18758}). + spaces are used in the new glyph drawing API. + Thanks to \I{Tomek Gieorgijewski} (\PR{18758}). } } } From 4e1f38f15e6beacb2fd8100b4f931e73da5cbdf0 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 18 Jul 2024 21:12:17 +0000 Subject: [PATCH 374/546] Improve xtfrm.AsIs() (thanks to Hilmar Berger and Ivan Krylov). git-svn-id: https://svn.r-project.org/R/trunk@86904 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/sort.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/library/base/R/sort.R b/src/library/base/R/sort.R index cbadce1fb2d..9931b69e1a7 100644 --- a/src/library/base/R/sort.R +++ b/src/library/base/R/sort.R @@ -297,7 +297,8 @@ xtfrm.factor <- function(x) as.integer(x) # primitive, so needs a wrapper xtfrm.AsIs <- function(x) { - if(length(cl <- class(x)) > 1) oldClass(x) <- cl[-1L] + cl <- oldClass(x) + oldClass(x) <- cl[cl != "AsIs"] NextMethod("xtfrm") } From af7074d3aa9c8f02f8c5ad9bc8135bc1514c64ab Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 18 Jul 2024 21:13:31 +0000 Subject: [PATCH 375/546] Drop I() which should no longer be needed (thanks to Hilmar Berger). git-svn-id: https://svn.r-project.org/R/trunk@86905 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/merge.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/base/R/merge.R b/src/library/base/R/merge.R index 88884206d92..c0274b43626 100644 --- a/src/library/base/R/merge.R +++ b/src/library/base/R/merge.R @@ -83,11 +83,11 @@ merge.data.frame <- } else { if(any(by.x == 0L)) { - x <- cbind(Row.names = I(row.names(x)), x) + x <- cbind(Row.names = row.names(x), x) by.x <- by.x + 1L } if(any(by.y == 0L)) { - y <- cbind(Row.names = I(row.names(y)), y) + y <- cbind(Row.names = row.names(y), y) by.y <- by.y + 1L } row.names(x) <- NULL From c62219e9f7774f3bbf63a8b90d1b552d2d32da3e Mon Sep 17 00:00:00 2001 From: urbaneks Date: Sat, 20 Jul 2024 03:35:41 +0000 Subject: [PATCH 376/546] don't segfault if GD doesn't set capabilities callback git-svn-id: https://svn.r-project.org/R/trunk@86906 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/grDevices/src/devices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/grDevices/src/devices.c b/src/library/grDevices/src/devices.c index 1617f5b9fe5..ddd7e234f2a 100644 --- a/src/library/grDevices/src/devices.c +++ b/src/library/grDevices/src/devices.c @@ -226,7 +226,7 @@ SEXP devcap(SEXP args) UNPROTECT(1); /* Further capabilities can be filled in by device */ - if (dd->deviceVersion >= R_GE_group) { + if (dd->deviceVersion >= R_GE_group && dd->capabilities) { devcap = dd->capabilities(capabilities); } else { devcap = capabilities; From 101508ae37a4d9710e095130034a7229d8afae3b Mon Sep 17 00:00:00 2001 From: hornik Date: Sat, 20 Jul 2024 08:49:07 +0000 Subject: [PATCH 377/546] Documentation for c86861. git-svn-id: https://svn.r-project.org/R/trunk@86907 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-ints.texi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/manual/R-ints.texi b/doc/manual/R-ints.texi index 1de60ca86d6..597b08e02c3 100644 --- a/doc/manual/R-ints.texi +++ b/doc/manual/R-ints.texi @@ -4509,6 +4509,11 @@ into errors. On most platforms invalid bytes in these files get converted to escapes (see @code{iconv(sub = "byte")}), but on others these lead to installation failure. Default: unset (but true for CRAN submission checks). + +@item _R_CHECK_XREFS_NOTE_MISSING_PACKAGE_ANCHORS_ +If set to a true value, check whether Rd cross-references to targets not +in the package itself or the base packages have package anchors. +Default: false (but true for CRAN submission checks). @end vtable The following variables control checks for undeclared/unconditional use @@ -4620,6 +4625,7 @@ _R_CHECK_URLS_SHOW_301_STATUS_=true _R_CHECK_UNDOC_USE_ALL_NAMES_=true _R_CHECK_S3_METHODS_SHOW_POSSIBLE_ISSUES_=true _R_CHECK_RD_NOTE_LOST_BRACES_=true +_R_CHECK_XREFS_NOTE_MISSING_PACKAGE_ANCHORS_=true @end example @noindent From ec7f4843622095527d2d9da12dbbee5b7f9e32f7 Mon Sep 17 00:00:00 2001 From: hornik Date: Sat, 20 Jul 2024 08:49:39 +0000 Subject: [PATCH 378/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86908 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/utils.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index 89625e6a44f..ad59eeab3ff 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -936,8 +936,15 @@ function(Tidy = Sys.getenv("R_TIDYCMD", "tidy")) OK <- nzchar(Sys.which(Tidy)) if(OK) { ver <- system2(Tidy, "--version", stdout = TRUE) - mat <- regexec("^HTML Tidy .*version (\\d+\\.\\d+\\.\\d+)$", - ver) + ## Argh. We used to match with + ## ^HTML Tidy .*version (\\d+\\.\\d+\\.\\d+)$ + ## but HTML Tidy 5.8.0 has added l10n to its version info. For + ## now, this always seems to match + ## ^HTML Tidy .* (\\d+\\.\\d+\\.\\d+)$ + ## if this changes, we could try getting the version info with + ## LC_MESSAGES= (set to empty) which seems to get the English + ## default. + mat <- regexec("^HTML Tidy .* (\\d+\\.\\d+\\.\\d+)$", ver) ver <- regmatches(ver, mat)[[1L]][2L] OK <- !is.na(ver) if(OK) { From 2b96e997b4df3f0ff95e8571cfd472c1efe85fdd Mon Sep 17 00:00:00 2001 From: hornik Date: Sat, 20 Jul 2024 08:50:23 +0000 Subject: [PATCH 379/546] Fix PR#18765. git-svn-id: https://svn.r-project.org/R/trunk@86909 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/packages2.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/utils/R/packages2.R b/src/library/utils/R/packages2.R index 04083ba4dd1..5d2a229f9b1 100644 --- a/src/library/utils/R/packages2.R +++ b/src/library/utils/R/packages2.R @@ -756,7 +756,7 @@ install.packages <- av2 <- NULL if(is.null(available)) { filters <- getOption("available_packages_filters") - if(!is.null(filters)) { + if(!is.null(filters) || ("filters" %in% ...names())) { available <- available.packages(contriburl = contriburl, method = method, ...) } else { From 083ec181c878bdec4dd8e881e6df9baacf8bdf1b Mon Sep 17 00:00:00 2001 From: smeyer Date: Mon, 22 Jul 2024 12:10:48 +0000 Subject: [PATCH 380/546] update comments git-svn-id: https://svn.r-project.org/R/trunk@86910 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/Examples/Makefile.in | 7 +++---- tests/Examples/Makefile.win | 4 +--- tests/README | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/Examples/Makefile.in b/tests/Examples/Makefile.in index 2bee1d065f0..ac080c5c775 100644 --- a/tests/Examples/Makefile.in +++ b/tests/Examples/Makefile.in @@ -40,11 +40,10 @@ test-Examples-Base: Makefile ## ## We do *not* want this to be added to test-Examples conditional on ## @USE_RECOMMENDED_PACKAGES_TRUE@. -## 'make check-all' is used for running test-Examples-Recommended in -## addition to 'make check'. -## nlme suggests 'Hmisc' +## 'make check-all' is used for running test-Packages-Recommended in +## addition to 'make check', which includes checking the examples. test-Examples-Recommended: test-Examples-Base - @$(ECHO) "tools::testInstalledPackages(scope='recommended', types='examples')" | _R_CHECK_FORCE_SUGGESTS_=FALSE $(R_EXE) + @$(ECHO) "tools::testInstalledPackages(scope='recommended', types='examples')" | $(R_EXE) ## mostlyclean: clean diff --git a/tests/Examples/Makefile.win b/tests/Examples/Makefile.win index b83c2750a26..9f08f810ab5 100644 --- a/tests/Examples/Makefile.win +++ b/tests/Examples/Makefile.win @@ -29,10 +29,8 @@ test-Examples-Base: @$(ECHO) "tools::testInstalledPackages(scope='base', types='examples', commentDonttest=!$(TEST_DONTTEST))" | $(R_EXE) -## nlme suggests 'Hmisc' test-Examples-Recommended: test-Examples-Base - @$(ECHO) "tools::testInstalledPackages(scope='recommended', types='examples')" | $(R_EXE) _R_CHECK_FORCE_SUGGESTS_=FALSE -## + @$(ECHO) "tools::testInstalledPackages(scope='recommended', types='examples')" | $(R_EXE) mostlyclean: clean clean: diff --git a/tests/README b/tests/README index b8bd6e40e53..dcd579906b0 100644 --- a/tests/README +++ b/tests/README @@ -19,8 +19,8 @@ runs all the checks, those in check-devel plus tests of the recommended packages. Note that for complete testing you will need a number of other -packages installed and available. For example, some 'nlme' tests depend -on 'Hmisc', and there are a number of cross references from help pages +packages installed and available. For example, +there are a number of cross references from help pages to CRAN packages. Set R_LIBS_USER_IN_R_TESTS or R_LIBS to include additional library trees before running these checks; the default user libraries (R_LIBS_USER) are ignored. From 245e78d0752f4b6c403de45a1d71408076da569d Mon Sep 17 00:00:00 2001 From: smeyer Date: Mon, 22 Jul 2024 12:35:10 +0000 Subject: [PATCH 381/546] don't use DESTDIR when building git-svn-id: https://svn.r-project.org/R/trunk@86911 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/Makefile.in | 2 +- doc/html/Makefile.in | 2 +- doc/manual/Makefile.in | 4 ++-- share/Makefile.in | 4 ++-- src/extra/blas/Makefile.in | 2 +- src/main/Makefile.in | 6 +++--- src/modules/X11/Makefile.in | 2 +- src/modules/internet/Makefile.in | 2 +- src/modules/lapack/Makefile.in | 4 ++-- src/scripts/Makefile.in | 2 +- src/unix/Makefile.in | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/Makefile.in b/doc/Makefile.in index c9e3a73a9ef..786bc1a4afc 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -36,7 +36,7 @@ R: Makefile svnonly (cd $${d} && $(MAKE) $@) || exit 1; \ done @if test "$(BUILDDIR_IS_SRCDIR)" = no ; then \ - $(MAKE) rdocdir=$(top_builddir)/doc install-sources; \ + $(MAKE) DESTDIR="" rdocdir=$(top_builddir)/doc install-sources; \ fi ## man pages last: currently needs perl (which is *not* checked at configure time); diff --git a/doc/html/Makefile.in b/doc/html/Makefile.in index 183ff8b221a..97ebabd70e1 100644 --- a/doc/html/Makefile.in +++ b/doc/html/Makefile.in @@ -38,7 +38,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status R: Makefile $(OBJECTS) svnonly @if test "$(BUILDDIR_IS_SRCDIR)" = no ; then \ - $(MAKE) rdocdir=$(top_builddir)/doc install-sources; \ + $(MAKE) DESTDIR="" rdocdir=$(top_builddir)/doc install-sources; \ fi svnonly: diff --git a/doc/manual/Makefile.in b/doc/manual/Makefile.in index 54664622a2d..ac9504a27e6 100644 --- a/doc/manual/Makefile.in +++ b/doc/manual/Makefile.in @@ -323,7 +323,7 @@ R-intro.pdf: stamp-images-pdf $(texiincludes) R-ints.pdf: $(texiincludes) stamp-images-pdf: @if test "$(BUILDDIR_IS_SRCDIR)" = no ; then \ - $(MAKE) rdocdir=$(top_builddir)/doc install-images-pdf; \ + $(MAKE) DESTDIR="" rdocdir=$(top_builddir)/doc install-images-pdf; \ fi @touch $@ R-lang.pdf: $(texiincludes) @@ -347,7 +347,7 @@ install-images-html: installdirs done stamp-images-html: @if test "$(BUILDDIR_IS_SRCDIR)" = no ; then \ - $(MAKE) rdocdir=$(top_builddir)/doc install-images-html; \ + $(MAKE) DESTDIR="" rdocdir=$(top_builddir)/doc install-images-html; \ fi @touch $@ install-images-pdf: installdirs diff --git a/share/Makefile.in b/share/Makefile.in index f7112edf085..6397fe0724d 100644 --- a/share/Makefile.in +++ b/share/Makefile.in @@ -23,9 +23,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status R: FORCE @if test "$(BUILDDIR_IS_SRCDIR)" = "no" ; then \ - $(MAKE) rsharedir=$(top_builddir)/share install-sources; \ + $(MAKE) DESTDIR="" rsharedir=$(top_builddir)/share install-sources; \ elif test "x@BUILD_TZONE_TRUE@" = "x"; then \ - $(MAKE) rsharedir=. install-zoneinfo; \ + $(MAKE) DESTDIR="" rsharedir=. install-zoneinfo; \ fi FORCE: diff --git a/src/extra/blas/Makefile.in b/src/extra/blas/Makefile.in index e57a5d5a754..b9010fae24c 100644 --- a/src/extra/blas/Makefile.in +++ b/src/extra/blas/Makefile.in @@ -36,7 +36,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(SOURCES_C) R: @$(MAKE) $(Rblas_la) - @$(MAKE) rhome="$(abs_top_builddir)" Rblas_install + @$(MAKE) DESTDIR="" rhome="$(abs_top_builddir)" Rblas_install blas2.o: blas2.f90 $(FC) $(ALL_FCFLAGS) -c @FCFLAGS_f90@ $< -o $@ diff --git a/src/main/Makefile.in b/src/main/Makefile.in index a4180e8fc0d..6e71c036500 100644 --- a/src/main/Makefile.in +++ b/src/main/Makefile.in @@ -158,10 +158,10 @@ libR.a: $(OBJECTS) $(STATIC_LIBS) @rm -Rf libs install-bin-local: $(R_binary) - @$(MAKE) rhome="$(abs_top_builddir)" install-bin + @$(MAKE) DESTDIR="" rhome="$(abs_top_builddir)" install-bin install-static-local: libR.a - @$(MAKE) rhome="$(abs_top_builddir)" install-static + @$(MAKE) DESTDIR="" rhome="$(abs_top_builddir)" install-static $(top_builddir)/etc/R.exp: $(OBJECTS) $(MAIN_LIBS) @$(SHELL) $(top_srcdir)/tools/ldAIX4 -o $@ $(OBJECTS) $(MAIN_LIBS) @@ -180,7 +180,7 @@ $(libR_la): $(libR_la_OBJECTS) $(libR_la_DEPENDENCIES) $(DYLIB_LINK) $(LIBR_LDFLAGS) -o $@ $(libR_la_OBJECTS) $(libR_la_LIBADD) install-lib-local: $(libR_la) - @$(MAKE) rhome="$(abs_top_builddir)" install-lib + @$(MAKE) DESTDIR="" rhome="$(abs_top_builddir)" install-lib # suppress #line directives diff --git a/src/modules/X11/Makefile.in b/src/modules/X11/Makefile.in index 0a118d8a893..fdd55ae6528 100644 --- a/src/modules/X11/Makefile.in +++ b/src/modules/X11/Makefile.in @@ -54,7 +54,7 @@ Makedeps: Makefile $(DEPENDS) R: Makedeps @$(MAKE) $(R_X11_la) $(R_de_la) - @$(MAKE) rhome="$(abs_top_builddir)" install + @$(MAKE) DESTDIR="" rhome="$(abs_top_builddir)" install $(R_X11_la): $(OBJECTS) $(SHLIB_LINK) -o $@ $(OBJECTS) $(R_X11_la_LIBADD) diff --git a/src/modules/internet/Makefile.in b/src/modules/internet/Makefile.in index 161463283d7..714f1019785 100644 --- a/src/modules/internet/Makefile.in +++ b/src/modules/internet/Makefile.in @@ -45,7 +45,7 @@ $(internet_la): $(OBJECTS) $(SHLIB_LINK) -o $@ $(OBJECTS) $(internet_la_LIBADD) ## ## Not sure if we want to do this ... - @$(MAKE) rhome="$(abs_top_builddir)" install + @$(MAKE) DESTDIR="" rhome="$(abs_top_builddir)" install ## install: installdirs diff --git a/src/modules/lapack/Makefile.in b/src/modules/lapack/Makefile.in index 0a1c9cb5a29..1a72b2925c5 100644 --- a/src/modules/lapack/Makefile.in +++ b/src/modules/lapack/Makefile.in @@ -96,14 +96,14 @@ dlartg.o dlassq.o zlartg.o zlassq.o la_xisnan.o: la_constants.o dlassq.o zlassq.o: la_xisnan.o R: Makedeps -@USE_EXTERNAL_LAPACK_FALSE@ @$(MAKE) rhome="$(abs_top_builddir)" $(Rlapack_la) Rlapack_install +@USE_EXTERNAL_LAPACK_FALSE@ @$(MAKE) DESTDIR="" rhome="$(abs_top_builddir)" $(Rlapack_la) Rlapack_install @$(MAKE) $(lapack_la) $(lapack_la): $(lapack_la_OBJECTS) $(SHLIB_LINK) -o $@ $(lapack_la_LDFLAGS) $(lapack_la_OBJECTS) $(lapack_la_LIBADD) $(EXTRA_LIBS) ## ## Not sure if we want to do this ... - @$(MAKE) rhome="$(abs_top_builddir)" install + @$(MAKE) DESTDIR="" rhome="$(abs_top_builddir)" install ## ## Include BLAS here, as with (static) ATLAS that pulls all the diff --git a/src/scripts/Makefile.in b/src/scripts/Makefile.in index d1da340d832..87b95ab14e0 100644 --- a/src/scripts/Makefile.in +++ b/src/scripts/Makefile.in @@ -31,7 +31,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ R: $(SCRIPTS_B) R.fe - @$(MAKE) rhome=$(top_builddir) install-cmds + @$(MAKE) DESTDIR="" rhome=$(top_builddir) install-cmds @$(INSTALL_SCRIPT) R.fe $(top_builddir)/bin/R ## diff --git a/src/unix/Makefile.in b/src/unix/Makefile.in index 4a352782109..2424c6a30d5 100644 --- a/src/unix/Makefile.in +++ b/src/unix/Makefile.in @@ -47,7 +47,7 @@ Makedeps: Makefile $(DEPENDS) R: Makedeps @$(MAKE) libunix.a - @$(MAKE) rhome="$(abs_top_builddir)" install-Rscript + @$(MAKE) DESTDIR="" rhome="$(abs_top_builddir)" install-Rscript ## Intel's icx, at least version 2023.2.0, needs -O0 ## or CPU times will all be zero. From 0fa95400b3aa51fbbc37674a2410d798c4be3439 Mon Sep 17 00:00:00 2001 From: smeyer Date: Mon, 22 Jul 2024 12:36:36 +0000 Subject: [PATCH 382/546] spelling git-svn-id: https://svn.r-project.org/R/trunk@86912 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 +- src/library/stats/man/cmdscale.Rd | 2 +- src/library/tools/R/QC.R | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index d5722b930f9..b2c1e31523c 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14593,7 +14593,7 @@ Rboolean charIsLatin1(SEXP); @noindent can be used to detect whether the internal representation of a given @code{CHARSXP} accessed via @code{CHAR} is latin1 (including ASCII). It is -not equivalent to to @code{getCharCE() == CE_LATIN1}. +not equivalent to @code{getCharCE() == CE_LATIN1}. Function diff --git a/src/library/stats/man/cmdscale.Rd b/src/library/stats/man/cmdscale.Rd index adc68e6b16c..4df59e7154b 100644 --- a/src/library/stats/man/cmdscale.Rd +++ b/src/library/stats/man/cmdscale.Rd @@ -59,7 +59,7 @@ cmdscale(d, k = 2, eig = FALSE, add = FALSE, x.ret = FALSE, could be in fewer than \code{n - 1} dimensions. } \value{ - If \code{.list} is false (as per default), a matrix with \code{k} + If \code{list.} is false (as per default), a matrix with \code{k} columns whose rows give the coordinates of the points chosen to represent the dissimilarities. diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index 5962aa2d65c..03e47b8b495 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -3456,7 +3456,7 @@ function(x, ...) c(if(length(bad) > 1L) { c("Vignette dependencies required without any vignettes:", .pretty_format(bad)) } else { - sprintf("Vignette dependency required without any vignettes:: %s", sQuote(bad)) + sprintf("Vignette dependency required without any vignettes: %s", sQuote(bad)) }, "") }, From e6ae4487697e64023b7c54d3c40f1faa1351e108 Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 22 Jul 2024 19:07:57 +0000 Subject: [PATCH 383/546] beta(2e306, 8e306) should not warn (even twice!) about lgammacor() underflow git-svn-id: https://svn.r-project.org/R/trunk@86913 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 9 +++++++++ src/nmath/lgammacor.c | 11 +++++++---- tests/reg-tests-1e.R | 7 +++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index ecf5a2b0a22..b55899ad3da 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -202,6 +202,15 @@ } } +\section{\Rlogo CHANGES IN R 4.4.1 patched}{ + \subsection{BUG FIXES}{ + \itemize{ + \item Mathlib function \code{lgammacor(x)} no longer warns about + underflow to zero for large \code{x}. + } + } +} + \section{\Rlogo CHANGES IN R 4.4.1}{ \subsection{C-LEVEL FACILITIES}{ \itemize{ diff --git a/src/nmath/lgammacor.c b/src/nmath/lgammacor.c index 974e1158027..0b2db95a799 100644 --- a/src/nmath/lgammacor.c +++ b/src/nmath/lgammacor.c @@ -25,11 +25,12 @@ * DESCRIPTION * * Compute the log gamma correction factor for x >= 10 so that + * --------- * * log(gamma(x)) = .5*log(2*pi) + (x-.5)*log(x) -x + lgammacor(x) * - * [ lgammacor(x) is called Del(x) in other contexts (e.g. dcdflib)] - * + * [ lgammacor(x) is called Del(x) in other contexts (e.g. dcdflib)], or stirlerr(x) + * ~~~~~~ ~~~~~~~~~~~ * NOTES * * This routine is a translation into C of a Fortran subroutine @@ -68,18 +69,20 @@ double attribute_hidden lgammacor(double x) * xmax = DBL_MAX / 48 = 2^1020 / 3 */ #define nalgm 5 #define xbig 94906265.62425156 -#define xmax 3.745194030963158e306 if (x < 10) // possibly consider stirlerr() ML_WARN_return_NAN +#ifndef IEEE_754 +# define xmax 3.745194030963158e306 else if (x >= xmax) { ML_WARNING(ME_UNDERFLOW, "lgammacor"); /* allow to underflow below */ } +#endif else if (x < xbig) { double tmp = 10 / x; return chebyshev_eval(tmp * tmp * 2 - 1, algmcs, nalgm) / x; } - // else, xbig <= x < xmax : + // x >= xbig return 1 / (x * 12); } diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 0dcbdc12d78..be3cf7c43fb 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1454,6 +1454,13 @@ stopifnot(exprs = { ## change NA names() into "NA" for R <= 4.4.1 +## warning for even *potential* underflow +B <- 2e306 +stopifnot(beta(B, 4*B) == 0, + all.equal(-5.00402423538187888e306, lbeta(B, 4*B), tolerance = 5e-16)) +## no longer warns - as we require IEEE_745 + + ## keep at end rbind(last = proc.time() - .pt, From 485f2a17eec04ed2d7975fedcc9dd7995d608b4b Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 23 Jul 2024 05:21:17 +0000 Subject: [PATCH 384/546] Tweaks for c86909. git-svn-id: https://svn.r-project.org/R/trunk@86914 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/packages2.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/library/utils/R/packages2.R b/src/library/utils/R/packages2.R index 5d2a229f9b1..2108b20ef2b 100644 --- a/src/library/utils/R/packages2.R +++ b/src/library/utils/R/packages2.R @@ -756,7 +756,8 @@ install.packages <- av2 <- NULL if(is.null(available)) { filters <- getOption("available_packages_filters") - if(!is.null(filters) || ("filters" %in% ...names())) { + if(!is.null(filters) || + !is.na(pmatch(...names(), "filters"))) { available <- available.packages(contriburl = contriburl, method = method, ...) } else { From 9c6d701da9663ab4983dadc9937b02587941a175 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 23 Jul 2024 08:18:24 +0000 Subject: [PATCH 385/546] Tweaks for c86909. git-svn-id: https://svn.r-project.org/R/trunk@86915 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/packages2.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/utils/R/packages2.R b/src/library/utils/R/packages2.R index 2108b20ef2b..1d07de27a6e 100644 --- a/src/library/utils/R/packages2.R +++ b/src/library/utils/R/packages2.R @@ -757,7 +757,7 @@ install.packages <- if(is.null(available)) { filters <- getOption("available_packages_filters") if(!is.null(filters) || - !is.na(pmatch(...names(), "filters"))) { + any(!is.na(pmatch(...names(), "filters")))) { available <- available.packages(contriburl = contriburl, method = method, ...) } else { From 47d7f9e658450cc8c3b3724046bdc7920d021f9f Mon Sep 17 00:00:00 2001 From: urbaneks Date: Wed, 24 Jul 2024 01:50:40 +0000 Subject: [PATCH 386/546] Quartz: use font info (if available) even without context (PR#18591) git-svn-id: https://svn.r-project.org/R/trunk@86916 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/grDevices/src/devQuartz.c | 35 +++++++++++++++++++-------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/library/grDevices/src/devQuartz.c b/src/library/grDevices/src/devQuartz.c index 9cabea16ff3..a924f9628aa 100644 --- a/src/library/grDevices/src/devQuartz.c +++ b/src/library/grDevices/src/devQuartz.c @@ -1939,10 +1939,16 @@ static CFStringRef text2unichar(CTXDESC, const char *text, UniChar **buffer, int static double RQuartz_StrWidth(const char *text, CTXDESC) { DEVSPEC; - if (!ctx) NOCTXR(strlen(text) * 10.0); /* for sanity reasons */ - RQuartz_SetFont(ctx, gc, xd); - CGFontRef font = CGContextGetFont(ctx); + CGFontRef font = 0; + if (!ctx) { /* if there is no context then don't set the font */ + xd->async = 1; /* flag us as not having a context */ + font = RQuartz_Font(gc, NULL); + if (!font) return (strlen(text) * 10.0); /* for sanity reasons */ + } else { + RQuartz_SetFont(ctx, gc, xd); + font = CGContextGetFont(ctx); + } float aScale = (float)((gc->cex * gc->ps * xd->tscale) / CGFontGetUnitsPerEm(font)); UniChar *buffer; @@ -2547,15 +2553,24 @@ RQuartz_MetricInfo(int c, const pGEcontext gc, pDevDesc dd) { DRAWSPEC; - if (!ctx) { /* dummy data if we have no context, for sanity reasons */ - *ascent = 10.0; - *descent= 2.0; - *width = 9.0; - NOCTX; + CGFontRef font = 0; + + if (!ctx) { + xd->async = 1; /* flag us as not having a context */ + font = RQuartz_Font(gc, NULL); + if (!font) { + /* dummy data if we have no font at all, for sanity reasons */ + *ascent = 10.0; + *descent= 2.0; + *width = 9.0; + return; + } + } else { + RQuartz_SetFont(ctx, gc, xd); + font = CGContextGetFont(ctx); } - RQuartz_SetFont(ctx, gc, xd); + { - CGFontRef font = CGContextGetFont(ctx); float aScale = (float)((gc->cex * gc->ps * xd->tscale) / CGFontGetUnitsPerEm(font)); UniChar *buffer, single; From 4c2bbac9007ff43b71bfa7a064ca43aa49257a5f Mon Sep 17 00:00:00 2001 From: urbaneks Date: Wed, 24 Jul 2024 01:58:55 +0000 Subject: [PATCH 387/546] update NEWS git-svn-id: https://svn.r-project.org/R/trunk@86917 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index b55899ad3da..d733bb0ed7c 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -207,6 +207,15 @@ \itemize{ \item Mathlib function \code{lgammacor(x)} no longer warns about underflow to zero for large \code{x}. + + \item Text widths and heights were incorrectly reported by the + Quartz device if the drawing context didn't exist yet (typically + when drawing off-screen to a window that is yet to appear, see + \PR{18591}). + + \item The Quartz device could segfault in cases where paths with + spaces are used in the new glyph drawing API. + Thanks to \I{Tomek Gieorgijewski} (\PR{18758}). } } } @@ -273,10 +282,6 @@ result and no explanation in \file{00check.log}) for a package which declares an invalid \code{VignetteBuilder} in \file{DESCRIPTION} but has no vignettes. - - \item The Quartz device could segfault in cases where paths with - spaces are used in the new glyph drawing API. - Thanks to \I{Tomek Gieorgijewski} (\PR{18758}). } } } From 0257ece5109b26faaa59bac11c3d99eab846d554 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 24 Jul 2024 08:14:07 +0000 Subject: [PATCH 388/546] Add 2-index subscripting for [ and [[ methods for person objects. git-svn-id: https://svn.r-project.org/R/trunk@86921 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 40 ++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 81ef80ec8ec..85d15b28056 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -190,13 +190,34 @@ function(role) role } -`[[.person` <- -`[.person` <- -function(x, i) -{ - rval <- unclass(x)[i] - class(rval) <- class(x) - return(rval) +person_field_names <- + c("given", "family", "role", "email", "comment") + +`[.person` <- function(x, i, j) { + y <- unclass(x)[i] + if(missing(j)) { + class(y) <- class(x) + } else { + j <- match.arg(j, person_field_names) + y <- lapply(y, `[[`, j) + } + y +} + +`[[.person` <- function(x, i, j) { + ## if(missing(i)) + ## stop(gettext("missing subscript", + ## domain = NA)) + i <- seq_along(x)[[i]] + y <- unclass(x)[[i]] + if(missing(j)) { + y <- list(y) + class(y) <- class(x) + } else { + j <- match.arg(j, person_field_names) + y <- y[[j]] + } + y } print.person <- @@ -215,7 +236,7 @@ function(x, name) ## person()) ## name <- match.arg(name, - c("given", "family", "role", "email", "comment", + c(person_field_names, "first", "last", "middle")) # for now ... ## ## Let's be nice and support first/middle/last for now. @@ -245,13 +266,14 @@ function(x, name) } if(length(rval) == 1L) rval <- rval[[1L]] + rval } `$<-.person` <- function(x, name, value) { - name <- match.arg(name, c("given", "family", "role", "email", "comment")) + name <- match.arg(name, person_field_names) x <- .listify(unclass(x)) value <- rep_len(value, length(x)) From cc3b5dc4240a8644110b1170f0118a0cd458cb8a Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 24 Jul 2024 09:10:13 +0000 Subject: [PATCH 389/546] Drop first/middle/last support in $ method for person objects. git-svn-id: https://svn.r-project.org/R/trunk@86922 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 42 +++++----------------------------- 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 85d15b28056..c81ce8fc57f 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -231,43 +231,13 @@ function(x, ...) function(x, name) { ## - ## extract internal list elements, return list if length > 1, vector - ## otherwise (to mirror the behaviur of the input format for - ## person()) + ## Return list if length > 1, vector otherwise (to mirror the + ## behavior of the input format for person()). ## - name <- match.arg(name, - c(person_field_names, - "first", "last", "middle")) # for now ... - ## - ## Let's be nice and support first/middle/last for now. - ## - if(name %in% c("first", "last", "middle")) { - message(gettextf("It is recommended to use %s/%s instead of %s/%s/%s.", - sQuote("given"), sQuote("family"), - sQuote("first"), sQuote("middle"), sQuote("last")), - domain = NA) - oname <- name - name <- switch(name, - "first" = "given", - "middle" = "given", - "last" = "family" - ) - } else { - oname <- name - } - - rval <- lapply(unclass(x), function(p) p[[name]]) - - if(oname == "first") rval <- lapply(rval, head, 1L) - if(oname == "middle") { - rval <- lapply(rval, tail, -1L) - if(any(ind <- (lengths(rval) == 0L))) - rval[ind] <- vector("list", length = sum(ind)) - } - - if(length(rval) == 1L) rval <- rval[[1L]] - - rval + name <- match.arg(name, person_field_names) + y <- lapply(unclass(x), `[[`, name) + if(length(y) == 1L) y <- y[[1L]] + y } `$<-.person` <- From d14429eea15082f854b874760727976d785e62b1 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 24 Jul 2024 10:05:33 +0000 Subject: [PATCH 390/546] Add [<- and [[<- methods for person objects. git-svn-id: https://svn.r-project.org/R/trunk@86923 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/NAMESPACE | 2 ++ src/library/utils/R/citation.R | 53 ++++++++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/library/utils/NAMESPACE b/src/library/utils/NAMESPACE index 251eb48eb51..2eb04f52707 100644 --- a/src/library/utils/NAMESPACE +++ b/src/library/utils/NAMESPACE @@ -146,8 +146,10 @@ S3method("$<-", "citation") S3method("$<-", "person") S3method("[", "bibentry") S3method("[", "person") +S3method("[<-", "person") S3method("[[", "bibentry") S3method("[[", "person") +S3method("[[<-", "person") S3method("as.data.frame", "bibentry") S3method("as.data.frame", "citation") S3method("as.data.frame", "person") diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index c81ce8fc57f..0045021ed68 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -193,7 +193,9 @@ function(role) person_field_names <- c("given", "family", "role", "email", "comment") -`[.person` <- function(x, i, j) { +`[.person` <- +function(x, i, j) +{ y <- unclass(x)[i] if(missing(j)) { class(y) <- class(x) @@ -204,10 +206,9 @@ person_field_names <- y } -`[[.person` <- function(x, i, j) { - ## if(missing(i)) - ## stop(gettext("missing subscript", - ## domain = NA)) +`[[.person` <- +function(x, i, j) +{ i <- seq_along(x)[[i]] y <- unclass(x)[[i]] if(missing(j)) { @@ -220,6 +221,48 @@ person_field_names <- y } +`[<-.person` <- +function(x, i, j, value) +{ + y <- unclass(x) + if(missing(j)) + y[i] <- as.person(value) + else { + j <- match.arg(j, person_field_names) + p <- seq_along(x)[i] + value <- rep_len(value, length(p)) + if(j == "role") + value <- lapply(value, .canonicalize_person_role) + for(i in p) + y[[i]][[j]] <- if(.is_not_nonempty_text(value[[i]])) + NULL + else as.character(value[[i]]) + } + class(y) <- class(x) + y +} + +`[[<-.person` <- +function(x, i, j, value) +{ + i <- seq_along(x)[[i]] + y <- unclass(x) + if(missing(j)) + y[i] <- as.person(value) + else { + j <- match.arg(j, person_field_names) + if(j == "role") + value <- .canonicalize_person_role(value) + y[[i]][[j]] <- if(.is_not_nonempty_text(value)) + NULL + else as.character(value) + } + class(y) <- class(x) + y +} + + + print.person <- function(x, ...) { From a457334301e87c9ddc95ec2b6c22af2906bdec93 Mon Sep 17 00:00:00 2001 From: smeyer Date: Wed, 24 Jul 2024 12:23:54 +0000 Subject: [PATCH 391/546] pass checks --without-recommended-packages git-svn-id: https://svn.r-project.org/R/trunk@86924 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/reg-packages.R | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/reg-packages.R b/tests/reg-packages.R index 8dc8bbfdab6..1a01b4fd43e 100644 --- a/tests/reg-packages.R +++ b/tests/reg-packages.R @@ -422,19 +422,20 @@ if(okA) { } else message("pkgA/DESCRIPTION not available") showProc.time() -require(PkgC, lib.loc = "myLib") -(r <- methods(PkgC:::foobar))# "should" return non-empty even when neither S3 generic nor method was exported -meths <- paste("foobar", c("Date", "default"), sep = ".") -try(PkgC:::foobar(pi)) # -> foobar.default is *not* 'found' -if(FALSE) # not working when run via `make` -PkgC:::foobar(Sys.Date()) # -> foobar.Date *is* found b/c S3method(.) -stopifnot(exprs = { - inherits(r, "MethodsFunction") - r == meths # may change if add an extra star - nrow(mi <- attr(r, "info")) == 2 - identical(meths, rownames(mi)) -}) -## failed up to R 4.4.x +if (requireNamespace("PkgC", lib.loc = "myLib")) { + (r <- methods(PkgC:::foobar))# "should" return non-empty even when neither S3 generic nor method was exported + meths <- paste("foobar", c("Date", "default"), sep = ".") + try(PkgC:::foobar(pi)) # -> foobar.default is *not* 'found' + if(FALSE) # not working when run via `make` + PkgC:::foobar(Sys.Date()) # -> foobar.Date *is* found b/c S3method(.) + stopifnot(exprs = { + inherits(r, "MethodsFunction") + r == meths # may change if add an extra star + nrow(mi <- attr(r, "info")) == 2 + identical(meths, rownames(mi)) + }) + ## failed up to R 4.4.x +} ## R CMD check should *not* warn about \Sexpr{} built sections in Rd (PR#17479): writeLines(msg <- capture.output( From 8d22bc91c0041057b712db690944ec2e5f2c4931 Mon Sep 17 00:00:00 2001 From: smeyer Date: Thu, 25 Jul 2024 14:40:55 +0000 Subject: [PATCH 392/546] drop now-redundant I() in some examples git-svn-id: https://svn.r-project.org/R/trunk@86925 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/AsIs.Rd | 3 ++- src/library/base/man/merge.Rd | 7 +++---- src/library/base/man/print.dataframe.Rd | 2 +- src/library/stats/man/reshape.Rd | 2 +- src/library/utils/man/write.table.Rd | 2 +- tests/Examples/stats-Ex.Rout.save | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/library/base/man/AsIs.Rd b/src/library/base/man/AsIs.Rd index 1635f1754db..26e7b57d7b5 100644 --- a/src/library/base/man/AsIs.Rd +++ b/src/library/base/man/AsIs.Rd @@ -24,7 +24,8 @@ I(x) \itemize{ \item In function \code{\link{data.frame}}. Protecting an object by enclosing it in \code{I()} in a call to \code{data.frame} inhibits the - conversion of character vectors to factors and the dropping of + conversion of character vectors to factors (only relevant if + \code{stringsAsFactors = TRUE}) and the dropping of names, and ensures that matrices are inserted as single columns. \code{I} can also be used to protect objects which are to be added to a data frame, or converted to a data frame \emph{via} diff --git a/src/library/base/man/merge.Rd b/src/library/base/man/merge.Rd index 8664742c105..17783d57346 100644 --- a/src/library/base/man/merge.Rd +++ b/src/library/base/man/merge.Rd @@ -127,14 +127,13 @@ merge(x, y, \dots) \examples{ authors <- data.frame( - ## I(*) : use character columns of names to get sensible sort order - surname = I(c("Tukey", "Venables", "Tierney", "Ripley", "McNeil")), + surname = c("Tukey", "Venables", "Tierney", "Ripley", "McNeil"), nationality = c("US", "Australia", "US", "UK", "Australia"), deceased = c("yes", rep("no", 4))) authorN <- within(authors, { name <- surname; rm(surname) }) books <- data.frame( - name = I(c("Tukey", "Venables", "Tierney", - "Ripley", "Ripley", "McNeil", "R Core")), + name = c("Tukey", "Venables", "Tierney", + "Ripley", "Ripley", "McNeil", "R Core"), title = c("Exploratory Data Analysis", "Modern Applied Statistics ...", "LISP-STAT", diff --git a/src/library/base/man/print.dataframe.Rd b/src/library/base/man/print.dataframe.Rd index cc7cec34021..f5207c3a695 100644 --- a/src/library/base/man/print.dataframe.Rd +++ b/src/library/base/man/print.dataframe.Rd @@ -40,7 +40,7 @@ \code{\link{data.frame}}. } \examples{ -(dd <- data.frame(x = 1:8, f = gl(2,4), ch = I(letters[1:8]))) +(dd <- data.frame(x = 1:8, f = gl(2,4), ch = letters[1:8])) # print() with defaults print(dd, quote = TRUE, row.names = FALSE) # suppresses row.names and quotes all entries diff --git a/src/library/stats/man/reshape.Rd b/src/library/stats/man/reshape.Rd index 0c04a92b2ff..905e0a3a7b6 100644 --- a/src/library/stats/man/reshape.Rd +++ b/src/library/stats/man/reshape.Rd @@ -221,7 +221,7 @@ reshape(wide, idvar = "Subject", varying = list(2:12), ## times need not be numeric df <- data.frame(id = rep(1:4, rep(2,4)), - visit = I(rep(c("Before","After"), 4)), + visit = rep(c("Before","After"), 4), x = rnorm(4), y = runif(4)) df reshape(df, timevar = "visit", idvar = "id", direction = "wide") diff --git a/src/library/utils/man/write.table.Rd b/src/library/utils/man/write.table.Rd index 0ec7eccce9a..3a152cd3ccc 100644 --- a/src/library/utils/man/write.table.Rd +++ b/src/library/utils/man/write.table.Rd @@ -165,7 +165,7 @@ write.csv2(\dots) } \examples{ -x <- data.frame(a = I("a \" quote"), b = pi) +x <- data.frame(a = "a \" quote", b = pi) tf <- tempfile(fileext = ".csv") ## To write a CSV file for input to Excel one might use diff --git a/tests/Examples/stats-Ex.Rout.save b/tests/Examples/stats-Ex.Rout.save index 5c8e7f58c65..8e2bd8df4b6 100644 --- a/tests/Examples/stats-Ex.Rout.save +++ b/tests/Examples/stats-Ex.Rout.save @@ -15508,7 +15508,7 @@ block N P K > > ## times need not be numeric > df <- data.frame(id = rep(1:4, rep(2,4)), -+ visit = I(rep(c("Before","After"), 4)), ++ visit = rep(c("Before","After"), 4), + x = rnorm(4), y = runif(4)) > df id visit x y From 5ec950090b08837ecc54439bc68ab5f4d76aaa64 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 26 Jul 2024 15:28:59 +0000 Subject: [PATCH 393/546] Fix function name in error mesage. git-svn-id: https://svn.r-project.org/R/trunk@86926 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/memory.c b/src/main/memory.c index d02a01bec91..b33a43e4813 100644 --- a/src/main/memory.c +++ b/src/main/memory.c @@ -4234,7 +4234,7 @@ SEXP *(STRING_PTR)(SEXP x) { const SEXP *(STRING_PTR_RO)(SEXP x) { if(TYPEOF(x) != STRSXP) error("%s() can only be applied to a '%s', not a '%s'", - "STRING_PTR_RO", "character", R_typeToChar(x)); + __func__, "character", R_typeToChar(x)); CHKZLN(x); return STRING_PTR_RO(x); } @@ -4247,7 +4247,7 @@ NORET SEXP * (VECTOR_PTR)(SEXP x) const SEXP *(VECTOR_PTR_RO)(SEXP x) { if(TYPEOF(x) != VECSXP) error("%s() can only be applied to a '%s', not a '%s'", - "STRING_PTR_RO", "list", R_typeToChar(x)); + __func__, "list", R_typeToChar(x)); CHKZLN(x); return VECTOR_PTR_RO(x); } From 299c479063fc9f53599ec6ccb4c6b5ff73a2adbb Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 28 Jul 2024 05:09:58 +0000 Subject: [PATCH 394/546] Markup. git-svn-id: https://svn.r-project.org/R/trunk@86927 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index d733bb0ed7c..76a78318746 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -205,7 +205,7 @@ \section{\Rlogo CHANGES IN R 4.4.1 patched}{ \subsection{BUG FIXES}{ \itemize{ - \item Mathlib function \code{lgammacor(x)} no longer warns about + \item \I{Mathlib} function \code{lgammacor(x)} no longer warns about underflow to zero for large \code{x}. \item Text widths and heights were incorrectly reported by the From 3cf49322dc0745677b42804851c925e6d6fc9bc4 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 28 Jul 2024 05:10:34 +0000 Subject: [PATCH 395/546] Add .authors_at_R_field_from_author_and_maintainer(). git-svn-id: https://svn.r-project.org/R/trunk@86928 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 41 +++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 0045021ed68..dfcd60cc49f 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -261,8 +261,6 @@ function(x, i, j, value) y } - - print.person <- function(x, ...) { @@ -1089,9 +1087,8 @@ function(x, name) if(!length(x)) return(NULL) ## - ## Extract internal list elements, return list if length > 1, vector - ## otherwise (to mirror the behaviour of the input format for - ## bibentry()) + ## Return list if length > 1, vector otherwise (to mirror the + ## behavior of the input format for bibentry()). ## is_attribute <- name %in% bibentry_attribute_names rval <- if(is_attribute) lapply(unclass(x), attr, name) @@ -1677,6 +1674,40 @@ function(x) paste(display, address) } +.authors_at_R_field_from_author_and_maintainer <- +function(a, m) +{ + p <- as.person(a) + r <- p[, "role"] + e <- p[, "email"] + ## If there are no aut roles yet, give everyone an aut role. + i <- (lengths(lapply(r, intersect, "aut")) > 0L) + if(!any(i)) + p[, "role"] <- r <- lapply(r, union, "aut") + ## Do we already have a cre role with email? + i <- (lengths(lapply(r, intersect, "cre")) > 0L) + j <- (lengths(e) > 0L) + if(any(i & j)) + return(structure(p, case = 1)) + ## No such luck. + ## Can we match the maintainer name? + s <- format(p, include = c("given", "family")) + k <- which(nzchar(s) & startsWith(tolower(m), tolower(s))) + ## If so, add cre role and email as necessary. + if(length(k)) { + k <- k[1L] + if(!i[k]) + p[[k, "role"]] <- c(r[[k]], "cre") + if(!j[k]) + p[[k, "email"]] <- tolower(sub(".*<(.*)>.*", "\\1", m)) + return(structure(p, case = 2)) + } + ## Otherwise need to add the maintainer. + m <- as.person(m) + m$role <- "cre" + structure(c(p, m), case = 3) +} + ## Cite using the default style (which is usually citeNatbib) cite <- From 3f2b3185db8d35cea57d3e3a4d91469bf56842dc Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 28 Jul 2024 05:11:50 +0000 Subject: [PATCH 396/546] Have CRAN submission checks note missing Authors@R and suggest auto-generated one. git-svn-id: https://svn.r-project.org/R/trunk@86929 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index 03e47b8b495..bdce1550a3e 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -7837,6 +7837,21 @@ function(dir, localOnly = FALSE, pkgSize = NA) out$authors_at_R_message <- msg } } + if(is.na(meta["Authors@R"])) { + aar <- + utils:::.authors_at_R_field_from_author_and_maintainer(meta["Author"], + maintainer) + aar <- format(aar, style = "R") + out$authors_at_R_missing <- + paste(c("No Authors@R field in DESCRIPTION.", + "Please add one, modifying", + paste(c(" Authors@R:", + rep.int(strrep(" ", 12L), + length(aar) - 1L)), + aar), + "as necessary."), + collapse = "\n") + } ## Check Author field. auth <- trimws(as.vector(meta["Author"])) @@ -8729,6 +8744,7 @@ function(x, ...) paste0(" ", y)), collapse = "\n") }, + if(length(y <- x$authors_at_R_missing)) y, if(length(y <- x$author_starts_with_Author)) { "Author field starts with 'Author:'." }, From 29fca6183e9b5b4cc58c7adf68e1a4016d67437a Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 28 Jul 2024 09:22:32 +0000 Subject: [PATCH 397/546] Experiment with format bibentry objects as Markdown. git-svn-id: https://svn.r-project.org/R/trunk@86930 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index dfcd60cc49f..e5e707935a0 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -749,7 +749,8 @@ function(x, i, drop = TRUE) } bibentry_format_styles <- - c("text", "Bibtex", "citation", "html", "latex", "textVersion", "R") + c("text", "Bibtex", "citation", "html", "latex", "textVersion", "R", + "md") .bibentry_match_format_style <- function(style) @@ -793,6 +794,15 @@ function(x, style = "text", .bibstyle = NULL, else if(is.character(macros)) macros <- tools::loadRdMacros(macros, tools:::initialRdMacros()) + if(style == "md") { + tmp <- tempfile() + on.exit(unlink(tmp), add = TRUE) + txt <- c("\\renewcommand{\\bold}{\\out{**#1**}}", + "\\renewcommand{\\href}{\\out{[#2](#1)}}", + "\\renewcommand{\\doi}{\\out{[doi:#1](https://doi.org/#1)}}") + writeLines(txt, tmp) + macros <- tools::loadRdMacros(tmp, macros) + } vapply(.bibentry_expand_crossrefs(x), function(y) { txt <- tools::toRd(y, style = .bibstyle) @@ -875,7 +885,8 @@ function(x, style = "text", .bibstyle = NULL, unlist(out) }, "citation" = format_as_citation(.bibentry(x), msg = citMsg), - "R" = .format_bibentry_as_R_code(x, ...) + "R" = .format_bibentry_as_R_code(x, ...), + "md" = format_via_Rd(tools::Rd2txt) ) as.character(out) } From 40934d3c35893cd1e920f9083f8ec8109e11494a Mon Sep 17 00:00:00 2001 From: maechler Date: Sun, 28 Jul 2024 19:44:50 +0000 Subject: [PATCH 398/546] fix PR#18727 with thanks to Mikael Jagan git-svn-id: https://svn.r-project.org/R/trunk@86931 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/drop.Rd | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/library/base/man/drop.Rd b/src/library/base/man/drop.Rd index 86a7d399b5b..5e97d2b85f6 100644 --- a/src/library/base/man/drop.Rd +++ b/src/library/base/man/drop.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/drop.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2021 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{drop} @@ -21,8 +21,10 @@ drop(x) \code{x}, but with any extents of length one removed. Any accompanying \code{dimnames} attribute is adjusted and returned with \code{x}: if the result is a vector the \code{names} are taken from - the \code{dimnames} (if any). If the result is a length-one vector, - the names are taken from the first dimension with a \I{dimname}. + the \code{dimnames} (if any). However, if the result is a vector + of length one, then it does not get \code{names} \emph{unless} exactly + one component of the \code{dimnames} is non-\code{NULL}, in which case + that component is used. Array subsetting (\code{\link{[}}) performs this reduction unless used with \code{drop = FALSE}, but sometimes it is useful to invoke @@ -34,6 +36,13 @@ drop(x) } \examples{ dim(drop(array(1:12, dim = c(1,3,1,1,2,1,2)))) # = 3 2 2 -drop(1:3 \%*\% 2:4) # scalar product +drop(1:3 \%*\% 2:4) # scalar product - w/o drop(.), would return 1x1 matrix + +# Behavior when result is length-1 vector: +(x <- x1 <- x2 <- array(0, c(1L, 1L), list("a", "b"))) +colnames(x1) <- rownames(x2) <- NULL +names(drop(x )) # NULL +names(drop(x1)) # "a" +names(drop(x2)) # "b" } \keyword{array} From d403603c5a63bf1ad1ab077a00c8d3504d993cbe Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 29 Jul 2024 05:58:29 +0000 Subject: [PATCH 399/546] Allow subscripting person objects by name. git-svn-id: https://svn.r-project.org/R/trunk@86932 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index e5e707935a0..4b7ec47d0c9 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -209,7 +209,10 @@ function(x, i, j) `[[.person` <- function(x, i, j) { - i <- seq_along(x)[[i]] + s <- seq_along(x) + if(is.character(i)) + names(s) <- names(x) + i <- s[[i]] y <- unclass(x)[[i]] if(missing(j)) { y <- list(y) @@ -229,7 +232,10 @@ function(x, i, j, value) y[i] <- as.person(value) else { j <- match.arg(j, person_field_names) - p <- seq_along(x)[i] + s <- seq_along(x) + if(!missing(i) && is.character(i)) + names(s) <- names(x) + p <- s[i] value <- rep_len(value, length(p)) if(j == "role") value <- lapply(value, .canonicalize_person_role) @@ -245,7 +251,10 @@ function(x, i, j, value) `[[<-.person` <- function(x, i, j, value) { - i <- seq_along(x)[[i]] + s <- seq_along(x) + if(is.character(i)) + names(s) <- names(x) + i <- s[[i]] y <- unclass(x) if(missing(j)) y[i] <- as.person(value) From 10fd4bd431f4d9ebf85dc94dacd7bc305d36d3fe Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 29 Jul 2024 13:45:04 +0000 Subject: [PATCH 400/546] implement visibility control on macOS git-svn-id: https://svn.r-project.org/R/trunk@86933 00db46b3-68df-0310-9c12-caf00c1e9a41 --- configure | 26 +++++++++++++++++--------- doc/NEWS.Rd | 3 ++- doc/manual/R-exts.texi | 33 ++++++++++++++++----------------- m4/R.m4 | 23 ++++++++++++++++------- 4 files changed, 51 insertions(+), 34 deletions(-) diff --git a/configure b/configure index dd6287fab3c..dc024694cbd 100755 --- a/configure +++ b/configure @@ -9054,24 +9054,32 @@ if test ${r_cv_visibility_attribute+y} then : printf %s "(cached) " >&6 else case e in #( - e) cat > conftest.c < conftest.c <&5 (eval $ac_try) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then - if grep '\.hidden.*foo' conftest.s >/dev/null; then - r_cv_visibility_attribute=yes - fi -fi + if grep '\.hidden.*foo' conftest.s >/dev/null; then + r_cv_visibility_attribute=yes + fi + fi + ;; +esac rm -f conftest.cs ;; esac @@ -27452,7 +27460,7 @@ _ACEOF # flags. r_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $r_verb" -(eval echo $as_me:27455: \"$ac_link\") >&5 +(eval echo $as_me:27463: \"$ac_link\") >&5 r_c_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$r_c_v_output" >&5 CFLAGS=$r_save_CFLAGS @@ -27530,7 +27538,7 @@ _ACEOF # flags. r_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $r_cv_prog_c_v" -(eval echo $as_me:27533: \"$ac_link\") >&5 +(eval echo $as_me:27541: \"$ac_link\") >&5 r_c_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$r_c_v_output" >&5 CFLAGS=$r_save_CFLAGS diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 76a78318746..27e38603151 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -80,7 +80,8 @@ \subsection{INSTALLATION}{ \itemize{ - \item . + \item Control of symbol visibility is now suported on macOS (the + previous check only worked on ELF platforms). } } diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index b2c1e31523c..e8b83d95cdf 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -16845,18 +16845,17 @@ code. @section Controlling visibility @cindex Visibility -Header @file{R_ext/Visibility.h} has some definitions for controlling the -visibility of entry points. These are only effective when +Header @file{R_ext/Visibility.h} has some definitions for controlling +the visibility of entry points. These are only effective when @samp{HAVE_VISIBILITY_ATTRIBUTE} is defined -- this is checked when @R{} is configured and recorded in header @file{Rconfig.h} (included by @file{R_ext/Visibility.h}). It is often defined on modern Unix-alikes -with a recent compiler@footnote{It is defined by the Intel compilers, -but also hides unsatisfied references and so cannot be used with @R{}. -It was not supported by the @abbr{AIX} nor Solaris compilers.}, but not -supported on macOS nor Windows. Minimizing the visibility of symbols in -a shared library will both speed up its loading (unlikely to be -significant) and reduce the possibility of linking to other entry points -of the same name. +with a recent compiler@footnote{Not pre-2023 Intel nor @abbr{AIX} nor +Solaris compilers.} but not supported on Windows. +@c Support for macOS was added for R 4.5.0. +Minimizing the visibility of symbols in a shared library will both speed +up its loading (unlikely to be significant) and reduce the possibility +of linking to other entry points of the same name. C/C++ entry points prefixed by @code{attribute_hidden} will not be visible in the shared object. There is no comparable mechanism for @@ -16865,14 +16864,14 @@ for example package @pkg{stats}. Most compilers which allow control of visibility will allow control of visibility for all symbols @emph{via} a flag, and where known the flag is encapsulated in the macros @samp{C_VISIBILITY}, @samp{CXX_VISIBILITY}@footnote{This applies to the -compiler for the default C++ dialect (currently C++11) and not -necessarily to other dialects.} and @samp{F_VISIBILITY} for C, C++ and -Fortran compilers.@footnote{In some cases Fortran compilers accept the -flag but do not actually hide their symbols: at the time of writing that -was true of @command{gfortran}, @command{flang-new} and Intel's -@command{ifx}.} These are defined in @file{etc/Makeconf} and so -available for normal compilation of package code. For example, -@file{src/Makevars} could include some of +compiler for the default C++ dialect and not necessarily to other +dialects.} and @samp{F_VISIBILITY} for C, C++ and Fortran +compilers.@footnote{In many cases Fortran compilers accept the flag but +do not actually hide their symbols: at the time of writing that was true +of @command{gfortran}, @command{flang-new} and Intel's @command{ifx}.} +These are defined in @file{etc/Makeconf} and so available for normal +compilation of package code. For example, @file{src/Makevars} could +include some of @example PKG_CFLAGS=$(C_VISIBILITY) diff --git a/m4/R.m4 b/m4/R.m4 index f5ba5ee6891..68874db14a9 100644 --- a/m4/R.m4 +++ b/m4/R.m4 @@ -4108,19 +4108,28 @@ done AC_DEFUN([R_GCC4_VISIBILITY], [AC_CACHE_CHECK([whether __attribute__((visibility())) is supported], [r_cv_visibility_attribute], -[cat > conftest.c < conftest.c <&AS_MESSAGE_LOG_FD); then - if grep '\.hidden.*foo' conftest.s >/dev/null; then - r_cv_visibility_attribute=yes - fi -fi + if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then + if grep '\.hidden.*foo' conftest.s >/dev/null; then + r_cv_visibility_attribute=yes + fi + fi + ;; +esac rm -f conftest.[cs] ]) if test $r_cv_visibility_attribute = yes; then From 83873fe7c1e3e23ef1ff4a986954bf1c8f01ce1d Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 29 Jul 2024 18:46:03 +0000 Subject: [PATCH 401/546] Experiment with formatting person objects as Markdown. git-svn-id: https://svn.r-project.org/R/trunk@86934 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 25 +++++++++++-------------- src/library/utils/man/person.Rd | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 4b7ec47d0c9..0f6a1be209e 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -470,7 +470,7 @@ function(x, list(given = " ", family = " ", email = ", ", role = ", ", comment = ", "), ..., - style = c("text", "R") + style = c("text", "R", "md") ) { if(!length(x)) return(character()) @@ -508,7 +508,7 @@ function(x, x <- lapply(x, function(e) { e$comment <- - .expand_ORCID_identifier(e$comment) + .expand_ORCID_identifier(e$comment, style) e }) @@ -557,21 +557,18 @@ function(object, escape = FALSE, ...) paste(object[nzchar(object)], collapse = " and ") } -.canonicalize_ORCID_identifier <- -function(x) -{ - paste0("https://orcid.org/", - sub(tools:::.ORCID_iD_variants_regexp, "\\3", x)) -} - .expand_ORCID_identifier <- -function(x) +function(x, style = "text") { if(any(ind <- ((names(x) == "ORCID") & - grepl(tools:::.ORCID_iD_variants_regexp, x)))) - x[ind] <- paste0("<", - .canonicalize_ORCID_identifier(x[ind]), - ">") + grepl(tools:::.ORCID_iD_variants_regexp, x)))) { + oid <- tools:::.ORCID_iD_canonicalize(x[ind]) + x[ind] <- if(style == "md") + sprintf("[ORCID %s](https://orcid.org/%s)", + oid, oid) + else + sprintf("", oid) + } x } diff --git a/src/library/utils/man/person.Rd b/src/library/utils/man/person.Rd index 8917d00e90d..0b7e3f7d7a0 100644 --- a/src/library/utils/man/person.Rd +++ b/src/library/utils/man/person.Rd @@ -34,7 +34,7 @@ as.person(x) collapse = list(given = " ", family = " ", email = ", ", role = ", ", comment = ", "), ..., - style = c("text", "R") + style = c("text", "R", "md") ) \method{toBibtex}{person}(object, escape = FALSE, ...) From 7518797738bc98b357dd2975571391dbd912e23f Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 30 Jul 2024 12:11:30 +0000 Subject: [PATCH 402/546] Run more checks on vignette meta-information (amends c64014). git-svn-id: https://svn.r-project.org/R/trunk@86935 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 85e26f37165..f07b9c09ab4 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -1235,16 +1235,36 @@ add_dummies <- function(dir, Log) strwrap(sQuote(db$file[!keep]), indent = 2L, exdent = 2L)) printLog0(Log, paste(msg, collapse = "\n"), "\n") } - pdfs <- file.path("inst", "doc", db[keep, ]$PDF) - missing <- !file.exists(pdfs) - if(any(missing)) { + elts <- file.path("inst", "doc", db[keep, ]$PDF) + miss <- !file.exists(elts) + if(any(miss)) { if(!any) warningLog(Log) any <- TRUE msg <- c("Output(s) listed in 'build/vignette.rds' but not in package:", - strwrap(sQuote(pdfs[missing]), indent = 2L, exdent = 2L)) + strwrap(sQuote(elts[miss]), indent = 2L, exdent = 2L)) printLog0(Log, paste(msg, collapse = "\n"), "\n") } - if (!any) resultLog(Log, "OK") + elts <- db[keep, ]$File + miss <- (nzchar(elts) & + !file.exists(file.path("inst", "doc", elts))) + if(any(miss)) { + if(!any) warningLog(Log) + any <- TRUE + msg <- c("Source(s) listed in 'build/vignette.rds' but not in package:", + strwrap(sQuote(elts[miss]), indent = 2L, exdent = 2L)) + printLog0(Log, paste(msg, collapse = "\n"), "\n") + } + elts <- db[keep, ]$R + miss <- (nzchar(elts) & + !file.exists(file.path("inst", "doc", elts))) + if(any(miss)) { + if(!any) warningLog(Log) + any <- TRUE + msg <- c("R code(s) listed in 'build/vignette.rds' but not in package:", + strwrap(sQuote(elts[miss]), indent = 2L, exdent = 2L)) + printLog0(Log, paste(msg, collapse = "\n"), "\n") + } + if(!any) resultLog(Log, "OK") } check_top_level <- function() From 0b7b7f29052cfbfeeb218ff634dbfb313459f3f6 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 30 Jul 2024 13:16:24 +0000 Subject: [PATCH 403/546] Spelling. git-svn-id: https://svn.r-project.org/R/trunk@86936 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 27e38603151..049e7d9917d 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -80,7 +80,7 @@ \subsection{INSTALLATION}{ \itemize{ - \item Control of symbol visibility is now suported on macOS (the + \item Control of symbol visibility is now supported on macOS (the previous check only worked on ELF platforms). } } From 6bc521c537b0841329bc26928640bb5db3902332 Mon Sep 17 00:00:00 2001 From: murrell Date: Tue, 30 Jul 2024 19:41:34 +0000 Subject: [PATCH 404/546] add 'rot' arg to glyphInfo() - thanks to Daniel Sabanes Bove git-svn-id: https://svn.r-project.org/R/trunk@86937 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 3 +++ src/include/R_ext/GraphicsEngine.h | 2 ++ src/library/grDevices/R/glyph.R | 11 ++++++--- src/library/grDevices/man/glyphInfo.Rd | 17 +++++++------- src/library/grid/R/typeset.R | 7 ++++-- src/library/grid/src/typeset.c | 6 ++++- src/library/grid/tests/glyphs.R | 32 +++++++++++++++++++++++++- src/main/engine.c | 7 ++++++ 8 files changed, 70 insertions(+), 15 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 049e7d9917d..d8a0827ae46 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -46,6 +46,9 @@ corresponding metadata field, and logical arguments \code{timestamp} and \code{producer} to optionally omit the respective metadata. (Thanks to \I{Edzer Pebesma}.) + + \item \code{grDevices::glyphInfo()} gains \code{rot} argument + to allow per-glyph rotation. (Thanks to \I{Daniel Sabanes Bove}.) } } diff --git a/src/include/R_ext/GraphicsEngine.h b/src/include/R_ext/GraphicsEngine.h index 83a735c0350..1934c1819d8 100644 --- a/src/include/R_ext/GraphicsEngine.h +++ b/src/include/R_ext/GraphicsEngine.h @@ -670,6 +670,8 @@ SEXP R_GE_glyphY(SEXP glyphs); SEXP R_GE_glyphFont(SEXP glyphs); SEXP R_GE_glyphSize(SEXP glyphs); SEXP R_GE_glyphColour(SEXP glyphs); +SEXP R_GE_glyphRotation(SEXP glyphs); +Rboolean R_GE_hasGlyphRotation(SEXP glyphs); const char* R_GE_glyphFontFile(SEXP glyphFont); int R_GE_glyphFontIndex(SEXP glyphFont); diff --git a/src/library/grDevices/R/glyph.R b/src/library/grDevices/R/glyph.R index 45e9cf33128..4be8dabbba8 100644 --- a/src/library/grDevices/R/glyph.R +++ b/src/library/grDevices/R/glyph.R @@ -180,7 +180,7 @@ glyphInfo <- function(id, x, y, font, size, fontList, width, height, hAnchor, vAnchor, - col=NA) { + col=NA, rot=0) { id <- as.integer(id) x <- as.numeric(x) y <- as.numeric(y) @@ -191,6 +191,7 @@ glyphInfo <- function(id, x, y, font, size, if (any(is.na(font)) || !all(font %in% seq_along(fontList))) stop("Unknown font") size <- as.numeric(size) + rot <- as.numeric(rot) ## Check colour (allow any R colour spec) nacol <- is.na(col) if (any(!nacol)) { @@ -239,8 +240,8 @@ glyphInfo <- function(id, x, y, font, size, ## Build glyph info dropNA <- !(is.na(id) | is.na(x) | is.na(y) | ## is.na(font) already checked - is.na(size)) - glyphs <- data.frame(id, x, y, font, size)[dropNA, ] + is.na(size) | is.na(rot)) + glyphs <- data.frame(id, x, y, font, size, rot)[dropNA, ] if (nrow(glyphs) < 1) stop("Invalid glyph info") ## Colour can be NA @@ -249,6 +250,10 @@ glyphInfo <- function(id, x, y, font, size, } else { glyphs$colour <- col } + ## Reorder to ensure backwards compatibility with code + ## where rot was not yet included. + col_order <- c("id", "x", "y", "font", "size", "colour", "rot") + glyphs <- glyphs[, col_order, drop = FALSE] ## Construct final structure info <- list(glyphs=glyphs, fonts=fontList, width=width, height=height, diff --git a/src/library/grDevices/man/glyphInfo.Rd b/src/library/grDevices/man/glyphInfo.Rd index 9121d24c5ae..9c57a6db616 100644 --- a/src/library/grDevices/man/glyphInfo.Rd +++ b/src/library/grDevices/man/glyphInfo.Rd @@ -20,14 +20,14 @@ \title{Describe a Set of Typeset Glyphs} \description{ Create an object that contains information about typeset glyphs. - This includes glyph identifiers, glyph locations, font and colour - information, and metric information. + This includes glyph identifiers, glyph locations, font, colour + and rotation information, and metric information. } \usage{ glyphInfo(id, x, y, font, size, fontList, width, height, hAnchor, vAnchor, - col=NA) + col=NA, rot=0) glyphFont(file, index, family, weight, style, PSname=NA) glyphFontList(...) @@ -62,6 +62,7 @@ glyphJust(just, ...) (against which to \code{"bottom"} justify), but can also be result from a call to \code{glyphAnchor()}.} \item{col}{An R colour value for each glyph. Can be \code{NA}.} + \item{rot}{The angle to rotate each glyph.} \item{file}{Character path to font file.} \item{index}{Numeric index of font within font file.} \item{family}{Character name of font family.} @@ -80,9 +81,9 @@ glyphJust(just, ...) \value{ The result from \code{glyphInfo()} is an \code{"RGlyphInfo"} object, essentially a data frame with each row - containing id, location, font, and colour for a glyph. - The metric information (widths and anchors) are stored as attributes - of the data frame. + containing id, location, font, colour and rotation for a glyph. + The metric information (widths and anchors) are stored + as attributes of the data frame. \code{glyphAnchor()}, \code{glyphWidth()}, and \code{glyphHeight()} return values that can be used to specify \code{width}, \code{height}, @@ -131,6 +132,6 @@ glyphJust(just, ...) width and height metrics. } \section{Warning}{ - Any glyph with \code{NA} in any of \code{id}, \code{x}, \code{y}, or - \code{size} is silently dropped. + Any glyph with \code{NA} in any of \code{id}, \code{x}, \code{y}, + \code{size} or \code{rot} is silently dropped. } diff --git a/src/library/grid/R/typeset.R b/src/library/grid/R/typeset.R index e22eca058de..6aca9a52826 100644 --- a/src/library/grid/R/typeset.R +++ b/src/library/grid/R/typeset.R @@ -106,9 +106,12 @@ glyphVJust <- function(y, glyphInfo, vjust) { drawDetails.glyphgrob <- function(x, recording=TRUE) { ## Calculate runs of glyphs + glyph_run_cols <- intersect( + c("font", "size", "rot", "colour"), + names(x$glyphInfo$glyphs) + ) fontstring <- unlist(do.call(paste, - c(x$glyphInfo$glyphs[c("font", "size", - "colour")], + c(x$glyphInfo$glyphs[glyph_run_cols], list(sep=":")))) runs <- rle(fontstring) ## Calculate final glyph positions diff --git a/src/library/grid/src/typeset.c b/src/library/grid/src/typeset.c index f61531c9dea..ff7f96f7479 100644 --- a/src/library/grid/src/typeset.c +++ b/src/library/grid/src/typeset.c @@ -81,6 +81,10 @@ static void renderGlyphs(SEXP runs, SEXP glyphInfo, SEXP x, SEXP y, SEXP font = VECTOR_ELT(fonts, INTEGER(R_GE_glyphFont(glyphs))[offset] - 1); double size = REAL(R_GE_glyphSize(glyphs))[offset]; + double glyphRotation = R_GE_hasGlyphRotation(glyphs) ? + REAL(R_GE_glyphRotation(glyphs))[offset] : + 0.0; + double finalRotation = rotationAngle + glyphRotation; char colstr[51]; strncpy(colstr, CHAR(STRING_ELT(R_GE_glyphColour(glyphs), offset)), 50); @@ -90,7 +94,7 @@ static void renderGlyphs(SEXP runs, SEXP glyphInfo, SEXP x, SEXP y, gx + offset, gy + offset, font, - size, colour, rotationAngle, + size, colour, finalRotation, dd); offset = offset + runLength; } diff --git a/src/library/grid/tests/glyphs.R b/src/library/grid/tests/glyphs.R index b8acf9df93f..88955d63609 100644 --- a/src/library/grid/tests/glyphs.R +++ b/src/library/grid/tests/glyphs.R @@ -199,7 +199,9 @@ testGlyph(Montserrat, hjust=glyphJust(0, "tight"), vjust="baseline") HersheyLabel("tight left (baseline) justification\n(tiny bit further left)", y=.2) -## rotated glyphs +## rotated glyphs: + +### viewport rotation grid.newpage() pushViewport(viewport(angle=30)) grid.segments(0,.5,1,.5, gp=gpar(col="grey")) @@ -216,6 +218,34 @@ testGlyph(Montserrat, hjust="left", vjust="baseline") popViewport() HersheyLabel("rotated (left baseline justified) glyphs", y=.2) +### glyph rotation +rotationInfo <- MontserratInfo +rotationInfo$rot <- rep(180, 6) +rotation <- do.call(glyphInfo, rotationInfo) +grid.newpage() +grid.segments(0,.5,1,.5, gp=gpar(col="grey")) +testGlyph(rotation) +HersheyLabel("glyphs with rotation (180 degrees)", y=.2) + +# Different rotation for each glyph works as well: +sepRotInfo <- MontserratInfo +sepRotInfo$id <- rep(499, 6) +sepRotInfo$rot <- seq(from = 0, to = 90, length = 6) +sepRot <- do.call(glyphInfo, sepRotInfo) +grid.newpage() +grid.segments(0,.5,1,.5, gp=gpar(col="grey")) +testGlyph(sepRot) +HersheyLabel("glyphs with different rotations", y=.2) + +# Rotation of glyphs inside a rotated viewport works: +grid.newpage() +pushViewport(viewport(angle=30)) +grid.segments(0,.5,1,.5, gp=gpar(col="grey")) +grid.segments(.5,0, .5,1, gp=gpar(col="grey")) +testGlyph(sepRot) +popViewport() +HersheyLabel("rotated glyphs inside rotated viewport", y=.2) + ## glyph x/y/width/height grid.newpage() grid.segments(0,.5,1,.5, gp=gpar(col="grey")) diff --git a/src/main/engine.c b/src/main/engine.c index 53c06c05c9e..7d69c4c79b3 100644 --- a/src/main/engine.c +++ b/src/main/engine.c @@ -3845,6 +3845,7 @@ SEXP R_GE_glyphInfoFonts(SEXP glyphInfo) { #define glyph_font 3 #define glyph_size 4 #define glyph_colour 5 +#define glyph_rotation 6 SEXP R_GE_glyphID(SEXP glyphs) { return VECTOR_ELT(glyphs, glyph_id); @@ -3864,6 +3865,12 @@ SEXP R_GE_glyphSize(SEXP glyphs) { SEXP R_GE_glyphColour(SEXP glyphs) { return VECTOR_ELT(glyphs, glyph_colour); } +SEXP R_GE_glyphRotation(SEXP glyphs) { + return VECTOR_ELT(glyphs, glyph_rotation); +} +Rboolean R_GE_hasGlyphRotation(SEXP glyphs) { + return LENGTH(glyphs) > glyph_rotation; +} #define glyph_font_file 0 #define glyph_font_index 1 From de313ef0e333de1610b025a10d7561119289fa26 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 30 Jul 2024 20:44:35 +0000 Subject: [PATCH 405/546] Add 2-index subscripting for [ and [[ methods for bibentry objects. git-svn-id: https://svn.r-project.org/R/trunk@86938 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 71 ++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 0f6a1be209e..25dea341ba6 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -727,30 +727,69 @@ function(x) unlist(keys) } -`[[.bibentry` <- `[.bibentry` <- -function(x, i, drop = TRUE) +function(x, i, j, drop = TRUE) { if(!length(x)) return(x) - cl <- class(x) - class(x) <- NULL - ## For character subscripting, use keys if there are no names. - ## Note that creating bibentries does not add the keys as names: - ## assuming that both can independently be set, we would need to - ## track whether names were auto-generated or not. - ## (We could consider providing a names() getter which returns given - ## names or keys as used for character subscripting, though). - if(is.character(i) && is.null(names(x))) - names(x) <- .bibentry_get_key(x) - y <- x[i] + s <- seq_along(x) + if(!missing(i) && is.character(i)) { + ## For character subscript i, use keys if there are no names. + ## Note that creating bibentries does not add the keys as names: + ## assuming that both can independently be set, we would need to + ## track whether names were auto-generated or not. + ## (We could consider providing a names() getter which returns + ## given names or keys as used for character subscripting, + ## though). + names(s) <- names(x) + if(is.null(names(s))) + names(s) <- .bibentry_get_key(x) + } + i <- s[i] + y <- unclass(x)[i] if(!all(ok <- lengths(y) > 0L)) { warning("subscript out of bounds") y <- y[ok] } - if(!drop) - attributes(y) <- attributes(x)[bibentry_list_attribute_names] - class(y) <- cl + if(missing(j)) { + if(!drop) + attributes(y) <- + attributes(x)[bibentry_list_attribute_names] + class(y) <- class(x) + } else { + stopifnot(is.character(j), + length(j) == 1L) + y <- if(j %in% bibentry_attribute_names) + lapply(y, attr, j) + else + lapply(y, `[[`, tolower(j)) + } + y +} + +`[[.bibentry` <- +function(x, i, j) +{ + s <- seq_along(x) + if(is.character(i)) { + ## See comments in [ method. + names(s) <- names(x) + if(is.null(names(s))) + names(s) <- .bibentry_get_key(x) + } + i <- s[[i]] + y <- unclass(x)[[i]] + if(missing(j)) { + y <- list(y) + class(y) <- class(x) + } else { + stopifnot(is.character(j), + length(j) == 1L) + y <- if(j %in% bibentry_attribute_names) + attr(y, j) + else + y[[tolower(j)]] + } y } From 70cfbe0bdf9ae39b719510f4b9ed6faab62b1640 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 30 Jul 2024 20:45:29 +0000 Subject: [PATCH 406/546] Allow directly specifying the names of revdeps to be checked. git-svn-id: https://svn.r-project.org/R/trunk@86939 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/checktools.R | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/library/tools/R/checktools.R b/src/library/tools/R/checktools.R index 5e41705224f..b9cf53a78ac 100644 --- a/src/library/tools/R/checktools.R +++ b/src/library/tools/R/checktools.R @@ -145,20 +145,24 @@ function(dir, ## Determine and download reverse dependencies to be checked as ## well. - reverse <- as.list(reverse) - ## Merge with defaults, using partial name matching. defaults <- list(which = c("Depends", "Imports", "LinkingTo"), recursive = FALSE, repos = getOption("repos")) - pos <- pmatch(names(reverse), names(defaults), nomatch = 0L) - defaults[pos] <- reverse[pos > 0L] + if(!is.character(reverse)) { + reverse <- as.list(reverse) + ## Merge with defaults, using partial name matching. + pos <- pmatch(names(reverse), names(defaults), nomatch = 0L) + defaults[pos] <- reverse[pos > 0L] + } subset_reverse_repos <- !identical(defaults$repos, getOption("repos")) if(subset_reverse_repos && !all(defaults$repos %in% getOption("repos"))) stop("'reverse$repos' should be a subset of getOption(\"repos\")") - rnames <- if(is.list(defaults$which)) { + rnames <- if(is.character(reverse)) { + reverse + } else if(is.list(defaults$which)) { ## No recycling of repos for now. defaults$recursive <- rep_len(as.list(defaults$recursive), length(defaults$which)) From e560ef08f06f451c722211df621fe61a3fe2f28f Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 31 Jul 2024 07:02:07 +0000 Subject: [PATCH 407/546] Export more CRAN tools. git-svn-id: https://svn.r-project.org/R/trunk@86940 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/NAMESPACE | 7 +++-- src/library/tools/R/CRANtools.R | 4 --- src/library/tools/man/CRANtools.Rd | 49 ++++++++++++++++++++++++++---- tests/Examples/tools-Ex.Rout.save | 13 ++++---- 4 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/library/tools/NAMESPACE b/src/library/tools/NAMESPACE index 2e3d71666eb..8bdd414fc0f 100644 --- a/src/library/tools/NAMESPACE +++ b/src/library/tools/NAMESPACE @@ -51,8 +51,11 @@ export("CRAN_package_db", "CRAN_check_results", "CRAN_check_details", "CRAN_check_issues", -## "CRAN_memtest_notes", - "summarize_CRAN_check_status") + "summarize_CRAN_check_status", + "CRAN_aliases_db", + "CRAN_archive_db", + "CRAN_current_db", + "CRAN_rdxrefs_db") export("R_user_dir") diff --git a/src/library/tools/R/CRANtools.R b/src/library/tools/R/CRANtools.R index 929156442bb..17a80869660 100644 --- a/src/library/tools/R/CRANtools.R +++ b/src/library/tools/R/CRANtools.R @@ -16,7 +16,6 @@ # A copy of the GNU General Public License is available at # https://www.R-project.org/Licenses/ -## exported summarize_CRAN_check_status <- function(packages, results = NULL, details = NULL, issues = NULL) { @@ -211,7 +210,6 @@ function(cran, path) readRDS(con) } -## exported CRAN_check_results <- function(flavors = NULL) { @@ -222,7 +220,6 @@ function(flavors = NULL) db } -## exported CRAN_check_details <- function(flavors = NULL) { @@ -242,7 +239,6 @@ function(flavors = NULL) ## "web/checks/memtest_notes.rds") ## } -## exported CRAN_check_issues <- function() read_CRAN_object(CRAN_baseurl_for_web_area(), diff --git a/src/library/tools/man/CRANtools.Rd b/src/library/tools/man/CRANtools.Rd index c5566aac640..d4b2a96d0e6 100644 --- a/src/library/tools/man/CRANtools.Rd +++ b/src/library/tools/man/CRANtools.Rd @@ -13,9 +13,14 @@ \alias{summarize_CRAN_check_status} \alias{R_CRAN_WEB} \alias{R_CRAN_SRC} +\alias{CRAN_current_db} +\alias{CRAN_aliases_db} +\alias{CRAN_rdxrefs_db} +\alias{CRAN_archive_db} \description{ - Tools for obtaining information about current packages in the - \abbr{CRAN} package repository, and their check status. + Tools for obtaining information about current and archived packages in + the \abbr{CRAN} package repository, and the check status of the + current packages. } \usage{ CRAN_package_db() @@ -27,6 +32,11 @@ summarize_CRAN_check_status(packages, results = NULL, details = NULL, issues = NULL) + +CRAN_current_db() +CRAN_aliases_db() +CRAN_rdxrefs_db() +CRAN_archive_db() } \arguments{ \item{packages}{a character vector of package names.} @@ -65,6 +75,22 @@ summarize_CRAN_check_status(packages, character frame with variables \code{Package}, \code{Version}, \code{kind} (an identifier for the issue) and \code{href} (a URL with information on the issue). + + \code{CRAN_current_db()} returns a data fame with the + \code{\link{file.info}()} of all current package sources in the + \abbr{CRAN} package repository. + + \code{CRAN_aliases_db()} returns the Rd aliases in the current + packages, as a nested per-package named list of per-Rd-file named + lists with the aliases. + + \code{CRAN_rdxrefs_db()} returns the Rd cross-references in the + current packages, as a per-package list of matrices with columns + \code{"Target"}, \code{"Anchor"} and \code{"Source"}. + + \code{CRAN_archive_db()} returns the \code{\link{file.info}()} of all + archived packages sources in the \abbr{CRAN} package repository, as a + per-package named list of data frames. } \value{ @@ -74,7 +100,12 @@ summarize_CRAN_check_status(packages, } \section{Which CRAN?}{ - The main functions access a \abbr{CRAN} mirror specified by the + Functions + \code{CRAN_package_db()}, + \code{CRAN_check_results()}, + \code{CRAN_check_details()} and + \code{CRAN_check_issues()} + access a \abbr{CRAN} mirror specified by the environment variable \env{R_CRAN_WEB}, defaulting to one specified in the \code{"repos"} option. Otherwise the entry in the \file{repositories} file (see \code{\link{setRepositories}}) is used: @@ -89,9 +120,15 @@ summarize_CRAN_check_status(packages, mirror of just \file{src/contrib} for installing packages you will need to set \env{R_CRAN_WEB} to point to a full mirror. - Internal functions \code{CRAN_aliases_db}, \code{CRAN_archive_db}, - \code{CRAN_current_db} and \code{CRAN_rdxrefs_db} (used by \command{R - CMD check}) use \env{R_CRAN_SRC} rather than \env{R_CRAN_WEB}. + Functions + \code{CRAN_current_db}, + \code{CRAN_aliases_db}, + \code{CRAN_rdxrefs_db} and + \code{CRAN_archive_db} + (also used by \command{R CMD check}) + use \env{R_CRAN_SRC} rather than \env{R_CRAN_WEB}. + The mirror to be used is reported by + \code{utils::\link{findCRANmirror}("src")}. } %% Tested in tests/CRANtools.R diff --git a/tests/Examples/tools-Ex.Rout.save b/tests/Examples/tools-Ex.Rout.save index ba9a319efd1..30fb26415f8 100644 --- a/tests/Examples/tools-Ex.Rout.save +++ b/tests/Examples/tools-Ex.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-07-15 r86900) -- "Unsuffered Consequences" +R Under development (unstable) (2024-07-30 r86939) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -7,8 +7,6 @@ R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. - Natural language support but running in an English locale - R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. @@ -34,6 +32,7 @@ Type 'q()' to quit R. > ### Title: CRAN Package Repository Tools > ### Aliases: CRAN_package_db CRAN_check_results CRAN_check_details > ### CRAN_check_issues summarize_CRAN_check_status R_CRAN_WEB R_CRAN_SRC +> ### CRAN_current_db CRAN_aliases_db CRAN_rdxrefs_db CRAN_archive_db > > ### ** Examples > @@ -212,7 +211,7 @@ Error in assertWarning(ff()) : > bibstyle("unsorted", sortKeys = function(refs) seq_along(refs), + fmtPrefix = function(paper) paste0("[", paper$.index, "]"), + .init = TRUE) - + > print(refs, .bibstyle = "unsorted") [1] R Core Team (2013). _R: A Language and Environment for Statistical Computing_. R Foundation for Statistical Computing, Vienna, Austria. @@ -1077,11 +1076,11 @@ An illustration of lexical scoping. > ### ** Examples > ## IGNORE_RDIFF_BEGIN > R_user_dir("FOO", "cache") -[1] "/Users/ripley/Library/Caches/org.R-project.R/R/FOO" +[1] "/home/Hornik/.cache/R/FOO" > > ## Create one, platform agnostically, must work if : > (Rdb <- R_user_dir("base")) -[1] "/Users/ripley/Library/Application Support/org.R-project.R/R/base" +[1] "/home/Hornik/.local/share/R/base" > if(newD <- !dir.exists(Rdb)) # should work user specifically: + newD <- dir.create(Rdb, recursive=TRUE) > dir(Rdb) # typically empty @@ -1233,7 +1232,7 @@ needs Deep Thought > cleanEx() > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 0.172 0.014 0.189 0 0 +Time elapsed: 0.313 0.014 0.329 0 0 > grDevices::dev.off() null device 1 From 4f32fca811f2073e2acbc8b655e075bbf2af52f1 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 31 Jul 2024 08:34:23 +0000 Subject: [PATCH 408/546] NEWS for c86940. git-svn-id: https://svn.r-project.org/R/trunk@86941 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index d8a0827ae46..36d9cf67086 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -45,10 +45,16 @@ \item \code{pdf()} gains an \code{author} argument to set the corresponding metadata field, and logical arguments \code{timestamp} and \code{producer} to optionally omit the - respective metadata. (Thanks to \I{Edzer Pebesma}.) + respective metadata. + (Thanks to \I{Edzer Pebesma}.) \item \code{grDevices::glyphInfo()} gains \code{rot} argument - to allow per-glyph rotation. (Thanks to \I{Daniel Sabanes Bove}.) + to allow per-glyph rotation. + (Thanks to \I{Daniel Sabanes Bove}.) + + \item Package \pkg{tools} now exports functions + \code{CRAN_current_db()}, \code{CRAN_aliases_db()}, + \code{CRAN_rdxrefs_db()}, and \code{CRAN_archive_db()}. } } From e6352f4c98c577d21ae6d8d98114706c69caab28 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 31 Jul 2024 08:34:44 +0000 Subject: [PATCH 409/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86942 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index f07b9c09ab4..83055b9f1eb 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -2983,9 +2983,11 @@ add_dummies <- function(dir, Log) pat <- paste(vf, collapse="|") pat <- paste0("^(", pat, ")-[0-9]+[.]pdf") bad <- bad | grepl(pat, files) + bad <- bad & is.na(match(files, basename(vigns$docs))) } bad <- bad | grepl("^fig.*[.]pdf$", files) badf <- files[bad] + dirs <- basename(list.dirs(doc_dir, recursive = FALSE)) badd <- dirs[dirs %in% c("auto", "Bilder", "fig", "figs", "figures", "Figures", "img", "images", "JSSstyle", From 36bd6e1ac974387d9299828ccab211daf2737fb4 Mon Sep 17 00:00:00 2001 From: maechler Date: Wed, 31 Jul 2024 08:45:22 +0000 Subject: [PATCH 410/546] mtext(.., padj=*) docu & example thanks to Aidan Lakshman and S.U., PR#18770 git-svn-id: https://svn.r-project.org/R/trunk@86943 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/graphics/man/mtext.Rd | 11 ++++++++--- tests/Examples/graphics-Ex.Rout.save | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/library/graphics/man/mtext.Rd b/src/library/graphics/man/mtext.Rd index 737715f9107..3e6a9437bf6 100644 --- a/src/library/graphics/man/mtext.Rd +++ b/src/library/graphics/man/mtext.Rd @@ -1,6 +1,6 @@ % File src/library/graphics/man/mtext.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{mtext} @@ -35,8 +35,8 @@ mtext(text, side = 3, line = 0, outer = FALSE, at = NA, parallel to the axis the default is to centre the string.} \item{padj}{adjustment for each string perpendicular to the reading direction (which is controlled by \code{adj}). For strings parallel - to the axes, \code{padj = 0} means left or bottom alignment, - and \code{padj = 1} means right or top alignment (relative to the line). + to the axes, \code{padj = 0} means bottom alignment, + and \code{padj = 1} means top alignment (relative to the axis line). If \code{padj} is not a finite value (the default), the value of \code{par("las")} determines the adjustment. For strings plotted @@ -103,5 +103,10 @@ mtext("mtext(..., line= -2, adj = 0)", line = -2, adj = 0) ##--- log axis : plot(1:10, exp(1:10), log = "y", main = "log =\"y\"", xlab = "xlab") for(s in 1:4) mtext(paste("mtext(...,side=", s ,")"), side = s) + +##--- illustrating padj behavior : +plot(0, axes=FALSE, ann=FALSE, frame.plot=TRUE) +for(si in 1:4) mtext(c("padj=0", "-----------", "padj=1"), + side = si, padj = c(0, 0.5, 1)) } \keyword{aplot} diff --git a/tests/Examples/graphics-Ex.Rout.save b/tests/Examples/graphics-Ex.Rout.save index bd9acd71b58..229a43a48ec 100644 --- a/tests/Examples/graphics-Ex.Rout.save +++ b/tests/Examples/graphics-Ex.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-06-08 r86705) -- "Unsuffered Consequences" +R Under development (unstable) (2024-07-30 r86939) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: aarch64-apple-darwin22.6.0 @@ -1737,6 +1737,11 @@ List of 2 > plot(1:10, exp(1:10), log = "y", main = "log =\"y\"", xlab = "xlab") > for(s in 1:4) mtext(paste("mtext(...,side=", s ,")"), side = s) > +> ##--- illustrating padj behavior : +> plot(0, axes=FALSE, ann=FALSE, frame.plot=TRUE) +> for(si in 1:4) mtext(c("padj=0", "-----------", "padj=1"), ++ side = si, padj = c(0, 0.5, 1)) +> > > > cleanEx() From f8b7032584a611f6ef382336e143e68e4b3323b6 Mon Sep 17 00:00:00 2001 From: ripley Date: Wed, 31 Jul 2024 14:24:44 +0000 Subject: [PATCH 411/546] updates for Intel compilers git-svn-id: https://svn.r-project.org/R/trunk@86944 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 760ddd49e5b..f2ef85431db 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -4894,15 +4894,14 @@ identified by the C/C++ macro @code{__INTEL_LLVM_COMPILER} (and do not define @code{__INTEL_COMPILER}: they also define @code{__clang__} and @code{__clang_major__}). -The C++ compiler uses the system's @code{lidstdc++} as its runtime +The C++ compiler uses the system's @code{libstdc++} as its runtime library rather than @I{LLVM}'s @code{libc++}. Standalone installers (which are free-of-charge) are available from @uref{https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html}: they are also part of the @I{oneAPI} Base and HPC (for Fortran) toolkits. -We tried the compilers in @I{oneAPI} 2024.1.x@footnote{2024.1.2 for -C/C++, 2024.1.0 for Fortran.} and 2023.x.y using (the paths +We tried the compilers in @I{oneAPI} 2024.2.0 and 2023.x.y using (the paths do differ by compiler version) @example IP=/path/to/compilers/bin/ @@ -4954,7 +4953,7 @@ version of @command{clang}: the Intel manual suggests checking @abbr{LTO}: it is not clear if the Fortran one does. @c https://community.intel.com/t5/Intel-C-Compiler/Troubles-with-getrusage-when-using-icx/m-p/1509374#M41116 -For some recent versions (including 2023.2.0) all CPU times in e.g.@: +For some earlier versions (including 2023.2.0) all CPU times in e.g.@: @code{proc.time()} are reported as zero. If you see this, uncomment the @samp{INTEL_ICX_FIX} setting in @file{config.site} and re-build. From 91834b9406bb4b2ed9ccd7811bdbc741bc5fb945 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 05:09:07 +0000 Subject: [PATCH 412/546] Improve URLs. git-svn-id: https://svn.r-project.org/R/trunk@86946 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-data.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-data.texi b/doc/manual/R-data.texi index 313cb0cebb5..7bfff44fe65 100644 --- a/doc/manual/R-data.texi +++ b/doc/manual/R-data.texi @@ -1204,7 +1204,7 @@ Traditionally there had been large (and expensive) commercial @abbr{RDBMS}s (@uref{https://www.ibm.com/products/informix, Informix}; @uref{https://www.oracle.com, Oracle}; @I{Sybase}; -@uref{https://www.ibm.com/products/db2, IBM's DB2}; +@uref{https://www.ibm.com/db2, IBM's DB2}; @uref{https://www.microsoft.com/sql-server/, Microsoft @acronym{SQL} Server} on Windows) and academic and small-system databases (such as MySQL@footnote{and forks, notably MariaDB.}, PostgreSQL, Microsoft @@ -1761,7 +1761,7 @@ handle binary files. Packages @CRANpkg{h5}, @I{Bioconductor}'s @pkg{rhdf5}, @CRANpkg{RNetCDF} and @CRANpkg{ncdf4} on @acronym{CRAN} provide interfaces to @acronym{NASA}'s @abbr{HDF5} (Hierarchical Data Format, see -@uref{https://www.hdfgroup.org/HDF5/}) and to @I{UCAR}'s @I{netCDF} data files +@uref{https://www.hdfgroup.org/wp-content/uploads/2017/07/HDF5.pdf}) and to @I{UCAR}'s @I{netCDF} data files (network Common Data Form, see @uref{https://www.unidata.ucar.edu/software/netcdf/}). From 6568e992c2fd153e76e0e3fb03b4bac455c9e6a5 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 05:09:39 +0000 Subject: [PATCH 413/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86947 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 56 ++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 25dea341ba6..bc526ac5044 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -1146,11 +1146,12 @@ function(x, name) ## Return list if length > 1, vector otherwise (to mirror the ## behavior of the input format for bibentry()). ## - is_attribute <- name %in% bibentry_attribute_names - rval <- if(is_attribute) lapply(unclass(x), attr, name) - else lapply(unclass(x), `[[`, tolower(name)) - if(length(rval) == 1L) rval <- rval[[1L]] - rval + y <- if(name %in% bibentry_attribute_names) + lapply(unclass(x), attr, name) + else + lapply(unclass(x), `[[`, tolower(name)) + if(length(y) == 1L) y <- y[[1L]] + y } `$<-.bibentry` <- @@ -1165,31 +1166,25 @@ function(x, name, value) value <- rep_len(.listify(value), length(x)) ## check bibtype - if(name == "bibtype") { - stopifnot(all(lengths(value) == 1L)) - BibTeX_names <- names(tools:::BibTeX_entry_field_db) - value <- unlist(value) - pos <- match(tolower(value), tolower(BibTeX_names)) - if(anyNA(pos)) - stop(gettextf("%s has to be one of %s", - sQuote("bibtype"), - paste(BibTeX_names, collapse = ", ")), - domain = NA) - value <- as.list(BibTeX_names[pos]) - } + if(name == "bibtype") + value <- .bibentry_canonicalize_bibtype_value(value) ## replace all values for(i in seq_along(x)) { if(is_attribute) { attr(x[[i]], name) <- - if(is.null(value[[i]])) NULL else paste(value[[i]]) + if(is.null(value[[i]])) + NULL + else + paste(value[[i]]) } else { x[[i]][[name]] <- - if(is.null(value[[i]])) NULL else { - if(name %in% c("author", "editor")) - as.person(value[[i]]) - else paste(value[[i]]) - } + if(is.null(value[[i]])) + NULL + else if(name %in% c("author", "editor")) + as.person(value[[i]]) + else + paste(value[[i]]) } } @@ -1199,6 +1194,21 @@ function(x, name, value) .bibentry(x) } +.bibentry_canonicalize_bibtype_value <- +function(value) +{ + stopifnot(all(lengths(value) == 1L)) + BibTeX_names <- names(tools:::BibTeX_entry_field_db) + value <- unlist(value) + pos <- match(tolower(value), tolower(BibTeX_names)) + if(anyNA(pos)) + stop(gettextf("%s has to be one of %s", + sQuote("bibtype"), + paste(BibTeX_names, collapse = ", ")), + domain = NA) + as.list(BibTeX_names[pos]) +} + `$<-.citation` <- function(x, name, value) .citation(NextMethod("$<-"), attr(x, "package")) From 1191265c94a3f09632a1946a4bc4a2258bb1e7bf Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 05:10:16 +0000 Subject: [PATCH 414/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86948 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/utils.R | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index ad59eeab3ff..d797cc67d1a 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -2598,10 +2598,11 @@ function(fun, args = list(), opts = "--no-save --no-restore", if (inherits(val, "condition")) { ## maybe wrap in a classed error and include some of res msg <- paste0("error in inferior call:\n ", conditionMessage(val)) - stop(errorCondition(msg, + stop(do.call(errorCondition, + c(list(message = msg, class = "inferiorCallError", - res = res, - error = val)) + value = val), + res))) } else { val <- val[[1L]] @@ -2614,9 +2615,10 @@ function(fun, args = list(), opts = "--no-save --no-restore", else ## again maybe wrap in a classed error and include some of res ## might want to distinguish two errors by sub-classes - stop(errorCondition("inferior call failed", - class = "inferiorCallError", - res = res)) + stop(do.call(errorCondition, + c(list(message = "inferior call failed", + class = "inferiorCallError"), + res = res))) } ### ** Rcmd From 08a4fd57689a396ca848fd24774bbc9a61a07bcd Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 05:11:14 +0000 Subject: [PATCH 415/546] Have parse_URI_reference() return a character frame for convenience. git-svn-id: https://svn.r-project.org/R/trunk@86949 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/urltools.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/library/tools/R/urltools.R b/src/library/tools/R/urltools.R index 024524f34e2..9440a1d8169 100644 --- a/src/library/tools/R/urltools.R +++ b/src/library/tools/R/urltools.R @@ -42,7 +42,8 @@ function(x) } else { y <- matrix(character(), 0L, 5L) } - colnames(y) <- c("scheme", "authority", "path", "query", "fragment") + y <- as.data.frame(y) + names(y) <- c("scheme", "authority", "path", "query", "fragment") y } From 49b3bda9b072e0dfc0af933cffddfc48c5e5b551 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 05:12:23 +0000 Subject: [PATCH 416/546] Document and export R() and parse_URI_reference(). git-svn-id: https://svn.r-project.org/R/trunk@86950 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/NAMESPACE | 5 ++- src/library/tools/man/R.Rd | 72 +++++++++++++++++++++++++++++++ src/library/tools/man/urltools.Rd | 23 +++++++++- 3 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 src/library/tools/man/R.Rd diff --git a/src/library/tools/NAMESPACE b/src/library/tools/NAMESPACE index 8bdd414fc0f..66ec7516ba6 100644 --- a/src/library/tools/NAMESPACE +++ b/src/library/tools/NAMESPACE @@ -62,7 +62,10 @@ export("R_user_dir") export(".print.via.format") export("check_package_urls", - "check_package_dois") + "check_package_dois", + "parse_URI_reference") + +export("R") exportPattern("^SIG.+") diff --git a/src/library/tools/man/R.Rd b/src/library/tools/man/R.Rd new file mode 100644 index 00000000000..86ea42d31fd --- /dev/null +++ b/src/library/tools/man/R.Rd @@ -0,0 +1,72 @@ +% File src/library/tools/man/R.Rd +% Part of the R package, https://www.R-project.org +% Copyright 2024 R Core Team +% Distributed under GPL 2 or later + +\name{R} +\alias{R} +\title{Call Function in Inferior R Process} +\description{ + Call a function with given arguments in a new (\dQuote{inferior}) R + process. +} +\usage{ +R(fun, args = list(), opts = "--no-save --no-restore", + env = character(), arch = "", drop = TRUE, timeout = 0) +} +\arguments{ + \item{fun}{a function to call in the inferior R process.} + \item{args}{a list of arguments to the function call.} + \item{opts}{a character vector of command line options to use when + starting the inferior R process.} + \item{env}{a character vector of name=value strings to set environment + variables to use when starting the inferior R process.} + \item{arch}{a character string giving a sub-architecture to use for + the inferior R process.} + \item{drop}{a logical controlling what gets returned in case of + \dQuote{success} (when there was no error running the inferior R + process and the value of the function call is not a condition + object). By default, in this case only that value is returned. + If \code{drop = FALSE}, a list with that value and status, stdout + and stderr of running the inferior R process.} + \item{timeout}{a timeout in seconds for the inferior R process, + ignored if 0.} +} +\details{ + The given function and argument list are serialized into a tempfile. + Then, an inferior R process is run via (a wrapper for) + \code{\link{system2}()} as controlled by arguments \code{opts}, + \code{env}, \code{arch} and \code{timeout}, the input of which loads + the tempfile and calls the function with the argument list. It is + ensured that an appropriate CRAN mirror is set. +} +\value{ + In case of \dQuote{success} (see above), the value of the function + call if \code{drop = TRUE} (default), or a named list with the value + and the status, stdout and stderr of running the inferior R process. + + Otherwise, currently an error condition object inheriting from + \code{"inferiorCallError"} with the result (status, stdout and stderr) + of running the inferior R process, and in case this was successfully + run but the value of the function call is a condition object, that + object in the \code{value} element. + + What gets returned in the non-success case may change in the future, + perhaps using two different classes for the two cases of + \dQuote{failure} (i.e., failure in running the inferior R process or + calling the function). +} +\examples{ +## Compute cos(0) in an inferior R process. +## By default, only return the value of the function call. +R(cos, list(0)) +## If 'drop = FALSE', we also get status, stdout and stderr. +R(cos, list(0), drop = FALSE) + +## A call giving an error: +(e <- tryCatch(R(stop, list("FOOBAR")), error = identity)) +## The inferior R process ran successfully: +e$status +## The function call gave an error: +e$value +} diff --git a/src/library/tools/man/urltools.Rd b/src/library/tools/man/urltools.Rd index 2646e8979e3..f43af4261f5 100644 --- a/src/library/tools/man/urltools.Rd +++ b/src/library/tools/man/urltools.Rd @@ -1,17 +1,20 @@ \name{urltools} \alias{check_package_urls} +\alias{parse_URI_reference} \title{Check Package URLs} \description{ Check URLs in package sources. } \usage{ check_package_urls(dir, verbose = FALSE) +parse_URI_reference(x) } \arguments{ \item{dir}{a character string specifying the path to a package's root source directory.} \item{verbose}{a logical indicating if output should monitor check progress.} + \item{x}{a character vector of URIs.} } \details{ Checking URLs is performed in parallel using \CRANpkg{curl} (so this @@ -28,13 +31,29 @@ check_package_urls(dir, verbose = FALSE) requests, and the ones with non-OK (200) status codes re-checked via \samp{GET} requests (unfortunately, \samp{HEAD} requests are not always honored appropriately). + + \code{parse_URI_reference()} is a helper which splits URI references + into its scheme, authority, path, query and fragment parts. + See RFC 3986 (\url{https://www.rfc-editor.org/rfc/rfc3986}) for more + information. } \value{ - A data frame inheriting from class \code{check_url_db} with - information on the URL check problems found. + For \code{check_url_db()}, a data frame inheriting from class + \code{check_url_db} with information on the URL check problems found. + + For \code{parse_URI_reference()}, a character frame with variables + \code{scheme}, \code{authority}, \code{path}, \code{query} and + \code{fragment}. } \note{ This functionality is still experimental: interfaces may change in future versions. } +\examples{ +## Examples from RFC 3986. +parse_URI_reference(c("foo://example.com:8042/over/there?name=ferret#nose", + "urn:example:animal:ferret:nose", + "mailto:John.Doe@example.com", + "tel:+1-816-555-1212")) +} \keyword{utilities} From 6acb64ff0c21436931533cbc01c26c40d4c647ad Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 05:12:46 +0000 Subject: [PATCH 417/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86951 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/Examples/tools-Ex.Rout.save | 97 ++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/tests/Examples/tools-Ex.Rout.save b/tests/Examples/tools-Ex.Rout.save index 30fb26415f8..ce0800e7822 100644 --- a/tests/Examples/tools-Ex.Rout.save +++ b/tests/Examples/tools-Ex.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-07-30 r86939) -- "Unsuffered Consequences" +R Under development (unstable) (2024-07-31 r86945) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -69,6 +69,71 @@ Type 'q()' to quit R. > > > cleanEx() +> nameEx("R") +> ### * R +> +> flush(stderr()); flush(stdout()) +> +> ### Name: R +> ### Title: Call Function in Inferior R Process +> ### Aliases: R +> +> ### ** Examples +> +> ## Compute cos(0) in an inferior R process. +> ## By default, only return the value of the function call. +> R(cos, list(0)) +[1] 1 +> ## If 'drop = FALSE', we also get status, stdout and stderr. +> R(cos, list(0), drop = FALSE) +$value +[1] 1 + +$status +[1] 0 + +$stdout + [1] "" + [2] "R Under development (unstable) (2024-07-31 r86945) -- \"Unsuffered Consequences\"" + [3] "Copyright (C) 2024 The R Foundation for Statistical Computing" + [4] "Platform: x86_64-pc-linux-gnu" + [5] "" + [6] "R is free software and comes with ABSOLUTELY NO WARRANTY." + [7] "You are welcome to redistribute it under certain conditions." + [8] "Type 'license()' or 'licence()' for distribution details." + [9] "" +[10] "R is a collaborative project with many contributors." +[11] "Type 'contributors()' for more information and" +[12] "'citation()' on how to cite R or R packages in publications." +[13] "" +[14] "Type 'demo()' for some demos, 'help()' for on-line help, or" +[15] "'help.start()' for an HTML browser interface to help." +[16] "Type 'q()' to quit R." +[17] "" +[18] "> x <- readRDS(\"/tmp/RtmplAYNCR/runri21acba5d0b9fff\")" +[19] "> options(repos = x$repos)" +[20] "> y <- tryCatch(list(do.call(x$fun, x$args, quote = TRUE)), error = identity)" +[21] "> saveRDS(y, \"/tmp/RtmplAYNCR/runro21acba2ad86f30\")" +[22] "> " + +$stderr +character(0) + +> +> ## A call giving an error: +> (e <- tryCatch(R(stop, list("FOOBAR")), error = identity)) + +> ## The inferior R process ran successfully: +> e$status +[1] 0 +> ## The function call gave an error: +> e$value + +> +> +> +> cleanEx() > nameEx("Rd2HTML") > ### * Rd2HTML > @@ -211,7 +276,7 @@ Error in assertWarning(ff()) : > bibstyle("unsorted", sortKeys = function(refs) seq_along(refs), + fmtPrefix = function(paper) paste0("[", paper$.index, "]"), + .init = TRUE) - + > print(refs, .bibstyle = "unsorted") [1] R Core Team (2013). _R: A Language and Environment for Statistical Computing_. R Foundation for Statistical Computing, Vienna, Austria. @@ -1064,6 +1129,32 @@ An illustration of lexical scoping. > > > cleanEx() +> nameEx("urltools") +> ### * urltools +> +> flush(stderr()); flush(stdout()) +> +> ### Name: urltools +> ### Title: Check Package URLs +> ### Aliases: check_package_urls parse_URI_reference +> ### Keywords: utilities +> +> ### ** Examples +> +> ## Examples from RFC 3986. +> parse_URI_reference(c("foo://example.com:8042/over/there?name=ferret#nose", ++ "urn:example:animal:ferret:nose", ++ "mailto:John.Doe@example.com", ++ "tel:+1-816-555-1212")) + scheme authority path query fragment +1 foo example.com:8042 /over/there name=ferret nose +2 urn example:animal:ferret:nose +3 mailto John.Doe@example.com +4 tel +1-816-555-1212 +> +> +> +> cleanEx() > nameEx("userdir") > ### * userdir > @@ -1232,7 +1323,7 @@ needs Deep Thought > cleanEx() > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 0.313 0.014 0.329 0 0 +Time elapsed: 0.336 0.008 0.719 0.303 0.066 > grDevices::dev.off() null device 1 From fd3c8498dbd8f5267016783e0839717721c145ff Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 06:33:16 +0000 Subject: [PATCH 418/546] NOTE output diffs. git-svn-id: https://svn.r-project.org/R/trunk@86952 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 83055b9f1eb..522491cfeee 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -4367,9 +4367,12 @@ add_dummies <- function(dir, Log) cmd <- paste0("invisible(tools::Rdiff('", exout, "', '", exsave, "',TRUE,TRUE))") out <- R_runR0(cmd, R_opts2) - resultLog(Log, "OK") - if(length(out)) - printLog0(Log, paste(c("", out, ""), collapse = "\n")) + if(length(out)) { + noteLog(Log) + printLog0(Log, paste(out, collapse = "\n"), "\n") + } + else + resultLog(Log, "OK") } TRUE From 172b62054d065ad6886d083f11ab2c5d6510270d Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 06:34:18 +0000 Subject: [PATCH 419/546] Have CRAN submission checks note possibly incomplete BugReport URLs. git-svn-id: https://svn.r-project.org/R/trunk@86953 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index bdce1550a3e..71925b8fd03 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -7926,6 +7926,25 @@ function(dir, localOnly = FALSE, pkgSize = NA) if(!is.na(v <- meta["URL"]) && length(z <- .bad_DESCRIPTION_URL_field_parts(v))) out$url_field_parts <- z + + ## Check BugReports field + if(!is.na(v <- meta["BugReports"])) { + ## Should be a single URL: this is checked in check_meta() + ## inside .check_packages(). + z <- parse_URI_reference(v) + if((endsWith(tolower(z$authority), "github.com") || + endsWith(tolower(z$authority), "gitlab.com")) && + basename(z$path) != "issues") { + w <- sprintf("%s/issues", sub("/$", "", v)) + out$bugreports <- + paste(c("The BugReports field in DESCRIPTION has", + sprintf(" %s", v), + "which should likely be", + sprintf(" %s", w), + "instead."), + collapse = "\n") + } + } skip_dates <- config_val_to_logical(Sys.getenv("_R_CHECK_CRAN_INCOMING_SKIP_DATES_", @@ -8988,6 +9007,7 @@ function(x, ...) strwrap("The URL field should be a list of URLs separated by commas or whitespace.")), collapse = "\n") })), + if(length(y <- x$bugreports)) y, fmt(c(if(length(x$GNUmake)) { "GNU make is a SystemRequirements." })), From 5925016dfdafc63969a7a81daf4478dd38960d0f Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 06:34:52 +0000 Subject: [PATCH 420/546] NEWS for c86950. git-svn-id: https://svn.r-project.org/R/trunk@86954 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 36d9cf67086..20e5a9265db 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -55,6 +55,9 @@ \item Package \pkg{tools} now exports functions \code{CRAN_current_db()}, \code{CRAN_aliases_db()}, \code{CRAN_rdxrefs_db()}, and \code{CRAN_archive_db()}. + + \item Package \pkg{tools} now exports functions + \code{R()} and \code{parse_URI_reference()}. } } From 240f4333063c23df8dba0b7db58a094a8810c677 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 07:32:22 +0000 Subject: [PATCH 421/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86955 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 48 ++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index bc526ac5044..613277f99cd 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -727,24 +727,20 @@ function(x) unlist(keys) } +.bibentry_names_or_keys <- +function(x) +{ + if(is.null(y <- names(x))) + y <- .bibentry_get_key(x) + y +} + `[.bibentry` <- function(x, i, j, drop = TRUE) { if(!length(x)) return(x) - s <- seq_along(x) - if(!missing(i) && is.character(i)) { - ## For character subscript i, use keys if there are no names. - ## Note that creating bibentries does not add the keys as names: - ## assuming that both can independently be set, we would need to - ## track whether names were auto-generated or not. - ## (We could consider providing a names() getter which returns - ## given names or keys as used for character subscripting, - ## though). - names(s) <- names(x) - if(is.null(names(s))) - names(s) <- .bibentry_get_key(x) - } + s <- .bibentry_seq_along(x, i) i <- s[i] y <- unclass(x)[i] if(!all(ok <- lengths(y) > 0L)) { @@ -770,13 +766,7 @@ function(x, i, j, drop = TRUE) `[[.bibentry` <- function(x, i, j) { - s <- seq_along(x) - if(is.character(i)) { - ## See comments in [ method. - names(s) <- names(x) - if(is.null(names(s))) - names(s) <- .bibentry_get_key(x) - } + s <- .bibentry_seq_along(x, i) i <- s[[i]] y <- unclass(x)[[i]] if(missing(j)) { @@ -793,6 +783,24 @@ function(x, i, j) y } +.bibentry_seq_along <- +function(x, i = NULL) +{ + ## When subscripting bibentries with character subscript i, we use + ## keys if there are no names. + ## Note that creating bibentries does not add the keys as names: + ## assuming that both can independently be set, we would need to + ## track whether names were auto-generated or not. + ## We could consider providing a names() getter which returns + ## given names or keys as used for character subscripting, though: + ## as of 2024-08 we have .bibentry_names_or_keys() for this. + s <- seq_along(x) + if(!missing(i) && is.character(i)) { + names(s) <- .bibentry_names_or_keys(x) + } + s +} + bibentry_format_styles <- c("text", "Bibtex", "citation", "html", "latex", "textVersion", "R", "md") From 83760deb4abc8d66968d3a03098aa9e91d90e04f Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 07:32:40 +0000 Subject: [PATCH 422/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86956 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/man/R.Rd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/library/tools/man/R.Rd b/src/library/tools/man/R.Rd index 86ea42d31fd..de9ab380173 100644 --- a/src/library/tools/man/R.Rd +++ b/src/library/tools/man/R.Rd @@ -61,7 +61,9 @@ R(fun, args = list(), opts = "--no-save --no-restore", ## By default, only return the value of the function call. R(cos, list(0)) ## If 'drop = FALSE', we also get status, stdout and stderr. +## IGNORE_RDIFF_BEGIN R(cos, list(0), drop = FALSE) +## IGNORE_RDIFF_END ## A call giving an error: (e <- tryCatch(R(stop, list("FOOBAR")), error = identity)) From b837d790ea16ea36e014f93aec347c4f900307e8 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 07:32:50 +0000 Subject: [PATCH 423/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86957 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/Examples/tools-Ex.Rout.save | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/Examples/tools-Ex.Rout.save b/tests/Examples/tools-Ex.Rout.save index ce0800e7822..ca84ae26143 100644 --- a/tests/Examples/tools-Ex.Rout.save +++ b/tests/Examples/tools-Ex.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-07-31 r86945) -- "Unsuffered Consequences" +R Under development (unstable) (2024-08-01 r86954) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -85,6 +85,7 @@ Type 'q()' to quit R. > R(cos, list(0)) [1] 1 > ## If 'drop = FALSE', we also get status, stdout and stderr. +> ## IGNORE_RDIFF_BEGIN > R(cos, list(0), drop = FALSE) $value [1] 1 @@ -94,7 +95,7 @@ $status $stdout [1] "" - [2] "R Under development (unstable) (2024-07-31 r86945) -- \"Unsuffered Consequences\"" + [2] "R Under development (unstable) (2024-08-01 r86954) -- \"Unsuffered Consequences\"" [3] "Copyright (C) 2024 The R Foundation for Statistical Computing" [4] "Platform: x86_64-pc-linux-gnu" [5] "" @@ -110,15 +111,16 @@ $stdout [15] "'help.start()' for an HTML browser interface to help." [16] "Type 'q()' to quit R." [17] "" -[18] "> x <- readRDS(\"/tmp/RtmplAYNCR/runri21acba5d0b9fff\")" +[18] "> x <- readRDS(\"/tmp/Rtmpa05XU3/runri2447a365273007\")" [19] "> options(repos = x$repos)" [20] "> y <- tryCatch(list(do.call(x$fun, x$args, quote = TRUE)), error = identity)" -[21] "> saveRDS(y, \"/tmp/RtmplAYNCR/runro21acba2ad86f30\")" +[21] "> saveRDS(y, \"/tmp/Rtmpa05XU3/runro2447a3756c0041\")" [22] "> " $stderr character(0) +> ## IGNORE_RDIFF_END > > ## A call giving an error: > (e <- tryCatch(R(stop, list("FOOBAR")), error = identity)) @@ -276,7 +278,7 @@ Error in assertWarning(ff()) : > bibstyle("unsorted", sortKeys = function(refs) seq_along(refs), + fmtPrefix = function(paper) paste0("[", paper$.index, "]"), + .init = TRUE) - + > print(refs, .bibstyle = "unsorted") [1] R Core Team (2013). _R: A Language and Environment for Statistical Computing_. R Foundation for Statistical Computing, Vienna, Austria. @@ -1323,7 +1325,7 @@ needs Deep Thought > cleanEx() > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 0.336 0.008 0.719 0.303 0.066 +Time elapsed: 0.315 0.018 0.699 0.321 0.043 > grDevices::dev.off() null device 1 From 2ae0d241b7c6bc1da86135105e4100119f22a641 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 09:04:41 +0000 Subject: [PATCH 424/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86958 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/man/R.Rd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/tools/man/R.Rd b/src/library/tools/man/R.Rd index de9ab380173..63dfa7d7af8 100644 --- a/src/library/tools/man/R.Rd +++ b/src/library/tools/man/R.Rd @@ -61,9 +61,9 @@ R(fun, args = list(), opts = "--no-save --no-restore", ## By default, only return the value of the function call. R(cos, list(0)) ## If 'drop = FALSE', we also get status, stdout and stderr. -## IGNORE_RDIFF_BEGIN +\dontdiff{ R(cos, list(0), drop = FALSE) -## IGNORE_RDIFF_END +} ## A call giving an error: (e <- tryCatch(R(stop, list("FOOBAR")), error = identity)) From d9b797125da4252d7495b607dfd806166ac09103 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 09:05:22 +0000 Subject: [PATCH 425/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86959 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/Examples/tools-Ex.Rout.save | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/Examples/tools-Ex.Rout.save b/tests/Examples/tools-Ex.Rout.save index ca84ae26143..e82302a330a 100644 --- a/tests/Examples/tools-Ex.Rout.save +++ b/tests/Examples/tools-Ex.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-08-01 r86954) -- "Unsuffered Consequences" +R Under development (unstable) (2024-08-01 r86957) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -95,7 +95,7 @@ $status $stdout [1] "" - [2] "R Under development (unstable) (2024-08-01 r86954) -- \"Unsuffered Consequences\"" + [2] "R Under development (unstable) (2024-08-01 r86957) -- \"Unsuffered Consequences\"" [3] "Copyright (C) 2024 The R Foundation for Statistical Computing" [4] "Platform: x86_64-pc-linux-gnu" [5] "" @@ -111,16 +111,17 @@ $stdout [15] "'help.start()' for an HTML browser interface to help." [16] "Type 'q()' to quit R." [17] "" -[18] "> x <- readRDS(\"/tmp/Rtmpa05XU3/runri2447a365273007\")" +[18] "> x <- readRDS(\"/tmp/Rtmpe6jyFK/runri2595b5455bd5f7\")" [19] "> options(repos = x$repos)" [20] "> y <- tryCatch(list(do.call(x$fun, x$args, quote = TRUE)), error = identity)" -[21] "> saveRDS(y, \"/tmp/Rtmpa05XU3/runro2447a3756c0041\")" +[21] "> saveRDS(y, \"/tmp/Rtmpe6jyFK/runro2595b54aedd2bc\")" [22] "> " $stderr character(0) > ## IGNORE_RDIFF_END +> > > ## A call giving an error: > (e <- tryCatch(R(stop, list("FOOBAR")), error = identity)) @@ -278,7 +279,7 @@ Error in assertWarning(ff()) : > bibstyle("unsorted", sortKeys = function(refs) seq_along(refs), + fmtPrefix = function(paper) paste0("[", paper$.index, "]"), + .init = TRUE) - + > print(refs, .bibstyle = "unsorted") [1] R Core Team (2013). _R: A Language and Environment for Statistical Computing_. R Foundation for Statistical Computing, Vienna, Austria. @@ -1325,7 +1326,7 @@ needs Deep Thought > cleanEx() > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 0.315 0.018 0.699 0.321 0.043 +Time elapsed: 0.338 0.004 0.721 0.338 0.039 > grDevices::dev.off() null device 1 From bab0b02c16ce20f085f354940970a6adaa4dc1db Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 09:06:14 +0000 Subject: [PATCH 426/546] Add [<- and [[<- methods for bibentry objects. git-svn-id: https://svn.r-project.org/R/trunk@86960 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/NAMESPACE | 2 + src/library/utils/R/citation.R | 80 +++++++++++++++++++++++++++++++--- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/src/library/utils/NAMESPACE b/src/library/utils/NAMESPACE index 2eb04f52707..7e74088e14a 100644 --- a/src/library/utils/NAMESPACE +++ b/src/library/utils/NAMESPACE @@ -146,9 +146,11 @@ S3method("$<-", "citation") S3method("$<-", "person") S3method("[", "bibentry") S3method("[", "person") +S3method("[<-", "bibentry") S3method("[<-", "person") S3method("[[", "bibentry") S3method("[[", "person") +S3method("[[<-", "bibentry") S3method("[[<-", "person") S3method("as.data.frame", "bibentry") S3method("as.data.frame", "citation") diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 613277f99cd..a4e98ca3330 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -783,6 +783,79 @@ function(x, i, j) y } +`[<-.bibentry` <- +function(x, i, j, value) +{ + y <- unclass(x) + if(missing(j)) { + y[i] <- as.bibentry(value) + } else { + stopifnot(is.character(j), + length(j) == 1L) + s <- .bibentry_seq_along(x, i) + p <- s[i] + ## See $<-.bibentry ... + value <- rep_len(.listify(value), length(x)) + if(j == "bibtype") + value <- .bibentry_canonicalize_bibtype_value(value) + for(i in p) { + if(j %in% bibentry_attribute_names) { + attr(y[[i]], j) <- + if(is.null(value[[i]])) + NULL + else + paste(value[[i]]) + } else { + y[[i]][[tolower(j)]] <- + if(is.null(value[[i]])) + NULL + else if(j %in% c("author", "editor")) + as.person(value[[i]]) + else + paste(value[[i]]) + } + .bibentry_check_bibentry1(y[[i]]) + } + } + class(y) <- class(x) + y +} + +`[[<-.bibentry` <- +function(x, i, j, value) +{ + s <- .bibentry_seq_along(x, i) + i <- s[[i]] + y <- unclass(x) + if(missing(j)) { + y[i] <- as.bibentry(value) + } else { + stopifnot(is.character(j), + length(j) == 1L) + if(j == "bibtype") + value <- + .bibentry_canonicalize_bibtype_value(list(value))[[1L]] + if(j %in% bibentry_attribute_names) { + attr(y[[i]], j) <- + if(is.null(value)) + NULL + else + paste(value) + } else { + y[[i]][[tolower(j)]] <- + if(is.null(value)) + NULL + else if(j %in% c("author", "editor")) + as.person(value) + else + paste(value) + } + .bibentry_check_bibentry1(y[[i]]) + } + class(y) <- class(x) + y +} + .bibentry_seq_along <- function(x, i = NULL) { @@ -1165,10 +1238,7 @@ function(x, name) `$<-.bibentry` <- function(x, name, value) { - is_attribute <- name %in% bibentry_attribute_names - x <- unclass(x) - if(!is_attribute) name <- tolower(name) ## recycle value value <- rep_len(.listify(value), length(x)) @@ -1179,14 +1249,14 @@ function(x, name, value) ## replace all values for(i in seq_along(x)) { - if(is_attribute) { + if(name %in% bibentry_attribute_names) { attr(x[[i]], name) <- if(is.null(value[[i]])) NULL else paste(value[[i]]) } else { - x[[i]][[name]] <- + x[[i]][[tolower(name)]] <- if(is.null(value[[i]])) NULL else if(name %in% c("author", "editor")) From 4b21ba6414608fa2f6d37a566d6a60cb41628d7f Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 10:59:39 +0000 Subject: [PATCH 427/546] Markup. git-svn-id: https://svn.r-project.org/R/trunk@86961 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/man/R.Rd | 7 ++++--- src/library/tools/man/urltools.Rd | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/library/tools/man/R.Rd b/src/library/tools/man/R.Rd index 63dfa7d7af8..4b03595c49d 100644 --- a/src/library/tools/man/R.Rd +++ b/src/library/tools/man/R.Rd @@ -33,12 +33,13 @@ R(fun, args = list(), opts = "--no-save --no-restore", ignored if 0.} } \details{ - The given function and argument list are serialized into a tempfile. + The given function and argument list are serialized into a + \I{tempfile}. Then, an inferior R process is run via (a wrapper for) \code{\link{system2}()} as controlled by arguments \code{opts}, \code{env}, \code{arch} and \code{timeout}, the input of which loads - the tempfile and calls the function with the argument list. It is - ensured that an appropriate CRAN mirror is set. + the \I{tempfile} and calls the function with the argument list. + It is ensured that an appropriate CRAN mirror is set. } \value{ In case of \dQuote{success} (see above), the value of the function diff --git a/src/library/tools/man/urltools.Rd b/src/library/tools/man/urltools.Rd index f43af4261f5..f4670eea09f 100644 --- a/src/library/tools/man/urltools.Rd +++ b/src/library/tools/man/urltools.Rd @@ -14,7 +14,7 @@ parse_URI_reference(x) source directory.} \item{verbose}{a logical indicating if output should monitor check progress.} - \item{x}{a character vector of URIs.} + \item{x}{a character vector of \abbr{URI}s.} } \details{ Checking URLs is performed in parallel using \CRANpkg{curl} (so this From 01a36950b59d03996ad813b015870dd85d70343e Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 11:00:13 +0000 Subject: [PATCH 428/546] Provide user agent default for the curl-based checks. git-svn-id: https://svn.r-project.org/R/trunk@86962 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/urltools.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/library/tools/R/urltools.R b/src/library/tools/R/urltools.R index 9440a1d8169..07064b6c7c6 100644 --- a/src/library/tools/R/urltools.R +++ b/src/library/tools/R/urltools.R @@ -856,6 +856,9 @@ function(urls, nobody = FALSE, verbose = FALSE, pool = NULL, list(connecttimeout = timeout, timeout = timeout)) + if(is.null(hdrs)) + hdrs <- .curl_handle_default_hdrs + bar <- .progress_bar(if (verbose) length(urls), msg = "fetching ") out <- vector("list", length(urls)) @@ -936,6 +939,9 @@ function(x) list(cookiesession = 1L, followlocation = 1L) +.curl_handle_default_hdrs <- + list("User-Agent" = "curl") + check_package_urls <- function(dir, verbose = FALSE) { From a79e6ac7158e216249876753b99452079c4fc0cd Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 11:00:31 +0000 Subject: [PATCH 429/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86963 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 106 +++++++++++++-------------------- 1 file changed, 43 insertions(+), 63 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index a4e98ca3330..45114bdc786 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -239,10 +239,8 @@ function(x, i, j, value) value <- rep_len(value, length(p)) if(j == "role") value <- lapply(value, .canonicalize_person_role) - for(i in p) - y[[i]][[j]] <- if(.is_not_nonempty_text(value[[i]])) - NULL - else as.character(value[[i]]) + for(i in p) + y[[i]] <- .person_elt_fld_gets(y[[i]], j, value[[i]]) } class(y) <- class(x) y @@ -262,13 +260,20 @@ function(x, i, j, value) j <- match.arg(j, person_field_names) if(j == "role") value <- .canonicalize_person_role(value) - y[[i]][[j]] <- if(.is_not_nonempty_text(value)) - NULL - else as.character(value) + y[[i]] <- .person_elt_fld_gets(y[[i]], j, value) } class(y) <- class(x) y } + +.person_elt_fld_gets <- +function(x, j, v) +{ + x[[j]] <- if(.is_not_nonempty_text(v)) + NULL + else as.character(v) + x +} print.person <- function(x, ...) @@ -301,13 +306,10 @@ function(x, name, value) value <- lapply(value, .canonicalize_person_role) for(i in seq_along(x)) { - x[[i]][[name]] <- if(.is_not_nonempty_text(value[[i]])) - NULL - else as.character(value[[i]]) + x[[i]] <- .person_elt_fld_gets(x[[i]], name, value[[i]]) } - class(x) <- "person" - x + .person(x) } c.person <- @@ -798,23 +800,9 @@ function(x, i, j, value) value <- rep_len(.listify(value), length(x)) if(j == "bibtype") value <- .bibentry_canonicalize_bibtype_value(value) + a <- (j %in% bibentry_attribute_names) for(i in p) { - if(j %in% bibentry_attribute_names) { - attr(y[[i]], j) <- - if(is.null(value[[i]])) - NULL - else - paste(value[[i]]) - } else { - y[[i]][[tolower(j)]] <- - if(is.null(value[[i]])) - NULL - else if(j %in% c("author", "editor")) - as.person(value[[i]]) - else - paste(value[[i]]) - } - .bibentry_check_bibentry1(y[[i]]) + y[[i]] <- .bibentry_elt_fld_gets(y[[i]], j, value[[i]], a) } } class(y) <- class(x) @@ -835,22 +823,8 @@ function(x, i, j, value) if(j == "bibtype") value <- .bibentry_canonicalize_bibtype_value(list(value))[[1L]] - if(j %in% bibentry_attribute_names) { - attr(y[[i]], j) <- - if(is.null(value)) - NULL - else - paste(value) - } else { - y[[i]][[tolower(j)]] <- - if(is.null(value)) - NULL - else if(j %in% c("author", "editor")) - as.person(value) - else - paste(value) - } - .bibentry_check_bibentry1(y[[i]]) + a <- (j %in% bibentry_attribute_names) + y[[i]] <- .bibentry_elt_fld_gets(y[[i]], j, value, a) } class(y) <- class(x) y @@ -874,6 +848,27 @@ function(x, i = NULL) s } +.bibentry_elt_fld_gets <- function(x, j, v, a) { + if(a) { + attr(x, j) <- + if(is.null(v)) + NULL + else + paste(v) + } else { + j <- tolower(j) + x[[j]] <- + if(is.null(v)) + NULL + else if(j %in% c("author", "editor")) + as.person(v) + else + paste(v) + } + .bibentry_check_bibentry1(x) + x +} + bibentry_format_styles <- c("text", "Bibtex", "citation", "html", "latex", "textVersion", "R", "md") @@ -1247,28 +1242,13 @@ function(x, name, value) if(name == "bibtype") value <- .bibentry_canonicalize_bibtype_value(value) - ## replace all values + ## replace all values and check whether all elements still have + ## their required fields: + a <- (name %in% bibentry_attribute_names) for(i in seq_along(x)) { - if(name %in% bibentry_attribute_names) { - attr(x[[i]], name) <- - if(is.null(value[[i]])) - NULL - else - paste(value[[i]]) - } else { - x[[i]][[tolower(name)]] <- - if(is.null(value[[i]])) - NULL - else if(name %in% c("author", "editor")) - as.person(value[[i]]) - else - paste(value[[i]]) - } + x[[i]] <- .bibentry_elt_fld_gets(x[[i]], name, value[[i]], a) } - ## check whether all elements still have their required fields - for(i in seq_along(x)) .bibentry_check_bibentry1(x[[i]]) - .bibentry(x) } From 2f4209cf1d1362991628aef641b297513ba7d025 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 1 Aug 2024 12:35:59 +0000 Subject: [PATCH 430/546] Document c86934. git-svn-id: https://svn.r-project.org/R/trunk@86964 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/man/person.Rd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/library/utils/man/person.Rd b/src/library/utils/man/person.Rd index 0b7e3f7d7a0..97dda120393 100644 --- a/src/library/utils/man/person.Rd +++ b/src/library/utils/man/person.Rd @@ -67,7 +67,8 @@ as.person(x) \item{collapse}{a list of characters (see \bold{Details}).} \item{\dots}{currently not used.} \item{style}{a character string specifying the print style, with - \code{"R"} yielding formatting as R code.} + \code{"R"} yielding formatting as R code and \code{"md"} yielding + Markdown (with email addresses and ORCID iDs hyperlinked).} \item{object}{an \R object inhering from class \code{"person"}.} \item{escape}{a logical indicating whether non-ASCII characters should be translated to LaTeX escape sequences.} From 8d0e21d969fc006acc6feaca17d3a2e75d8e1912 Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 2 Aug 2024 09:30:22 +0000 Subject: [PATCH 431/546] Allow getting ownership information for junctions (part of PR#18736). git-svn-id: https://svn.r-project.org/R/trunk@86965 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/platform.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/platform.c b/src/main/platform.c index 76dee3fefe6..5704e331ed5 100644 --- a/src/main/platform.c +++ b/src/main/platform.c @@ -1014,7 +1014,9 @@ attribute_hidden SEXP do_fileinfo(SEXP call, SEXP op, SEXP args, SEXP rho) PSECURITY_DESCRIPTOR sd = NULL; DWORD saveerr = ERROR_SUCCESS; int ok = 0; - h = CreateFileW(wfn, GENERIC_READ, + /* NOTE: GENERIC_READ asks for too much + (e.g. access denied for junctions) */ + h = CreateFileW(wfn, READ_CONTROL, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); ok = (h != INVALID_HANDLE_VALUE); From 42548ac0a7ee6a859247c348713867f96b8d931e Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 2 Aug 2024 09:54:43 +0000 Subject: [PATCH 432/546] Fix comment. git-svn-id: https://svn.r-project.org/R/trunk@86966 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/platform.c b/src/main/platform.c index 5704e331ed5..dc9ecc50c09 100644 --- a/src/main/platform.c +++ b/src/main/platform.c @@ -1014,8 +1014,8 @@ attribute_hidden SEXP do_fileinfo(SEXP call, SEXP op, SEXP args, SEXP rho) PSECURITY_DESCRIPTOR sd = NULL; DWORD saveerr = ERROR_SUCCESS; int ok = 0; - /* NOTE: GENERIC_READ asks for too much - (e.g. access denied for junctions) */ + /* NOTE: GENERIC_READ would be asking too much + (e.g. junctions under Users/Default in Windows 10) */ h = CreateFileW(wfn, READ_CONTROL, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); From 33673f0c41713c52d73fd8d8cdaa60d9389a732f Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 2 Aug 2024 16:27:29 +0000 Subject: [PATCH 433/546] Provide user domain in Sys.info on Windows. git-svn-id: https://svn.r-project.org/R/trunk@86967 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/extra.c | 94 +++++++++++++++++++++++++++++--- src/library/base/man/Sys.info.Rd | 7 ++- 2 files changed, 91 insertions(+), 10 deletions(-) diff --git a/src/gnuwin32/extra.c b/src/gnuwin32/extra.c index 9488680f23e..02052c9f20a 100644 --- a/src/gnuwin32/extra.c +++ b/src/gnuwin32/extra.c @@ -3,7 +3,7 @@ * file extra.c * Copyright (C) 1998--2003 Guido Masarotto and Brian Ripley * Copyright (C) 2004 The R Foundation - * Copyright (C) 2005--2023 The R Core Team + * Copyright (C) 2005--2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -168,9 +168,76 @@ SEXP in_loadRconsole(SEXP sfile) return R_NilValue; } +/* returns R_alloc'd results */ +static int getCurrentUserAndDomain(char **user, char **domain) +{ + int ok = 0; + HANDLE h = INVALID_HANDLE_VALUE; + DWORD err; + DWORD tilen = 0; + PTOKEN_USER t = NULL; + char *ubuf = NULL; + DWORD ulen = 0; + char *dbuf = NULL; + DWORD dlen = 0; + SID_NAME_USE suse = SidTypeUnknown; + + ok = OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, TRUE, &h); + if (!ok) { + err = GetLastError(); + if (err == ERROR_NO_TOKEN || err == ERROR_NO_IMPERSONATION_TOKEN) + ok = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &h); + } + + ok = ok && !GetTokenInformation(h, TokenUser, NULL, 0, &tilen) + && GetLastError() == ERROR_INSUFFICIENT_BUFFER; + + if (ok) { + t = (PTOKEN_USER) R_alloc(tilen, 1); + ok = GetTokenInformation(h, TokenUser, t, tilen, &tilen); + } + + if (ok) { + ok = !LookupAccountSid(NULL, t->User.Sid, ubuf, &ulen, dbuf, &dlen, + &suse) + && GetLastError() == ERROR_INSUFFICIENT_BUFFER; + + if (ok) { + ubuf = R_alloc(ulen, 1); + dbuf = R_alloc(dlen, 1); + ok = LookupAccountSid(NULL, t->User.Sid, ubuf, &ulen, dbuf, &dlen, + &suse); + } + } + + if (!ok) + err = GetLastError(); + + if (h != INVALID_HANDLE_VALUE) + CloseHandle(h); + + if (ok) { + if (user) + *user = ubuf; + if (domain) + *domain = dbuf; + return 1; + } else { + if (user) + *user = NULL; + if (domain) + *domain = NULL; + SetLastError(err); + return 0; + } +} + + #include typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); +const char *formatError(DWORD res); + /* base::Sys.info */ // keep in step with src/library/utils/src/windows/util.c SEXP do_sysinfo(SEXP call, SEXP op, SEXP args, SEXP rho) @@ -178,11 +245,14 @@ SEXP do_sysinfo(SEXP call, SEXP op, SEXP args, SEXP rho) SEXP ans, ansnames; OSVERSIONINFOEX osvi; char ver[256], buf[1000]; - wchar_t name[MAX_COMPUTERNAME_LENGTH + 1], user[UNLEN+1]; - DWORD namelen = MAX_COMPUTERNAME_LENGTH + 1, userlen = UNLEN+1; + wchar_t name[MAX_COMPUTERNAME_LENGTH + 1]; + DWORD namelen = MAX_COMPUTERNAME_LENGTH + 1; + const void *vmax = vmaxget(); + char *uname; + char *udomain; checkArity(op, args); - PROTECT(ans = allocVector(STRSXP, 8)); + PROTECT(ans = allocVector(STRSXP, 9)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if(!GetVersionEx((OSVERSIONINFO *)&osvi)) error(_("unsupported version of Windows")); @@ -258,12 +328,18 @@ SEXP do_sysinfo(SEXP call, SEXP op, SEXP args, SEXP rho) #else SET_STRING_ELT(ans, 4, mkChar("x86")); #endif - GetUserNameW(user, &userlen); - wcstoutf8(buf, user, sizeof(buf)); - SET_STRING_ELT(ans, 5, mkCharCE(buf, CE_UTF8)); + if (!getCurrentUserAndDomain(&uname, &udomain)) { + SET_STRING_ELT(ans, 5, mkChar("unknown")); + SET_STRING_ELT(ans, 8, mkChar("unknown")); + warning(_("cannot resolve current user or domain: '%s'"), + formatError(GetLastError())); + } else { + SET_STRING_ELT(ans, 5, mkChar(uname)); + SET_STRING_ELT(ans, 8, mkChar(udomain)); + } SET_STRING_ELT(ans, 6, STRING_ELT(ans, 5)); SET_STRING_ELT(ans, 7, STRING_ELT(ans, 5)); - PROTECT(ansnames = allocVector(STRSXP, 8)); + PROTECT(ansnames = allocVector(STRSXP, 9)); SET_STRING_ELT(ansnames, 0, mkChar("sysname")); SET_STRING_ELT(ansnames, 1, mkChar("release")); SET_STRING_ELT(ansnames, 2, mkChar("version")); @@ -272,7 +348,9 @@ SEXP do_sysinfo(SEXP call, SEXP op, SEXP args, SEXP rho) SET_STRING_ELT(ansnames, 5, mkChar("login")); SET_STRING_ELT(ansnames, 6, mkChar("user")); SET_STRING_ELT(ansnames, 7, mkChar("effective_user")); + SET_STRING_ELT(ansnames, 8, mkChar("udomain")); setAttrib(ans, R_NamesSymbol, ansnames); + vmaxset(vmax); UNPROTECT(2); return ans; } diff --git a/src/library/base/man/Sys.info.Rd b/src/library/base/man/Sys.info.Rd index f6bc1c6555b..436e07e146d 100644 --- a/src/library/base/man/Sys.info.Rd +++ b/src/library/base/man/Sys.info.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/Sys.info.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2021 R Core Team +% Copyright 1995-2024 R Core Team % Copyright 2008 The R Foundation % Distributed under GPL 2 or later @@ -29,13 +29,16 @@ Sys.info() \code{"unknown"} if it cannot be ascertained. This may differ from the real user in \sQuote{set-user-ID} processes.} + \item{udomain}{The domain name for the user. Only available on Windows.} \describe{ \item{On Unix-alike platforms: }{ The first five fields come from the \code{uname(2)} system call. The login name comes from \code{getlogin(2)}, and the user names from \code{getpwuid(getuid())} and \code{getpwuid(geteuid())}.} - \item{On Windows: }{The last three fields give the same value.} + \item{On Windows: }{ + Fields \code{login}, \code{user} and \code{effective_user} give the same + value. \code{udomain} is the corresponding domain.} } } \details{ From be5045923f10c9207d28fea66cb7dd07ed1bdcdb Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 2 Aug 2024 18:29:28 +0000 Subject: [PATCH 434/546] Take user domain into account when checking for extra files left behind by a package check. git-svn-id: https://svn.r-project.org/R/trunk@86968 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 522491cfeee..ed0897a54d0 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -435,7 +435,8 @@ add_dummies <- function(dir, Log) snapshot <- function() { - snap1 <- function(dir, recursive = TRUE, user, notemp = FALSE) + snap1 <- function(dir, recursive = TRUE, user, udomain = NA, + notemp = FALSE) { foo <- list.files(dir, recursive = recursive, full.names = TRUE, include.dirs = TRUE, no.. = TRUE) @@ -446,11 +447,17 @@ add_dummies <- function(dir, Log) foo <- foo[!(poss & isdir)] } owner <- file.info(foo)[, "uname"] - foo[owner == user] + sel <- (owner == user) + if (!is.na(udomain)) { + odomain <- file.info(foo)[, "udomain"] + sel <- sel & (odomain == udomain) + } + foo[sel] } ## This should always give the uname for files created by the ## current user: user <- Sys.info()[["effective_user"]] + udomain <- Sys.info()["udomain"] ## NA (nonexistent) on Unix home <- normalizePath("~") xtra <- Sys.getenv("_R_CHECK_THINGS_IN_OTHER_DIRS_XTRA_", "") xtra <- if (nzchar(xtra)) strsplit(xtra, ";", fixed = TRUE)[[1L]] @@ -470,11 +477,12 @@ add_dummies <- function(dir, Log) else file.path(home, ".local", "share"), xtra) x <- vector("list", length(dirs)); names(x) <- dirs - x[[1]] <- snap1(dirs[1], FALSE, user) - x[[2]] <- snap1(dirs[2], FALSE, user, TRUE) - x[[3]] <- snap1(dirs[3], TRUE, user) - x[[4]] <- snap1(dirs[4], TRUE, user) - for (i in seq_along(xtra)) x[[4+i]] <- snap1(dirs[4+i], FALSE, user) + x[[1]] <- snap1(dirs[1], FALSE, user, udomain) + x[[2]] <- snap1(dirs[2], FALSE, user, udomain, TRUE) + x[[3]] <- snap1(dirs[3], TRUE, user, udomain) + x[[4]] <- snap1(dirs[4], TRUE, user, udomain) + for (i in seq_along(xtra)) + x[[4+i]] <- snap1(dirs[4+i], FALSE, user, udomain) x } From f3682fbf596908ef4f65b168b8c96d25265292b7 Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 2 Aug 2024 18:31:10 +0000 Subject: [PATCH 435/546] Check also temporary directory on Windows when looking for extra files left behind by a package check. git-svn-id: https://svn.r-project.org/R/trunk@86969 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index ed0897a54d0..137c9b68d6d 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -462,7 +462,7 @@ add_dummies <- function(dir, Log) xtra <- Sys.getenv("_R_CHECK_THINGS_IN_OTHER_DIRS_XTRA_", "") xtra <- if (nzchar(xtra)) strsplit(xtra, ";", fixed = TRUE)[[1L]] else character() - dirs <- c(home, "/tmp", '/dev/shm', + dirs <- c(home, dirname(tempdir()), '/dev/shm', ## taken from tools::R_user_dir, but package rappdirs ## is similar with other possibilities on Windows. if (.Platform$OS.type == "windows") From 849e1eabda5538b20932469fed15d2f045e3b8c9 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 4 Aug 2024 11:21:46 +0000 Subject: [PATCH 436/546] Improve as suggested by SM. git-svn-id: https://svn.r-project.org/R/trunk@86970 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/man/CRANtools.Rd | 4 ++-- src/library/tools/man/urltools.Rd | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/library/tools/man/CRANtools.Rd b/src/library/tools/man/CRANtools.Rd index d4b2a96d0e6..adcd78e6076 100644 --- a/src/library/tools/man/CRANtools.Rd +++ b/src/library/tools/man/CRANtools.Rd @@ -69,10 +69,10 @@ CRAN_archive_db() Packages with all-OK checks are indicated via a \code{*} \code{Check} wildcard name and OK \code{Status}. - \code{CRAN_check_issues()} returns a character frame with additional + \code{CRAN_check_issues()} returns a information on additional check issues (including the memory-access check results made available from \url{https://www.stats.ox.ac.uk/pub/bdr/memtests/}) as a - character frame with variables \code{Package}, \code{Version}, + data frame with character variables \code{Package}, \code{Version}, \code{kind} (an identifier for the issue) and \code{href} (a URL with information on the issue). diff --git a/src/library/tools/man/urltools.Rd b/src/library/tools/man/urltools.Rd index f4670eea09f..e7a427f0877 100644 --- a/src/library/tools/man/urltools.Rd +++ b/src/library/tools/man/urltools.Rd @@ -41,9 +41,9 @@ parse_URI_reference(x) For \code{check_url_db()}, a data frame inheriting from class \code{check_url_db} with information on the URL check problems found. - For \code{parse_URI_reference()}, a character frame with variables - \code{scheme}, \code{authority}, \code{path}, \code{query} and - \code{fragment}. + For \code{parse_URI_reference()}, a data frame with character + variables \code{scheme}, \code{authority}, \code{path}, \code{query} + and \code{fragment}. } \note{ This functionality is still experimental: interfaces may change in From c59aff70c3441529658e5ff831c7ef0d10791655 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 4 Aug 2024 11:22:04 +0000 Subject: [PATCH 437/546] Improve URLs. git-svn-id: https://svn.r-project.org/R/trunk@86971 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/connections.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/base/man/connections.Rd b/src/library/base/man/connections.Rd index addc440847c..e9ff0bef2f5 100644 --- a/src/library/base/man/connections.Rd +++ b/src/library/base/man/connections.Rd @@ -536,7 +536,7 @@ socketTimeout(socket, timeout = -1) #endif #ifdef unix in mode \code{"r"} only. This reads the X11 primary selection (see - \url{https://specifications.freedesktop.org/clipboards-spec/clipboards-latest.txt}), + \url{https://specifications.freedesktop.org/clipboards-spec/latest}), which can also be specified as \code{"X11_primary"} and the secondary selection as \code{"X11_secondary"}. On most systems the clipboard selection (that used by \sQuote{Copy} from an \sQuote{Edit} menu) can From 004ecfa749f4f487f10795535f98204159103060 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 4 Aug 2024 11:22:22 +0000 Subject: [PATCH 438/546] Spelling. git-svn-id: https://svn.r-project.org/R/trunk@86972 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/man/person.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/utils/man/person.Rd b/src/library/utils/man/person.Rd index 97dda120393..c55331e057b 100644 --- a/src/library/utils/man/person.Rd +++ b/src/library/utils/man/person.Rd @@ -68,7 +68,7 @@ as.person(x) \item{\dots}{currently not used.} \item{style}{a character string specifying the print style, with \code{"R"} yielding formatting as R code and \code{"md"} yielding - Markdown (with email addresses and ORCID iDs hyperlinked).} + Markdown (with email addresses and \I{ORCID iD}s hyperlinked).} \item{object}{an \R object inhering from class \code{"person"}.} \item{escape}{a logical indicating whether non-ASCII characters should be translated to LaTeX escape sequences.} From 2de17fce1a70682bf54bb6e94b57196fe8612c9d Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 4 Aug 2024 11:22:53 +0000 Subject: [PATCH 439/546] Add rep() and unique() methods for person objects. git-svn-id: https://svn.r-project.org/R/trunk@86973 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/NAMESPACE | 2 ++ src/library/utils/R/citation.R | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/library/utils/NAMESPACE b/src/library/utils/NAMESPACE index 7e74088e14a..73715334f8e 100644 --- a/src/library/utils/NAMESPACE +++ b/src/library/utils/NAMESPACE @@ -164,10 +164,12 @@ S3method("print", "bibentry") S3method("print", "citation") S3method("print", "person") S3method("rep", "bibentry") +S3method("rep", "person") S3method("sort", "bibentry") S3method("toBibtex", "bibentry") S3method("transform", "bibentry") S3method("unique", "bibentry") +S3method("unique", "person") S3method(.DollarNames, default) S3method(.DollarNames, list) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 45114bdc786..56f85312c17 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -574,6 +574,22 @@ function(x, style = "text") x } +rep.person <- +function(x, ...) +{ + y <- NextMethod("rep") + class(y) <- class(x) + y +} + +unique.person <- +function(x, ...) +{ + y <- NextMethod("unique") + class(y) <- class(x) + y +} + as.data.frame.person <- as.data.frame.vector ###################################################################### From 05e746638aa23a231f484671a8a25712dc3bc952 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 4 Aug 2024 12:13:43 +0000 Subject: [PATCH 440/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86974 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 56f85312c17..32d3249567e 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -285,6 +285,7 @@ function(x, ...) `$.person` <- function(x, name) { + if(!length(x)) return(NULL) ## ## Return list if length > 1, vector otherwise (to mirror the ## behavior of the input format for person()). @@ -299,17 +300,15 @@ function(x, name) function(x, name, value) { name <- match.arg(name, person_field_names) - x <- .listify(unclass(x)) - value <- rep_len(value, length(x)) - + y <- unclass(x) + value <- rep_len(.listify(value), length(y)) if(name == "role") value <- lapply(value, .canonicalize_person_role) - - for(i in seq_along(x)) { - x[[i]] <- .person_elt_fld_gets(x[[i]], name, value[[i]]) + for(i in seq_along(y)) { + y[[i]] <- .person_elt_fld_gets(y[[i]], name, value[[i]]) } - - .person(x) + class(y) <- class(x) + y } c.person <- @@ -756,8 +755,6 @@ function(x) `[.bibentry` <- function(x, i, j, drop = TRUE) { - if(!length(x)) return(x) - s <- .bibentry_seq_along(x, i) i <- s[i] y <- unclass(x)[i] @@ -1233,7 +1230,6 @@ function(x) function(x, name) { if(!length(x)) return(NULL) - ## ## Return list if length > 1, vector otherwise (to mirror the ## behavior of the input format for bibentry()). @@ -1249,23 +1245,20 @@ function(x, name) `$<-.bibentry` <- function(x, name, value) { - x <- unclass(x) - + y <- unclass(x) ## recycle value value <- rep_len(.listify(value), length(x)) - ## check bibtype if(name == "bibtype") value <- .bibentry_canonicalize_bibtype_value(value) - ## replace all values and check whether all elements still have ## their required fields: a <- (name %in% bibentry_attribute_names) - for(i in seq_along(x)) { - x[[i]] <- .bibentry_elt_fld_gets(x[[i]], name, value[[i]], a) + for(i in seq_along(y)) { + y[[i]] <- .bibentry_elt_fld_gets(y[[i]], name, value[[i]], a) } - - .bibentry(x) + class(y) <- class(x) + y } .bibentry_canonicalize_bibtype_value <- From 474498335d1bc47ad1e5f8d5695129ef2fb7b4c3 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 4 Aug 2024 19:46:20 +0000 Subject: [PATCH 441/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86975 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 32d3249567e..b5d1358665e 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -474,10 +474,11 @@ function(x, style = c("text", "R", "md") ) { - if(!length(x)) return(character()) - style <- match.arg(style) + if(!length(x)) + return(if(style == "R") "person()" else character()) + if(style == "R") return(.format_person_as_R_code(x)) args <- c("given", "family", "email", "role", "comment") @@ -908,10 +909,11 @@ function(x, style = "text", .bibstyle = NULL, macros = NULL, ...) { - if(!length(x)) return(character()) - style <- .bibentry_match_format_style(style) + if(!length(x)) + return(if(style == "R") "bibentry()" else character()) + if(sort) x <- sort(x, .bibstyle = .bibstyle) x$.index <- as.list(seq_along(x)) From 666ee43f4d54c66515f2682d4c7fb786edcacdc9 Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 5 Aug 2024 05:01:23 +0000 Subject: [PATCH 442/546] Make as.person.default() recognize ORCID comment/ git-svn-id: https://svn.r-project.org/R/trunk@86976 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index b5d1358665e..3a13422b770 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -389,8 +389,17 @@ function(x) ## Step C. as_person1 <- function(x) { comment <- if(grepl("\\(.*\\)", x)) - sub(".*\\(([^)]*)\\).*", "\\1", x) - else NULL + sub(".*\\(([^)]*)\\).*", "\\1", x) + else NULL + if(!is.null(comment)) { + chunks <- strsplit(comment, ", ", fixed = TRUE)[[1L]] + if(any(i <- grepl(tools:::.ORCID_iD_variants_regexp, + chunks))) { + chunks[i] <- tools:::.ORCID_iD_canonicalize(chunks[i]) + names(chunks)[i] <- "ORCID" + comment <- chunks + } + } x <- sub("[[:space:]]*\\([^)]*\\)", "", x) email <- if(grepl("<.*>", x)) unlist(strsplit(gsub("[[:space:]]*", "", From 20794a9516e7d76fead31cbc7a35bafb92ea0f5e Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 5 Aug 2024 05:01:36 +0000 Subject: [PATCH 443/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@86977 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/sysdata.rda | Bin 9251 -> 9293 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/library/tools/R/sysdata.rda b/src/library/tools/R/sysdata.rda index d5a50bfe59e0f95c55e6d67b66297e71c8e34348..bcc92f7ad056d8be3e05e644ab91c587f15ba2a0 100644 GIT binary patch literal 9293 zcmZ9ORZtuZu%&Sc?(PikgEM$=cXti$I=H)AaCd?`!QBb&?gV!T``4{~*t@5@>U_^# z)u#?w3QxT$CH?+kw#B{NCK&4?T(U<*)!qlFH3SuijeDH64^yDosw0iiSrA7 zesAThiYmL~WBn@Wo~hh?j)dnup{*6~`}dEMzli2EP$J8c6Ul(*)EOBJ1o8$Ls2~w= z*wEgL(d1-+L0(o?R&G{y#Mj<`5a9e!QO^eidO}k6W@lyV1oy6Zwmr8!;ze}%Si4n< zyEnnUI*Lq4cxh4`d`-E`V2U;F62lBKfs}L&iA{n;1xCrwy|Kjp=Q$)>Td{T zS^IIVticp;%NY112-gK-B zC7>o<`FfW2(^{-o0g%HLI0Sja_qFCKA)yA_H|bX`Y?o`K;n0`;E{r#C6ey>Nj$_@T zxZVP**+nC@3&W@gFghNDL@Lbk0g^@AYx0^c7@7kkql^h0+89{UVz zaCS~(E9PWrx2P67pm{T1;nsj>Xu+Vyd-;J0`7M}mml&dQG>Dr@>M-63Vmj~C^BM;D zOg}-+B?o4hQtg+riRkW@IB%}_p?b+U{KT?Qf#gDXPh(I*J9OJ%6=QEYHzvlHZI5Lq zo^2W=$3(1bnrB*M;X@gF#N6cMMJSo7)jkKONEzbTR!biHP4p5Md>+jE&RJh!tE_^n zID}*muNMX~`Y|fW(`=j=F92#0_f}(ZgPGqKtA`LR1hcr;ti+$dZ|~4WkB7xacnkK% z)aG8p3|*T>1w}nXu7c%{JC9VePR=li-|I3Dn+$UFUAO9+gG?xf@0nu7mIe7R5Yb0E z)&;qs@77)E%LbSR&&;Fxo2YTj2*g;wecJJ=oR7x&q$awQo=8t?MPPx zcprHh<~~sF^+9FjLj97gs|E2Ya3`0VfeVh=V_n|3#{m6SdL~OlfgAqs^`p3q`6xbB zN=|nhLN?4@R<6z;6G0NF%?qNtk4$BkCUBzdSaWQkl7e%}%duc_ewN|Kd5UzDNmV7q zwxLeoNo1LrtW&I`7}GZ<7C}6ciYPZ;GDm@Q46nkK_~o~B+kuHTOZ14Mk!xkGrKuFs(XetOOnEN65;~yQJ_kLz8k3RAge->t zHZE-w#-%k8jj1Ms!rmCi2(pMkTToXdy%D^K0@_HgNtTcVvD3A|JJi3>TU4VQBKygr z)M?a-tHR?$EF%%|BI)Lq)|An+J(0%JGRf!%vGc=H*y>eqvqII%*&Er=W-kaub$%O9 zpbB<q*Dd2dlkE z@BD2*OjgzU(8sTmf0SQl8Dk?_QB+ideP)S~Y00+#9I~2Kkz|B7<4L@pjJck{7^=W; zXf^Rp5?+du|E^t8kH1tGpz3RpS+{SE#xu1$Z&^?^29V7Nlx04XTCI9VUiRJpS#)f}~-9>d0EWyhDVeIg3{OI`t ze%GJ*o+SkP1LkpmnB`mXg1YqeP!YY&Ppd>}0a7&cD z!eV5;S^LZIJ@j{~X@Gl?1oG2q-Nv}WwAqOD_j5~PtQq(V8SPkTk-ByX{@~M zug*pJU~|>WX1l__X01Vz#am~EI>!$sgg!;#d}Wf}{&>utNGyM4^pQOK>Q)b?LabG8 zDgRPg3KqwSn(Wkb4Gf0=7u8XMS|%!Q^kwqPRM(kz9;{yVBz>lu+EdprX{}_&<4H=U zi-dR|l#Vq@PU|A8$0+)Dh^sD#kG9+WF+zN4%ctIv`{=AMqmtT(5-h=9lJ;nA&P~5p zhhHIG%rIyWYL0>;00W_-So7C0wLi)7iU5~L*_iIN9C&=s(Y5Lq_ddH z4Iu{7l&Vut$^}-XxMFiL&^b0ukPf0JAvcR$Y?yqfGg%>#*r|4BRGXkL|^+idqW3n2kiVDra(_yBAJVYLI`lwy2`^wt_VYpXO>rAb^uo|o$ zxp->pi0L6Q=fp4#N_!1XI#c0_axfBRbGW%kB$bd0mp_pVrh2h`hBBTxC#C!Pkp%U4 zLAYW&Hf^wa;IdVvh9~7_#J2Gm<3+epQ!F;LY{v#9l;Tw!#0JKyI6YK{B&)$ZV;8bV z5ju0Pq%eT53peE^LJoYfF1~b)OC}DC0WQYR{uuP;NGB5}5&dRg7R->}=gpbt)>-NP z_!Po#xHq@fm9bmPA%yKR@UI}*U%KWCFde_aq)q7Ox6UQaOR?TSC88X{#(c`~qLxVb z*Igfs8KT=N2xA{f!K68VE!Mx4>xUjIhQ^qNg{4>!$7Bot&}&!I=5xO6<2lrEm!UMV zr;Wdn%|V#|DS$Xf0QAKy5CXXmpnANzd)wAd44;}3A}w0;7I*Gg&AepP685<7Ii5Hh zexz~c-FI7c%zfq!tNb{TZ5v|9918PxrU%gddxo19Z=fOpF z2>zHv)bV&Qnx^v>hNMMWnT%DEdcJR-Ynb_z(;;0O z3{WT=clf7I7M3rZhP!vEbTDu*doUlFUIt3e{gp-kBjI4|!!iAvC81F}!?Fsz&7(q`;%hIlrS z>dY8e)k)FS~W3oQmfPewWSN9gOF&h091dVF1}7yBEo`!Mb)plZ2H4zK%py2f?@dFU zax!G@yJlP;?Qa{rJMq(;Fl{fN zFL&D%T_R|NQ49Gb z}LffV}2B!xZY!{J?;bWUj3CP|hCoROvk z3v5tFN;z7Hi4e(H>Zqv@=~yA%v=Us3hPq`vfp|gIFF0V_fYo0Va}wAEFkhl8j4E(7 zf><9&9TL5^Nthl)WV|l2@APo|*Z4OD`ivBGhdJ@dlW`T)F>-uczPQ_O{4sXyWrE9w z!zY3o0NPEBG3s~kP~vLkgv>1OZg@2~5i;!cy)iTzw1@zf81o>=!eq4|a=SqY!iRa| z=uq!nOu(MlB!NPp_~4bsnN(`j=jkDHMQj%bD3uY?perj0fL>%lowIVNu#?(Q*vtWm zUg{i#X>pr#RJkuv&7ojgu&xEmpevCajb|~;SdiqzLg7Q*x`!E?dM7iGTxSl0qpX{@ zot9L3#Poa?cu$MdO5DkrH~c%4-s0-~g!>+|GZiB=pL(m9awavMK16|sV*-7Mewt}e zkujJ9Y(`N~J_%wGsA`gj{u@_AgBYs2pV}Sb%9~*h!I0YxO}EIUI3uny*hYy7mDZ}; zr>sNVPyvS2Q3zpM1kmr9g9E6k8LDS~9PNA0m|x*mESB))#Fs${TTl~(Oc2&WsOVq~ z=%>sTCZqbJW=#0d1gTLGQbVihjQ0>Oj`3{_*6EPMZk)W>E>6 z5Y>qxz<4HGO((7|eOrestZgp*_S;>J@<_CX41pD;eh)yxQ+D=E_{1Ufs^z_z=!?evwQQ zX04}X#a|!(8(~)-M!qn5HnmAF87=WwEs?eC2~Edh`P*l==}OWiepsqiT+kCV5I3w1 z)rNkP5vTcwi<4LI1zu~*nj4A{oV3EdH*`~v$Vm$#6zz7bVX}ro1oyDQ1i-u#&n9T# zfh+xqH77_4_^*`p<@V?8n*VEM_OAqgI=ilN(*6(g0J%}Gx@#{~^FL1}vQ}y&UH7<(kDFV3>%!ogpy}-P zV9vR3KM|>{eSdR$ej%cMZ2IqqVO$=A*A8c>aIAv zpc}6NxSWw_T1~jDY)!RN_y}K~D;C+8%|%yiB`TResl;x>l+!)>HWws|u*B+pezccy zp^*tzs8^M0$tM9iWf%jH)CfW|!`W(Ee37-<;ekESmdq8*ziMB9u(ROaTh*ckuPoIl zo5|A7E0rztFFkn@&0=jCi^wo5+}myK#~&wT&=(aGOO zAcmPk-8Ij<4#3Y9H#6kD8lRsRg|^M|s*+3f9OI)#lN5hFJMraza=)iPOOkK5u9LA6 zf`5vz(kv%>q<=TsfV|%fw9JWTbKLG1ZK%zl|5j-~nshSwgj9xf84abiA@gy%PU>9f zYxg*B%q`(uQ7TNFff^)Ja7oq_E|oWu?uo){zBa{}A5G(0VS9GQ@d20?Cwe3HVu|!m zmX`;jI~_Tmbg#MB$-~8tp4~S6f4lQ?+tf9%DWkX%=nW@GSPwUPqS}VG(BBfUVa5^- zapg4aiX?N9DR`Em=J6fTE`}wF6H_^k-aSR9$FKnMPbU4p4DnU!%%~{)I%w~&dFZRi zUC>uB4{|H#2s`5=EArSxn~@;H^AYJ(X1Zrlk2EsbRdx>^yugMOTJLl(4N1{^GDXp( z?ww-|D1Jk4fLj4Q zcZ7?>HP+^qH7jLIt^br_to`09c<>Lny5kR6fBP3GBJT4q>c)MCY1aEv!lMD`<)7$5 zb<)Y3kWips$P-9sI1K!Zj>T(SN4%H*@<1+dO`G+0KC+j81GB3YVa$RPpNZCxw5mPv z_a=L=cmy)zRyd!+wlg2(Gvb+&F!O;r*lNeP7FRzlLrWgd-A6$HugS}QiM-G7%zdmm zylL{iG-t0IVm+D&TN7#{cjhZS$fi_S9VT)L)t>Bd>kL_1!YeOAsr@(GC} zS7+ZA#)kPT%wfxSXaMw*HAoK+8vHBCO=M#>HMf~++Wo7|PxB54$EW1<;i~QfZUyGo zz(Cn)bqPc zM_|G~IX|0V*p90Q>LZoausH_~t;_@vKCs-Eh$sb~AOcfr?f4b#O$zc3GEc1{#?zI2 zvFn-rHc5|Z1CU0ggwHZYV{URYZmL>Qz{E};GJxMb2W4%B3!2b&=!toDO#qo;JTwC; z-p8!K_{pb>JjKt0!NtA7bl`&%t)Yp78#3?ctatch3R#L-)lUFQpeaS2B>^hEG~N}( z`L9ywZ>1e#kvniEux~#}DKUCmGm~c|bp4Y*2aX4AmWfifD`UH{DEuQ# z|K(-fQgGjCIMoy zD7;b3%`@ixQf)heNAC53XJ7#^PK;Z#Mt%~cNK0kzp7rEJU28+RNknf3stQw!aQFh)D2qs>6<9O9SIjd^q?CzUO^IS#ES>sU^s3+KysQscWLT zk!(lZFs)V?M1Y2kA>lYW+O{1DO4}~|`)EKI${*$CEKM9uw6V)LeN~`@#Sh4IukG-A z=~3kWuc}CxZK*aNFGL!o+-><(YOhz+;_+~Ya{cqZ|4s7e=0#n&{p)fqL~9xvbK|Wz zu)EC7j>=^yE5K@~diq`X%j)Jn;7n@h^)=uilZDfhjGHvSoL7hgtvfI`%=1x@5Iy6ny&U%=N}gQnk;%A{CK=mBY*o&+=EgmsjDb{4c6{~=*PO*{7cRr)2O|0%T}kBKdWDKN!jd5%^%$<0@GE^W7{ zGRVZU)_xJ^0CvbtnV8!WB_QMg@J%jClr(B=Vu$u>za<#3roV|8;L*TEx-u!n$?Iga z^6sf{ba+(sqxzw5_$VkCfE#FpH=ZJiE>L!m^pyp=1dUHphFHhsy0T_QBmK$|sI&a6 z;QrwL6qpSy(lYyzP(>u6*uDf7+pMoQYq)+t+pvAZig`0-K&xjKoK6{|mhaC!>3XAL z^-z$IzUCxL;UyRRq;J^Nn$FPNODc8TXqC_pi6^QtiN3l73Y=|dHpKhAm;8V$A;BRY zn;M}p-`S$i>`BM(f#()z#2r{friy9cxoYSBZrG?s^afn`HX6NmqOiWYB`2jCu(|rD zZEz0A6edwUea$?2`(TxB>mj&-@#ln`Ad)ukhpzg~?i`0PSBIl-9`wFx_OGAM(5CAJ zBTtniKC3qg@I(%JB#c(cZ@=NiUe>V;WKy?* z144@)RSdCl3ORVaZu8!ZF<;gu#PuHM;_lv0NsaPJ<>mF5?st$jUsY4=l0}Ke1N;MGL3Km=J^A*xazZ@#UR(Kd%?$JiZhF>_w zJTHCTl1|Wb?A!hz8g9M--!(;DZYmo!br}_R<-75l3Q2IjYLj$ zsm*b*nsl5tschUDXXngmFMO-s}T3b8VO=~uTS>ww$~p*2KGi10Z@oOQd7JU`Tj3fqeON3u_FAX0hh>W- zgM%;Q+i{plf_l(9>*GB6-ve(YZQ(n?@AF(oMX}~;zdTtKTTbl+@|%?v%BLq5G2(7g zdIykoE)rq9)BP|GhyJ%Qm0Qo}51n;fr7`M=sFl6paM)3=;w5u=F#fRUs={2&QlVN| zB39f|yD;JvtUuB-m1Ihocaejej7BEokU9Y85cb5&V&TW>mJ+4&Im?b&Z%uTbJW{njTo;-q2{6!?aQx>OW5=56mMVc!O?afw$ekV1)F_}X2_bpV7ridjUvu))_n*NB>46i7Aonz z_>Dll7XW76EGl~adAYI^aB>pN^!rclCN(bjdi8r$`H?nNSV~c2-z+P+`799CIK&EH z!Ceg-b8GtOiOemSSYOI&%zEc|E zbG}@)1+BMLS%x&q($^n!Y(42)`^mgsNJ(0|c)u&#dcdAl8QqX)! zzES%074W_hK1A^I$hPcD54@V2scI~BYSXqqZ;pRs2}N~l*$oYSTw))80hBj3WQ}Ue zJ|=~#RG@}}gBR^yQeg~a<^TJLgG9dzr7#iMqfY)(o6^n_hx<%T z2kq(u#L{U*VF-c2{Wtfbv*^CICtzKJ z=@!JjVLn#bOe!!MOm-bh-g+JLzk*bL1Q_M1u4HbvgK8{u$AVbuo z7$?I&i}v}Vgoi1*ITkcVg#ZLjURqUsp$44+{mNz^vV^_@1c5+Tyxra%iJFc*rvDo@}ZBQ@rP}01b zQ3uu@aNNANyrjj;udvtq*8PvramT`or5^R;fGpt4=v5J)8_}DV*E!38w_(|mNF(x7 z@Oi@CGWGm2`n%v3?#1Q%S?Ai%tgIf$vnHJ%Uq6rXnH}sRja6XeC?j_ySfjcDNo~}3 z>4)7o7&Xzx3NROx?NR-hmUJ=e6Gg3!6}3z@jQ@jo;p*B3Fb%EI6-AU)6_E@KMbZB+ z>JQ_>#T2y`Rn*eiFh;LO|1V6YYongP@$4F4QG}7`2);;5R?oEd(Mi=CHrA;B)k&cu zN2!h5AB~_XQBM=>jxofo4m(@b2h{MwTVt+EC%RwrD4uVlEN0wU4{n2i4)Sv_)Zgm7 zON4oX>!$uRKx=ZD+*LSAr*i)e_^6|;bMEAXDDw;FGd~U|0kkm@iS`(y2 z>&$Z-+-MQ}C8dBOylirRA#;q?%eSJ4BHMD3)P8)u;O~<{`#vpf8GMePaO+<<>}c4| z&KYFX>6A;a$!fe}O{NO$D2yyO{(MbMdmn;XS7IN|USaKVl9@PODe{FsBaxHQ^dj4M z7(>!c|FNIOFIThYvQl@gLN~dHPr_|$NVe0HoR}<1v)@@KAcMB%S7zXGOc5r2w`4f2 zThrhh(#@M}-ej-0+R-t(Z7Pq4XKJ;D(V(tP+ zGmJ50qex|+q*yoE4APC8pObAt@k3kuZKx^LNjeckbA|QxGJ?PV-3(c^L8G>k3-|Fn z)v%EW{v>PGW7QYVwI7F-snTZ!nRyx-_b%`^lbi!1B4RSGnHz)vz|@2{q+Tral;bQ9 zITKx$TS7*Qg!c08FfSB%vSwPgeCq;1(-W)#$iLf=w}ZA;qTS6_&CtNdL=GcJ)(cIK z?xC4F?0Hf+$n9jGv|H~C1OB1!xJ2oZZ)S6Be%(XYk{q1vvmrnq71RhUO<<&4VT&&t~mmh~mR(U6b?cc`{TrYw( zlJ#*1SSH_(Uq46gtd{UMAQol_Imcnvh^ex2X`+r7 zM`0}jRmL|~n5l=~l_00d5LBgbEYeuud!91}@iH(}Pb}=!?OABjIG1rm0n=o1D&_a( zEikPZQh3#LvdJORTBcTq<0poQm!kM=uv`~uk5_Xt%_x=Ru)K9ud-|a#Oakk5DwSB&muOqg zEgy42eR?=Wt!+~*HSHIssuX_ew8#LfxqnzLExW{@E@--gd@U?;idG(dj^gGoQh$vf ze+>vXy1S=u+zX=%kRB`~Zeq(oHq``9jt@+M5S91k&*?MG;5Lw53j!g>40B{aS3t(8 zyQ%GtWDWn^HMXe=V;YPmv8>O2JGc=s8kHOHj2(m5Uk*J;Qj|Q_y$<+Ut(y%fsD9pm(TE8%7iGZ$QaKcvb=NUsKFkLP(mNgJh7V=SkCzLM+gUC(?R|@9Ks~ z`e|~B7-nRjgg(JCL%h-QL^8mnX=C+vz`+-ZWB9IVVAk^t5{g#L^>+gf8#S0zj;gS2Zh*0<jYjD)AaakQ3{s=Or@|~1e56*u>szFDlNtuazEY%jk%k?R(}gr^M)Ep=r1xjrA?FbkGk%${Sp00Vk2cw_BzkggHNQavpU+ zoIUEB)X}M^3n$`*mW@;)&sSQJ-U&UHs zMKQV1b`jV0I!Nt&+b3QJYxE6-hs5GzGS?{=6wk9X z3R&mmL=-?8=W3^K_~ec2P%MR6hSSLugJ()A#?*yg6#Ch;B@Cy zGD92H>EB4RDLC~vvC#YtaV{RyzDJPg1q;+M%HW*U^ildP19>;k(!7St7KO#kZTW7S z2=-WF<+DIf^$1RW%R{YYbuBKAU)!+AfmS;3-LA=$Jb@Jet#GYpItHwKYdWzh zYTVzCDqpiBD>OY*KSqMS9Eq!-&Duh7+c-e;wrikbxoEpi+ci*o+AbHAB|FH0aYNDm zxXJ*YXF37QTMHYx3E*@gA6Qr~L)pM8z5+nQH@h^4EM<7q@mbTge8e9Fb1a}WGxfb=0$*YsO3p? zvMKG6u%m#yC?q&nKLLSj#y^c2L%;II9IQ*Qnv}K2dut0br|Cu+6%yb zG{LHX34rzyV?)9N(IYnS9(Bd?#;8zLJsU62?NQ$Yt1p!5@}i~%YYz$stIMa%Y?H=g z7^6PT!c(S7-DY%yS_(;%@sT*Hn57)HOivQm1Q@^!#hMsJ0R{ckktj+4(1J%yPWrtV z4g+Nnzn|8WONCEJ|D9o20SzNriXb0?1ahX|mOwdZkc|~(lQJ#8C6_m?2*lJ4Wl_gM zMS9X4A|Ky>zIpbQj8aYGY? zp2!H-WQ16_rRgIIKyeYhKWwC6ikz4>%*nLyGr2I44Brh$cBcmv4Xd{2`p3X%)KUwq z&@*K53S*@o$g?2~Rei^RF;~n`s9h#Y5hzT?sV)#6;7Z0yx~3mS1lB#U6+OZmT#QRV z$4kng2X>sQ%zGW!<1}4@#@;mrnA2@s%&9TFu zJ!Dd3H!Y#qBeqpW^W5&D0cLll7P_K^Ii@fg1qXK@j){9+N9<Y3;38owX;xy-Rakz0jwqA$&^@M{?gbYNf2?MO<-E36YI#1^9C{=|t#QH2 zb7DP$(+1KOCveFlV6~AqZ+HhUdZaI{#`BQHAztu~^&royTmJj+@&^7yG2&uo9I5A?TX3TH4O^N5~Z|@^K+$Z(q2xP$_riCjH88hHOT=j z0aSu3=Ug|iu+Kg2j+pBaR3vjf+C(=+4}H7~0M?NgEcYkj7LXS9xt@okc|oi%y+G6- z5>&vwzHavVTx{k}gacxQrQ@X=tD8S*nYa&FIk7F@)8(0TNdjSOC${i8oCtB6JMq!g zGJE2q4(!`O8@v3bxV2X1VstUd`D!+pQJw2Er~J!Sitf7brt>_n{z{V1_|;P^bgrj) zRMeT;O|kODd0|pqN&t$tJ%uSQ_p~Au{EJE6SBudDpB8iMt7$gli%+rmes3ktDqi^& znB8E!oBBGs=M(BwAAJf_9QCU*O!C$zERbCGDM0w`Q-F}St0^Gk!C#KSvK#+u3dwo_ zI9NDVW|X!hm;N#W0`+a#xqnLn4LBlBD|y+!UnG@|b=_Y|ab*AfH5n#5@iToCUi?H_ zgeyPE3x7V(ha)IWcqF^@FDDSyudhx5;n?SS3|A!iQ7-A`qMVh-Jj;Y zOgY+-mr>BA2tZn^2m=gP9wG{mz92#Y2|$VmByWgyHboGTfrOKp@Id+&E|Mvd8Yq}i z3Nv8>l~Gcl;0gldXhDi5LI(W(8_1`DxWP*Ljubq&n}Wth5O`atAriIJ%JwT!D1*_2 z8Ra#MCnP)*L4_5b7mD^;3K|G63>SDgwr~mgAc71jmK15o){}HqiZd*x09E3oh{K2) zM6_WU0f922*|!iQzLEuus$l}5YG@&? zO~e;gfD`t*5@bk75|IX8VWM@_SVJOCO28p$LW(-5;vK1a3#+1Ifsu9cHBplNf8h13b9B(fZs`+vNV`#i)u*Z^bXRwuQO=|&0}5=u&t<#^JHfDGR~ zh?vr4o|nDRDbj!sBW+2FE-i6L){8luOLAl>nY;txrE46VjWG@1Z%Cn~glZ9AO7j?G z%2trJG#FpHBo&;D?~fE>N}IErnS7QrDcvI6G-(beqp8G|Qji>6N{Ln?OeqOLh9vZw zB!iy`IHf(4qD~_Sk|R!O&D{*|d#VRl3P4>(fMndO%$4I%$;{3MqtyAD2}cd5T8Tuh z#;STS95r0jq)^oO$bbk!C2cB^DB%SXAt{waB`B3xy2B$=$&jnzDU~Ie@YG@o#61Pl zk_lF+{Y&>E~;4PIT_F<}n?dq(X5 z%tBX3S^Z|9Kx`&r*l1!a)*T4w*jSE-KT5<0RLh$>h*Vgi2g~= zsoZ`DdY0{Ewe4g`GxGB*53gKLqf8no1cz;%P^ZghS-#|FS;q7HUV6l3JeG3uMZ=RX z<6rucABY)`_Uq5dd~@_;ZrkazK#TS;<;@{&!T32k)piHD^y`n(d=bap#&;}x!sc^! z!Ul$s_7j*uz9CCb5IPb$@4k3^GU3s<5i?JxcCe?$#e4wb>pxY(D>X{9Vx&1 zXwQwK4%ME-$9uA*oa&s<{L{6!J?QiKQx+%#8!8;hjr(Iz()AcCeyhVlU+prlac&#N z*f)b?js8{d5Ex?ZM=-|Ns$JmAYm5j+KdPW@0~W+&Y0oYI($S)8yDVe@=zFoj4C2Gp ztjQ}(P3aK^!hh~MY)_puv>gOA3=(rhD82yd(hisxT90)?09G#z*0lQJw(~PG&9hc(uwtxp*8#3 z{%-9>tQ&NwsmaNQvKB0BTAeA-@7LE^3%STQ*H~ix^%|ePXFpH%8IHh#4|D)0vwZ)< zXbg=x-L$7iM+Y@*W#Tz3QQslwkUSVQ7drlXQWF~;i4ImPJMFg56{hZC+t!7 zzqSMBxejFXN0>L~aI|adRT5d$wxiJXVEYBr1$ITgqwU0Qb8U|}&^@;LXfT_?DA1B0 zfJ?`=q(JK*Q^G@6W6Qe+95OBDgil11`OmfFJQ)5u=8*+`_FV@=KQ1PQ;foOD$8$pL zI#(tG#^dzB*z~~I^uXB6^uXBkz}WP_*vE2U?4B@e;`1?Jh(V7A?7s0>>PA62YW6RC z%o*XM#jUwcE~buIjvnc=Lq%XkbV#TXpK45f8_d3SeGQn#jPAc2!gj!jjcH>Y!26FM zYDWa;`Inq9*u3b+tk%D<2vwGT^>Eu)doW{~?uqs?HgU9X_g)_CY#%-PF8i8v?CmQS z>Ri_1e`B2%_v4u8X)sq_)*kIYI?|+*Jzs!{#e^~0DJL7_>~>}7fx5d=UBEiVi2ePe z15L3ml#_OMa37<+3{AGqF^e#=gbVX6&)=*m<_P#y@!zg#eyoI&c zno{kx4X$#( zVrEs$93NEb8Ge57ej3b}?1H(O?7eF2h+($u6lV=TPe}u9X@+L9an7iW`$0m>WXw~X zP`p*^0Cz`hh~+bj*J2G64^*x8d|eFi{aV}sZ9i3Z(%v)E{g3-}<0I)IX2wzEGqWQw!%SjnW1Xq$G0OF1S55qI9VR9$ zt%er=W!3xGE>k~NBu%cnN5YoWBoC9)($~8Zt?W3aMs2p|W$$E2Kh+7%%SS(I4}4IN za{TBthc!QW>6mQ602?S#qlrflUpxEx&3nvG0zCmf#|(@&s>#^2gi(5igPorr#@jsY zvClT_QEQkN{2d(lywfX=7u&n9;8krK_&DI!lWKf-2SjhZqRkrE9UwjF21}BPFCRI& z-}jhMjzjxx&y)V~QR2>FOBnjEW1lZKGzMJXXFPR!=co8!sb)$8pjd^gDZ(KI>7rd^ z`IQu&n*1|rY=7y1LT!!^;&%a9fxafkKE!V+rl2!{mY=4-pZT!JdTY?R%E-A0@i~h5 zduGOmNaSxmcRpsNbsE~=p#m9b?tGQgX?pkJ&7k)$bieJo{8p`)p$w`>O=uASgya=+s?h%+u!Dp%k>@7rH!Kw`w=+@F4k+?2aVdJu}E>N`D$@< zEY|h{d(k^$sOfx&!K+MAYnrs<%a6U5`3k;?e}O5rvy>g z>f47uG)S8|dS4Lh6v8!!hU|ip@7D|Y!bW91zp)`~?=R{PtcV83{l>wA=g%L$t{;%d zYCQJI8%oC#kpa&98v|agKltVU_`m$$#u2f9`QJFE3-#ScwI^q(j*rYk*JmfzoyH#Z zbyJjlSASJ}*my;o+nyIRUb#LyN7s1byOH<0{;&hwZ5+}j^~15`uGgRa^8b9`7`z#I z@FthZL*lf;*Y%p~bxhi*!ALpB)RJZQm^Kbf8u}!7LymcUck7S+U;e}Rb=ww=1(ls0ST|gd z()0@-@$akOeNCqy=0sZ*w^U!mx%)G&)E~Ib#*f5l{6w5lg2G2)hk3$`#v|ymMUJUD z5*t<2Fw1o|?u}X}IrZZUd<&vDsSXD;8y)9ae~~A$-ctZ*j{TqHK`}2@&MbCQ#r9r!W7(j zvDD~Gh68WUtct%X;b^Vo@du%qgEz2a1PR9+_FvWKInH~3SD__OF-KiTs zX@xl(klEM-?CUr=quUgt_t0X;%>tO3L1;4eCLPy?$V+zb{o%4$LP40EvC;wJP=P^!!W7f!J(#wwbXQw#t*{5yusN`2+c>c-hM z`sMl~1IE;M*cS*U>;7V~vZ(+{1u>ATunL066VnG)Q(1RRG%AwH%NuIt)s0f+?1M3K zF}@7)9XW2}$h8U1w%f@B&u{#heP;~(i(SUt)T->g-<{7QC>Q+gezr~Bia$fCdwNx#<&72!K1GYBvS%7L5mA1A9 z0ELl&U#Y=vq(fC>ACAk#AE=$&hf2OuJ$v_)Neg-dS_-{NI5#3uAK%jvC{B-lAJ4s_T@k(}dqwJ}UNwWUtM%0^}U26)6$`82i?8xK1K z6v{hV(#`{OVEZsqRgbn7wEAw_A-V}>jtfenZMtCCvQMBjb{;f#9bGI&&s++Ir)AKl z4}Gyb5ZaO-?kPd~O7e|oY}3)yEveIpp~%BD_&&GFm91glaWztLN*Z#$vufcgK5 zSjUs$i9e!TR2@r&LO~69R<;To;{kFV_fz+Xp}UUV&&8i5lAI&C4cy>-Uw;J5aKo_i zz=yF?-5pM3d#SG>cIzn)p0QlGjs6)JnJDb!T=pR--#kxQ8i-r`wVr%)QF7Kdw*Am- z5goc~vTqf)v%XjLD~%cp8fy79$+uQrL&3XMe`OwruHX2fM?5nyY0uQ(jPctXb(mkT z@su=aI3l3=1$W4GB0v6W))1H0={MeL-H8igYeW6@WVM_h?;%R}#G9qeY$Yo|?|FMOmoGKW;qiP)Q7*0p@{w z97m7F)qgkTaktye^=K2nn3!XqnB+)ThI-+LL(}mP3dq%8Y}a;c4K^1%<1@f!z2Gq+*1C@=}_2fhTx#Yf$9Mfy*4JxtQHW#`%e%YGJ^v#Wu z81HB7<93aQ>`QWz*YQ!eO+iEtSb&Yb0sW!QjY1_q5^y%znAB9cD%J_^6SvcfbAb(A z&DjBAeYFiTe#t3qY-S@Th3ZJas8|gP+CDKYDQG+N=Mo!(+A;ZHXrrb_VQA4N{NDgA z9Kgghqw&7VoAvFcPddZ~S%7|nay=fe0n*q_r8E+7YF-Yl|C@RZ)}|hT?mPu~3rQO^ zRxPA0;<$~Uh^}``-?eZt{3Q1I7q^OHl_`t(&d}0~M?GI22>-TW;qJJtRxbWvW=_Pu zN9&E)iy6yCv6L4Qn7G)V(;kVhg*Y}dLQzu1rdY|J!j3AG%c^h{idA*eR0>r|p=M)I znSm>h2NX6Z{BY|O%jY+-F3SUF>bu+f+u~B2$aiw$I-3d8`G?3cJ0MYw8aXC5*jCw9 z$!3?A!K`p|=~ptD1)z2&Ul_k)uhgHJcH^h0DU?fz*G{@VIX2k`){{?WLhV+3L)B}n zIt}Zn>qB+3f;#(VeXoDq4@u)+Xg2_JiuUOT;?^Aar3#-Om5~@s#Rp&*?!1Yb?B`cw z1-AwUeB=2V2Yi6a}7fN|06!q#{|S(3Cd zE76#uv;07h|KuPR#EnewcLZQ&W|{rG^xq&ceWuU!nLg9!zs55&Gj{?0`(3&y%qJIX z#^()YE~dccmxsIYZ?5qg&&4BZvpX;FL)AMp(0$XBzQ?{$i#Lwk{C-6(tMP*amPaG5 zE%K!66_)UO@|=wQ_>vKowk6-~t#SG;!*hXk;2;0^`@d&9p<5*2o#4P_cDch^i)}$6 z_xH>zx0x~8U>6TIk_~TzeYd<}G-qaJZ$SBMTHF6j@n`cJ8zPw($%07Y_s9zZw;*r} z0=FRJmPE2Fk`^L`gJJ5>1pu6D7HcEllP`YkARHUbL1Mt>r~)dC^*4w3ZjG2a3nEz*$&yHxMY1B2Rgpv*%7SNQ;F&7Ci|lSx z(~0}e z2E~I+#MM}L;~uhGLObk?LK5i6HhVRtSYvnexKSv{X3H|Mb8}C`H6&M`Q>PtvvNhc} z@Z*d9%($7y#I&&J8ovej$aS^n#K+4sF2N#{09};qPhL7fvMj-9@5R?=9Ep2uZXL!K z4zmu|phH2+lzM#q(TT@y;v1wOJHR*g%pe&(njN%TFC8zLZSiG9s$4HTXLn6tzmhhz z9qKVhhl3a0EwMhuGn9||ORwz{gJzj_OJQ23@EWUSk2rl!AzpvM2kj}$C+cgD*?EFs zfV+1={O~eY5HIaHZNp4Gq|8Ua>$;U52eHztJhVr?k9Ut=WqjUc7yK}hMZ#iHe*zk& zhZpAENbe5Pq&9gaDP~5*K4Z%~-W(kdC?EC|vBGG2OQ>9@Jhue{}R{2QTp9ml%zjGOGT* zGx%Hed|Cc6`zQp}-&rWJ2%Nt`K7;!J50XG&`m1faCGISF9`qso&QRi4DC@+3x; zCo!r#iBaWAj4DrJRCyAk%7Rg!jbhZsM2!4IjKV~W;zW$nM2zx8jLJle>O_pqi5L@k zTA0Ywg6ahxP!0ot%~Ex8rK&!ulsC&~1XQbq2|`<$G_xv`W>#g=%&JV9S(QmMtFo4H zKo_>knI{2i zoJl+dbIf3yVGa~90NIN(v4?$Tg;}2IJ6F=iuQMBl85PVVVpb@#KbXzHSjZ#_o-de9 z1Wta-@x-NJm10dM|l1O&!6F8ACXvtX9FI#AuPaC zgr~&V3QrZDO?bYC=fA`AKhl2vFL<`$c>vEtcy{1<1kYo5p2D-6@M4ZL^K|}}&*J?; z!)*=tTmoR@>dbVrI^C>JH>=2?>1K7hS^ao6tIFa!^_b60J?0;y$NcZ?`TrLOdO+>Q F004d4*g*gQ From b75cd644899841796255da9ed09f16dab5fa70fa Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 5 Aug 2024 06:19:26 +0000 Subject: [PATCH 444/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86978 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 3a13422b770..976e2b2dada 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -197,6 +197,11 @@ person_field_names <- function(x, i, j) { y <- unclass(x)[i] + if(!all(ok <- lengths(y) > 0L)) { + warning(gettext("subscript out of bounds"), + domain = NA) + y <- y[ok] + } if(missing(j)) { class(y) <- class(x) } else { @@ -229,7 +234,7 @@ function(x, i, j, value) { y <- unclass(x) if(missing(j)) - y[i] <- as.person(value) + y[i] <- if(is.null(value)) NULL else as.person(value) else { j <- match.arg(j, person_field_names) s <- seq_along(x) @@ -255,7 +260,7 @@ function(x, i, j, value) i <- s[[i]] y <- unclass(x) if(missing(j)) - y[i] <- as.person(value) + y[i] <- if(is.null(value)) NULL else as.person(value) else { j <- match.arg(j, person_field_names) if(j == "role") @@ -269,9 +274,12 @@ function(x, i, j, value) .person_elt_fld_gets <- function(x, j, v) { - x[[j]] <- if(.is_not_nonempty_text(v)) - NULL - else as.character(v) + x[j] <- list(if(.is_not_nonempty_text(v)) + NULL + else as.character(v)) + if(all(vapply(x, is.null, NA))) + stop(gettext("must have some non-empty fields"), + domain = NA) x } @@ -769,7 +777,8 @@ function(x, i, j, drop = TRUE) i <- s[i] y <- unclass(x)[i] if(!all(ok <- lengths(y) > 0L)) { - warning("subscript out of bounds") + warning(gettext("subscript out of bounds"), + domain = NA) y <- y[ok] } if(missing(j)) { @@ -813,7 +822,7 @@ function(x, i, j, value) { y <- unclass(x) if(missing(j)) { - y[i] <- as.bibentry(value) + y[i] <- if(is.null(value)) NULL else as.bibentry(value) } else { stopifnot(is.character(j), length(j) == 1L) @@ -839,7 +848,7 @@ function(x, i, j, value) i <- s[[i]] y <- unclass(x) if(missing(j)) { - y[i] <- as.bibentry(value) + y[i] <- if(is.null(value)) NULL else as.bibentry(value) } else { stopifnot(is.character(j), length(j) == 1L) From 99aa8ffcf90325559acbd451c756010c0287941d Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 6 Aug 2024 15:58:08 +0000 Subject: [PATCH 445/546] report clang warning of undefined behaviour git-svn-id: https://svn.r-project.org/R/trunk@86981 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 137c9b68d6d..b82df42da54 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -1261,7 +1261,7 @@ add_dummies <- function(dir, Log) msg <- c("Source(s) listed in 'build/vignette.rds' but not in package:", strwrap(sQuote(elts[miss]), indent = 2L, exdent = 2L)) printLog0(Log, paste(msg, collapse = "\n"), "\n") - } + } elts <- db[keep, ]$R miss <- (nzchar(elts) & !file.exists(file.path("inst", "doc", elts))) @@ -1271,7 +1271,7 @@ add_dummies <- function(dir, Log) msg <- c("R code(s) listed in 'build/vignette.rds' but not in package:", strwrap(sQuote(elts[miss]), indent = 2L, exdent = 2L)) printLog0(Log, paste(msg, collapse = "\n"), "\n") - } + } if(!any) resultLog(Log, "OK") } @@ -2995,7 +2995,7 @@ add_dummies <- function(dir, Log) } bad <- bad | grepl("^fig.*[.]pdf$", files) badf <- files[bad] - + dirs <- basename(list.dirs(doc_dir, recursive = FALSE)) badd <- dirs[dirs %in% c("auto", "Bilder", "fig", "figs", "figures", "Figures", "img", "images", "JSSstyle", @@ -5957,6 +5957,7 @@ add_dummies <- function(dir, Log) ## Apple and LLVM clang " warning: switch condition has boolean value \\[-Wswitch-bool\\]", + " warning: .* \\[-Wembedded-directive\\]", ## LLVM flang warnings: ## Includes Hollerith constants From 01dffff2f316a73625fac5f606d43673cdecfc5c Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 7 Aug 2024 05:54:58 +0000 Subject: [PATCH 446/546] Improve URLs. git-svn-id: https://svn.r-project.org/R/trunk@86982 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/connections.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/base/man/connections.Rd b/src/library/base/man/connections.Rd index e9ff0bef2f5..c0bc2c63ee7 100644 --- a/src/library/base/man/connections.Rd +++ b/src/library/base/man/connections.Rd @@ -536,7 +536,7 @@ socketTimeout(socket, timeout = -1) #endif #ifdef unix in mode \code{"r"} only. This reads the X11 primary selection (see - \url{https://specifications.freedesktop.org/clipboards-spec/latest}), + \url{https://specifications.freedesktop.org/clipboard-spec/latest}), which can also be specified as \code{"X11_primary"} and the secondary selection as \code{"X11_secondary"}. On most systems the clipboard selection (that used by \sQuote{Copy} from an \sQuote{Edit} menu) can From 64303c15cedeac241208d08146dfdf782344f1eb Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 7 Aug 2024 05:55:41 +0000 Subject: [PATCH 447/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@86983 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/citation.R | 37 +++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/library/utils/R/citation.R b/src/library/utils/R/citation.R index 976e2b2dada..2371bfa4981 100644 --- a/src/library/utils/R/citation.R +++ b/src/library/utils/R/citation.R @@ -564,16 +564,25 @@ function(x, ...) toBibtex.person <- function(object, escape = FALSE, ...) { - object <- vapply(object, function(p) { - br <- if(is.null(p$family)) c("{", "}") else c("", "") - s <- format(p, include = c("family", "given"), - braces = list(given = br, family = c("", ","))) - if(isTRUE(escape) && - (Encoding(s <- enc2utf8(s)) == "UTF-8")) - tools::encoded_text_to_latex(s, "UTF-8") - else s - }, "") - paste(object[nzchar(object)], collapse = " and ") + y <- vapply(object, + function(p) { + br <- if(is.null(p$family)) + c("{", "}") + else c("", "") + s <- format(p, include = c("family", "given"), + braces = list(given = br, + family = c("", ","))) + if(isTRUE(escape) && + (Encoding(s <- enc2utf8(s)) == "UTF-8")) + tools::encoded_text_to_latex(s, "UTF-8") + else s + }, + "") + y <- y[nzchar(y)] + if(length(y)) + y <- paste(y, collapse = " and ") + class(y) <- "Bibtex" + y } .expand_ORCID_identifier <- @@ -1369,11 +1378,11 @@ function(object, escape = FALSE, ...) if(length(object)) { object$.index <- NULL - rval <- head(unlist(lapply(object, format_bibentry1)), -1L) + y <- head(unlist(lapply(object, format_bibentry1)), -1L) } else - rval <- character() - class(rval) <- "Bibtex" - rval + y <- character() + class(y) <- "Bibtex" + y } sort.bibentry <- From fe3920356cec361fe8bfd58dfe2761b9829770bb Mon Sep 17 00:00:00 2001 From: maechler Date: Wed, 7 Aug 2024 11:29:29 +0000 Subject: [PATCH 448/546] add more API entries for Lapack git-svn-id: https://svn.r-project.org/R/trunk@86984 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 8 +- doc/manual/R-exts.texi | 99 ++++++++-------- src/include/R_ext/Applic.h | 31 +++-- src/include/R_ext/Error.h | 11 +- src/include/R_ext/Lapack.h | 207 ++++++++++++++++++++++++++++++---- src/library/tools/R/sotools.R | 13 ++- 6 files changed, 272 insertions(+), 97 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 20e5a9265db..d8f440c953e 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -159,6 +159,10 @@ upgraded to \samp{WARNING}s in preparation for removing declarations and, where possible, hiding these entry points. + \item The set of Lapack (double and complex) routines in API headers + \file{R_ext/Lapack.h} and \file{R_ext/Applic.h} has been extended, + mostly to routines actually in use from packages. + \item Additional non-API entry points added to those reported by \command{R CMD check}: \code{IS_LONG_VEC}, \code{PRCODE}, \code{PRENV}, \code{PRVALUE}, \code{R_nchar}, @@ -197,12 +201,12 @@ \item \code{stem()} correctly formats also in cases where rounding up, e.g., from 9.96 to 10 needs more digits; thanks to \I{Ella Kaye} and \I{Kelly Bodwin}, fixing \PR{8934} during - \sQuote{\I{R Dev Day}} at \I{useR!2024}. + \sQuote{\I{R Dev Day}} at \I{useR!2024}. \item \pkg{tools}' \code{toTitleCase()} now works better, fixing \PR{18674}, thanks to \I{Shannon Pileggi}, \I{Sarah Zeller}, \I{Reiko Okamoto}, and \I{Hugo Gruson}'s \sQuote{\I{R Dev Day}} - effort. + effort. \item Printing matrices (typically with many rows and or columns) now also omits columns when desirable according to option diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index e8b83d95cdf..69fbc1ef0c1 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -616,7 +616,7 @@ hence not available automatically along with it). Many packages using suggests and so the user package needs to do so too and include this in @samp{VignetteBuilder}. -@c This included latin2 but we now know musl does not support it. +@c This included latin2 but we now know musl does not support it. @c DESCRIPTION field Encoding If the @file{DESCRIPTION} file is not entirely in @acronym{ASCII} it should contain an @samp{Encoding} field specifying an encoding. This is @@ -685,8 +685,8 @@ codes. An @samp{RdMacros} field can be used to hold a comma-separated list of packages from which the current package will import @file{Rd} macro definitions. These package should also be listed in @samp{Imports} -(or @samp{Depends}). The macros in these packages will be -imported after the system macros, in the +(or @samp{Depends}). The macros in these packages will be +imported after the system macros, in the order listed in the @samp{RdMacros} field, before any macro definitions in the current package are loaded. Macro definitions in individual @file{.Rd} files in the @file{man} directory are loaded last, and are @@ -1543,7 +1543,7 @@ namespace). If you are not using @samp{LazyData} and either your data files are large or e.g., you use @file{data/foo.R} scripts to produce your data, loading -your namespace, you +your namespace, you can speed up installation by providing a file @file{datalist} in the @file{data} subdirectory. This should have one line per topic that @code{data()} will find, in the format @samp{foo} if @code{data(foo)} @@ -1897,7 +1897,7 @@ config --help} for details. If you do, it is essential that you use both the command and the appropriate flags, so that for example @samp{CC} must always be used with @samp{CFLAGS} and (for code to be linked into a shared library) @samp{CPICFLAGS}. For Fortran, be careful -to use @samp{FC FFLAGS FPICFLAGS} for fixed-form Fortran and +to use @samp{FC FFLAGS FPICFLAGS} for fixed-form Fortran and @samp{FC FCFLAGS FPICFLAGS} for free-form Fortran. As from @R{} 4.3.0, variables @@ -1929,7 +1929,7 @@ AX_BLAS([], AC_MSG_ERROR([could not find your BLAS library], 1)) @end example @noindent Note that @code{FLIBS} as determined by @R{} must be used to ensure that -Fortran code works on all @R{} platforms. +Fortran code works on all @R{} platforms. @strong{N.B.}: If the @command{configure} script creates files, e.g.@: @@ -2692,7 +2692,7 @@ PKG_LIBS = -LCsdp/lib -lsdp $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB): Csdp/lib/libsdp.a -Csdp/lib/libsdp.a: +Csdp/lib/libsdp.a: @@(cd Csdp/lib && $(MAKE) libsdp.a \ CC="$(CC)" CFLAGS="$(CFLAGS) $(CPICFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)") @end smallexample @@ -2899,7 +2899,7 @@ version 14.1. @c (search for `Oracle Developer Studio 12.6: Fortran User's Guide' and @c look for Ā§4.6). @c Intel Fortran had full Fortran 2008 support from version 17.0, and some -@c 2018 support in version 16.0 and more in version 19.0. +@c 2018 support in version 16.0 and more in version 19.0. Modern versions of Fortran support modules, whereby compiling one source file creates a module file which is then included in others. (Module @@ -3952,7 +3952,7 @@ placing them in the @file{inst/doc} hierarchy of the source package or by using calls to @code{system.file()}. All other files needed to re-make the vignettes (such as @LaTeX{} style files, Bib@TeX{} input files and files for any figures not created by running the code in the -vignette) must be in the vignette source directory. @code{R CMD check} +vignette) must be in the vignette source directory. @code{R CMD check} will check that vignette production has succeeded by comparing modification times of output files in @file{inst/doc} with the source in @file{vignettes}. @@ -6073,7 +6073,7 @@ conflicts with @code{std::make_unique} from C++14 and @code{std::byte}, @item In C++ code @example -using namesapace std; +using namesapace std; @end example @noindent is not good practice, and has caused platform-dependent errors if @@ -8434,7 +8434,7 @@ will expand to \Sexpr[results=rd]@{tools:::Rd_expr_PR(1234)@} @end example @noindent -when parsed. +when parsed. Some macros that might be of general use are: @ftable @code @@ -9160,8 +9160,8 @@ For example > summary(women) Called from: summary.data.frame(women) Browse[1]> ls() - [1] "digits" "i" "lbs" "lw" "maxsum" "ncw" "nm" "nr" - [9] "nv" "object" "sms" "z" + [1] "digits" "i" "lbs" "lw" "maxsum" "ncw" "nm" "nr" + [9] "nv" "object" "sms" "z" Browse[1]> maxsum [1] 7 Browse[1]> c @@ -9336,7 +9336,7 @@ something like options(expressions=500) @end example -@noindent +@noindent and re-run the example showing the error. Sometimes there is warning that clearly is the precursor to some later @@ -10028,10 +10028,10 @@ Other useful flags include @noindent which causes the first report to be fatal (it always is for the @code{unreachable} and @code{return} suboptions). For more detailed -information on where the runtime error occurs, using +information on where the runtime error occurs, using @example -setenv UBSAN_OPTIONS 'print_stacktrace=1' +setenv UBSAN_OPTIONS 'print_stacktrace=1' @end example @noindent will include a traceback in the report. Beyond that, @R{} can @@ -10503,7 +10503,7 @@ the dylibs including those in packages. It may be simplest to attach the debugger to a running process (see above). Specifically, run @R{} and when it is at the prompt just before -a command that is to be debugged, at a terminal +a command that is to be debugged, at a terminal @example ps -ef | grep exec/R @@ -10767,7 +10767,7 @@ package writers using the same symbol name, and such name clashes are normally sufficient to cause @R{} to crash. (If it is not present and the call is from the body of a function defined in a package namespace, the shared object loaded by the first (if any) @code{useDynLib} -directive will be used.) +directive will be used.) @c However, prior to @R{} 2.15.2 the detection of the correct namespace is @c unreliable and you are strongly recommended to use the @code{PACKAGE} @c argument for packages to be used with earlier versions of @R{}. @@ -11785,7 +11785,7 @@ ignored. Since @R{} 4.2.0, @file{Makevars.ucrt} will be used in preference to @file{Makevars.win} and @file{src/Makefile.ucrt} will be used in preference to @file{src/Makefile.win}. For past experiences of building DLLs with a variety of -compilers, see file @samp{README.packages}. +compilers, see file @samp{README.packages}. Under Windows you can supply an exports definitions file called @file{@var{dllname}-win.def}: otherwise all entry points in objects (but not libraries) supplied to @code{R CMD SHLIB} will be exported from the @@ -12274,7 +12274,7 @@ pointer to a structure with typedef @code{SEXPREC}. Think of this structure as a @emph{variant type} that can handle all the usual types of @R{} objects, that is vectors of various modes, functions, environments, language objects and so on. The details are given later -in this section and in +in this section and in @ref{R Internal Structures, , , R-ints, R Internals}, but for most purposes the programmer does not need to know them. Think rather of a @@ -12327,8 +12327,8 @@ stack-based, so @code{UNPROTECT(@var{n})} unprotects the last @var{n} objects which were protected. The calls to @code{PROTECT} and @code{UNPROTECT} must balance when the user's code returns and should balance in all functions. @R{} will warn about -@code{"stack imbalance in .Call"} (or @code{.External}) if the -housekeeping is wrong. +@code{"stack imbalance in .Call"} (or @code{.External}) if the +housekeeping is wrong. Here is a small example of creating an @R{} numeric vector in C code: @@ -12422,7 +12422,7 @@ protecting objects, certain rules have to be followed: @itemize -@item +@item Pointer-protection balance. Calls to @code{PROTECT} and @code{UNPROTECT} should balance in each function. A function may only call @code{UNPROTECT} or @code{REPROTECT} on objects it has itself protected. Note that the pointer @@ -12537,7 +12537,7 @@ Among the important internal @code{SEXPTYPE}s are @code{LANGSXP}, @code{CHARSXP}, @code{PROMSXP}, etc. (@strong{N.B.}: although it is possible to return objects of internal types, it is unsafe to do so as assumptions are made about how they are handled which may be violated at -user-level evaluation.) More details are given in +user-level evaluation.) More details are given in @ref{R Internal Structures, , , R-ints, R Internals}. Unless you are very sure about the type of the arguments, the code @@ -12886,7 +12886,7 @@ and enables us to say @end example This code only works for names that are ASCII (@pxref{Character encoding -issues}). +issues}). @node Handling character data @subsection Handling character data @@ -13151,7 +13151,7 @@ Some additional predicates: @group Rboolean isBlankString(const char *); Rboolean Rf_StringBlank(SEXP); -Rboolean StringFalse(const char *); +Rboolean StringFalse(const char *); Rboolean StringTrue(const char *); int IS_LONG_VEC(SEXP); int IS_SCALAR(SEXP, int); @@ -13951,7 +13951,7 @@ Here is the complete C code which we will explain section by section. @example @group -#include +#include #include #include /* for DBL_EPSILON */ @@ -14403,7 +14403,7 @@ Package @CRANpkg{RODBC} uses external pointers to maintain its connections open at once, and the status information for each is stored in a C structure (pointed to by @code{thisHandle} in the code extract below) that is returned @emph{via} an external pointer as part of the -@pkg{RODBC} +@pkg{RODBC} `channel' (as the @code{"handle_ptr"} attribute). The external pointer is created by @@ -15390,7 +15390,7 @@ in C code (@pxref{Registering native routines}). For example @example init.c:10:13: warning: type of 'vsom_' does not match original declaration [-Wlto-type-mismatch] - extern void F77_NAME(vsom)(void *, void *, void *, void *, + extern void F77_NAME(vsom)(void *, void *, void *, void *, void *, void *, void *, void *, void *); vsom.f90:20:33: note: type mismatch in parameter 9 subroutine vsom(neurons,dt,dtrows,dtcols,xdim,ydim,alpha,train) @@ -15440,7 +15440,7 @@ which gives @example void rmsg_ (char *msg, size_t msg_len); @end example -@noindent +@noindent (where @code{size_t} applies to version 8 and later). We could re-write that portably in C as @example @@ -15454,7 +15454,7 @@ void F77_NAME(rmsg)(char *msg, FC_LEN_T msg_len) char cmsg[msg_len+1]; strncpy(cmsg, msg, msg_len); cmsg[msg_len] = '\0'; // nul-terminate the string, to be sure - // do something with 'cmsg' + // do something with 'cmsg' @} @end example @noindent @@ -15474,12 +15474,12 @@ void F77_NAME(rmsg)(char *msg, FC_LEN_T msg_len) char cmsg[msg_len+1]; strncpy(cmsg, msg, msg_len); cmsg[msg_len] = '\0'; - // do something with 'cmsg' + // do something with 'cmsg' @} #else void F77_NAME(rmsg)(char *msg) @{ - // do something with 'msg' + // do something with 'msg' @} #endif @end example @@ -15564,7 +15564,7 @@ the character length(s) from C to Fortran. A portable way to do this is # define FCONE #endif ... - F77_CALL(dgemm)("N", "T", &nrx, &ncy, &ncx, &one, x, + F77_CALL(dgemm)("N", "T", &nrx, &ncy, &ncx, &one, x, &nrx, y, &nry, &zero, z, &nrx FCONE FCONE); @end example @noindent @@ -15756,7 +15756,7 @@ void rmultinom(int n, double* prob, int K, int* rN) @end example @noindent where @code{K = length(prob)}, -@iftex +@iftex @tex $\pi :=$ @code{prob[]}, @end tex @@ -15836,7 +15836,7 @@ function, which is the derivative of @code{lgammafn}. In other words, @code{trigamma(x) == psigamma(x,1)}, etc. The underlying workhorse, @code{dpsifn()}, is useful, e.g., when several derivatives of @eqn{\log\Gamma=, log Gamma=}@code{lgammafn} are desired. It computes and -returns in @code{ans[]} the length-@var{m} sequence +returns in @code{ans[]} the length-@var{m} sequence @eqn{(-1)^{k+1} / \Gamma(k+1) * \psi^{(k)}(x), (-1)^(k+1) / gamma(k+1) * psi(k;x)} for @eqn{k = n \ldots n+m-1, k = n ... n+m-1}, where @eqn{\psi^{(k)}(x), psi(k;x)} is the @I{k-th} derivative of @eqn{\psi(x), Psi(x)}, i.e., @@ -15896,7 +15896,7 @@ as @R{}) for the cases where @var{x}, @var{y} or @var{i} are 0 or missing or infinite or @code{NaN}. @code{pow1p(@var{x}, @var{y})} computes @code{(1 + @var{x})^@var{y}}, accurately -even for small @var{x}, i.e., @eqn{|x| \ll 1, |x| << 1}. +even for small @var{x}, i.e., @eqn{|x| \ll 1, |x| << 1}. @end deftypefun @apifun log1p @@ -16444,7 +16444,7 @@ A @code{NULL} prefix or extension is replaced by @code{""}. Note that the return value is dynamically allocated and should be freed using @code{R_free_tmpnam} when no longer needed (unlike the system call @code{tmpnam}). Freeing the result using @code{free} is no -longer recommended. +longer recommended. @end deftypefun @apifun R_atof @@ -16989,7 +16989,7 @@ above (no longer maintained) @item @file{Rversion.h} @tab @R{} version information @item @file{Rinterface.h} @tab for add-on front-ends (Unix-alikes only) @item @file{Rembedded.h} @tab for add-on front-ends -@item @file{R_ext/Applic.h} @tab optimization and integration +@item @file{R_ext/Applic.h} @tab optimization, integration and some Lapack ones) @item @file{R_ext/BLAS.h} @tab C definitions for BLAS routines @item @file{R_ext/Callbacks.h} @tab C (and R function) top-level task handlers @@ -17100,17 +17100,17 @@ functions that should be used instead: @item REAL0 @itemx COMPLEX0 Use @code{REAL} and @code{COMPLEX}. -@item STRING_PTR -@itemx DATAPTR +@item STRING_PTR +@itemx DATAPTR @itemx STDVEC_DATAPTR Use @code{STRING_PTR_RO} and @code{DATAPTR_RO}. Obtaining writable pointers to these data can violate the memory manager's integrity assumptions and is not supported. @item isFrame Use @code{isDataFrame}, added in @R{} 4.5.0. -@item BODY -@itemx FORMALS -@itemx CLOENV +@item BODY +@itemx FORMALS +@itemx CLOENV Use @code{R_ClosureBody}, @code{R_ClosureFormals}, and @code{R_ClosureEnv}; these were added in @R{} 4.5.0. @item ENCLOS @@ -17226,7 +17226,7 @@ have been copying their definition and directly accessing the bits in memory. The structure of the object header is, however, internal to @R{} and may have to change in the future. -@code{IS_ASCII} can be replaced by @code{charIsASCII}, added in @R{} 4.5.0. +@code{IS_ASCII} can be replaced by @code{charIsASCII}, added in @R{} 4.5.0. It can also be replaced by code that checks individual characters (bytes). Information provided by the other macros is available via function @@ -17244,7 +17244,7 @@ which should be rarely since @R{} >= 4.2.0 (UTF-8 is used as native encoding on most systems running R). Several packages use the encoding information to find out whether an -internal string representation visible via @code{CHAR} is UTF-8 or latin1. +internal string representation visible via @code{CHAR} is UTF-8 or latin1. @R{} 4.5.0 provides functions @code{charIsUTF8} and @code{charIsLatin1} for this purpose, which are safer against future changes and handle also native strings when running in the corresponding locale. Note that both will be @@ -17773,7 +17773,7 @@ invocation of @command{make}, see @ref{Writing portable packages}. all: $(MAKE) -f "$@{R_HOME@}/etc$@{R_ARCH@}/Makeconf" -f Makefile.inner @end example - + Additional flags which @code{$(MAIN_LINK)} includes are, amongst others, those to select @abbr{OpenMP} and @option{--export-dynamic} for the GNU linker on some platforms. In principle @code{$(LIBS)} is not needed @@ -18310,7 +18310,7 @@ int main (int argc, char **argv) Rp->ShowMessage = askok; Rp->YesNoCancel = askyesnocancel; Rp->Busy = myBusy; - + Rp->R_Quiet = TRUE; /* Default is FALSE */ Rp->R_Interactive = FALSE; /* Default is TRUE */ Rp->RestoreAction = SA_RESTORE; @@ -18542,5 +18542,6 @@ front ends and other forms of embedding @R{}. @bye @c Local Variables: *** -@c mode: TeXinfo *** +@c mode: texinfo *** +@c TeX-master: t *** @c End: *** diff --git a/src/include/R_ext/Applic.h b/src/include/R_ext/Applic.h index 3c8916b1f1c..87795d8bb1d 100644 --- a/src/include/R_ext/Applic.h +++ b/src/include/R_ext/Applic.h @@ -89,12 +89,9 @@ int findInterval(double *xt, int n, double x, int *mflag); // findInterval2() is only in Utils.h (and hence Rinternals.h) - -/* ------------------ Entry points NOT in the R API --------------- */ - /* The following are registered for use in .C/.Fortran */ -/* appl/dqrutl.f: interfaces to dqrsl */ +/* ../../appl/dqrutl.f: interfaces to dqrsl */ void F77_NAME(dqrqty)(double *x, int *n, int *k, double *qraux, double *y, int *ny, double *qty); void F77_NAME(dqrqy)(double *x, int *n, int *k, double *qraux, @@ -105,9 +102,20 @@ void F77_NAME(dqrrsd)(double *x, int *n, int *k, double *qraux, double *y, int *ny, double *rsd); void F77_NAME(dqrxb)(double *x, int *n, int *k, double *qraux, double *y, int *ny, double *xb); - /* end of registered */ + +/* find qr decomposition, dqrdc2() is basis of R's qr(), + also used by nlme and many other packages. */ +void F77_NAME(dqrdc2)(double *x, int *ldx, int *n, int *p, + double *tol, int *rank, + double *qraux, int *pivot, double *work); +void F77_NAME(dqrls)(double *x, int *n, int *p, double *y, int *ny, + double *tol, double *b, double *rsd, + double *qty, int *k, + int *jpvt, double *qraux, double *work); +/* ------------------ Entry points NOT in the R API --------------- */ + /* hidden, for use in R.bin/R.dll/libR.so */ /* appl/pretty.c: for use in engine.c and util.c @@ -117,7 +125,6 @@ double R_pretty(double *lo, double *up, int *ndiv, int min_n, double shrink_sml, const double high_u_fact[], int eps_correction, int return_bounds); - /* For use in package stats */ /* appl/uncmin.c : */ @@ -132,7 +139,7 @@ void fdhess(int n, double *x, double fval, fcn_p fun, void *state, double *h, int nfd, double *step, double *f, int ndigit, double *typx); -/* Foremerly used in package nlme, still used by pcaPP */ +/* Formerly used in package nlme, still used by pcaPP */ void optif9(int nr, int n, double *x, fcn_p fcn, fcn_p d1fcn, d2fcn_p d2fcn, void *state, double *typsiz, double fscale, int method, @@ -141,16 +148,6 @@ void optif9(int nr, int n, double *x, double steptl, double *xpls, double *fpls, double *gpls, int *itrmcd, double *a, double *wrk, int *itncnt); -/* find qr decomposition, dqrdc2() is basis of R's qr(), - also used by nlme and many other packages. */ -void F77_NAME(dqrdc2)(double *x, int *ldx, int *n, int *p, - double *tol, int *rank, - double *qraux, int *pivot, double *work); -void F77_NAME(dqrls)(double *x, int *n, int *p, double *y, int *ny, - double *tol, double *b, double *rsd, - double *qty, int *k, - int *jpvt, double *qraux, double *work); - #ifdef __cplusplus } #endif diff --git a/src/include/R_ext/Error.h b/src/include/R_ext/Error.h index 5bccb3d7103..633c75c1615 100644 --- a/src/include/R_ext/Error.h +++ b/src/include/R_ext/Error.h @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1998-2023 The R Core Team + * Copyright (C) 1998-2024 The R Core Team * * This header file is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -27,6 +27,7 @@ #define R_ERROR_H_ #include +#include /* for F77_... */ #ifdef __cplusplus extern "C" { @@ -58,7 +59,13 @@ NORET void WrongArgCount(const char *); void Rf_warning(const char *, ...) R_PRINTF_FORMAT(1,2); void R_ShowMessage(const char *s); - + +#ifdef FC_LEN_T +NORET void F77_NAME(xerbla)(const char *srname, int *info, const FC_LEN_T srname_len); +#else +NORET void F77_NAME(xerbla)(const char *srname, int *info); +#endif + #ifdef __cplusplus } diff --git a/src/include/R_ext/Lapack.h b/src/include/R_ext/Lapack.h index 2854f418cf7..e2077bc478f 100644 --- a/src/include/R_ext/Lapack.h +++ b/src/include/R_ext/Lapack.h @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2003-2024 The R Core Team. + * Copyright (C) 2003-2024 The R Core Team * Copyright (C) 2008-2019 The R Foundation * * This header file is free software; you can redistribute it and/or modify @@ -29,7 +29,7 @@ Part of the API. - R packages that use these should have PKG_LIBS in src/Makevars include + R packages that use these should have PKG_LIBS in src/Makevars include $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) */ @@ -44,10 +44,10 @@ // configure checked that Fortran INTEGER is 32-bit and the same as C int. /* logicals need checking (already they are compiler-dependent) - LAPACKE has + LAPACKE has #define lapack_logical lapack_int hence int32_t/int64_t - But that is not what Fortran comoilers do (int_least32_t for gfortran) + But that is not what Fortran comoilers do (int_least32_t for gfortran) OTOH the Accelerate headers use int/long. */ @@ -78,6 +78,11 @@ extern "C" { In the LAPACK sources in the INSTALL directory. */ extern void F77_NAME(ilaver)(La_INT *major, La_INT *minor, La_INT *patch); +extern int F77_NAME(ilaenv)(La_INT *ispec, /* input code determining the desired info */ + const char *name, /* name of calling subroutine */ + const char *opts, /* options of caller, e.g. 'UTN' for (UPLO = 'U', TRANS = 'T', DIAG = 'N') */ + /* "problem dimensions" of subroutine () ; may not all be required : */ + La_INT *n1, La_INT *n2, La_INT *n3, La_INT *n4); // Never defined by R itself. #ifndef La_extern @@ -96,6 +101,11 @@ extern void F77_NAME(ilaver)(La_INT *major, La_INT *minor, La_INT *patch); // La_extern char La_rcond_type(const char *typstr); +/* DISNAN returns .TRUE. if its argument is NaN, and .FALSE. otherwise. */ +/* To be replaced by the Fortran 2003 intrinsic in the future. */ +La_extern La_LGL +F77_NAME(disnan)(const La_INT* din); + /* Selected Double Precision Lapack Routines ======== */ @@ -243,7 +253,7 @@ F77_NAME(dgees)(const char* jobvs, const char* sort, const La_INT* n, double* a, const La_INT* lda, La_INT* sdim, double* wr, double* wi, double* vs, const La_INT* ldvs, - double* work, const La_INT* lwork, La_LGL* bwork, La_INT* info + double* work, const La_INT* lwork, La_LGL* bwork, La_INT* info FCLEN FCLEN); /* DGEESX - compute for an N-by-N real nonsymmetric matrix A, the */ /* eigenvalues, the real Schur form T, and, optionally, the matrix */ @@ -436,7 +446,7 @@ F77_NAME(dgges)(const char* jobvsl, const char* jobvsr, const char* sort, double* alphai, const double* beta, double* vsl, const La_INT* ldvsl, double* vsr, const La_INT* ldvsr, - double* work, const La_INT* lwork, La_LGL* bwork, La_INT* info + double* work, const La_INT* lwork, La_LGL* bwork, La_INT* info FCLEN FCLEN FCLEN); /* DGGGLM - solve a general Gauss-Markov linear model (GLM) problem */ @@ -847,6 +857,18 @@ F77_NAME(dpotf2)(const char* uplo, const La_INT* n, La_extern void F77_NAME(dpotrf)(const char* uplo, const La_INT* n, double* a, const La_INT* lda, La_INT* info FCLEN); + /* DPOTRF2 computes the Cholesky factorization of a real symmetric */ + /* positive definite matrix A using the recursive algorithm. */ +La_extern void +F77_NAME(dpotrf2)(const char* uplo, const La_INT* n, + double* a, const La_INT* lda, La_INT* info FCLEN); +/* DPFTRF computes the Cholesky factorization of a real symmetric */ +/* positive definite matrix A (which is in RFP format). */ +La_extern void +F77_NAME(dpftrf)(const char* transr, const char* uplo, const La_INT* n, + double* a, La_INT* info FCLEN FCLEN); + + /* DPOTRI - compute the inverse of a real symmetric positive */ /* definite matrix A using the Cholesky factorization A = U**T*U */ /* or A = L*L**T computed by DPOTRF */ @@ -1176,7 +1198,7 @@ F77_NAME(dsptri)(const char* uplo, const La_INT* n, La_extern void F77_NAME(dsptrs)(const char* uplo, const La_INT* n, const La_INT* nrhs, const double* ap, - const La_INT* ipiv, double* b, const La_INT* ldb, + const La_INT* ipiv, double* b, const La_INT* ldb, La_INT* info FCLEN); @@ -1263,6 +1285,14 @@ F77_NAME(dsycon)(const char* uplo, const La_INT* n, const La_INT* ipiv, const double* anorm, double* rcond, double* work, La_INT* iwork, La_INT* info FCLEN); +/* DSYEQUB computes row and column scalings intended to equilibrate a */ +/* symmetric matrix A (with respect to the Euclidean norm) and reduce */ +/* its condition number. */ +La_extern void +F77_NAME(dsyequb)(const char* uplo, const La_INT* n, + const double* a, const La_INT* lda, + double* s, double* scond, double* amax, + double* work, La_INT* info FCLEN); /* DSYEV - compute all eigenvalues and, optionally, eigenvectors */ /* of a real symmetric matrix A */ La_extern void @@ -1443,6 +1473,12 @@ F77_NAME(dtbtrs)(const char* uplo, const char* trans, const double* ab, const La_INT* ldab, double* b, const La_INT* ldb, La_INT* info FCLEN FCLEN FCLEN); +/* DTFSM solves a matrix equation ('a' is a triangular matrix in Rectangular Full Packed (RFP) */ +La_extern void +F77_NAME(dtfsm)(const char* transr, const char* side, const char* uplo, const char* trans, const char* diag, + const La_INT* m, const La_INT* n, const double* alpha, const double* a, + double* b, const La_INT* ldb FCLEN FCLEN FCLEN FCLEN FCLEN); + //* Double precision Triangular matrices Generalized problems -> DTG /* DTGEVC - compute some or all of the right and/or left */ @@ -1512,10 +1548,20 @@ F77_NAME(dtptrs)(const char* uplo, const char* trans, const La_INT* nrhs, const double* ap, double* b, const La_INT* ldb, La_INT* info #ifdef usePR18534fix - FCLEN + FCLEN #endif FCLEN FCLEN); +/* DTPTTR copies a triangular matrix from the standard packed format (TP) to the standard full format (TR) */ +La_extern void +F77_NAME(dtpttr)(const char* uplo, const La_INT* n, const double* ap, + double *a, const La_INT* lda, const La_INT* info FCLEN); +/* DTRTTP copies a triangular matrix from the standard full format (TR) to the standard packed format (TP) */ +La_extern void +F77_NAME(dtrttp)(const char* uplo, const La_INT* n, + const double* a, const La_INT* lda, + double *ap, const La_INT* info FCLEN); + //* Double precision TRiangular matrices -> DTR /* DTRCON - estimate the reciprocal of the condition number of a */ @@ -1574,7 +1620,7 @@ F77_NAME(dtrsen)(const char* job, const char* compq, double* wr, double* wi, La_INT* m, double* s, double* sep, double* work, const La_INT* lwork, - La_INT* iwork, const La_INT* liwork, La_INT* info + La_INT* iwork, const La_INT* liwork, La_INT* info FCLEN FCLEN); /* DTRSNA - estimate reciprocal condition numbers for specified */ @@ -1625,7 +1671,7 @@ F77_NAME(dtrtrs)(const char* uplo, const char* trans, -//* Double precision utilities in Lapack +//* Double precision utilities in Lapack /* DHGEQZ - implement a single-/double-shift version of the QZ */ /* method for finding the generalized eigenvalues */ @@ -1742,7 +1788,7 @@ F77_NAME(dlaed2)(const La_INT* k, const La_INT* n, double* d, La_extern void F77_NAME(dlaed3)(const La_INT* k, const La_INT* n, const La_INT* n1, double* d, double* q, const La_INT* ldq, - const double* rho, double* dlamda, double* q2, + const double* rho, double* dlamda, double* q2, La_INT* indx, La_INT* ctot, double* w, double* s, La_INT* info); /* DLAED4 - subroutine computes the I-th updated eigenvalue of a */ @@ -2043,7 +2089,7 @@ F77_NAME(dlaqge)(const La_INT* m, const La_INT* n, La_extern void F77_NAME(dlaqsb)(const char* uplo, const La_INT* n, const La_INT* kd, double* ab, const La_INT* ldab, const double* s, - const double* scond, const double* amax, + const double* scond, const double* amax, const char* equed FCLEN FCLEN); /* DLAQSP - equilibrate a symmetric matrix A using the scaling */ /* factors in the vector S */ @@ -2496,7 +2542,7 @@ F77_NAME(dggev)(const char* jobvl, const char* jobvr, La_INT *n, double * La_INT *info FCLEN FCLEN); La_extern void -F77_NAME(dggevx)(const char* balanc, const char* jobvl, const char* jobvr, const char* +F77_NAME(dggevx)(const char* balanc, const char* jobvl, const char* jobvr, const char* sense, La_INT *n, double *a, La_INT *lda, double *b, La_INT *ldb, double *alphar, double *alphai, double * beta, double *vl, La_INT *ldvl, double *vr, La_INT *ldvr, @@ -2605,7 +2651,7 @@ F77_NAME(dlarz)(const char* side, La_INT *m, La_INT *n, La_INT *l, La_INT *ldc, double *work FCLEN); La_extern void -F77_NAME(dlarzb)(const char* side, const char* trans, const char* direct, const char* +F77_NAME(dlarzb)(const char* side, const char* trans, const char* direct, const char* storev, La_INT *m, La_INT *n, La_INT *k, La_INT *l, double *v, La_INT *ldv, double *t, La_INT *ldt, double *c, La_INT * ldc, double *work, La_INT *ldwork @@ -2757,7 +2803,7 @@ F77_NAME(dspgvd)(La_INT *itype, const char* jobz, const char* uplo, La_INT * La_INT *liwork, La_INT *info FCLEN FCLEN); La_extern void -F77_NAME(dspgvx)(La_INT *itype, const char* jobz, const char* range, const char* +F77_NAME(dspgvx)(La_INT *itype, const char* jobz, const char* range, const char* uplo, La_INT *n, double *ap, double *bp, double *vl, double *vu, La_INT *il, La_INT *iu, double *abstol, La_INT * *m, double *w, double *z, La_INT *ldz, double *work, @@ -2836,6 +2882,12 @@ F77_NAME(dtgsyl)(const char* trans, La_INT *ijob, La_INT *m, La_INT * scale, double *dif, double *work, La_INT *lwork, La_INT * iwork, La_INT *info FCLEN); +/* DTRTTF copies a triangular matrix from the standard full format (TR) to the rectangular full packed (RFP) format (TF) */ +La_extern void +F77_NAME(dtrttf)(const char* transr, const char* uplo, const La_INT *n, + const double* a, const La_INT *lda, + double* arf, La_INT *info FCLEN FCLEN); + La_extern void F77_NAME(dtzrzf)(La_INT *m, La_INT *n, double *a, La_INT * lda, double *tau, double *work, La_INT *lwork, La_INT *info); @@ -2855,6 +2907,7 @@ F77_NAME(dpstrf)(const char* uplo, const La_INT* n, La_extern La_LGL * F77_NAME(lsame)(const char* ca, const char* cb FCLEN FCLEN); + La_extern void F77_NAME(zbdsqr)(const char* uplo, La_INT *n, La_INT *ncvt, La_INT * nru, La_INT *ncc, double *d, double *e, La_complex *vt, @@ -2938,6 +2991,17 @@ F77_NAME(zgetrs)(const char* trans, La_INT *n, La_INT *nrhs, La_INT *ldb, La_INT *info FCLEN); +/* ZHEEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices + * Added in R 4.5.0 + */ +La_extern void +F77_NAME(zheevd)(const char* jobz, const char* uplo, const La_INT *n, + La_complex *a, La_INT *lda, + double* w, + La_complex *work, const La_INT *lwork, + double *rwork, const La_INT *lrwork, + La_INT *iwork, const La_INT *liwork, La_INT *info FCLEN FCLEN); + La_extern void F77_NAME(zhetd2)(const char* uplo, La_INT *n, La_complex *a, La_INT *lda, double *d, double *e, La_complex *tau, La_INT *info FCLEN); @@ -2981,7 +3045,7 @@ F77_NAME(zlanhe)(const char* norm, const char* uplo, La_INT *n, La_complex *a, La_INT *lda, double *work FCLEN FCLEN); La_extern double -F77_NAME(zlanhs)(const char* norm, La_INT *n, La_complex *a, La_INT *lda, +F77_NAME(zlanhs)(const char* norm, La_INT *n, La_complex *a, La_INT *lda, double *work FCLEN); La_extern double @@ -3006,7 +3070,7 @@ F77_NAME(zlarf)(const char* side, La_INT *m, La_INT *n, La_complex ldc, La_complex *work FCLEN); La_extern void -F77_NAME(zlarfb)(const char* side, const char* trans, +F77_NAME(zlarfb)(const char* side, const char* trans, const char* direct, const char* storev, La_INT *m, La_INT *n, La_INT *k, La_complex *v, La_INT *ldv, La_complex *t, La_INT *ldt, La_complex *c, La_INT * @@ -3056,7 +3120,7 @@ F77_NAME(zlatrd)(const char* uplo, La_INT *n, La_INT *nb, La_complex *w, La_INT *ldw FCLEN); La_extern void -F77_NAME(zlatrs)(const char* uplo, const char* trans, +F77_NAME(zlatrs)(const char* uplo, const char* trans, const char* diag, const char* normin, La_INT *n, La_complex *a, La_INT *lda, La_complex *x, double *scale, double *cnorm, La_INT *info @@ -3130,7 +3194,7 @@ F77_NAME(ztptri)(const char* uplo, const char* diag, const La_INT* n, La_complex La_INT *info FCLEN FCLEN); La_extern void -F77_NAME(ztptrs)(const char* uplo, const char* trans, const char* diag, +F77_NAME(ztptrs)(const char* uplo, const char* trans, const char* diag, const La_INT* n, const La_INT* nrhs, const La_complex* ap, La_complex* b, const La_INT* ldb, La_INT* info FCLEN FCLEN FCLEN); @@ -3246,12 +3310,62 @@ F77_NAME(zgesdd)(const char* jobz, La_complex *vt, const La_INT *ldvt, La_complex *work, const La_INT *lwork, double *rwork, La_INT *iwork, La_INT *info FCLEN); + +/* ZGELS solves overdetermined or underdetermined systems for GE matrices */ +La_extern void +F77_NAME(zgels)(const char* trans, const La_INT *m, const La_INT *n, const La_INT *nrhs, + La_complex *a, const La_INT *lda, + La_complex *b, const La_INT *ldb, La_complex *work, const La_INT *lwork, + La_INT *info FCLEN); + La_extern void F77_NAME(zgelsd)(La_INT *m, La_INT *n, La_INT *nrhs, La_complex *a, La_INT *lda, La_complex *b, La_INT *ldb, double *s, - double *rcond, La_INT *rank, + double *rcond, La_INT *rank, La_complex *work, La_INT *lwork, double *rwork, La_INT *iwork, La_INT *info); +/* ZGESVX computes the solution to system of linear equations A * X = B for GE matrices */ +La_extern void +F77_NAME(zgesvx)(const char* fact, const char* trans, const La_INT *n, const La_INT *nrhs, + La_complex *a, const La_INT *lda, + La_complex *af, const La_INT *ldaf, La_INT *ipiv, + char* equed, double *r, double *c, + La_complex *b, const La_INT *ldb, + La_complex *x, const La_INT *ldx, + double *rcond, double *ferr, double *berr, + La_complex *work, double *rwork, + La_INT *info FCLEN FCLEN FCLEN); /* FCLEN also for 'equed' */ + +/* ZGGES computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE matrices */ +La_extern void +F77_NAME(zgges)(const char* jobvsl, const char* jobvsr, const char* sort, + void *selctg, /* <--- FIXME: a fortran logical function of two complex arguments*/ +/* .. Function Arguments .. \\ LOGICAL SELCTG \\ EXTERNAL SELCTG +* SELCTG is a LOGICAL FUNCTION of two COMPLEX*16 arguments +* SELCTG must be declared EXTERNAL in the calling subroutine. +* If SORT = 'N', SELCTG is not referenced. +* If SORT = 'S', SELCTG is used to select eigenvalues to sort +* to the top left of the Schur form. */ + const La_INT *n, + La_complex *a, const La_INT *lda, + La_complex *b, const La_INT *ldb, + La_INT *sdim, La_complex *alpha, La_complex *beta, + La_complex *vsl, const La_INT *ldvsl, + La_complex *vsr, const La_INT *ldvsr, + La_complex *work, const La_INT *lwork, + double *rwork, La_LGL *bwork, + La_INT *info FCLEN FCLEN FCLEN); + +/* ZGGEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices */ +La_extern void +F77_NAME(zggev)(const char* jobvl, const char* jobvr, const La_INT *n, + La_complex *a, const La_INT *lda, + La_complex *b, const La_INT *ldb, La_complex *alpha, La_complex *beta, + La_complex *vl, const La_INT *ldvl, + La_complex *vr, const La_INT *ldvr, + La_complex *work, const La_INT *lwork, double *rwork, + La_INT *info FCLEN FCLEN); + /* More Complex for R 4.4.0 --- Complex Hermitian (incl "crossprod") */ La_extern double @@ -3260,6 +3374,11 @@ F77_NAME(zlanhp)(const char* norm, const char* uplo, La_complex const* AP, double* work FCLEN FCLEN); +/* ZLARTG generates a plane rotation with real cosine and complex sine */ +La_extern void +F77_NAME(zlartg)(const La_complex* F, const La_complex* G, + double* C, La_complex* S, La_complex* R); + La_extern void F77_NAME(zhpcon)(const char* uplo, La_INT const* n, La_complex const* AP, La_INT const* ipiv, double const* anorm, @@ -3269,7 +3388,7 @@ F77_NAME(zhpcon)(const char* uplo, La_INT const* n, La_complex const* AP, La_extern void F77_NAME(zhptrf)(const char* uplo, La_INT const* n, La_complex* AP, La_INT* ipiv, La_INT* info FCLEN); - + La_extern void F77_NAME(zhptri)(const char* uplo, La_INT const* n, La_complex* AP, La_INT const* ipiv, La_complex* work, La_INT* info FCLEN); @@ -3318,6 +3437,52 @@ F77_NAME(zhpev)(const char *jobz, const char *uplo, La_complex *work, double *rwork, La_INT *info FCLEN FCLEN); + +/* ZROT applies a plane rotation with real cosine and complex sine to a pair of complex vectors */ +La_extern void +F77_NAME(zrot)(const La_INT *n, + La_complex *cx, const La_INT *incx, + La_complex *cy, const La_INT *incy, double *c, La_complex *s); + +/* ZTGSEN reorders the generalized Schur decomposition of a complex matrix pair (A, B), + * (A, B) must be in generalized Schur canonical form, i.e., A and B are both upper triangular. + * ZTGSEN also computes the generalized eigenvalues of (A, B) */ +La_extern void +F77_NAME(ztgsen)(const La_INT *ijob, const La_LGL *wantq, const La_LGL *wantz, + const La_LGL *select, const La_INT *n, + La_complex *a, const La_INT *lda, + La_complex *b, const La_INT *ldb, + La_complex *alpha, La_complex *beta, + La_complex *q, const La_INT *ldq, + La_complex *z, const La_INT *ldz, + La_INT *m, double *pl, double *pr, double *dif, + La_complex *work, const La_INT *lwork, + La_INT *iwork, const La_INT *liwork, La_INT *info); + +/* ZTRSEN reorders the Schur factorization of a complex matrix A = Q*T*Q**H, + so that a selected cluster of eigenvalues appears in the leading positions + on the diagonal of the upper triangular matrix T, and the leading columns + of Q form an orthonormal basis of the corresponding right invariant subspace. */ +La_extern void +F77_NAME(ztrsen)(const char* job, const char* compq, const La_LGL *select, const La_INT *n, + La_complex *t, const La_INT *ldt, + La_complex *q, const La_INT *ldq, La_complex *w, + La_INT *m, double *s, double *sep, + La_complex *work, const La_INT *lwork, La_INT *info FCLEN FCLEN); + +/* ZTRSYL solves the complex Sylvester matrix equation + op(A)*X + X*op(B) = scale*C or + op(A)*X - X*op(B) = scale*C, + where op(A) = A or A**H, and A and B are both upper triangular. */ +La_extern void +F77_NAME(ztrsyl)(const char* trana, const char* tranb, const La_INT *isgn, + const La_INT *m, const La_INT *n, + const La_complex *a, const La_INT *lda, + const La_complex *b, const La_INT *ldb, + La_complex *c, const La_INT *ldc, double *scale, + La_INT *info FCLEN FCLEN); + + /* =========================== DEPRECATED ============================== Routines below were deprecated in LAPACK 3.6.0, and are not diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index e3dfca7156a..6f4e60624aa 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -1,11 +1,11 @@ # File src/library/tools/R/sotools.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 2011-2023 The R Core Team +# Copyright (C) 2011-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -693,11 +693,12 @@ nonAPI <- c("chol_", "chol2inv_", "cg_", "ch_", "rg_", "R_new_custom_connection", "R_ReadConnection", "R_WriteConnection", "R_GetConnection", -## non-API in Applic.h -## future <- c("dqrcf_", "dqrdc2_", "dqrls_", "dqrqty_", "dqrqy_") -## d1mach_ and i1mach_ are mentioned (since R 2.15.3) in R-exts. +## in ../../../include/R_ext/Applic.h -- these are API now: +## "dqrcf_", "dqrqty_", "dqrqy_", "dqrrsd_", "dqrxb_", +## "dqrdc2_", "dqrls_", +## "d1mach_" and "i1mach_" are API now in R-exts. "R_Pretty") ## hidden, so unlikely to be usable -## "optif9") ## used by nlme and pcaPP +## "optif9") ## used by pcaPP ## grDevices uses R_Home R_InputHandlers R_TempDir R_Visible R_cairoCdynload R_fopen R_gzclose R_gzgets R_gzopen R_isForkedChild Rf_envlength Rf_strIsASCII Rf_utf8towcs Rg_set_col_ptrs Ri18n_wcwidth addInputHandler do_X11 do_contourLines do_getGraphicsEventEnv do_getSnapshot do_playSnapshot do_saveplot locale2charset mbcsToUcs2 ptr_R_ProcessEvents From 46836e4d3d617f43146ef3c04f6a2ec0d234a01f Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 9 Aug 2024 07:05:44 +0000 Subject: [PATCH 449/546] revert "accident" of 86984 git-svn-id: https://svn.r-project.org/R/trunk@86985 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/sotools.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/sotools.R b/src/library/tools/R/sotools.R index 6f4e60624aa..44bf5a05c36 100644 --- a/src/library/tools/R/sotools.R +++ b/src/library/tools/R/sotools.R @@ -5,7 +5,7 @@ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, From bbe4e08fe3cf29030e7da8d4fa8514b472ed014b Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 9 Aug 2024 08:26:30 +0000 Subject: [PATCH 450/546] Note about PCRE2 and quantifiers with unspecified lower limit. git-svn-id: https://svn.r-project.org/R/trunk@86986 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/regex.Rd | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/library/base/man/regex.Rd b/src/library/base/man/regex.Rd index 569ebd3fbea..88ab1cd8e21 100644 --- a/src/library/base/man/regex.Rd +++ b/src/library/base/man/regex.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/regex.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2022 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{regex} @@ -219,7 +219,10 @@ (essentially 2012), the man pages at \url{https://www.pcre.org/original/doc/html/} should be a good match. PCRE2 (PCRE version >= 10.00) has man pages at - \url{https://www.pcre.org/current/doc/html/}). + \url{https://www.pcre.org/current/doc/html/}), but note that individual + PCRE versions may still differ in behavior (e.g. PCRE 10.43 introduced + quantifiers with an unspecified lower limit, but earlier versions documented + that they were treated as literals). Perl regular expressions can be computed byte-by-byte or (UTF-8) character-by-character: the latter is used in all multibyte From 001056d6f683921c0086792002daf4ea52cc76fe Mon Sep 17 00:00:00 2001 From: ripley Date: Fri, 9 Aug 2024 10:40:14 +0000 Subject: [PATCH 451/546] correct prototype for ilaenv git-svn-id: https://svn.r-project.org/R/trunk@86987 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/R_ext/Lapack.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/include/R_ext/Lapack.h b/src/include/R_ext/Lapack.h index e2077bc478f..9bf80568080 100644 --- a/src/include/R_ext/Lapack.h +++ b/src/include/R_ext/Lapack.h @@ -78,11 +78,12 @@ extern "C" { In the LAPACK sources in the INSTALL directory. */ extern void F77_NAME(ilaver)(La_INT *major, La_INT *minor, La_INT *patch); -extern int F77_NAME(ilaenv)(La_INT *ispec, /* input code determining the desired info */ +extern int F77_NAME(ilaenv)(const La_INT *ispec, /* input code determining the desired info */ const char *name, /* name of calling subroutine */ const char *opts, /* options of caller, e.g. 'UTN' for (UPLO = 'U', TRANS = 'T', DIAG = 'N') */ /* "problem dimensions" of subroutine () ; may not all be required : */ - La_INT *n1, La_INT *n2, La_INT *n3, La_INT *n4); + const La_INT *n1, const La_INT *n2, + const La_INT *n3, const La_INT *n4 FCLEN FCLEN); // Never defined by R itself. #ifndef La_extern From 131ece73847d08f551d105f0e168e6f1788caa51 Mon Sep 17 00:00:00 2001 From: kalibera Date: Fri, 9 Aug 2024 16:42:57 +0000 Subject: [PATCH 452/546] Fix memory leak in sink(type="message"), PR#18760. Fix treatment of sink.number(type="message"). git-svn-id: https://svn.r-project.org/R/trunk@86988 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/connections.R | 4 ++-- src/main/connections.c | 10 ++++++---- tests/reg-tests-2.Rout.save | 13 ++++++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/library/base/R/connections.R b/src/library/base/R/connections.R index d5569c40697..4d8207b27ae 100644 --- a/src/library/base/R/connections.R +++ b/src/library/base/R/connections.R @@ -1,7 +1,7 @@ # File src/library/base/R/connections.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2021 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -241,7 +241,7 @@ closeAllConnections <- function() { ## first re-divert any diversion of stderr. i <- sink.number(type = "message") - if(i > 0L) sink(stderr(), type = "message") + if(i != 2L) sink(stderr(), type = "message") ## now unwind the sink diversion stack. n <- sink.number() if(n > 0L) for(i in seq_len(n)) sink() diff --git a/src/main/connections.c b/src/main/connections.c index 0f5dcbf49ca..c0d12a5ad58 100644 --- a/src/main/connections.c +++ b/src/main/connections.c @@ -5355,13 +5355,15 @@ attribute_hidden SEXP do_sink(SEXP call, SEXP op, SEXP args, SEXP rho) error(_("sink stack is full")); switch_or_tee_stdout(icon, closeOnExit, tee); } else { - if(icon < 0) { - R_ReleaseObject(getConnection(R_ErrorCon)->ex_ptr); + if(icon < 0 || icon == 2) { + if (R_ErrorCon > 2) + R_ReleaseObject(getConnection(R_ErrorCon)->ex_ptr); R_ErrorCon = 2; } else { - getConnection(icon); /* check validity */ + Rconnection con = getConnection(icon); /* check validity */ R_ErrorCon = icon; - R_PreserveObject(getConnection(icon)->ex_ptr); + if (icon > 2) + R_PreserveObject(con->ex_ptr); } } diff --git a/tests/reg-tests-2.Rout.save b/tests/reg-tests-2.Rout.save index 5be8047efd7..88983faaa5f 100644 --- a/tests/reg-tests-2.Rout.save +++ b/tests/reg-tests-2.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-03-11 r86096) -- "Unsuffered Consequences" +R Under development (unstable) (2024-08-07 r86984) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -1473,6 +1473,9 @@ Error in log("a") : non-numeric argument to mathematical function > > ## bail out > closeAllConnections() +Warning message: +In .Internal(gc(verbose, reset, full)) : + closing unused connection 3 (all.Rout) > (foo <- showConnections()) description class mode text isopen can read can write > stopifnot(nrow(foo) == 0) @@ -6379,7 +6382,7 @@ function(given = NULL) { if (is.null(given)) callObj$default <- TRUE callObj } - + > print(foo, useSource = FALSE) function (given = NULL) { @@ -6390,7 +6393,7 @@ function (given = NULL) callObj$default <- TRUE callObj } - + > attr(foo, "srcref") <- NULL > foo function (given = NULL) @@ -6402,7 +6405,7 @@ function (given = NULL) callObj$default <- TRUE callObj } - + > (f <- structure(function(){}, note = "just a note", + yada = function() "not the same")) function(){} @@ -8355,7 +8358,7 @@ Error in f() : argument is missing, with no default > withAutoprint({ show.srcref() }) language show.srcref() - attr(*, "srcref")= 'srcref' int [1:8] 1 21 1 33 21 33 3 3 - ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' + ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' > ## no attr(*, "src..") in R <= 4.3.1 > ## > withAutoprint({ From 4384e529913900c3f4ba8ad57b024aba2aad85b8 Mon Sep 17 00:00:00 2001 From: ripley Date: Sat, 10 Aug 2024 13:57:07 +0000 Subject: [PATCH 453/546] many missing underscores git-svn-id: https://svn.r-project.org/R/trunk@86989 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/po/ca.po | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/library/base/po/ca.po b/src/library/base/po/ca.po index a50ae2aad88..a38445bde47 100644 --- a/src/library/base/po/ca.po +++ b/src/library/base/po/ca.po @@ -71,7 +71,7 @@ msgstr "R_pretty(): interval molt petit Ā«celĀ·laĀ»=%g, corregit a %g" #: src/appl/pretty.c:146 #, c-format msgid "R_pretty(): very large range 'cell'=%g, corrected to %g" -msgstr "Rpretty(): interval molt gran Ā«celĀ·laĀ»=%g, corregit a %g" +msgstr "R_pretty(): interval molt gran Ā«celĀ·laĀ»=%g, corregit a %g" #: src/gnuwin32/dynload.c:118 #, c-format @@ -780,7 +780,7 @@ msgstr "tipus no implementat %d a Ā«createRSymbolObjectĀ»" #: src/main/Rdynload.c:1655 #, fuzzy msgid "R_getRegisteredRoutines() expects a DllInfo reference" -msgstr "RgetRegisteredRoutines() espera una referĆØncia de DllInfo" +msgstr "R_getRegisteredRoutines() espera una referĆØncia de DllInfo" #: src/main/Rdynload.c:1744 #, fuzzy, c-format @@ -4526,7 +4526,7 @@ msgstr "el marcador de posiciĆ³ de la canonada nomĆ©s es pot utilitzar com a arg #: src/main/gram.y:1335 #, fuzzy, c-format msgid "'=>' is disabled; set '_R_USE_PIPEBIND_' envvar to a true value to enable it (%s:%d:%d)" -msgstr "Ā«=>Ā» estĆ  desactivat; establiu Ā«RUSEPIPEBINDĀ» envvar a un valor real per a habilitar-lo (%s:%d:%d)" +msgstr "Ā«=>Ā» estĆ  desactivat; establiu Ā«R_USE_PIPEBINDĀ» envvar a un valor real per a habilitar-lo (%s:%d:%d)" #: src/main/gram.y:1411 #, fuzzy, c-format @@ -5030,7 +5030,7 @@ msgstr "no s'ha pogut assignar espai per a l'element de crida de retorn de nivel #: src/main/main.c:1728 #, fuzzy msgid "negative index passed to R_removeTaskCallbackByIndex" -msgstr "ƍndex negatiu passat a RremoveTaskCallbackByIndex" +msgstr "ƍndex negatiu passat a R_removeTaskCallbackByIndex" #: src/main/main.c:1855 #, fuzzy, c-format @@ -5202,18 +5202,18 @@ msgstr "unprotectptr: no s'ha trobat el punter" #, fuzzy, c-format msgid "R_Reprotect: only %d protected item, can't reprotect index %d" msgid_plural "R_Reprotect: only %d protected items, can't reprotect index %d" -msgstr[0] "RReprotect: nomĆ©s %d element protegit, no es pot reprotegir l'Ć­ndex %d" -msgstr[1] "RReprotect: nomĆ©s %d elements protegits, no es pot reprotegir l'Ć­ndex %d" +msgstr[0] "R_Reprotect: nomĆ©s %d element protegit, no es pot reprotegir l'Ć­ndex %d" +msgstr[1] "R_Reprotect: nomĆ©s %d elements protegits, no es pot reprotegir l'Ć­ndex %d" #: src/main/memory.c:3528 #, fuzzy, c-format msgid "'R_Calloc' could not allocate memory (%llu of %llu bytes)" -msgstr "'RCalloc' no ha pogut assignar memĆ²ria (%llu de %llu bytes)" +msgstr "'R_Calloc' no ha pogut assignar memĆ²ria (%llu de %llu bytes)" #: src/main/memory.c:3539 #, fuzzy, c-format msgid "'R_Realloc' could not re-allocate memory (%llu bytes)" -msgstr "'RRealloc' no ha pogut reassignar la memĆ²ria (%llu bytes)" +msgstr "'R_Realloc' no ha pogut reassignar la memĆ²ria (%llu bytes)" #: src/main/memory.c:3949 #, fuzzy, c-format @@ -5228,12 +5228,12 @@ msgstr "no Ć©s segur retornar el punter del vector" #: src/main/memory.c:4140 #, fuzzy, c-format msgid "attempt to set index %lld/%lld in SET_STRING_ELT" -msgstr "s'ha intentat establir l'Ć­ndex %lld/%lld a SETSTRINGELT" +msgstr "s'ha intentat establir l'Ć­ndex %lld/%lld a SET_STRING_ELT" #: src/main/memory.c:4161 #, fuzzy, c-format msgid "attempt to set index %lld/%lld in SET_VECTOR_ELT" -msgstr "s'ha intentat establir l'Ć­ndex %lld/%lld a SETVECTORELT" +msgstr "s'ha intentat establir l'Ć­ndex %lld/%lld a SET_VECTOR_ELT" #: src/main/memory.c:4344 src/main/memory.c:4353 src/main/memory.c:4366 #: src/main/memory.c:4383 src/main/memory.c:4398 src/main/memory.c:4414 @@ -5485,7 +5485,7 @@ msgstr "El paquet Ā«mĆØtodesĀ» encara no s'ha carregat" #: src/main/objects.c:1725 #, fuzzy msgid "R_getClassDef(.) called with NULL string pointer" -msgstr "RgetClassDef(.) cridat amb un punter de cadena nul" +msgstr "R_getClassDef(.) cridat amb un punter de cadena nul" #: src/main/objects.c:1772 #, fuzzy @@ -5807,7 +5807,7 @@ msgstr "error de lectura a Ā«%sĀ»" #: src/main/platform.c:2193 #, fuzzy msgid "setting 'LC_NUMERIC' may cause R to function strangely" -msgstr "establir Ā«LCNUMERICĀ» pot fer que l'R funcioni estranyament" +msgstr "establir Ā«LC_NUMERICĀ» pot fer que l'R funcioni estranyament" #: src/main/platform.c:2206 #, fuzzy, c-format @@ -6170,7 +6170,7 @@ msgstr "cadena UTF-8 no vĆ lida" #: src/main/raw.c:391 #, fuzzy msgid "argument 'allow_surrogate_pairs' must be TRUE or FALSE" -msgstr "l'argument Ā«allowsurrogatepairsĀ» ha de ser CERT o FALS" +msgstr "l'argument Ā«allow_surrogate_pairsĀ» ha de ser CERT o FALS" #: src/main/relop.c:140 src/main/relop.c:154 src/main/relop.c:169 #, fuzzy, c-format @@ -7177,7 +7177,7 @@ msgstr "%d arguments no utilitzats pel format" #: src/main/startup.c:72 #, fuzzy msgid "R_LibraryFileName: buffer too small" -msgstr "RLibraryFileName: la memĆ²ria intermĆØdia Ć©s massa petita" +msgstr "R_LibraryFileName: la memĆ²ria intermĆØdia Ć©s massa petita" #: src/main/subassign.c:142 #, fuzzy @@ -7617,27 +7617,27 @@ msgstr "punt Unicode %u no vĆ lid" #: src/main/sysutils.c:2224 #, fuzzy msgid "'R_USER' not set" -msgstr "no s'ha definit Ā«RUSERĀ»" +msgstr "no s'ha definit Ā«R_USERĀ»" #: src/main/sysutils.c:2245 src/main/sysutils.c:2273 #, fuzzy msgid "cannot allocate 'R_TempDir'" -msgstr "no es pot assignar Ā«RTempDirĀ»" +msgstr "no es pot assignar Ā«R_TempDirĀ»" #: src/main/sysutils.c:2267 #, fuzzy msgid "'R_TempDir' contains space" -msgstr "'RTempDir' contĆ© espai" +msgstr "'R_TempDir' contĆ© espai" #: src/main/sysutils.c:2279 #, fuzzy msgid "cannot create 'R_TempDir'" -msgstr "no s'ha pogut crear Ā«RTempDirĀ»" +msgstr "no s'ha pogut crear Ā«R_TempDirĀ»" #: src/main/sysutils.c:2285 src/main/sysutils.c:2296 src/main/sysutils.c:2301 #, fuzzy msgid "unable to set R_SESSION_TMPDIR" -msgstr "no s'ha pogut establir RSESSIONTMPDIR" +msgstr "no s'ha pogut establir R_SESSION_TMPDIR" #: src/main/sysutils.c:2351 #, fuzzy @@ -7647,7 +7647,7 @@ msgstr "nom temporal massa llarg" #: src/main/sysutils.c:2355 #, fuzzy msgid "allocation failed in R_tmpnam2" -msgstr "ha fallat l'assignaciĆ³ a Rtmpnam2" +msgstr "ha fallat l'assignaciĆ³ a R_tmpnam2" #: src/main/sysutils.c:2361 #, fuzzy From 2747f18a1458935e442a1acf96963ff49c4f9a4b Mon Sep 17 00:00:00 2001 From: ripley Date: Sat, 10 Aug 2024 14:09:32 +0000 Subject: [PATCH 454/546] report clang-only warning git-svn-id: https://svn.r-project.org/R/trunk@86990 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index b82df42da54..72c3987216f 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -5958,6 +5958,7 @@ add_dummies <- function(dir, Log) ## Apple and LLVM clang " warning: switch condition has boolean value \\[-Wswitch-bool\\]", " warning: .* \\[-Wembedded-directive\\]", + " warning: using directive refers to implicitly-defined namespace", ## LLVM flang warnings: ## Includes Hollerith constants From b0284a60f28e32259d0b38fdc36d52484deeafe2 Mon Sep 17 00:00:00 2001 From: ripley Date: Sun, 11 Aug 2024 10:19:37 +0000 Subject: [PATCH 455/546] another warning on including R headers from C++ git-svn-id: https://svn.r-project.org/R/trunk@86991 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 69fbc1ef0c1..b6c44ccf06d 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14738,7 +14738,9 @@ there that can be included too, but many of the features they contain should be regarded as undocumented and unstable. Most of these header files, including all those included by @file{R.h}, -can be used from C++ code. +can be used from C++ code. (However, they cannot safely be included in +a @code{extern "C" @{ @}} block as they may include C++ headers when +included from C++ code---and whether this succeeds is system-specific). @quotation Note Because @R{} re-maps many of its external names to avoid clashes with From 2ae60093b2bb0c70c22607cb7a50e364c862a152 Mon Sep 17 00:00:00 2001 From: ripley Date: Sun, 11 Aug 2024 16:23:40 +0000 Subject: [PATCH 456/546] include float.h in Constants.h unconditionally git-svn-id: https://svn.r-project.org/R/trunk@86993 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 ++++ doc/manual/R-exts.texi | 10 +++++----- src/include/R_ext/Constants.h | 4 ++-- src/library/tools/R/install.R | 2 ++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index d8f440c953e..91bbe6df116 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -175,6 +175,10 @@ \code{"Mb"}, \code{"Gb"} , \dots, and \code{"Mbytes"} strings as \emph{arguments} instead of as part of the (translatable format) string. This is one step for \PR{18297}; from \I{Henrik Bengtsson}. + + \item Header \file{Constants.h} (included by \file{R.h}) now + includes header \file{float.h} or \file{cfloat} for constants such as + \code{DBL_MAX} even if \file{STRICT_R_HEADERS} is defined. } } diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index b6c44ccf06d..c414382b1a8 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -16100,11 +16100,11 @@ natural logarithm (@code{log(x)} in @R{}). @end quotation @apihdr R_ext/Constants.h -There are a set of constants (@code{PI}, @code{DOUBLE_EPS}) (and so on) -defined (unless @code{STRICT_R_HEADERS} is defined) in the included -header @file{R_ext/Constants.h}, mainly for compatibility with @Sl{}. -All but @code{PI} are deprecated and should be replaced by the C99/C++11 -versions used in that file. +For compatibility with @Sl{} this file defines the constant @code{PI} +(unless @code{STRICT_R_HEADERS} is defined): this is deprecated and +should be replaced by @code{M_PI}. @file{Constants.h} includes either C +header @file{float.h} or C++ header @file{cfloat}, which provide +constants such as @code{DBL_MAX}. @apivar TRUE @apivar FALSE diff --git a/src/include/R_ext/Constants.h b/src/include/R_ext/Constants.h index ad7c1247776..d218f53b27b 100644 --- a/src/include/R_ext/Constants.h +++ b/src/include/R_ext/Constants.h @@ -35,13 +35,13 @@ /* S-compatibility defines. */ -#ifndef STRICT_R_HEADERS -#define PI M_PI #ifdef __cplusplus #include /* Defines the RHSs, C++11 and later */ #else #include /* Defines the RHSs, C99 and later */ #endif +#ifndef STRICT_R_HEADERS +#define PI M_PI /* The DOUBLE_* defines were deprecated in R 4.2.0 and removed in 4.3.0. #define DOUBLE_DIGITS DBL_MANT_DIG diff --git a/src/library/tools/R/install.R b/src/library/tools/R/install.R index 52e1e4cd9cd..ed875486cec 100644 --- a/src/library/tools/R/install.R +++ b/src/library/tools/R/install.R @@ -2762,6 +2762,8 @@ if(FALSE) { ) if(config_val_to_logical(Sys.getenv("_R_CXX_USE_NO_REMAP_", "FALSE"))) makeargs <- c(makeargs, "CXX_DEFS=-DR_NO_REMAP") + if(config_val_to_logical(Sys.getenv("_R_USE_STRICT_R_HEADERS_", "FALSE"))) + makeargs <- c(makeargs, "XDEFS=-DSTRICT_R_HEADERS=1") cmd <- paste(MAKE, p1(paste("-f", shQuote(makefiles))), p1(makeargs), p1(makeobjs)) From 1a2980cac7e0e920cb30d82dec3ded9337f999fe Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 12 Aug 2024 05:32:54 +0000 Subject: [PATCH 457/546] comment on move towards STRICT_R_HEADERS as default git-svn-id: https://svn.r-project.org/R/trunk@86994 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 10 +++++++--- doc/manual/R-exts.texi | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 91bbe6df116..cbf6982924f 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -176,9 +176,13 @@ \emph{arguments} instead of as part of the (translatable format) string. This is one step for \PR{18297}; from \I{Henrik Bengtsson}. - \item Header \file{Constants.h} (included by \file{R.h}) now - includes header \file{float.h} or \file{cfloat} for constants such as - \code{DBL_MAX} even if \file{STRICT_R_HEADERS} is defined. + \item Header \file{R_ext/Constants.h} (included by \file{R.h}) now + includes header \file{float.h} or \file{cfloat} for constants such + as \code{DBL_MAX} even if \file{STRICT_R_HEADERS} is defined. + + \item The legecy definition of \code{PI} in + \file{R_ext/Constants.h} (included by \file{R.h} will be removeed + shortly: use \code{M_PI} instead. } } diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index c414382b1a8..d02ac6a5525 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14971,8 +14971,9 @@ Memory obtained by these macros should be aligned in the same way as @apifun Free @c The R_ forms were introduced in 2016-09, hence for R 3.4.0 Historically the macros @code{Calloc}, @code{Free} and @code{Realloc} -were used, and these remain available unless @code{STRICT_R_HEADERS} -was defined prior to the inclusion of the header. +were used, and these remain available unless @code{STRICT_R_HEADERS} +was defined prior to the inclusion of the header, but these are likely to +be removed in the near future. @code{R_Calloc}, @code{R_Realloc}, and @code{R_Free} are currently implemented as macros expanding to calls to @code{R_chk_calloc}, From c573eee94c00aca395ea0c07632fdc69cbcff938 Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 12 Aug 2024 05:33:35 +0000 Subject: [PATCH 458/546] comment on move towards STRICT_R_HEADERS as default git-svn-id: https://svn.r-project.org/R/trunk@86995 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index cbf6982924f..a1a125e02f5 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -181,7 +181,7 @@ as \code{DBL_MAX} even if \file{STRICT_R_HEADERS} is defined. \item The legecy definition of \code{PI} in - \file{R_ext/Constants.h} (included by \file{R.h} will be removeed + \file{R_ext/Constants.h} (included by \file{R.h}) will be removeed shortly: use \code{M_PI} instead. } } From 01144fc43ee711ba3746f3d7f2822ddb5b4092ca Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 12 Aug 2024 07:30:19 +0000 Subject: [PATCH 459/546] document _R_USE_STRICT_R_HEADERS_, make it part of --as-cran git-svn-id: https://svn.r-project.org/R/trunk@86997 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 ++++ src/library/tools/R/check.R | 1 + 2 files changed, 5 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index a1a125e02f5..97f34b45040 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -193,6 +193,10 @@ \item \command{R CMD check --as-cran} notes bad parts in the \file{DESCRIPTION} file's URL fields. + + \item Installation will define \code{STRICT_R_HEADER} if + environment variable \env{_R_USE_STRICT_R_HEADERS_} is set to a + true value: this is done by \command{R CMD check --as-cran}. } } diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 72c3987216f..fdbd9813baf 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -7167,6 +7167,7 @@ add_dummies <- function(dir, Log) Sys.setenv("_R_CHECK_MBCS_CONVERSION_FAILURE_" = "TRUE") Sys.setenv("_R_CHECK_VALIDATE_UTF8_" = "TRUE") Sys.setenv("_R_CXX_USE_NO_REMAP_" = "TRUE") + Sys.setenv("_R_USE_STRICT_R_HEADERS_" = "TRUE") Sys.setenv("_R_CHECK_XREFS_NOTE_MISSING_PACKAGE_ANCHORS_" = "TRUE") R_check_vc_dirs <- TRUE R_check_executables_exclusions <- FALSE From 5e940aa8d2c28eff42d38d55ff85fa18f0271fcd Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 12 Aug 2024 07:30:51 +0000 Subject: [PATCH 460/546] typo git-svn-id: https://svn.r-project.org/R/trunk@86998 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 97f34b45040..9de12e97c91 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -194,7 +194,7 @@ \item \command{R CMD check --as-cran} notes bad parts in the \file{DESCRIPTION} file's URL fields. - \item Installation will define \code{STRICT_R_HEADER} if + \item Installation will define \code{STRICT_R_HEADERS} if environment variable \env{_R_USE_STRICT_R_HEADERS_} is set to a true value: this is done by \command{R CMD check --as-cran}. } From c4e4b2cfef24e76171b2a921ea96cc4793e7bba8 Mon Sep 17 00:00:00 2001 From: ripley Date: Mon, 12 Aug 2024 12:37:48 +0000 Subject: [PATCH 461/546] comments git-svn-id: https://svn.r-project.org/R/trunk@86999 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/R_ext/Constants.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/include/R_ext/Constants.h b/src/include/R_ext/Constants.h index d218f53b27b..68dfaa8e326 100644 --- a/src/include/R_ext/Constants.h +++ b/src/include/R_ext/Constants.h @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 1998-2022 The R Core Team. + * Copyright (C) 1998-2024 The R Core Team. * * This header file is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -27,7 +27,9 @@ #ifndef R_EXT_CONSTANTS_H_ #define R_EXT_CONSTANTS_H_ -/* usually in math.h, but not with strict C99/C++11 compliance */ +/* usually in math.h, but not with strict C99/C++11 compliance. + Also in Rmath.h + */ #ifndef M_PI #define M_PI 3.141592653589793238462643383279502884197169399375 #endif @@ -36,12 +38,14 @@ S-compatibility defines. */ #ifdef __cplusplus -#include /* Defines the RHSs, C++11 and later */ +# include /* Defines the RHSs, C++11 and later */ #else -#include /* Defines the RHSs, C99 and later */ +# include /* Defines the RHSs, C99 and later */ #endif + #ifndef STRICT_R_HEADERS -#define PI M_PI +# define PI M_PI +#endif /* The DOUBLE_* defines were deprecated in R 4.2.0 and removed in 4.3.0. #define DOUBLE_DIGITS DBL_MANT_DIG @@ -49,6 +53,5 @@ #define DOUBLE_XMAX DBL_MAX #define DOUBLE_XMIN DBL_MIN */ -#endif #endif /* R_EXT_CONSTANTS_H_ */ From ffb173627213c98a10d1306701ac7cf7d1230e12 Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 12 Aug 2024 15:51:17 +0000 Subject: [PATCH 462/546] NEWS entries. git-svn-id: https://svn.r-project.org/R/trunk@87000 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 9de12e97c91..5014f9750ba 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -58,6 +58,17 @@ \item Package \pkg{tools} now exports functions \code{R()} and \code{parse_URI_reference()}. + + \item It is now possible to set the background color for row and + column names in the data editor on Windows (\command{Rgui}). + + \item \command{Rterm} on Windows now accepts input lines of unlimited + length. + + \item \code{file.info()} on Windows now provides file owner name and + domain. + + \item \code{Sys.info()} on Windows now provides current user domain. } } From 6223118d882cd8b1fa6d68ffb364d6571b655bdd Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 13 Aug 2024 10:39:14 +0000 Subject: [PATCH 463/546] STRICT_R_HEADERS, including R headers in extern "C" {} git-svn-id: https://svn.r-project.org/R/trunk@87001 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 8 +++++--- doc/manual/R-exts.texi | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 5014f9750ba..6d5de6f1b97 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -191,9 +191,11 @@ includes header \file{float.h} or \file{cfloat} for constants such as \code{DBL_MAX} even if \file{STRICT_R_HEADERS} is defined. - \item The legecy definition of \code{PI} in - \file{R_ext/Constants.h} (included by \file{R.h}) will be removeed - shortly: use \code{M_PI} instead. + \item It is intended that \file{STRICT_R_HEADERS} will become the + default prior to release. This will remove the legacy definitions + of \code{PI}, \code{Calloc}, \code{Realloc} and \code{Free}: use + \code{M_PI}, \code{R_Calloc}, \code{R_Realloc} or \code{R_Free} + instead. } } diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index d02ac6a5525..cf429cd4560 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -6236,6 +6236,15 @@ Inclusion by such headers of C-style headers such as @file{math.h} (see above). The most portable way to interface to other software with a C API is to use C code (which can normally be mixed with C++ code in a package). +@item +Include only what is essential in @code{extern "C" @{@}} blocks in C++ +code. In particular it is not portable to include @R{} headers in such +blocks (although they are themselves C code, they may include C++ system +headers and the oublic ones already enclose their declarations in such a +block). And maintainers have include @R{} headers from other headers +included in such a block. +@c obscure compilation failures seen with clang++/libc++ + @item @code{reinterpret_cast} in C++ is not safe for pointers: for example the types may have different alignment requirements. Use @code{memcpy} to copy @@ -16103,9 +16112,9 @@ natural logarithm (@code{log(x)} in @R{}). @apihdr R_ext/Constants.h For compatibility with @Sl{} this file defines the constant @code{PI} (unless @code{STRICT_R_HEADERS} is defined): this is deprecated and -should be replaced by @code{M_PI}. @file{Constants.h} includes either C -header @file{float.h} or C++ header @file{cfloat}, which provide -constants such as @code{DBL_MAX}. +should be replaced by @code{M_PI}. Header @file{Constants.h} includes +either C header @file{float.h} or C++ header @file{cfloat}, which +provide constants such as @code{DBL_MAX}. @apivar TRUE @apivar FALSE From 2ed30a3fb43481ce3de763db099800ed74fef22f Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 13 Aug 2024 10:44:05 +0000 Subject: [PATCH 464/546] typo git-svn-id: https://svn.r-project.org/R/trunk@87003 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index cf429cd4560..1795cccc0eb 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -6240,7 +6240,7 @@ use C code (which can normally be mixed with C++ code in a package). Include only what is essential in @code{extern "C" @{@}} blocks in C++ code. In particular it is not portable to include @R{} headers in such blocks (although they are themselves C code, they may include C++ system -headers and the oublic ones already enclose their declarations in such a +headers and the public ones already enclose their declarations in such a block). And maintainers have include @R{} headers from other headers included in such a block. @c obscure compilation failures seen with clang++/libc++ From 6b12b481944c78e234b1e1f5404aec6b14657ac8 Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 13 Aug 2024 11:20:55 +0000 Subject: [PATCH 465/546] comments on using from C++ git-svn-id: https://svn.r-project.org/R/trunk@87004 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/R_ext/stats_package.h | 4 ++-- src/include/R_ext/stats_stubs.h | 4 ++-- src/include/Rmath.h0.in | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/include/R_ext/stats_package.h b/src/include/R_ext/stats_package.h index 5cf8a700d30..0695b8e3798 100644 --- a/src/include/R_ext/stats_package.h +++ b/src/include/R_ext/stats_package.h @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2007--2020 The R Core Team. + * Copyright (C) 2007--2024 The R Core Team. * * This header file is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -21,7 +21,7 @@ * https://www.R-project.org/Licenses/ */ -/* Not part of the API */ +/* Not part of the API, not callable from C++ */ #ifndef R_STATS_PACKAGE_H #define R_STATS_PACKAGE_H diff --git a/src/include/R_ext/stats_stubs.h b/src/include/R_ext/stats_stubs.h index 7030790b63d..92607f7bc72 100644 --- a/src/include/R_ext/stats_stubs.h +++ b/src/include/R_ext/stats_stubs.h @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2007--2020 The R Core Team. + * Copyright (C) 2007--2024 The R Core Team. * * This header file is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -21,7 +21,7 @@ * https://www.R-project.org/Licenses/ */ -/* Not part of the API */ +/* Not part of the API, not callable from C++ */ #include #include diff --git a/src/include/Rmath.h0.in b/src/include/Rmath.h0.in index 1ea5d8e42e1..b2aed0ff2fc 100644 --- a/src/include/Rmath.h0.in +++ b/src/include/Rmath.h0.in @@ -69,7 +69,9 @@ #if !defined(HAVE_WORKING_LOG1P) /* remap to avoid problems with getting the right entry point */ +extern "C" { double Rlog1p(double); +} #define log1p Rlog1p #endif From 0d416ec78f2c80cb4302804a48f5ff83598fd4d1 Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 13 Aug 2024 15:38:31 +0000 Subject: [PATCH 466/546] Unlimited line length on Unix with readline (PR#18690). git-svn-id: https://svn.r-project.org/R/trunk@87005 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/unix/sys-std.c | 54 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/src/unix/sys-std.c b/src/unix/sys-std.c index 41726969c44..cde9f8cca1a 100644 --- a/src/unix/sys-std.c +++ b/src/unix/sys-std.c @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 1997--2023 The R Core Team + * Copyright (C) 1997--2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -562,6 +562,7 @@ struct _R_ReadlineData { int readline_len; int readline_eof; unsigned char *readline_buf; + unsigned char *readline_rest; R_ReadlineData *prev; }; @@ -685,15 +686,33 @@ static void readline_handler(char *line) if (strlen(line) && rl_top->readline_addtohistory) add_history(line); # endif - /* We need to append a \n if the completed line would fit in the - buffer but not otherwise. Byte [buflen] is zeroed in - the caller. - */ - strncpy((char *)rl_top->readline_buf, line, buflen); + /* line does not include \n. We should behave like fgets(), so pretend + that the line terminator was read and return it in the buffer. We + should terminate the string by \0 (regardless of that R_ReplConsole + is robust against non-termination). + + If the line does not fit into the buffer, we should only return + a \0 terminated prefix that fits (not terminated by \n\0), like + fgets(). We place the rest into readline_rest so that it can + be returned by subsequent calls to ReadConsole. + + In principle. we might as well return the original buffer with the + whole line we get from readline, but the readline documentation + states that the buffer should be freed by the _handler_ (emphasis + added) when it is done with it. So better copy to be safe. */ size_t l = strlen(line); if(l < buflen - 1) { + memcpy(rl_top->readline_buf, line, l); rl_top->readline_buf[l] = '\n'; rl_top->readline_buf[l+1] = '\0'; + } else { + memcpy(rl_top->readline_buf, line, buflen - 1); + rl_top->readline_buf[buflen - 1] = '\0'; + size_t lrest = l - buflen + 1; + rl_top->readline_rest = R_Calloc(lrest + 2, unsigned char); + memcpy(rl_top->readline_rest, line + buflen - 1, lrest); + rl_top->readline_rest[lrest] = '\n'; + rl_top->readline_rest[lrest + 1] = '\0'; } } else { @@ -1029,10 +1048,31 @@ Rstd_ReadConsole(const char *prompt, unsigned char *buf, int len, } else { #ifdef HAVE_LIBREADLINE + static unsigned char *rl_rest = NULL; + static size_t rl_rest_offset = 0; + + if (rl_rest) { + /* remaining line data (too long line) from a previous call */ + size_t r = strlen(rl_rest + rl_rest_offset); + if (r < len) { + memcpy(buf, rl_rest + rl_rest_offset, r); + buf[r] = '\0'; /* buf[r-1] is \n */ + R_Free(rl_rest); + rl_rest = NULL; + rl_rest_offset = 0; + } else { + memcpy(buf, rl_rest + rl_rest_offset, len - 1); + buf[len - 1] = '\0'; + rl_rest_offset += len - 1; + } + return 1; + } + R_ReadlineData rl_data; if (UsingReadline) { rl_data.readline_gotaline = 0; rl_data.readline_buf = buf; + rl_data.readline_rest = NULL; rl_data.readline_addtohistory = addtohistory; rl_data.readline_len = len; rl_data.readline_eof = 0; @@ -1101,6 +1141,8 @@ Rstd_ReadConsole(const char *prompt, unsigned char *buf, int len, rl_callback_read_char(); if(rl_data.readline_eof || rl_data.readline_gotaline) { rl_top = rl_data.prev; + if (rl_data.readline_rest) + rl_rest = rl_data.readline_rest; return(rl_data.readline_eof ? 0 : 1); } } From 912022476adc9d5a70bf968402f00ebf4be6d5d0 Mon Sep 17 00:00:00 2001 From: maechler Date: Tue, 13 Aug 2024 16:05:48 +0000 Subject: [PATCH 467/546] findInterval() speed -- 2 new options `checkSorted`, `checkNA` git-svn-id: https://svn.r-project.org/R/trunk@87006 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 4 +++ src/library/base/R/findInt.R | 8 +++--- src/library/base/man/findInterval.Rd | 14 ++++++++-- src/main/names.c | 4 +-- src/main/util.c | 42 +++++++++++++++++----------- 5 files changed, 47 insertions(+), 25 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 6d5de6f1b97..c8647dd9ca7 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -69,6 +69,10 @@ domain. \item \code{Sys.info()} on Windows now provides current user domain. + + \item \code{findInterval()} gets new options \code{checkSorted} and + \code{checkNA} which allow to skip relatively costly checks; related + to \PR{16567}. } } diff --git a/src/library/base/R/findInt.R b/src/library/base/R/findInt.R index ff6b7ac4ef1..24f50e0b9ea 100644 --- a/src/library/base/R/findInt.R +++ b/src/library/base/R/findInt.R @@ -1,7 +1,7 @@ # File src/library/base/R/findInt.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2015 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,13 +18,13 @@ ### This is a `variant' of approx( method = "constant" ) : findInterval <- function(x, vec, rightmost.closed = FALSE, all.inside = FALSE, - left.open = FALSE) + left.open = FALSE, checkSorted = TRUE, checkNA = TRUE) { ## Purpose: returns the indices of x in vec; vec[] sorted ## --------------------------------------------------------- ## Author: Martin Maechler, Date: 4 Jan 2002 (of very different .C version) - if(!identical(FALSE, is.unsorted(vec))) + if(checkSorted && !identical(FALSE, is.unsorted(vec))) stop("'vec' must be sorted non-decreasingly and not contain NAs") .Internal(findInterval(as.double(vec), as.double(x), - rightmost.closed, all.inside, left.open)) + rightmost.closed, all.inside, left.open, checkNA)) } diff --git a/src/library/base/man/findInterval.Rd b/src/library/base/man/findInterval.Rd index 8c61349da24..dc75ece2ac1 100644 --- a/src/library/base/man/findInterval.Rd +++ b/src/library/base/man/findInterval.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/findInterval.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2015 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{findInterval} @@ -8,7 +8,7 @@ \title{Find Interval Numbers or Indices} \usage{ findInterval(x, vec, rightmost.closed = FALSE, all.inside = FALSE, - left.open = FALSE) + left.open = FALSE, checkSorted = TRUE, checkNA = TRUE) } \arguments{ \item{x}{numeric.} @@ -24,6 +24,13 @@ findInterval(x, vec, rightmost.closed = FALSE, all.inside = FALSE, swapped with \eqn{<} (and \eqn{>} with \eqn{\ge}), and \code{rightmost.closed} means \sQuote{leftmost is closed}. This may be useful, e.g., in survival analysis computations.} + \item{checkSorted}{logical indicating if \code{vec} should be checked, + i.e., \code{\link{is.unsorted(vec)}} is asserted to be false. Setting + this to \code{FALSE} skips the check gaining speed, but may return + nonsense results in case \code{vec} is not sorted.} + \item{checkNA}{logical indicating if each \code{x[i]} should be checked + as with \code{\link{is.na}(.)}. Setting this to \code{FALSE} in case + of \code{NA}'s in \code{x[]} may result in platform dependent nonsense.} } \description{ Given a vector of non-decreasing breakpoints in \code{vec}, find the @@ -88,6 +95,9 @@ X <- sort(round(stats::rt(N, df = 2), 2)) tt <- c(-100, seq(-2, 2, length.out = 201), +100) it <- findInterval(tt, X) tt[it < 1 | it >= N] # only first and last are outside range(X) +stopifnot(identical(it, ## suppressing the checks is faster *BUT* dangerous, unless + ## you *know* that X is sorted and tt contains no NA's + findInterval(tt, X, checkSorted=FALSE, checkNA=FALSE))) ## 'left.open = TRUE' means "mirroring" : N <- length(v) diff --git a/src/main/names.c b/src/main/names.c index a77b5d798d4..f6c89801ccd 100644 --- a/src/main/names.c +++ b/src/main/names.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1997--2023 The R Core Team + * Copyright (C) 1997--2024 The R Core Team * Copyright (C) 2003--2018 The R Foundation * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka * @@ -949,7 +949,7 @@ FUNTAB R_FunTab[] = {"lazyLoadDBinsertValue",do_lazyLoadDBinsertValue, 0, 11, 5, {PP_FUNCALL, PREC_FN, 0}}, {"bincode", do_bincode, 0, 11, 4, {PP_FUNCALL, PREC_FN, 0}}, {"tabulate", do_tabulate, 0, 11, 2, {PP_FUNCALL, PREC_FN, 0}}, -{"findInterval",do_findinterval, 0, 11, 5, {PP_FUNCALL, PREC_FN, 0}}, +{"findInterval",do_findinterval, 0, 11, 6, {PP_FUNCALL, PREC_FN, 0}}, {"pretty", do_pretty, 0, 11, 8, {PP_FUNCALL, PREC_FN, 0}}, {"formatC", do_formatC, 0, 11, 7, {PP_FUNCALL, PREC_FN, 0}}, {"crc64", do_crc64, 0, 11, 1, {PP_FUNCALL, PREC_FN, 0}}, diff --git a/src/main/util.c b/src/main/util.c index 541be12a4f0..77dba448699 100644 --- a/src/main/util.c +++ b/src/main/util.c @@ -935,7 +935,7 @@ static SEXP root_dir_on_drive(char d) buf[0] = d; buf[1] = ':'; buf[2] = '/'; - return mkCharLenCE(buf, 3, CE_UTF8); + return mkCharLenCE(buf, 3, CE_UTF8); } attribute_hidden SEXP do_dirname(SEXP call, SEXP op, SEXP args, SEXP rho) @@ -961,7 +961,7 @@ attribute_hidden SEXP do_dirname(SEXP call, SEXP op, SEXP args, SEXP rho) R_UTF8fixslash(buf); /* remove trailing file separator(s) */ while (ll && buf[ll-1] == '/') ll--; - if (ll == 2 && buf[1] == ':' && buf[2]) { + if (ll == 2 && buf[1] == ':' && buf[2]) { SET_STRING_ELT(ans, i, root_dir_on_drive(buf[0])); continue; } @@ -1376,7 +1376,7 @@ utf8toucs32(wchar_t high, const char *s) /* These return the result in wchar_t. If wchar_t is 16 bit (e.g. UTF-16LE on Windows) only the high surrogate is returned; call utf8toutf16low next. */ -size_t +size_t utf8toucs(wchar_t *wc, const char *s) { unsigned int byte; @@ -2091,8 +2091,8 @@ int attribute_hidden Rf_AdobeSymbol2ucs2(int n) R_strtod5 is used by type_convert(numerals=) (utils/src/io.c) The parser uses R_atof (and handles non-numeric strings itself). - That is the same as R_strtod but ignores endptr. - Also used by gnuwin32/windlgs/src/ttest.c, + That is the same as R_strtod but ignores endptr. + Also used by gnuwin32/windlgs/src/ttest.c, exported and in Utils.h (but not in R-exts). */ @@ -2230,7 +2230,7 @@ double R_strtod5(const char *str, char **endptr, char dec, It's not right if the exponent is very large, but the overflow or underflow below will handle it. 1e308 is already Inf, but negative exponents can go down to -323 - before undeflowing to zero. And people could do perverse things + before undeflowing to zero. And people could do perverse things like 0.00000001e312. */ // C17 Ā§6.4.4.2 requires a non-empty 'digit sequence' @@ -2808,12 +2808,13 @@ attribute_hidden SEXP do_tabulate(SEXP call, SEXP op, SEXP args, SEXP rho) attribute_hidden SEXP do_findinterval(SEXP call, SEXP op, SEXP args, SEXP rho) { checkArity(op, args); - SEXP xt, x, right, inside, leftOp; + SEXP xt, x, right, inside, leftOp, chkNA; xt = CAR(args); args = CDR(args); x = CAR(args); args = CDR(args); right = CAR(args); args = CDR(args); inside = CAR(args);args = CDR(args); - leftOp = CAR(args); + leftOp = CAR(args);args = CDR(args); + chkNA = CAR(args); if(TYPEOF(xt) != REALSXP || TYPEOF(x) != REALSXP) error("invalid input"); #ifdef LONG_VECTOR_SUPPORT if (IS_LONG_VEC(xt)) @@ -2829,15 +2830,21 @@ attribute_hidden SEXP do_findinterval(SEXP call, SEXP op, SEXP args, SEXP rho) error(_("invalid '%s' argument"), "all.inside"); SEXP ans = allocVector(INTSXP, nx); double *rxt = REAL(xt), *rx = REAL(x); - int ii = 1; - for(int i = 0; i < nx; i++) { + int ii = 1, mfl; + if (chkNA) + for(int i = 0; i < nx; i++) { if (ISNAN(rx[i])) ii = NA_INTEGER; - else { - int mfl; - ii = findInterval2(rxt, n, rx[i], sr, si, lO, ii, &mfl); // -> ../appl/interv.c - } + else +#define FIND_INT ii = findInterval2(rxt, n, rx[i], sr, si, lO, ii, &mfl) /* -> ../appl/interv.c */ + FIND_INT; INTEGER(ans)[i] = ii; + } + else { // do *not* check ISNAN(rx[i]) + for(int i = 0; i < nx; i++) { + FIND_INT; + INTEGER(ans)[i] = ii; + } } return ans; } @@ -3226,7 +3233,7 @@ SEXP do_compareNumericVersion(SEXP call, SEXP op, SEXP args, SEXP env) na = 0; PROTECT(ans = allocVector(INTSXP, na)); for(i = 0; i < na; i++) { - INTEGER(ans)[i] = + INTEGER(ans)[i] = compareNumericVersion(VECTOR_ELT(x, i % nx), VECTOR_ELT(y, i % ny)); } @@ -3246,7 +3253,7 @@ attribute_hidden int Rasprintf_malloc(char **str, const char *fmt, ...) /* could optimize by using non-zero initial size, large enough so that most prints with fill */ /* trio does not accept NULL as str */ - ret = vsnprintf(dummy, 0, fmt, ap); + ret = vsnprintf(dummy, 0, fmt, ap); va_end(ap); if (ret <= 0) @@ -3271,4 +3278,5 @@ attribute_hidden int Rasprintf_malloc(char **str, const char *fmt, ...) *str = buf; return ret; } - + + From c09a18ddc13280d5f6e9f86d81df31d5e180626d Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 13 Aug 2024 16:23:27 +0000 Subject: [PATCH 468/546] Expand documentation of R_ReadConsole. git-svn-id: https://svn.r-project.org/R/trunk@87007 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 1795cccc0eb..65aa18e4ed1 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -17860,13 +17860,16 @@ a state terminates (@code{@var{which}=0}). These functions interact with a console. -@code{R_ReadConsole} prints the given prompt at the console and then -does a @code{fgets(3)}--like operation, transferring up to @var{buflen} -characters into the buffer @var{buf}. The last two bytes should be -set to @samp{"\n\0"} to preserve sanity. If @var{hist} is non-zero, -then the line should be added to any command history which is being -maintained. The return value is 0 is no input is available and >0 -otherwise. +@code{R_ReadConsole} prints the given prompt at the console and then does a +@code{fgets(3)}--like operation, writing up to @var{buflen} bytes into the +buffer @var{buf}. The last of the bytes written should be @samp{"\0"}. +When there is enough space in the buffer to hold the full input line +including the line terminator, the line terminator should be included. +Otherwise, the rest of the line should be returned in subsequent calls to +@code{R_ReadConsole}. The last call should return data terminated by the line +terminator. If @var{hist} is non-zero, then the line should be added to any +command history which is being maintained. The return value is 0 if no +input is available and >0 otherwise. @code{R_WriteConsoleEx} writes the given buffer to the console, @var{otype} specifies the output type (regular output or From 32db856fb18430964c4166738cc73ede12df1942 Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 13 Aug 2024 16:28:17 +0000 Subject: [PATCH 469/546] Add cast. git-svn-id: https://svn.r-project.org/R/trunk@87008 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/unix/sys-std.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/sys-std.c b/src/unix/sys-std.c index cde9f8cca1a..80256a3e835 100644 --- a/src/unix/sys-std.c +++ b/src/unix/sys-std.c @@ -1053,7 +1053,7 @@ Rstd_ReadConsole(const char *prompt, unsigned char *buf, int len, if (rl_rest) { /* remaining line data (too long line) from a previous call */ - size_t r = strlen(rl_rest + rl_rest_offset); + size_t r = strlen((char *)rl_rest + rl_rest_offset); if (r < len) { memcpy(buf, rl_rest + rl_rest_offset, r); buf[r] = '\0'; /* buf[r-1] is \n */ From ff54a38433828cec6758eac6f47c22e83533698b Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 13 Aug 2024 18:08:39 +0000 Subject: [PATCH 470/546] Spelling. git-svn-id: https://svn.r-project.org/R/trunk@87009 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index c8647dd9ca7..aff5f5250dc 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -174,7 +174,7 @@ upgraded to \samp{WARNING}s in preparation for removing declarations and, where possible, hiding these entry points. - \item The set of Lapack (double and complex) routines in API headers + \item The set of LAPACK (double and complex) routines in API headers \file{R_ext/Lapack.h} and \file{R_ext/Applic.h} has been extended, mostly to routines actually in use from packages. From e2f10fa02eeea604afc21c559ce36ea1a49649b8 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 13 Aug 2024 18:09:29 +0000 Subject: [PATCH 471/546] Fix PR#18772. git-svn-id: https://svn.r-project.org/R/trunk@87010 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 65aa18e4ed1..2730d3e1b3c 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -353,7 +353,8 @@ Version: 0.5-1 Date: 2015-01-01 Title: My First Collection of Functions Authors@@R: c(person("Joe", "Developer", role = c("aut", "cre"), - email = "Joe.Developer@@some.domain.net"), + email = "Joe.Developer@@some.domain.net", + comment = c(ORCID = "nnnn-nnnn-nnnn-nnnn")), person("Pat", "Developer", role = "aut"), person("A.", "User", role = "ctb", email = "A.User@@whereever.net")) @@ -482,6 +483,9 @@ Auto-generated package citation information takes advantage of this specification. The @samp{Author} and @samp{Maintainer} fields are auto-generated from it if needed when building@footnote{at least if this is done in a locale which matches the package encoding.} or installing. +Note that for CRAN submissions, providing @samp{Authors@R} is required, +and providing @abbr{ORCID} identifiers (see \url{https://orcid.org/}) +where possible is strongly encouraged. @findex COPYRIGHTS @c DESCRIPTION field Copyright @@ -17001,7 +17005,7 @@ above (no longer maintained) @item @file{Rversion.h} @tab @R{} version information @item @file{Rinterface.h} @tab for add-on front-ends (Unix-alikes only) @item @file{Rembedded.h} @tab for add-on front-ends -@item @file{R_ext/Applic.h} @tab optimization, integration and some Lapack ones) +@item @file{R_ext/Applic.h} @tab optimization, integration and some LAPACK ones) @item @file{R_ext/BLAS.h} @tab C definitions for BLAS routines @item @file{R_ext/Callbacks.h} @tab C (and R function) top-level task handlers From 111a82b616f615503d83057e2f4e67c61b346f32 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 13 Aug 2024 18:52:31 +0000 Subject: [PATCH 472/546] Tweak for c87006. git-svn-id: https://svn.r-project.org/R/trunk@87011 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/findInterval.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/base/man/findInterval.Rd b/src/library/base/man/findInterval.Rd index dc75ece2ac1..513f372dcd9 100644 --- a/src/library/base/man/findInterval.Rd +++ b/src/library/base/man/findInterval.Rd @@ -25,7 +25,7 @@ findInterval(x, vec, rightmost.closed = FALSE, all.inside = FALSE, \code{rightmost.closed} means \sQuote{leftmost is closed}. This may be useful, e.g., in survival analysis computations.} \item{checkSorted}{logical indicating if \code{vec} should be checked, - i.e., \code{\link{is.unsorted(vec)}} is asserted to be false. Setting + i.e., \code{\link{is.unsorted}(vec)} is asserted to be false. Setting this to \code{FALSE} skips the check gaining speed, but may return nonsense results in case \code{vec} is not sorted.} \item{checkNA}{logical indicating if each \code{x[i]} should be checked From e7630d6c3b15d4e52677621b5908fc19cf56cce8 Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 13 Aug 2024 19:12:01 +0000 Subject: [PATCH 473/546] @ not \ in texinfo git-svn-id: https://svn.r-project.org/R/trunk@87012 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 2730d3e1b3c..ddcd0d8b8a9 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -484,7 +484,7 @@ specification. The @samp{Author} and @samp{Maintainer} fields are auto-generated from it if needed when building@footnote{at least if this is done in a locale which matches the package encoding.} or installing. Note that for CRAN submissions, providing @samp{Authors@R} is required, -and providing @abbr{ORCID} identifiers (see \url{https://orcid.org/}) +and providing @abbr{ORCID} identifiers (see @url{https://orcid.org/}) where possible is strongly encouraged. @findex COPYRIGHTS From 9cafcfb3163a702934cb3fc381f03a43e99c602c Mon Sep 17 00:00:00 2001 From: ripley Date: Wed, 14 Aug 2024 11:48:13 +0000 Subject: [PATCH 474/546] more on 'using namespace std' git-svn-id: https://svn.r-project.org/R/trunk@87013 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index ddcd0d8b8a9..6a07d3839c8 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -6084,7 +6084,10 @@ is not good practice, and has caused platform-dependent errors if included before headers, especially system headers (which may be included by other headers). The best practice is to use explicit @code{std::} prefixes for all functions declared by the C++ standard to -be in that namespace. +be in that namespace. It is an error to use @code{using namesapace +std} before including any C++ headers, and some recent compilers will +warn if this is done. +@c Both LLVM and Applw clang do. @item @c including @I{LLVM} clang as from 4.0.0 From a2d63ab6aac648834f84d9aa473b13aca5db443d Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 14 Aug 2024 19:01:29 +0000 Subject: [PATCH 475/546] Make sure SETJMP return value passed to LONGJMP is not zero. git-svn-id: https://svn.r-project.org/R/trunk@87015 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/context.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/context.c b/src/main/context.c index 35d9fc89e88..fe15ef9d399 100644 --- a/src/main/context.c +++ b/src/main/context.c @@ -238,6 +238,9 @@ attribute_hidden void NORET R_jumpctxt(RCNTXT * targetcptr, int mask, SEXP val) R_OldCStackLimit = 0; } + if (mask == 0) + mask = 1; // make sure the return value for SETJMP is not zero + LONGJMP(cptr->cjmpbuf, mask); } From 583df2508e4e2ae655e14cda1b35da44fe7b4930 Mon Sep 17 00:00:00 2001 From: pd Date: Thu, 15 Aug 2024 08:19:01 +0000 Subject: [PATCH 476/546] Make CRAN: src/base-prerelease primary source of snapshots git-svn-id: https://svn.r-project.org/R/trunk@87016 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-FAQ.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/manual/R-FAQ.texi b/doc/manual/R-FAQ.texi index 2268d968cd1..940fa59bf19 100644 --- a/doc/manual/R-FAQ.texi +++ b/doc/manual/R-FAQ.texi @@ -312,6 +312,8 @@ CVS). Tarballs with daily snapshots of the r-devel and r-patched development versions of R can be found at +@url{https://cran.r-project.org/src/base-prerelease}. An alternative +source is @url{https://stat.ethz.ch/R/daily/}. @c Sources are also available via anonymous rsync. Use From 3a0a3feba249a0bf4d89ef7f52697c2c46e94978 Mon Sep 17 00:00:00 2001 From: pd Date: Thu, 15 Aug 2024 08:20:18 +0000 Subject: [PATCH 477/546] Make CRAN: src/base-prerelease primary source of snapshots git-svn-id: https://svn.r-project.org/R/trunk@87017 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index f2ef85431db..135cda6d9a4 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -125,10 +125,13 @@ the patched version of the current release being available via Subversion.) The tarballs are available from -@uref{https://stat.ethz.ch/R/daily/}. Download +@uref{https://cran.r-project.org/src/base-prerelease}. Download @file{R-patched.tar.gz} or @file{R-devel.tar.gz} (or the @file{.tar.bz2} versions) and unpack as described in the previous section. They are -built in exactly the same way as distributions of @R{} releases. +built in exactly the same way and on the same platform as distributions +of @R{} releases. Notice, that you probably want to use the CRAN master +site for this, due to propagation delays. An +alternative source of daily snapshots is maintained at @uref{https://stat.ethz.ch/R/daily/}. @c Keep this single-item menu to avoid a spurious warning about From 3e449a54842d2a4aeb5fb203620718369c3a2a6b Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 15 Aug 2024 11:17:41 +0000 Subject: [PATCH 478/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@87018 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/raw.Rd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/library/base/man/raw.Rd b/src/library/base/man/raw.Rd index 7c921a9b931..85508e6c05d 100644 --- a/src/library/base/man/raw.Rd +++ b/src/library/base/man/raw.Rd @@ -49,6 +49,8 @@ is.raw(x) \code{NA} are set to \code{0} (the \code{nul} byte). \code{as.raw} and \code{is.raw} are \link{primitive} functions. + + \code{as.raw} is a generic function. } \seealso{ \code{\link{charToRaw}}, \code{\link{rawShift}}, etc. From cc2e00fd300d35643c2cd89209797294bd9f2448 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 15 Aug 2024 11:18:34 +0000 Subject: [PATCH 479/546] Drop GCC 14 diagnostics lines with code literals when checking compilation flags. git-svn-id: https://svn.r-project.org/R/trunk@87019 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index fdbd9813baf..c773fac81c1 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -3747,6 +3747,9 @@ add_dummies <- function(dir, Log) ## skip stuff before building libs ll <- grep("^[*][*] libs", lines, useBytes = TRUE) if (length(ll)) lines <- lines[-seq_len(ll[1L])] + ## drop GCC 14 diagnostics lines with code literals + patt <- "^[[:digit:]]+ \\|" + lines <- lines[!grepl(patt, lines, useBytes = TRUE)] poss <- grep(" -[Wmf]", lines, useBytes = TRUE, value = TRUE) ## compilation lines start at the left margin, ## and are not configure/echo lines From 0f63ec93e2f99fa361f74f46989f5af3abf0144c Mon Sep 17 00:00:00 2001 From: pd Date: Thu, 15 Aug 2024 14:13:41 +0000 Subject: [PATCH 480/546] typo git-svn-id: https://svn.r-project.org/R/trunk@87020 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 6a07d3839c8..7db06013d7e 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -6087,7 +6087,7 @@ included by other headers). The best practice is to use explicit be in that namespace. It is an error to use @code{using namesapace std} before including any C++ headers, and some recent compilers will warn if this is done. -@c Both LLVM and Applw clang do. +@c Both LLVM and Apple clang do. @item @c including @I{LLVM} clang as from 4.0.0 From bfa1c4fde68c852711f51a3d11332b20175be03c Mon Sep 17 00:00:00 2001 From: lawrence Date: Thu, 15 Aug 2024 18:31:01 +0000 Subject: [PATCH 481/546] add the matrixOps group generic to the methods package git-svn-id: https://svn.r-project.org/R/trunk@87021 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/groupGeneric.Rd | 2 +- src/library/methods/NAMESPACE | 1 + src/library/methods/R/BasicFunsList.R | 2 -- src/library/methods/R/makeBasicFunsList.R | 8 ++++++++ src/library/methods/man/S4groupGeneric.Rd | 9 ++++++--- src/main/array.c | 6 +----- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/library/base/man/groupGeneric.Rd b/src/library/base/man/groupGeneric.Rd index 94c41aa1d04..86a161ba951 100644 --- a/src/library/base/man/groupGeneric.Rd +++ b/src/library/base/man/groupGeneric.Rd @@ -22,7 +22,7 @@ Group generic methods can be defined for the following pre-specified groups of functions, \code{Math}, \code{Ops}, \code{matrixOps}, \code{Summary} and \code{Complex}. (There are no objects of these names in base \R, but there are in the - \pkg{methods} package, not yet for \code{matrixOps}.) + \pkg{methods} package.) A method defined for an individual member of the group takes precedence over a method defined for the group as a whole. diff --git a/src/library/methods/NAMESPACE b/src/library/methods/NAMESPACE index 240658e1a47..7a2b32f6091 100644 --- a/src/library/methods/NAMESPACE +++ b/src/library/methods/NAMESPACE @@ -134,6 +134,7 @@ export(makeMethodsList) export(makePrototypeFromClassDef) export(makeStandardGeneric) export(matchSignature) +export(matrixOps) export(mergeMethods) export(metaNameUndo) export(methodSignatureMatrix) diff --git a/src/library/methods/R/BasicFunsList.R b/src/library/methods/R/BasicFunsList.R index c4ce3fe7825..7b5e0534d56 100644 --- a/src/library/methods/R/BasicFunsList.R +++ b/src/library/methods/R/BasicFunsList.R @@ -41,8 +41,6 @@ list( , "[<-" = function(x, i, j, ..., value) standardGeneric("[<-") , "[[" = function(x, i, j, ...) standardGeneric("[[") , "[[<-" = function(x, i, j, ..., value) standardGeneric("[[<-") -### S4 generic via R_possible_dispatch in do_matprod -, "%*%" = function(x, y) standardGeneric("%*%") , "crossprod" = function(x, y=NULL, ...) standardGeneric("crossprod") , "tcrossprod"= function(x, y=NULL, ...) standardGeneric("tcrossprod") , "xtfrm" = function(x) standardGeneric("xtfrm") diff --git a/src/library/methods/R/makeBasicFunsList.R b/src/library/methods/R/makeBasicFunsList.R index 0b8810d2c84..11f04d20d3c 100644 --- a/src/library/methods/R/makeBasicFunsList.R +++ b/src/library/methods/R/makeBasicFunsList.R @@ -120,6 +120,14 @@ utils::globalVariables(".addBasicGeneric") knownMembers = c("Arith", "Compare", "Logic"), package = "base") + ## The matrixOps group + members <- c("%*%") + for(f in members) + funs <- .addBasicGeneric(funs, f, function(x, y) standardGeneric(""), + "matrixOps") + + setGroupGeneric(where = where, "matrixOps", function(x, y) NULL, + knownMembers = members, package = "base") ## The Summary group diff --git a/src/library/methods/man/S4groupGeneric.Rd b/src/library/methods/man/S4groupGeneric.Rd index c8197015ff6..58d1c4bee87 100644 --- a/src/library/methods/man/S4groupGeneric.Rd +++ b/src/library/methods/man/S4groupGeneric.Rd @@ -8,6 +8,7 @@ \alias{GroupGenericFunctions} \alias{Math} \alias{Ops} +\alias{matrixOps} \alias{Summary} \alias{Arith} \alias{Logic} @@ -35,6 +36,7 @@ Arith(e1, e2) Compare(e1, e2) Ops(e1, e2) +matrixOps(x, y) Logic(e1, e2) Math(x) Math2(x, digits) @@ -42,7 +44,7 @@ Summary(x, \dots, na.rm = FALSE) Complex(z) } \arguments{ - \item{x, z, e1, e2}{objects.} + \item{x, y, z, e1, e2}{objects.} \item{digits}{number of digits to be used in \code{round} or \code{signif}.} \item{\dots}{further arguments passed to or from methods.} \item{na.rm}{logical: should missing values be removed?} @@ -62,8 +64,8 @@ Complex(z) method selection, see \code{\link{Methods_Details}}. There are also - S3 groups \code{Math}, \code{Ops}, \code{Summary} and - \code{Complex}, see \code{?\link{S3groupGeneric}}, + S3 groups \code{Math}, \code{Ops}, \code{Summary}, \code{Complex} + and \code{matrixOps}, see \code{?\link{S3groupGeneric}}, with no corresponding \R objects, but these are irrelevant for S4 group generic functions. @@ -97,6 +99,7 @@ There are also \code{"prod"}, \code{"sum"}, \code{"any"}, \code{"all"}} \item{\code{Complex}}{\code{"Arg"}, \code{"Conj"}, \code{"Im"}, \code{"Mod"}, \code{"Re"}} + \item{\code{matrixOps}}{\code{"\%*\%"}} } Note that \code{Ops} merely consists of three sub groups. diff --git a/src/main/array.c b/src/main/array.c index 071c02898ef..0d042c7f92b 100644 --- a/src/main/array.c +++ b/src/main/array.c @@ -1277,11 +1277,7 @@ attribute_hidden SEXP do_matprod(SEXP call, SEXP op, SEXP args, SEXP rho) /* Remove argument names to ensure positional matching */ for(s = args; s != R_NilValue; s = CDR(s)) SET_TAG(s, R_NilValue); - if ((IS_S4_OBJECT(x) || IS_S4_OBJECT(y)) && R_has_methods(op)){ - value = R_possible_dispatch(call, op, args, rho, FALSE); - if (value) return value; - } - else if (DispatchGroup("matrixOps", call, op, args, rho, &ans)) + if (DispatchGroup("matrixOps", call, op, args, rho, &ans)) return ans; } // the default method: From 23617ddf40194b1d428ec7606324a79845e057f0 Mon Sep 17 00:00:00 2001 From: ripley Date: Thu, 15 Aug 2024 19:15:31 +0000 Subject: [PATCH 482/546] comment out unused variable git-svn-id: https://svn.r-project.org/R/trunk@87022 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/array.c b/src/main/array.c index 0d042c7f92b..9cfcede3a3e 100644 --- a/src/main/array.c +++ b/src/main/array.c @@ -1273,7 +1273,7 @@ attribute_hidden SEXP do_matprod(SEXP call, SEXP op, SEXP args, SEXP rho) SEXP x = CAR(args), y = CADR(args), ans; if (OBJECT(x) || OBJECT(y)) { - SEXP s, value; + SEXP s; //, value; /* Remove argument names to ensure positional matching */ for(s = args; s != R_NilValue; s = CDR(s)) SET_TAG(s, R_NilValue); From 2543f228ff2092be672b359d48ea02c64af8fcf7 Mon Sep 17 00:00:00 2001 From: ripley Date: Fri, 16 Aug 2024 06:36:05 +0000 Subject: [PATCH 483/546] Intel's icpx also warns git-svn-id: https://svn.r-project.org/R/trunk@87023 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 7db06013d7e..4552662bd1f 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -6087,7 +6087,7 @@ included by other headers). The best practice is to use explicit be in that namespace. It is an error to use @code{using namesapace std} before including any C++ headers, and some recent compilers will warn if this is done. -@c Both LLVM and Apple clang do. +@c LLVM and Apple clang and Intel icpx do. @item @c including @I{LLVM} clang as from 4.0.0 From 99340a38bd731e38473c2e7c265ee9eaf567b8d3 Mon Sep 17 00:00:00 2001 From: ripley Date: Fri, 16 Aug 2024 06:38:41 +0000 Subject: [PATCH 484/546] typo git-svn-id: https://svn.r-project.org/R/trunk@87024 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 4552662bd1f..f70ea23d111 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -6084,7 +6084,7 @@ is not good practice, and has caused platform-dependent errors if included before headers, especially system headers (which may be included by other headers). The best practice is to use explicit @code{std::} prefixes for all functions declared by the C++ standard to -be in that namespace. It is an error to use @code{using namesapace +be in that namespace. It is an error to use @code{using namespace std} before including any C++ headers, and some recent compilers will warn if this is done. @c LLVM and Apple clang and Intel icpx do. From 70a3052e8e0e066df27f89cc4908f8e90fd85d40 Mon Sep 17 00:00:00 2001 From: ripley Date: Fri, 16 Aug 2024 06:41:13 +0000 Subject: [PATCH 485/546] long-standing typo git-svn-id: https://svn.r-project.org/R/trunk@87025 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index f70ea23d111..dc5eea6457a 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -6077,7 +6077,7 @@ conflicts with @code{std::make_unique} from C++14 and @code{std::byte}, @item In C++ code @example -using namesapace std; +using namespace std; @end example @noindent is not good practice, and has caused platform-dependent errors if From 4012847c459cf62eead00090c9954f10ed3d52fa Mon Sep 17 00:00:00 2001 From: kalibera Date: Sat, 17 Aug 2024 14:41:27 +0000 Subject: [PATCH 486/546] Improve handling of very long input lines in Rgui console (PR#18690). git-svn-id: https://svn.r-project.org/R/trunk@87027 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/console.c | 163 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 148 insertions(+), 15 deletions(-) diff --git a/src/gnuwin32/console.c b/src/gnuwin32/console.c index ceb80c4fb8f..d2d6be51300 100644 --- a/src/gnuwin32/console.c +++ b/src/gnuwin32/console.c @@ -1713,42 +1713,72 @@ static void draweditline(control c) } /* This needs to convert the nul-terminated wchar_t string 'in' to a - sensible strinf in buf[len]. It must not be empty, as R will - interpret that as EOF, and it should end in \n, as 'in' should do. + sensible string in buf. It must not be empty, as R will + interpret that as EOF, but 'in' would not be empty. The returned string + should end in \n when 'in' does. The string is malloc'd by wcstobuf(). Our strategy is to convert character by character to the current Windows locale, using \uxxxx escapes for invalid characters. */ -static void wcstobuf(char *buf, int len, const wchar_t *in) +static void wcstobuf(char **buf, const wchar_t *in) { - int used, tot = 0; - char *p = buf, tmp[7]; - const wchar_t *wc = in; + int used; + char *p, tmp[MB_CUR_MAX]; + const wchar_t *wc; wchar_t wc_check; mbstate_t mb_st; - for(; wc; wc++, p+=used, tot+=used) { - if(tot >= len - 2) break; - used = wctomb(p, *wc); + size_t needed = 0; + for(wc = in; *wc; wc++) { + used = wctomb(tmp, *wc); if (used >= 0) { /* conversion was successful, but check that converting back gets the original result (it does not with best-fit transliteration) NOTE: WideCharToMultiByte may be faster */ memset(&mb_st, 0, sizeof(mbstate_t)); + if (mbrtowc(&wc_check, tmp, used, &mb_st) < 0 || wc_check != *wc) + used = -1; + } + if (used < 0) + used = 6; /* \unnnn */ + needed += used; + } + needed++; /* \0 */ + + *buf = malloc(needed); + if (!*buf) { + R_ShowMessage(G_("Not enough memory")); + return; + } + + for(wc = in, p = *buf; *wc; wc++, p+=used) { + used = wctomb(p, *wc); + if (used >= 0) { + memset(&mb_st, 0, sizeof(mbstate_t)); if (mbrtowc(&wc_check, p, used, &mb_st) < 0 || wc_check != *wc) used = -1; } if (used < 0) { - snprintf(tmp, 7, "\\u%x", *wc); - used = strlen(tmp); - memcpy(p, tmp, used); + /* Note that this hack only works inside string literals, where + the parser accepts such escapes. Outside, one gets an error. + This is not relevant with UTF-8 as the native encoding. */ + snprintf(p, 7, "\\u%04x", *wc); + used = 6; } } - *p++ = '\n'; *p = '\0'; + *p = '\0'; } -int consolereads(control c, const char *prompt, char *buf, int len, +/* len is a suggested number of characters per line. The line or its segment + is returned in malloc'd buffer as *buf and is zero-terminated. + The terminator is preceeded by \n only in the last segment of the + line. + + The code may be simpler if changed to reading lines of arbitrary length, + but getting there might not be worth the effort. */ + +int consolereads0(control c, const char *prompt, char **buf, int len, int addtohistory) { ConsoleData p = getdata(c); @@ -1901,7 +1931,8 @@ int consolereads(control c, const char *prompt, char *buf, int len, cur_line[max_pos + 1] = L'\0'; } else cur_line[max_pos] = L'\0'; - wcstobuf(buf, len, cur_line); + if (buf) + wcstobuf(buf, cur_line); //sprintf(buf, "%ls", cur_line); //if(strlen(buf) == 0) strcpy(buf, "invalid input\n"); CURROW = -1; @@ -1919,6 +1950,108 @@ int consolereads(control c, const char *prompt, char *buf, int len, } } +int consolereads(control c, const char *prompt, char *buf, int len, + int addtohistory) +{ + static char *line = NULL; + static size_t offset = 0; + static int res = 0; + + if (!line) { + char *segment; + size_t slen; + size_t llen; + + segment = NULL; + res = consolereads0(c, prompt, &segment, len, addtohistory); + if (!segment) { + /* error */ + buf[0] = '\0'; + return res; + } + slen = strlen(segment); + if (!slen || (segment[slen - 1] == '\n' && slen < len - 1) + || len == slen - 1) { + + /* line ends within the segment (common case) or + segment is empty (should not happen) or + internal segment of line of same length as buffer */ + + memcpy(buf, segment, slen); + free(segment); + buf[slen] = '\0'; + return res; + } + + /* Now read the (rest of) the line and only after that present it + to the parser. This is an emulation of the parse loop but is + robust to variations in the number of bytes read in each iteration. + + The problem is that consolereads0() cannot easily cap + the number of bytes read to an exact boundary, because it was + designed to work on wchar_ts (BMP characters): these differ in + length in multi-byte representation and they may be replaced + by escapes to avoid transliteration. + + This hence captures some of the behavior of the parse loop by + assuming a certain way to compute the continuation prompt. Also, + it post-pones detection of some parse/lexer errors until the + line is finished (so as if the editor allowed entering unlimited + lines, but without actually fully supporting editing of such lines) + */ + line = segment; + llen = slen; + offset = 0; + segment = NULL; + + while(slen && line[llen - 1] != '\n') { + const char *cprompt = CHAR(STRING_ELT( + GetOption1(install("continue")), 0)); + res |= consolereads0(c, cprompt, &segment, len, addtohistory); + if (!segment) { + /* error */ + buf[0] = '\0'; + free(line); + line = NULL; + return res; + } + + slen = strlen(segment); + char *newline = realloc(line, llen + slen + 1); + if (!newline) { + /* allocation error */ + buf[0] = '\0'; + free(segment); + free(line); + line = NULL; + return res; + } + line = newline; + memcpy(line + llen, segment, slen); + llen += slen; + line[llen] = '\0'; + free(segment); + segment = NULL; + } + } + + if (line) { + size_t rlen = strlen(line + offset); + if (rlen < len) { + memcpy(buf, line + offset, rlen); + buf[rlen] = '\0'; + free(line); + line = NULL; + offset = 0; + } else { + memcpy(buf, line + offset, len - 1); + buf[len - 1] = '\0'; + offset += len - 1; + } + } + return res; +} + void console_sbf(control c, int pos) { ConsoleData p = getdata(c); From 304af48d703f214bc272d9f640cd28b37d377c08 Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 19 Aug 2024 14:13:37 +0000 Subject: [PATCH 487/546] Fix pushback at end of line (overflow character) in Rgui console for clipboard input. git-svn-id: https://svn.r-project.org/R/trunk@87028 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/gnuwin32/console.c | 25 ++++++++++++++++++++++++- src/gnuwin32/consolestructs.h | 4 +++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/gnuwin32/console.c b/src/gnuwin32/console.c index d2d6be51300..f1088463396 100644 --- a/src/gnuwin32/console.c +++ b/src/gnuwin32/console.c @@ -335,6 +335,7 @@ newconsoledata(font f, int rows, int cols, int bufbytes, int buflines, p->kind = kind; /* PR#14624 claimed this was needed, with no example */ p->chbrk = p->modbrk = '\0'; + p->pushed_back_char = L'\0'; if (kind == CONSOLE) { p->lbuf = newxbuf(bufbytes, buflines, SLBUF); if (!p->lbuf) { @@ -1619,6 +1620,11 @@ static wchar_t consolegetc(control c) wchar_t ch; p = getdata(c); + if (p->pushed_back_char) { + ch = p->pushed_back_char; + p->pushed_back_char = L'\0'; + return ch; + } while((p->numkeys == 0) && (!p->clp)) { R_WaitEvent(); @@ -1674,6 +1680,22 @@ static wchar_t consolegetc(control c) return ch; } +/* only works for a single wide character; only used at the end of line + during overflow */ +static void consoleungetc(control c, wchar_t ch) +{ + ConsoleData p; + + p = getdata(c); + p->pushed_back_char = ch; +} + +/* +Has been used before at the end of line (during overflow); does not correctly +handle completed input from clipboard (e.g. pasting a single character), +it erroneously provides previous keyboard input (the completed clipboard +input is lost). + static void consoleunputc(control c) { ConsoleData p = getdata(c); @@ -1685,6 +1707,7 @@ static void consoleunputc(control c) else p->firstkey = NKEYS - 1; } } +*/ /* This scrolls as far left as possible */ static void checkvisible(control c) @@ -1920,7 +1943,7 @@ int consolereads0(control c, const char *prompt, char **buf, int len, if (chtype || (cur_char == L'\n') || (cur_char == EOFKEY)) { if (chtype) { if (cur_pos == max_pos) { - consoleunputc(c); + consoleungetc(c, cur_char); } else { gabeep(); break; diff --git a/src/gnuwin32/consolestructs.h b/src/gnuwin32/consolestructs.h index 277c05a0b47..781bb1023a3 100644 --- a/src/gnuwin32/consolestructs.h +++ b/src/gnuwin32/consolestructs.h @@ -2,7 +2,7 @@ * R : A Computer Language for Statistical Data Analysis * file consolestructs.h * Copyright (C) 2004-8 The R Foundation - * Copyright (C) 2023 The R Core Team + * Copyright (C) 2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -71,6 +71,8 @@ struct structConsoleData { int cursor_blink; menuitem mcopy, mpaste, mpastecmds, mpopcopy, mpoppaste, mpoppastecmds; + + wchar_t pushed_back_char; /* consolegetc, consoleungetc */ }; typedef struct structConsoleData *ConsoleData; From 874fa1008e6cb090c7c898c422d703ca0026d600 Mon Sep 17 00:00:00 2001 From: hornik Date: Tue, 20 Aug 2024 13:50:09 +0000 Subject: [PATCH 488/546] Add mirrors.hust.edu.cn. git-svn-id: https://svn.r-project.org/R/trunk@87029 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index 7900b6e0756..eb51e9feb2e 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -30,6 +30,7 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "China (Nanjing) [https]",China,Nanjing,https://mirrors.nju.edu.cn/CRAN/,"eScience Center, Nanjing University","my # yaoge123.com",1,cn,"secure_mirror_from_master" "China (Shanghai 2) [https]",China,Shanghai,https://mirrors.sjtug.sjtu.edu.cn/cran/,"Shanghai Jiao Tong University","Alex Chi ",1,cn,"secure_mirror_from_master" "China (Shenzhen) [https]",China,Shenzhen,https://mirrors.sustech.edu.cn/CRAN/,"Southern University of Science and Technology (SUSTech)","cra # sustech.edu.cn",1,cn,"secure_mirror_from_master" +"China (Wuhan) [https]",China,Wuhan,https://mirrors.hust.edu.cn/CRAN/,"Huazhong University of Science and Technology","mirror_support # hust.edu.cn",1,cn "China (Xianyang) [https]",China,Xianyang,https://mirrors.nwafu.edu.cn/cran/,"Northwest A&F University (NWAFU)","dingyuxiao99 # nwafu.edu.cn",1,cn "Colombia (Cali) [https]",Colombia,Cali,https://www.icesi.edu.co/CRAN/,"Icesi University","adminred # Icesi.edu.co",1,co,"secure_mirror_from_master" "Costa Rica [https]","Costa Rica","San JosĆ©",https://mirror.uned.ac.cr/cran/,"Distance State University (UNED)","rherrerav # uned.ac.cr",1,cr,"secure_mirror_from_master" From 909257ea1260997dc760777c99a5bd9902f2008d Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 21 Aug 2024 09:22:02 +0000 Subject: [PATCH 489/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@87030 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index eb51e9feb2e..e32114adb6e 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -26,7 +26,7 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "China (Hong Kong) [https]",China,"Hong Kong",https://mirror-hk.koddos.net/CRAN/,"KoDDoS in Hong Kong","mirror # koddos.net",1,cn,"secure_mirror_from_master" "China (Guangzhou) [https]",China,Guangzhou,https://mirrors.e-ducation.cn/CRAN/,"Elite Education","x.liu # eliteu.cn",1,cn,"secure_mirror_from_master" "China (Jinan) [https]",China,Jinan,https://mirrors.qlu.edu.cn/CRAN/,"Qilu University of Technology","admin # qlunet.cn",1,cn,"secure_mirror_from_master" -"China (Lanzhou) [https]",China,Lanzhou,https://mirror.lzu.edu.cn/CRAN/,"Lanzhou University Open Source Society","oss.lzu.edu.cn # gmail.com",1,cn,"secure_mirror_from_master" +"China (Lanzhou) [https]",China,Lanzhou,https://mirror.lzu.edu.cn/CRAN/,"Lanzhou University Open Source Society","oss.lzu.edu.cn # gmail.com",0,cn,"secure_mirror_from_master" "China (Nanjing) [https]",China,Nanjing,https://mirrors.nju.edu.cn/CRAN/,"eScience Center, Nanjing University","my # yaoge123.com",1,cn,"secure_mirror_from_master" "China (Shanghai 2) [https]",China,Shanghai,https://mirrors.sjtug.sjtu.edu.cn/cran/,"Shanghai Jiao Tong University","Alex Chi ",1,cn,"secure_mirror_from_master" "China (Shenzhen) [https]",China,Shenzhen,https://mirrors.sustech.edu.cn/CRAN/,"Southern University of Science and Technology (SUSTech)","cra # sustech.edu.cn",1,cn,"secure_mirror_from_master" From 182c1762c227342874b2f20413e8db61da24eef6 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 21 Aug 2024 11:09:38 +0000 Subject: [PATCH 490/546] Drop packages.othr.de, mirrors.upm.edu.my, mirror.epn.edu.ec, cran.stat.upd.edu.ph, cran.ncc.metu.edu.tr, cran.curtin.edu.au, and cran.biodisk.org. git-svn-id: https://svn.r-project.org/R/trunk@87031 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 7 ------- 1 file changed, 7 deletions(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index e32114adb6e..671a8bc4ef6 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -4,7 +4,6 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Australia (Canberra) [https]",Australia,Canberra,https://cran.csiro.au/,CSIRO,"ben.tan # csiro.au, Jayesh.joshi # csiro.au, CSIROServiceDesk # csiro.au",1,au,"secure_mirror_from_master" "Australia (Melbourne 1) [https]",Australia,Melbourne,https://mirror.aarnet.edu.au/pub/CRAN/,AARNET,"",1,au,"secure_mirror_from_master" "Australia (Melbourne 2) [https]",Australia,Melbourne,https://cran.ms.unimelb.edu.au/,"School of Mathematics and Statistics, University of Melbourne","sys-unix # lists.unimelb.edu.au",1,au,"secure_mirror_from_master" -"Australia (Perth) [https]",Australia,Perth,https://cran.curtin.edu.au/,"Curtin University","unix # curtin.edu.au",0,au,"secure_mirror_from_master" "Austria [https]",Austria,Wien,https://cran.wu.ac.at/,"WirtschaftsuniversitƤt Wien","CRAN # R-project.org",1,at,"secure_mirror_from_master" "Belgium (Antwerp) [https]",Belgium,Antwerp,https://www.freestatistics.org/cran/,"Patrick Wessa","patrick # wessa.net",1,be "Belgium (Brussels) [https]",Belgium,Brussels,https://ftp.belnet.be/mirror/CRAN/,"Belnet, the Belgian research and education network","ftpmaint # belnet.be",1,be,"secure_mirror_from_master" @@ -39,7 +38,6 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Denmark [https]",Denmark,Aalborg,https://mirrors.dotsrc.org/cran/,"Aalborg University","staff # dotsrc.org",1,dk,"secure_mirror_from_master" "East Asia [https]",0-Cloud-East-Asia,0-Cloud-East-Asia,"https://cran.asia/","Personnel Psychology Laboratory, Kwangwoon University (sites: Seoul, Tokyo, Singapore, Manila, Bangalore)","admin # cran.asia",1,asia,"secure_mirror_from_master,maintainer_address_bounces" "Ecuador (Cuenca) [https]",Ecuador,Cuenca,https://mirror.cedia.org.ec/CRAN/,CEDIA,"mirror # cedia.org.ec",1,ec,"secure_mirror_from_master" -"Ecuador (Quito) [https]",Ecuador,Quito,https://mirror.epn.edu.ec/CRAN/,Escuela PolitĆ©cnica Nacional,"paul.bernal # cedia.org.ec",0,ec,"secure_mirror_from_master" "France (Lyon 1) [https]",France,Lyon,https://pbil.univ-lyon1.fr/CRAN/,"Dept. of Biometry & Evol. Biology, University of Lyon","Jean Thioulouse ",1,fr,"secure_mirror_from_master" "France (Lyon 2) [https]",France,Lyon,https://mirror.ibcp.fr/pub/CRAN/,"CNRS IBCP, Lyon","alexis.michon # ibcp.fr",1,fr,"secure_mirror_from_master" "France (Marseille) [https]",France,Marseille,https://cran.biotools.fr/,"IBDM, Marseille","andrew.saurin # univ-amu.fr",1,fr,"secure_mirror_from_master" @@ -52,7 +50,6 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Germany (MĆ¼nster) [https]",Germany,MĆ¼nster,https://cran.uni-muenster.de/,"University of MĆ¼nster, Germany","Edzer Pebesma ",1,de,"secure_mirror_from_master" "Germany (NĆ¼rnberg) [https]",Germany,NĆ¼rnberg,https://mirror.clientvps.com/CRAN/,ClientVPS,"info # clientvps.com",1,de,"maintainer_address_bounces" "Germany (Oberhausen) [https]",Germany,Oberhausen,https://mirror.kamp.de/cran/,"KAMP Netzwerkdienste GmbH","support # kamp.de",1,de -"Germany (Regensburg) [https]",Germany,Regensburg,https://packages.othr.de/cran/,"OTH Regensburg","admin-storage # oth-regensburg.de",0,de,"secure_mirror_from_master" "Greece [https]",Greece,Crete,https://ftp.cc.uoc.gr/mirrors/CRAN/,"University of Crete","mirrors # Cc.uoc.gr",1,gr,"secure_mirror_from_master" "Iceland [https]",Iceland,Reykjavik,https://cran.hafro.is/,"Marine Research Institute","cran # hafro.is",1,is,"secure_mirror_from_master" "India (Bengaluru) [https]",India,Bengaluru,https://cran.icts.res.in/,"International Centre for Theoretical Sciences","cran # icts.res.in",1,in,"secure_mirror_from_master" @@ -63,8 +60,6 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Italy (Padua) [https]",Italy,Padua,https://cran.stat.unipd.it/,"University of Padua","cran # stat.unipd.it",1,it,"secure_mirror_from_master" "Japan (Yonezawa) [https]",Japan,Yonezawa,https://ftp.yz.yamagata-u.ac.jp/pub/cran/,"Yamagata University","www-admin # ftp.yz.yamagata-u.ac.jp",1,jp,"secure_mirror_from_master" "Korea (Gyeongsan-si) [https]",Korea,Gyeongsan-si,https://cran.yu.ac.kr/,"Yeungnam University","sysop # yu.ac.kr",1,kr,"secure_mirror_from_master" -"Korea (Ulsan) [https]",Korea,Ulsan,https://cran.biodisk.org/,"The Genome Institute of UNIST (Ulsan National Institute of Science and Technology)","ldsrman # gmail.com",0,kr,"secure_mirror_from_master" -"Malaysia [https]",Malaysia,Serdang,https://mirrors.upm.edu.my/CRAN/,"Universiti Putra Malaysia","Ng Keng Yap ",0,my,"secure_mirror_from_master" "Mexico (Mexico City) [https]",Mexico,"Mexico City",https://cran.itam.mx/,"Instituto Tecnologico Autonomo de Mexico","Ernesto Barrios ",1,mx,"secure_mirror_from_master" "Mexico (Texcoco) [https]",Mexico,Texcoco,https://www.est.colpos.mx/,"Colegio de Postgraduados, Texcoco","perpdgo # gmail.com",1,mx,"secure_mirror_from_master" "Morocco [https]",Morocco,Rabat,https://mirror.marwan.ma/cran/,"MARWAN","noc # marwan.ma",1,ma,"secure_mirror_from_master" @@ -72,7 +67,6 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Netherlands (Dronten) [https]","Netherlands",Dronten,https://mirror.lyrahosting.com/CRAN/,"Lyra Hosting","admin # lyrahosting.com",1,nl,"secure_mirror_from_master" "New Zealand [https]","New Zealand",Auckland,https://cran.stat.auckland.ac.nz/,"University of Auckland","s.urbanek # auckland.ac.nz",1,nz,"secure_mirror_from_master" "Norway [https]",Norway,Bergen,https://cran.uib.no/,"University of Bergen","sundrift # It.uib.no",1,no,"secure_mirror_from_master" -"Philippines [https]",Philippines,"Quezon City",https://cran.stat.upd.edu.ph/,"University of the Philippines and PREGINET","COARE Team , ops # pregi.net",0,ph,"maintainer_address_bounces" "Poland [https]",Poland,Warsaw,https://cran.mi2.ai/,"MI2.ai, Warsaw University of Technology","przemyslaw.biecek # gmail.com",1,pl "Portugal (Lisbon) [https]",Portugal,Lisbon,https://cran.radicaldevelop.com/,"RadicalDevelop, Lda","geral # radicaldevelop.com",1,pt "Russia (Novosibirsk) [https]",Russia,Novosibirsk,https://mirror.truenetwork.ru/CRAN/,"Truenetwork","mirror # truenetwork.ru",1,ru @@ -86,7 +80,6 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment Thailand,Thailand,Hatyai,http://mirrors.psu.ac.th/pub/cran/,"Prince of Songkla University, Hatyai","wipat.s # psu.ac.th",1,th,"maintainer_address_bounces" "Turkey (Denizli) [https]",Turkey,Denizli,https://cran.pau.edu.tr/,"Pamukkale University, Denizli","Ugur Zeybek ",1,tr,"secure_mirror_from_master" "Turkey (Istanbul) [https]",Turkey,Istanbul,https://cran.gedik.edu.tr/,"Istanbul Gedik University","gedikedu # gedik.edu.tr",1,tr,"secure_mirror_from_master" -"Turkey (Mersin) [https]",Turkey,Mersin,https://cran.ncc.metu.edu.tr/,"Middle East Technical University Northern Cyprus Campus, Mersin","Ahmed A. Zaim , ncc-cc # metu.edu.tr",0,tr,"secure_mirror_from_master" "UK (Bristol) [https]",UK,Bristol,https://www.stats.bris.ac.uk/R/,"University of Bristol","Oliver Johnson , it-zone-d # bristol.ac.uk",1,uk,"secure_mirror_from_master" "UK (London 1) [https]",UK,London,https://cran.ma.imperial.ac.uk/,"Imperial College London","andy.thomas # imperial.ac.uk",1,uk,"secure_mirror_from_master" "UK (Warwick)",UK,Coventry,https://anorien.csc.warwick.ac.uk/CRAN/," University of Warwick","David Quigley ",1,uk From 117bf5b064d71b34f3b4541a0c80b320333d90e4 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 21 Aug 2024 12:25:35 +0000 Subject: [PATCH 491/546] Document and export base_aliases_db() and base_rdxrefs_db(). git-svn-id: https://svn.r-project.org/R/trunk@87032 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/NAMESPACE | 3 +++ src/library/tools/R/CRANtools.R | 5 +++++ src/library/tools/man/CRANtools.Rd | 15 ++++++++++----- src/library/tools/man/basetools.Rd | 30 ++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 src/library/tools/man/basetools.Rd diff --git a/src/library/tools/NAMESPACE b/src/library/tools/NAMESPACE index 66ec7516ba6..43191e3b457 100644 --- a/src/library/tools/NAMESPACE +++ b/src/library/tools/NAMESPACE @@ -57,6 +57,9 @@ export("CRAN_package_db", "CRAN_current_db", "CRAN_rdxrefs_db") +export("base_aliases_db", + "base_rdxrefs_db") + export("R_user_dir") export(".print.via.format") diff --git a/src/library/tools/R/CRANtools.R b/src/library/tools/R/CRANtools.R index 17a80869660..fb2e80eb42a 100644 --- a/src/library/tools/R/CRANtools.R +++ b/src/library/tools/R/CRANtools.R @@ -260,6 +260,11 @@ function() read_CRAN_object(CRAN_baseurl_for_src_area(), "src/contrib/Meta/archive.rds") +CRAN_authors_db <- +function() + read_CRAN_object(CRAN_baseurl_for_src_area(), + "src/contrib/Meta/authors.rds") + CRAN_current_db <- function() read_CRAN_object(CRAN_baseurl_for_src_area(), diff --git a/src/library/tools/man/CRANtools.Rd b/src/library/tools/man/CRANtools.Rd index adcd78e6076..5e1f46b9259 100644 --- a/src/library/tools/man/CRANtools.Rd +++ b/src/library/tools/man/CRANtools.Rd @@ -1,6 +1,6 @@ % File src/library/tools/man/CRANtools.Rd % Part of the R package, https://www.R-project.org -% Copyright 2016-2022 R Core Team +% Copyright 2016-2024 R Core Team % Distributed under GPL 2 or later \name{CRANtools} @@ -121,16 +121,21 @@ CRAN_archive_db() need to set \env{R_CRAN_WEB} to point to a full mirror. Functions - \code{CRAN_current_db}, - \code{CRAN_aliases_db}, - \code{CRAN_rdxrefs_db} and - \code{CRAN_archive_db} + \code{CRAN_current_db()}, + \code{CRAN_aliases_db()}, + \code{CRAN_rdxrefs_db()} and + \code{CRAN_archive_db()} (also used by \command{R CMD check}) use \env{R_CRAN_SRC} rather than \env{R_CRAN_WEB}. The mirror to be used is reported by \code{utils::\link{findCRANmirror}("src")}. } +\seealso{ + \code{\link{base_aliases_db}()} and \code{\link{base_rdxrefs_db}()} + for getting the Rd aliases and cross-references in the base packages. +} + %% Tested in tests/CRANtools.R \examples{\donttest{ ## This can be rather slow with a non-local CRAN mirror diff --git a/src/library/tools/man/basetools.Rd b/src/library/tools/man/basetools.Rd new file mode 100644 index 00000000000..f7ce1bd9bb7 --- /dev/null +++ b/src/library/tools/man/basetools.Rd @@ -0,0 +1,30 @@ +% File src/library/tools/man/basetools.Rd +% Part of the R package, https://www.R-project.org +% Copyright 2024 R Core Team +% Distributed under GPL 2 or later + +\name{basetools} +\title{Base Package Tools} +\alias{base_aliases_db} +\alias{base_rdxrefs_db} +\description{ + Tools for obtaining information about base packages. +} +\usage{ +base_aliases_db() +base_rdxrefs_db() +} +\details{ + \code{base_aliases_db()} returns the Rd aliases in the base + packages, as a nested per-package named list of per-Rd-file named + lists with the aliases. + + \code{base_rdxrefs_db()} returns the Rd cross-references in the + base packages, as a per-package list of matrices with columns + \code{"Target"}, \code{"Anchor"} and \code{"Source"}. +} +\seealso{ + \code{\link{CRAN_aliases_db}()} and \code{\link{CRAN_rdxrefs_db}()} + for getting the Rd aliases and cross-references in the current CRAN + packages. +} From 8fd09fe33189262239aa4c12699800a0a4c96fd8 Mon Sep 17 00:00:00 2001 From: ripley Date: Wed, 21 Aug 2024 13:16:35 +0000 Subject: [PATCH 492/546] update git-svn-id: https://svn.r-project.org/R/trunk@87033 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 135cda6d9a4..dd2624b18c2 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -4904,7 +4904,7 @@ Standalone installers (which are free-of-charge) are available from @uref{https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html}: they are also part of the @I{oneAPI} Base and HPC (for Fortran) toolkits. -We tried the compilers in @I{oneAPI} 2024.2.0 and 2023.x.y using (the paths +We tried the compilers in @I{oneAPI} 2024.2.1 and 2023.x.y using (the paths do differ by compiler version) @example IP=/path/to/compilers/bin/ From 45ba634ff6487c558a86f9c40fdcea568c74a9c8 Mon Sep 17 00:00:00 2001 From: ripley Date: Wed, 21 Aug 2024 13:16:58 +0000 Subject: [PATCH 493/546] stress that GNU make has to be tested for git-svn-id: https://svn.r-project.org/R/trunk@87034 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index dc5eea6457a..ab3105e9567 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -4913,7 +4913,9 @@ SystemRequirements: GNU make and ensure that you use the value of environment variable @env{MAKE} (and not just @command{make}) in your scripts. (On some platforms GNU make is available under a name such as @command{gmake}, and there -@code{SystemRequirements} is used to set @env{MAKE}.) +@code{SystemRequirements} is used to set @env{MAKE}.) Your +@code{configure} script (or similar) does need to check that the +executable pointed to by @env{MAKE} is indeed GNU make. If you only need GNU make for parts of the package which are rarely needed (for example to create bibliography files under From 46ad4920299b784fbbe6efe2bdc4dc76c2195328 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 21 Aug 2024 13:33:16 +0000 Subject: [PATCH 494/546] Document and export CRAN_authors_db(). git-svn-id: https://svn.r-project.org/R/trunk@87036 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/NAMESPACE | 3 ++- src/library/tools/man/CRANtools.Rd | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/library/tools/NAMESPACE b/src/library/tools/NAMESPACE index 43191e3b457..38b82e3c5e2 100644 --- a/src/library/tools/NAMESPACE +++ b/src/library/tools/NAMESPACE @@ -55,7 +55,8 @@ export("CRAN_package_db", "CRAN_aliases_db", "CRAN_archive_db", "CRAN_current_db", - "CRAN_rdxrefs_db") + "CRAN_rdxrefs_db", + "CRAN_authors_db") export("base_aliases_db", "base_rdxrefs_db") diff --git a/src/library/tools/man/CRANtools.Rd b/src/library/tools/man/CRANtools.Rd index 5e1f46b9259..093004ec9fd 100644 --- a/src/library/tools/man/CRANtools.Rd +++ b/src/library/tools/man/CRANtools.Rd @@ -17,6 +17,7 @@ \alias{CRAN_aliases_db} \alias{CRAN_rdxrefs_db} \alias{CRAN_archive_db} +\alias{CRAN_authors_db} \description{ Tools for obtaining information about current and archived packages in the \abbr{CRAN} package repository, and the check status of the @@ -37,6 +38,8 @@ CRAN_current_db() CRAN_aliases_db() CRAN_rdxrefs_db() CRAN_archive_db() + +CRAN_authors_db() } \arguments{ \item{packages}{a character vector of package names.} @@ -76,7 +79,7 @@ CRAN_archive_db() \code{kind} (an identifier for the issue) and \code{href} (a URL with information on the issue). - \code{CRAN_current_db()} returns a data fame with the + \code{CRAN_current_db()} returns a data frame with the \code{\link{file.info}()} of all current package sources in the \abbr{CRAN} package repository. @@ -91,6 +94,13 @@ CRAN_archive_db() \code{CRAN_archive_db()} returns the \code{\link{file.info}()} of all archived packages sources in the \abbr{CRAN} package repository, as a per-package named list of data frames. + + \code{CRAN_authors_db()} returns information on the authors of the + current CRAN packages extracted from the \samp{Authors@R} fields in + the package \file{DESCRIPTION} files, as a data frame with character + columns giving the given and family names, email addresses, + \abbr{ORCID} identifier, roles, and comments of the person entries, + and the corresponding package. } \value{ @@ -123,7 +133,8 @@ CRAN_archive_db() Functions \code{CRAN_current_db()}, \code{CRAN_aliases_db()}, - \code{CRAN_rdxrefs_db()} and + \code{CRAN_rdxrefs_db()}, + \code{CRAN_authors_db()} and \code{CRAN_archive_db()} (also used by \command{R CMD check}) use \env{R_CRAN_SRC} rather than \env{R_CRAN_WEB}. From 6dd3b5286320a9a8d97864f4a1e99e850bb258d3 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 21 Aug 2024 13:35:05 +0000 Subject: [PATCH 495/546] NEWS for c87036 and c87032. git-svn-id: https://svn.r-project.org/R/trunk@87037 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index aff5f5250dc..469da5e8396 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -54,11 +54,15 @@ \item Package \pkg{tools} now exports functions \code{CRAN_current_db()}, \code{CRAN_aliases_db()}, - \code{CRAN_rdxrefs_db()}, and \code{CRAN_archive_db()}. + \code{CRAN_rdxrefs_db()}, \code{CRAN_archive_db()}, and + \code{CRAN_authors_db()}. \item Package \pkg{tools} now exports functions \code{R()} and \code{parse_URI_reference()}. + \item Package \pkg{tools} now exports functions + \code{base_aliases_db()} and \code{base_rdxrefs_db()}. + \item It is now possible to set the background color for row and column names in the data editor on Windows (\command{Rgui}). From bed10be6f28052094d1750133599b8d910cd42aa Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 21 Aug 2024 13:35:13 +0000 Subject: [PATCH 496/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@87038 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/Examples/tools-Ex.Rout.save | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/Examples/tools-Ex.Rout.save b/tests/Examples/tools-Ex.Rout.save index e82302a330a..cf5bb12e653 100644 --- a/tests/Examples/tools-Ex.Rout.save +++ b/tests/Examples/tools-Ex.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-08-01 r86957) -- "Unsuffered Consequences" +R Under development (unstable) (2024-08-21 r87032) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -33,6 +33,7 @@ Type 'q()' to quit R. > ### Aliases: CRAN_package_db CRAN_check_results CRAN_check_details > ### CRAN_check_issues summarize_CRAN_check_status R_CRAN_WEB R_CRAN_SRC > ### CRAN_current_db CRAN_aliases_db CRAN_rdxrefs_db CRAN_archive_db +> ### CRAN_authors_db > > ### ** Examples > @@ -95,7 +96,7 @@ $status $stdout [1] "" - [2] "R Under development (unstable) (2024-08-01 r86957) -- \"Unsuffered Consequences\"" + [2] "R Under development (unstable) (2024-08-21 r87032) -- \"Unsuffered Consequences\"" [3] "Copyright (C) 2024 The R Foundation for Statistical Computing" [4] "Platform: x86_64-pc-linux-gnu" [5] "" @@ -111,10 +112,10 @@ $stdout [15] "'help.start()' for an HTML browser interface to help." [16] "Type 'q()' to quit R." [17] "" -[18] "> x <- readRDS(\"/tmp/Rtmpe6jyFK/runri2595b5455bd5f7\")" +[18] "> x <- readRDS(\"/tmp/RtmppU3jOk/runri1222936a0e6877\")" [19] "> options(repos = x$repos)" [20] "> y <- tryCatch(list(do.call(x$fun, x$args, quote = TRUE)), error = identity)" -[21] "> saveRDS(y, \"/tmp/Rtmpe6jyFK/runro2595b54aedd2bc\")" +[21] "> saveRDS(y, \"/tmp/RtmppU3jOk/runro1222932d23e62e\")" [22] "> " $stderr @@ -279,7 +280,7 @@ Error in assertWarning(ff()) : > bibstyle("unsorted", sortKeys = function(refs) seq_along(refs), + fmtPrefix = function(paper) paste0("[", paper$.index, "]"), + .init = TRUE) - + > print(refs, .bibstyle = "unsorted") [1] R Core Team (2013). _R: A Language and Environment for Statistical Computing_. R Foundation for Statistical Computing, Vienna, Austria. @@ -1326,7 +1327,7 @@ needs Deep Thought > cleanEx() > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 0.338 0.004 0.721 0.338 0.039 +Time elapsed: 0.333 0.016 0.729 0.293 0.082 > grDevices::dev.off() null device 1 From 5dcb6b07333ba91bdaa5c04f1c0d6d9e7e5185d5 Mon Sep 17 00:00:00 2001 From: murrell Date: Thu, 22 Aug 2024 23:37:01 +0000 Subject: [PATCH 497/546] improvement to heatmap help page - thanks to Tomek Gieorgijewski git-svn-id: https://svn.r-project.org/R/trunk@87039 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/stats/man/heatmap.Rd | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/library/stats/man/heatmap.Rd b/src/library/stats/man/heatmap.Rd index 998ee863d97..aefc6d50a76 100644 --- a/src/library/stats/man/heatmap.Rd +++ b/src/library/stats/man/heatmap.Rd @@ -54,10 +54,12 @@ heatmap(x, Rowv = NULL, Colv = if(symm)"Rowv" else NULL, \item{revC}{logical indicating if the column order should be \I{\code{\link{rev}}ersed} for plotting, such that e.g., for the symmetric case, the symmetry axis is as usual.} - \item{scale}{character indicating if the values should be centered and - scaled in either the row direction or the column direction, or - none. The default is \code{"row"} if \code{symm} false, and - \code{"none"} otherwise.} + \item{scale}{character indicating if the values on the heatmap should + be centered and scaled in either the row direction or the column + direction, or none. The default is \code{"row"} if \code{symm} + false, and \code{"none"} otherwise. This scaling only affects the + \emph{colour} scale; it does not scale the original data. See the + Examples.} \item{na.rm}{logical indicating whether \code{NA}'s should be removed.} \item{margins}{numeric vector of length 2 containing the margins (see \code{\link{par}(mar = *)}) for column and row names, respectively.} @@ -155,6 +157,23 @@ heatmap(x, Rowv = NA, Colv = NA, scale = "column", main = "heatmap(*, NA, NA) ~= image(t(x))") %% also want example using the `add.exp' argument! +## Demonstration of the 'scale' argument: +## The only change in the code is the 'scale' arg. +## The only visible change is in the color scale on the heatmap +## (the original data are not scaled). + +heatmap(x, col = terrain.colors(128), scale = "column", + RowSideColors = rc, + ColSideColors = cc, + margins = c(5,10), + main = "heatmap(, ..., scale = \"column\")") +heatmap(x, col = terrain.colors(128), scale = "none", + RowSideColors = rc, + ColSideColors = cc, + margins = c(5,10), + main = "heatmap(, ..., scale = \"none\")") + + round(Ca <- cor(attitude), 2) symnum(Ca) # simple graphic heatmap(Ca, symm = TRUE, margins = c(6,6)) # with reorder() From b426477661feb2cef412fbb9a5e9692313575a28 Mon Sep 17 00:00:00 2001 From: murrell Date: Fri, 23 Aug 2024 03:55:10 +0000 Subject: [PATCH 498/546] ?axis documentation bug - thanks to J. R. M. Hosking git-svn-id: https://svn.r-project.org/R/trunk@87040 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/graphics/man/axis.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/graphics/man/axis.Rd b/src/library/graphics/man/axis.Rd index 1c3661b809a..3308b144daa 100644 --- a/src/library/graphics/man/axis.Rd +++ b/src/library/graphics/man/axis.Rd @@ -39,7 +39,7 @@ axis(side, at = NULL, labels = TRUE, tick = TRUE, line = NA, \item{outer}{a logical value indicating whether the axis should be drawn in the outer plot margin, rather than the standard plot margin.} - \item{font}{font for text. Defaults to \code{par("font")}.} + \item{font}{font for text. Defaults to \code{par("font.axis")}.} \item{lty}{line type for both the axis line and the tick marks.} \item{lwd, lwd.ticks}{line widths for the axis line and the tick marks. Zero or negative values will suppress the line or ticks.} From 45fe54fe14394e0bad9ac8b55121c4173bcd570f Mon Sep 17 00:00:00 2001 From: murrell Date: Fri, 23 Aug 2024 04:04:44 +0000 Subject: [PATCH 499/546] update test output for r87039 git-svn-id: https://svn.r-project.org/R/trunk@87041 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/Examples/stats-Ex.Rout.save | 39 +++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/tests/Examples/stats-Ex.Rout.save b/tests/Examples/stats-Ex.Rout.save index 8e2bd8df4b6..bb076f69ac7 100644 --- a/tests/Examples/stats-Ex.Rout.save +++ b/tests/Examples/stats-Ex.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-06-13 r86727) -- "Unsuffered Consequences" +R Under development (unstable) (2024-08-21 r87038) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -7,6 +7,8 @@ R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. + Natural language support but running in an English locale + R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. @@ -5124,7 +5126,7 @@ function (V) r[seq.int(from = 1L, by = p + 1L, length.out = p)] <- 1 r } - + > stopifnot(all.equal(Cl, cov2cor(cov(longley))), + all.equal(cor(longley, method = "kendall"), @@ -7772,7 +7774,7 @@ attr(,".Environment") > environment(as.formula("y ~ x")) > environment(as.formula("y ~ x", env = new.env())) - + > > > ## Create a formula for a model with a large number of variables: @@ -8387,6 +8389,23 @@ List of 4 > heatmap(x, Rowv = NA, Colv = NA, scale = "column", + main = "heatmap(*, NA, NA) ~= image(t(x))") > +> ## Demonstration of the 'scale' argument: +> ## The only change in the code is the 'scale' arg. +> ## The only visible change is in the color scale on the heatmap +> ## (the original data are not scaled). +> +> heatmap(x, col = terrain.colors(128), scale = "column", ++ RowSideColors = rc, ++ ColSideColors = cc, ++ margins = c(5,10), ++ main = "heatmap(, ..., scale = \"column\")") +> heatmap(x, col = terrain.colors(128), scale = "none", ++ RowSideColors = rc, ++ ColSideColors = cc, ++ margins = c(5,10), ++ main = "heatmap(, ..., scale = \"none\")") +> +> > round(Ca <- cor(attitude), 2) rating complaints privileges learning raises critical advance rating 1.00 0.83 0.43 0.62 0.59 0.16 0.16 @@ -12697,14 +12716,14 @@ attr(,"class") $linkfun function (mu) mu^lambda - - + + $linkinv function (eta) pmax(eta^(1/lambda), .Machine$double.eps) - - + + > > @@ -17063,8 +17082,8 @@ Step function with continuity 'f'= 0.2 , 3 knots at > unclass(sfun0) function (v) .approxfun(x, y, v, method, yleft, yright, f, na.rm) - - + + attr(,"call") stepfun(1:3, y0, f = 0) > ls(envir = environment(sfun0)) @@ -19630,7 +19649,7 @@ Number of Fisher Scoring iterations: 6 > cleanEx() > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 5.428 0.289 5.837 0 0 +Time elapsed: 9.527 0.16 9.691 0 0 > grDevices::dev.off() null device 1 From c5fbbe889742eaa315340d0489da44e620ae41dc Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 23 Aug 2024 07:45:33 +0000 Subject: [PATCH 500/546] Sys.setLanguage() needs care in an LC_ALL=C session git-svn-id: https://svn.r-project.org/R/trunk@87042 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 3 +++ src/library/base/R/stop.R | 15 +++++++++++++-- tests/reg-tests-1e.R | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 469da5e8396..8ad3e2990b8 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -248,6 +248,9 @@ \I{Ekaterina Akimova}, \I{Hanne Oberman}, \I{Abhishek Ulayil}, and \I{Lionel Henry} at the \sQuote{\I{R Dev Day}}, thus fixing \PR{15027}. + + \item \code{Sys.setLanguage()} now works in an \command{LC_ALL=C R} session + on some platforms. } } } diff --git a/src/library/base/R/stop.R b/src/library/base/R/stop.R index dbeb511ca5c..3ca39985c65 100644 --- a/src/library/base/R/stop.R +++ b/src/library/base/R/stop.R @@ -1,7 +1,7 @@ # File src/library/base/R/stop.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2022 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -128,15 +128,26 @@ gettextf <- function(fmt, ..., domain = NULL, trim = TRUE) ## the default domain="R" seems to work for all of base R: {"R", "R-base", "RGui"} Sys.setLanguage <- function(lang, unset = "en") { + if (!capabilities("NLS") || is.na(.popath)) { + warning(gettextf("no natural language support or missing translations"), domain=NA) + return(invisible("")) + } stopifnot(is.character(lang), length(lang) == 1L, # e.g., "es" , "fr_CA" lang == "C" || grepl("^[a-z][a-z]", lang)) curLang <- Sys.getenv("LANGUAGE", unset = NA) # so it can be reset if(is.na(curLang) || !nzchar(curLang)) curLang <- unset # "factory" default + if(isC <- identical("C", Sys.getlocale())) { ## e.g. LC_ALL=C R on Linux + lcSet <- if(.Platform[["OS.type"]] == "unix") + Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") + ## TODOs: 1) does en_US.UTF-8 always exist? 2) need to deal w/ Windows ? + ok.lc <- !is.null(lcSet) && nzchar(lcSet) # NULL or "" are not ok + if(!ok.lc) warning(gettextf("In a bare C locale, could not change language"), domain=NA) + } else ok.lc <- TRUE ok <- Sys.setenv(LANGUAGE=lang) if(!ok) warning(gettextf('Sys.setenv(LANGUAGE="%s") may have failed', lang), domain=NA) ok. <- capabilities("NLS") && isTRUE(bindtextdomain(NULL)) # only flush the cache (of already translated strings) - invisible(structure(curLang, ok = ok && ok.)) + invisible(structure(curLang, ok = ok && ok.lc && ok.)) } diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index be3cf7c43fb..7bc55842b46 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1461,6 +1461,15 @@ stopifnot(beta(B, 4*B) == 0, ## no longer warns - as we require IEEE_745 +## as reg-tests-1.R run with LC_ALL=C -- test Sys.setLanguage() here +try( 1 + "2") +oL <- Sys.setLanguage("fr") +(out <- tryCmsg(1 + "2")) +if(attr(oL, "ok") && capabilities("NLS") && !is.na(.popath)) + stopifnot(grepl("^argument non num.rique pour un ", out)) +## was *not* switched to French (when this was run via 'make ..') + + ## keep at end rbind(last = proc.time() - .pt, From 3d76ac7df8ff97544ba2f4f20ca182888619cf2d Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 23 Aug 2024 08:21:56 +0000 Subject: [PATCH 501/546] stem() now works git-svn-id: https://svn.r-project.org/R/trunk@87043 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 2 ++ src/library/graphics/src/stem.c | 10 ++++++---- tests/reg-tests-2.R | 4 ++++ tests/reg-tests-2.Rout.save | 11 ++++++++++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 8ad3e2990b8..7cde3f09a39 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -236,6 +236,8 @@ \I{Ella Kaye} and \I{Kelly Bodwin}, fixing \PR{8934} during \sQuote{\I{R Dev Day}} at \I{useR!2024}. + Additionally, \code{stem(x}} now works normally also when \code{length(x) == 1}. + \item \pkg{tools}' \code{toTitleCase()} now works better, fixing \PR{18674}, thanks to \I{Shannon Pileggi}, \I{Sarah Zeller}, \I{Reiko Okamoto}, and \I{Hugo Gruson}'s \sQuote{\I{R Dev Day}} diff --git a/src/library/graphics/src/stem.c b/src/library/graphics/src/stem.c index b389359ed4a..55fe7778125 100644 --- a/src/library/graphics/src/stem.c +++ b/src/library/graphics/src/stem.c @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis + * Copyright (C) 1997--2024 The R Core Team * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 1997-2018 R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,7 +49,7 @@ static void stem_print(int close, int dist, int ndigits) static double rnd(double u, double c) { - return ((u < 0) ? (u*c - .5) : (u*c + .5)); + return ((u < 0) ? (u*c - .5) : (u*c + .5)); } static Rboolean @@ -62,8 +62,10 @@ stem_leaf(double *x, int n, double scale, int width, double atom) R_rsort(x,n); +#if 0 if(n <= 1) return FALSE; +#endif Rprintf("\n"); mu = 10; @@ -85,14 +87,14 @@ stem_leaf(double *x, int n, double scale, int width, double atom) r = atom + fabs(x[0])/scale; c = R_pow_di(10.0, (int)(1.0 - floor(log10(r)))); } - + /* Find the print width of the stem. */ double xlow = rnd(x[0], c), xhigh = rnd(x[n-1], c), lo_nd = floor(xlow/mu)*mu, hi_nd = floor(xhigh/mu)*mu; - + ldigits = (lo_nd < 0) ? (int) floor(log10(-lo_nd)) + 1 : 0; hdigits = (hi_nd > 0) ? (int) floor(log10(hi_nd)): 0; ndigits = (ldigits < hdigits) ? hdigits : ldigits; diff --git a/tests/reg-tests-2.R b/tests/reg-tests-2.R index d828f430743..d99b9494f13 100644 --- a/tests/reg-tests-2.R +++ b/tests/reg-tests-2.R @@ -1196,6 +1196,10 @@ stem(c(rep(1, 10), 1+1.e-10), atom=0) # integer-overflow is avoided. stem(c(8.48, 9.58, 9.96)) ## wrongly indented '10 |' since even before R 1.0.0 +## stem() now produces output +stem(123) +## length(x) == 1 was explicitly skipped in R <= 4.4.z + ## PR#6633 warnings with vector op matrix, and more set.seed(1) diff --git a/tests/reg-tests-2.Rout.save b/tests/reg-tests-2.Rout.save index 88983faaa5f..98239cd6cd3 100644 --- a/tests/reg-tests-2.Rout.save +++ b/tests/reg-tests-2.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-08-07 r86984) -- "Unsuffered Consequences" +R Under development (unstable) (2024-08-23 r87041) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -3877,6 +3877,15 @@ Residuals 42 29204 695.3 > ## wrongly indented '10 |' since even before R 1.0.0 > +> ## stem() now produces output +> stem(123) + + The decimal point is 2 digit(s) to the right of the | + + 1 | 2 + +> ## length(x) == 1 was explicitly skipped in R <= 4.4.z +> > > ## PR#6633 warnings with vector op matrix, and more > set.seed(1) From fc896b4578c86b3148f2549d5309c3e0c9721288 Mon Sep 17 00:00:00 2001 From: smeyer Date: Fri, 23 Aug 2024 09:11:38 +0000 Subject: [PATCH 502/546] show .fail's tail git-svn-id: https://svn.r-project.org/R/trunk@87044 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/Makefile.common | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.common b/tests/Makefile.common index ef145a96976..4f215a9b50e 100644 --- a/tests/Makefile.common +++ b/tests/Makefile.common @@ -120,7 +120,12 @@ FORCE: .R.Rout: @rm -f $@ $@.fail $@.log @$(ECHO) $(ECHO_N) "running code in '$<' ...$(ECHO_C)" > $@.log - @$(R) < $< > $@.fail 2>&1 || (cat $@.log && rm $@.log && exit 1) + @$(R) < $< > $@.fail 2>&1 || { \ + $(ECHO) "$(ECHO_T) FAILED" >> $@.log; \ + $(ECHO) "==> $@.fail <==" >> $@.log; \ + tail $@.fail >>$@.log; \ + cat $@.log && rm $@.log && exit 1; \ + } @$(ECHO) "$(ECHO_T) OK" >> $@.log @if test -f $(srcdir)/$@.save ; then \ $(ECHO) $(ECHO_N) \ From 7d2402ef561fdf8b179437f7d089db54ed302594 Mon Sep 17 00:00:00 2001 From: ripley Date: Fri, 23 Aug 2024 09:29:30 +0000 Subject: [PATCH 503/546] grammar, sweeping up yet again git-svn-id: https://svn.r-project.org/R/trunk@87045 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 7cde3f09a39..075ea411b6d 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -231,12 +231,13 @@ method for data frames, and also bug \PR{18745}. \I{Relatedly}, the \code{format()} method gets an option \code{cut.names}. - \item \code{stem()} correctly formats also in cases where rounding - up, e.g., from 9.96 to 10 needs more digits; thanks to - \I{Ella Kaye} and \I{Kelly Bodwin}, fixing \PR{8934} during - \sQuote{\I{R Dev Day}} at \I{useR!2024}. + \item \code{stem()} formats correctly also in cases where rounding + up, e.g., from 9.96 to 10 needs more digits; thanks to \I{Ella + Kaye} and \I{Kelly Bodwin}, fixing \PR{8934} during \sQuote{\I{R + Dev Day}} at \I{useR!2024}. - Additionally, \code{stem(x}} now works normally also when \code{length(x) == 1}. + Additionally, \code{stem(x)} now works normally also when + \code{length(x) == 1}. \item \pkg{tools}' \code{toTitleCase()} now works better, fixing \PR{18674}, thanks to \I{Shannon Pileggi}, \I{Sarah Zeller}, From f0174d40715ebae881b4b899298284c7bf651b81 Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 23 Aug 2024 09:47:02 +0000 Subject: [PATCH 504/546] do FIXME in print.ls_str(): use "en" temporarily git-svn-id: https://svn.r-project.org/R/trunk@87046 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 3 +++ src/library/utils/R/str.R | 9 ++++++--- tests/reg-tests-1e.R | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 075ea411b6d..3d2a57092a5 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -254,6 +254,9 @@ \item \code{Sys.setLanguage()} now works in an \command{LC_ALL=C R} session on some platforms. + + \item Printing \code{ls.str()} now tries harder to show + \code{""} even when \R's language setting is not English. } } } diff --git a/src/library/utils/R/str.R b/src/library/utils/R/str.R index 5fd9c20b87a..2fa2d7d9b3d 100644 --- a/src/library/utils/R/str.R +++ b/src/library/utils/R/str.R @@ -696,6 +696,10 @@ print.ls_str <- function(x, max.level = 1, give.attr = FALSE, strargs <- c(list(max.level = max.level, give.attr = give.attr, digits.d = digits), args) n. <- substr(tempfile("ls_str_", tmpdir=""), 2L, 20L) + if(is.na(L <- Sys.getenv("LANGUAGE", unset=NA)) || L != "en") { + Sys.setLanguage("en") # for "" to work below + on.exit(if(is.na(L)) Sys.unsetenv("LANGUAGE") else Sys.setenv(LANGUAGE = L)) + } for(nam in x) { cat(nam, ": ") ## check missingness, e.g. inside debug(.) : @@ -712,9 +716,8 @@ print.ls_str <- function(x, max.level = 1, give.attr = FALSE, o <- tryCatch(get(nam, envir = E, mode = M), error = function(e){ attr(e, eA) <- TRUE; e }) if(inherits(o, "error") && isTRUE(attr(o, eA))) { - cat(## FIXME: only works with "C" (or English) LC_MESSAGES locale! - if(length(grep("missing|not found", o$message))) - "" else o$message, "\n", sep = "") + cat(if(grepl("missing|not found", o$message)) "" else o$message, + "\n", sep = "") } else { ## do.call(str, c(list(o), strargs), diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 7bc55842b46..190c885458c 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1470,6 +1470,21 @@ if(attr(oL, "ok") && capabilities("NLS") && !is.na(.popath)) ## was *not* switched to French (when this was run via 'make ..') +## print( ls.str() ) using '' also in non-English setup: +## {test may give false negative, unproblematically} +M <- alist(.=)$. +stopifnot(missing(M)) +try( M ) # --> Error: argument "M" is missing, with no default (typically English) +ls.str(pattern = "^M$") # (typically:) M : +(oL <- Sys.setLanguage("de")) +try( M ) # --> Error : Argument "M" fehlt (ohne Standardwert) +(out <- capture.output(ls.str(pattern = "^M$"))) +# reset LANGUAGE, etc where needed (and see effect): +rm(M); if(attr(oL,"ok")) Sys.setLanguage(oL) +stopifnot(endsWith(out, "")) +## failed in R <= 4.4.1; out was "M : Argument \"M\" fehlt <...>" + + ## keep at end rbind(last = proc.time() - .pt, From a51d0b5b49902e156bec43c39c16f05aa550fb83 Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 23 Aug 2024 10:02:35 +0000 Subject: [PATCH 505/546] extend pnorm()`s range to underflow gracefully to denormalized git-svn-id: https://svn.r-project.org/R/trunk@87047 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 2 ++ src/nmath/pnorm.c | 13 ++++++++----- tests/d-p-q-r-tst-2.R | 9 ++++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 3d2a57092a5..1e04c7445b7 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -77,6 +77,8 @@ \item \code{findInterval()} gets new options \code{checkSorted} and \code{checkNA} which allow to skip relatively costly checks; related to \PR{16567}. + + \item \code{pnorm(x)} underflows more gracefully. } } diff --git a/src/nmath/pnorm.c b/src/nmath/pnorm.c index 5407d702758..8006fd6df42 100644 --- a/src/nmath/pnorm.c +++ b/src/nmath/pnorm.c @@ -1,6 +1,6 @@ /* * Mathlib : A C Library of Special Functions - * Copyright (C) 2000-2023 The R Core Team + * Copyright (C) 2000-2024 The R Core Team * Copyright (C) 2003 The R Foundation * Copyright (C) 1998 Ross Ihaka * @@ -223,7 +223,7 @@ void pnorm_both(double x, double *cum, double *ccum, int i_tail, int log_p) * Note that we do want symmetry(0), lower/upper -> hence use y */ else if((log_p && y < 1e170) /* avoid underflow below */ - /* ^^^^^ MM FIXME: could speed up for log_p and |x| >> 5.657 ! + /* ^^^^^ MM FIXME: could speed up for log_p and y := |x| >> 5.657 ! * Then, make use of Abramowitz & Stegun, 26.2.13, p.932, something like * Even smarter: work with example(pnormAsymp, package="DPQ") @@ -243,9 +243,12 @@ void pnorm_both(double x, double *cum, double *ccum, int i_tail, int log_p) well, actually x = -1.34..e154 = -sqrt(DBL_MAX) already overflows x^2 The largest x for which x/2*x is finite is x = +/- 1.89615038e154 ~= sqrt(2) * sqrt(.Machine$double.xmax) + + NB: allowing "DENORMS" ==> boundaries at +/- 38.4674 <--> qnorm(log(2^-1074), log.p=TRUE) + -- rather than 37.5193 (up to R 4.4.x) */ - || (lower && -37.5193 < x && x < 8.2924) - || (upper && -8.2924 < x && x < 37.5193) + || (lower && -38.4674 < x && x < 8.2924) + || (upper && -8.2924 < x && x < 38.4674) ) { /* Evaluate pnorm for x in (-37.5, -5.657) union (5.657, 37.5) */ @@ -261,7 +264,7 @@ void pnorm_both(double x, double *cum, double *ccum, int i_tail, int log_p) do_del(x); swap_tail; - } else { /* large x such that probs are 0 or 1 */ + } else { /* large |x| such that probs are 0 or 1 */ if(x > 0) { *cum = R_D__1; *ccum = R_D__0; } else { *cum = R_D__0; *ccum = R_D__1; } } diff --git a/tests/d-p-q-r-tst-2.R b/tests/d-p-q-r-tst-2.R index 98c2c88a40e..4414f50d524 100644 --- a/tests/d-p-q-r-tst-2.R +++ b/tests/d-p-q-r-tst-2.R @@ -741,6 +741,13 @@ stopifnot(exprs = { }) ## all these where -Inf in R <= 4.0.x +## pnorm(x) returns non-zero for a bit larger |x|, now returning denormalized +(pL <- pnorm(-38.4)) +stopifnot(pL > 0, all.equal(6.6015999e-323, pL), + pL == pnorm(38.4, lower.tail=FALSE), + pnorm(-38.46739999) == 2^-1074) +## in R <= 4.4.x, the non-zero boundary was at -37.5193 + ## qnbinom(*, size=, mu=) -- PR#18095: qi <- 0:16 @@ -879,7 +886,7 @@ prb <- 0.995 (pqb6 <- pbinom(qb6, size = sz, prob = prb)) (pqb6_1 <- pbinom(qb6-1, size = sz, prob = prb)) stopifnot(exprs = { - qb6 == c(6001:6004,6004:6005) # not in R 4.4.0, nor 4.1.1 + qb6 == c(6001:6004,6004:6005) # not so in R 4.4.0, nor 4.1.1 1 > pqb6 & pqb6 >= 0.05 # " 0.05 > pqb6_1 & pqb6_1 >= 0.035# " }) From 4339636dfebc9cdd5d4e301b0ec3390563101240 Mon Sep 17 00:00:00 2001 From: smeyer Date: Fri, 23 Aug 2024 11:34:19 +0000 Subject: [PATCH 506/546] tweak show(), fixing PR#18786 (thanks to Michael Chirico) git-svn-id: https://svn.r-project.org/R/trunk@87048 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/methods/R/show.R | 4 ++-- tests/reg-S4.R | 4 ++++ tests/reg-S4.Rout.save | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/library/methods/R/show.R b/src/library/methods/R/show.R index 9bba1b37077..c8b7eb223dd 100644 --- a/src/library/methods/R/show.R +++ b/src/library/methods/R/show.R @@ -107,8 +107,8 @@ show <- function(object) showDefault(object) pkg <- object@package exported <- pkg == ".GlobalEnv" || isBaseNamespace(ns <- asNamespace(pkg)) || nam %in% names(.getNamespaceInfo(ns, "exports")) - showGen <- if(exported) nam # was dQuote(nam, NULL) - else paste(pkg, nam, sep=":::") + qnam <- deparse1(as.name(nam), backtick = TRUE) # was dQuote(nam, NULL) + showGen <- if(exported) qnam else paste(pkg, qnam, sep=":::") cat("Methods may be defined for arguments: ", paste0(object@signature, collapse=", "), "\n", "Use showMethods(", showGen, diff --git a/tests/reg-S4.R b/tests/reg-S4.R index f1ca099a2de..46d03997dee 100644 --- a/tests/reg-S4.R +++ b/tests/reg-S4.R @@ -888,3 +888,7 @@ setClass("foo") sealClass("foo") # failed in R < 4.5.0 stopifnot(isSealedClass("foo")) stopifnot(removeClass("foo")) + + +## show() should recommend backticks for showMethods() +stopifnot(any(grepl("showMethods(`body<-`)", capture.output(show(`body<-`)), fixed=TRUE))) diff --git a/tests/reg-S4.Rout.save b/tests/reg-S4.Rout.save index eba98ed3774..e665ed7b4ca 100644 --- a/tests/reg-S4.Rout.save +++ b/tests/reg-S4.Rout.save @@ -1187,3 +1187,7 @@ class(from) <- "foo" > stopifnot(isSealedClass("foo")) > stopifnot(removeClass("foo")) > +> +> ## show() should recommend backticks for showMethods() +> stopifnot(any(grepl("showMethods(`body<-`)", capture.output(show(`body<-`)), fixed=TRUE))) +> From 23abac9c06535c882387cef3a0dd08dbc8d0c38a Mon Sep 17 00:00:00 2001 From: smeyer Date: Fri, 23 Aug 2024 14:14:28 +0000 Subject: [PATCH 507/546] spelling git-svn-id: https://svn.r-project.org/R/trunk@87049 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/duplicated.Rd | 2 +- src/library/datasets/man/npk.Rd | 3 ++- src/library/stats/man/heatmap.Rd | 2 +- src/library/utils/man/hashtab.Rd | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/library/base/man/duplicated.Rd b/src/library/base/man/duplicated.Rd index cc8f910e536..03c56349bbc 100644 --- a/src/library/base/man/duplicated.Rd +++ b/src/library/base/man/duplicated.Rd @@ -22,7 +22,7 @@ indicating which elements (rows) are duplicates. \code{anyDuplicated(.)} is a \dQuote{generalized} more efficient - version \code{any(duplicated(.))}, returning positive integer indices + version of \code{any(duplicated(.))}, returning positive integer indices instead of just \code{TRUE}. } \usage{ diff --git a/src/library/datasets/man/npk.Rd b/src/library/datasets/man/npk.Rd index 7f941aab665..3314fc978f5 100644 --- a/src/library/datasets/man/npk.Rd +++ b/src/library/datasets/man/npk.Rd @@ -1,9 +1,10 @@ % File src/library/datasets/man/npk.Rd % Part of the R package, https://www.R-project.org -% copyright (C) 1999 W. N. Venables and B. D. Ripley +% Copyright (C) 1999 W. N. Venables and B. D. Ripley % Distributed under GPL 2 or later \name{npk} +\docType{data} \alias{npk} \title{ Classical N, P, K Factorial Experiment diff --git a/src/library/stats/man/heatmap.Rd b/src/library/stats/man/heatmap.Rd index aefc6d50a76..ae9fbc20d4b 100644 --- a/src/library/stats/man/heatmap.Rd +++ b/src/library/stats/man/heatmap.Rd @@ -56,7 +56,7 @@ heatmap(x, Rowv = NULL, Colv = if(symm)"Rowv" else NULL, symmetric case, the symmetry axis is as usual.} \item{scale}{character indicating if the values on the heatmap should be centered and scaled in either the row direction or the column - direction, or none. The default is \code{"row"} if \code{symm} + direction, or none. The default is \code{"row"} if \code{symm} is false, and \code{"none"} otherwise. This scaling only affects the \emph{colour} scale; it does not scale the original data. See the Examples.} diff --git a/src/library/utils/man/hashtab.Rd b/src/library/utils/man/hashtab.Rd index 0cf02cea1a5..33c0673fae5 100644 --- a/src/library/utils/man/hashtab.Rd +++ b/src/library/utils/man/hashtab.Rd @@ -131,7 +131,7 @@ is.hashtab(x) } As an experimental feature, the element operator \code{[[} can also be - used get or set hash table entries, and \code{length} can be used to + used to get or set hash table entries, and \code{length} can be used to obtain the number of entries. It is not yet clear whether this is a good idea. } From e5f99af5b4f38e74640dc3fbcce0c93d5edbe497 Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 26 Aug 2024 11:39:12 +0000 Subject: [PATCH 508/546] safer checking Sys.setLanguage() git-svn-id: https://svn.r-project.org/R/trunk@87050 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/reg-tests-1e.R | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 190c885458c..1e3551e18e5 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1463,10 +1463,19 @@ stopifnot(beta(B, 4*B) == 0, ## as reg-tests-1.R run with LC_ALL=C -- test Sys.setLanguage() here try( 1 + "2") -oL <- Sys.setLanguage("fr") +oL <- tryCatch(warning = identity, + Sys.setLanguage("fr") + ) # e.g. on Windows: .. C locale, could not change language" +if(inherits(oL, "warning")) { + print(oL) + oL <- structure(conditionMessage(oL), ok = FALSE) +} (out <- tryCmsg(1 + "2")) -if(attr(oL, "ok") && capabilities("NLS") && !is.na(.popath)) - stopifnot(grepl("^argument non num.rique pour un ", out)) +if(attr(oL, "ok") && capabilities("NLS") && !is.na(.popath) + && !grepl("macOS", osVersion) # macOS fails currently + ) + stopifnot(is.character(print("checking 'out' : ")), + grepl("^argument non num.rique pour un ", out)) ## was *not* switched to French (when this was run via 'make ..') From 0f99146fb196d70e90c959d57c1c092431427d6a Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 26 Aug 2024 14:50:33 +0000 Subject: [PATCH 509/546] do not warn but message, when Sys.setLanguage("en") is deficient in C locale git-svn-id: https://svn.r-project.org/R/trunk@87051 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 3 ++- src/library/base/R/stop.R | 15 +++++++++------ src/library/base/man/gettext.Rd | 9 ++++++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 1e04c7445b7..4d63d8b253b 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -255,7 +255,8 @@ \PR{15027}. \item \code{Sys.setLanguage()} now works in an \command{LC_ALL=C R} session - on some platforms. + on some platforms, warns about \emph{some} failures to change the + language and gets an option related to these warning messages. \item Printing \code{ls.str()} now tries harder to show \code{""} even when \R's language setting is not English. diff --git a/src/library/base/R/stop.R b/src/library/base/R/stop.R index 3ca39985c65..b7583c45473 100644 --- a/src/library/base/R/stop.R +++ b/src/library/base/R/stop.R @@ -126,27 +126,30 @@ gettextf <- function(fmt, ..., domain = NULL, trim = TRUE) ## Could think of using *several* domains, i.e. domain = vector; but seems complicated; ## the default domain="R" seems to work for all of base R: {"R", "R-base", "RGui"} -Sys.setLanguage <- function(lang, unset = "en") +Sys.setLanguage <- function(lang, unset = "en", allowC4en = TRUE) { if (!capabilities("NLS") || is.na(.popath)) { warning(gettextf("no natural language support or missing translations"), domain=NA) - return(invisible("")) + return(invisible(structure("", ok = FALSE))) } stopifnot(is.character(lang), length(lang) == 1L, # e.g., "es" , "fr_CA" lang == "C" || grepl("^[a-z][a-z]", lang)) curLang <- Sys.getenv("LANGUAGE", unset = NA) # so it can be reset if(is.na(curLang) || !nzchar(curLang)) curLang <- unset # "factory" default - if(isC <- identical("C", Sys.getlocale())) { ## e.g. LC_ALL=C R on Linux + Warning <- if(allowC4en && startsWith(lang, "en")) message else warning + if(identical("C", Sys.getlocale()) && lang != "C") { ## e.g. LC_ALL=C R on Linux lcSet <- if(.Platform[["OS.type"]] == "unix") Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") - ## TODOs: 1) does en_US.UTF-8 always exist? 2) need to deal w/ Windows ? + ## TODOs: 1) does en_US.UTF-8 always exist? + ## 2) How to deal w/ Windows ? {can set things but with *no* effect} ok.lc <- !is.null(lcSet) && nzchar(lcSet) # NULL or "" are not ok - if(!ok.lc) warning(gettextf("In a bare C locale, could not change language"), domain=NA) + if(!ok.lc) + Warning(gettextf("In a bare C locale, could not change language"), domain=NA) } else ok.lc <- TRUE ok <- Sys.setenv(LANGUAGE=lang) if(!ok) - warning(gettextf('Sys.setenv(LANGUAGE="%s") may have failed', lang), domain=NA) + Warning(gettextf('Sys.setenv(LANGUAGE="%s") may have failed', lang), domain=NA) ok. <- capabilities("NLS") && isTRUE(bindtextdomain(NULL)) # only flush the cache (of already translated strings) invisible(structure(curLang, ok = ok && ok.lc && ok.)) diff --git a/src/library/base/man/gettext.Rd b/src/library/base/man/gettext.Rd index a0dcd6d65e9..79cfcfa17cf 100644 --- a/src/library/base/man/gettext.Rd +++ b/src/library/base/man/gettext.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/gettext.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2023 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{gettext} @@ -27,7 +27,7 @@ ngettext(n, msg1, msg2, domain = NULL) bindtextdomain(domain, dirname = NULL) -Sys.setLanguage(lang, unset = "en") +Sys.setLanguage(lang, unset = "en", allowC4en = TRUE) } \arguments{ \item{\dots}{one or more character vectors.} @@ -46,6 +46,9 @@ Sys.setLanguage(lang, unset = "en") \item{unset}{a string, specifying the default language assumed to be current in the case \code{\link{Sys.getenv}("LANGUAGE")} is unset or empty.} + \item{allowC4en}{logical indicating if a current (sometimes \dQuote{hard}) + setting of language \code{"C"} is acceptable for \code{lang = "en"}. In that + case, \code{\link{message}()} is called instead of \code{\link{warning}()}.} } \details{ If \code{domain} is \code{NULL} (the default) in \code{gettext} @@ -70,7 +73,7 @@ Sys.setLanguage(lang, unset = "en") The \emph{language} to be used for message translation is determined by your OS default and/or the locale setting at \R's startup, see - \code{\link{Sys.getlocale}()}, and notably the \env{LANGUAGE} environment + \code{\link{Sys.getlocale}()}, and notably the \env{LANGUAGE} environment variable, and also \code{Sys.setLanguage()} here. Conventionally the domain for \R warning/error messages in package From 4426167c9837aa0f9dc57c5163f1fd73e80573b7 Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 26 Aug 2024 14:53:13 +0000 Subject: [PATCH 510/546] Docs update re when method argument is unused. git-svn-id: https://svn.r-project.org/R/trunk@87052 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/man/install.packages.Rd | 5 ++--- src/library/utils/man/update.packages.Rd | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/library/utils/man/install.packages.Rd b/src/library/utils/man/install.packages.Rd index 415d00f7166..8f78b6c6a3e 100644 --- a/src/library/utils/man/install.packages.Rd +++ b/src/library/utils/man/install.packages.Rd @@ -1,6 +1,6 @@ % File src/library/utils/man/install.packages.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2023 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{install.packages} @@ -72,8 +72,7 @@ install.packages(pkgs, lib, repos = getOption("repos"), Incompatible with \code{type = "both"}. } \item{method}{ - download method, see \code{\link{download.file}}. Unused if - a non-\code{NULL} \code{available} is supplied. + download method, see \code{\link{download.file}}. } \item{available}{ a matrix as returned by \code{\link{available.packages}} diff --git a/src/library/utils/man/update.packages.Rd b/src/library/utils/man/update.packages.Rd index 34725355921..305cc5ea8b6 100644 --- a/src/library/utils/man/update.packages.Rd +++ b/src/library/utils/man/update.packages.Rd @@ -1,6 +1,6 @@ % File src/library/utils/man/update.packages.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2019 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{update.packages} @@ -52,7 +52,8 @@ new.packages(lib.loc = NULL, repos = getOption("repos"), Incompatible with \code{type = "both"}. } \item{method}{Download method, see \code{\link{download.file}}. - Unused if a non-\code{NULL} \code{available} is supplied.} + Unused by \code{\link{old.packages}} if a non-\code{NULL} \code{available} + is supplied.} \item{instlib}{character string giving the library directory where to install the packages.} \item{ask}{logical indicating whether to ask the user to select From f8530e9aaffb179bcf05e21f2fe50de8e5aa870c Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 26 Aug 2024 16:15:45 +0000 Subject: [PATCH 511/546] YA catch Sys.setLanguage() warning git-svn-id: https://svn.r-project.org/R/trunk@87053 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/reg-tests-1e.R | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 1e3551e18e5..6df593d21d4 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1485,11 +1485,10 @@ M <- alist(.=)$. stopifnot(missing(M)) try( M ) # --> Error: argument "M" is missing, with no default (typically English) ls.str(pattern = "^M$") # (typically:) M : -(oL <- Sys.setLanguage("de")) -try( M ) # --> Error : Argument "M" fehlt (ohne Standardwert) +(oL <- tryCatch(Sys.setLanguage("de"), warning = identity, error = identity)) +try( M ) # in good case --> Error : Argument "M" fehlt (ohne Standardwert) (out <- capture.output(ls.str(pattern = "^M$"))) -# reset LANGUAGE, etc where needed (and see effect): -rm(M); if(attr(oL,"ok")) Sys.setLanguage(oL) +rm(M); if(attr(oL,"ok")) Sys.setLanguage(oL) # reset LANGUAGE etc stopifnot(endsWith(out, "")) ## failed in R <= 4.4.1; out was "M : Argument \"M\" fehlt <...>" From e700475e6de7dd8511788379e7039c8bda6d6abd Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 26 Aug 2024 20:39:07 +0000 Subject: [PATCH 512/546] oops: YA git-svn-id: https://svn.r-project.org/R/trunk@87054 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/reg-tests-1e.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 6df593d21d4..735f0ea8087 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1488,7 +1488,7 @@ ls.str(pattern = "^M$") # (typically:) M : (oL <- tryCatch(Sys.setLanguage("de"), warning = identity, error = identity)) try( M ) # in good case --> Error : Argument "M" fehlt (ohne Standardwert) (out <- capture.output(ls.str(pattern = "^M$"))) -rm(M); if(attr(oL,"ok")) Sys.setLanguage(oL) # reset LANGUAGE etc +rm(M); if(isTRUE(attr(oL,"ok"))) Sys.setLanguage(oL) # reset LANGUAGE etc stopifnot(endsWith(out, "")) ## failed in R <= 4.4.1; out was "M : Argument \"M\" fehlt <...>" From 76040e2aebd2dd6857b4a8e1eb2e6202654280b6 Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 26 Aug 2024 22:26:42 +0000 Subject: [PATCH 513/546] Sys.setLanguage(): default C.vs.en = "silent" git-svn-id: https://svn.r-project.org/R/trunk@87056 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/stop.R | 17 +++++++++++------ src/library/base/man/gettext.Rd | 12 +++++++----- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/library/base/R/stop.R b/src/library/base/R/stop.R index b7583c45473..749a28eca5b 100644 --- a/src/library/base/R/stop.R +++ b/src/library/base/R/stop.R @@ -126,18 +126,23 @@ gettextf <- function(fmt, ..., domain = NULL, trim = TRUE) ## Could think of using *several* domains, i.e. domain = vector; but seems complicated; ## the default domain="R" seems to work for all of base R: {"R", "R-base", "RGui"} -Sys.setLanguage <- function(lang, unset = "en", allowC4en = TRUE) +Sys.setLanguage <- function(lang, unset = "en", C.vs.en = c("silent", "msg", "warn")) { - if (!capabilities("NLS") || is.na(.popath)) { - warning(gettextf("no natural language support or missing translations"), domain=NA) - return(invisible(structure("", ok = FALSE))) - } stopifnot(is.character(lang), length(lang) == 1L, # e.g., "es" , "fr_CA" lang == "C" || grepl("^[a-z][a-z]", lang)) curLang <- Sys.getenv("LANGUAGE", unset = NA) # so it can be reset + if (!capabilities("NLS") || is.na(.popath)) { + warning(gettextf("no natural language support or missing translations"), domain=NA) + return(invisible(structure(curLang, ok = FALSE))) + } if(is.na(curLang) || !nzchar(curLang)) curLang <- unset # "factory" default - Warning <- if(allowC4en && startsWith(lang, "en")) message else warning + Warning <- if(startsWith(lang, "en")) + switch(match.arg(C.vs.en), + silent = function(...){}, + msg = message, + warn = warning) + else warning if(identical("C", Sys.getlocale()) && lang != "C") { ## e.g. LC_ALL=C R on Linux lcSet <- if(.Platform[["OS.type"]] == "unix") Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") diff --git a/src/library/base/man/gettext.Rd b/src/library/base/man/gettext.Rd index 79cfcfa17cf..5507cc3688f 100644 --- a/src/library/base/man/gettext.Rd +++ b/src/library/base/man/gettext.Rd @@ -1,4 +1,4 @@ -% File src/library/base/man/gettext.Rd +se% File src/library/base/man/gettext.Rd % Part of the R package, https://www.R-project.org % Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later @@ -27,7 +27,7 @@ ngettext(n, msg1, msg2, domain = NULL) bindtextdomain(domain, dirname = NULL) -Sys.setLanguage(lang, unset = "en", allowC4en = TRUE) +Sys.setLanguage(lang, unset = "en", C.vs.en = c("silent", "msg", "warn")) } \arguments{ \item{\dots}{one or more character vectors.} @@ -46,9 +46,11 @@ Sys.setLanguage(lang, unset = "en", allowC4en = TRUE) \item{unset}{a string, specifying the default language assumed to be current in the case \code{\link{Sys.getenv}("LANGUAGE")} is unset or empty.} - \item{allowC4en}{logical indicating if a current (sometimes \dQuote{hard}) - setting of language \code{"C"} is acceptable for \code{lang = "en"}. In that - case, \code{\link{message}()} is called instead of \code{\link{warning}()}.} + \item{C.vs.en}{a string specifying how a current (sometimes \dQuote{hard}) + setting of language \code{"C"} is treated for \code{lang = "en"}. + When \code{"silent"}, nothing is signalled, when \code{"msg"}, a + \code{\link{message}()} and if \code{"warn"} a \code{\link{warning}()} + is signalled.} } \details{ If \code{domain} is \code{NULL} (the default) in \code{gettext} From c3bf94a51fc8a4a396a0a412a0b458acb1715d8b Mon Sep 17 00:00:00 2001 From: ripley Date: Tue, 27 Aug 2024 07:40:09 +0000 Subject: [PATCH 514/546] spurious chars git-svn-id: https://svn.r-project.org/R/trunk@87057 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/man/gettext.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/base/man/gettext.Rd b/src/library/base/man/gettext.Rd index 5507cc3688f..3a320cdbbdb 100644 --- a/src/library/base/man/gettext.Rd +++ b/src/library/base/man/gettext.Rd @@ -1,4 +1,4 @@ -se% File src/library/base/man/gettext.Rd +% File src/library/base/man/gettext.Rd % Part of the R package, https://www.R-project.org % Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later From f7fb7d2a03a28cd037cd4e94135ff96bf1edd441 Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 27 Aug 2024 09:28:35 +0000 Subject: [PATCH 515/546] Do not include RS.h from Error.h (amends 86984, avoids some name conflicts on symbols defined with !STRICT_R_HEADERS). git-svn-id: https://svn.r-project.org/R/trunk@87058 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/include/R_ext/Error.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/include/R_ext/Error.h b/src/include/R_ext/Error.h index 633c75c1615..9bfa774da67 100644 --- a/src/include/R_ext/Error.h +++ b/src/include/R_ext/Error.h @@ -26,8 +26,14 @@ #ifndef R_ERROR_H_ #define R_ERROR_H_ +#if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS) +# include +#else +# include /* for size_t */ +#endif + #include -#include /* for F77_... */ +#include /* for HAVE_F77_UNDERSCORE */ #ifdef __cplusplus extern "C" { @@ -56,17 +62,26 @@ NORET void Rf_error(const char *, ...) R_PRINTF_FORMAT(1, 2); NORET void UNIMPLEMENTED(const char *); NORET void WrongArgCount(const char *); -void Rf_warning(const char *, ...) R_PRINTF_FORMAT(1,2); +void Rf_warning(const char *, ...) R_PRINTF_FORMAT(1,2); -void R_ShowMessage(const char *s); +void R_ShowMessage(const char *s); -#ifdef FC_LEN_T -NORET void F77_NAME(xerbla)(const char *srname, int *info, const FC_LEN_T srname_len); +#ifdef HAVE_F77_UNDERSCORE +/* F77_NAME is in RS.h, but better not include it here (e.g. due to + name conflicts involving symbols defined with !STRICT_R_HEADERS) */ +# ifdef FC_LEN_T +NORET void xerbla_(const char *srname, int *info, const FC_LEN_T srname_len); +# else +NORET void xerbla_(const char *srname, int *info); +# endif #else -NORET void F77_NAME(xerbla)(const char *srname, int *info); +# ifdef FC_LEN_T +NORET void xerbla(const char *srname, int *info, const FC_LEN_T srname_len); +# else +NORET void xerbla(const char *srname, int *info); +# endif #endif - #ifdef __cplusplus } #endif From e20d8d1407420df7ff0d5544ba86410d865aaa36 Mon Sep 17 00:00:00 2001 From: kalibera Date: Tue, 27 Aug 2024 09:57:51 +0000 Subject: [PATCH 516/546] Fix typo. git-svn-id: https://svn.r-project.org/R/trunk@87059 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index ab3105e9567..3ddf8e7a208 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -12427,7 +12427,7 @@ unprotected. @apifun R_ReleaseObject There is another way to avoid the effects of garbage collection: a call to @code{R_PreserveObject} adds an object to an internal list of objects -not to be collects, and a subsequent call to @code{R_ReleaseObject} +not to be collected, and a subsequent call to @code{R_ReleaseObject} removes it from that list. This provides a way for objects which are not returned as part of @R{} objects to be protected across calls to compiled code: on the other hand it becomes the user's responsibility to From 9becfa8388506242952c25f2f1d7781a55151092 Mon Sep 17 00:00:00 2001 From: maechler Date: Tue, 27 Aug 2024 10:38:43 +0000 Subject: [PATCH 517/546] modularize --> internal .isExported(name, pkg) and .maybeUnhideName(name, pkg) git-svn-id: https://svn.r-project.org/R/trunk@87060 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/methods/R/RMethodUtils.R | 15 ++++++++++++--- src/library/methods/R/show.R | 7 ++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/library/methods/R/RMethodUtils.R b/src/library/methods/R/RMethodUtils.R index 2de23f04794..33d3462808f 100644 --- a/src/library/methods/R/RMethodUtils.R +++ b/src/library/methods/R/RMethodUtils.R @@ -491,6 +491,15 @@ getGeneric <- value } +##' Is `name` from package `pkg` *exported* from the package namespace ? +.isExported <- function(name, pkg) + pkg == ".GlobalEnv" || isBaseNamespace(ns <- asNamespace(pkg)) || + name %in% names(.getNamespaceInfo(ns, "exports")) + +.maybeUnhideName <- function(name, pkg) + if(.isExported(name, pkg)) name else paste(pkg, name, sep=":::") + + ## cache and retrieve generic functions. If the same generic name ## appears for multiple packages, a named list of the generics is cached. .genericTable <- new.env(TRUE, baseenv()) @@ -740,9 +749,9 @@ getGenerics <- function(where, searchForm = FALSE) ## all the packages cached ==? all packages with methods ## globally visible. Assertion based on cacheMetaData + setMethod fdefs <- as.list(.genericTable, all.names=TRUE, sorted=TRUE) - fnames <- mapply(function(nm, obj) { - if (is.list(obj)) names(obj) else nm - }, names(fdefs), fdefs, SIMPLIFY=FALSE) + fnames <- mapply(function(nm, obj) if(is.list(obj)) names(obj) else nm, + names(fdefs), fdefs, SIMPLIFY=FALSE) +### FIXME: at least *optionally* we want to filter (aka "drop") *non*-exported S4 generics packages <- lapply(fdefs, .packageForGeneric) new("ObjectsWithPackage", unlist(fnames), package=unlist(packages)) } diff --git a/src/library/methods/R/show.R b/src/library/methods/R/show.R index c8b7eb223dd..f46880e0ae0 100644 --- a/src/library/methods/R/show.R +++ b/src/library/methods/R/show.R @@ -1,7 +1,7 @@ # File src/library/methods/R/show.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2020 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -105,13 +105,10 @@ show <- function(object) showDefault(object) cat("\n") show(object@.Data) pkg <- object@package - exported <- pkg == ".GlobalEnv" || isBaseNamespace(ns <- asNamespace(pkg)) || - nam %in% names(.getNamespaceInfo(ns, "exports")) qnam <- deparse1(as.name(nam), backtick = TRUE) # was dQuote(nam, NULL) - showGen <- if(exported) qnam else paste(pkg, qnam, sep=":::") cat("Methods may be defined for arguments: ", paste0(object@signature, collapse=", "), "\n", - "Use showMethods(", showGen, + "Use showMethods(", .maybeUnhideName(qnam, pkg), ") for currently available ones.\n", sep="") if(.simpleInheritanceGeneric(object)) cat("(This generic function excludes non-simple inheritance; see ?setIs)\n") From 4433359b17a89a900be2a3fef6805d5f4a56ad93 Mon Sep 17 00:00:00 2001 From: maechler Date: Tue, 27 Aug 2024 12:52:38 +0000 Subject: [PATCH 518/546] Sys.setLanguage() default "msg", not "silent" git-svn-id: https://svn.r-project.org/R/trunk@87061 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/stop.R | 6 +++--- src/library/base/man/gettext.Rd | 4 ++-- src/library/utils/R/str.R | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/library/base/R/stop.R b/src/library/base/R/stop.R index 749a28eca5b..b8f79bac540 100644 --- a/src/library/base/R/stop.R +++ b/src/library/base/R/stop.R @@ -126,17 +126,17 @@ gettextf <- function(fmt, ..., domain = NULL, trim = TRUE) ## Could think of using *several* domains, i.e. domain = vector; but seems complicated; ## the default domain="R" seems to work for all of base R: {"R", "R-base", "RGui"} -Sys.setLanguage <- function(lang, unset = "en", C.vs.en = c("silent", "msg", "warn")) +Sys.setLanguage <- function(lang, unset = "en", C.vs.en = c("msg", "warn", "silent")) { stopifnot(is.character(lang), length(lang) == 1L, # e.g., "es" , "fr_CA" lang == "C" || grepl("^[a-z][a-z]", lang)) curLang <- Sys.getenv("LANGUAGE", unset = NA) # so it can be reset + if(is.na(curLang) || !nzchar(curLang)) + curLang <- unset # "factory" default if (!capabilities("NLS") || is.na(.popath)) { warning(gettextf("no natural language support or missing translations"), domain=NA) return(invisible(structure(curLang, ok = FALSE))) } - if(is.na(curLang) || !nzchar(curLang)) - curLang <- unset # "factory" default Warning <- if(startsWith(lang, "en")) switch(match.arg(C.vs.en), silent = function(...){}, diff --git a/src/library/base/man/gettext.Rd b/src/library/base/man/gettext.Rd index 3a320cdbbdb..78a6cac05c0 100644 --- a/src/library/base/man/gettext.Rd +++ b/src/library/base/man/gettext.Rd @@ -27,7 +27,7 @@ ngettext(n, msg1, msg2, domain = NULL) bindtextdomain(domain, dirname = NULL) -Sys.setLanguage(lang, unset = "en", C.vs.en = c("silent", "msg", "warn")) +Sys.setLanguage(lang, unset = "en", C.vs.en = c("msg", "warn", "silent")) } \arguments{ \item{\dots}{one or more character vectors.} @@ -48,7 +48,7 @@ Sys.setLanguage(lang, unset = "en", C.vs.en = c("silent", "msg", "warn")) empty.} \item{C.vs.en}{a string specifying how a current (sometimes \dQuote{hard}) setting of language \code{"C"} is treated for \code{lang = "en"}. - When \code{"silent"}, nothing is signalled, when \code{"msg"}, a + When \code{"silent"}, nothing happens, when \code{"msg"}, a \code{\link{message}()} and if \code{"warn"} a \code{\link{warning}()} is signalled.} } diff --git a/src/library/utils/R/str.R b/src/library/utils/R/str.R index 2fa2d7d9b3d..b3246d4ba67 100644 --- a/src/library/utils/R/str.R +++ b/src/library/utils/R/str.R @@ -697,7 +697,7 @@ print.ls_str <- function(x, max.level = 1, give.attr = FALSE, digits.d = digits), args) n. <- substr(tempfile("ls_str_", tmpdir=""), 2L, 20L) if(is.na(L <- Sys.getenv("LANGUAGE", unset=NA)) || L != "en") { - Sys.setLanguage("en") # for "" to work below + Sys.setLanguage("en", C.vs.en="silent") # for "" to work below on.exit(if(is.na(L)) Sys.unsetenv("LANGUAGE") else Sys.setenv(LANGUAGE = L)) } for(nam in x) { From a173be62c75b84797e8108b04b92216545467d27 Mon Sep 17 00:00:00 2001 From: maechler Date: Tue, 27 Aug 2024 16:46:31 +0000 Subject: [PATCH 519/546] better .maybeUnhideName() [more to come] git-svn-id: https://svn.r-project.org/R/trunk@87062 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/methods/R/RMethodUtils.R | 7 ++++--- src/library/methods/R/show.R | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/library/methods/R/RMethodUtils.R b/src/library/methods/R/RMethodUtils.R index 33d3462808f..7802857ddf9 100644 --- a/src/library/methods/R/RMethodUtils.R +++ b/src/library/methods/R/RMethodUtils.R @@ -496,9 +496,10 @@ getGeneric <- pkg == ".GlobalEnv" || isBaseNamespace(ns <- asNamespace(pkg)) || name %in% names(.getNamespaceInfo(ns, "exports")) -.maybeUnhideName <- function(name, pkg) - if(.isExported(name, pkg)) name else paste(pkg, name, sep=":::") - +.maybeUnhideName <- function(name, pkg, qName = FALSE) { + nm <- if(qName) deparse1(as.name(name), backtick = TRUE) else name + if(.isExported(name, pkg)) nm else paste(pkg, nm, sep=":::") +} ## cache and retrieve generic functions. If the same generic name ## appears for multiple packages, a named list of the generics is cached. diff --git a/src/library/methods/R/show.R b/src/library/methods/R/show.R index f46880e0ae0..92e0ec6d736 100644 --- a/src/library/methods/R/show.R +++ b/src/library/methods/R/show.R @@ -105,10 +105,9 @@ show <- function(object) showDefault(object) cat("\n") show(object@.Data) pkg <- object@package - qnam <- deparse1(as.name(nam), backtick = TRUE) # was dQuote(nam, NULL) cat("Methods may be defined for arguments: ", paste0(object@signature, collapse=", "), "\n", - "Use showMethods(", .maybeUnhideName(qnam, pkg), + "Use showMethods(", .maybeUnhideName(nam, pkg, qName = TRUE), ") for currently available ones.\n", sep="") if(.simpleInheritanceGeneric(object)) cat("(This generic function excludes non-simple inheritance; see ?setIs)\n") From e70221764644afeae122abb48d2b2729b953d21c Mon Sep 17 00:00:00 2001 From: ligges Date: Tue, 27 Aug 2024 22:50:29 +0000 Subject: [PATCH 520/546] add EUPL-1.2 (EUPL-1.1 is superseded) git-svn-id: https://svn.r-project.org/R/trunk@87063 00db46b3-68df-0310-9c12-caf00c1e9a41 --- share/licenses/license.db | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/share/licenses/license.db b/share/licenses/license.db index 26ca7a8171a..bbc3e8125ad 100644 --- a/share/licenses/license.db +++ b/share/licenses/license.db @@ -203,7 +203,15 @@ Name: European Union Public License Version: 1.1 Abbrev: EUPL FSF: free (https://www.gnu.org/licenses/license-list.html#EUPL) -OSI: open (https://opensource.org/licenses/EUPL-1.1) +OSI: open but superseded (https://opensource.org/licenses/EUPL-1.1) +URL: https://joinup.ec.europa.eu/software/page/eupl +FOSS: yes + +Name: European Union Public License +Version: 1.2 +Abbrev: EUPL +FSF: free (https://www.gnu.org/licenses/license-list.html#EUPL) +OSI: open (https://opensource.org/licenses/EUPL-1.2) URL: https://joinup.ec.europa.eu/software/page/eupl FOSS: yes From cab94e11771a250ad915580832d75d06106b1b6d Mon Sep 17 00:00:00 2001 From: maechler Date: Wed, 28 Aug 2024 10:29:39 +0000 Subject: [PATCH 521/546] use .Library for Matrix git-svn-id: https://svn.r-project.org/R/trunk@87065 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/eval-etc-2.R | 2 +- tests/eval-etc-2.Rout.save | 8 ++++---- tests/reg-examples3.R | 4 +++- tests/reg-examples3.Rout.save | 19 +++++++++++++------ tests/reg-tests-3.R | 10 +++++++--- tests/reg-tests-3.Rout.save | 13 +++++++++---- 6 files changed, 37 insertions(+), 19 deletions(-) diff --git a/tests/eval-etc-2.R b/tests/eval-etc-2.R index cf1920cf1a4..428a8a38379 100644 --- a/tests/eval-etc-2.R +++ b/tests/eval-etc-2.R @@ -9,7 +9,7 @@ srcdir <- file.path(Sys.getenv("SRCDIR"), "eval-fns.R") source(if(file.exists(srcdir)) srcdir else "./eval-fns.R", echo = TRUE) rm("srcdir") -require("Matrix") +require("Matrix", .Library) D5. <- Diagonal(x = 5:1) D5N <- D5.; D5N[5,5] <- NA ## a subset/version of example(Matrix) : -------------------------------- diff --git a/tests/eval-etc-2.Rout.save b/tests/eval-etc-2.Rout.save index 7b849e1908c..ee4b9a6bc1d 100644 --- a/tests/eval-etc-2.Rout.save +++ b/tests/eval-etc-2.Rout.save @@ -1,7 +1,7 @@ -R Under development (unstable) (2023-10-23 r85391) -- "Unsuffered Consequences" -Copyright (C) 2023 The R Foundation for Statistical Computing -Platform: aarch64-apple-darwin22.6.0 +R Under development (unstable) (2024-08-27 r87063) -- "Unsuffered Consequences" +Copyright (C) 2024 The R Foundation for Statistical Computing +Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -56,7 +56,7 @@ Type 'q()' to quit R. + cat(nm, ": ", sep = .... [TRUNCATED] > rm("srcdir") > -> require("Matrix") +> require("Matrix", .Library) Loading required package: Matrix > D5. <- Diagonal(x = 5:1) > D5N <- D5.; D5N[5,5] <- NA diff --git a/tests/reg-examples3.R b/tests/reg-examples3.R index 69b950922c1..d834c4948f4 100644 --- a/tests/reg-examples3.R +++ b/tests/reg-examples3.R @@ -87,9 +87,11 @@ contrasts(fff) <- contr.sum(5)[, 1:2]; contrasts(fff) ## using sparse contrasts: % useful, once model.matrix() works with these : ffs <- fff +if(requireNamespace("Matrix", lib.loc=.Library)) withAutoprint({ contrasts(ffs) <- contr.sum(5, sparse = TRUE)[, 1:2]; contrasts(ffs) stopifnot(all.equal(ffs, fff)) contrasts(ffs) <- contr.sum(5, sparse = TRUE); contrasts(ffs) +}) # glm.Rd utils::data(anorexia, package = "MASS") @@ -155,7 +157,7 @@ termplot(hills.lm, transform.x = TRUE, terms = "log(dist)", main = "Transformed") # xtabs.Rd -if(require("Matrix")) { +if(require("Matrix", .Library)) { ## similar to "nlme"s 'ergoStool' : d.ergo <- data.frame(Type = paste0("T", rep(1:4, 9*4)), Subj = gl(9, 4, 36*4)) diff --git a/tests/reg-examples3.Rout.save b/tests/reg-examples3.Rout.save index 4d1c437f6d6..9a7f3ad20f7 100644 --- a/tests/reg-examples3.Rout.save +++ b/tests/reg-examples3.Rout.save @@ -1,7 +1,7 @@ -R Under development (unstable) (2022-03-19 r81942) -- "Unsuffered Consequences" -Copyright (C) 2022 The R Foundation for Statistical Computing -Platform: x86_64-pc-linux-gnu (64-bit) +R Under development (unstable) (2024-08-27 r87063) -- "Unsuffered Consequences" +Copyright (C) 2024 The R Foundation for Statistical Computing +Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -256,7 +256,13 @@ t -1 -1 -0.2471257 0.2688164 > > ## using sparse contrasts: % useful, once model.matrix() works with these : > ffs <- fff -> contrasts(ffs) <- contr.sum(5, sparse = TRUE)[, 1:2]; contrasts(ffs) +> if(requireNamespace("Matrix", lib.loc=.Library)) withAutoprint({ ++ contrasts(ffs) <- contr.sum(5, sparse = TRUE)[, 1:2]; contrasts(ffs) ++ stopifnot(all.equal(ffs, fff)) ++ contrasts(ffs) <- contr.sum(5, sparse = TRUE); contrasts(ffs) ++ }) +> contrasts(ffs) <- contr.sum(5, sparse = TRUE)[, 1:2] +> contrasts(ffs) [,1] [,2] [,3] [,4] a 1 0 -0.2471257 0.2688164 c 0 1 -0.2471257 0.2688164 @@ -264,7 +270,8 @@ i 0 0 -0.1498721 -0.8817814 s 0 0 0.8912491 0.0753323 t -1 -1 -0.2471257 0.2688164 > stopifnot(all.equal(ffs, fff)) -> contrasts(ffs) <- contr.sum(5, sparse = TRUE); contrasts(ffs) +> contrasts(ffs) <- contr.sum(5, sparse = TRUE) +> contrasts(ffs) 5 x 4 sparse Matrix of class "dgCMatrix" a 1 . . . @@ -446,7 +453,7 @@ Standard deviations: + terms = "log(dist)", main = "Transformed") > > # xtabs.Rd -> if(require("Matrix")) { +> if(require("Matrix", .Library)) { + ## similar to "nlme"s 'ergoStool' : + d.ergo <- data.frame(Type = paste0("T", rep(1:4, 9*4)), + Subj = gl(9, 4, 36*4)) diff --git a/tests/reg-tests-3.R b/tests/reg-tests-3.R index dec085c4338..cdca12bc80a 100644 --- a/tests/reg-tests-3.R +++ b/tests/reg-tests-3.R @@ -104,7 +104,7 @@ cbind(npk, foo) ## failed in R < 2.10.0 -if(suppressMessages(require("Matrix"))) { +if(suppressMessages(require("Matrix", .Library))) { print(cS. <- contr.SAS(5, sparse = TRUE)) stopifnot(all(contr.SAS(5) == cS.), all(contr.helmert(5, sparse = TRUE) == contr.helmert(5))) @@ -131,7 +131,7 @@ print(xtabs(~ x1 + x2, exclude = 'c', na.action = na.pass)) ## median should work by default for a suitable S4 class. ## adapted from adaptsmoFMRI -if(suppressMessages(require("Matrix"))) { +if(suppressMessages(require("Matrix", .Library))) { x <- matrix(c(1,2,3,4)) print(m <- median(x)) stopifnot(all.equal(m, median(as(x, "denseMatrix")))) @@ -169,7 +169,7 @@ if(require("MASS")) { } ## the error was in lm.(w)fit -if(require("Matrix")) { +if(require("Matrix", .Library)) { m1 <- m2 <- m <- matrix(1:12, 3,4) dimnames(m2) <- list(LETTERS[1:3], letters[1:4]) @@ -277,6 +277,10 @@ if(hasME) withAutoprint({ desc$Repository <- NULL c3 <- citation(auto = desc) stopifnot(identical(print(c3$url), URL1)) # R <= 4.4.0 gave both URLs + + unloadNamespace(pkg) }) + + cat('Time elapsed: ', proc.time(),'\n') diff --git a/tests/reg-tests-3.Rout.save b/tests/reg-tests-3.Rout.save index 487de179a9e..99f320954bc 100644 --- a/tests/reg-tests-3.Rout.save +++ b/tests/reg-tests-3.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-06-18 r86779) -- "Unsuffered Consequences" +R Under development (unstable) (2024-08-27 r87063) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -689,7 +689,7 @@ Loading required package: survival > ## failed in R < 2.10.0 > > -> if(suppressMessages(require("Matrix"))) { +> if(suppressMessages(require("Matrix", .Library))) { + print(cS. <- contr.SAS(5, sparse = TRUE)) + stopifnot(all(contr.SAS(5) == cS.), + all(contr.helmert(5, sparse = TRUE) == contr.helmert(5))) @@ -756,7 +756,7 @@ x1 a b > > ## median should work by default for a suitable S4 class. > ## adapted from adaptsmoFMRI -> if(suppressMessages(require("Matrix"))) { +> if(suppressMessages(require("Matrix", .Library))) { + x <- matrix(c(1,2,3,4)) + print(m <- median(x)) + stopifnot(all.equal(m, median(as(x, "denseMatrix")))) @@ -814,7 +814,7 @@ X2 0 1 0 > ## the error was in lm.(w)fit > -> if(require("Matrix")) { +> if(require("Matrix", .Library)) { + m1 <- m2 <- m <- matrix(1:12, 3,4) + dimnames(m2) <- list(LETTERS[1:3], + letters[1:4]) @@ -995,6 +995,8 @@ packages. + desc$Repository <- NULL + c3 <- citation(auto = desc) + stopifnot(identical(print(c3$url), URL1)) # R <= 4.4.0 gave both URLs ++ ++ unloadNamespace(pkg) + }) > c2 <- citation(pkg, .Library) > c2$author[[1]]$given[[1]] <- "J." @@ -1078,6 +1080,9 @@ A BibTeX entry for LaTeX users is > c3 <- citation(auto = desc) > stopifnot(identical(print(c3$url), URL1)) [1] "https://example.org" +> unloadNamespace(pkg) +> +> > > cat('Time elapsed: ', proc.time(),'\n') Time elapsed: 2.176 0.139 2.315 0.002 0 From 39ff7362dac5380c47ba4d756a350d30168396e9 Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 28 Aug 2024 13:02:04 +0000 Subject: [PATCH 522/546] Updated. git-svn-id: https://svn.r-project.org/R/trunk@87066 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index 671a8bc4ef6..92b9ffd9600 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -29,7 +29,7 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "China (Nanjing) [https]",China,Nanjing,https://mirrors.nju.edu.cn/CRAN/,"eScience Center, Nanjing University","my # yaoge123.com",1,cn,"secure_mirror_from_master" "China (Shanghai 2) [https]",China,Shanghai,https://mirrors.sjtug.sjtu.edu.cn/cran/,"Shanghai Jiao Tong University","Alex Chi ",1,cn,"secure_mirror_from_master" "China (Shenzhen) [https]",China,Shenzhen,https://mirrors.sustech.edu.cn/CRAN/,"Southern University of Science and Technology (SUSTech)","cra # sustech.edu.cn",1,cn,"secure_mirror_from_master" -"China (Wuhan) [https]",China,Wuhan,https://mirrors.hust.edu.cn/CRAN/,"Huazhong University of Science and Technology","mirror_support # hust.edu.cn",1,cn +"China (Wuhan) [https]",China,Wuhan,https://mirrors.hust.edu.cn/CRAN/,"Huazhong University of Science and Technology","mirror_support # hust.edu.cn",1,cn,"secure_mirror_from_master" "China (Xianyang) [https]",China,Xianyang,https://mirrors.nwafu.edu.cn/cran/,"Northwest A&F University (NWAFU)","dingyuxiao99 # nwafu.edu.cn",1,cn "Colombia (Cali) [https]",Colombia,Cali,https://www.icesi.edu.co/CRAN/,"Icesi University","adminred # Icesi.edu.co",1,co,"secure_mirror_from_master" "Costa Rica [https]","Costa Rica","San JosĆ©",https://mirror.uned.ac.cr/cran/,"Distance State University (UNED)","rherrerav # uned.ac.cr",1,cr,"secure_mirror_from_master" @@ -66,7 +66,7 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Netherlands (Amsterdam) [https]","Netherlands",Amsterdam,https://mirrors.evoluso.com/CRAN/,"Evoluso.com","mirrors # evoluso.com",1,nl, "Netherlands (Dronten) [https]","Netherlands",Dronten,https://mirror.lyrahosting.com/CRAN/,"Lyra Hosting","admin # lyrahosting.com",1,nl,"secure_mirror_from_master" "New Zealand [https]","New Zealand",Auckland,https://cran.stat.auckland.ac.nz/,"University of Auckland","s.urbanek # auckland.ac.nz",1,nz,"secure_mirror_from_master" -"Norway [https]",Norway,Bergen,https://cran.uib.no/,"University of Bergen","sundrift # It.uib.no",1,no,"secure_mirror_from_master" +"Norway [https]",Norway,Bergen,https://cran.uib.no/,"University of Bergen","sundrift # It.uib.no",1,no,"secure_mirror_from_master,maintainer_address_bounces" "Poland [https]",Poland,Warsaw,https://cran.mi2.ai/,"MI2.ai, Warsaw University of Technology","przemyslaw.biecek # gmail.com",1,pl "Portugal (Lisbon) [https]",Portugal,Lisbon,https://cran.radicaldevelop.com/,"RadicalDevelop, Lda","geral # radicaldevelop.com",1,pt "Russia (Novosibirsk) [https]",Russia,Novosibirsk,https://mirror.truenetwork.ru/CRAN/,"Truenetwork","mirror # truenetwork.ru",1,ru @@ -83,7 +83,7 @@ Thailand,Thailand,Hatyai,http://mirrors.psu.ac.th/pub/cran/,"Prince of Songkla U "UK (Bristol) [https]",UK,Bristol,https://www.stats.bris.ac.uk/R/,"University of Bristol","Oliver Johnson , it-zone-d # bristol.ac.uk",1,uk,"secure_mirror_from_master" "UK (London 1) [https]",UK,London,https://cran.ma.imperial.ac.uk/,"Imperial College London","andy.thomas # imperial.ac.uk",1,uk,"secure_mirror_from_master" "UK (Warwick)",UK,Coventry,https://anorien.csc.warwick.ac.uk/CRAN/," University of Warwick","David Quigley ",1,uk -"USA (IA) [https]",USA,Ames,https://mirror.las.iastate.edu/CRAN/,"Iowa State University, Ames, IA","statit # iastate.edu",1,us,"secure_mirror_from_master" +"USA (IA) [https]",USA,Ames,https://mirror.las.iastate.edu/CRAN/,"Iowa State University, Ames, IA","cran-mirror # iastate.edu",1,us,"secure_mirror_from_master" "USA (IN)",USA,Bloomington,http://ftp.ussg.iu.edu/CRAN/,"Indiana University","rtadmin # indiana.edu",1,us "USA (MI) [https]",USA,"Ann Arbor",https://repo.miserver.it.umich.edu/cran/,"MBNI, University of Michigan, Ann Arbor, MI","linux-mirrors # umich.edu",1,us,"secure_mirror_from_master" "USA (MO) [https]",USA,"St. Louis",https://cran.wustl.edu/,"Washington University, St. Louis, MO","Jonathan Rapkin ",1,us,"secure_mirror_from_master" From b5d27a328efdaf0f5186a16ea2e0fe4165287e8c Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 28 Aug 2024 13:02:33 +0000 Subject: [PATCH 523/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@87067 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/utils.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index d797cc67d1a..66fd24bea1b 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -2098,8 +2098,9 @@ function(file, encoding = NA, keep.source = getOption("keep.source")) ### ** .persons_from_metadata -.persons_from_metadata <- function(dir) { - meta <- .get_package_metadata(dir) +.persons_from_metadata <- function(dir, meta = NULL) { + if(is.null(meta)) + meta <- .get_package_metadata(dir) if(!is.na(aar <- meta["Authors@R"])) { aar <- tryCatch(utils:::.read_authors_at_R_field(aar), error = identity) From 1d0f1aea1849f74e3c165e27805b99d629f9f79f Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 28 Aug 2024 13:03:50 +0000 Subject: [PATCH 524/546] Send CRAN package/mirror maintainer emails to CRAN with maintainers in Bcc. git-svn-id: https://svn.r-project.org/R/trunk@87068 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/CRANtools.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/library/tools/R/CRANtools.R b/src/library/tools/R/CRANtools.R index fb2e80eb42a..3127116e3ed 100644 --- a/src/library/tools/R/CRANtools.R +++ b/src/library/tools/R/CRANtools.R @@ -381,12 +381,12 @@ function(mirrors, db = NULL, collapse = TRUE) addresses <- gsub("[[:space:]]*#[[:space:]]*", "@", addresses) to <- unique(unlist(strsplit(addresses, "[[:space:]]*,[[:space:]]*"))) - head <- list("To" = to, - "CC" = "CRAN@R-project.org", + head <- list("To" = "CRAN@R-project.org", + "Bcc" = to, "Subject" = "CRAN mirrors maintained by you", "Reply-To" = "CRAN@R-project.org") if(collapse) { - head$To <- paste(head$To, collapse = ",\n ") + head$Bcc <- paste(head$Bcc, collapse = ",\n ") head <- sprintf("%s: %s", names(head), unlist(head)) } len <- length(addresses) @@ -563,12 +563,12 @@ function(packages, db = NULL, collapse = TRUE) ind <- match(packages, db[, "Package"]) addresses <- db[ind, "Address"] to <- sort(unique(addresses)) - head <- list("To" = to, - "CC" = "CRAN@R-project.org", + head <- list("To" = "CRAN@R-project.org", + "Bcc" = to, "Subject" = "CRAN packages maintained by you", "Reply-To" = "CRAN@R-project.org") if(collapse) { - head$To <- paste(head$To, collapse = ",\n ") + head$Bcc <- paste(head$Bcc, collapse = ",\n ") head <- sprintf("%s: %s", names(head), unlist(head)) } lst <- split(db[ind, "Package"], db[ind, "Maintainer"]) From dff9236d24ca02e4d6f87185bbb2b4e28a9c31cf Mon Sep 17 00:00:00 2001 From: hornik Date: Wed, 28 Aug 2024 17:14:34 +0000 Subject: [PATCH 525/546] Drop mirror.rcg.sfu.ca. git-svn-id: https://svn.r-project.org/R/trunk@87069 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/CRAN_mirrors.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/CRAN_mirrors.csv b/doc/CRAN_mirrors.csv index 92b9ffd9600..8f012072270 100644 --- a/doc/CRAN_mirrors.csv +++ b/doc/CRAN_mirrors.csv @@ -12,7 +12,6 @@ Name,Country,City,URL,Host,Maintainer,OK,CountryCode,Comment "Brazil (SP 1) [https]",Brazil,"Sao Paulo",https://vps.fmvz.usp.br/CRAN/,"University of Sao Paulo, Sao Paulo","Fernando Ferreira ",1,br,"secure_mirror_from_master" "Brazil (SP 2) [https]",Brazil,Piracicaba,https://brieger.esalq.usp.br/CRAN/,"University of Sao Paulo, Piracicaba","A Augusto F Garcia , augusto.garcia # usp.br",1,br,"secure_mirror_from_master" "Bulgaria [https]",Bulgaria,Sofia,https://ftp.uni-sofia.bg/CRAN/,"Sofia University","Alexander Velin ",1,bg,"secure_mirror_from_master" -"Canada (BC) [https]",Canada,Burnaby,https://mirror.rcg.sfu.ca/mirror/CRAN/,"Simon Fraser University, Burnaby","research-support # sfu.ca",1,ca "Canada (MB) [https]",Canada,Winnipeg,https://muug.ca/mirror/cran/,"Manitoba Unix User Group","mirror # muug.ca",1,ca,"secure_mirror_from_master" "Canada (ON 1) [https]",Canada,Waterloo,https://mirror.csclub.uwaterloo.ca/CRAN/,"University of Waterloo","syscom # csclub.uwaterloo.ca",1,ca,"secure_mirror_from_master" "Canada (ON 2) [https]",Canada,Hamilton,https://cran.mirror.rafal.ca/,"Rafal Rzeczkowski","Rafal Rzeczkowski ",1,ca,"secure_mirror_from_master" From 04f990682ba1c7f22877a720131f6f974045311a Mon Sep 17 00:00:00 2001 From: pd Date: Wed, 28 Aug 2024 23:23:34 +0000 Subject: [PATCH 526/546] maintainer-mode changes git-svn-id: https://svn.r-project.org/R/trunk@87070 00db46b3-68df-0310-9c12-caf00c1e9a41 From ecfa74b3c39b44686f364c5bb00e0ea86a9e9f5c Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 29 Aug 2024 07:17:07 +0000 Subject: [PATCH 527/546] NOTE output diffs. git-svn-id: https://svn.r-project.org/R/trunk@87071 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/check.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index c773fac81c1..8dba80dfe88 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -4622,7 +4622,9 @@ add_dummies <- function(dir, Log) ## check o/p might be in a different encoding. lines <- readLines(logf, warn = FALSE) if(any(grepl("Running R code.*times elapsed time", - lines, useBytes = TRUE))) + lines, useBytes = TRUE)) || + any(startsWith(lines, " Comparing") & + !endsWith(lines, "... OK"))) any <- TRUE } if(any) noteLog(Log) else resultLog(Log, "OK") From 4ca3ead8b8eb9d1e600f33ad275d62b728ba67e4 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 29 Aug 2024 07:17:17 +0000 Subject: [PATCH 528/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@87072 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index 71925b8fd03..d96c10b5ff3 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -7518,8 +7518,15 @@ function(dir, localOnly = FALSE, pkgSize = NA) p <- strsplit(meta[field], " *, *")[[1L]] ## multicore has been superseded by parallel. Almost all of ## snow has been too, so it should be optional. - p2 <- grep("^(multicore|snow|doSNOW)( |\\(|$)", p, value = TRUE) - uses <- c(uses, p2) + ## + ## However, as of 2024-08 there are still 40 and 64 CRAN + ## packages which at least suggest snow or doSNOW, respectively, + ## apparently needing the functionality of snow not ported to + ## parallel (MPI, ...). Hence better to no longer NOTE their + ## use. + ## p2 <- grep("^(multicore|snow|doSNOW)( |\\(|$)", p, value = TRUE) + ## uses <- c(uses, p2) + ## ## BRugs and R2OpenBUGS have a SystemRequirements of OpenBUGS. ## which requires ix86 (not x86-64) and currently installs ## only on Linux using a compiler supporting -m32. From 9b011cb7f37033700ecbf501c57799d81e8375ff Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 29 Aug 2024 07:17:34 +0000 Subject: [PATCH 529/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@87073 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 3ddf8e7a208..91ffdbe3a57 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -1720,8 +1720,8 @@ HTTP server and by client. There should be no space in the host part of an @samp{http://} URL, and spaces in the remainder should be encoded, with each space replaced by @samp{%20}. -Other characters may benefit from being encoded: see the help on -@code{URLencode()}. +Reserved characters should be encoded unless used in their reserved +sense: see the help on @code{URLencode()}. The canonical URL for a @acronym{CRAN} package is @example From f0219d60ad5712f48eb7ee04f15504c79dd2cab8 Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 29 Aug 2024 07:50:30 +0000 Subject: [PATCH 530/546] Fix typo. git-svn-id: https://svn.r-project.org/R/trunk@87074 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-exts.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 91ffdbe3a57..8a67a41cbe8 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -14369,8 +14369,8 @@ Weak references are used to allow the programmer to maintain information on entities without preventing the garbage collection of the entities once they become unreachable. -A weak reference contains a key and a value. The value is reachable is -if it either reachable directly or @emph{via} weak references with reachable +A weak reference contains a key and a value. The value is reachable +if it is either reachable directly or @emph{via} weak references with reachable keys. Once a value is determined to be unreachable during garbage collection, the key and value are set to @code{R_NilValue} and the finalizer will be run later in the garbage collection. From 43d5769bece45767ad8d8706a636ab6b5816e141 Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 29 Aug 2024 08:08:35 +0000 Subject: [PATCH 531/546] Avoid including headers from extern C blocks to reduce the risk of breakage with C++ compilers. git-svn-id: https://svn.r-project.org/R/trunk@87075 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/extra/graphapp/graphapp.h | 8 +++--- src/extra/graphapp/internal.h | 8 +++--- src/include/R_ext/Altrep.h | 5 ++-- src/include/R_ext/GraphicsDevice.h | 4 +-- src/include/R_ext/GraphicsEngine.h | 9 ++++++- src/include/R_ext/MathThreads.h | 5 ++-- src/include/R_ext/QuartzDevice.h | 10 +++++--- src/include/R_ext/RS.h | 2 +- src/include/Rinterface.h | 40 +++++++++++++++++++----------- src/include/Rinternals.h | 17 +++++++------ 10 files changed, 68 insertions(+), 40 deletions(-) diff --git a/src/extra/graphapp/graphapp.h b/src/extra/graphapp/graphapp.h index 692c50ac9c8..d1919530f4e 100644 --- a/src/extra/graphapp/graphapp.h +++ b/src/extra/graphapp/graphapp.h @@ -21,6 +21,11 @@ * Assume C declarations for C++ */ +#include +#include + +#include + #ifdef __cplusplus extern "C" { #endif /* begin normal C declarations */ @@ -29,8 +34,6 @@ extern "C" { * Definition of some constants. */ -#include -#include #ifndef Pi #define Pi 3.14159265359 @@ -1251,7 +1254,6 @@ void showcaret(control c, int showing); * Library supplied variables. */ -#include #undef LibExtern #ifdef GA_DLL_BUILD # define LibExtern extern diff --git a/src/extra/graphapp/internal.h b/src/extra/graphapp/internal.h index 0d522a93d4b..b813ca4854a 100644 --- a/src/extra/graphapp/internal.h +++ b/src/extra/graphapp/internal.h @@ -74,10 +74,6 @@ PROTECTED void updatestatus(const char *text); PROTECTED font new_font_object(HFONT hf); UINT default_font_charset(void); -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include @@ -87,6 +83,10 @@ extern "C" { #include +#ifdef __cplusplus +extern "C" { +#endif + #ifdef __MWERKS__ /* Metrowerks Codewarrior Cross-Platform C/C++ Compiler */ #define COMPILER 32 diff --git a/src/include/R_ext/Altrep.h b/src/include/R_ext/Altrep.h index 85cddb7e82f..b5e0df7345f 100644 --- a/src/include/R_ext/Altrep.h +++ b/src/include/R_ext/Altrep.h @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2016-2023 The R Core Team. + * Copyright (C) 2016-2024 The R Core Team. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -26,6 +26,8 @@ #ifndef R_EXT_ALTREP_H_ #define R_EXT_ALTREP_H_ +#include + #ifdef __cplusplus extern "C" { #endif @@ -104,7 +106,6 @@ typedef Rbyte (*R_altraw_Elt_method_t)(SEXP, R_xlen_t); typedef R_xlen_t (*R_altraw_Get_region_method_t)(SEXP, R_xlen_t, R_xlen_t, Rbyte *); -#include typedef Rcomplex (*R_altcomplex_Elt_method_t)(SEXP, R_xlen_t); typedef R_xlen_t (*R_altcomplex_Get_region_method_t)(SEXP, R_xlen_t, R_xlen_t, Rcomplex *); diff --git a/src/include/R_ext/GraphicsDevice.h b/src/include/R_ext/GraphicsDevice.h index 2b102483a6b..bd225c0ba6b 100644 --- a/src/include/R_ext/GraphicsDevice.h +++ b/src/include/R_ext/GraphicsDevice.h @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2001-11 The R Core Team. + * Copyright (C) 2001-24 The R Core Team. * * This header file is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -44,6 +44,7 @@ # endif #endif +#include #include #ifdef __cplusplus @@ -973,7 +974,6 @@ Rboolean doesIdle(pDevDesc dd); Rf_onintr(); \ } while(0) -#include LibExtern Rboolean R_interrupts_suspended; LibExtern int R_interrupts_pending; extern void Rf_onintr(void); diff --git a/src/include/R_ext/GraphicsEngine.h b/src/include/R_ext/GraphicsEngine.h index 1934c1819d8..ad26afe619b 100644 --- a/src/include/R_ext/GraphicsEngine.h +++ b/src/include/R_ext/GraphicsEngine.h @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2001-21 The R Core Team. + * Copyright (C) 2001-24 The R Core Team. * * This header file is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -229,9 +229,16 @@ typedef struct { typedef R_GE_gcontext* pGEcontext; +#ifdef __cplusplus +} +#endif #include /* needed for DevDesc */ +#ifdef __cplusplus +extern "C" { +#endif + typedef struct _GEDevDesc GEDevDesc; typedef SEXP (* GEcallback)(GEevent, GEDevDesc *, SEXP); diff --git a/src/include/R_ext/MathThreads.h b/src/include/R_ext/MathThreads.h index 7445a3c54dd..995b789941c 100644 --- a/src/include/R_ext/MathThreads.h +++ b/src/include/R_ext/MathThreads.h @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2000-2014 The R Core Team. + * Copyright (C) 2000-2024 The R Core Team. * * This header file is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -36,11 +36,12 @@ #ifndef R_EXT_MATHTHREADS_H_ #define R_EXT_MATHTHREADS_H_ +#include + #ifdef __cplusplus extern "C" { #endif -#include LibExtern int R_num_math_threads; LibExtern int R_max_num_math_threads; diff --git a/src/include/R_ext/QuartzDevice.h b/src/include/R_ext/QuartzDevice.h index 4ca21c849b3..396b832ded7 100644 --- a/src/include/R_ext/QuartzDevice.h +++ b/src/include/R_ext/QuartzDevice.h @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2007-2016 The R Core Team + * Copyright (C) 2007-2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -95,13 +95,15 @@ #include #endif +#if HAVE_AQUA +#include +#endif + #ifdef __cplusplus extern "C" { #endif -#if HAVE_AQUA -#include -#else +#ifndef HAVE_AQUA typedef void* CGContextRef; #endif diff --git a/src/include/R_ext/RS.h b/src/include/R_ext/RS.h index d6c4717ca20..16a98184be4 100644 --- a/src/include/R_ext/RS.h +++ b/src/include/R_ext/RS.h @@ -36,7 +36,7 @@ # define R_SIZE_T size_t #endif -#include /* for F77_APPEND_UNDERSCORE */ +#include /* for HAVE_F77_UNDERSCORE */ #ifdef __cplusplus extern "C" { diff --git a/src/include/Rinterface.h b/src/include/Rinterface.h index 7eec60b554d..de6a8988d04 100644 --- a/src/include/Rinterface.h +++ b/src/include/Rinterface.h @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 1998--2022 The R Core Team. + * Copyright (C) 1998--2024 The R Core Team. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,16 +33,39 @@ #ifndef RINTERFACE_H_ #define RINTERFACE_H_ -#include +#ifdef CSTACK_DEFNS +/* duplicating older Defn.h. + Note: this is never used when including Rinterface.h from R itself +*/ +# if !defined(HAVE_UINTPTR_T) && !defined(uintptr_t) + typedef unsigned long uintptr_t; +# else +# ifndef __cplusplus +# include +# elif __cplusplus >= 201103L +# include +# endif +# endif +#endif #ifdef __cplusplus /* we do not support DO_NOT_USE_CXX_HEADERS in this file */ # include -extern "C" { #else # include #endif +#include + +#ifdef R_INTERFACE_PTRS +# include // for SEXP +# include // for SA_TYPE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + // See R_ext/Error.h #if defined NORET #elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202301L) @@ -112,15 +135,6 @@ extern int R_running_as_main_program; /* duplicating older Defn.h. Note: this is never used when including Rinterface.h from R itself */ -#if !defined(HAVE_UINTPTR_T) && !defined(uintptr_t) - typedef unsigned long uintptr_t; -#else -# ifndef __cplusplus -# include -# elif __cplusplus >= 201103L -# include -# endif -#endif extern uintptr_t R_CStackLimit; /* C stack limit */ extern uintptr_t R_CStackStart; /* Initial stack address */ @@ -129,8 +143,6 @@ extern uintptr_t R_CStackStart; /* Initial stack address */ /* formerly in src/unix/devUI.h */ #ifdef R_INTERFACE_PTRS -#include // for SEXP -#include // for SA_TYPE #ifdef __SYSTEM__ # define extern diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index 517376b19aa..3fb375b9160 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -34,7 +34,6 @@ # include # include # include -extern "C" { #else # include # include /* for INT_MAX */ @@ -52,18 +51,22 @@ extern "C" { #include -typedef unsigned char Rbyte; - -/* type for length of (standard, not long) vectors etc */ -typedef int R_len_t; -#define R_LEN_T_MAX INT_MAX - /* both config.h and Rconfig.h set SIZEOF_SIZE_T, but Rconfig.h is skipped if config.h has already been included. */ #ifndef R_CONFIG_H # include #endif +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned char Rbyte; + +/* type for length of (standard, not long) vectors etc */ +typedef int R_len_t; +#define R_LEN_T_MAX INT_MAX + #if ( SIZEOF_SIZE_T > 4 ) # define LONG_VECTOR_SUPPORT #endif From 7cf7376f751e975a4b00548df600f50e06edc0ea Mon Sep 17 00:00:00 2001 From: maechler Date: Thu, 29 Aug 2024 10:58:06 +0000 Subject: [PATCH 532/546] print.ls_str(): FIXME git-svn-id: https://svn.r-project.org/R/trunk@87076 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/str.R | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library/utils/R/str.R b/src/library/utils/R/str.R index b3246d4ba67..499f4f4ad0e 100644 --- a/src/library/utils/R/str.R +++ b/src/library/utils/R/str.R @@ -712,6 +712,7 @@ print.ls_str <- function(x, max.level = 1, give.attr = FALSE, ##__ str(get(nam, envir = E, mode = M), ##__ max.level = max.level, give.attr = give.attr, ...) + ## FIXME: get() should rather return a *classed* error in this case eA <- sprintf("%s:%s", nam, n.) o <- tryCatch(get(nam, envir = E, mode = M), error = function(e){ attr(e, eA) <- TRUE; e }) From 81f7e0547cc3659e4e63a4e0815766c1dab6c1c2 Mon Sep 17 00:00:00 2001 From: hornik Date: Thu, 29 Aug 2024 12:41:41 +0000 Subject: [PATCH 533/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@87077 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/tools/R/QC.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/QC.R b/src/library/tools/R/QC.R index d96c10b5ff3..537678c6b99 100644 --- a/src/library/tools/R/QC.R +++ b/src/library/tools/R/QC.R @@ -7903,7 +7903,7 @@ function(dir, localOnly = FALSE, pkgSize = NA) if(!isTRUE(out$descr_bad_start) && !grepl("^['\"]?[[:upper:]]", descr)) out$descr_bad_initial <- TRUE descr <- strwrap(descr) - if(any(ind <- grepl("(^|[^<])https?://", descr))) { + if(any(ind <- grepl("(^|[^ Date: Thu, 29 Aug 2024 17:39:37 +0000 Subject: [PATCH 534/546] 2 typos; overflow chk, mentioned a while ago git-svn-id: https://svn.r-project.org/R/trunk@87078 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/errors.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/errors.c b/src/main/errors.c index 091f63801e0..15f7d89fce2 100644 --- a/src/main/errors.c +++ b/src/main/errors.c @@ -126,6 +126,10 @@ void attribute_no_sanitizer_instrumentation R_CheckStack2(size_t extra) int dummy; intptr_t usage = R_CStackDir * (R_CStackStart - (uintptr_t)&dummy); + if (INTPTR_MAX - usage < extra) + /* addition would overflow, this is definitely too much */ + R_SignalCStackOverflow(INTPTR_MAX); + /* do it this way, as some compilers do usage + extra in unsigned arithmetic */ usage += extra; @@ -2814,10 +2818,10 @@ SEXP R_makeOutOfBoundsError(SEXP x, int subscript, SEXP sindex, "%s", R_MSG_subs_o_b); PROTECT(cond); - /* In some cases the 'sbscript' argument is negative, indicating + /* In some cases the 'subscript' argument is negative, indicating that which subscript is out of bounds is not known. We could probably do better, but for now report 'subscript' as NA in the - condition objec. */ + condition object. */ SEXP ssub = ScalarInteger(subscript >= 0 ? subscript + 1 : NA_INTEGER); PROTECT(ssub); From c45360a9333a3f6a372ab9a86be26873ef5b1f49 Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 30 Aug 2024 12:33:26 +0000 Subject: [PATCH 535/546] (cont.) 87062: even better " showMethods(....) " suggestion in show() \\\ mv|clean "S4 tests" git-svn-id: https://svn.r-project.org/R/trunk@87079 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/methods/R/RMethodUtils.R | 19 +++++++++++-- src/library/methods/R/show.R | 42 +++++++++++++++++++++++++--- tests/classes-methods.R | 37 ++++++++++++++++++++++++ tests/reg-S4.R | 17 ++++------- tests/reg-S4.Rout.save | 20 ++++++------- 5 files changed, 106 insertions(+), 29 deletions(-) diff --git a/src/library/methods/R/RMethodUtils.R b/src/library/methods/R/RMethodUtils.R index 7802857ddf9..ff3bdcc9e6c 100644 --- a/src/library/methods/R/RMethodUtils.R +++ b/src/library/methods/R/RMethodUtils.R @@ -496,9 +496,24 @@ getGeneric <- pkg == ".GlobalEnv" || isBaseNamespace(ns <- asNamespace(pkg)) || name %in% names(.getNamespaceInfo(ns, "exports")) -.maybeUnhideName <- function(name, pkg, qName = FALSE) { +##' is `name` "visually exported", i.e., exported from pkg in search() +.isExportedVis <- function(name, pkg) + (pkg == ".GlobalEnv" || paste0("package:", pkg) %in% search()[-1L]) && + (isBaseNamespace(ns <- asNamespace(pkg)) || + name %in% names(.getNamespaceInfo(ns, "exports"))) + +##' "Minimal" valid name when `name` is from `pkg` (which can be ".GlobalEnv") +##' @param name string +##' @param pkg string +##' @param qName logical(-alike) +##' @return string +.minimalName <- function(name, pkg, qName = FALSE, chkXport = TRUE) { nm <- if(qName) deparse1(as.name(name), backtick = TRUE) else name - if(.isExported(name, pkg)) nm else paste(pkg, nm, sep=":::") + if(chkXport && .isExported(name, pkg)) { + if(pkg == ".GlobalEnv" || paste0("package:", pkg) %in% search()[-1L]) + nm + else paste(pkg, nm, sep="::") + } else paste(pkg, nm, sep=":::") } ## cache and retrieve generic functions. If the same generic name diff --git a/src/library/methods/R/show.R b/src/library/methods/R/show.R index 92e0ec6d736..448479d0e2b 100644 --- a/src/library/methods/R/show.R +++ b/src/library/methods/R/show.R @@ -53,8 +53,10 @@ showExtraSlots <- function(object, ignore) { if(is(ignore, "classRepresentation")) ignore <- slotNames(ignore) else if(!is(ignore, "character")) - stop(gettextf("invalid 'ignore' argument; should be a class definition or a character vector, got an object of class %s", dQuote(class(ignore))), - domain = NA) + stop(gettextf( + "invalid 'ignore' argument; should be a class definition or a character vector, got an object of class %s", + dQuote(class(ignore))), + domain = NA) slots <- slotNames(class(object)) for(s in slots[is.na(match(slots, ignore))]) { cat("Slot ",s, ":\n", sep="") @@ -105,10 +107,42 @@ show <- function(object) showDefault(object) cat("\n") show(object@.Data) pkg <- object@package + ## Find "correct" pkg in case in case object was e.g. Matrix::`diag<-` + ## where pkg is "base" (!) + ## This is imperfect (but clearly better than nothing): + mayMulti <- FALSE + if(notGen <- !(if(pkg == ".GlobalEnv") + isGeneric(nam) + else isGeneric(nam, getNamespace(pkg)))) { + ## other namespaces where a generic may live: + nss <- Filter(function(.) methods:::.hasS4MetaData(getNamespace(.)), + setdiff(loadedNamespaces(), c(pkg, "base"))) + hasGen <- vapply(nss, function(ns) isGeneric(nam, getNamespace(ns)), NA) + if(notGen <- !any(hasGen)) + ## if(notGen <- !isGeneric(nam, getNamespace(pkg <- "base"))) + pkg <- "" + else { + mayMulti <- TRUE + pkgs <- nss[hasGen] # with length >= 1 + pkg <- pkgs[[1L]] # take the first + } + } + ## grepl("::", so <- as.character(substitute(object)), fixed=TRUE)) + ## pkg <- ....... cat("Methods may be defined for arguments: ", paste0(object@signature, collapse=", "), "\n", - "Use showMethods(", .maybeUnhideName(nam, pkg, qName = TRUE), - ") for currently available ones.\n", sep="") + "Use showMethods(", .minimalName(nam, pkg, qName = TRUE, chkXport = !notGen), + ") for currently available ones", sep="") + if(notGen) { + cat(" where does not seem to be among the loadedNamespaces()") + } else if(mayMulti && length(pkgs) > 1L) { ## pkg == pkgs[[1]] + pkgs <- pkgs[-1L] # => length(pkgs) >= 1 + pkgs <- dQuote(pkgs, FALSE) + cat(sprintf(" where additionally to %s, the could also be %s", pkg, + if(length(pkgs) == 1L) pkgs + else paste("one of", paste0(pkgs, collapse = ", ")))) + } + cat(".\n") if(.simpleInheritanceGeneric(object)) cat("(This generic function excludes non-simple inheritance; see ?setIs)\n") }, diff --git a/tests/classes-methods.R b/tests/classes-methods.R index b92f338ec24..27193a715d7 100644 --- a/tests/classes-methods.R +++ b/tests/classes-methods.R @@ -19,6 +19,7 @@ if(require("Matrix", lib.loc = .Library, quietly = TRUE)) { identical(D5N, pmin(D5N, 5)), identical(as.matrix(pmin(D5N +1, 3)), pmin(as.matrix(D5N)+1, 3)), + is.function(Matrix::crossprod), # needed Matrix 1.6-1.1 for R-devel, Sep.2023 ## TRUE) @@ -158,3 +159,39 @@ stopifnot(exprs = { grepl('x = "numeric", y = "missing"', attr(err1, "condition")$message) identical(err1, err1Y) # (as $call is empty) }) + + +## PR#17496: sealClass() +setClass("foo", slots = c(name = "character"), sealed = TRUE) +stopifnot(isSealedClass("foo")) +tools::assertError(setClass("foo")) +stopifnot(removeClass("foo")) +setClass("foo") +sealClass("foo") # failed in R < 4.5.0 +stopifnot(isSealedClass("foo")) +stopifnot(removeClass("foo")) + + +## show() should recommend backticks for showMethods() +stopifnot(any(grepl("showMethods(`body<-`)", capture.output(show(`body<-`)), fixed=TRUE))) + +## show( ) should use correct " Use showMethods(.....) for ...." +pkg <- "Matrix" +if(length(P <- grep(pkg, search(), fixed=TRUE, value=TRUE))) + detach(P, character.only=TRUE, force=TRUE) +(hasME <- requireNamespace(pkg, quietly=TRUE, lib.loc = .Library)) +if(hasME) { + capture.output( show(Matrix::"diag<-") ) |> tail(1) -> out1 + stopifnot(grepl("showMethods(Matrix::`diag<-`)", out1, fixed=TRUE)) + ## + if(require(pkg, character.only=TRUE)) { + capture.output( show(Matrix::"diag<-") ) |> tail(1) -> out1 + stopifnot(grepl("showMethods(`diag<-`)", out1, fixed=TRUE)) + detach(paste0("package:", pkg), character.only=TRUE, unload=TRUE) + } else + unloadNamespace(pkg) +} + + + +cat('Time elapsed: ', proc.time(),'\n') diff --git a/tests/reg-S4.R b/tests/reg-S4.R index 46d03997dee..86887ea822f 100644 --- a/tests/reg-S4.R +++ b/tests/reg-S4.R @@ -879,16 +879,11 @@ setClass("bar", contains = "foo") body(getClass("bar")@contains[[1]]@coerce)[[2]] -## PR#17496: sealClass() -setClass("foo", slots = c(name = "character"), sealed = TRUE) -stopifnot(isSealedClass("foo")) -tools::assertError(setClass("foo")) -stopifnot(removeClass("foo")) -setClass("foo") -sealClass("foo") # failed in R < 4.5.0 -stopifnot(isSealedClass("foo")) -stopifnot(removeClass("foo")) +## ----- from here on, keep at EOF ----- + +cat('Time elapsed: ', proc.time(),'\n') -## show() should recommend backticks for showMethods() -stopifnot(any(grepl("showMethods(`body<-`)", capture.output(show(`body<-`)), fixed=TRUE))) +### NB: Only add new tests here _IF_ checking output, +### -- otherwise use ./classes-methods.R +### ^^^^^^^^^^^^^^^^^ diff --git a/tests/reg-S4.Rout.save b/tests/reg-S4.Rout.save index e665ed7b4ca..9b2cec7e58b 100644 --- a/tests/reg-S4.Rout.save +++ b/tests/reg-S4.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2024-05-13 r86546) -- "Unsuffered Consequences" +R Under development (unstable) (2024-08-27 r87063) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu @@ -1177,17 +1177,13 @@ value <- methods::new("A") class(from) <- "foo" > > -> ## PR#17496: sealClass() -> setClass("foo", slots = c(name = "character"), sealed = TRUE) -> stopifnot(isSealedClass("foo")) -> tools::assertError(setClass("foo")) -> stopifnot(removeClass("foo")) -> setClass("foo") -> sealClass("foo") # failed in R < 4.5.0 -> stopifnot(isSealedClass("foo")) -> stopifnot(removeClass("foo")) > +> ## ----- from here on, keep at EOF ----- +> +> cat('Time elapsed: ', proc.time(),'\n') +Time elapsed: 0.869 0.169 1.642 0.001 0.003 > -> ## show() should recommend backticks for showMethods() -> stopifnot(any(grepl("showMethods(`body<-`)", capture.output(show(`body<-`)), fixed=TRUE))) +> ### NB: Only add new tests here _IF_ checking output, +> ### -- otherwise use ./classes-methods.R +> ### ^^^^^^^^^^^^^^^^^ > From 719b3c87a31f2b42aa3ec5d36ef373a81a1cf99a Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 30 Aug 2024 14:13:49 +0000 Subject: [PATCH 536/546] get() now signals error of class "GetMissingError" git-svn-id: https://svn.r-project.org/R/trunk@87080 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 6 ++++-- src/library/base/man/get.Rd | 16 +++++++++++++++- src/library/utils/R/str.R | 18 ++---------------- src/main/envir.c | 10 +++++++--- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 4d63d8b253b..ce15c1a7f25 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -79,6 +79,8 @@ to \PR{16567}. \item \code{pnorm(x)} underflows more gracefully. + + \item \code{get(nam, env)} now signals a \emph{classed} error (\code{"getMissingError"}) } } @@ -258,8 +260,8 @@ on some platforms, warns about \emph{some} failures to change the language and gets an option related to these warning messages. - \item Printing \code{ls.str()} now tries harder to show - \code{""} even when \R's language setting is not English. + \item Printing \code{ls.str()} now shows \code{""} even when + \R's language setting is not English. } } } diff --git a/src/library/base/man/get.Rd b/src/library/base/man/get.Rd index a9cb0aa83be..c28543f36ec 100644 --- a/src/library/base/man/get.Rd +++ b/src/library/base/man/get.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/get.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2023 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{get} @@ -82,6 +82,9 @@ dynGet(x, ifnotfound = , minframe = 1L, inherits = FALSE) } \value{ For \code{get}, the object found. If no object is found an error results. + If the object is the internal missing argument (aka \code{R_MissingArg} + in C), a \emph{classed} error, class \code{"getMissingError"} is + signalled. For \code{mget}, a named list of objects (found or specified \emph{via} \code{ifnotfound}). @@ -116,5 +119,16 @@ get("\%o\%") ## test mget e1 <- new.env() mget(letters, e1, ifnotfound = as.list(LETTERS)) + +## very low-level: get()ing the "missing argument", e.g., inside browser() +ls.str(E <- environment((\(m) \(){})())) # m : +str(E$m) # (empty) symbol +tryCatch(get("m",E), error = function(e) e) # +stopifnot(exprs = { + inherits(tryCatch(get ("m", E), error=identity), "getMissingError") + inherits(tryCatch(get0("m", E), error=identity), "getMissingError") + is.symbol(E$m) # => valid argument to get(), and *also* gets 'missing arg': + inherits(tryCatch(get ( E$m ) , error=identity), "getMissingError") +}) } \keyword{data} diff --git a/src/library/utils/R/str.R b/src/library/utils/R/str.R index 499f4f4ad0e..b63d03cd44d 100644 --- a/src/library/utils/R/str.R +++ b/src/library/utils/R/str.R @@ -696,28 +696,14 @@ print.ls_str <- function(x, max.level = 1, give.attr = FALSE, strargs <- c(list(max.level = max.level, give.attr = give.attr, digits.d = digits), args) n. <- substr(tempfile("ls_str_", tmpdir=""), 2L, 20L) - if(is.na(L <- Sys.getenv("LANGUAGE", unset=NA)) || L != "en") { - Sys.setLanguage("en", C.vs.en="silent") # for "" to work below - on.exit(if(is.na(L)) Sys.unsetenv("LANGUAGE") else Sys.setenv(LANGUAGE = L)) - } for(nam in x) { cat(nam, ": ") ## check missingness, e.g. inside debug(.) : - -##__ Why does this give too many in some case? -##__ if(eval(substitute(missing(.), list(. = as.name(nam))), -##__ envir = E)) -##__ cat("\n") -##__ else -##__ str(get(nam, envir = E, mode = M), -##__ max.level = max.level, give.attr = give.attr, ...) - - ## FIXME: get() should rather return a *classed* error in this case - eA <- sprintf("%s:%s", nam, n.) + eA <- sprintf("%s:%s", nam, n.) # need a 'mark' in case nam *is* an error object o <- tryCatch(get(nam, envir = E, mode = M), error = function(e){ attr(e, eA) <- TRUE; e }) if(inherits(o, "error") && isTRUE(attr(o, eA))) { - cat(if(grepl("missing|not found", o$message)) "" else o$message, + cat(if(inherits(o, "getMissingError")) "" else o$message, "\n", sep = "") } else { diff --git a/src/main/envir.c b/src/main/envir.c index 2ae4d417f73..4331a23f69a 100644 --- a/src/main/envir.c +++ b/src/main/envir.c @@ -2138,9 +2138,13 @@ attribute_hidden SEXP do_get(SEXP call, SEXP op, SEXP args, SEXP rho) /* Search for the object */ rval = findVar1mode(t1, genv, gmode, wants_S4, ginherits, PRIMVAL(op)); - if (rval == R_MissingArg) - error(_("argument \"%s\" is missing, with no default"), - CHAR(PRINTNAME(t1))); + if (rval == R_MissingArg) { // signal a *classed* error: + SEXP cond = R_makeErrorCondition(call, "getMissingError", NULL, 0, + _("argument \"%s\" is missing, with no default"), CHAR(PRINTNAME(t1))); + PROTECT(cond); + R_signalErrorCondition(cond, call); + UNPROTECT(1); /* cond; not reached */ + } switch (PRIMVAL(op) ) { case 0: // exists(.) : From d3bfbfeeaa035fa47dc023c79cfe49921cd1d8de Mon Sep 17 00:00:00 2001 From: maechler Date: Fri, 30 Aug 2024 14:17:27 +0000 Subject: [PATCH 537/546] Sys.setLanguage(): tweak "C" case git-svn-id: https://svn.r-project.org/R/trunk@87081 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/stop.R | 11 +++++++---- src/library/base/man/locales.Rd | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/library/base/R/stop.R b/src/library/base/R/stop.R index b8f79bac540..c67416541c5 100644 --- a/src/library/base/R/stop.R +++ b/src/library/base/R/stop.R @@ -144,13 +144,16 @@ Sys.setLanguage <- function(lang, unset = "en", C.vs.en = c("msg", "warn", "sile warn = warning) else warning if(identical("C", Sys.getlocale()) && lang != "C") { ## e.g. LC_ALL=C R on Linux - lcSet <- if(.Platform[["OS.type"]] == "unix") - Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") - ## TODOs: 1) does en_US.UTF-8 always exist? + lcSet <- if(.Platform[["OS.type"]] == "unix") # works to "undo LC_ALL=C" + paste0(collapse="", vapply(c("LC_ALL", "LC_MESSAGES"), + \(a) Sys.setlocale(a, "en_US.UTF-8"), "")) + ## TODOs: 1) we assume en_US.UTF-8 exists on all "unix" ## 2) How to deal w/ Windows ? {can set things but with *no* effect} ok.lc <- !is.null(lcSet) && nzchar(lcSet) # NULL or "" are not ok if(!ok.lc) - Warning(gettextf("In a bare C locale, could not change language"), domain=NA) + Warning(gettextf( + "In bare C locale: LANGUAGE reset, but message language may be unchanged"), + domain=NA) } else ok.lc <- TRUE ok <- Sys.setenv(LANGUAGE=lang) if(!ok) diff --git a/src/library/base/man/locales.Rd b/src/library/base/man/locales.Rd index ceeb8fad373..b0267d394be 100644 --- a/src/library/base/man/locales.Rd +++ b/src/library/base/man/locales.Rd @@ -195,15 +195,15 @@ Sys.setenv("LANGUAGE" = "es") # set the language for error/warning messages sep <- switch(Sys.info()[["sysname"]], "Darwin"=, "SunOS" = "/", "Linux" =, "Windows" = ";") - ##' show a "full" Sys.getlocale() nicely: - showL <- function(loc) { + ##' named vector from a "full" Sys.getlocale() : + asNvec <- function(loc) { sl <- strsplit(strsplit(loc, sep)[[1L]], "=") - if(all(sapply(sl, length) == 2L)) + if(all(lengths(sl) == 2L)) setNames(sapply(sl, `[[`, 2L), sapply(sl, `[[`, 1L)) else setNames(as.character(sl), .LC.categories[1+seq_along(sl)]) } - print.Dlist(lloc <- showL(Sys.getlocale())) + print.Dlist(lloc <- asNvec(Sys.getlocale())) ## R-supported ones (but LC_ALL): lloc[.LC.categories[-1]] } From 0e1629a4224a1b5a2589859182b1d535da53d97d Mon Sep 17 00:00:00 2001 From: maechler Date: Sat, 31 Aug 2024 16:07:34 +0000 Subject: [PATCH 538/546] use MISSING_ARGUMENT_ERROR() in one more case git-svn-id: https://svn.r-project.org/R/trunk@87082 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/eval.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/eval.c b/src/main/eval.c index d718b989b08..524a7b8bc94 100644 --- a/src/main/eval.c +++ b/src/main/eval.c @@ -1078,6 +1078,8 @@ static void handle_eval_depth_overflow(void) /* Return value of "e" evaluated in "rho". */ +static void MISSING_ARGUMENT_ERROR(SEXP symbol, SEXP rho); + /* some places, e.g. deparse2buff, call this with a promise and rho = NULL */ SEXP eval(SEXP e, SEXP rho) { @@ -1181,12 +1183,7 @@ SEXP eval(SEXP e, SEXP rho) /* the error signaled here for a missing ..d matches the one signaled in getvar() for byte compiled code, but ...elt() signals a slightly different error (see PR18661) */ - const char *n = CHAR(PRINTNAME(e)); - if(*n) errorcall(getLexicalCall(rho), - _("argument \"%s\" is missing, with no default"), - CHAR(PRINTNAME(e))); - else errorcall(getLexicalCall(rho), - _("argument is missing, with no default")); + MISSING_ARGUMENT_ERROR(e, rho); } else if (TYPEOF(tmp) == PROMSXP) { ENSURE_PROMISE_IS_EVALUATED(tmp); @@ -3060,7 +3057,6 @@ static Rboolean checkTailPosition(SEXP call, SEXP code, SEXP rho) else return FALSE; } -static void MISSING_ARGUMENT_ERROR(SEXP symbol, SEXP rho); attribute_hidden SEXP do_tailcall(SEXP call, SEXP op, SEXP args, SEXP rho) { #ifdef SUPPORT_TAILCALL From 982288a5640ba584ff0d7e6ba85bf566a4184686 Mon Sep 17 00:00:00 2001 From: hornik Date: Sun, 1 Sep 2024 08:13:49 +0000 Subject: [PATCH 539/546] Avoid as.vector() trafo for same-kind apparently vector-like operands. git-svn-id: https://svn.r-project.org/R/trunk@87083 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/sets.R | 154 +++++++++++++++++++++-------------- src/library/base/man/sets.Rd | 42 +++++++--- 2 files changed, 126 insertions(+), 70 deletions(-) diff --git a/src/library/base/R/sets.R b/src/library/base/R/sets.R index d7a9644b104..4884f257eeb 100644 --- a/src/library/base/R/sets.R +++ b/src/library/base/R/sets.R @@ -1,7 +1,7 @@ # File src/library/base/R/sets.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2021 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,76 +16,110 @@ # A copy of the GNU General Public License is available at # https://www.R-project.org/Licenses/ -union <- function(x, y) { - u <- as.vector(x) - v <- as.vector(y) - ## - ## Remove eventually: not safe enough for arbitrary classes. - ## if(!is.object(x) || !is.object(y) || - ## !identical(class(x), class(y))) { - ## x <- u - ## y <- v - ## } - ## z <- c(x[!duplicated(unclass(u))], - ## y[!duplicated(unclass(v)) & (match(v, u, 0L) == 0L)]) - ## names(z) <- NULL - ## z - ## - ## Could do - ## c(u[!duplicated(unclass(u))], - ## v[!duplicated(unclass(v)) & (match(v, u, 0L) == 0L)]) - ## but the following is faster and "basically the same": - unique(c(u, v)) +## +## The set ops have always been documented to work for args that are +## "same-kind" (same mode in the unclassed case) and sequences of items, +## i.e., "vector-like". +## In the "same-kind" case we test for vector-like whether subscripting +## no items from x or y retains the class. +## Where needed, we also check whether duplicated() on x or y has the +## same length as x or y: for consistency this could always be done, at +## a possible loss of efficiency where not needed. +## + +union <- +function(x, y) +{ + if(is.null(x)) return(y) + if(is.null(y)) return(x) + cx <- class(x) + cy <- class(y) + if((isa(x, cy) || isa(y, cx)) && + identical(class(y0 <- y[integer()]), cy) && + (length(dx <- duplicated(x)) == length(x)) && + (length(dy <- duplicated(y)) == length(y))) { + if(!isa(x, cy)) + x <- c(y0, x) + } else { + x <- as.vector(x) + y <- as.vector(y) + y0 <- y[integer()] + dx <- duplicated(x) + dy <- duplicated(y) + } + x <- x[!dx] + y <- y[!dy & (match(y, x, 0L) == 0L)] + c(x, y) } -intersect <- function(x, y) +intersect <- +function(x, y) { if(is.null(x) || is.null(y)) return(NULL) - u <- as.vector(x) - v <- as.vector(y) - ## - ## Remove eventually: not safe enough for arbitrary classes. - ## if(!is.object(x) || !is.object(y) || - ## !identical(class(x), class(y))) { - ## x <- u - ## y <- v - ## } - ## z <- c(x[!duplicated(unclass(u)) & (match(u, v, 0L) > 0L)], - ## y[numeric()]) - ## ## (Combining with y[numeric()] in the common class case is needed - ## ## e.g. for factors to combine levels.) - ## names(z) <- NULL - ## z - ## - c(u[!duplicated(unclass(u)) & (match(u, v, 0L) > 0L)], - v[numeric()]) + cx <- class(x) + cy <- class(y) + if((isa(x, cy) || isa(y, cx)) && + identical(class(y0 <- y[integer()]), cy) && + (length(dx <- duplicated(x)) == length(x))) { + x <- x[!dx] + } else { + x <- as.vector(x) + x <- x[!duplicated(x)] + y <- as.vector(y) + y0 <- y[integer()] + } + ## Combining with y0 in the common class case is needed e.g. for + ## factors to combine levels, and otherwise to get a common mode. + c(x[match(x, y, 0L) > 0L], y0) } -setdiff <- function(x, y) +setdiff <- +function(x, y) { - u <- as.vector(x) - v <- as.vector(y) - ## - ## Remove eventually: not safe enough for arbitrary classes. - ## z <- x[!duplicated(unclass(u)) & (match(u, v, 0L) == 0L)] - ## names(z) <- NULL - ## z - ## - u[!duplicated(unclass(u)) & (match(u, v, 0L) == 0L)] + if(is.null(x) || is.null(y)) + return(x) + cx <- class(x) + cy <- class(y) + if((isa(x, cy) || isa(y, cx)) && + identical(class(x[integer()]), cx) && + (length(dx <- duplicated(x)) == length(x))) { + x <- x[!dx] + } else { + x <- as.vector(x) + x <- x[!duplicated(x)] + y <- as.vector(y) + } + x[match(x, y, 0L) == 0L] } -## speed optimization etc: R-devel, Jan.4-6, 2000; then again 15 yrs later -setequal <- function(x, y) +setequal <- +function(x, y) { - x <- as.vector(x) - y <- as.vector(y) + cx <- class(x) + cy <- class(y) + if(!((isa(x, cy) || isa(y, cx)) && + identical(class(x[integer()]), cx))) { + x <- as.vector(x) + y <- as.vector(y) + } !( anyNA(match(x, y)) || anyNA(match(y, x)) ) } -## same as %in% ( ./match.R ) but different arg names, and use match() -## on as.vector() transformations for consistency with the other set -## functions. -is.element <- function(el, set) - match(as.vector(el), as.vector(set), 0L) > 0L - +## same as %in% ( ./match.R ) but different arg names (and possible +## as.vactor() transformation in the case args are not vector-like +## same-kind. +is.element <- +function(el, set) +{ + x <- el + y <- set + cx <- class(x) + cy <- class(y) + if(!((isa(x, cy) || isa(y, cx)) && + identical(class(x[integer()]), cx))) { + x <- as.vector(x) + y <- as.vector(y) + } + match(x, y, 0L) > 0L +} diff --git a/src/library/base/man/sets.Rd b/src/library/base/man/sets.Rd index 4afb3822e96..4229e8000f1 100644 --- a/src/library/base/man/sets.Rd +++ b/src/library/base/man/sets.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/sets.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{sets} @@ -32,20 +32,33 @@ is.element(el, set) equality and membership on two vectors. } \details{ - Each of \code{union}, \code{intersect}, \code{setdiff} and - \code{setequal} will discard any duplicated values in the arguments, - and they apply \code{\link{as.vector}} to their arguments (and so - in particular coerce factors to character vectors). + The set operations are intended for \dQuote{same-kind} + \dQuote{vector-like} objects containing sequences of items. However, + being \dQuote{vector-like} cannot easily be ascertained (in particular + as \code{\link{is.vector}()} enforces a very narrow concept of + \dQuote{vector}). - \code{is.element(x, y)} is identical to \code{x \%in\% y}. + Thus, for \R < 4.5.0, the set operands were always transformed via + \code{\link{as.vector}()} (so that in particular, factors were coerced + to character vectors). Starting with \R 4.5.0, operands of the + \dQuote{same kind} (in the sense that \code{\link{isa}(x, class(y))} + or \code{\link{isa}(y, class(x))} which appear to be + \dQuote{vector-like} (in the sense that subscripting \code{x} and/or + \code{y} by \code{integer()} leaves the class unchanged) are no longer + transformed. In particular, union, intersection and set difference + of two factors now give factors (see the examples). + + \code{is.element(x, y)} is identical to \code{x \%in\% y} (after + possibly transforming via \code{\link{as.vector}()}). } \value{ - For \code{union}, a vector of a common mode. + For \code{union}, a vector of a common mode or class. - For \code{intersect}, a vector of a common mode, or \code{NULL} if - \code{x} or \code{y} is \code{NULL}. + For \code{intersect}, a vector of a common mode or class, or + \code{NULL} if \code{x} or \code{y} is \code{NULL}. - For \code{setdiff}, a vector of the same \code{\link{mode}} as \code{x}. + For \code{setdiff}, a vector of the same \code{\link{mode}} or class + as \code{x}. A logical scalar for \code{setequal} and a logical of the same length as \code{x} for \code{is.element}. @@ -72,5 +85,14 @@ setequal( union(x, y), is.element(x, y) # length 10 is.element(y, x) # length 8 + +## Factors: +x <- as.factor(c("A", "B", "A")) +y <- as.factor(c("B", "b")) +union(x, y) +intersect(x, y) +setdiff(x, y) +setdiff(y, x) +## (Note that union() and intersect() merge the levels.) } \keyword{misc} From fa691d7b3da7bf0a3bd5b0daf92e18fd049b48da Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 2 Sep 2024 12:03:24 +0000 Subject: [PATCH 540/546] Report result code for each URL when downloading files simultaneously via download.file(). Limit the number of concurrently open files and concurrent downloads. git-svn-id: https://svn.r-project.org/R/trunk@87084 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/man/download.file.Rd | 9 +- src/modules/internet/libcurl.c | 445 +++++++++++++++++-------- 2 files changed, 305 insertions(+), 149 deletions(-) diff --git a/src/library/utils/man/download.file.Rd b/src/library/utils/man/download.file.Rd index f65814f67b3..c367171bebd 100644 --- a/src/library/utils/man/download.file.Rd +++ b/src/library/utils/man/download.file.Rd @@ -1,6 +1,6 @@ % File src/library/utils/man/download.file.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2022 R Core Team +% Copyright 1995-2024 R Core Team % Distributed under GPL 2 or later \name{download.file} @@ -274,7 +274,12 @@ download.file(url, destfile, method, quiet = FALSE, mode = "w", An (invisible) integer code, \code{0} for success and non-zero for failure. For the \code{"wget"} and \code{"curl"} methods this is the status code returned by the external program. The \code{"internal"} - method can return \code{1}, but will in most cases throw an error. + method can return \code{1}, but will in most cases throw an error. When + simultaneously downloading two or more files (see the \code{url} argument) + and download of at least one file succeeds, \code{0} is returned with + attribute \code{retvals}, which provides an integer vector of the same + length as \code{url} with a result code for each file (\code{0} for + success and non-zero for failure). What happens to the destination file(s) in the case of error depends on the method and \R{} version. Currently the \code{"internal"}, diff --git a/src/modules/internet/libcurl.c b/src/modules/internet/libcurl.c index e84b9ccd39a..d8c6cbba03c 100644 --- a/src/modules/internet/libcurl.c +++ b/src/modules/internet/libcurl.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2015-2023 The R Core Team + * Copyright (C) 2015-2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -188,6 +188,40 @@ static const char *ftp_errstr(const long status) return str; } +/* Report a download error based on libcurl message. Issue warnings and + record a flag (see errs[] in in_do_curlDownload) when errs[] is used. */ +static void download_report_url_error(CURLMsg *msg) +{ + const char *url, *strerr, *type; + long status = 0; + int *url_errs = NULL; + curl_easy_getinfo(msg->easy_handle, CURLINFO_EFFECTIVE_URL, &url); + curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, + &status); + if (curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &url_errs) + == CURLE_OK && url_errs) (*url_errs)++; + + // This reports the redirected URL + if (status >= 400) { + if (url && url[0] == 'h') { + strerr = http_errstr(status); + type = "HTTP"; + } else { + strerr = ftp_errstr(status); + type = "FTP"; + } + warning(_("cannot open URL '%s': %s status was '%ld %s'"), + url, type, status, strerr); + } else { + strerr = curl_easy_strerror(msg->data.result); + if (streql(strerr, "Timeout was reached")) + warning(_("URL '%s': Timeout of %d seconds was reached"), + url, current_timeout); + else + warning(_("URL '%s': status was '%s'"), url, strerr); + } +} + /* Check curl_multi_info_read for errors, reporting as warnings @@ -199,30 +233,7 @@ static int curlMultiCheckerrs(CURLM *mhnd) for(int n = 1; n > 0;) { CURLMsg *msg = curl_multi_info_read(mhnd, &n); if (msg && (msg->data.result != CURLE_OK)) { - const char *url, *strerr, *type; - long status = 0; - curl_easy_getinfo(msg->easy_handle, CURLINFO_EFFECTIVE_URL, &url); - curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, - &status); - // This reports the redirected URL - if (status >= 400) { - if (url && url[0] == 'h') { - strerr = http_errstr(status); - type = "HTTP"; - } else { - strerr = ftp_errstr(status); - type = "FTP"; - } - warning(_("cannot open URL '%s': %s status was '%ld %s'"), - url, type, status, strerr); - } else { - strerr = curl_easy_strerror(msg->data.result); - if (streql(strerr, "Timeout was reached")) - warning(_("URL '%s': Timeout of %d seconds was reached"), - url, current_timeout); - else - warning(_("URL '%s': status was '%s'"), url, strerr); - } + download_report_url_error(msg); retval++; } } @@ -322,7 +333,7 @@ rcvBody(void *buffer, size_t size, size_t nmemb, void *userp) // needed to discard spurious ftp 'body' otherwise written to stdout return size * nmemb; } -#endif +#endif /* HAVE_LIBCURL */ static void handle_cleanup(void *data) { @@ -531,40 +542,50 @@ typedef struct { CURL ***hnd; FILE **out; SEXP sfile; + int *errs; #ifdef Win32 winprogressbar *pbar; #endif } download_cleanup_info; -static void download_cleanup(void *data) +/* Clean up URL at given index. Close the file handle, delete file if + obviously wrong, remove the easy handle if present. */ +static void download_cleanup_url(int i, download_cleanup_info *c) { - download_cleanup_info *c = data; - - for (int i = 0; i < c->nurls; i++) { - if (c->out && c->out[i]) { - fclose(c->out[i]); + if (c->out && c->out[i]) { + fclose(c->out[i]); + c->out[i] = NULL; #if LIBCURL_VERSION_NUM >= 0x073700 - curl_off_t dl; - curl_easy_getinfo(c->hnd[i], CURLINFO_SIZE_DOWNLOAD_T, &dl); + curl_off_t dl; + curl_easy_getinfo(c->hnd[i], CURLINFO_SIZE_DOWNLOAD_T, &dl); #else - double dl; - curl_easy_getinfo(c->hnd[i], CURLINFO_SIZE_DOWNLOAD, &dl); + double dl; + curl_easy_getinfo(c->hnd[i], CURLINFO_SIZE_DOWNLOAD, &dl); #endif - if (c->sfile) { - long status = 0L; - curl_easy_getinfo(c->hnd[i], CURLINFO_RESPONSE_CODE, &status); - // should we do something about incomplete transfers? - if (status != 200 && dl == 0.) { - const void *vmax = vmaxget(); - unlink(R_ExpandFileName(translateChar(STRING_ELT(c->sfile, i)))); - vmaxset(vmax); - } + if (c->sfile) { + long status = 0L; + curl_easy_getinfo(c->hnd[i], CURLINFO_RESPONSE_CODE, &status); + // should we do something about incomplete transfers? + if (status != 200 && dl == 0.) { + const void *vmax = vmaxget(); + unlink(R_ExpandFileName(translateChar(STRING_ELT(c->sfile, i)))); + vmaxset(vmax); } - curl_multi_remove_handle(c->mhnd, c->hnd[i]); } - if (c->hnd && c->hnd[i]) - curl_easy_cleanup(c->hnd[i]); + curl_multi_remove_handle(c->mhnd, c->hnd[i]); } + if (c->hnd && c->hnd[i]) { + curl_easy_cleanup(c->hnd[i]); + c->hnd[i] = NULL; + } +} + +static void download_cleanup(void *data) +{ + download_cleanup_info *c = data; + + for (int i = 0; i < c->nurls; i++) + download_cleanup_url(i, c); if (c->mhnd) curl_multi_cleanup(c->mhnd); if (c->headers) @@ -576,6 +597,170 @@ static void download_cleanup(void *data) #endif } +/* Add URL at index i: open file, create easy handle, add to multi-handle. + Report errors (issue warnings, set flags) only when mustWork != 0. + Returns 0 on success. */ +static int download_add_url(int i, SEXP scmd, const char *mode, + int quiet, int single, int mustwork, + download_cleanup_info *c) +{ + const char *url, *file; + const void *vmax = vmaxget(); + + url = translateChar(STRING_ELT(scmd, i)); + c->hnd[i] = curl_easy_init(); + if (!c->hnd[i]) { + if (mustwork) { + c->errs[i]++; + warning(_("could not create curl handle")); + } + vmaxset(vmax); + return 1; + } + curl_easy_setopt(c->hnd[i], CURLOPT_URL, url); + curl_easy_setopt(c->hnd[i], CURLOPT_FAILONERROR, 1L); + /* Users will normally expect to follow redirections, although + that is not the default in either curl or libcurl. */ + curlCommon(c->hnd[i], 1, 1); + // all but Unix-alikes with ancient libcurl (before 2012-03-22) +#if (LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 25) + curl_easy_setopt(c->hnd[i], CURLOPT_TCP_KEEPALIVE, 1L); +#endif + curl_easy_setopt(c->hnd[i], CURLOPT_HTTPHEADER, c->headers); + + /* check that destfile can be written */ + file = translateChar(STRING_ELT(c->sfile, i)); + c->out[i] = R_fopen(R_ExpandFileName(file), mode); + if (!c->out[i]) { + if (mustwork) { + c->errs[i]++; + warning(_("URL %s: cannot open destfile '%s', reason '%s'"), + url, file, strerror(errno)); + } + vmaxset(vmax); + return 1; + } +#ifdef Unix +# if LIBCURL_VERSION_MAJOR < 7 || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR < 28) + if (fileno(c->out[i]) >= FD_SETSIZE) { + fclose(c->out[i]); + c->out[i] = NULL; + if (mustwork) { + c->errs[i]++; + warning(_("file descriptor is too large for select()")); + } + vmaxset(vmax); + return 1; + } +# endif +#endif + // This uses the internal CURLOPT_WRITEFUNCTION + curl_easy_setopt(c->hnd[i], CURLOPT_WRITEDATA, c->out[i]); + curl_multi_add_handle(c->mhnd, c->hnd[i]); + + curl_easy_setopt(c->hnd[i], CURLOPT_PRIVATE, c->errs+i); + + total = 0.; + if (!quiet && single) { + // It would in principle be possible to have + // multiple progress bars on Windows. + curl_easy_setopt(c->hnd[i], CURLOPT_NOPROGRESS, 0L); + ndashes = 0; +#ifdef Win32 + if (R_Interactive) { + if (!pbar.wprog) { + pbar.wprog = newwindow(_("Download progress"), + rect(0, 0, 540, 100), + Titlebar | Centered); + setbackground(pbar.wprog, dialog_bg()); + pbar.l_url = newlabel(" ", rect(10, 15, 520, 25), + AlignCenter); + pbar.pb = newprogressbar(rect(20, 50, 500, 20), + 0, 1024, 1024, 1); + pbar.pc = 0; + } + + settext(pbar.l_url, url); + setprogressbar(pbar.pb, 0); + settext(pbar.wprog, "Download progress"); + show(pbar.wprog); + c->pbar = &pbar; + } +#endif + // For libcurl >= 7.32.0 use CURLOPT_XFERINFOFUNCTION +#if LIBCURL_VERSION_NUM >= 0x072000 + curl_easy_setopt(c->hnd[i], CURLOPT_XFERINFOFUNCTION, progress); + curl_easy_setopt(c->hnd[i], CURLOPT_XFERINFODATA, c->hnd[i]); +#else + curl_easy_setopt(c->hnd[i], CURLOPT_PROGRESSFUNCTION, progress); + curl_easy_setopt(c->hnd[i], CURLOPT_PROGRESSDATA, c->hnd[i]); +#endif + } else curl_easy_setopt(c->hnd[i], CURLOPT_NOPROGRESS, 1L); + + /* This would allow the negotiation of compressed HTTP transfers, + but it is not clear it is always a good idea. + curl_easy_setopt(hnd[i], CURLOPT_ACCEPT_ENCODING, "gzip, deflate"); + */ + + if (!quiet) REprintf(_("trying URL '%s'\n"), url); + vmaxset(vmax); + return 0; +} + +/* Add one URL to the multi-handle, possibly trying multiple URLs in case + of failures. Report any errors. Advance URL index accordingly. */ +static int download_add_one_url(int *i, SEXP scmd, const char *mode, int quiet, + int single, download_cleanup_info *c) +{ + while(*i < c->nurls) { + if (!download_add_url((*i)++, scmd, mode, quiet, single, 1, c)) + return 0; /* success */ + } + return 1; /* failure */ +} + +/* Add at most n URLs to the multi-handle, if possible. Bail out when an URL + cannot be added (do not advance, do not report errors). The idea is that + when an URL cannot be added, it can be due to lack of resources (i.e. + connections), so it makes sense to try later. Advance only when URLs have + been added. */ +static int download_try_add_urls(int *i, int n, SEXP scmd, + const char *mode, int quiet, int single, + download_cleanup_info *c) +{ + int added = 0; + + while(added < n && *i < c->nurls) { + if (!download_add_url(*i, scmd, mode, quiet, single, 0, c)) { + (*i)++; + added++; + } else + break; + } + return added; /* number of added URLs */ +} + +/* For all finished downloads from the multi handle, clean up the easy + handle, close the file, report errors, delete the file if obviously + wrong. */ +static void download_close_finished(download_cleanup_info *c) +{ + for(int n = 1; n > 0;) { + CURLMsg *msg = curl_multi_info_read(c->mhnd, &n); + if (!msg) + break; + + /* compute URL index */ + int *url_errs = NULL; + curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &url_errs); + int i = url_errs - c->errs; + + if (msg->data.result != CURLE_OK) + download_report_url_error(msg); + download_cleanup_url(i, c); + } +} + /* download(url, destfile, quiet, mode, headers, cacheOK) */ SEXP attribute_hidden @@ -587,7 +772,7 @@ in_do_curlDownload(SEXP call, SEXP op, SEXP args, SEXP rho) return R_NilValue; #else SEXP scmd, sfile, smode, sheaders; - const char *url, *file, *mode; + const char *mode; int quiet, cacheOK; struct curl_slist *headers = NULL; const void *vmax = vmaxget(); @@ -598,6 +783,8 @@ in_do_curlDownload(SEXP call, SEXP op, SEXP args, SEXP rho) if (!isString(scmd) || length(scmd) < 1) error(_("invalid '%s' argument"), "url"); int nurls = length(scmd); + int single = (nurls == 1); + const int MAX_CONCURRENT_URLS = 15; #ifdef Win32 /* not used as 7.28 is required */ @@ -630,6 +817,7 @@ in_do_curlDownload(SEXP call, SEXP op, SEXP args, SEXP rho) c.nurls = nurls; c.hnd = NULL; c.out = NULL; + c.errs = NULL; if (strchr(mode, 'w')) c.sfile = sfile; else @@ -674,112 +862,45 @@ in_do_curlDownload(SEXP call, SEXP op, SEXP args, SEXP rho) c.mhnd = mhnd; int still_running, repeats = 0, n_err = 0; + R_CheckStack2((size_t)nurls + * (sizeof(int) + sizeof(FILE *) + sizeof(CURL **))); CURL **hnd[nurls]; FILE *out[nurls]; + int errs[nurls]; for(int i = 0; i < nurls; i++) { hnd[i] = NULL; out[i] = NULL; + errs[i] = 0; } c.hnd = hnd; c.out = out; + c.errs = errs; - for(int i = 0; i < nurls; i++) { - url = translateChar(STRING_ELT(scmd, i)); - hnd[i] = curl_easy_init(); - if (!hnd[i]) { - n_err += 1; - warning(_("could not create curl handle")); - continue; - } - curl_easy_setopt(hnd[i], CURLOPT_URL, url); - curl_easy_setopt(hnd[i], CURLOPT_FAILONERROR, 1L); - /* Users will normally expect to follow redirections, although - that is not the default in either curl or libcurl. */ - curlCommon(hnd[i], 1, 1); - // all but Unix-alikes with ancient libcurl (before 2012-03-22) -#if (LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 25) - curl_easy_setopt(hnd[i], CURLOPT_TCP_KEEPALIVE, 1L); -#endif - curl_easy_setopt(hnd[i], CURLOPT_HTTPHEADER, headers); - - /* check that destfile can be written */ - file = translateChar(STRING_ELT(sfile, i)); - out[i] = R_fopen(R_ExpandFileName(file), mode); - if (!out[i]) { - n_err += 1; - warning(_("URL %s: cannot open destfile '%s', reason '%s'"), - url, file, strerror(errno)); - continue; - } -#ifdef Unix -# if LIBCURL_VERSION_MAJOR < 7 || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR < 28) - if (fileno(out[i]) >= FD_SETSIZE) { - n_err += 1; - fclose(out[i]); - out[i] = NULL; - warning(_("file descriptor is too large for select()")); - continue; - } -# endif -#endif - // This uses the internal CURLOPT_WRITEFUNCTION - curl_easy_setopt(hnd[i], CURLOPT_WRITEDATA, out[i]); - curl_multi_add_handle(mhnd, hnd[i]); - - total = 0.; - if (!quiet && nurls <= 1) { - // It would in principle be possible to have - // multiple progress bars on Windows. - curl_easy_setopt(hnd[i], CURLOPT_NOPROGRESS, 0L); - ndashes = 0; -#ifdef Win32 - if (R_Interactive) { - if (!pbar.wprog) { - pbar.wprog = newwindow(_("Download progress"), - rect(0, 0, 540, 100), - Titlebar | Centered); - setbackground(pbar.wprog, dialog_bg()); - pbar.l_url = newlabel(" ", rect(10, 15, 520, 25), - AlignCenter); - pbar.pb = newprogressbar(rect(20, 50, 500, 20), - 0, 1024, 1024, 1); - pbar.pc = 0; - } - - settext(pbar.l_url, url); - setprogressbar(pbar.pb, 0); - settext(pbar.wprog, "Download progress"); - show(pbar.wprog); - c.pbar = &pbar; - } -#endif - // For libcurl >= 7.32.0 use CURLOPT_XFERINFOFUNCTION -#if LIBCURL_VERSION_NUM >= 0x072000 - curl_easy_setopt(hnd[i], CURLOPT_XFERINFOFUNCTION, progress); - curl_easy_setopt(hnd[i], CURLOPT_XFERINFODATA, hnd[i]); -#else - curl_easy_setopt(hnd[i], CURLOPT_PROGRESSFUNCTION, progress); - curl_easy_setopt(hnd[i], CURLOPT_PROGRESSDATA, hnd[i]); -#endif - } else curl_easy_setopt(hnd[i], CURLOPT_NOPROGRESS, 1L); + int next_url = 0; - /* This would allow the negotiation of compressed HTTP transfers, - but it is not clear it is always a good idea. - curl_easy_setopt(hnd[i], CURLOPT_ACCEPT_ENCODING, "gzip, deflate"); - */ + /* We keep adding URLs to the libcurl multi-handle while the download + is in progress (no more than MAX_CONCURRENT_URLS at a time). We are + not adding more to avoid running out of resources (number of file + handles, FILE streams, etc) and to not hurt performance (too many + parallel writes). - if (!quiet) REprintf(_("trying URL '%s'\n"), url); - } + When no URL is active, at least one must be added to ensure progress. + But if possible we add more (up to MAX_CONCURRENT_URLS) - we do that + only optionally to reduce the risks of failing due to lack of resources. + */ - if (n_err == nurls) { - // no dest files could be opened, so bail out - endcontext(&cntxt); - download_cleanup(&c); - vmaxset(vmax); + if (download_add_one_url(&next_url, scmd, mode, quiet, single, &c)) { + // no dest files could be opened, so bail out + endcontext(&cntxt); + download_cleanup(&c); + vmaxset(vmax); return ScalarInteger(1); } + download_try_add_urls(&next_url, MAX_CONCURRENT_URLS - 1, scmd, + mode, quiet, single, &c); + R_Busy(1); // curl_multi_wait needs curl >= 7.28.0 . curl_multi_perform(mhnd, &still_running); @@ -800,10 +921,23 @@ in_do_curlDownload(SEXP call, SEXP op, SEXP args, SEXP rho) } else repeats = 0; R_ProcessEvents(); curl_multi_perform(mhnd, &still_running); - } while(still_running); + + if (!single) + /* don't do for single URL downloads to preserve special reporting + (below) which needs the easy handle */ + download_close_finished(&c); /* releases resources */ + + if (!still_running) + download_add_one_url(&next_url, scmd, mode, quiet, single, &c); + + download_try_add_urls(&next_url, MAX_CONCURRENT_URLS - still_running - 1, + scmd, mode, quiet, single, &c); + + curl_multi_perform(mhnd, &still_running); + } while(still_running || next_url < nurls); R_Busy(0); #ifdef Win32 - if (R_Interactive && !quiet && nurls<=1) { + if (R_Interactive && !quiet && single) { c.pbar = NULL; hide(pbar.wprog); } else if (total > 0.) { @@ -814,7 +948,7 @@ in_do_curlDownload(SEXP call, SEXP op, SEXP args, SEXP rho) if (total > 0.) REprintf("\n"); if (R_Consolefile) fflush(R_Consolefile); #endif - if (nurls == 1) { + if (single) { long status; curl_easy_getinfo(hnd[0], CURLINFO_RESPONSE_CODE, &status); // new interface in libcurl >= 7.55.0 @@ -843,14 +977,21 @@ in_do_curlDownload(SEXP call, SEXP op, SEXP args, SEXP rho) (double) dl, (double) cl); } - n_err += curlMultiCheckerrs(mhnd); + /* record status of single URL download, because download_close_finished() + cleans up the easy handle */ + long status = 0; + if (single) + curl_easy_getinfo(hnd[0], CURLINFO_RESPONSE_CODE, &status); - if(nurls > 1) { + download_close_finished(&c); /* updates errs */ + + for(int i = 0; i < nurls; i++) + if (errs[i]) n_err++; + + if(!single) { if (n_err == nurls) error(_("cannot download any files")); else if (n_err) warning(_("some files were not downloaded")); } else if(n_err) { - long status = 0L; - curl_easy_getinfo(hnd[0], CURLINFO_RESPONSE_CODE, &status); if (status != 200) error(_("cannot open URL '%s'"), translateChar(STRING_ELT(scmd, 0))); @@ -861,7 +1002,17 @@ in_do_curlDownload(SEXP call, SEXP op, SEXP args, SEXP rho) endcontext(&cntxt); download_cleanup(&c); vmaxset(vmax); - return ScalarInteger(0); + SEXP ans = ScalarInteger(0); + if(nurls > 1) { + PROTECT(ans); + SEXP sretvals = install("retvals"); + SEXP retval = allocVector(INTSXP, nurls); + setAttrib(ans, sretvals, retval); + for(int i = 0; i < nurls; i++) + INTEGER(retval)[i] = errs[i] ? 1 : 0; + UNPROTECT(1); /* ans */ + } + return ans; #endif } From 5557c3e7e2e0ec64743aff64b3b2bee23219e350 Mon Sep 17 00:00:00 2001 From: kalibera Date: Mon, 2 Sep 2024 12:04:52 +0000 Subject: [PATCH 541/546] Use simultaneous download with libcurl download method in download.packages() and install.packages(). git-svn-id: https://svn.r-project.org/R/trunk@87085 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/utils/R/packages.R | 50 +++++++++++++++++++++++++++------ src/library/utils/R/packages2.R | 47 ++++++++++++++++++++++--------- 2 files changed, 76 insertions(+), 21 deletions(-) diff --git a/src/library/utils/R/packages.R b/src/library/utils/R/packages.R index 24ec1ec2f41..9847168d366 100644 --- a/src/library/utils/R/packages.R +++ b/src/library/utils/R/packages.R @@ -1,7 +1,7 @@ # File src/library/utils/R/packages.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2023 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -749,6 +749,11 @@ download.packages <- function(pkgs, destdir, available = NULL, available <- available.packages(contriburl = contriburl, method = method, ...) + if (missing(method) || method == "auto" || method == "libcurl") + bulkdown <- matrix(character(), 0L, 3L) + else + bulkdown <- NULL + retval <- matrix(character(), 0L, 2L) for(p in unique(pkgs)) { @@ -800,17 +805,46 @@ download.packages <- function(pkgs, destdir, available = NULL, url <- paste(repos, fn, sep = "/") destfile <- file.path(destdir, fn) - res <- try(download.file(url, destfile, method, mode = "wb", - ...)) - if(!inherits(res, "try-error") && res == 0L) - retval <- rbind(retval, c(p, destfile)) - else - warning(gettextf("download of package %s failed", sQuote(p)), - domain = NA, immediate. = TRUE) + if (is.null(bulkdown)) { + # serial download + res <- try(download.file(url, destfile, method, mode = "wb", + ...)) + if(!inherits(res, "try-error") && res == 0L) + retval <- rbind(retval, c(p, destfile)) + else + warning(gettextf("download of package %s failed", sQuote(p)), + domain = NA, immediate. = TRUE) + } else + bulkdown <- rbind(bulkdown, c(p, destfile, url)) } } } + if (!is.null(bulkdown) && nrow(bulkdown) > 0) { + # bulk download using libcurl + urls <- bulkdown[,3] + destfiles <- bulkdown[,2] + ps <- bulkdown[,1] + + res <- try(download.file(urls, destfiles, "libcurl", mode = "wb", ...)) + if(!inherits(res, "try-error") && res == 0L) { + if (length(urls) > 1) { + retvals <- attr(res, "retvals") + for(i in seq_along(retvals)) { + if (retvals[i] == 0L) + retval <- rbind(retval, c(ps[i], destfiles[i])) + else + warning(gettextf("download of package %s failed", + sQuote(ps[i])), domain = NA, immediate. = TRUE) + } + } else + retval <- rbind(retval, c(ps, destfiles)) + } else + for(p in ps) + warning(gettextf("download of package %s failed", sQuote(p)), + domain = NA, immediate. = TRUE) + } + retval } diff --git a/src/library/utils/R/packages2.R b/src/library/utils/R/packages2.R index 1d07de27a6e..f0c18caced0 100644 --- a/src/library/utils/R/packages2.R +++ b/src/library/utils/R/packages2.R @@ -1,7 +1,7 @@ # File src/library/utils/R/packages2.R # Part of the R package, https://www.R-project.org # -# Copyright (C) 1995-2023 The R Core Team +# Copyright (C) 1995-2024 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -398,22 +398,43 @@ install.packages <- if(nonlocalrepos) { df <- function(p, destfile, method, ...) download.file(p, destfile, method, mode = "wb", ...) - urls <- pkgs[web] - for (p in unique(urls)) { - this <- pkgs == p - destfile <- file.path(tmpd, basename(p)) - res <- try(df(p, destfile, method, ...)) - if(!inherits(res, "try-error") && res == 0L) - pkgs[this] <- destfile - else { - ## There will be enough notification from the try() - pkgs[this] <- NA + urls <- unique(pkgs[web]) + + if (missing(method) || method == "auto" || method == "libcurl") { + # bulk download using libcurl + destfiles <- file.path(tmpd, basename(urls)) + res <- try(df(urls, destfiles, "libcurl", ...)) + if(!inherits(res, "try-error") && res == 0L) { + if (length(urls) > 1) { + retvals <- attr(res, "retvals") + for(i in seq_along(retvals)) { + this <- pkgs == urls[i] + if (retvals[i] == 0L) + pkgs[this] <- destfiles[i] + else + pkgs[this] <- NA + } + } else + pkgs[web] <- destfiles + } else + pkgs[web] <- NA + } else { + # serial download + for (p in urls) { + this <- pkgs == p + destfile <- file.path(tmpd, basename(p)) + res <- try(df(p, destfile, method, ...)) + if(!inherits(res, "try-error") && res == 0L) + pkgs[this] <- destfile + else { + ## There will be enough notification from the try() + pkgs[this] <- NA + } } - } + } } } - ## Look at type == "both" ## NB it is only safe to use binary packages with a macOS ## build that uses the same R foundation layout as CRAN since From 5beb631f1ef7dd7fd7199e47caf0412a9d82257d Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 2 Sep 2024 12:11:10 +0000 Subject: [PATCH 542/546] Tweaks. git-svn-id: https://svn.r-project.org/R/trunk@87086 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/sets.R | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/library/base/R/sets.R b/src/library/base/R/sets.R index 4884f257eeb..f3d6c31f00b 100644 --- a/src/library/base/R/sets.R +++ b/src/library/base/R/sets.R @@ -40,16 +40,15 @@ function(x, y) (length(dy <- duplicated(y)) == length(y))) { if(!isa(x, cy)) x <- c(y0, x) + x <- x[!dx] + y <- y[!dy] } else { x <- as.vector(x) + x <- x[!duplicated(x)] y <- as.vector(y) - y0 <- y[integer()] - dx <- duplicated(x) - dy <- duplicated(y) + y <- y[!duplicated(y)] } - x <- x[!dx] - y <- y[!dy & (match(y, x, 0L) == 0L)] - c(x, y) + c(x, y[match(y, x, 0L) == 0L]) } intersect <- From 2c6b9ab1c6fcb9f999f613158915a4bd00dc2b2f Mon Sep 17 00:00:00 2001 From: hornik Date: Mon, 2 Sep 2024 12:12:27 +0000 Subject: [PATCH 543/546] asplit() gains a 'drop' argument. git-svn-id: https://svn.r-project.org/R/trunk@87087 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/array.R | 9 +++++++-- src/library/base/R/duplicated.R | 6 +++--- src/library/base/man/asplit.Rd | 7 +++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/library/base/R/array.R b/src/library/base/R/array.R index c0d2ea6fb83..8e862140345 100644 --- a/src/library/base/R/array.R +++ b/src/library/base/R/array.R @@ -111,7 +111,7 @@ function(x, sep = "", base = list(LETTERS), unique = TRUE) ## (With 'X' replaced by 'x'). asplit <- -function(x, MARGIN) +function(x, MARGIN, drop = FALSE) { ## Ensure that x is an array object dl <- length(dim(x)) @@ -146,7 +146,12 @@ function(x, MARGIN) d2 <- prod(d.ans) newx <- aperm(x, c(s.call, s.ans)) dim(newx) <- c(prod(d.call), d2) - ans <- lapply(seq_len(d2), function(i) array(newx[,i], d.call, dn.call)) + ans <- if(drop) + lapply(seq_len(d2), + function(i) newx[, i]) + else + lapply(seq_len(d2), + function(i) array(newx[,i], d.call, dn.call)) array(ans, d.ans, dn.ans) } diff --git a/src/library/base/R/duplicated.R b/src/library/base/R/duplicated.R index 70c7ece9e53..2a1d54df421 100644 --- a/src/library/base/R/duplicated.R +++ b/src/library/base/R/duplicated.R @@ -57,7 +57,7 @@ function(x, incomparables = FALSE, MARGIN = 1L, fromLast = FALSE, ...) paste(dx, collapse = ",")), domain = NA) temp <- if((ndim > 1L) && (prod(dx[-MARGIN]) > 1L)) - asplit(x, MARGIN) + asplit(x, MARGIN, TRUE) else x res <- duplicated.default(temp, fromLast = fromLast, ...) dim(res) <- dim(temp) @@ -96,7 +96,7 @@ function(x, incomparables = FALSE, MARGIN = 1L, fromLast = FALSE, ...) paste(dx, collapse = ",")), domain = NA) temp <- if((ndim > 1L) && (prod(dx[-MARGIN]) > 1L)) - asplit(x, MARGIN) + asplit(x, MARGIN, TRUE) else x anyDuplicated.default(temp, fromLast = fromLast) } @@ -147,7 +147,7 @@ function(x, incomparables = FALSE, MARGIN = 1, fromLast = FALSE, ...) paste(dx, collapse = ",")), domain = NA) temp <- if((ndim > 1L) && (prod(dx[-MARGIN]) > 1L)) - asplit(x, MARGIN) + asplit(x, MARGIN, TRUE) else x args <- rep(alist(a=), ndim) names(args) <- NULL diff --git a/src/library/base/man/asplit.Rd b/src/library/base/man/asplit.Rd index 40477d200e7..4f15aa961c5 100644 --- a/src/library/base/man/asplit.Rd +++ b/src/library/base/man/asplit.Rd @@ -3,7 +3,7 @@ \title{Split Array/Matrix By Its Margins} \description{Split an array or matrix by its margins.} \usage{ -asplit(x, MARGIN) +asplit(x, MARGIN, drop = FALSE) } \arguments{ \item{x}{an array, including a matrix.} @@ -12,10 +12,13 @@ asplit(x, MARGIN) columns, \code{c(1, 2)} indicates rows and columns. Where \code{x} has named dimnames, it can be a character vector selecting dimension names.} + \item{drop}{a logical indicating whether the splits should drop + dimensions and dimnames.} } \value{ A \dQuote{list array} with dimension \eqn{dv} and each element an - array of dimension \eqn{de} and dimnames preserved as available, where + array of dimension \eqn{de} and dimnames preserved as available if + \code{drop} is false and a vector otherwise, where \eqn{dv} and \eqn{de} are, respectively, the dimensions of \code{x} included and not included in \code{MARGIN}. } From 46531d6fdb66a61cafb0efad3373ae1dc84a7d13 Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 2 Sep 2024 13:15:01 +0000 Subject: [PATCH 544/546] Sys.setLanguage() in "C" case: change locale only when force=TRUE git-svn-id: https://svn.r-project.org/R/trunk@87088 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/base/R/stop.R | 11 +++++++++-- src/library/base/man/gettext.Rd | 8 +++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/library/base/R/stop.R b/src/library/base/R/stop.R index c67416541c5..a576f519fbe 100644 --- a/src/library/base/R/stop.R +++ b/src/library/base/R/stop.R @@ -126,7 +126,8 @@ gettextf <- function(fmt, ..., domain = NULL, trim = TRUE) ## Could think of using *several* domains, i.e. domain = vector; but seems complicated; ## the default domain="R" seems to work for all of base R: {"R", "R-base", "RGui"} -Sys.setLanguage <- function(lang, unset = "en", C.vs.en = c("msg", "warn", "silent")) +Sys.setLanguage <- function(lang, unset = "en", + C.vs.en = c("msg", "warn", "silent"), force = FALSE) { stopifnot(is.character(lang), length(lang) == 1L, # e.g., "es" , "fr_CA" lang == "C" || grepl("^[a-z][a-z]", lang)) @@ -144,6 +145,7 @@ Sys.setLanguage <- function(lang, unset = "en", C.vs.en = c("msg", "warn", "sile warn = warning) else warning if(identical("C", Sys.getlocale()) && lang != "C") { ## e.g. LC_ALL=C R on Linux + if(force) { lcSet <- if(.Platform[["OS.type"]] == "unix") # works to "undo LC_ALL=C" paste0(collapse="", vapply(c("LC_ALL", "LC_MESSAGES"), \(a) Sys.setlocale(a, "en_US.UTF-8"), "")) @@ -154,10 +156,15 @@ Sys.setLanguage <- function(lang, unset = "en", C.vs.en = c("msg", "warn", "sile Warning(gettextf( "In bare C locale: LANGUAGE reset, but message language may be unchanged"), domain=NA) + } else { # !force (default) : + Warning(gettextf("In bare C locale, not forcing locale; possibly use 'force = TRUE'?"), + domain=NA) + return(invisible(structure(curLang, ok = FALSE))) + } } else ok.lc <- TRUE ok <- Sys.setenv(LANGUAGE=lang) if(!ok) - Warning(gettextf('Sys.setenv(LANGUAGE="%s") may have failed', lang), domain=NA) + warning(gettextf('Sys.setenv(LANGUAGE="%s") may have failed', lang), domain=NA) ok. <- capabilities("NLS") && isTRUE(bindtextdomain(NULL)) # only flush the cache (of already translated strings) invisible(structure(curLang, ok = ok && ok.lc && ok.)) diff --git a/src/library/base/man/gettext.Rd b/src/library/base/man/gettext.Rd index 78a6cac05c0..f91ecbc1008 100644 --- a/src/library/base/man/gettext.Rd +++ b/src/library/base/man/gettext.Rd @@ -27,7 +27,8 @@ ngettext(n, msg1, msg2, domain = NULL) bindtextdomain(domain, dirname = NULL) -Sys.setLanguage(lang, unset = "en", C.vs.en = c("msg", "warn", "silent")) +Sys.setLanguage(lang, unset = "en", C.vs.en = c("msg", "warn", "silent"), + force = FALSE) } \arguments{ \item{\dots}{one or more character vectors.} @@ -51,6 +52,11 @@ Sys.setLanguage(lang, unset = "en", C.vs.en = c("msg", "warn", "silent")) When \code{"silent"}, nothing happens, when \code{"msg"}, a \code{\link{message}()} and if \code{"warn"} a \code{\link{warning}()} is signalled.} + \item{force}{logical indicating if in case of a \dQuote{hard} set + \code{"C"} locale, \code{Sys.setLanguage()} should try modifying the + locale (to \code{"en"}) in order to subsequently set the desired language + \code{lang}, currently only when \code{\link{.Platform}[["OS.type"]]} + is \code{"unix"}.} } \details{ If \code{domain} is \code{NULL} (the default) in \code{gettext} From f27dad49446a207218d0c920213cef460ef072f9 Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 2 Sep 2024 13:49:41 +0000 Subject: [PATCH 545/546] =?UTF-8?q?.getMethodsTable():=20get0()=20instead?= =?UTF-8?q?=20of=20exists()+get()=20\\=20=20typo=20thanks=20to=20Rodolphe?= =?UTF-8?q?=20Dug=C3=A9=20de=20B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.r-project.org/R/trunk@87089 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/methods/R/methodsTable.R | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/library/methods/R/methodsTable.R b/src/library/methods/R/methodsTable.R index 9260eb3473a..3947f359846 100644 --- a/src/library/methods/R/methodsTable.R +++ b/src/library/methods/R/methodsTable.R @@ -173,7 +173,7 @@ if(is.environment(current)) { if(is.environment(obj)) list2env(as.list(obj, all.names=TRUE), current) - else if(is(obj, "MethdodDefinition")) { + else if(is(obj, "MethodDefinition")) { var <- .pkgMethodLabel(obj) if(nzchar(var)) assign(var, obj, envir = current) } @@ -1159,12 +1159,14 @@ useMTable <- function(onOff = NA) check = TRUE, inherited = FALSE) { name <- if(inherited) ".AllMTable" else ".MTable" - if(check && !exists(name, envir = env, inherits = FALSE)) { - .setupMethodsTables(fdef, initialize = TRUE) - if(!exists(name, envir = env, inherits = FALSE)) - stop("invalid methods table request") + if(check) { + get0(name, envir = env, inherits = FALSE) %||% { + .setupMethodsTables(fdef, initialize = TRUE) + get0(name, envir = env, inherits = FALSE) %||% stop("invalid methods table request") + } } - get(name, envir = env) + else + get(name, envir = env) } .getGenericSigLength <- function(fdef, env = environment(fdef), check = TRUE) { From 4778112deccaf909e93a0bec77d6c5ccd0e9155f Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 2 Sep 2024 14:18:51 +0000 Subject: [PATCH 546/546] modif.87080: class: "missingArgError", subclass: "getMissingError" git-svn-id: https://svn.r-project.org/R/trunk@87090 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/main/envir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/envir.c b/src/main/envir.c index 4331a23f69a..bbb387ded54 100644 --- a/src/main/envir.c +++ b/src/main/envir.c @@ -2139,7 +2139,7 @@ attribute_hidden SEXP do_get(SEXP call, SEXP op, SEXP args, SEXP rho) /* Search for the object */ rval = findVar1mode(t1, genv, gmode, wants_S4, ginherits, PRIMVAL(op)); if (rval == R_MissingArg) { // signal a *classed* error: - SEXP cond = R_makeErrorCondition(call, "getMissingError", NULL, 0, + SEXP cond = R_makeErrorCondition(call, "missingArgError", "getMissingError", 0, _("argument \"%s\" is missing, with no default"), CHAR(PRINTNAME(t1))); PROTECT(cond); R_signalErrorCondition(cond, call);