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

Use Rf_charIsASCII for IS_ASCII instead of testing LEVELS on R >= 4.5 #6422

Merged
merged 10 commits into from
Mar 5, 2025
Merged
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ rowwiseDT(

4. The translations submitted for 1.16.0 are now actually shipped with the package -- our deepest apologies to the translators for the omission. We have added a CI check to ensure that the .mo binaries which get shipped with the package are always up-to-date.

2. Continued work to remove non-API C functions, [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks Ivan Krylov for the PRs and for writing a clear and concise guide about the R API: https://aitap.codeberg.page/R-api/.

# data.table [v1.16.0](https://github.com/Rdatatable/data.table/milestone/30) (25 August 2024)

## BREAKING CHANGES
Expand Down
6 changes: 5 additions & 1 deletion src/data.table.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
/* we mean the encoding bits, not CE_NATIVE in a UTF-8 locale */
#define IS_UTF8(x) (getCharCE(x) == CE_UTF8)
#define IS_LATIN(x) (getCharCE(x) == CE_LATIN1)
#define IS_ASCII(x) (LEVELS(x) & 64) // API expected in R >= 4.5
#if R_VERSION < R_Version(4, 5, 0) || R_SVN_REVISION < 86789
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this here even though there's another (4,5,0) check above at L21

  • The R_SVN_REVISIONs are different
  • The IS_UTF8() and IS_LATIN() macros are also right here

# define IS_ASCII(x) (LEVELS(x) & 64)
#else
# define IS_ASCII(x) (Rf_charIsASCII(x)) // no CE_ASCII
#endif
#define IS_TRUE(x) (TYPEOF(x)==LGLSXP && LENGTH(x)==1 && LOGICAL(x)[0]==TRUE)
#define IS_FALSE(x) (TYPEOF(x)==LGLSXP && LENGTH(x)==1 && LOGICAL(x)[0]==FALSE)
#define IS_TRUE_OR_FALSE(x) (TYPEOF(x)==LGLSXP && LENGTH(x)==1 && LOGICAL(x)[0]!=NA_LOGICAL)
Expand Down
Loading