Skip to content

Replace pcre-light with regex-pcre#19

Open
pbrisbin wants to merge 3 commits into
ua-parser:masterfrom
pbrisbin:pb/regex-pcre
Open

Replace pcre-light with regex-pcre#19
pbrisbin wants to merge 3 commits into
ua-parser:masterfrom
pbrisbin:pb/regex-pcre

Conversation

@pbrisbin

@pbrisbin pbrisbin commented Jun 2, 2026

Copy link
Copy Markdown

pcre-light requires shared library libpcre. This library was usually
available on Ubuntu as libpcre3. It's now being replaced, confusingly, by
libpcre2. Additionally, the library, and it's -dev varietals might not be
present in Ubuntu v26, or may be present as other, also confusing names.

Besides, removing a shared library requirement, absent other trade-offs seems
like a good idea. And I don't know of any other trade-offs, so here we are.

The keep the diff down, I defined a match and compile function with the same
interfaces the pcre-light, but written in terms of regex-pcre functions.

That regex-pcre functions are in IO, which means we require
unsafePerformIO, but this is exactly what the pcre-light functions did
internally anyway, so there is no change in safety introduced.

To get the OS Parser tests to pass, I had to copy the normalize pattern
present in the UA parser. I'm not sure if it's intentional to normalize empty
text to Nothing for UA but not OS; I hope not.

pbrisbin added 3 commits June 2, 2026 11:46
`pcre-light` requires shared library `libpcre`. This library was usually
available on Ubuntu as `libpcre3`. It's now being replaced, confusingly,
by `libpcre2`. Additionally, the library, and it's `-dev` varietals
might not be present in Ubuntu v26, or may be present as other, also
confusing names.

Besides, removing a shared library requirement, absent other trade-offs
seems like a good idea. And I don't know of any other trade-offs, so
here we are.

The keep the diff down, I defined a `match` and `compile` function with
the same interfaces the `pcre-light`, but written in terms of
`regex-pcre` functions. This does add an unused argument, which could be
confusing, so I'm happy to messy the diff in order to address that.

That `regex-pcre` functions are in `IO`, which means we require
`unsafePerformIO`, but this is exactly what the `pcre-light` functions
did internally anyway, so there is no change in safety introduced.

I've left the error handling as `TODO` for now, but can flesh that out
if/when I find this PR has a chance of being accepted.

To get the OS Parser tests to pass, I had to copy the `normalize`
pattern present in the UA parser. I'm not sure if it's intentional to
normalize empty text to `Nothing` for UA but not OS; I hope not.
Both functions now faithfully match the `pcre-light` versions.
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.

1 participant