Skip to content

Conversation

@myclevorname
Copy link

Yes, it uses a goto statement. Even though goto statements are considered harmful, I think it is okay in this situation. This fixes #78.

Yes, it uses a goto statement. Even though goto statements are
considered harmful, I think it is okay in this situation.
rewind (file);


// If there is a UTF-8 endian marker at the beginning of the file, skip it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will incorporate that into a new commit.

@tari
Copy link
Contributor

tari commented Jun 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Couldn't open input file" on input file of size 0

2 participants