From e3e2f063244804bb147418dc219ba6db8219304b Mon Sep 17 00:00:00 2001 From: Zher Huei Lee Date: Mon, 7 Aug 2017 23:13:15 +0800 Subject: Replacement of internal RegEx with PCRE2 The pattern and replacement matching behaviour has been changed purely due to the nature of switching to a standards-compliant library. One mistake in the previous behaviour was that named groups didn't have a number. This has been corrected. As names are actually just an alias of numbered groups, RegExMatch::get_name_dict() is now get_names() and is a dict referring to the group number it represents. Duplicate names are enabled and the with the first matching instance used. Due the lack of a suitable equivalent in PCRE2, RegExMatch::expand() was removed. --- modules/regex/SCsub | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'modules/regex/SCsub') diff --git a/modules/regex/SCsub b/modules/regex/SCsub index 0882406761..0fbdf97620 100644 --- a/modules/regex/SCsub +++ b/modules/regex/SCsub @@ -1,7 +1,50 @@ #!/usr/bin/env python Import('env') +Import('env_modules') -env.add_source_files(env.modules_sources, "*.cpp") +env_regex = env_modules.Clone() +env_regex.Append(CPPFLAGS=["-DPCRE2_CODE_UNIT_WIDTH=0"]) +env_regex.add_source_files(env.modules_sources, "*.cpp") -Export('env') +if (env['builtin_pcre2'] != 'no'): + thirdparty_dir = "#thirdparty/pcre2/src/" + thirdparty_flags = ["-DPCRE2_STATIC", "-DHAVE_CONFIG_H", "-DSUPPORT_JIT"] + thirdparty_sources = [ + "pcre2_auto_possess.c", + "pcre2_chartables.c", + "pcre2_compile.c", + "pcre2_config.c", + "pcre2_context.c", + "pcre2_dfa_match.c", + "pcre2_error.c", + "pcre2_find_bracket.c", + "pcre2_jit_compile.c", + "pcre2_maketables.c", + "pcre2_match.c", + "pcre2_match_data.c", + "pcre2_newline.c", + "pcre2_ord2utf.c", + "pcre2_pattern_info.c", + "pcre2_serialize.c", + "pcre2_string_utils.c", + "pcre2_study.c", + "pcre2_substitute.c", + "pcre2_substring.c", + "pcre2_tables.c", + "pcre2_ucd.c", + "pcre2_valid_utf.c", + "pcre2_xclass.c", + ] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] + env_regex.Append(CPPPATH=[thirdparty_dir]) + env_regex.Append(CPPFLAGS=thirdparty_flags) + def pcre2_builtin(width): + env_pcre2 = env_modules.Clone() + env_pcre2["OBJSUFFIX"] = "_" + width + env_pcre2["OBJSUFFIX"] + env_pcre2.Append(CPPPATH=[thirdparty_dir]) + env_pcre2.add_source_files(env.modules_sources, thirdparty_sources) + env_pcre2.Append(CPPFLAGS=thirdparty_flags) + env_pcre2.Append(CPPFLAGS=["-DPCRE2_CODE_UNIT_WIDTH=" + width]) + pcre2_builtin("16") + pcre2_builtin("32") -- cgit v1.2.3