From fc315189ac1b0b3156a4d0761e9c4902126a120a Mon Sep 17 00:00:00 2001 From: Davis Vaughan Date: Fri, 1 Dec 2023 10:08:33 -0500 Subject: [PATCH] Fix usage of C level format token (#1897) * Use the correct format string for `R_xlen_t` * NEWS bullet --- NEWS.md | 2 ++ src/altrep-rle.c | 2 +- src/vctrs-core.h | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index e7836bfd0..788e4fd51 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # vctrs (development version) +* Internal changes requested by CRAN around C level format strings (#1896). + * Fixed tests related to changes to `dim<-()` in R-devel (#1889). # vctrs 0.6.4 diff --git a/src/altrep-rle.c b/src/altrep-rle.c index 6f56a7022..1b712dbc1 100644 --- a/src/altrep-rle.c +++ b/src/altrep-rle.c @@ -59,7 +59,7 @@ Rboolean altrep_rle_Inspect(SEXP x, int deep, int pvec, void (*inspect_subtree)(SEXP, int, int, int)) { - Rprintf("vctrs_altrep_rle (len=%d, materialized=%s)\n", + Rprintf("vctrs_altrep_rle (len=%" R_PRIdXLEN_T ", materialized=%s)\n", altrep_rle_Length(x), R_altrep_data2(x) != R_NilValue ? "T" : "F"); return TRUE; diff --git a/src/vctrs-core.h b/src/vctrs-core.h index 6ce64dd9a..f02c10b9a 100644 --- a/src/vctrs-core.h +++ b/src/vctrs-core.h @@ -108,5 +108,15 @@ enum vctrs_dbl dbl_classify(double x); #define VECTOR_PTR_RO(x) ((const SEXP*) DATAPTR_RO(x)) +// Likely supplied in R 4.4.0 +// https://github.com/wch/r-source/commit/38403c9c347dd5426da6009573b087188ec6be04 +#ifndef R_PRIdXLEN_T +# ifdef LONG_VECTOR_SUPPORT +# define R_PRIdXLEN_T "td" +# else +# define R_PRIdXLEN_T "d" +# endif +#endif + #endif