Skip to content

Commit 72cbd17

Browse files
committed
Drop direct use of LEVELS in R >= 4.5
There's no explicit encoding code for ASCII, so use charIsASCII() ("eapi", expected to appear in R-4.5.0).
1 parent a524d14 commit 72cbd17

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/data.table.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636
/* we mean the encoding bits, not CE_NATIVE in a UTF-8 locale */
3737
#define IS_UTF8(x) (getCharCE(x) == CE_UTF8)
3838
#define IS_LATIN(x) (getCharCE(x) == CE_LATIN1)
39-
#define IS_ASCII(x) (LEVELS(x) & 64) // API expected in R >= 4.5
39+
#if R_VERSION < R_Version(4, 5, 0)
40+
# define IS_ASCII(x) (LEVELS(x) & 64)
41+
#else
42+
# define IS_ASCII(x) (Rf_charIsASCII(x)) // no CE_ASCII
43+
#endif
4044
#define IS_TRUE(x) (TYPEOF(x)==LGLSXP && LENGTH(x)==1 && LOGICAL(x)[0]==TRUE)
4145
#define IS_FALSE(x) (TYPEOF(x)==LGLSXP && LENGTH(x)==1 && LOGICAL(x)[0]==FALSE)
4246
#define IS_TRUE_OR_FALSE(x) (TYPEOF(x)==LGLSXP && LENGTH(x)==1 && LOGICAL(x)[0]!=NA_LOGICAL)

0 commit comments

Comments
 (0)