From f89c6245d454fd9dc5a96754a8bfc05af3cdd808 Mon Sep 17 00:00:00 2001 From: Brian Dentino Date: Tue, 10 Jan 2023 15:14:31 -0400 Subject: [PATCH] Add option to build with ruby-like capture group names --- CMakeLists.txt | 5 +++++ dockerfiles/Dockerfile | 1 + lib/onigmo/CMakeLists.txt | 15 ++++++++++----- lib/onigmo/regparse.c | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1728acc7791..bd2fb73a050 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,7 @@ option(FLB_SMALL "Optimise for small size" No) option(FLB_COVERAGE "Build with code-coverage" No) option(FLB_JEMALLOC "Build with Jemalloc support" No) option(FLB_REGEX "Build with Regex support" Yes) +option(FLB_REGEX_RUBY "Build with ruby regex capture name support" No) option(FLB_UTF8_ENCODER "Build with UTF8 encoding support" Yes) option(FLB_PARSER "Build with Parser support" Yes) option(FLB_TLS "Build with SSL/TLS support" Yes) @@ -959,6 +960,10 @@ if(FLB_REGEX) add_subdirectory(${FLB_PATH_LIB_ONIGMO} EXCLUDE_FROM_ALL) endif() +if(FLB_REGEX_RUBY) + option(ONIGMO_RUBY_REGEX_NAMES ON) +endif() + # tutf8e (UTF8 Encoding) # ===================== if(FLB_UTF8_ENCODER) diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index 7f555564f19..54063a02532 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -76,6 +76,7 @@ RUN cmake -DFLB_RELEASE=On \ -DFLB_NIGHTLY_BUILD="$FLB_NIGHTLY_BUILD" \ -DFLB_LOG_NO_CONTROL_CHARS=On \ -DFLB_CHUNK_TRACE="$FLB_CHUNK_TRACE" \ + -DFLB_REGEX_RUBY=On \ .. RUN make -j "$(getconf _NPROCESSORS_ONLN)" diff --git a/lib/onigmo/CMakeLists.txt b/lib/onigmo/CMakeLists.txt index 4a3b30d7da1..c2d73640494 100644 --- a/lib/onigmo/CMakeLists.txt +++ b/lib/onigmo/CMakeLists.txt @@ -84,11 +84,12 @@ set(PACKAGE_URL "") # Build Options option(USE_COMBINATION_EXPLOSION_CHECK "Enable combination explosion check" No) option(USE_CRNL_AS_LINE_TERMINATOR "Enable CR+NL as line terminator" No) -option(ONIGMO_SHARED_LIB "Enable to build shared library" Yes) -option(ONIGMO_CTESTS "Enable testing with ctest" Yes) -option(ONIGMO_CTESTS_SAMPLE "Enable testing with ctest on sample" Yes) -option(ONIGMO_PYTHON_TESTS "Enable testing with python tests" Yes) -option(ONIGMO_MACOS_DEFAULTS "Build with predefined macOS settings" Yes) +option(ONIGMO_RUBY_REGEX_NAMES "Enable ruby-like named capture groups" No) +option(ONIGMO_SHARED_LIB "Enable to build shared library" Yes) +option(ONIGMO_CTESTS "Enable testing with ctest" Yes) +option(ONIGMO_CTESTS_SAMPLE "Enable testing with ctest on sample" Yes) +option(ONIGMO_PYTHON_TESTS "Enable testing with python tests" Yes) +option(ONIGMO_MACOS_DEFAULTS "Build with predefined macOS settings" Yes) if(USE_COMBINATION_EXPLOSION_CHECK) add_definitions(-DUSE_COMBINATION_EXPLOSION_CHECK=1) @@ -267,6 +268,10 @@ if(ONIGMO_SHARED_LIB) RUNTIME DESTINATION ${ONIGMO_INSTALL_BINDIR}) endif() +if(ONIGMO_RUBY_REGEX_NAMES) + add_definitions(-DRUBY_CODE_NAME) +endif() + # Test Source if(ONIGMO_CTESTS) diff --git a/lib/onigmo/regparse.c b/lib/onigmo/regparse.c index 49b7e9c841d..adb2fb341a6 100644 --- a/lib/onigmo/regparse.c +++ b/lib/onigmo/regparse.c @@ -2506,7 +2506,7 @@ get_name_end_code_point(OnigCodePoint start) } #ifdef USE_NAMED_GROUP -# ifdef RUBY +# if defined(RUBY) || defined(RUBY_CODE_NAME) # define ONIGENC_IS_CODE_NAME(enc, c) TRUE # else # define ONIGENC_IS_CODE_NAME(enc, c) ONIGENC_IS_CODE_WORD(enc, c)