Switch from pcre to pcre2 (#4684)

The issue at [0] was opened and I just took a stab at it. I have no
prior experience with pcre and pcre2, but using [1,2] I hacked together
something that seems to work. Next, Michael told me to turn that
patch/hack into a PR, so here we are.

The dependency in meson.build now uses version:'>=10', but this is more
a random guess than actual knowledge.

There was a while loop in regex_new() that dealt with an error when pcre
was not compiled with UTF-8 support. This loop uses a magic constant of
32 for the error code. I just dropped this loop, because I was just
writing a hack and did not intend to turn this into a PR. Also, a quick "grep
32 /usr/include/pcre.h" does not find anything useful, so... *shrug*

pcre_study() was removed without replacement, so the corresponding code
is also simply removed.

Testing done: The test suite passes for me. YMMV.

[0]: https://github.com/i3/i3/issues/4682
[1]: https://www.pcre.org/current/doc/html/pcre2api.html
[2]: https://www.pcre.org/current/doc/html/pcre2demo.html

Signed-off-by: Uli Schlachter <psychon@znc.in>
Fixes: https://github.com/i3/i3/issues/4682
This commit is contained in:
Uli Schlachter
2021-11-29 18:20:54 +01:00
committed by GitHub
parent 298c3aede9
commit 6c7efc4de8
3 changed files with 21 additions and 27 deletions

View File

@ -9,11 +9,13 @@
*/
#pragma once
#define PCRE2_CODE_UNIT_WIDTH 8
#define SN_API_NOT_YET_FROZEN 1
#include <libsn/sn-launcher.h>
#include <xcb/randr.h>
#include <pcre.h>
#include <pcre2.h>
#include <sys/time.h>
#include <cairo/cairo.h>
@ -248,8 +250,7 @@ struct Startup_Sequence {
*/
struct regex {
char *pattern;
pcre *regex;
pcre_extra *extra;
pcre2_code *regex;
};
/**