Skip to content

Conversation

@jonstewart
Copy link
Contributor

lg_add_pattern_list() was always returning -1. Now it returns 0 if there are no errors.

The actual implementation function lightgrep_c_api.cpp is too long. I've made some minor changes but more is needed. Since it's using the Boost string token library, I'm hesitant to break up little subfunctions that advance the token iterators. An obvious refactoring, though, would be to extract a function for just parsing a line containing one pattern, and that'd probably make the code easier to read and less nested.

Other refactoring thoughts, @juliapaluch?

…d Boost program_options, which disables some warnings in a pragma block, instead of the raw Boost header directly. Suppresses many warnings with clang on my Mac.
…ning because it uncovered a function in need of attention, to be done on a separate.
…re it's useful in C++ to do this to suppress unused argument warnings). But C is also quite happy for main(void) instead of main(int argc, char *arg[]), so let's use that instead in the C example to be rid of a warning.
… (a long) by refactoring this for-loop into a while loop. Initializing i to zero in the initializer of the for-loop, with auto, caused the type to be an int. Initializing it directly from std::string::find_first_of coerces the type to a size_type, and then... this just suits a while loop a bit better.
…omplaining about yynerrs being set to 0, but never being used.
…n units and is not necessary there as Catch2 now supplies stream output for containers.
…old-style C++ iterators, by removing it entirely. It was only used in one place for real, and a for-loop is a slightly simpler and smaller (in executable size for the translation unit) than using std::copy with the iterator. In C++23, there's std::ranges::join_with_view/std::ranges::views::join_with so the lack of this iterator can be replaced by a more modern version in STL with an upgrade to C++23.
…d a null pointer for err. This is still gross and needs some refactoring. lg_add_pattern_list() now apes lg_add_pattern() in returning -1 on error and 0 on success... but this is _not_ how lg_parse_pattern() works, and it leads to some impedance mismatch throughout.
…ing specified. Pass the encodings into addPatternHelper() as const. Rename 'el' to 'encList'.
@jonstewart
Copy link
Contributor Author

NB: this is built on top of the other kill-warnings branch.

@juliapaluch
Copy link
Contributor

Can you merge main into this branch & push so we can get the checks to run?

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.

2 participants