Skip to content

Use library strncasecmp if available#535

Merged
goatshriek merged 10 commits intogoatshriek:latestfrom
flinkflonk:531_use_strncasecmp_from_lib_if_available
Oct 22, 2025
Merged

Use library strncasecmp if available#535
goatshriek merged 10 commits intogoatshriek:latestfrom
flinkflonk:531_use_strncasecmp_from_lib_if_available

Conversation

@flinkflonk
Copy link
Contributor

Introduces new flags regarding the availability of strncasecmp (which nowadays should be in strings.h), moves the custom function into its own sourcefile which is only compiled and connected to the rest of the code via a wrapper header.

Closes #531

Introduces new flags regarding the availability of strncasecmp (which
nowadays should be in strings.h), moves the custom function into its
own sourcefile which is only compiled and connected to the rest of the
code via a wrapper header.

Closes goatshriek#531
@flinkflonk
Copy link
Contributor Author

There's one "FIXME" in my code, I haven't checked out the thread safety of the custom function (which I didn't write, I just refactored 😁 ). Also, I have tested this on Linux, but not on Windows, so somebody might want to check if it still compiles on Windows (it should).

@goatshriek goatshriek added the refactor changes that require refactoring of existing code label Oct 19, 2025
@goatshriek goatshriek self-assigned this Oct 19, 2025
@goatshriek
Copy link
Owner

My apologies for the delay, I am aiming to review this and provide comments on the next 24 hours.

Copy link
Owner

@goatshriek goatshriek left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together! It looks like there are some failing test cases, which I didn't look to closely at as I expect you'll be able to work out the issues. The other comments should be straightforward to address, and then I believe this will be good to go!

@flinkflonk
Copy link
Contributor Author

I have now gone through your code review and made the requested changes. The tests failing are not really related to my code (and they failed before I touched it), and as far as I can see it's because of three factors (which are out of scope for this pull request):

  • the function stumpless_get_severity_enum_from_buffer in src/severity.c returns a enum stumpless_severity, but in two places there's just a size_t or int returned (i or -1).
  • the test checks for a value of -1 being returned, but it is clearly a STUMPLESS_SEVERITY_*_VALUE in the test cases provided
  • besides, EMERG, WARN and ERROR are marked as "deprecated" in the source code for a different test

Copy link
Owner

@goatshriek goatshriek left a comment

Choose a reason for hiding this comment

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

Thanks for digging into that test! The implementation is indeed broken, as you outlined. I'll fix this in a separate change - if you don't mind, please comment out the failing test case, and I will re-enable it when I fix the issue. I'd like to see the rest of the CI tests pass to make sure they're good to go.

Otherwise, I believe this will be good to go once the header path is updated in src/config/no_strncasecmp.c, and the header check issues are resolved. The header checks should be resolved by adding entries into the tools/check_headers/stumpless_private.yml manifest for the new symbols HAVE_STRNCASECMP, config_strncasecmp and strncasecmp_custom, and an entry into tools/check_headers/standard_library.yml for strncasecmp.

@flinkflonk
Copy link
Contributor Author

Ok, after disabling the test the ones running on my fork are complaining about not being able to upload coverage reports. But more important: the Windows build returns success (because it doesn't include coverage), so I guess we're good to go?

@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.82%. Comparing base (844641e) to head (10b35ea).
⚠️ Report is 1 commits behind head on latest.

Files with missing lines Patch % Lines
src/severity.c 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           latest     #535   +/-   ##
=======================================
  Coverage   90.82%   90.82%           
=======================================
  Files          47       47           
  Lines        4576     4566   -10     
  Branches      609      605    -4     
=======================================
- Hits         4156     4147    -9     
  Misses        276      276           
+ Partials      144      143    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@goatshriek
Copy link
Owner

Great, looks good! You don't have to worry about the coverage reports. The only remaining thing is to add the header check entries outlined above, which should resolve the header check that is currently failing in the static analysis.

@flinkflonk
Copy link
Contributor Author

Ok, hopefully I ticked all the boxes and dotted all the i-s, it seems the only thing breaking now - at least in my fork - is "Sonarcloud Analysis" (which can't "find the project", whatever that means).

@goatshriek goatshriek merged commit f30a2ee into goatshriek:latest Oct 22, 2025
55 of 56 checks passed
@goatshriek
Copy link
Owner

Excellent work, thanks once again for putting this change together! I especially appreciate that you checked the CI runs in your fork while working through the fixes - this is a huge time saver and is often missed by contributors.

@flinkflonk
Copy link
Contributor Author

Thanks a lot for being so patient with me, I might be somewhat useful at C (and maybe a little bit of C++) but not really into pull requests and what is expected. Looking at the CI results in my own fork was no biggie here, I've seen projects where it is more of an issue to understand what is going on (openssl for instance has a CI run that takes multiple hours).
So thanks for the help from your side, and hope my work added some value :)

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

Labels

refactor changes that require refactoring of existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use library strncasecmp when available

2 participants