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

Fix getline usage #419

Merged
merged 2 commits into from
Dec 27, 2023
Merged

Fix getline usage #419

merged 2 commits into from
Dec 27, 2023

Conversation

darvark
Copy link
Contributor

@darvark darvark commented Dec 24, 2023

Fixes according to issue #414.

Still can't find solution for failing test_rules error.

@zcsahok
Copy link
Member

zcsahok commented Dec 26, 2023

The tests seem to be all OK.

@dl1jbe
Copy link
Member

dl1jbe commented Dec 27, 2023

Looks much better and fixes most problems.

Just one question left: What do you want to check with the lines like

if (s_inputbuffer_len > 0) {

and similar. Do you want to make sure there is an allocated buffer? That should be guaranteed by readline() returning without an error.

@darvark
Copy link
Contributor Author

darvark commented Dec 27, 2023

Yes I want to be sure that something was read. getline will return -1 only in case of error i other case returns number of characters read. So it can return in theory 0, and function will have to work on zero length buffer? In theory I can remove that check, but not sure if it's sully desired and safe

@dl1jbe
Copy link
Member

dl1jbe commented Dec 27, 2023

I see. But than you should test the value returned by getline() instead. That would be

'''
while ((read = getline(&s_inputbuffer, &s_inputbuffer_len, cfp)) != -1) {
if (read > 0) {
....
}
}
'''

If I read the man page right the inputbuffer will be expanded as needed but not shrink-ed if it is to large, so its size from 's_inputbuffer_len' may not represent the line length.

@darvark
Copy link
Contributor Author

darvark commented Dec 27, 2023

Right, Ok, switching condition. Meanwhile one question (not related to that PR). Is there any documentation about usage python plugins? We can enable support or python plugins, bu I didn't found anything about usage or how to write them

@dl1jbe
Copy link
Member

dl1jbe commented Dec 27, 2023

Meanwhile one question (not related to that PR). Is there any documentation about usage python plugins? We can enable support or python plugins, bu I didn't found anything about usage or how to write them

Please see TLFs man page section `PYTHON PLUGIN'.

As the plugin was made by Zoli, he can give more informations if needed.

@dl1jbe
Copy link
Member

dl1jbe commented Dec 27, 2023

Your code looks good now. There are some places were a check for empty lines is already in place. But we will sort that out later.

Thanks for the work on it. Will merge it in now.

@dl1jbe dl1jbe merged commit 446ea10 into Tlf:master Dec 27, 2023
2 checks passed
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.

3 participants