-
Notifications
You must be signed in to change notification settings - Fork 990
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
gcc-12 always-false in fread.c #5476
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8dd86ef
gcc-12 always-false in fread.c
mattdowle f011155
better comment, used else rather than continue to read better now tha…
mattdowle 80692fb
gcc-10 bumped to gcc-12 in CRAN_Release.cmd
mattdowle f2964c1
1.14.3 => 1.14.5; 1.14.4 will be backported patch to resolve current …
mattdowle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1284,25 +1284,22 @@ int freadMain(freadMainArgs _args) { | |
while (*nastr) { | ||
if (**nastr == '\0') { | ||
blank_is_a_NAstring = true; | ||
// if blank is the only one, as is the default, clear NAstrings so that doesn't have to be checked | ||
if (nastr==NAstrings && nastr+1==NULL) NAstrings=NULL; | ||
nastr++; | ||
continue; | ||
} else { | ||
const char *ch = *nastr; | ||
size_t nchar = strlen(ch); | ||
if (isspace(ch[0]) || isspace(ch[nchar-1])) | ||
STOP(_("freadMain: NAstring <<%s>> has whitespace at the beginning or end"), ch); | ||
if (strcmp(ch,"T")==0 || strcmp(ch,"F")==0 || | ||
strcmp(ch,"TRUE")==0 || strcmp(ch,"FALSE")==0 || | ||
strcmp(ch,"True")==0 || strcmp(ch,"False")==0) | ||
STOP(_("freadMain: NAstring <<%s>> is recognized as type boolean, this is not permitted."), ch); | ||
if ((strcmp(ch,"1")==0 || strcmp(ch,"0")==0) && args.logical01) | ||
STOP(_("freadMain: NAstring <<%s>> and logical01=%s, this is not permitted."), ch, args.logical01 ? "TRUE" : "FALSE"); | ||
char *end; | ||
errno = 0; | ||
(void)strtod(ch, &end); // careful not to let "" get to here (see continue above) as strtod considers "" numeric | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment looks stale now that 'continue' is removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indeed. good spot. |
||
if (errno==0 && (size_t)(end - ch) == nchar) any_number_like_NAstrings = true; | ||
} | ||
const char *ch = *nastr; | ||
size_t nchar = strlen(ch); | ||
if (isspace(ch[0]) || isspace(ch[nchar-1])) | ||
STOP(_("freadMain: NAstring <<%s>> has whitespace at the beginning or end"), ch); | ||
if (strcmp(ch,"T")==0 || strcmp(ch,"F")==0 || | ||
strcmp(ch,"TRUE")==0 || strcmp(ch,"FALSE")==0 || | ||
strcmp(ch,"True")==0 || strcmp(ch,"False")==0) | ||
STOP(_("freadMain: NAstring <<%s>> is recognized as type boolean, this is not permitted."), ch); | ||
if ((strcmp(ch,"1")==0 || strcmp(ch,"0")==0) && args.logical01) | ||
STOP(_("freadMain: NAstring <<%s>> and logical01=%s, this is not permitted."), ch, args.logical01 ? "TRUE" : "FALSE"); | ||
char *end; | ||
errno = 0; | ||
(void)strtod(ch, &end); // careful not to let "" get to here (see continue above) as strtod considers "" numeric | ||
if (errno==0 && (size_t)(end - ch) == nchar) any_number_like_NAstrings = true; | ||
nastr++; | ||
} | ||
disabled_parsers[CT_BOOL8_N] = !args.logical01; | ||
|
@@ -1325,6 +1322,10 @@ int freadMain(freadMainArgs _args) { | |
DTPRINT(_(" show progress = %d\n"), args.showProgress); | ||
DTPRINT(_(" 0/1 column will be read as %s\n"), args.logical01? "boolean" : "integer"); | ||
} | ||
if (*NAstrings==NULL || // user sets na.strings=NULL | ||
(**NAstrings=='\0' && *(NAstrings+1)==NULL)) { // user sets na.strings="" | ||
NAstrings=NULL; // clear NAstrings to save end_NA_string() dealing with these cases (blank_is_a_NAstring was set to true above) | ||
} | ||
|
||
stripWhite = args.stripWhite; | ||
skipEmptyLines = args.skipEmptyLines; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slightly confused by the templating in the string here am I missing something? in the error case logical01 is always TRUE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good spot. agree
and logical01=TRUE, this
could be in the string directly and the ternary isn't needed.