Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move into compliance with C API changes #1165

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/backports.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ SEXP Rf_installChar(SEXP x) {
return Rf_install(CHAR(x));
}
#endif

#if defined(R_VERSION) && R_VERSION < R_Version(4, 5, 0)
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
6 changes: 5 additions & 1 deletion src/backports.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
#include <Rversion.h>

#if defined(R_VERSION) && R_VERSION < R_Version(3, 2, 0)
SEXP Rf_installChar(SEXP x);
SEXP Rf_installChar(SEXP);
#endif

#if defined(R_VERSION) && R_VERSION < R_Version(4, 5, 0)
SEXP R_mkClosure(SEXP, SEXP, SEXP);
#endif

#endif
6 changes: 2 additions & 4 deletions src/conditions.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define R_NO_REMAP
#include <Rinternals.h>
#include "backports.h"
#include "utils.h"
#include <R_ext/Parse.h>

Expand All @@ -19,10 +20,7 @@ SEXP current_env(void) {
SEXP parsed = PROTECT(R_ParseVector(code, -1, &status, R_NilValue));
SEXP body = VECTOR_ELT(parsed, 0);

SEXP fn = PROTECT(Rf_allocSExp(CLOSXP));
SET_FORMALS(fn, R_NilValue);
SET_BODY(fn, body);
SET_CLOENV(fn, R_BaseEnv);
SEXP fn = PROTECT(R_mkClosure(R_NilValue, body, R_BaseEnv));

call = Rf_lang1(fn);
R_PreserveObject(call);
Expand Down
2 changes: 1 addition & 1 deletion src/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ SEXP pmap_impl(SEXP env,
PROTECT_WITH_INDEX(call, &call_shelter);

bool has_call_names = call_names != R_NilValue;
const SEXP* v_call_names = has_call_names ? STRING_PTR(call_names) : NULL;
const SEXP* v_call_names = has_call_names ? STRING_PTR_RO(call_names) : NULL;
int call_n = INTEGER_ELT(ffi_call_n, 0);

for (int j = call_n - 1; j >= 0; --j) {
Expand Down
2 changes: 1 addition & 1 deletion src/pluck.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ SEXP extract_env(SEXP x, SEXP index_i, int i, bool strict) {
}

SEXP sym = Rf_installChar(index);
SEXP out = Rf_findVarInFrame3(x, sym, TRUE);
SEXP out = Rf_findVarInFrame(x, sym);

if (check_unbound_value(out, index_i, strict)) {
return R_NilValue;
Expand Down
Loading