Skip to content

Commit

Permalink
Merge branch 'master' into fix4784
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Oct 1, 2024
2 parents 21b33c8 + d62aac9 commit 12083a7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 33 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
on:
push:
branches:
- master
branches: [master]
pull_request:
branches:
- master

name: code-quality

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/performance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: atime performance tests

on:
pull_request:
branches:
- '*'
types:
- opened
- reopened
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/rchk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
# under the License.
on:
push:
branches:
- master
branches: [master]
pull_request:

name: 'rchk'
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [master]
pull_request:
branches: [master]

name: test-coverage.yaml

Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ variables:
_R_CHECK_FORCE_SUGGESTS_: "false"
_R_CHECK_NO_STOP_ON_TEST_ERROR_: "true"
_R_CHECK_SYSTEM_CLOCK_: "false" ## https://stackoverflow.com/questions/63613301/r-cmd-check-note-unable-to-verify-current-time
_R_CHECK_TESTS_NLINES_: "0"
TZ: "UTC" ## to avoid 'Failed to create bus connection' from timedatectl via Sys.timezone() on Docker with R 3.4.
## Setting TZ for all GLCI jobs to isolate them from timezone. We could have a new GLCI job to test under
## a non-UTC timezone, although, that's what we do routinely in dev.
Expand Down Expand Up @@ -114,7 +115,6 @@ test-lin-rel:
_R_CHECK_CRAN_INCOMING_: "FALSE"
_R_CHECK_CRAN_INCOMING_REMOTE_: "FALSE"
_R_CHECK_FORCE_SUGGESTS_: "TRUE"
_R_CHECK_TESTS_NLINES_: "0"
OPENBLAS_MAIN_FREE: "1"
script:
- *install-deps
Expand Down
6 changes: 3 additions & 3 deletions R/programming.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ list2lang = function(x) {
stopf("'x' must be a list")
if (is.AsIs(x))
return(rm.AsIs(x))
asis = vapply(x, is.AsIs, FALSE)
char = vapply(x, is.character, FALSE)
asis = vapply_1b(x, is.AsIs)
char = vapply_1b(x, is.character)
to.name = !asis & char
if (any(to.name)) { ## turns "my_name" character scalar into `my_name` symbol, for convenience
if (any(non.scalar.char <- lengths(x[to.name])!=1L)) {
Expand All @@ -24,7 +24,7 @@ list2lang = function(x) {
x[to.name] = lapply(x[to.name], as.name)
}
if (isTRUE(getOption("datatable.enlist", TRUE))) { ## recursively enlist for nested lists, see note section in substitute2 manual
islt = vapply(x, only.list, FALSE) #5057 nested DT that inherits from a list must not be turned into list call
islt = vapply_1b(x, only.list) #5057 nested DT that inherits from a list must not be turned into list call
to.enlist = !asis & islt
if (any(to.enlist)) {
x[to.enlist] = lapply(x[to.enlist], enlist)
Expand Down
40 changes: 20 additions & 20 deletions src/programming.c
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#include "data.table.h"

static void substitute_call_arg_names(SEXP expr, SEXP env) {
R_len_t len = length(expr);
if (len && isLanguage(expr)) { // isLanguage is R's is.call
SEXP arg_names = getAttrib(expr, R_NamesSymbol);
if (!isNull(arg_names)) {
SEXP env_names = getAttrib(env, R_NamesSymbol);
int *imatches = INTEGER(PROTECT(chmatch(arg_names, env_names, 0)));
const SEXP *env_sub = SEXPPTR_RO(env);
SEXP tmp = expr;
for (int i=0; i<length(arg_names); i++, tmp=CDR(tmp)) { // substitute call arg names
if (imatches[i]) {
SEXP sym = env_sub[imatches[i]-1];
if (!isSymbol(sym))
error(_("Attempting to substitute '%s' element with object of type '%s' but it has to be 'symbol' type when substituting name of the call argument, functions 'as.name' and 'I' can be used to work out proper substitution, see ?substitute2 examples."), CHAR(STRING_ELT(arg_names, i)), type2char(TYPEOF(sym)));
SET_TAG(tmp, sym);
}
}
UNPROTECT(1); // chmatch
}
for (SEXP tmp=expr; tmp!=R_NilValue; tmp=CDR(tmp)) { // recursive call to substitute in nested expressions
substitute_call_arg_names(CADR(tmp), env);
if (!length(expr) || !isLanguage(expr))
return; // isLanguage is R's is.call
SEXP arg_names = getAttrib(expr, R_NamesSymbol);
if (!isNull(arg_names)) {
SEXP env_names = getAttrib(env, R_NamesSymbol);
int *imatches = INTEGER(PROTECT(chmatch(arg_names, env_names, 0)));
const SEXP *env_sub = SEXPPTR_RO(env);
SEXP tmp = expr;
for (int i=0; i<length(arg_names); i++, tmp=CDR(tmp)) { // substitute call arg names
if (!imatches[i])
continue;
SEXP sym = env_sub[imatches[i]-1];
if (!isSymbol(sym))
error(_("Attempting to substitute '%s' element with object of type '%s' but it has to be 'symbol' type when substituting name of the call argument, functions 'as.name' and 'I' can be used to work out proper substitution, see ?substitute2 examples."), CHAR(STRING_ELT(arg_names, i)), type2char(TYPEOF(sym)));
SET_TAG(tmp, sym);
}
UNPROTECT(1); // chmatch
}
for (SEXP tmp=expr; tmp!=R_NilValue; tmp=CDR(tmp)) { // recursive call to substitute in nested expressions
substitute_call_arg_names(CADR(tmp), env);
}
}

SEXP substitute_call_arg_namesR(SEXP expr, SEXP env) {
SEXP ans = PROTECT(MAYBE_REFERENCED(expr) ? duplicate(expr) : expr);
substitute_call_arg_names(ans, env); // updates in-place
Expand Down

0 comments on commit 12083a7

Please sign in to comment.