diff --git a/configure b/configure index 96dfc2e0..f7786bde 100755 --- a/configure +++ b/configure @@ -3904,31 +3904,6 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Operating system is $platform" >&5 printf "%s\n" "$as_me: Operating system is $platform" >&6;} -#-------------------------------------------------------------------------------# -# Test R features # -#-------------------------------------------------------------------------------# - -ac_fn_check_decl "$LINENO" "R_getVarEx" "ac_cv_have_decl_R_getVarEx" "#include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_R_getVarEx" = xyes -then : - ac_have_decl=1 -else case e in #( - e) ac_have_decl=0 ;; -esac -fi -printf "%s\n" "#define HAVE_DECL_R_GETVAREX $ac_have_decl" >>confdefs.h -ac_fn_check_decl "$LINENO" "R_NewEnv" "ac_cv_have_decl_R_NewEnv" "#include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_R_NewEnv" = xyes -then : - ac_have_decl=1 -else case e in #( - e) ac_have_decl=0 ;; -esac -fi -printf "%s\n" "#define HAVE_DECL_R_NEWENV $ac_have_decl" >>confdefs.h - #-------------------------------------------------------------------------------# # Prepend compiler/linker variables from nc-config (if enabled) # diff --git a/configure.ac b/configure.ac index 27d01bb1..45e0ec1f 100644 --- a/configure.ac +++ b/configure.ac @@ -105,11 +105,6 @@ AC_CHECK_DECLS([_WIN32], [platform=Unix-alike])]) AC_MSG_NOTICE([Operating system is $platform]) -#-------------------------------------------------------------------------------# -# Test R features # -#-------------------------------------------------------------------------------# - -AC_CHECK_DECLS([R_getVarEx, R_NewEnv], [], [], [#include ]) #-------------------------------------------------------------------------------# # Prepend compiler/linker variables from nc-config (if enabled) # diff --git a/src/config.h.in b/src/config.h.in index 1043629d..4b8f35cf 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -32,14 +32,6 @@ don't. */ #undef HAVE_DECL_NC_PERSIST -/* Define to 1 if you have the declaration of 'R_getVarEx', and to 0 if you - don't. */ -#undef HAVE_DECL_R_GETVAREX - -/* Define to 1 if you have the declaration of 'R_NewEnv', and to 0 if you - don't. */ -#undef HAVE_DECL_R_NEWENV - /* Define to 1 if you have the declaration of '_WIN32', and to 0 if you don't. */ #undef HAVE_DECL__WIN32 diff --git a/src/convert.c b/src/convert.c index 40b237ef..1dbae5c3 100644 --- a/src/convert.c +++ b/src/convert.c @@ -48,6 +48,7 @@ #include #include +#include #include @@ -6884,7 +6885,10 @@ R_nc_char_symbol (char *in, size_t size, char *work) static void R_nc_enum_factor (R_nc_buf *io) { - SEXP levels, env, cmd, symbol, index; + SEXP levels, env, symbol, index; +#if !defined(R_VERSION) || R_VERSION < R_Version(4, 1, 0) + SEXP cmd; +#endif size_t size, nmem, ifac, nfac; char *memname, *memval, *work, *inval; int ncid, imem, imemmax, *out, any_undef; @@ -6903,7 +6907,7 @@ R_nc_enum_factor (R_nc_buf *io) /* Create a hashed environment for value-index pairs. Members inherit PROTECTion from the env. */ -#if defined(HAVE_DECL_R_NEWENV) && (HAVE_DECL_R_NEWENV == 1) +#if defined(R_VERSION) && R_VERSION >= R_Version(4, 1, 0) env = PROTECT(R_NewEnv(R_BaseEnv, TRUE, 0)); #else cmd = PROTECT(lang1 (install ("new.env"))); @@ -6948,7 +6952,7 @@ R_nc_enum_factor (R_nc_buf *io) any_undef = 0; for (ifac=0, inval=io->cbuf; ifac= R_Version(4, 5, 0) index = R_getVarEx(symbol, env, FALSE, R_UnboundValue); #else index = findVar (symbol, env); @@ -6969,7 +6973,11 @@ R_nc_enum_factor (R_nc_buf *io) } /* Allow garbage collection of env and levels */ +#if defined(R_VERSION) && R_VERSION >= R_Version(4, 1, 0) + UNPROTECT(2); +#else UNPROTECT(3); +#endif } diff --git a/tools/convert.m4 b/tools/convert.m4 index 6195125d..7fb6bd4f 100644 --- a/tools/convert.m4 +++ b/tools/convert.m4 @@ -49,6 +49,7 @@ dnl Insert warning into generated C code: #include #include +#include #include @@ -1300,7 +1301,10 @@ R_nc_char_symbol (char *in, size_t size, char *work) static void R_nc_enum_factor (R_nc_buf *io) { - SEXP levels, env, cmd, symbol, index; + SEXP levels, env, symbol, index; +#if !defined(R_VERSION) || R_VERSION < R_Version(4, 1, 0) + SEXP cmd; +#endif size_t size, nmem, ifac, nfac; char *memname, *memval, *work, *inval; int ncid, imem, imemmax, *out, any_undef; @@ -1319,7 +1323,7 @@ R_nc_enum_factor (R_nc_buf *io) /* Create a hashed environment for value-index pairs. Members inherit PROTECTion from the env. */ -#if defined(HAVE_DECL_R_NEWENV) && (HAVE_DECL_R_NEWENV == 1) +#if defined(R_VERSION) && R_VERSION >= R_Version(4, 1, 0) env = PROTECT(R_NewEnv(R_BaseEnv, TRUE, 0)); #else cmd = PROTECT(lang1 (install ("new.env"))); @@ -1364,7 +1368,7 @@ R_nc_enum_factor (R_nc_buf *io) any_undef = 0; for (ifac=0, inval=io->cbuf; ifac= R_Version(4, 5, 0) index = R_getVarEx(symbol, env, FALSE, R_UnboundValue); #else index = findVar (symbol, env); @@ -1385,7 +1389,11 @@ R_nc_enum_factor (R_nc_buf *io) } /* Allow garbage collection of env and levels */ +#if defined(R_VERSION) && R_VERSION >= R_Version(4, 1, 0) + UNPROTECT(2); +#else UNPROTECT(3); +#endif }