Skip to content

Commit

Permalink
lregex: use pcre2 if p flag is given
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Oct 27, 2021
1 parent c30b89a commit 6a8d5b7
Show file tree
Hide file tree
Showing 25 changed files with 270 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cross-compile-android-ndk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
--disable-xml \
--disable-json \
--disable-yaml \
--disable-pcre2 \
CC="$CC" \
CFLAGS="\"$CFLAGS\"" \
CPPFLAGS="\"$CPPFLAGS\"" \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cross-compile-mingw-w64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
--disable-xml \
--disable-json \
--disable-yaml \
--disable-pcre2 \
CC=${{ matrix.target }}-gcc \
CFLAGS='-v' \
AR=${{ matrix.target }}-ar \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing-gnulinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: update package information
run: sudo apt-get -y -o APT::Immediate-Configure=false update
- name: install tools and libraries
run: sudo apt-get -y -o APT::Immediate-Configure=false install valgrind pkg-config automake bash libjansson-dev libyaml-dev libseccomp-dev libxml2-dev gdb python3-docutils
run: sudo apt-get -y -o APT::Immediate-Configure=false install valgrind pkg-config automake bash libjansson-dev libyaml-dev libseccomp-dev libxml2-dev gdb python3-docutils libpcre2-dev
- name: install rubygems and lcov
if: matrix.compiler == 'gcc' && matrix.os == 'ubuntu-20.04'
#run: sudo apt-get -y -o APT::Immediate-Configure=false install rubygems lcov
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: install tools and libraries
run: |
brew upgrade python@3.9 || brew link --overwrite python@3.9
brew install automake pkg-config bash libxml2 jansson libyaml gdb docutils
brew install automake pkg-config bash libxml2 jansson libyaml gdb docutils pcre2
- name: autogen.sh
run: ./autogen.sh
- name: report the version of cc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing-with-vlagrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: update package information
run: sudo apt-get update
- name: install tools and libraries
run: sudo apt-get install valgrind pkg-config automake bash libjansson-dev libyaml-dev libseccomp-dev libxml2-dev gdb
run: sudo apt-get install valgrind pkg-config automake bash libjansson-dev libyaml-dev libseccomp-dev libxml2-dev libpcre2-dev gdb
- name: autogen.sh
run: ./autogen.sh
- name: report the version of cc
Expand Down
9 changes: 9 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ readtags_LDADD = $(GNULIB_LIBS)
dist_readtags_SOURCES += $(READTAGS_DSL_SRCS) $(READTAGS_DSL_HEADS)
endif

if HAVE_PCRE2
PARSER_SRCS += $(PCRE2_SRCS)
PARSER_HEADS += $(PCRE2_HEADS)
endif

if HAVE_LIBXML
PARSER_SRCS += $(XML_SRCS)
PARSER_HEADS += $(XML_HEADS)
Expand Down Expand Up @@ -123,6 +128,7 @@ libctags_a_CFLAGS += $(LIBXML_CFLAGS)
libctags_a_CFLAGS += $(JANSSON_CFLAGS)
libctags_a_CFLAGS += $(LIBYAML_CFLAGS)
libctags_a_CFLAGS += $(SECCOMP_CFLAGS)
libctags_a_CFLAGS += $(PCRE2_CFLAGS)

nodist_libctags_a_SOURCES = $(REPOINFO_HEADS) $(PEG_SRCS) $(PEG_HEADS)
BUILT_SOURCES = $(REPOINFO_HEADS)
Expand Down Expand Up @@ -189,6 +195,7 @@ ctags_LDADD += $(JANSSON_LIBS)
ctags_LDADD += $(LIBYAML_LIBS)
ctags_LDADD += $(SECCOMP_LIBS)
ctags_LDADD += $(ICONV_LIBS)
ctags_LDADD += $(PCRE2_LIBS)
dist_ctags_SOURCES = $(CMDLINE_HEADS) $(CMDLINE_SRCS)

if HOST_MINGW
Expand All @@ -213,6 +220,7 @@ mini_geany_LDADD += $(JANSSON_LIBS)
mini_geany_LDADD += $(LIBYAML_LIBS)
mini_geany_LDADD += $(SECCOMP_LIBS)
mini_geany_LDADD += $(ICONV_LIBS)
mini_geany_LDADD += $(PCRE2_LIBS)
mini_geany_SOURCES = $(MINI_GEANY_HEADS) $(MINI_GEANY_SRCS)

bin_PROGRAMS += optscript
Expand All @@ -226,6 +234,7 @@ optscript_LDADD += $(JANSSON_LIBS)
optscript_LDADD += $(LIBYAML_LIBS)
optscript_LDADD += $(SECCOMP_LIBS)
optscript_LDADD += $(ICONV_LIBS)
optscript_LDADD += $(PCRE2_LIBS)
optscript_SOURCES = $(OPTSCRIPT_SRCS)

if INSTALL_ETAGS
Expand Down
4 changes: 4 additions & 0 deletions Tmain/list-mline-regex-flags.d/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@

CTAGS=$1

. ../utils.sh

is_feature_available ${CTAGS} pcre2

${CTAGS} --quiet --options=NONE --list-mline-regex-flags
1 change: 1 addition & 0 deletions Tmain/list-mline-regex-flags.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
b basic interpreted as a Posix basic regular expression.
e extend interpreted as a Posix extended regular expression (default)
i icase applied in a case-insensitive manner
p pcre2 use pcre2 regex engine
- fatal="MESSAGE" print the given MESSAGE and exit
- mgroup=N a group in pattern determining the line number of tag
- warning="MESSAGE" print the given MESSAGE at WARNING level
Expand Down
4 changes: 4 additions & 0 deletions Tmain/list-mtable-regex-flags.d/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@

CTAGS=$1

. ../utils.sh

is_feature_available ${CTAGS} pcre2

${CTAGS} --quiet --options=NONE --_list-mtable-regex-flags
1 change: 1 addition & 0 deletions Tmain/list-mtable-regex-flags.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
b basic interpreted as a Posix basic regular expression.
e extend interpreted as a Posix extended regular expression (default)
i icase applied in a case-insensitive manner
p pcre2 use pcre2 regex engine
- fatal="MESSAGE" print the given MESSAGE and exit
- mgroup=N a group in pattern determining the line number of tag
- placeholder don't put this tag to tags file.
Expand Down
4 changes: 4 additions & 0 deletions Tmain/list-regex-flags.d/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@

CTAGS=$1

. ../utils.sh

is_feature_available ${CTAGS} pcre2

${CTAGS} --quiet --options=NONE --list-regex-flags
1 change: 1 addition & 0 deletions Tmain/list-regex-flags.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
b basic interpreted as a Posix basic regular expression.
e extend interpreted as a Posix extended regular expression (default)
i icase applied in a case-insensitive manner
p pcre2 use pcre2 regex engine
x exclusive skip testing the other patterns if a line is matched to this pattern
- fatal="MESSAGE" print the given MESSAGE and exit
- placeholder don't put this tag to tags file.
Expand Down
14 changes: 14 additions & 0 deletions Units/pcre2-single-line.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--langdef=Foo
--map-Foo=.foo
--kinddef-Foo=d,def,definitions
--kinddef-Foo=v,var,variables
--kinddef-Foo=f,func,functions
--kinddef-Foo=m,macro,macros
--kinddef-Foo=p,pkg,packages


--regex-Foo=/def\s+(\W)(\w+)\1/\2/d/p
--regex-Foo=/var\s+(\W)(\w+)\1/\2/v/{pcre2}
--regex-Foo=/func\s+["']?(.+?)['"]?$/\1/f/pi
--regex-Foo=/macro\s+["']?(.+?)['"]?$/\1/m/{pcre2}{icase}
--regex-Foo=/package\s+["']?(.+?)['"]?$/\1/p/i{pcre2}
9 changes: 9 additions & 0 deletions Units/pcre2-single-line.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
P0 input.foo /^package P0$/;" p
abc input.foo /^var "abc"$/;" v
capture_me_in_bar input.foo /^def |capture_me_in_bar|$/;" d
capture_me_in_slash input.foo /^def \/capture_me_in_slash\/$/;" d
f0 input.foo /^func 'f0'$/;" f
f1 input.foo /^func "f1"$/;" f
f2 input.foo /^func f2$/;" f
f3 input.foo /^FunC f3$/;" f
m0 input.foo /^macro m0$/;" m
1 change: 1 addition & 0 deletions Units/pcre2-single-line.d/features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pcre2
10 changes: 10 additions & 0 deletions Units/pcre2-single-line.d/input.foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def |capture_me_in_bar|
def {dont_capture_me}
def /capture_me_in_slash/
var "abc"
func 'f0'
func "f1"
func f2
FunC f3
macro m0
package P0
18 changes: 9 additions & 9 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- run:
name: Install build tools
command: |
dnf -y install gcc automake autoconf pkgconfig make libseccomp-devel libxml2-devel jansson-devel libyaml-devel findutils diffutils sudo
dnf -y install gcc automake autoconf pkgconfig make libseccomp-devel libxml2-devel jansson-devel libyaml-devel pcre2-devel findutils diffutils sudo
dnf -y install jq puppet python3-sphinx
- run:
name: Build
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
- run:
name: Install build tools
command: |
dnf -y install gcc automake autoconf pkgconfig make libseccomp-devel libxml2-devel jansson-devel libyaml-devel findutils diffutils sudo
dnf -y install gcc automake autoconf pkgconfig make libseccomp-devel libxml2-devel jansson-devel libyaml-devel pcre2-devel findutils diffutils sudo
dnf -y install jq puppet
- run:
name: Build
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
- run:
name: Install build tools
command: |
dnf -y install gcc automake autoconf pkgconfig bmake libseccomp-devel libxml2-devel jansson-devel libyaml-devel findutils sudo
dnf -y install gcc automake autoconf pkgconfig bmake libseccomp-devel libxml2-devel jansson-devel libyaml-devel pcre2-devel findutils sudo
dnf -y install jq puppet
- run:
name: Build
Expand All @@ -116,7 +116,7 @@ jobs:
- run:
name: Install build tools
command: |
dnf -y install gcc automake autoconf pkgconfig bmake libseccomp-devel libxml2-devel jansson-devel libyaml-devel findutils sudo
dnf -y install gcc automake autoconf pkgconfig bmake libseccomp-devel libxml2-devel jansson-devel libyaml-devel pcre2-devel findutils sudo
dnf -y install jq puppet
- run:
name: Build
Expand All @@ -142,7 +142,7 @@ jobs:
- run:
name: Install build tools
command: |
dnf -y install gcc automake autoconf pkgconfig make libseccomp-devel libxml2-devel jansson-devel libyaml-devel findutils diffutils sudo
dnf -y install gcc automake autoconf pkgconfig make libseccomp-devel libxml2-devel jansson-devel libyaml-devel findutils diffutils sudo pcre2-devel
dnf -y install jq puppet python3-docutils
- run:
name: Run autogen.sh
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
- run:
name: Install build tools
command: |
yum -y --enablerepo=powertools install python3 gcc automake autoconf pkgconfig make libxml2-devel jansson-devel libyaml-devel findutils diffutils sudo
yum -y --enablerepo=powertools install python3 gcc automake autoconf pkgconfig make libxml2-devel jansson-devel libyaml-devel pcre2-devel findutils diffutils sudo
- run:
name: Build
command: |
Expand All @@ -200,7 +200,7 @@ jobs:
- run:
name: Install build tools
command: |
yum -y --enablerepo=powertools install python3 gcc automake autoconf pkgconfig make libxml2-devel jansson-devel libyaml-devel findutils diffutils sudo
yum -y --enablerepo=powertools install python3 gcc automake autoconf pkgconfig make libxml2-devel jansson-devel libyaml-devel pcre2-devel findutils diffutils sudo
- run:
name: Build
command: |
Expand All @@ -224,7 +224,7 @@ jobs:
- run:
name: Install build tools
command: |
yum -y install python3 gcc automake autoconf pkgconfig make libxml2-devel jansson-devel libyaml-devel findutils diffutils sudo
yum -y install python3 gcc automake autoconf pkgconfig make libxml2-devel jansson-devel libyaml-devel pcre2-devel findutils diffutils sudo
- run:
name: Build
command: |
Expand All @@ -249,7 +249,7 @@ jobs:
- run:
name: Install build tools
command: |
yum -y install gcc automake autoconf pkgconfig make libxml2-devel jansson-devel libyaml-devel findutils diffutils sudo
yum -y install gcc automake autoconf pkgconfig make libxml2-devel jansson-devel libyaml-devel pcre2-devel findutils diffutils sudo
- run:
name: Build
command: |
Expand Down
14 changes: 14 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,20 @@ AS_IF([test "x$enable_yaml" != "xno"], [
])
AM_CONDITIONAL(HAVE_LIBYAML, test "x$have_libyaml" = xyes)

AC_ARG_ENABLE([pcre2],
[AS_HELP_STRING([--disable-pcre2],
[disable pcre2 support])])

AH_TEMPLATE([HAVE_PCRE2],
[Define this value if pcre2 is available.])
AS_IF([test "x$enable_pcre2" != "xno"], [
PKG_CHECK_MODULES(PCRE2, libpcre2-8,
[have_libpcre2_8=yes
AC_DEFINE(HAVE_PCRE2)],
[AS_IF([test "x$enable_pcre2" = "xyes"], [
AC_MSG_ERROR([libpcre2-8 not found])])])
])
AM_CONDITIONAL(HAVE_PCRE2, test "x$have_libpcre2_8" = xyes)

# Checks for missing prototypes
# -----------------------------
Expand Down
Loading

0 comments on commit 6a8d5b7

Please sign in to comment.