Fix compare of file suffix#703
Conversation
File suffix only checked the initial char, not the entire ending. Replace check with strcmp.
| if (config->num_files == 1 && file_config->logfile_optional_counter) { | ||
| /* <filename>.dlt or <filename>_<tmsp>.dlt */ | ||
| if ((files[i]->d_name[len] == suffix[0]) || | ||
| if (strcmp(files[i]->d_name + len, suffix) == 0 || |
There was a problem hiding this comment.
Hi @averater
this comparation is wrong when the file contains timestamp
There was a problem hiding this comment.
Do you mean it is wrong also as it is? Because all I did was change the suffix comparison from only comparing the "." to comparing the entire suffix.
If we need to change the comparison for files with timestamps then maybe that would be a different pull request?
There was a problem hiding this comment.
@averater
I know, it should be covered all cases in your PR.
You can apply in current PR, don't need other PR
There was a problem hiding this comment.
I would prefer if someone else fixed that part as I have other task with higher prio and don't have time to look into this soon. Either merge only this PR and fix only this part or someone else has to fix all of it.
There was a problem hiding this comment.
This PR fixes the case without timestamp. If there is a timestamp it will only check for a delimiter. Next line:
(file_config->logfile_timestamp &&
(files[i]->d_name[len] == file_config->logfile_delimiter))) {
To fix that we need to either check files[i]->d_nam from the back or know how long the timestamp is. That will be needed in this PR: #772
File suffix only checked the initial char, not the entire ending. Replace check with strcmp.