Skip to content
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

Ignoring/truncating lines that are too long? #36

Open
HankLloydRight opened this issue Feb 11, 2023 · 3 comments
Open

Ignoring/truncating lines that are too long? #36

HankLloydRight opened this issue Feb 11, 2023 · 3 comments

Comments

@HankLloydRight
Copy link

HankLloydRight commented Feb 11, 2023

Hello,

If I change line 423 in IniFile.cpp from:

return errorBufferTooSmall;
to
return errorNoError;

Would that result in the validate function not returning an error but instead just truncating lines that are too long (instead of returning an invalid file error)?

What's your reasoning behind invalidating the entire file if any lines are longer than the buffer length instead of just silently (or not silently) truncating them?

My thinking is if an end-user inadvertently has one line go over inibufferlen, the entire file is rejected, instead of just the offending line(s).

Thank you.

@stevemarple
Copy link
Owner

The file is processed line-by-line which enables IniFile to work with only a small amount of RAM. The parser expects that a buffer contains an entire line. I've not tried but I expect that the change you suggested would be equivalent to splitting the line by inserting a newline character, it won't truncate lines that are too long.

I don't see any point in truncating lines that are too long for the buffer. It is reasonable to assume that all provided key/value pairs are important. So either the file is valid and can be parsed, or else it is not valid.

If you need to support longer line lengths then you need to increase the buffer size.

@HankLloydRight
Copy link
Author

HankLloydRight commented Feb 11, 2023

If you need to support longer line lengths then you need to increase the buffer size.

I'm thinking more for comment lines which can be safely ignored and has the chance of a user typing too much.

@HankLloydRight
Copy link
Author

I guess what I'm asking is it possible for the Ini file validation check to ignore lines that just comments? But continue to check actual key/value pairs for the pre-set buffer length limit.

So end-users who are modifying the ini files can type whatever comments they want without fear of going over a pre-set buffer length (say 100 bytes) and inadvertently invalidating the ini file.

thanks.

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

No branches or pull requests

2 participants