Skip to content
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
25 changes: 0 additions & 25 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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 <R.h>
" "$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 <R.h>
" "$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) #
Expand Down
5 changes: 0 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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 <R.h>])

#-------------------------------------------------------------------------------#
# Prepend compiler/linker variables from nc-config (if enabled) #
Expand Down
8 changes: 0 additions & 8 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions src/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

#include <R.h>
#include <Rinternals.h>
#include <Rversion.h>

#include <netcdf.h>

Expand Down Expand Up @@ -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;
Expand All @@ -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")));
Expand Down Expand Up @@ -6948,7 +6952,7 @@ R_nc_enum_factor (R_nc_buf *io)
any_undef = 0;
for (ifac=0, inval=io->cbuf; ifac<nfac; ifac++, inval+=size) {
symbol = PROTECT(R_nc_char_symbol (inval, size, work));
#if defined(HAVE_DECL_R_GETVAREX) && (HAVE_DECL_R_GETVAREX == 1)
#if defined(R_VERSION) && R_VERSION >= R_Version(4, 5, 0)
index = R_getVarEx(symbol, env, FALSE, R_UnboundValue);
#else
index = findVar (symbol, env);
Expand All @@ -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
}


Expand Down
14 changes: 11 additions & 3 deletions tools/convert.m4
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dnl Insert warning into generated C code:

#include <R.h>
#include <Rinternals.h>
#include <Rversion.h>

#include <netcdf.h>

Expand Down Expand Up @@ -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;
Expand All @@ -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")));
Expand Down Expand Up @@ -1364,7 +1368,7 @@ R_nc_enum_factor (R_nc_buf *io)
any_undef = 0;
for (ifac=0, inval=io->cbuf; ifac<nfac; ifac++, inval+=size) {
symbol = PROTECT(R_nc_char_symbol (inval, size, work));
#if defined(HAVE_DECL_R_GETVAREX) && (HAVE_DECL_R_GETVAREX == 1)
#if defined(R_VERSION) && R_VERSION >= R_Version(4, 5, 0)
index = R_getVarEx(symbol, env, FALSE, R_UnboundValue);
#else
index = findVar (symbol, env);
Expand All @@ -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
}


Expand Down
Loading