-
Notifications
You must be signed in to change notification settings - Fork 237
pcre2test: improve expand and its use of buffers
#773
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
base: main
Are you sure you want to change the base?
Conversation
expand and its use of buffersexpand and its use of buffers
src/pcre2test.c
Outdated
| size_t pp_offset = pp - buffer; | ||
| size_t pt_offset = pt - pbuffer8; | ||
| expand_input_buffers(); | ||
| expand_input_buffers(m); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This thing with m can't be correct, can it? It looks like m is being set to the size of the current expansion, not the size of what's in the buffer plus the new content.
What happens for this: /[a]{1000}[b]{1000}/expand
Allow for a nicer fallback in case of syntax errors in the pattern implementation while avoiding negative values masquerading as positive ones. While at it, make sure that in non LP64 environments UINT32_MAX is still considered valid. Update the data implementation to behave similarly and cleanup fixes that had accumlated unorganically.
Use realloc() for exponential resize of all buffers, which has the advantage of potentially not needing to copy. Add a parameter to `expand_input_buffers()` to indicate the minimum size required and allow a smarter fallback when the buffer can't be doubled.
|
I apologize, I think I have created a ton of conflicts in this branch after my splitting of I will rebase your changes if you would like, just ask. |
Mainly as a way to clean the code and make it more resilient.
It changes the behavior of the pattern
/\[]{-1}/expandwhich will now be treated as a literal instead of triggering a bogus syntax error and clarifies that no pattern or buffer could be larger than SIZE_MAX bytes.Improves error checking for 32-bit platforms and even 64-bit ones that are not LP64.