diff --git a/DESCRIPTION b/DESCRIPTION index 6fbea42..b897fb7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,12 +2,12 @@ Package: yaml Type: Package Title: Methods to Convert R Data to YAML and Back Date: 2023-11-28 -Version: 2.3.8 +Version: 2.3.9 Suggests: RUnit Author: Shawn P Garbett [aut], Jeremy Stephens [aut, cre], Kirill Simonov [aut], Yihui Xie [ctb], Zhuoer Dong [ctb], Hadley Wickham [ctb], Jeffrey Horner [ctb], reikoch [ctb], Will Beasley [ctb], Brendan O'Connor [ctb], Gregory R. Warnes [ctb], - Michael Quinn [ctb], Zhian N. Kamvar [ctb] + Michael Quinn [ctb], Zhian N. Kamvar [ctb], Charlie Gao [ctb] Maintainer: Shawn Garbett License: BSD_3_clause + file LICENSE Description: Implements the 'libyaml' 'YAML' 1.1 parser and emitter diff --git a/VERSION b/VERSION index bc4abe8..5aa7c52 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.3.8 +2.3.9 diff --git a/src/r_emit.c b/src/r_emit.c index 5b52cdd..7c6912d 100644 --- a/src/r_emit.c +++ b/src/r_emit.c @@ -11,6 +11,22 @@ typedef struct { size_t capa; } s_emitter_output; +#if R_VERSION < R_Version(4, 5, 0) + +# define R_ClosureFormals(x) FORMALS(x) +# define R_ClosureBody(x) BODY(x) +# define R_ClosureEnv(x) CLOENV(x) + +static inline 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 + static SEXP Ryaml_deparse_function(SEXP s_obj) { SEXP s_new_obj = NULL, s_call = NULL, s_result = NULL, s_chr = NULL; @@ -20,10 +36,7 @@ static SEXP Ryaml_deparse_function(SEXP s_obj) /* Copy function without any attributes */ if (TYPEOF(s_obj) == CLOSXP) { PROTECT(s_obj); - PROTECT(s_new_obj = allocSExp(CLOSXP)); - SET_FORMALS(s_new_obj, FORMALS(s_obj)); - SET_BODY(s_new_obj, BODY(s_obj)); - SET_CLOENV(s_new_obj, CLOENV(s_obj)); + PROTECT(s_new_obj = R_mkClosure(R_ClosureFormals(s_obj), R_ClosureBody(s_obj), R_ClosureEnv(s_obj))); SET_OBJECT(s_new_obj, OBJECT(s_obj)); UNPROTECT(2); s_obj = s_new_obj; diff --git a/src/r_ext.h b/src/r_ext.h index 040354e..fbba3e4 100644 --- a/src/r_ext.h +++ b/src/r_ext.h @@ -12,6 +12,7 @@ #include #include "R.h" #include "Rdefines.h" +#include "Rversion.h" #include "R_ext/Rdynload.h" #include "R_ext/Parse.h" #include "R_ext/Print.h"