Skip to content

Commit

Permalink
Align argument types and format strings (#524)
Browse files Browse the repository at this point in the history
* Test balloon

* Something different

* Apply to all the affected loci

* Take compiler's suggestion

* Cast this

* Undo unrelated whitespaces changes

* Additional checks suggested by Gabor

* Fix another format specification

* Prune CI a bit

* NEWS bullet
  • Loading branch information
jennybc committed Nov 29, 2023
1 parent dca0094 commit 997e945
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
- {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}
# keep this until the format specifier dust is truly settled (#524)
- {os: windows-latest, r: 'devel'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# vroom (development version)

* Internal changes requested by CRAN around format specification (#524).

# vroom 1.6.4

* It is now possible (again?) to read from a list of connections (@bairdj, #514).
Expand Down
8 changes: 8 additions & 0 deletions src/r_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
#include <string>
#include <vector>

#ifndef R_PRIdXLEN_T
# ifdef LONG_VECTOR_SUPPORT
# define R_PRIdXLEN_T "td"
# else
# define R_PRIdXLEN_T "d"
# endif
#endif

namespace vroom {

inline std::string
Expand Down
4 changes: 2 additions & 2 deletions src/unicode_fopen.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ inline FILE* unicode_fopen(const char* path, const char* mode) {
}
buf = (wchar_t*)R_alloc(len, sizeof(wchar_t));
if (buf == NULL) {
Rf_error("Could not allocate buffer of size: %ll", len);
Rf_error("Could not allocate buffer of size: %zu", len);
}

MultiByteToWideChar(CP_UTF8, 0, path, -1, buf, len);
Expand All @@ -75,7 +75,7 @@ make_mmap_source(const char* file, std::error_code& error) {
}
buf = (wchar_t*)malloc(len * sizeof(wchar_t));
if (buf == NULL) {
Rf_error("Could not allocate buffer of size: %ll", len);
Rf_error("Could not allocate buffer of size: %zu", len);
}

MultiByteToWideChar(CP_UTF8, 0, file, -1, buf, len);
Expand Down
1 change: 1 addition & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cstring>
#include <sstream>
#include <string>
#include <tuple>

namespace vroom {

Expand Down
3 changes: 2 additions & 1 deletion src/vroom_big_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

constexpr long long NA_INTEGER64 = 0x8000000000000000LL;

#include "r_utils.h"
#include "vroom.h"

namespace cpp11 {
Expand Down Expand Up @@ -56,7 +57,7 @@ class vroom_big_int : public vroom_vec {
static Rboolean
Inspect(SEXP x, int, int, int, void (*)(SEXP, int, int, int)) {
Rprintf(
"vroom_big_int (len=%d, materialized=%s)\n",
"vroom_big_int (len=%" R_PRIdXLEN_T ", materialized=%s)\n",
Length(x),
R_altrep_data2(x) != R_NilValue ? "T" : "F");
return TRUE;
Expand Down
3 changes: 2 additions & 1 deletion src/vroom_chr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "altrep.h"

#include "r_utils.h"
#include "vroom_vec.h"

cpp11::strings read_chr(vroom_vec_info* info);
Expand Down Expand Up @@ -38,7 +39,7 @@ struct vroom_chr : vroom_vec {
static Rboolean
Inspect(SEXP x, int, int, int, void (*)(SEXP, int, int, int)) {
Rprintf(
"vroom_chr (len=%d, materialized=%s)\n",
"vroom_chr (len=%" R_PRIdXLEN_T ", materialized=%s)\n",
Length(x),
R_altrep_data2(x) != R_NilValue ? "T" : "F");
return TRUE;
Expand Down
3 changes: 2 additions & 1 deletion src/vroom_date.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <cpp11/doubles.hpp>

#include "r_utils.h"
#include "vroom_dttm.h"

using namespace vroom;
Expand Down Expand Up @@ -47,7 +48,7 @@ class vroom_date : public vroom_dttm {
static Rboolean
Inspect(SEXP x, int, int, int, void (*)(SEXP, int, int, int)) {
Rprintf(
"vroom_date (len=%d, materialized=%s)\n",
"vroom_date (len=%" R_PRIdXLEN_T ", materialized=%s)\n",
Length(x),
R_altrep_data2(x) != R_NilValue ? "T" : "F");
return TRUE;
Expand Down
3 changes: 2 additions & 1 deletion src/vroom_dbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "altrep.h"
#include "parallel.h"
#include "r_utils.h"
#include "vroom_vec.h"

double bsd_strtod(const char* begin, const char* end, const char decimalMark);
Expand Down Expand Up @@ -37,7 +38,7 @@ class vroom_dbl : public vroom_vec {
static Rboolean
Inspect(SEXP x, int, int, int, void (*)(SEXP, int, int, int)) {
Rprintf(
"vroom_dbl (len=%d, materialized=%s)\n",
"vroom_dbl (len=%" R_PRIdXLEN_T ", materialized=%s)\n",
Length(x),
R_altrep_data2(x) != R_NilValue ? "T" : "F");
return TRUE;
Expand Down
3 changes: 2 additions & 1 deletion src/vroom_dttm.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cpp11/doubles.hpp>
#include <cpp11/integers.hpp>

#include "r_utils.h"
#include "vroom.h"
#include "vroom_vec.h"

Expand Down Expand Up @@ -65,7 +66,7 @@ class vroom_dttm : public vroom_vec {
static Rboolean
Inspect(SEXP x, int, int, int, void (*)(SEXP, int, int, int)) {
Rprintf(
"vroom_dttm (len=%d, materialized=%s)\n",
"vroom_dttm (len=%" R_PRIdXLEN_T ", materialized=%s)\n",
Length(x),
R_altrep_data2(x) != R_NilValue ? "T" : "F");
return TRUE;
Expand Down
3 changes: 2 additions & 1 deletion src/vroom_fct.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cpp11/strings.hpp>

#include "altrep.h"
#include "r_utils.h"
#include "vroom.h"
#include "vroom_vec.h"

Expand Down Expand Up @@ -122,7 +123,7 @@ struct vroom_fct : vroom_vec {
static Rboolean
Inspect(SEXP x, int, int, int, void (*)(SEXP, int, int, int)) {
Rprintf(
"vroom_factor (len=%d, materialized=%s)\n",
"vroom_factor (len=%" R_PRIdXLEN_T ", materialized=%s)\n",
Length(x),
R_altrep_data2(x) != R_NilValue ? "T" : "F");
return TRUE;
Expand Down
3 changes: 2 additions & 1 deletion src/vroom_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "altrep.h"

#include "r_utils.h"
#include "vroom_vec.h"

int strtoi(const char* begin, const char* end);
Expand Down Expand Up @@ -35,7 +36,7 @@ class vroom_int : public vroom_vec {
static Rboolean
Inspect(SEXP x, int, int, int, void (*)(SEXP, int, int, int)) {
Rprintf(
"vroom_int (len=%d, materialized=%s)\n",
"vroom_int (len=%" R_PRIdXLEN_T ", materialized=%s)\n",
Length(x),
R_altrep_data2(x) != R_NilValue ? "T" : "F");
return TRUE;
Expand Down
3 changes: 2 additions & 1 deletion src/vroom_num.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "altrep.h"

#include "r_utils.h"
#include "vroom_vec.h"

#include "parallel.h"
Expand Down Expand Up @@ -47,7 +48,7 @@ class vroom_num : public vroom_vec {
static Rboolean
Inspect(SEXP x, int, int, int, void (*)(SEXP, int, int, int)) {
Rprintf(
"vroom_num (len=%d, materialized=%s)\n",
"vroom_num (len=%" R_PRIdXLEN_T ", materialized=%s)\n",
Length(x),
R_altrep_data2(x) != R_NilValue ? "T" : "F");
return TRUE;
Expand Down
3 changes: 2 additions & 1 deletion src/vroom_rle.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "altrep.h"
#include "r_utils.h"

#ifdef HAS_ALTREP

Expand Down Expand Up @@ -40,7 +41,7 @@ class vroom_rle {
static Rboolean
Inspect(SEXP x, int, int, int, void (*)(SEXP, int, int, int)) {
Rprintf(
"vroom_rle (len=%d, materialized=%s)\n",
"vroom_rle (len=%" R_PRIdXLEN_T ", materialized=%s)\n",
Length(x),
R_altrep_data2(x) != R_NilValue ? "T" : "F");
return TRUE;
Expand Down
3 changes: 2 additions & 1 deletion src/vroom_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <cpp11/doubles.hpp>

#include "r_utils.h"
#include "vroom.h"
#include "vroom_dttm.h"

Expand Down Expand Up @@ -47,7 +48,7 @@ class vroom_time : public vroom_dttm {
static Rboolean
Inspect(SEXP x, int, int, int, void (*)(SEXP, int, int, int)) {
Rprintf(
"vroom_time (len=%d, materialized=%s)\n",
"vroom_time (len=%" R_PRIdXLEN_T ", materialized=%s)\n",
Length(x),
R_altrep_data2(x) != R_NilValue ? "T" : "F");
return TRUE;
Expand Down
2 changes: 1 addition & 1 deletion src/vroom_write.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void write_buf_con(const std::vector<char>& buf, SEXP con, bool is_stdout) {
if (is_stdout) {
std::string out;
std::copy(buf.begin(), buf.end(), std::back_inserter(out));
Rprintf("%.*s", buf.size(), out.c_str());
Rprintf("%.*s", (int) buf.size(), out.c_str());
} else {
write_buf(buf, con);
}
Expand Down

0 comments on commit 997e945

Please sign in to comment.