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

ENHANCED: use pcre2 library instead of pcre1 #11

Merged
merged 1 commit into from
Mar 25, 2022

Conversation

kamahen
Copy link
Member

@kamahen kamahen commented Mar 10, 2022

This is a preliminary commit, to review some design decisions:

  • bsr2, newline2 because the underlying number codes changed
  • slightly different way of processing options, due to pcre2 changing some of its api (bsr, newline, amongst others)
  • dropped some code that tried to do stack allocation instead of malloc (instead just use the pcre2_compile_context_create())

There are also some TODOs that will be removed.

Please verify that I've followed the C formatting conventions (it's not a style that I normally use).

When all the reviews are done (including a detailed check of all the options), the various commits will be squashed into a single commit.

@kamahen kamahen mentioned this pull request Mar 10, 2022
@kamahen
Copy link
Member Author

kamahen commented Mar 13, 2022

I just realized that I've been doing the options wrong. Unlike PCRE1, where there's just one set of flags for both compile and match, there are 4 different flags and I need to distinguish them. E.g.: 0x00000001u is PCRE2_ALLOW_EMPTY_CLASS, PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES, PCRE2_JIT_COMPLETE, PCRE2_NOTBOL.

So, I need to rewrite the options handling. :(
Which means there's much more work than just finding typos and missing options.

@kamahen
Copy link
Member Author

kamahen commented Mar 24, 2022

I've pushed a new squashed change - ready for review.

@kamahen
Copy link
Member Author

kamahen commented Mar 24, 2022

When you've finished reviewing the code, I'll prepare a git patch file for the other changes (#2 (comment)). These aren't needed for building and testing on Linux, but are possibly needed for other kinds of builds. (I'm delaying creation of the patch file, to be sure it's against the latest version of the master)

@kamahen
Copy link
Member Author

kamahen commented Mar 25, 2022

I've sent 3 patches to bugs@swi-prolog.org, to be applied after this PR is applied.
This contains some diffs that I forgot to include in #2 (comment)
for swipl-devel, plus distro-debian and packages/jpl

  - Issue SWI-Prolog#2
  - Numerous small bug fixes and enhancements (e.g., handling of
    duplicate options, capture_type, error checking).
  - This commit takes advantage of refactoring that was
    done on the pcre1 code to make it easier to handle the
    pcre2 options (which are both more numerous and have a different
    underlying API).
  - Added new pcre2 options
  - Removed some obsolete options, preserving backwards compatibility
    where possible
  - The meaning of optimise(true) has changed - it now calls
    the JIT compiler
  - Renamed bsr(...) and newline(...) options to bsr2(...) and newline2(...)
    because the pcre2 interface has changed
  - compat(javascript) is replaced by alt_bsux(true) and extra_alt_bsux(true)
  - Code improvements:
    use `uint32_t` wherever possible instead of `unsigned` or `int`
  - Does not use the new pcre2_substitute() for re_replace/{4,5},
    re_split/{3,4}, re_foldl/6 (however, some improvements have been
    made to the APIs for these).
- Added test cases
@JanWielemaker JanWielemaker merged commit 1ace340 into SWI-Prolog:master Mar 25, 2022
@kamahen kamahen deleted the pcre2 branch April 5, 2022 13:52
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