1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

LibRegex: Add RegexStringView wrapper to support utf8 and utf32 views

This commit is contained in:
Emanuel Sprung 2020-06-09 00:15:09 +02:00 committed by Andreas Kling
parent 12dd40a2a5
commit 4a630d4b63
11 changed files with 596 additions and 304 deletions

View file

@ -79,7 +79,7 @@ int regcomp(regex_t* reg, const char* pattern, int cflags)
preg->cflags = cflags;
String pattern_str(pattern);
preg->re = make<Regex<PosixExtended>>(pattern_str, PosixOptions {} | (PosixFlags)cflags);
preg->re = make<Regex<PosixExtended>>(pattern_str, PosixOptions {} | (PosixFlags)cflags | PosixFlags::SkipTrimEmptyMatches);
auto parser_result = preg->re->parser_result;
if (parser_result.error != regex::Error::NoError) {
@ -109,9 +109,9 @@ int regexec(const regex_t* reg, const char* string, size_t nmatch, regmatch_t pm
RegexResult result;
if (eflags & REG_SEARCH)
result = preg->re->search({ string }, PosixOptions {} | (PosixFlags)eflags);
result = preg->re->search(string, PosixOptions {} | (PosixFlags)eflags);
else
result = preg->re->match({ string }, PosixOptions {} | (PosixFlags)eflags);
result = preg->re->match(string, PosixOptions {} | (PosixFlags)eflags);
if (result.success) {
auto size = result.matches.size();