Allow an empty input file to be parsed correctly#79
Open
myclevorname wants to merge 2 commits intoalberthdev:masterfrom
Open
Allow an empty input file to be parsed correctly#79myclevorname wants to merge 2 commits intoalberthdev:masterfrom
myclevorname wants to merge 2 commits intoalberthdev:masterfrom
Conversation
Yes, it uses a goto statement. Even though goto statements are considered harmful, I think it is okay in this situation.
tari
reviewed
Jun 8, 2024
| rewind (file); | ||
|
|
||
|
|
||
| // If there is a UTF-8 endian marker at the beginning of the file, skip it. |
Contributor
There was a problem hiding this comment.
Since the implementation of this is the issue, I think the problem can be fixed more easily by changing this only.
Something like..
unsigned char file_head[3];
read_size = fread(file_head, 1, 3, file);
if (read_size == 3 && memcmp(file_head, utf8_endian_mark, sizeof(file_head)) == 0) {
// Skip UTF-8 BOM
size -= sizeof(file_head);
} else {
// Read data needs to be retained
rewind(file);
}
Author
There was a problem hiding this comment.
Thanks, I will incorporate that into a new commit.
Contributor
|
I'd also recommend adding a test for this, but that might not be easy to do since our tests are set up to have metadata in the input file. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Yes, it uses a goto statement. Even though goto statements are considered harmful, I think it is okay in this situation. This fixes #78.