Skip to content

Commit 5eef830

Browse files
committed
More #ifdef wrapping for connections API
Wrap the helper functions too. Avoid double negatives.
1 parent 1a98f38 commit 5eef830

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/freadR.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ void progress(int p, int eta)
741741
}
742742
// # nocov end
743743

744+
#if R_CONNECTIONS_VERSION == 1
744745
typedef struct {
745746
Rconnection con;
746747
const char *filepath;
@@ -809,12 +810,11 @@ static SEXP do_spill(void *data)
809810

810811
return ScalarReal((double)total_read);
811812
}
813+
#endif // R_CONNECTIONS_VERSION == 1
812814

813815
// Spill connection contents to a tempfile so R-level fread can treat it like a filename
814816
SEXP spillConnectionToFile(SEXP connection, SEXP tempfile_path, SEXP nrows_limit) {
815-
#if R_CONNECTIONS_VERSION != 1
816-
INTERNAL_STOP(_("spillConnectionToFile: unexpected R_CONNECTIONS_VERSION = %d", R_CONNECTIONS_VERSION)); // # nocov
817-
#else
817+
#if R_CONNECTIONS_VERSION == 1
818818
if (!isString(tempfile_path) || LENGTH(tempfile_path) != 1) {
819819
INTERNAL_STOP(_("spillConnectionToFile: tempfile_path must be a single string")); // # nocov
820820
}
@@ -839,7 +839,9 @@ INTERNAL_STOP(_("spillConnectionToFile: unexpected R_CONNECTIONS_VERSION = %d",
839839
}
840840

841841
return R_ExecWithCleanup(do_spill, &state, spill_cleanup, &state);
842-
#endif // was R_CONNECTIONS_VERSION not != 1?
842+
#else // R_CONNECTIONS_VERSION != 1
843+
INTERNAL_STOP(_("spillConnectionToFile: unexpected R_CONNECTIONS_VERSION = %d", R_CONNECTIONS_VERSION)); // # nocov
844+
#endif
843845
}
844846

845847
void halt__(bool warn, const char *format, ...)

0 commit comments

Comments
 (0)