Skip to content

Commit ade5f95

Browse files
renamed _const_cast and __halt (#7011)
* renamed `_const_cast` and `__halt` * restore spurious diffs * restore more diffs --------- Co-authored-by: Michael Chirico <[email protected]>
1 parent 2715663 commit ade5f95

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/fread.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static void Field(FieldParseContext *ctx);
127127
* Drops `const` qualifier from a `const char*` variable, equivalent of
128128
* `const_cast<char*>` in C++.
129129
*/
130-
static char* _const_cast(const char *ptr) {
130+
static char* const_cast(const char *ptr) {
131131
union { const char *a; char *b; } tmp = { ptr };
132132
return tmp.b;
133133
}
@@ -1570,7 +1570,7 @@ int freadMain(freadMainArgs _args) {
15701570
DTPRINT(_("Avoidable file copy in RAM took %.3f seconds. %s.\n"), time_taken, msg); // # nocov. not warning as that could feasibly cause CRAN tests to fail, say, if test machine is heavily loaded
15711571
}
15721572
}
1573-
*_const_cast(eof) = '\0'; // cow page
1573+
*const_cast(eof) = '\0'; // cow page
15741574
}
15751575
// else char* input already guaranteed to end with \0. We do not modify direct char* input at all, ever.
15761576
// We have now ensured the input ends on eof and that *eof=='\0' too. Normally, lastEOLreplaced will be true.
@@ -1862,8 +1862,8 @@ int freadMain(freadMainArgs _args) {
18621862
if (verbose) DTPRINT(_(" 1-column file ends with 2 or more end-of-line. Restoring last eol using extra byte in cow page.\n"));
18631863
eof++;
18641864
}
1865-
*_const_cast(eof-1) = eol_one_r ? '\r' : '\n';
1866-
*_const_cast(eof) = '\0';
1865+
*const_cast(eof-1) = eol_one_r ? '\r' : '\n';
1866+
*const_cast(eof) = '\0';
18671867
}
18681868
}
18691869

src/freadR.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ void progress(int p, int eta) {
708708
}
709709
// # nocov end
710710

711-
void __halt(bool warn, const char *format, ...) {
711+
void halt__(bool warn, const char *format, ...) {
712712
// Solves: http://stackoverflow.com/questions/18597123/fread-data-table-locks-files
713713
// TODO: always include fnam in the STOP message. For log files etc.
714714
va_list args;

src/freadR.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
// However, msg has to be manually constructed first (rather than simply leaving construction to snprintf inside warning()
2020
// or error()) because the msg usually points to substrings from the mmp (which is invalid after close).
2121
// Where no halt is happening, we can just use raw Rprintf() or warning()
22-
void __halt(bool warn, const char *format, ...); // see freadR.c
23-
#define STOP(...) __halt(0, __VA_ARGS__)
22+
void halt__(bool warn, const char *format, ...); // see freadR.c
23+
#define STOP(...) halt__(0, __VA_ARGS__)
2424
static char internal_error_buff[1001] __attribute__((unused)); // match internalErrSize // todo: fix imports such that compiler warns correctly #6468
25-
#define INTERNAL_STOP(...) do {snprintf(internal_error_buff, 1000, __VA_ARGS__); __halt(0, "%s %s: %s. %s", _("Internal error in"), __func__, internal_error_buff, _("Please report to the data.table issues tracker"));} while (0)
25+
#define INTERNAL_STOP(...) do {snprintf(internal_error_buff, 1000, __VA_ARGS__); halt__(0, "%s %s: %s. %s", _("Internal error in"), __func__, internal_error_buff, _("Please report to the data.table issues tracker"));} while (0)
2626
#define DTPRINT Rprintf
27-
#define DTWARN(...) warningsAreErrors ? __halt(1, __VA_ARGS__) : warning(__VA_ARGS__)
27+
#define DTWARN(...) warningsAreErrors ? halt__(1, __VA_ARGS__) : warning(__VA_ARGS__)
2828

2929
#endif
30-

0 commit comments

Comments
 (0)