Create dummy framework for all functions and programs.

This commit is contained in:
Philip.Hazel 2014-03-07 17:28:52 +00:00
parent 0fd300bf87
commit f4174bab90
30 changed files with 3769 additions and 821 deletions

View File

@ -3,6 +3,9 @@
AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = -I m4
## Specify the documentation files that are distributed.
# FIXME
#dist_doc_DATA = \
# doc/pcre.txt \
@ -72,6 +75,59 @@ ACLOCAL_AMFLAGS = -I m4
# doc/html/pcretest.html \
# doc/html/pcreunicode.html
# FIXME
#dist_man_MANS = \
# doc/pcre2-config.1 \
# doc/pcre2.3 \
# doc/pcre2-16.3 \
# doc/pcre2-32.3 \
# doc/pcre2_assign_jit_stack.3 \
# doc/pcre2_compile.3 \
# doc/pcre2_compile2.3 \
# doc/pcre2_config.3 \
# doc/pcre2_copy_named_substring.3 \
# doc/pcre2_copy_substring.3 \
# doc/pcre2_dfa_exec.3 \
# doc/pcre2_exec.3 \
# doc/pcre2_free_study.3 \
# doc/pcre2_free_substring.3 \
# doc/pcre2_free_substring_list.3 \
# doc/pcre2_fullinfo.3 \
# doc/pcre2_get_named_substring.3 \
# doc/pcre2_get_stringnumber.3 \
# doc/pcre2_get_stringtable_entries.3 \
# doc/pcre2_get_substring.3 \
# doc/pcre2_get_substring_list.3 \
# doc/pcre2_jit_exec.3 \
# doc/pcre2_jit_stack_alloc.3 \
# doc/pcre2_jit_stack_free.3 \
# doc/pcre2_maketables.3 \
# doc/pcre2_pattern_to_host_byte_order.3 \
# doc/pcre2_refcount.3 \
# doc/pcre2_study.3 \
# doc/pcre2_utf16_to_host_byte_order.3 \
# doc/pcre2_utf32_to_host_byte_order.3 \
# doc/pcre2_version.3 \
# doc/pcre2api.3 \
# doc/pcre2build.3 \
# doc/pcre2callout.3 \
# doc/pcre2compat.3 \
# doc/pcre2demo.3 \
# doc/pcre2grep.1 \
# doc/pcre2jit.3 \
# doc/pcre2limits.3 \
# doc/pcre2matching.3 \
# doc/pcre2partial.3 \
# doc/pcre2pattern.3 \
# doc/pcre2perform.3 \
# doc/pcre2posix.3 \
# doc/pcre2precompile.3 \
# doc/pcre2sample.3 \
# doc/pcre2stack.3 \
# doc/pcre2syntax.3 \
# doc/pcre2test.1 \
# doc/pcre2unicode.3
# The Libtool libraries to install. We'll add to this later.
lib_LTLIBRARIES =
@ -147,7 +203,7 @@ src/pcre2.h.generic: src/pcre2.h.in configure.ac
# resulting config.h is munged by perl to put #ifdefs round any #defines for
# macros with values, and to #undef all boolean macros such as HAVE_xxx and
# SUPPORT_xxx. We also get rid of any gcc-specific visibility settings. Make
# sure that PCRE_EXP_DEFN is unset (in case it has visibility settings).
# sure that PCRE2_EXP_DEFN is unset (in case it has visibility settings).
src/config.h.generic: configure.ac
rm -rf $@ _generic
@ -173,11 +229,8 @@ MAINTAINERCLEANFILES += src/pcre2.h.generic src/config.h.generic
# These are the header files we'll install. We do not distribute pcre2.h
# because it is generated from pcre2.h.in.
nodist_include_HEADERS = \
src/pcre2.h
#FIXME
#include_HEADERS = \
# src/pcre2posix.h
nodist_include_HEADERS = src/pcre2.h
include_HEADERS = src/pcre2posix.h
# This is the "config" script.
@ -204,33 +257,37 @@ endif # WITH_REBUILD_CHARTABLES
BUILT_SOURCES = src/pcre2_chartables.c
NODIST_SOURCES = src/pcre2_chartables.c
## Define the list of common sources, then build whichever of the 8-, 16-, or
## 32-bit libraries are configured.
## Define the list of common sources, then arrange to build whichever of the
## 8-, 16-, or 32-bit libraries are configured.
COMMON_SOURCES = \
src/pcre2_byte_order.c \
src/pcre2_compile.c \
src/pcre2_config.c \
src/pcre2_context.c \
src/pcre2_dfa_exec.c \
src/pcre2_error.c \
src/pcre2_exec.c \
src/pcre2_internal.h \
src/pcre2_jit_compile.c \
src/pcre2_jit_exec.c \
src/pcre2_jit_misc.c \
src/pcre2_maketables.c \
src/pcre2_match_data.c \
src/pcre2_pattern_info.c \
src/pcre2_substring.c \
src/pcre2_version.c
# pcre2_byte_order.c \
# pcre2_compile.c \
# pcre2_config.c \
# pcre2_dfa_exec.c \
# pcre2_exec.c \
# pcre2_fullinfo.c \
# pcre2_get.c \
# pcre2_globals.c \
# pcre2_jit_compile.c \
# pcre2_maketables.c \
# pcre2_newline.c \
# pcre2_ord2utf8.c \
# pcre2_refcount.c \
# pcre2_string_utils.c \
# pcre2_study.c \
# pcre2_tables.c \
# pcre2_ucd.c \
# pcre2_valid_utf8.c \
# pcre2_xclass.c \
# ucp.h
# src/pcre2_newline.c \
# src/pcre2_ord2utf8.c \
# src/pcre2_refcount.c \
# src/pcre2_string_utils.c \
# src/pcre2_study.c \
# src/pcre2_tables.c \
# src/pcre2_ucd.c \
# src/pcre2_valid_utf8.c \
# src/pcre2_xclass.c \
# src/ucp.h
if WITH_PCRE8
@ -240,7 +297,7 @@ libpcre2_8_la_SOURCES = \
nodist_libpcre2_8_la_SOURCES = \
$(NODIST_SOURCES)
libpcre2_8_la_CFLAGS = \
-DPCRE2_DATA_WIDTH=8 \
-DPCRE2_CODE_UNIT_WIDTH=8 \
$(VISIBILITY_CFLAGS) \
$(AM_CFLAGS)
libpcre2_8_la_LIBADD =
@ -253,7 +310,7 @@ libpcre2_16_la_SOURCES = \
nodist_libpcre2_16_la_SOURCES = \
$(NODIST_SOURCES)
libpcre2_16_la_CFLAGS = \
-DPCRE2_DATA_WIDTH=16 \
-DPCRE2_CODE_UNIT_WIDTH=16 \
$(VISIBILITY_CFLAGS) \
$(AM_CFLAGS)
libpcre2_16_la_LIBADD =
@ -266,7 +323,7 @@ libpcre2_32_la_SOURCES = \
nodist_libpcre2_32_la_SOURCES = \
$(NODIST_SOURCES)
libpcre2_32_la_CFLAGS = \
-DPCRE2_DATA_WIDTH=32 \
-DPCRE2_CODE_UNIT_WIDTH=32 \
$(VISIBILITY_CFLAGS) \
$(AM_CFLAGS)
libpcre2_32_la_LIBADD =
@ -276,6 +333,7 @@ endif # WITH_PCRE32
# pcre2_chartables.c, used unless --enable-rebuild-chartables is specified.
EXTRA_DIST += src/pcre2_chartables.c.dist
CLEANFILES += src/pcre2_chartables.c
# The JIT compiler lives in a separate directory, but its files are #included
# when pcre2_jit_compile.c is processed, so they must be distributed.
@ -337,7 +395,36 @@ libpcre2_32_la_CFLAGS += $(GCOV_CFLAGS)
endif # WITH_PCRE32
endif # WITH_GCOV
CLEANFILES += src/pcre2_chartables.c
## A version of the 8-bit library that has a POSIX API.
if WITH_PCRE8
lib_LTLIBRARIES += libpcre2-posix.la
libpcre2_posix_la_SOURCES = src/pcre2posix.c
libpcre2_posix_la_CFLAGS = \
-DPCRE2_CODE_UNIT_WIDTH=8 \
$(VISIBILITY_CFLAGS) $(AM_CFLAGS)
libpcre2_posix_la_LDFLAGS = $(EXTRA_LIBPCRE2_POSIX_LDFLAGS)
libpcre2_posix_la_LIBADD = libpcre2-8.la
if WITH_GCOV
libpcre2_posix_la_CFLAGS += $(GCOV_CFLAGS)
endif # WITH_GCOV
endif # WITH_PCRE8
## Build pcre2grep if the 8-bit library is enabled
if WITH_PCRE8
bin_PROGRAMS += pcre2grep
pcre2grep_SOURCES = src/pcre2grep.c
pcre2grep_CFLAGS = $(AM_CFLAGS)
pcre2grep_LDADD = $(LIBZ) $(LIBBZ2)
pcre2grep_LDADD += libpcre2-8.la
if WITH_GCOV
pcre2grep_CFLAGS += $(GCOV_CFLAGS)
pcre2grep_LDADD += $(GCOV_LIBS)
endif # WITH_GCOV
endif # WITH_PCRE8
## -------- Testing ----------
## If JIT support is enabled, arrange for the JIT test program to run.
@ -362,70 +449,55 @@ pcre2_jit_test_LDADD += $(GCOV_LIBS)
endif # WITH_GCOV
endif # WITH_JIT
## A version of the 8-bit library that has a POSIX API.
# Build the general pcre2test program. The file src/pcre2_printint.c is
# #included by pcre2test as many times as needed, at different code unit
# widths.
# FIXME
#if WITH_PCRE8
#lib_LTLIBRARIES += libpcre2posix.la
#libpcre2posix_la_SOURCES = pcre2posix.c
#libpcre2posix_la_CFLAGS = $(VISIBILITY_CFLAGS) $(AM_CFLAGS)
#libpcre2posix_la_LDFLAGS = $(EXTRA_LIBPCREPOSIX_LDFLAGS)
#libpcre2posix_la_LIBADD = libpcre2-8.la
#if WITH_GCOV
#libpcre2posix_la_CFLAGS += $(GCOV_CFLAGS)
#endif # WITH_GCOV
#endif # WITH_PCRE8
bin_PROGRAMS += pcre2test
EXTRA_DIST += src/pcre2_printint.c
pcre2test_SOURCES = src/pcre2test.c
pcre2test_CFLAGS = $(AM_CFLAGS)
pcre2test_LDADD = $(LIBREADLINE)
## The main unit tests
if WITH_PCRE8
pcre2test_LDADD += libpcre2-8.la libpcre2-posix.la
endif # WITH_PCRE8
# Each unit test is a binary plus a script that runs that binary in various
# ways. We install these test binaries in case folks find it helpful.
if WITH_PCRE16
pcre2test_LDADD += libpcre2-16.la
endif # WITH_PCRE16
if WITH_PCRE32
pcre2test_LDADD += libpcre2-32.la
endif # WITH_PCRE32
if WITH_VALGRIND
pcre2test_CFLAGS += $(VALGRIND_CFLAGS)
endif # WITH_VALGRIND
if WITH_GCOV
pcre2test_CFLAGS += $(GCOV_CFLAGS)
pcre2test_LDADD += $(GCOV_LIBS)
endif # WITH_GCOV
## The main library tests. Each test is a binary plus a script that runs that
## binary in various ways. We install these test binaries in case folks find it
## helpful.
# FIXME
#TESTS += RunTest
#dist_noinst_SCRIPTS += RunTest
#EXTRA_DIST += RunTest.bat
#bin_PROGRAMS += pcretest
#pcretest_SOURCES = pcretest.c
#pcretest_CFLAGS = $(AM_CFLAGS)
#pcretest_LDADD = $(LIBREADLINE)
#if WITH_PCRE8
#pcretest_SOURCES += pcre2_printint.c
#pcretest_LDADD += libpcre2-8.la libpcre2posix.la
#endif # WITH_PCRE8
#
## FIXME
##if WITH_PCRE16
##pcretest_SOURCES += pcre16_printint.c
##pcretest_LDADD += libpcre2-16.la
##endif # WITH_PCRE16
##if WITH_PCRE32
##pcretest_SOURCES += pcre32_printint.c
##pcretest_LDADD += libpcre2-32.la
##endif # WITH_PCRE32
#
#if WITH_VALGRIND
#pcretest_CFLAGS += $(VALGRIND_CFLAGS)
#endif # WITH_VALGRIND
#if WITH_GCOV
#pcretest_CFLAGS += $(GCOV_CFLAGS)
#pcretest_LDADD += $(GCOV_LIBS)
#endif # WITH_GCOV
#
#if WITH_PCRE8
## When the 8-bit library is configured, pcre2grep will have been built.
#if WIDH_PCRE8
#TESTS += RunGrepTest
#dist_noinst_SCRIPTS += RunGrepTest
#bin_PROGRAMS += pcregrep
#pcregrep_SOURCES = pcregrep.c
#pcregrep_CFLAGS = $(AM_CFLAGS)
#pcregrep_LDADD = $(LIBZ) $(LIBBZ2)
#pcregrep_LDADD += libpcre2-8.la
#if WITH_GCOV
#pcregrep_CFLAGS += $(GCOV_CFLAGS)
#pcregrep_LDADD += $(GCOV_LIBS)
#endif # WITH_GCOV
#endif # WITH_PCRE8
## Distribute all the test data files
EXTRA_DIST += \
testdata/grepbinary \
testdata/grepfilelist \
@ -521,139 +593,33 @@ CLEANFILES += \
testtemp* \
testtry \
testNinput
## ------------ End of testing -------------
# PCRE demonstration program. No longer built automatcally. The point is that
# the users should build it themselves. So just distribute the source.
# PCRE demonstration program. Not built automatcally. The point is that the
# users should build it themselves. So just distribute the source.
EXTRA_DIST += src/pcre2demo.c
## Utility rules, documentation, etc.
# We have .pc files for pkg-config users.
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA =
if WITH_PCRE8
pkgconfig_DATA += libpcre2-8.pc libpcre2posix.pc
pkgconfig_DATA += libpcre2-8.pc libpcre2-posix.pc
endif
if WITH_PCRE16
pkgconfig_DATA += libpcre2-16.pc
endif
if WITH_PCRE32
pkgconfig_DATA += libpcre2-32.pc
endif
# FIXME
#dist_man_MANS = \
# doc/pcre2-config.1 \
# doc/pcre2.3 \
# doc/pcre2-16.3 \
# doc/pcre2-32.3 \
# doc/pcre2_assign_jit_stack.3 \
# doc/pcre2_compile.3 \
# doc/pcre2_compile2.3 \
# doc/pcre2_config.3 \
# doc/pcre2_copy_named_substring.3 \
# doc/pcre2_copy_substring.3 \
# doc/pcre2_dfa_exec.3 \
# doc/pcre2_exec.3 \
# doc/pcre2_free_study.3 \
# doc/pcre2_free_substring.3 \
# doc/pcre2_free_substring_list.3 \
# doc/pcre2_fullinfo.3 \
# doc/pcre2_get_named_substring.3 \
# doc/pcre2_get_stringnumber.3 \
# doc/pcre2_get_stringtable_entries.3 \
# doc/pcre2_get_substring.3 \
# doc/pcre2_get_substring_list.3 \
# doc/pcre2_jit_exec.3 \
# doc/pcre2_jit_stack_alloc.3 \
# doc/pcre2_jit_stack_free.3 \
# doc/pcre2_maketables.3 \
# doc/pcre2_pattern_to_host_byte_order.3 \
# doc/pcre2_refcount.3 \
# doc/pcre2_study.3 \
# doc/pcre2_utf16_to_host_byte_order.3 \
# doc/pcre2_utf32_to_host_byte_order.3 \
# doc/pcre2_version.3 \
# doc/pcre2api.3 \
# doc/pcre2build.3 \
# doc/pcre2callout.3 \
# doc/pcre2compat.3 \
# doc/pcre2demo.3 \
# doc/pcre2grep.1 \
# doc/pcre2jit.3 \
# doc/pcre2limits.3 \
# doc/pcre2matching.3 \
# doc/pcre2partial.3 \
# doc/pcre2pattern.3 \
# doc/pcre2perform.3 \
# doc/pcre2posix.3 \
# doc/pcre2precompile.3 \
# doc/pcre2sample.3 \
# doc/pcre2stack.3 \
# doc/pcre2syntax.3 \
# doc/pcre2test.1 \
# doc/pcre2unicode.3
# FIXME
# Arrange for the per-function man pages to have 16- and 32-bit names as well.
#install-data-hook:
# ln -sf pcre_assign_jit_stack.3 $(DESTDIR)$(man3dir)/pcre16_assign_jit_stack.3
# ln -sf pcre_compile.3 $(DESTDIR)$(man3dir)/pcre16_compile.3
# ln -sf pcre_compile2.3 $(DESTDIR)$(man3dir)/pcre16_compile2.3
# ln -sf pcre_config.3 $(DESTDIR)$(man3dir)/pcre16_config.3
# ln -sf pcre_copy_named_substring.3 $(DESTDIR)$(man3dir)/pcre16_copy_named_substring.3
# ln -sf pcre_copy_substring.3 $(DESTDIR)$(man3dir)/pcre16_copy_substring.3
# ln -sf pcre_dfa_exec.3 $(DESTDIR)$(man3dir)/pcre16_dfa_exec.3
# ln -sf pcre_exec.3 $(DESTDIR)$(man3dir)/pcre16_exec.3
# ln -sf pcre_free_study.3 $(DESTDIR)$(man3dir)/pcre16_free_study.3
# ln -sf pcre_free_substring.3 $(DESTDIR)$(man3dir)/pcre16_free_substring.3
# ln -sf pcre_free_substring_list.3 $(DESTDIR)$(man3dir)/pcre16_free_substring_list.3
# ln -sf pcre_fullinfo.3 $(DESTDIR)$(man3dir)/pcre16_fullinfo.3
# ln -sf pcre_get_named_substring.3 $(DESTDIR)$(man3dir)/pcre16_get_named_substring.3
# ln -sf pcre_get_stringnumber.3 $(DESTDIR)$(man3dir)/pcre16_get_stringnumber.3
# ln -sf pcre_get_stringtable_entries.3 $(DESTDIR)$(man3dir)/pcre16_get_stringtable_entries.3
# ln -sf pcre_get_substring.3 $(DESTDIR)$(man3dir)/pcre16_get_substring.3
# ln -sf pcre_get_substring_list.3 $(DESTDIR)$(man3dir)/pcre16_get_substring_list.3
# ln -sf pcre_jit_exec.3 $(DESTDIR)$(man3dir)/pcre16_jit_exec.3
# ln -sf pcre_jit_stack_alloc.3 $(DESTDIR)$(man3dir)/pcre16_jit_stack_alloc.3
# ln -sf pcre_jit_stack_free.3 $(DESTDIR)$(man3dir)/pcre16_jit_stack_free.3
# ln -sf pcre_maketables.3 $(DESTDIR)$(man3dir)/pcre16_maketables.3
# ln -sf pcre_pattern_to_host_byte_order.3 $(DESTDIR)$(man3dir)/pcre16_pattern_to_host_byte_order.3
# ln -sf pcre_refcount.3 $(DESTDIR)$(man3dir)/pcre16_refcount.3
# ln -sf pcre_study.3 $(DESTDIR)$(man3dir)/pcre16_study.3
# ln -sf pcre_utf16_to_host_byte_order.3 $(DESTDIR)$(man3dir)/pcre16_utf16_to_host_byte_order.3
# ln -sf pcre_version.3 $(DESTDIR)$(man3dir)/pcre16_version.3
# ln -sf pcre_assign_jit_stack.3 $(DESTDIR)$(man3dir)/pcre32_assign_jit_stack.3
# ln -sf pcre_compile.3 $(DESTDIR)$(man3dir)/pcre32_compile.3
# ln -sf pcre_compile2.3 $(DESTDIR)$(man3dir)/pcre32_compile2.3
# ln -sf pcre_config.3 $(DESTDIR)$(man3dir)/pcre32_config.3
# ln -sf pcre_copy_named_substring.3 $(DESTDIR)$(man3dir)/pcre32_copy_named_substring.3
# ln -sf pcre_copy_substring.3 $(DESTDIR)$(man3dir)/pcre32_copy_substring.3
# ln -sf pcre_dfa_exec.3 $(DESTDIR)$(man3dir)/pcre32_dfa_exec.3
# ln -sf pcre_exec.3 $(DESTDIR)$(man3dir)/pcre32_exec.3
# ln -sf pcre_free_study.3 $(DESTDIR)$(man3dir)/pcre32_free_study.3
# ln -sf pcre_free_substring.3 $(DESTDIR)$(man3dir)/pcre32_free_substring.3
# ln -sf pcre_free_substring_list.3 $(DESTDIR)$(man3dir)/pcre32_free_substring_list.3
# ln -sf pcre_fullinfo.3 $(DESTDIR)$(man3dir)/pcre32_fullinfo.3
# ln -sf pcre_get_named_substring.3 $(DESTDIR)$(man3dir)/pcre32_get_named_substring.3
# ln -sf pcre_get_stringnumber.3 $(DESTDIR)$(man3dir)/pcre32_get_stringnumber.3
# ln -sf pcre_get_stringtable_entries.3 $(DESTDIR)$(man3dir)/pcre32_get_stringtable_entries.3
# ln -sf pcre_get_substring.3 $(DESTDIR)$(man3dir)/pcre32_get_substring.3
# ln -sf pcre_get_substring_list.3 $(DESTDIR)$(man3dir)/pcre32_get_substring_list.3
# ln -sf pcre_jit_exec.3 $(DESTDIR)$(man3dir)/pcre32_jit_exec.3
# ln -sf pcre_jit_stack_alloc.3 $(DESTDIR)$(man3dir)/pcre32_jit_stack_alloc.3
# ln -sf pcre_jit_stack_free.3 $(DESTDIR)$(man3dir)/pcre32_jit_stack_free.3
# ln -sf pcre_maketables.3 $(DESTDIR)$(man3dir)/pcre32_maketables.3
# ln -sf pcre_pattern_to_host_byte_order.3 $(DESTDIR)$(man3dir)/pcre32_pattern_to_host_byte_order.3
# ln -sf pcre_refcount.3 $(DESTDIR)$(man3dir)/pcre32_refcount.3
# ln -sf pcre_study.3 $(DESTDIR)$(man3dir)/pcre32_study.3
# ln -sf pcre_utf32_to_host_byte_order.3 $(DESTDIR)$(man3dir)/pcre32_utf32_to_host_byte_order.3
# ln -sf pcre_version.3 $(DESTDIR)$(man3dir)/pcre32_version.3
# gcov/lcov code coverage reporting
#

View File

@ -17,10 +17,10 @@ m4_define(pcre2_date, [2014-99-99])
# 50 lines of this file. Please update that if the variables above are moved.
# Libtool shared library interface versions (current:revision:age)
m4_define(libpcre2-8_version, [0:0:0])
m4_define(libpcre2-16_version, [0:0:0])
m4_define(libpcre2-32_version, [0:0:0])
m4_define(libpcre2posix_version, [0:0:0])
m4_define(libpcre2_8_version, [0:0:0])
m4_define(libpcre2_16_version, [0:0:0])
m4_define(libpcre2_32_version, [0:0:0])
m4_define(libpcre2_posix_version, [0:0:0])
AC_PREREQ(2.57)
AC_INIT(PCRE2, pcre2_major.pcre2_minor[]pcre2_prerelease, , pcre2)
@ -300,16 +300,15 @@ then
enable_utf=no
fi
# Convert the newline identifier into the appropriate integer value. The first
# three are ASCII values 0x0a, 0x0d, and 0x0d0a, but if EBCDIC is enabled, they
# are changed below.
# Convert the newline identifier into the appropriate integer value. These must
# agree with the PCRE2_NEWLINE_xxx values in pcre2.h.
case "$enable_newline" in
lf) ac_pcre_newline_value=10 ;;
cr) ac_pcre_newline_value=13 ;;
crlf) ac_pcre_newline_value=3338 ;;
anycrlf) ac_pcre_newline_value=-2 ;;
any) ac_pcre_newline_value=-1 ;;
cr) ac_pcre_newline_value=0 ;;
lf) ac_pcre_newline_value=1 ;;
crlf) ac_pcre_newline_value=2 ;;
any) ac_pcre_newline_value=3 ;;
anycrlf) ac_pcre_newline_value=4 ;;
*)
AC_MSG_ERROR([invalid argument \"$enable_newline\" to --enable-newline option])
;;
@ -320,30 +319,16 @@ if test "x$enable_ebcdic_nl25" = "xyes"; then
enable_ebcdic=yes
fi
# Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled,
# and the newline value is adjusted appropriately (CR is still 13, but LF is
# 21 or 37). Also check that UTF support is not requested, because PCRE cannot
# handle EBCDIC and UTF in the same build. To do so it would need to use
# different character constants depending on the mode.
# Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled.
# Also check that UTF support is not requested, because PCRE cannot handle
# EBCDIC and UTF in the same build. To do so it would need to use different
# character constants depending on the mode.
#
if test "x$enable_ebcdic" = "xyes"; then
enable_rebuild_chartables=yes
if test "x$enable_utf" = "xyes"; then
AC_MSG_ERROR([support for EBCDIC and UTF-8/16/32 cannot be enabled at the same time])
fi
if test "x$enable_ebcdic_nl25" = "xno"; then
case "$ac_pcre_newline_value" in
10) ac_pcre_newline_value=21 ;;
3338) ac_pcre_newline_value=3349 ;;
esac
else
case "$ac_pcre_newline_value" in
10) ac_pcre_newline_value=37 ;;
3338) ac_pcre_newline_value=3365 ;;
esac
fi
fi
# Check argument to --with-link-size
@ -490,13 +475,13 @@ fi
# This facilitates -ansi builds under Linux
dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc])
PCRE_STATIC_CFLAG=""
PCRE2_STATIC_CFLAG=""
if test "x$enable_shared" = "xno" ; then
AC_DEFINE([PCRE_STATIC], [1], [
AC_DEFINE([PCRE2_STATIC], [1], [
Define to any value if linking statically (TODO: make nice with Libtool)])
PCRE_STATIC_CFLAG="-DPCRE_STATIC"
PCRE2_STATIC_CFLAG="-DPCRE2_STATIC"
fi
AC_SUBST(PCRE_STATIC_CFLAG)
AC_SUBST(PCRE2_STATIC_CFLAG)
# Here is where pcre specific defines are handled
@ -592,12 +577,8 @@ fi
AC_DEFINE_UNQUOTED([NEWLINE], [$ac_pcre_newline_value], [
The value of NEWLINE determines the default newline character sequence. PCRE
client programs can override this by selecting other values at run time. In
ASCII environments, the value can be 10 (LF), 13 (CR), or 3338 (CRLF); in
EBCDIC environments the value can be 21 or 37 (LF), 13 (CR), or 3349 or 3365
(CRLF) because there are two alternative codepoints (0x15 and 0x25) that are
used as the NL line terminator that is equivalent to ASCII LF. In both ASCII
and EBCDIC environments the value can also be -1 (ANY), or -2 (ANYCRLF).])
client programs can override this by selecting other values at run time. The
valid values are 0 (CR), 1 (LF), 2 (CRLF), 3 (ANY), and 4 (ANYCRLF).])
if test "$enable_bsr_anycrlf" = "yes"; then
AC_DEFINE([BSR_ANYCRLF], [], [
@ -658,7 +639,7 @@ AC_DEFINE([MAX_NAME_COUNT], [10000], [
change it. Care must be taken if it is increased, because it guards
against integer overflow caused by enormously large patterns.])
AH_VERBATIM([PCRE_EXP_DEFN], [
AH_VERBATIM([PCRE2_EXP_DEFN], [
/* If you are compiling for a system other than a Unix-like system or
Win32, and it needs some magic to be inserted before the definition
of a function that is exported by the library, define this macro to
@ -668,27 +649,23 @@ AH_VERBATIM([PCRE_EXP_DEFN], [
This macro apears at the start of every exported function that is part
of the external API. It does not appear on functions that are "external"
in the C sense, but which are internal to the library. */
#undef PCRE_EXP_DEFN])
#undef PCRE2_EXP_DEFN])
if test "$enable_ebcdic" = "yes"; then
AC_DEFINE_UNQUOTED([EBCDIC], [], [
If you are compiling for a system that uses EBCDIC instead of ASCII
character codes, define this macro to any value. You must also edit the
NEWLINE macro below to set a suitable EBCDIC newline, commonly 21 (0x15).
On systems that can use "configure" or CMake to set EBCDIC, NEWLINE is
automatically adjusted. When EBCDIC is set, PCRE assumes that all input
strings are in EBCDIC. If you do not define this macro, PCRE will assume
input strings are ASCII or UTF-8/16/32 Unicode. It is not possible to build
a version of PCRE that supports both EBCDIC and UTF-8/16/32.])
character codes, define this macro to any value. When EBCDIC is set, PCRE
assumes that all input strings are in EBCDIC. If you do not define this
macro, PCRE will assume input strings are ASCII or UTF-8/16/32 Unicode. It
is not possible to build a version of PCRE that supports both EBCDIC and
UTF-8/16/32.])
fi
if test "$enable_ebcdic_nl25" = "yes"; then
AC_DEFINE_UNQUOTED([EBCDIC_NL25], [], [
In an EBCDIC environment, define this macro to any value to arrange for
the NL character to be 0x25 instead of the default 0x15. NL plays the role
that LF does in an ASCII/Unicode environment. The value must also be set in
the NEWLINE macro below. On systems that can use "configure" or CMake to
set EBCDIC_NL25, the adjustment of NEWLINE is automatic.])
that LF does in an ASCII/Unicode environment.])
fi
if test "$enable_valgrind" = "yes"; then
@ -708,25 +685,25 @@ case $host_os in
;;
esac
# The extra LDFLAGS for each particular library
# (Note: The libpcre*_version bits are m4 variables, assigned above)
# The extra LDFLAGS for each particular library. The libpcre2*_version values
# are m4 variables, assigned above.
EXTRA_LIBPCRE8_LDFLAGS="$EXTRA_LIBPCRE8_LDFLAGS \
$NO_UNDEFINED -version-info libpcre8_version"
EXTRA_LIBPCRE2_8_LDFLAGS="$EXTRA_LIBPCRE2_8_LDFLAGS \
$NO_UNDEFINED -version-info libpcre2_8_version"
EXTRA_LIBPCRE16_LDFLAGS="$EXTRA_LIBPCRE16_LDFLAGS \
$NO_UNDEFINED -version-info libpcre16_version"
EXTRA_LIBPCRE2_16_LDFLAGS="$EXTRA_LIBPCRE2_16_LDFLAGS \
$NO_UNDEFINED -version-info libpcre2_16_version"
EXTRA_LIBPCRE32_LDFLAGS="$EXTRA_LIBPCRE32_LDFLAGS \
$NO_UNDEFINED -version-info libpcre32_version"
EXTRA_LIBPCRE2_32_LDFLAGS="$EXTRA_LIBPCRE2_32_LDFLAGS \
$NO_UNDEFINED -version-info libpcre2_32_version"
EXTRA_LIBPCREPOSIX_LDFLAGS="$EXTRA_LIBPCREPOSIX_LDFLAGS \
$NO_UNDEFINED -version-info libpcre2posix_version"
EXTRA_LIBPCRE2_POSIX_LDFLAGS="$EXTRA_LIBPCRE2_POSIX_LDFLAGS \
$NO_UNDEFINED -version-info libpcre2_posix_version"
AC_SUBST(EXTRA_LIBPCRE8_LDFLAGS)
AC_SUBST(EXTRA_LIBPCRE16_LDFLAGS)
AC_SUBST(EXTRA_LIBPCRE32_LDFLAGS)
AC_SUBST(EXTRA_LIBPCREPOSIX_LDFLAGS)
AC_SUBST(EXTRA_LIBPCRE2_8_LDFLAGS)
AC_SUBST(EXTRA_LIBPCRE2_16_LDFLAGS)
AC_SUBST(EXTRA_LIBPCRE2_32_LDFLAGS)
AC_SUBST(EXTRA_LIBPCRE2_POSIX_LDFLAGS)
# When we run 'make distcheck', use these arguments. Turning off compiler
# optimization makes it run faster.
@ -852,7 +829,7 @@ AC_CONFIG_FILES(
libpcre2-8.pc
libpcre2-16.pc
libpcre2-32.pc
libpcre2posix.pc
libpcre2-posix.pc
pcre2-config
src/pcre2.h
)

13
libpcre2-posix.pc Normal file
View File

@ -0,0 +1,13 @@
# Package Information for pkg-config
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libpcre2-posix
Description: Posix compatible interface to libpcre2-8
Version: 9.00-DEV
Libs: -L${libdir} -lpcre2-posix
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
Requires.private: libpcre2-8

View File

@ -5,9 +5,9 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libpcreposix
Description: PCREPosix - Posix compatible interface to libpcre
Name: libpcre2-posix
Description: Posix compatible interface to libpcre2-8
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lpcreposix
Libs: -L${libdir} -lpcre2-posix
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
Requires.private: libpcre
Requires.private: libpcre2-8

View File

@ -75,9 +75,8 @@ AC_DEFUN([PCRE2_VISIBILITY],
HAVE_VISIBILITY=1
AC_DEFINE(PCRE2_EXP_DECL, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible])
AC_DEFINE(PCRE2_EXP_DEFN, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
AC_DEFINE(PCRE2_EXP_DATA_DEFN, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
AC_DEFINE(PCREPOSIX_EXP_DECL, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible])
AC_DEFINE(PCREPOSIX_EXP_DEFN, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible])
AC_DEFINE(PCRE2POSIX_EXP_DECL, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible])
AC_DEFINE(PCRE2POSIX_EXP_DEFN, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible])
fi
fi
AC_SUBST([VISIBILITY_CFLAGS])

View File

@ -36,20 +36,16 @@ sure both macros are undefined; an emulation function will then be used. */
/* #undef BSR_ANYCRLF */
/* If you are compiling for a system that uses EBCDIC instead of ASCII
character codes, define this macro to any value. You must also edit the
NEWLINE macro below to set a suitable EBCDIC newline, commonly 21 (0x15).
On systems that can use "configure" or CMake to set EBCDIC, NEWLINE is
automatically adjusted. When EBCDIC is set, PCRE assumes that all input
strings are in EBCDIC. If you do not define this macro, PCRE will assume
input strings are ASCII or UTF-8/16/32 Unicode. It is not possible to build
a version of PCRE that supports both EBCDIC and UTF-8/16/32. */
character codes, define this macro to any value. When EBCDIC is set, PCRE
assumes that all input strings are in EBCDIC. If you do not define this
macro, PCRE will assume input strings are ASCII or UTF-8/16/32 Unicode. It
is not possible to build a version of PCRE that supports both EBCDIC and
UTF-8/16/32. */
/* #undef EBCDIC */
/* In an EBCDIC environment, define this macro to any value to arrange for the
NL character to be 0x25 instead of the default 0x15. NL plays the role that
LF does in an ASCII/Unicode environment. The value must also be set in the
NEWLINE macro below. On systems that can use "configure" or CMake to set
EBCDIC_NL25, the adjustment of NEWLINE is automatic. */
LF does in an ASCII/Unicode environment. */
/* #undef EBCDIC_NL25 */
/* Define to 1 if you have the `bcopy' function. */
@ -168,13 +164,9 @@ sure both macros are undefined; an emulation function will then be used. */
/* The value of NEWLINE determines the default newline character sequence.
PCRE client programs can override this by selecting other values at run
time. In ASCII environments, the value can be 10 (LF), 13 (CR), or 3338
(CRLF); in EBCDIC environments the value can be 21 or 37 (LF), 13 (CR), or
3349 or 3365 (CRLF) because there are two alternative codepoints (0x15 and
0x25) that are used as the NL line terminator that is equivalent to ASCII
LF. In both ASCII and EBCDIC environments the value can also be -1 (ANY),
or -2 (ANYCRLF). */
#define NEWLINE 10
time. The valid values are 0 (CR), 1 (LF), 2 (CRLF), 3 (ANY), and 4
(ANYCRLF). */
#define NEWLINE 1
/* PCRE uses recursive function calls to handle backtracking while matching.
This can sometimes be a problem on systems that have stacks of limited
@ -212,27 +204,14 @@ sure both macros are undefined; an emulation function will then be used. */
#define PARENS_NEST_LIMIT 250
/* to make a symbol visible */
#define PCRE2_EXP_DATA_DEFN __attribute__ ((visibility ("default")))
#define PCRE2POSIX_EXP_DECL extern __attribute__ ((visibility ("default")))
/* to make a symbol visible */
#define PCRE2POSIX_EXP_DEFN extern __attribute__ ((visibility ("default")))
/* to make a symbol visible */
#define PCRE2_EXP_DECL extern __attribute__ ((visibility ("default")))
/* to make a symbol visible */
#define PCRE2_EXP_DEFN __attribute__ ((visibility ("default")))
/* The value of PCREGREP_BUFSIZE determines the size of buffer used by
pcregrep to hold parts of the file it is searching. This is also the
minimum value. The actual amount of memory used by pcregrep is three times
this number, because it allows for the buffering of "before" and "after"
lines. */
#define PCREGREP_BUFSIZE 20480
/* to make a symbol visible */
#define PCREPOSIX_EXP_DECL extern __attribute__ ((visibility ("default")))
/* to make a symbol visible */
#define PCREPOSIX_EXP_DEFN extern __attribute__ ((visibility ("default")))
/* If you are compiling for a system other than a Unix-like system or
Win32, and it needs some magic to be inserted before the definition
@ -243,10 +222,17 @@ sure both macros are undefined; an emulation function will then be used. */
This macro apears at the start of every exported function that is part
of the external API. It does not appear on functions that are "external"
in the C sense, but which are internal to the library. */
/* #undef PCRE_EXP_DEFN */
#define PCRE2_EXP_DEFN __attribute__ ((visibility ("default")))
/* Define to any value if linking statically (TODO: make nice with Libtool) */
#define PCRE_STATIC 1
#define PCRE2_STATIC 1
/* The value of PCREGREP_BUFSIZE determines the size of buffer used by
pcregrep to hold parts of the file it is searching. This is also the
minimum value. The actual amount of memory used by pcregrep is three times
this number, because it allows for the buffering of "before" and "after"
lines. */
#define PCREGREP_BUFSIZE 20480
/* When calling PCRE via the POSIX interface, additional working storage is
required for holding the pointers to capturing substrings because PCRE

View File

@ -35,20 +35,16 @@ sure both macros are undefined; an emulation function will then be used. */
#undef BSR_ANYCRLF
/* If you are compiling for a system that uses EBCDIC instead of ASCII
character codes, define this macro to any value. You must also edit the
NEWLINE macro below to set a suitable EBCDIC newline, commonly 21 (0x15).
On systems that can use "configure" or CMake to set EBCDIC, NEWLINE is
automatically adjusted. When EBCDIC is set, PCRE assumes that all input
strings are in EBCDIC. If you do not define this macro, PCRE will assume
input strings are ASCII or UTF-8/16/32 Unicode. It is not possible to build
a version of PCRE that supports both EBCDIC and UTF-8/16/32. */
character codes, define this macro to any value. When EBCDIC is set, PCRE
assumes that all input strings are in EBCDIC. If you do not define this
macro, PCRE will assume input strings are ASCII or UTF-8/16/32 Unicode. It
is not possible to build a version of PCRE that supports both EBCDIC and
UTF-8/16/32. */
#undef EBCDIC
/* In an EBCDIC environment, define this macro to any value to arrange for the
NL character to be 0x25 instead of the default 0x15. NL plays the role that
LF does in an ASCII/Unicode environment. The value must also be set in the
NEWLINE macro below. On systems that can use "configure" or CMake to set
EBCDIC_NL25, the adjustment of NEWLINE is automatic. */
LF does in an ASCII/Unicode environment. */
#undef EBCDIC_NL25
/* Define to 1 if you have the `bcopy' function. */
@ -167,12 +163,8 @@ sure both macros are undefined; an emulation function will then be used. */
/* The value of NEWLINE determines the default newline character sequence.
PCRE client programs can override this by selecting other values at run
time. In ASCII environments, the value can be 10 (LF), 13 (CR), or 3338
(CRLF); in EBCDIC environments the value can be 21 or 37 (LF), 13 (CR), or
3349 or 3365 (CRLF) because there are two alternative codepoints (0x15 and
0x25) that are used as the NL line terminator that is equivalent to ASCII
LF. In both ASCII and EBCDIC environments the value can also be -1 (ANY),
or -2 (ANYCRLF). */
time. The valid values are 0 (CR), 1 (LF), 2 (CRLF), 3 (ANY), and 4
(ANYCRLF). */
#undef NEWLINE
/* PCRE uses recursive function calls to handle backtracking while matching.
@ -211,27 +203,14 @@ sure both macros are undefined; an emulation function will then be used. */
#undef PARENS_NEST_LIMIT
/* to make a symbol visible */
#undef PCRE2_EXP_DATA_DEFN
#undef PCRE2POSIX_EXP_DECL
/* to make a symbol visible */
#undef PCRE2POSIX_EXP_DEFN
/* to make a symbol visible */
#undef PCRE2_EXP_DECL
/* to make a symbol visible */
#undef PCRE2_EXP_DEFN
/* The value of PCREGREP_BUFSIZE determines the size of buffer used by
pcregrep to hold parts of the file it is searching. This is also the
minimum value. The actual amount of memory used by pcregrep is three times
this number, because it allows for the buffering of "before" and "after"
lines. */
#undef PCREGREP_BUFSIZE
/* to make a symbol visible */
#undef PCREPOSIX_EXP_DECL
/* to make a symbol visible */
#undef PCREPOSIX_EXP_DEFN
/* If you are compiling for a system other than a Unix-like system or
Win32, and it needs some magic to be inserted before the definition
@ -242,10 +221,17 @@ sure both macros are undefined; an emulation function will then be used. */
This macro apears at the start of every exported function that is part
of the external API. It does not appear on functions that are "external"
in the C sense, but which are internal to the library. */
#undef PCRE_EXP_DEFN
#undef PCRE2_EXP_DEFN
/* Define to any value if linking statically (TODO: make nice with Libtool) */
#undef PCRE_STATIC
#undef PCRE2_STATIC
/* The value of PCREGREP_BUFSIZE determines the size of buffer used by
pcregrep to hold parts of the file it is searching. This is also the
minimum value. The actual amount of memory used by pcregrep is three times
this number, because it allows for the buffering of "before" and "after"
lines. */
#undef PCREGREP_BUFSIZE
/* When calling PCRE via the POSIX interface, additional working storage is
required for holding the pointers to capturing substrings because PCRE

View File

@ -67,7 +67,7 @@ don't change existing definitions of PCRE2_EXP_DECL. */
# endif
#endif
/* Have to include stdlib.h and stdint.h to ensure that size_t and uint8_t etc
/* Have to include stdlib.h and stdint.h to ensure that size_t and uint8_t etc
are defined. */
#include <stdlib.h>
@ -84,8 +84,8 @@ compilation, and/or interpretive execution. The following tags indicate which:
C alters what is compiled
J alters what JIT compiles
E affects pcre_exec() execution
D affects pcre_dfa_exec() execution
E affects pcre2_exec() execution
D affects pcre2_dfa_exec() execution
*/
/* The first group of options are those that are set in the context. */
@ -147,14 +147,14 @@ execution. */
/* Newline and \R settings, for use in the context. */
#define PCRE2_NEWLINE_CR 0x00000001
#define PCRE2_NEWLINE_LF 0x00000002
#define PCRE2_NEWLINE_CRLF 0x00000004
#define PCRE2_NEWLINE_ANY 0x00000008
#define PCRE2_NEWLINE_ANYCRLF 0x00000010
#define PCRE2_NEWLINE_CR 0
#define PCRE2_NEWLINE_LF 1
#define PCRE2_NEWLINE_CRLF 2
#define PCRE2_NEWLINE_ANY 3
#define PCRE2_NEWLINE_ANYCRLF 4
#define PCRE2_BSR_ANYCRLF 0x00000020
#define PCRE2_BSR_UNICODE 0x00000040
#define PCRE2_BSR_UNICODE 0
#define PCRE2_BSR_ANYCRLF 1
/* Exec-time and get/set-time error codes */
@ -167,69 +167,63 @@ execution. */
#define PCRE2_ERROR_NOSUBSTRING (-7)
#define PCRE2_ERROR_MATCHLIMIT (-8)
#define PCRE2_ERROR_CALLOUT (-9) /* Never used by PCRE2 itself */
#define PCRE2_ERROR_BADUTF (-10)
#define PCRE2_ERROR_BADUTF_OFFSET (-11)
#define PCRE2_ERROR_PARTIAL (-12)
#define PCRE2_ERROR_BADPARTIAL (-13)
#define PCRE2_ERROR_INTERNAL (-14)
#define PCRE2_ERROR_BADCOUNT (-15)
#define PCRE2_ERROR_DFA_UITEM (-16)
#define PCRE2_ERROR_DFA_UCOND (-17)
#define PCRE2_ERROR_DFA_UMLIMIT (-18)
#define PCRE2_ERROR_DFA_WSSIZE (-19)
#define PCRE2_ERROR_DFA_RECURSE (-20)
#define PCRE2_ERROR_RECURSIONLIMIT (-21)
#define PCRE2_ERROR_BADNEWLINE (-22)
#define PCRE2_ERROR_BADOFFSET (-23)
#define PCRE2_ERROR_SHORTUTF (-24)
#define PCRE2_ERROR_RECURSELOOP (-25)
#define PCRE2_ERROR_JIT_STACKLIMIT (-26)
#define PCRE2_ERROR_BADMODE (-27)
#define PCRE2_ERROR_BADENDIANNESS (-28)
#define PCRE2_ERROR_DFA_BADRESTART (-29)
#define PCRE2_ERROR_JIT_BADOPTION (-30)
#define PCRE2_ERROR_BADLENGTH (-31)
#define PCRE2_ERROR_UNSET (-32)
#define PCRE2_ERROR_PARTIAL (-10)
#define PCRE2_ERROR_BADPARTIAL (-11)
#define PCRE2_ERROR_INTERNAL (-12)
#define PCRE2_ERROR_BADCOUNT (-13)
#define PCRE2_ERROR_DFA_UITEM (-14)
#define PCRE2_ERROR_DFA_UCOND (-15)
#define PCRE2_ERROR_DFA_UMLIMIT (-16)
#define PCRE2_ERROR_DFA_WSSIZE (-17)
#define PCRE2_ERROR_DFA_RECURSE (-18)
#define PCRE2_ERROR_RECURSIONLIMIT (-19)
#define PCRE2_ERROR_BADOFFSET (-20)
#define PCRE2_ERROR_RECURSELOOP (-21)
#define PCRE2_ERROR_JIT_STACKLIMIT (-22)
#define PCRE2_ERROR_BADMODE (-23)
#define PCRE2_ERROR_BADENDIANNESS (-24)
#define PCRE2_ERROR_DFA_BADRESTART (-25)
#define PCRE2_ERROR_JIT_BADOPTION (-26)
#define PCRE2_ERROR_BADLENGTH (-27)
#define PCRE2_ERROR_UNSET (-28)
#define PCRE2_ERROR_BADUTF_OFFSET (-29)
/* Specific error codes for UTF-8 validity checks */
#define PCRE2_UTF8_ERR0 0
#define PCRE2_UTF8_ERR1 1
#define PCRE2_UTF8_ERR2 2
#define PCRE2_UTF8_ERR3 3
#define PCRE2_UTF8_ERR4 4
#define PCRE2_UTF8_ERR5 5
#define PCRE2_UTF8_ERR6 6
#define PCRE2_UTF8_ERR7 7
#define PCRE2_UTF8_ERR8 8
#define PCRE2_UTF8_ERR9 9
#define PCRE2_UTF8_ERR10 10
#define PCRE2_UTF8_ERR11 11
#define PCRE2_UTF8_ERR12 12
#define PCRE2_UTF8_ERR13 13
#define PCRE2_UTF8_ERR14 14
#define PCRE2_UTF8_ERR15 15
#define PCRE2_UTF8_ERR16 16
#define PCRE2_UTF8_ERR17 17
#define PCRE2_UTF8_ERR18 18
#define PCRE2_UTF8_ERR19 19
#define PCRE2_UTF8_ERR20 20
#define PCRE2_UTF8_ERR21 21
#define PCRE2_ERROR_UTF8_ERR1 (-31)
#define PCRE2_ERROR_UTF8_ERR2 (-32)
#define PCRE2_ERROR_UTF8_ERR3 (-33)
#define PCRE2_ERROR_UTF8_ERR4 (-34)
#define PCRE2_ERROR_UTF8_ERR5 (-35)
#define PCRE2_ERROR_UTF8_ERR6 (-36)
#define PCRE2_ERROR_UTF8_ERR7 (-37)
#define PCRE2_ERROR_UTF8_ERR8 (-38)
#define PCRE2_ERROR_UTF8_ERR9 (-39)
#define PCRE2_ERROR_UTF8_ERR10 (-40)
#define PCRE2_ERROR_UTF8_ERR11 (-41)
#define PCRE2_ERROR_UTF8_ERR12 (-42)
#define PCRE2_ERROR_UTF8_ERR13 (-43)
#define PCRE2_ERROR_UTF8_ERR14 (-44)
#define PCRE2_ERROR_UTF8_ERR15 (-45)
#define PCRE2_ERROR_UTF8_ERR16 (-46)
#define PCRE2_ERROR_UTF8_ERR17 (-47)
#define PCRE2_ERROR_UTF8_ERR18 (-48)
#define PCRE2_ERROR_UTF8_ERR19 (-49)
#define PCRE2_ERROR_UTF8_ERR20 (-50)
#define PCRE2_ERROR_UTF8_ERR21 (-51)
/* Specific error codes for UTF-16 validity checks */
#define PCRE2_UTF16_ERR0 0
#define PCRE2_UTF16_ERR1 1
#define PCRE2_UTF16_ERR2 2
#define PCRE2_UTF16_ERR3 3
#define PCRE2_ERROR_UTF16_ERR1 (-52)
#define PCRE2_ERROR_UTF16_ERR2 (-53)
#define PCRE2_ERROR_UTF16_ERR3 (-54)
/* Specific error codes for UTF-32 validity checks */
#define PCRE2_UTF32_ERR0 0
#define PCRE2_UTF32_ERR1 1
#define PCRE2_UTF32_ERR3 2
#define PCRE2_ERROR_UTF32_ERR1 (-55)
#define PCRE2_ERROR_UTF32_ERR3 (-56)
/* Request types for pcre2_get_info() */
/* Request types for pcre2_pattern_info() */
#define PCRE2_INFO_BACKREFMAX 0
#define PCRE2_INFO_CAPTURECOUNT 1
@ -278,6 +272,7 @@ typedef const PCRE2_UCHAR8 *PCRE2_SPTR8;
typedef const PCRE2_UCHAR16 *PCRE2_SPTR16;
typedef const PCRE2_UCHAR32 *PCRE2_SPTR32;
/* Generic types for opaque structures and JIT callback functions. These
declarations are defined in a macro that is expanded for each width later. */
@ -285,8 +280,8 @@ declarations are defined in a macro that is expanded for each width later. */
struct pcre2_real_context; \
typedef struct pcre2_real_context pcre2_context; \
\
struct pcre2_real; \
typedef struct pcre2_real pcre2; \
struct pcre2_real_code; \
typedef struct pcre2_real_code pcre2_code; \
\
struct pcre2_real_match_data; \
typedef struct pcre2_real_match_data pcre2_match_data; \
@ -296,6 +291,7 @@ typedef struct pcre2_real_jit_stack pcre2_jit_stack; \
\
typedef pcre2_jit_stack *(*pcre2_jit_callback)(void *);
/* The structure for passing out data via the pcre_callout_function. We use a
structure so that new fields can be added on the end in future versions,
without changing the API of the function, thereby allowing old clients to work
@ -323,6 +319,7 @@ typedef struct pcre2_callout_block { \
/* ------------------------------------------------------------------ */ \
} pcre2_callout_block;
/* Utility functions for byte order swaps. These are not generic functions;
each appears only its own library. */
@ -331,84 +328,142 @@ PCRE2_EXP_DECL int pcre2_utf16_to_host_byte_order(PCRE2_UCHAR16 *,
PCRE2_EXP_DECL int pcre2_utf32_to_host_byte_order(PCRE2_UCHAR32 *,
PCRE2_SPTR32, int, int *, int);
/* List the generic forms of all other functions in a macro. */
#define PCRE2_FUNCTION_LIST \
PCRE2_EXP_DECL pcre2 *pcre2_compile(pcre2_context *, PCRE2_SPTR, int, \
uint32_t, int *, size_t *); \
/* List the generic forms of all other functions in macros, which will be
expanded for each width below. Start with functions that give general
information. */
#define PCRE2_GENERAL_INFO_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_config(int, void *); \
PCRE2_EXP_DECL size_t pcre2_get_exec_frame_size(void); \
PCRE2_EXP_DECL int pcre2_version(PCRE2_UCHAR *, size_t);
/* Functions for manipulating contexts. */
#define PCRE2_CONTEXT_FUNCTIONS \
PCRE2_EXP_DECL size_t pcre2_context_size(void); \
PCRE2_EXP_DECL \
pcre2_context *pcre2_copy_context(pcre2_context *); \
PCRE2_EXP_DECL int pcre2_copy_named_substring(pcre2_match_data *, \
PCRE2_SPTR, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL int pcre2_copy_substring(pcre2_match_data *, int, \
PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL \
pcre2_match_data *pcre2_create_match_data(pcre2_context *, size_t); \
PCRE2_EXP_DECL int pcre2_dfa_exec(pcre2_context *, const pcre2 *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *, int *, size_t); \
PCRE2_EXP_DECL int pcre2_exec(pcre2_context *, const pcre2 *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *); \
PCRE2_EXP_DECL void pcre2_free_compiled_code(pcre2_context *, pcre2 *); \
PCRE2_EXP_DECL void pcre2_free_context(pcre2_context *); \
PCRE2_EXP_DECL void pcre2_free_match_data(pcre2_context *, \
pcre2_match_data *); \
PCRE2_EXP_DECL void pcre2_free_substring(pcre2_context *, PCRE2_SPTR); \
PCRE2_EXP_DECL void pcre2_free_substring_list(pcre2_context *, \
PCRE2_SPTR *); \
PCRE2_EXP_DECL \
pcre2_context *pcre2_init_context(pcre2_context *); \
\
PCRE2_EXP_DECL uint32_t pcre2_get_bsr_convention(pcre2_context *); \
PCRE2_EXP_DECL int (*pcre2_get_callout(pcre2_context *)) \
(pcre2_callout_block *, void *); \
PCRE2_EXP_DECL \
unsigned char *pcre2_get_character_tables(pcre2_context *); \
const unsigned char *pcre2_get_character_tables(pcre2_context *); \
PCRE2_EXP_DECL uint32_t pcre2_get_context_options(pcre2_context *); \
PCRE2_EXP_DECL int pcre2_get_error_message(int, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL size_t pcre2_get_error_offset(pcre2_match_data *); \
PCRE2_EXP_DECL int pcre2_get_error_reason(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_exec_frame_size(void); \
PCRE2_EXP_DECL int pcre2_get_info(const pcre2 *, uint32_t, void *); \
PCRE2_EXP_DECL size_t pcre2_get_leftchar(pcre2_match_data *); \
PCRE2_EXP_DECL \
PCRE2_SPTR pcre2_get_mark(pcre2_match_data *); \
PCRE2_EXP_DECL uint32_t pcre2_get_match_limit(pcre2_context *); \
PCRE2_EXP_DECL void pcre2_get_memory_management(pcre2_context *, \
void *(**)(size_t, void *), \
void (**)(void *, void *)); \
PCRE2_EXP_DECL int pcre2_get_named_substring(pcre2_context *, \
pcre2_match_data *, PCRE2_SPTR, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_get_named_substring_length(pcre2_match_data *, \
PCRE2_SPTR); \
PCRE2_EXP_DECL uint32_t pcre2_get_newline_convention(pcre2_context *); \
PCRE2_EXP_DECL size_t *pcre2_get_ovector(pcre2_match_data *); \
PCRE2_EXP_DECL size_t *pcre2_get_ovector_slots(pcre2_match_data *); \
PCRE2_EXP_DECL uint32_t pcre2_get_parens_nest_limit(pcre2_context *); \
PCRE2_EXP_DECL int (*pcre2_get_recursion_guard(pcre2_context *)) \
(int, void *); \
(uint32_t, void *); \
PCRE2_EXP_DECL uint32_t pcre2_get_recursion_limit(pcre2_context *); \
PCRE2_EXP_DECL void pcre2_get_recursion_memory_management(\
pcre2_context *, \
void *(**)(size_t, void *), \
void (**)(void *, void *)); \
PCRE2_EXP_DECL size_t pcre2_get_rightchar(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_startchar(pcre2_match_data *); \
PCRE2_EXP_DECL int pcre2_get_stringtable_entries(const pcre2 *, \
PCRE2_EXP_DECL void *pcre2_get_user_data(pcre2_context *); \
\
PCRE2_EXP_DECL int pcre2_set_bsr_convention(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL int pcre2_set_callout(pcre2_context *, \
int (*)(pcre2_callout_block *, void *)); \
PCRE2_EXP_DECL int pcre2_set_character_tables(pcre2_context *, \
const unsigned char *); \
PCRE2_EXP_DECL int pcre2_set_context_options(pcre2_context *, uint32_t, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_match_limit(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL int pcre2_set_memory_management(pcre2_context *, \
void * (*)(size_t, void *), \
void (*)(void *, void *)); \
PCRE2_EXP_DECL int pcre2_set_newline_convention(pcre2_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_parens_nest_limit(pcre2_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_recursion_guard(pcre2_context *, \
int (*)(uint32_t, void *)); \
PCRE2_EXP_DECL int pcre2_set_recursion_limit(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL int pcre2_set_recursion_memory_management(\
pcre2_context *, void * (*)(size_t, void *), \
void (*)(void *, void *)); \
PCRE2_EXP_DECL int pcre2_set_user_data(pcre2_context *, void *);
/* Functions concerned with compiling a pattern to PCRE internal code. */
#define PCRE2_COMPILE_FUNCTIONS \
PCRE2_EXP_DECL \
pcre2_code *pcre2_compile(pcre2_context *, PCRE2_SPTR, int, \
uint32_t, int *, size_t *); \
PCRE2_EXP_DECL void pcre2_free_compiled_code(pcre2_context *, \
pcre2_code *);
/* Functions that give information about a compiled pattern. */
#define PCRE2_PATTERN_INFO_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_pattern_info(const pcre2_code *, uint32_t, \
void *); \
PCRE2_EXP_DECL int pcre2_get_stringtable_entries(const pcre2_code *, \
PCRE2_SPTR, PCRE2_UCHAR **, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_get_substring_number(const pcre2_code *, \
PCRE2_SPTR);
/* Functions for running a match and inspecting the result. */
#define PCRE2_MATCH_FUNCTIONS \
PCRE2_EXP_DECL \
pcre2_match_data *pcre2_create_match_data(pcre2_context *, size_t); \
PCRE2_EXP_DECL int pcre2_dfa_exec(pcre2_context *, const pcre2_code *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *, int *, size_t); \
PCRE2_EXP_DECL int pcre2_exec(pcre2_context *, const pcre2_code *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *); \
PCRE2_EXP_DECL void pcre2_free_match_data(pcre2_context *, \
pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_leftchar(pcre2_match_data *); \
PCRE2_EXP_DECL \
PCRE2_SPTR pcre2_get_mark(pcre2_match_data *); \
PCRE2_EXP_DECL size_t *pcre2_get_ovector(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_ovector_slots(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_rightchar(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_startchar(pcre2_match_data *);
/* Convenience functions for handling matched substrings. */
#define PCRE2_SUBSTRING_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_copy_named_substring(pcre2_match_data *, \
PCRE2_SPTR, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL int pcre2_copy_substring(pcre2_match_data *, int, \
PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL void pcre2_free_substring(pcre2_context *, PCRE2_UCHAR *); \
PCRE2_EXP_DECL void pcre2_free_substring_list(pcre2_context *, \
PCRE2_SPTR *); \
PCRE2_EXP_DECL int pcre2_get_named_substring(pcre2_context *, \
pcre2_match_data *, PCRE2_SPTR, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_get_named_substring_length(pcre2_match_data *, \
PCRE2_SPTR); \
PCRE2_EXP_DECL int pcre2_get_substring(pcre2_context *, \
pcre2_match_data *, int, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_get_substring_length(pcre2_match_data *, int); \
PCRE2_EXP_DECL int pcre2_get_substring_list(pcre2_context *, \
pcre2_match_data *, PCRE2_UCHAR ***); \
PCRE2_EXP_DECL int pcre2_get_substring_number(const pcre2 *, \
PCRE2_SPTR); \
PCRE2_EXP_DECL void *pcre2_get_user_data(pcre2_context *); \
PCRE2_EXP_DECL \
pcre2_context *pcre2_init_context(pcre2_context *); \
PCRE2_EXP_DECL int pcre2_jit_compile(pcre2_context *, pcre2 *, \
pcre2_match_data *, PCRE2_UCHAR ***);
/* Functions for JIT processing */
#define PCRE2_JIT_FUNCTIONS \
PCRE2_EXP_DECL void pcre2_jit_compile(pcre2_context *, pcre2_code *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_jit_exec(pcre2_context *, const pcre2 *, \
PCRE2_EXP_DECL int pcre2_jit_exec(pcre2_context *, const pcre2_code *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *, pcre2_jit_stack *); \
PCRE2_EXP_DECL void pcre2_jit_free_unused_memory(pcre2_context *); \
@ -416,135 +471,120 @@ PCRE2_EXP_DECL \
pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_context *, size_t, \
size_t); \
PCRE2_EXP_DECL void pcre2_jit_stack_assign(pcre2_context *, \
const pcre2 *, pcre2_jit_callback, void *); \
const pcre2_code *, pcre2_jit_callback, void *); \
PCRE2_EXP_DECL void pcre2_jit_stack_free(pcre2_context *, \
pcre2_jit_stack *); \
pcre2_jit_stack *);
/* Other miscellaneous functions. */
#define PCRE2_OTHER_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_get_error_message(int, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL \
const unsigned char *pcre2_maketables(void); \
PCRE2_EXP_DECL int pcre2_pattern_to_host_byte_order(pcre2 *); \
PCRE2_EXP_DECL void pcre2_set_bsr_convention(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL void pcre2_set_callout(pcre2_context *, \
int (*)(pcre2_callout_block *, void *)); \
PCRE2_EXP_DECL void pcre2_set_character_tables(pcre2_context *, \
unsigned char *); \
PCRE2_EXP_DECL void pcre2_set_context_options(pcre2_context *, uint32_t, \
uint32_t); \
PCRE2_EXP_DECL void pcre2_set_match_limit(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL void pcre2_set_memory_management(pcre2_context *, \
void * (*)(size_t, void *), \
void (*)(void *, void *)); \
PCRE2_EXP_DECL void pcre2_set_newline_convention(pcre2_context *, \
uint32_t); \
PCRE2_EXP_DECL void pcre2_set_parens_nest_limit(pcre2_context *, \
uint32_t); \
PCRE2_EXP_DECL void pcre2_set_recursion_guard(pcre2_context *, \
int (*)(uint32_t, void *)); \
PCRE2_EXP_DECL void pcre2_set_recursion_limit(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL void pcre2_set_recursion_memory_management(\
pcre2_context *, void * (*)(size_t, void *), \
void (*)(void *, void *)); \
PCRE2_EXP_DECL void pcre2_set_user_data(pcre2_context *, void *); \
PCRE2_EXP_DECL int pcre2_version(PCRE2_UCHAR *, size_t);
const unsigned char *pcre2_maketables(pcre2_context *); \
PCRE2_EXP_DECL int pcre2_pattern_to_host_byte_order(pcre2_code *);
/* Define macros that generate width-specific names from generic versions. The
three-level macro scheme is necessary to get the macros expanded when we want
them to be. First we get the width from PCRE2_LOCAL_WIDTH, which is used for
generating three versions of each external function below. After that,
PCRE2_ADDWIDTH will be re-defined to use PCRE2_DATA_WIDTH, for use when macros
such as pcre2_compile are called by application code. */
generating three versions of everything below. After that, PCRE2_SUFFIX will be
re-defined to use PCRE2_CODE_UNIT_WIDTH, for use when macros such as
pcre2_compile are called by application code. */
#define PCRE2_JOIN(a,b) a ## b
#define PCRE2_GLUE(a,b) PCRE2_JOIN(a,b)
#define PCRE2_ADDWIDTH(a) PCRE2_GLUE(a,PCRE2_LOCAL_WIDTH)
#define PCRE2_SUFFIX(a) PCRE2_GLUE(a,PCRE2_LOCAL_WIDTH)
/* Data types */
#define PCRE2_UCHAR PCRE2_ADDWIDTH(PCRE2_UCHAR)
#define PCRE2_SPTR PCRE2_ADDWIDTH(PCRE2_SPTR)
#define PCRE2_UCHAR PCRE2_SUFFIX(PCRE2_UCHAR)
#define PCRE2_SPTR PCRE2_SUFFIX(PCRE2_SPTR)
#define pcre2 PCRE2_ADDWIDTH(pcre2_)
#define pcre2_jit_callback PCRE2_ADDWIDTH(pcre2_jit_callback_)
#define pcre2_jit_stack PCRE2_ADDWIDTH(pcre2_jit_stack_)
#define pcre2_code PCRE2_SUFFIX(pcre2_code_)
#define pcre2_jit_callback PCRE2_SUFFIX(pcre2_jit_callback_)
#define pcre2_jit_stack PCRE2_SUFFIX(pcre2_jit_stack_)
#define pcre2_real_code PCRE2_SUFFIX(pcre2_real_code_)
#define pcre2_real_context PCRE2_SUFFIX(pcre2_real_context_)
#define pcre2_real_jit_stack PCRE2_SUFFIX(pcre2_real_jit_stack_)
#define pcre2_real_match_data PCRE2_SUFFIX(pcre2_real_match_data_)
#define pcre2_real PCRE2_ADDWIDTH(pcre2_real_)
#define pcre2_real_context PCRE2_ADDWIDTH(pcre2_real_context_)
#define pcre2_real_jit_stack PCRE2_ADDWIDTH(pcre2_real_jit_stack_)
#define pcre2_real_match_data PCRE2_ADDWIDTH(pcre2_real_match_data_)
/* Data blocks */
#define pcre2_callout_block PCRE2_ADDWIDTH(pcre2_callout_block_)
#define pcre2_context PCRE2_ADDWIDTH(pcre2_context_)
#define pcre2_match_data PCRE2_ADDWIDTH(pcre2_match_data_)
#define pcre2_callout_block PCRE2_SUFFIX(pcre2_callout_block_)
#define pcre2_context PCRE2_SUFFIX(pcre2_context_)
#define pcre2_match_data PCRE2_SUFFIX(pcre2_match_data_)
/* Functions */
#define pcre2_compile PCRE2_ADDWIDTH(pcre2_compile_)
#define pcre2_config PCRE2_ADDWIDTH(pcre2_config_)
#define pcre2_context_size PCRE2_ADDWIDTH(pcre2_context_size_)
#define pcre2_copy_context PCRE2_ADDWIDTH(pcre2_copy_context_)
#define pcre2_copy_named_substring PCRE2_ADDWIDTH(pcre2_copy_named_substring_)
#define pcre2_copy_substring PCRE2_ADDWIDTH(pcre2_copy_substring_)
#define pcre2_create_match_data PCRE2_ADDWIDTH(pcre2_create_match_data_)
#define pcre2_dfa_exec PCRE2_ADDWIDTH(pcre2_dfa_exec_)
#define pcre2_exec PCRE2_ADDWIDTH(pcre2_exec_)
#define pcre2_free_compiled_code PCRE2_ADDWIDTH(pcre2_free_compiled_code_)
#define pcre2_free_context PCRE2_ADDWIDTH(pcre2_free_context_)
#define pcre2_free_match_data PCRE2_ADDWIDTH(pcre2_free_match_data_)
#define pcre2_free_substring PCRE2_ADDWIDTH(pcre2_free_substring_)
#define pcre2_free_substring_list PCRE2_ADDWIDTH(pcre2_free_substring_list_)
#define pcre2_get_bsr_convention PCRE2_ADDWIDTH(pcre2_get_bsr_convention_)
#define pcre2_get_callout PCRE2_ADDWIDTH(pcre2_get_callout_)
#define pcre2_get_character_tables PCRE2_ADDWIDTH(pcre2_get_character_tables_)
#define pcre2_get_context_options PCRE2_ADDWIDTH(pcre2_get_context_options_)
#define pcre2_get_error_message PCRE2_ADDWIDTH(pcre2_get_error_message_)
#define pcre2_get_error_offset PCRE2_ADDWIDTH(pcre2_get_error_offset_)
#define pcre2_get_error_reason PCRE2_ADDWIDTH(pcre2_get_error_reason_)
#define pcre2_get_info PCRE2_ADDWIDTH(pcre2_get_info_)
#define pcre2_get_leftchar PCRE2_ADDWIDTH(pcre2_get_leftchar_)
#define pcre2_get_mark PCRE2_ADDWIDTH(pcre2_get_mark_)
#define pcre2_get_match_limit PCRE2_ADDWIDTH(pcre2_get_match_limit_)
#define pcre2_get_memory_management PCRE2_ADDWIDTH(pcre2_get_memory_management_)
#define pcre2_get_named_substring PCRE2_ADDWIDTH(pcre2_get_named_substring_)
#define pcre2_get_named_substring_length PCRE2_ADDWIDTH(pcre2_get_named_substring_length_)
#define pcre2_get_newline_convention PCRE2_ADDWIDTH(pcre2_get_newline_convention_)
#define pcre2_get_ovector PCRE2_ADDWIDTH(pcre2_get_ovector_)
#define pcre2_get_ovector_slots PCRE2_ADDWIDTH(pcre2_get_ovector_slots_)
#define pcre2_get_parens_nest_limit PCRE2_ADDWIDTH(pcre2_get_parens_nest_limit_)
#define pcre2_get_recursion_guard PCRE2_ADDWIDTH(pcre2_get_recursion_guard_)
#define pcre2_get_recursion_limit PCRE2_ADDWIDTH(pcre2_get_recursion_limit_)
#define pcre2_get_recursion_memory_management PCRE2_ADDWIDTH(pcre2_get_recursion_memory_management_)
#define pcre2_get_rightchar PCRE2_ADDWIDTH(pcre2_get_rightchar_)
#define pcre2_get_startchar PCRE2_ADDWIDTH(pcre2_get_startchar_)
#define pcre2_get_stringtable_entries PCRE2_ADDWIDTH(pcre2_get_stringtable_entries_)
#define pcre2_get_substring PCRE2_ADDWIDTH(pcre2_get_substring_)
#define pcre2_get_substring_length PCRE2_ADDWIDTH(pcre2_get_substring_length_)
#define pcre2_get_substring_list PCRE2_ADDWIDTH(pcre2_get_substring_list_)
#define pcre2_get_substring_number PCRE2_ADDWIDTH(pcre2_get_substring_number_)
#define pcre2_get_user_data PCRE2_ADDWIDTH(pcre2_get_user_data_)
#define pcre2_init_context PCRE2_ADDWIDTH(pcre2_init_context_)
#define pcre2_jit_compile PCRE2_ADDWIDTH(pcre2_jit_compile_)
#define pcre2_jit_exec PCRE2_ADDWIDTH(pcre2_jit_exec_)
#define pcre2_jit_free_unused_memory PCRE2_ADDWIDTH(pcre2_jit_free_unused_memory_)
#define pcre2_jit_stack_alloc PCRE2_ADDWIDTH(pcre2_jit_stack_alloc_)
#define pcre2_jit_stack_assign PCRE2_ADDWIDTH(pcre2_jit_stack_assign_)
#define pcre2_jit_stack_free PCRE2_ADDWIDTH(pcre2_jit_stack_free_)
#define pcre2_maketables PCRE2_ADDWIDTH(pcre2_maketables_)
#define pcre2_pattern_to_host_byte_order PCRE2_ADDWIDTH(pcre2_pattern_to_host_byte_order_)
#define pcre2_set_bsr_convention PCRE2_ADDWIDTH(pcre2_set_bsr_convention_)
#define pcre2_set_callout PCRE2_ADDWIDTH(pcre2_set_callout_)
#define pcre2_set_character_tables PCRE2_ADDWIDTH(pcre2_set_character_tables_)
#define pcre2_set_context_options PCRE2_ADDWIDTH(pcre2_set_context_options_)
#define pcre2_set_match_limit PCRE2_ADDWIDTH(pcre2_set_match_limit_)
#define pcre2_set_memory_management PCRE2_ADDWIDTH(pcre2_set_memory_management_)
#define pcre2_set_newline_convention PCRE2_ADDWIDTH(pcre2_set_newline_convention_)
#define pcre2_set_recursion_guard PCRE2_ADDWIDTH(pcre2_set_recursion_guard_)
#define pcre2_set_parens_nest_limit PCRE2_ADDWIDTH(pcre2_set_parens_nest_limit_)
#define pcre2_set_recursion_limit PCRE2_ADDWIDTH(pcre2_set_recursion_limit_)
#define pcre2_set_recursion_memory_management PCRE2_ADDWIDTH(pcre2_set_recursion_memory_management_)
#define pcre2_set_user_data PCRE2_ADDWIDTH(pcre2_set_user_data_)
#define pcre2_version PCRE2_ADDWIDTH(pcre2_version_)
/* Functions: the complete list in alphabetical order */
#define pcre2_compile PCRE2_SUFFIX(pcre2_compile_)
#define pcre2_config PCRE2_SUFFIX(pcre2_config_)
#define pcre2_context_size PCRE2_SUFFIX(pcre2_context_size_)
#define pcre2_copy_context PCRE2_SUFFIX(pcre2_copy_context_)
#define pcre2_copy_named_substring PCRE2_SUFFIX(pcre2_copy_named_substring_)
#define pcre2_copy_substring PCRE2_SUFFIX(pcre2_copy_substring_)
#define pcre2_create_match_data PCRE2_SUFFIX(pcre2_create_match_data_)
#define pcre2_dfa_exec PCRE2_SUFFIX(pcre2_dfa_exec_)
#define pcre2_exec PCRE2_SUFFIX(pcre2_exec_)
#define pcre2_free_compiled_code PCRE2_SUFFIX(pcre2_free_compiled_code_)
#define pcre2_free_context PCRE2_SUFFIX(pcre2_free_context_)
#define pcre2_free_match_data PCRE2_SUFFIX(pcre2_free_match_data_)
#define pcre2_free_substring PCRE2_SUFFIX(pcre2_free_substring_)
#define pcre2_free_substring_list PCRE2_SUFFIX(pcre2_free_substring_list_)
#define pcre2_get_bsr_convention PCRE2_SUFFIX(pcre2_get_bsr_convention_)
#define pcre2_get_callout PCRE2_SUFFIX(pcre2_get_callout_)
#define pcre2_get_character_tables PCRE2_SUFFIX(pcre2_get_character_tables_)
#define pcre2_get_context_options PCRE2_SUFFIX(pcre2_get_context_options_)
#define pcre2_get_error_message PCRE2_SUFFIX(pcre2_get_error_message_)
#define pcre2_get_leftchar PCRE2_SUFFIX(pcre2_get_leftchar_)
#define pcre2_get_mark PCRE2_SUFFIX(pcre2_get_mark_)
#define pcre2_get_match_limit PCRE2_SUFFIX(pcre2_get_match_limit_)
#define pcre2_get_memory_management PCRE2_SUFFIX(pcre2_get_memory_management_)
#define pcre2_get_named_substring PCRE2_SUFFIX(pcre2_get_named_substring_)
#define pcre2_get_named_substring_length PCRE2_SUFFIX(pcre2_get_named_substring_length_)
#define pcre2_get_newline_convention PCRE2_SUFFIX(pcre2_get_newline_convention_)
#define pcre2_get_ovector PCRE2_SUFFIX(pcre2_get_ovector_)
#define pcre2_get_ovector_slots PCRE2_SUFFIX(pcre2_get_ovector_slots_)
#define pcre2_get_parens_nest_limit PCRE2_SUFFIX(pcre2_get_parens_nest_limit_)
#define pcre2_get_recursion_guard PCRE2_SUFFIX(pcre2_get_recursion_guard_)
#define pcre2_get_recursion_limit PCRE2_SUFFIX(pcre2_get_recursion_limit_)
#define pcre2_get_recursion_memory_management PCRE2_SUFFIX(pcre2_get_recursion_memory_management_)
#define pcre2_get_rightchar PCRE2_SUFFIX(pcre2_get_rightchar_)
#define pcre2_get_startchar PCRE2_SUFFIX(pcre2_get_startchar_)
#define pcre2_get_stringtable_entries PCRE2_SUFFIX(pcre2_get_stringtable_entries_)
#define pcre2_get_substring PCRE2_SUFFIX(pcre2_get_substring_)
#define pcre2_get_substring_length PCRE2_SUFFIX(pcre2_get_substring_length_)
#define pcre2_get_substring_list PCRE2_SUFFIX(pcre2_get_substring_list_)
#define pcre2_get_substring_number PCRE2_SUFFIX(pcre2_get_substring_number_)
#define pcre2_get_user_data PCRE2_SUFFIX(pcre2_get_user_data_)
#define pcre2_init_context PCRE2_SUFFIX(pcre2_init_context_)
#define pcre2_jit_compile PCRE2_SUFFIX(pcre2_jit_compile_)
#define pcre2_jit_exec PCRE2_SUFFIX(pcre2_jit_exec_)
#define pcre2_jit_free_unused_memory PCRE2_SUFFIX(pcre2_jit_free_unused_memory_)
#define pcre2_jit_stack_alloc PCRE2_SUFFIX(pcre2_jit_stack_alloc_)
#define pcre2_jit_stack_assign PCRE2_SUFFIX(pcre2_jit_stack_assign_)
#define pcre2_jit_stack_free PCRE2_SUFFIX(pcre2_jit_stack_free_)
#define pcre2_maketables PCRE2_SUFFIX(pcre2_maketables_)
#define pcre2_pattern_info PCRE2_SUFFIX(pcre2_pattern_info_)
#define pcre2_pattern_to_host_byte_order PCRE2_SUFFIX(pcre2_pattern_to_host_byte_order_)
#define pcre2_set_bsr_convention PCRE2_SUFFIX(pcre2_set_bsr_convention_)
#define pcre2_set_callout PCRE2_SUFFIX(pcre2_set_callout_)
#define pcre2_set_character_tables PCRE2_SUFFIX(pcre2_set_character_tables_)
#define pcre2_set_context_options PCRE2_SUFFIX(pcre2_set_context_options_)
#define pcre2_set_match_limit PCRE2_SUFFIX(pcre2_set_match_limit_)
#define pcre2_set_memory_management PCRE2_SUFFIX(pcre2_set_memory_management_)
#define pcre2_set_newline_convention PCRE2_SUFFIX(pcre2_set_newline_convention_)
#define pcre2_set_recursion_guard PCRE2_SUFFIX(pcre2_set_recursion_guard_)
#define pcre2_set_parens_nest_limit PCRE2_SUFFIX(pcre2_set_parens_nest_limit_)
#define pcre2_set_recursion_limit PCRE2_SUFFIX(pcre2_set_recursion_limit_)
#define pcre2_set_recursion_memory_management PCRE2_SUFFIX(pcre2_set_recursion_memory_management_)
#define pcre2_set_user_data PCRE2_SUFFIX(pcre2_set_user_data_)
#define pcre2_version PCRE2_SUFFIX(pcre2_version_)
/* Now generate all three sets of width-specific structures and function
prototypes. */
@ -552,41 +592,75 @@ prototypes. */
#define PCRE2_LOCAL_WIDTH 8
PCRE2_TYPES_LIST
PCRE2_STRUCTURE_LIST
PCRE2_FUNCTION_LIST
PCRE2_GENERAL_INFO_FUNCTIONS
PCRE2_CONTEXT_FUNCTIONS
PCRE2_COMPILE_FUNCTIONS
PCRE2_PATTERN_INFO_FUNCTIONS
PCRE2_MATCH_FUNCTIONS
PCRE2_SUBSTRING_FUNCTIONS
PCRE2_JIT_FUNCTIONS
PCRE2_OTHER_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
#define PCRE2_LOCAL_WIDTH 16
PCRE2_TYPES_LIST
PCRE2_STRUCTURE_LIST
PCRE2_FUNCTION_LIST
PCRE2_GENERAL_INFO_FUNCTIONS
PCRE2_CONTEXT_FUNCTIONS
PCRE2_COMPILE_FUNCTIONS
PCRE2_PATTERN_INFO_FUNCTIONS
PCRE2_MATCH_FUNCTIONS
PCRE2_SUBSTRING_FUNCTIONS
PCRE2_JIT_FUNCTIONS
PCRE2_OTHER_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
#define PCRE2_LOCAL_WIDTH 32
PCRE2_TYPES_LIST
PCRE2_STRUCTURE_LIST
PCRE2_FUNCTION_LIST
PCRE2_GENERAL_INFO_FUNCTIONS
PCRE2_CONTEXT_FUNCTIONS
PCRE2_COMPILE_FUNCTIONS
PCRE2_PATTERN_INFO_FUNCTIONS
PCRE2_MATCH_FUNCTIONS
PCRE2_SUBSTRING_FUNCTIONS
PCRE2_JIT_FUNCTIONS
PCRE2_OTHER_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
/* Undefine the list macros; they are no longer needed. */
#undef PCRE2_TYPES_LIST
#undef PCRE2_STRUCTURE_LIST
#undef PCRE2_FUNCTION_LIST
#undef PCRE2_ADDWIDTH
#undef PCRE2_GENERAL_INFO_FUNCTIONS
#undef PCRE2_CONTEXT_FUNCTIONS
#undef PCRE2_COMPILE_FUNCTIONS
#undef PCRE2_PATTERN_INFO_FUNCTIONS
#undef PCRE2_MATCH_FUNCTIONS
#undef PCRE2_SUBSTRING_FUNCTIONS
#undef PCRE2_JIT_FUNCTIONS
#undef PCRE2_OTHER_FUNCTIONS
/* Re-define PCRE2_ADDWIDTH to use the external width value, if defined.
Otherwise, undefine the other macros and make PCRE2_ADDWIDTH a no-op, to reduce
/* Re-define PCRE2_SUFFIX to use the external width value, if defined.
Otherwise, undefine the other macros and make PCRE2_SUFFIX a no-op, to reduce
confusion. */
#ifdef PCRE2_DATA_WIDTH
#if PCRE2_DATA_WIDTH != 8 && PCRE2_DATA_WIDTH != 16 && PCRE2_DATA_WIDTH != 32
#error PCRE2_DATA_WIDTH must be 8, 16, or 32
#undef PCRE2_SUFFIX
#ifdef PCRE2_CODE_UNIT_WIDTH
#if PCRE2_CODE_UNIT_WIDTH != 8 && \
PCRE2_CODE_UNIT_WIDTH != 16 && \
PCRE2_CODE_UNIT_WIDTH != 32
#error PCRE2_CODE_UNIT_WIDTH must be 8, 16, or 32
#endif
#define PCRE2_ADDWIDTH(a) PCRE2_GLUE(a,PCRE2_DATA_WIDTH)
#define PCRE2_SUFFIX(a) PCRE2_GLUE(a, PCRE2_CODE_UNIT_WIDTH)
#else
#undef PCRE2_JOIN
#undef PCRE2_GLUE
#define PCRE2_ADDWIDTH(a) a
#define PCRE2_SUFFIX(a) a
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@ -67,7 +67,7 @@ don't change existing definitions of PCRE2_EXP_DECL. */
# endif
#endif
/* Have to include stdlib.h and stdint.h to ensure that size_t and uint8_t etc
/* Have to include stdlib.h and stdint.h to ensure that size_t and uint8_t etc
are defined. */
#include <stdlib.h>
@ -84,8 +84,8 @@ compilation, and/or interpretive execution. The following tags indicate which:
C alters what is compiled
J alters what JIT compiles
E affects pcre_exec() execution
D affects pcre_dfa_exec() execution
E affects pcre2_exec() execution
D affects pcre2_dfa_exec() execution
*/
/* The first group of options are those that are set in the context. */
@ -147,14 +147,14 @@ execution. */
/* Newline and \R settings, for use in the context. */
#define PCRE2_NEWLINE_CR 0x00000001
#define PCRE2_NEWLINE_LF 0x00000002
#define PCRE2_NEWLINE_CRLF 0x00000004
#define PCRE2_NEWLINE_ANY 0x00000008
#define PCRE2_NEWLINE_ANYCRLF 0x00000010
#define PCRE2_NEWLINE_CR 0
#define PCRE2_NEWLINE_LF 1
#define PCRE2_NEWLINE_CRLF 2
#define PCRE2_NEWLINE_ANY 3
#define PCRE2_NEWLINE_ANYCRLF 4
#define PCRE2_BSR_ANYCRLF 0x00000020
#define PCRE2_BSR_UNICODE 0x00000040
#define PCRE2_BSR_UNICODE 0
#define PCRE2_BSR_ANYCRLF 1
/* Exec-time and get/set-time error codes */
@ -167,69 +167,63 @@ execution. */
#define PCRE2_ERROR_NOSUBSTRING (-7)
#define PCRE2_ERROR_MATCHLIMIT (-8)
#define PCRE2_ERROR_CALLOUT (-9) /* Never used by PCRE2 itself */
#define PCRE2_ERROR_BADUTF (-10)
#define PCRE2_ERROR_BADUTF_OFFSET (-11)
#define PCRE2_ERROR_PARTIAL (-12)
#define PCRE2_ERROR_BADPARTIAL (-13)
#define PCRE2_ERROR_INTERNAL (-14)
#define PCRE2_ERROR_BADCOUNT (-15)
#define PCRE2_ERROR_DFA_UITEM (-16)
#define PCRE2_ERROR_DFA_UCOND (-17)
#define PCRE2_ERROR_DFA_UMLIMIT (-18)
#define PCRE2_ERROR_DFA_WSSIZE (-19)
#define PCRE2_ERROR_DFA_RECURSE (-20)
#define PCRE2_ERROR_RECURSIONLIMIT (-21)
#define PCRE2_ERROR_BADNEWLINE (-22)
#define PCRE2_ERROR_BADOFFSET (-23)
#define PCRE2_ERROR_SHORTUTF (-24)
#define PCRE2_ERROR_RECURSELOOP (-25)
#define PCRE2_ERROR_JIT_STACKLIMIT (-26)
#define PCRE2_ERROR_BADMODE (-27)
#define PCRE2_ERROR_BADENDIANNESS (-28)
#define PCRE2_ERROR_DFA_BADRESTART (-29)
#define PCRE2_ERROR_JIT_BADOPTION (-30)
#define PCRE2_ERROR_BADLENGTH (-31)
#define PCRE2_ERROR_UNSET (-32)
#define PCRE2_ERROR_PARTIAL (-10)
#define PCRE2_ERROR_BADPARTIAL (-11)
#define PCRE2_ERROR_INTERNAL (-12)
#define PCRE2_ERROR_BADCOUNT (-13)
#define PCRE2_ERROR_DFA_UITEM (-14)
#define PCRE2_ERROR_DFA_UCOND (-15)
#define PCRE2_ERROR_DFA_UMLIMIT (-16)
#define PCRE2_ERROR_DFA_WSSIZE (-17)
#define PCRE2_ERROR_DFA_RECURSE (-18)
#define PCRE2_ERROR_RECURSIONLIMIT (-19)
#define PCRE2_ERROR_BADOFFSET (-20)
#define PCRE2_ERROR_RECURSELOOP (-21)
#define PCRE2_ERROR_JIT_STACKLIMIT (-22)
#define PCRE2_ERROR_BADMODE (-23)
#define PCRE2_ERROR_BADENDIANNESS (-24)
#define PCRE2_ERROR_DFA_BADRESTART (-25)
#define PCRE2_ERROR_JIT_BADOPTION (-26)
#define PCRE2_ERROR_BADLENGTH (-27)
#define PCRE2_ERROR_UNSET (-28)
#define PCRE2_ERROR_BADUTF_OFFSET (-29)
/* Specific error codes for UTF-8 validity checks */
#define PCRE2_UTF8_ERR0 0
#define PCRE2_UTF8_ERR1 1
#define PCRE2_UTF8_ERR2 2
#define PCRE2_UTF8_ERR3 3
#define PCRE2_UTF8_ERR4 4
#define PCRE2_UTF8_ERR5 5
#define PCRE2_UTF8_ERR6 6
#define PCRE2_UTF8_ERR7 7
#define PCRE2_UTF8_ERR8 8
#define PCRE2_UTF8_ERR9 9
#define PCRE2_UTF8_ERR10 10
#define PCRE2_UTF8_ERR11 11
#define PCRE2_UTF8_ERR12 12
#define PCRE2_UTF8_ERR13 13
#define PCRE2_UTF8_ERR14 14
#define PCRE2_UTF8_ERR15 15
#define PCRE2_UTF8_ERR16 16
#define PCRE2_UTF8_ERR17 17
#define PCRE2_UTF8_ERR18 18
#define PCRE2_UTF8_ERR19 19
#define PCRE2_UTF8_ERR20 20
#define PCRE2_UTF8_ERR21 21
#define PCRE2_ERROR_UTF8_ERR1 (-31)
#define PCRE2_ERROR_UTF8_ERR2 (-32)
#define PCRE2_ERROR_UTF8_ERR3 (-33)
#define PCRE2_ERROR_UTF8_ERR4 (-34)
#define PCRE2_ERROR_UTF8_ERR5 (-35)
#define PCRE2_ERROR_UTF8_ERR6 (-36)
#define PCRE2_ERROR_UTF8_ERR7 (-37)
#define PCRE2_ERROR_UTF8_ERR8 (-38)
#define PCRE2_ERROR_UTF8_ERR9 (-39)
#define PCRE2_ERROR_UTF8_ERR10 (-40)
#define PCRE2_ERROR_UTF8_ERR11 (-41)
#define PCRE2_ERROR_UTF8_ERR12 (-42)
#define PCRE2_ERROR_UTF8_ERR13 (-43)
#define PCRE2_ERROR_UTF8_ERR14 (-44)
#define PCRE2_ERROR_UTF8_ERR15 (-45)
#define PCRE2_ERROR_UTF8_ERR16 (-46)
#define PCRE2_ERROR_UTF8_ERR17 (-47)
#define PCRE2_ERROR_UTF8_ERR18 (-48)
#define PCRE2_ERROR_UTF8_ERR19 (-49)
#define PCRE2_ERROR_UTF8_ERR20 (-50)
#define PCRE2_ERROR_UTF8_ERR21 (-51)
/* Specific error codes for UTF-16 validity checks */
#define PCRE2_UTF16_ERR0 0
#define PCRE2_UTF16_ERR1 1
#define PCRE2_UTF16_ERR2 2
#define PCRE2_UTF16_ERR3 3
#define PCRE2_ERROR_UTF16_ERR1 (-52)
#define PCRE2_ERROR_UTF16_ERR2 (-53)
#define PCRE2_ERROR_UTF16_ERR3 (-54)
/* Specific error codes for UTF-32 validity checks */
#define PCRE2_UTF32_ERR0 0
#define PCRE2_UTF32_ERR1 1
#define PCRE2_UTF32_ERR3 2
#define PCRE2_ERROR_UTF32_ERR1 (-55)
#define PCRE2_ERROR_UTF32_ERR3 (-56)
/* Request types for pcre2_get_info() */
/* Request types for pcre2_pattern_info() */
#define PCRE2_INFO_BACKREFMAX 0
#define PCRE2_INFO_CAPTURECOUNT 1
@ -278,6 +272,7 @@ typedef const PCRE2_UCHAR8 *PCRE2_SPTR8;
typedef const PCRE2_UCHAR16 *PCRE2_SPTR16;
typedef const PCRE2_UCHAR32 *PCRE2_SPTR32;
/* Generic types for opaque structures and JIT callback functions. These
declarations are defined in a macro that is expanded for each width later. */
@ -285,8 +280,8 @@ declarations are defined in a macro that is expanded for each width later. */
struct pcre2_real_context; \
typedef struct pcre2_real_context pcre2_context; \
\
struct pcre2_real; \
typedef struct pcre2_real pcre2; \
struct pcre2_real_code; \
typedef struct pcre2_real_code pcre2_code; \
\
struct pcre2_real_match_data; \
typedef struct pcre2_real_match_data pcre2_match_data; \
@ -296,6 +291,7 @@ typedef struct pcre2_real_jit_stack pcre2_jit_stack; \
\
typedef pcre2_jit_stack *(*pcre2_jit_callback)(void *);
/* The structure for passing out data via the pcre_callout_function. We use a
structure so that new fields can be added on the end in future versions,
without changing the API of the function, thereby allowing old clients to work
@ -323,6 +319,7 @@ typedef struct pcre2_callout_block { \
/* ------------------------------------------------------------------ */ \
} pcre2_callout_block;
/* Utility functions for byte order swaps. These are not generic functions;
each appears only its own library. */
@ -331,84 +328,142 @@ PCRE2_EXP_DECL int pcre2_utf16_to_host_byte_order(PCRE2_UCHAR16 *,
PCRE2_EXP_DECL int pcre2_utf32_to_host_byte_order(PCRE2_UCHAR32 *,
PCRE2_SPTR32, int, int *, int);
/* List the generic forms of all other functions in a macro. */
#define PCRE2_FUNCTION_LIST \
PCRE2_EXP_DECL pcre2 *pcre2_compile(pcre2_context *, PCRE2_SPTR, int, \
uint32_t, int *, size_t *); \
/* List the generic forms of all other functions in macros, which will be
expanded for each width below. Start with functions that give general
information. */
#define PCRE2_GENERAL_INFO_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_config(int, void *); \
PCRE2_EXP_DECL size_t pcre2_get_exec_frame_size(void); \
PCRE2_EXP_DECL int pcre2_version(PCRE2_UCHAR *, size_t);
/* Functions for manipulating contexts. */
#define PCRE2_CONTEXT_FUNCTIONS \
PCRE2_EXP_DECL size_t pcre2_context_size(void); \
PCRE2_EXP_DECL \
pcre2_context *pcre2_copy_context(pcre2_context *); \
PCRE2_EXP_DECL int pcre2_copy_named_substring(pcre2_match_data *, \
PCRE2_SPTR, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL int pcre2_copy_substring(pcre2_match_data *, int, \
PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL \
pcre2_match_data *pcre2_create_match_data(pcre2_context *, size_t); \
PCRE2_EXP_DECL int pcre2_dfa_exec(pcre2_context *, const pcre2 *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *, int *, size_t); \
PCRE2_EXP_DECL int pcre2_exec(pcre2_context *, const pcre2 *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *); \
PCRE2_EXP_DECL void pcre2_free_compiled_code(pcre2_context *, pcre2 *); \
PCRE2_EXP_DECL void pcre2_free_context(pcre2_context *); \
PCRE2_EXP_DECL void pcre2_free_match_data(pcre2_context *, \
pcre2_match_data *); \
PCRE2_EXP_DECL void pcre2_free_substring(pcre2_context *, PCRE2_SPTR); \
PCRE2_EXP_DECL void pcre2_free_substring_list(pcre2_context *, \
PCRE2_SPTR *); \
PCRE2_EXP_DECL \
pcre2_context *pcre2_init_context(pcre2_context *); \
\
PCRE2_EXP_DECL uint32_t pcre2_get_bsr_convention(pcre2_context *); \
PCRE2_EXP_DECL int (*pcre2_get_callout(pcre2_context *)) \
(pcre2_callout_block *, void *); \
PCRE2_EXP_DECL \
unsigned char *pcre2_get_character_tables(pcre2_context *); \
const unsigned char *pcre2_get_character_tables(pcre2_context *); \
PCRE2_EXP_DECL uint32_t pcre2_get_context_options(pcre2_context *); \
PCRE2_EXP_DECL int pcre2_get_error_message(int, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL size_t pcre2_get_error_offset(pcre2_match_data *); \
PCRE2_EXP_DECL int pcre2_get_error_reason(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_exec_frame_size(void); \
PCRE2_EXP_DECL int pcre2_get_info(const pcre2 *, uint32_t, void *); \
PCRE2_EXP_DECL size_t pcre2_get_leftchar(pcre2_match_data *); \
PCRE2_EXP_DECL \
PCRE2_SPTR pcre2_get_mark(pcre2_match_data *); \
PCRE2_EXP_DECL uint32_t pcre2_get_match_limit(pcre2_context *); \
PCRE2_EXP_DECL void pcre2_get_memory_management(pcre2_context *, \
void *(**)(size_t, void *), \
void (**)(void *, void *)); \
PCRE2_EXP_DECL int pcre2_get_named_substring(pcre2_context *, \
pcre2_match_data *, PCRE2_SPTR, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_get_named_substring_length(pcre2_match_data *, \
PCRE2_SPTR); \
PCRE2_EXP_DECL uint32_t pcre2_get_newline_convention(pcre2_context *); \
PCRE2_EXP_DECL size_t *pcre2_get_ovector(pcre2_match_data *); \
PCRE2_EXP_DECL size_t *pcre2_get_ovector_slots(pcre2_match_data *); \
PCRE2_EXP_DECL uint32_t pcre2_get_parens_nest_limit(pcre2_context *); \
PCRE2_EXP_DECL int (*pcre2_get_recursion_guard(pcre2_context *)) \
(int, void *); \
(uint32_t, void *); \
PCRE2_EXP_DECL uint32_t pcre2_get_recursion_limit(pcre2_context *); \
PCRE2_EXP_DECL void pcre2_get_recursion_memory_management(\
pcre2_context *, \
void *(**)(size_t, void *), \
void (**)(void *, void *)); \
PCRE2_EXP_DECL size_t pcre2_get_rightchar(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_startchar(pcre2_match_data *); \
PCRE2_EXP_DECL int pcre2_get_stringtable_entries(const pcre2 *, \
PCRE2_EXP_DECL void *pcre2_get_user_data(pcre2_context *); \
\
PCRE2_EXP_DECL int pcre2_set_bsr_convention(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL int pcre2_set_callout(pcre2_context *, \
int (*)(pcre2_callout_block *, void *)); \
PCRE2_EXP_DECL int pcre2_set_character_tables(pcre2_context *, \
const unsigned char *); \
PCRE2_EXP_DECL int pcre2_set_context_options(pcre2_context *, uint32_t, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_match_limit(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL int pcre2_set_memory_management(pcre2_context *, \
void * (*)(size_t, void *), \
void (*)(void *, void *)); \
PCRE2_EXP_DECL int pcre2_set_newline_convention(pcre2_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_parens_nest_limit(pcre2_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_recursion_guard(pcre2_context *, \
int (*)(uint32_t, void *)); \
PCRE2_EXP_DECL int pcre2_set_recursion_limit(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL int pcre2_set_recursion_memory_management(\
pcre2_context *, void * (*)(size_t, void *), \
void (*)(void *, void *)); \
PCRE2_EXP_DECL int pcre2_set_user_data(pcre2_context *, void *);
/* Functions concerned with compiling a pattern to PCRE internal code. */
#define PCRE2_COMPILE_FUNCTIONS \
PCRE2_EXP_DECL \
pcre2_code *pcre2_compile(pcre2_context *, PCRE2_SPTR, int, \
uint32_t, int *, size_t *); \
PCRE2_EXP_DECL void pcre2_free_compiled_code(pcre2_context *, \
pcre2_code *);
/* Functions that give information about a compiled pattern. */
#define PCRE2_PATTERN_INFO_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_pattern_info(const pcre2_code *, uint32_t, \
void *); \
PCRE2_EXP_DECL int pcre2_get_stringtable_entries(const pcre2_code *, \
PCRE2_SPTR, PCRE2_UCHAR **, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_get_substring_number(const pcre2_code *, \
PCRE2_SPTR);
/* Functions for running a match and inspecting the result. */
#define PCRE2_MATCH_FUNCTIONS \
PCRE2_EXP_DECL \
pcre2_match_data *pcre2_create_match_data(pcre2_context *, size_t); \
PCRE2_EXP_DECL int pcre2_dfa_exec(pcre2_context *, const pcre2_code *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *, int *, size_t); \
PCRE2_EXP_DECL int pcre2_exec(pcre2_context *, const pcre2_code *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *); \
PCRE2_EXP_DECL void pcre2_free_match_data(pcre2_context *, \
pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_leftchar(pcre2_match_data *); \
PCRE2_EXP_DECL \
PCRE2_SPTR pcre2_get_mark(pcre2_match_data *); \
PCRE2_EXP_DECL size_t *pcre2_get_ovector(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_ovector_slots(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_rightchar(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_startchar(pcre2_match_data *);
/* Convenience functions for handling matched substrings. */
#define PCRE2_SUBSTRING_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_copy_named_substring(pcre2_match_data *, \
PCRE2_SPTR, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL int pcre2_copy_substring(pcre2_match_data *, int, \
PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL void pcre2_free_substring(pcre2_context *, PCRE2_UCHAR *); \
PCRE2_EXP_DECL void pcre2_free_substring_list(pcre2_context *, \
PCRE2_SPTR *); \
PCRE2_EXP_DECL int pcre2_get_named_substring(pcre2_context *, \
pcre2_match_data *, PCRE2_SPTR, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_get_named_substring_length(pcre2_match_data *, \
PCRE2_SPTR); \
PCRE2_EXP_DECL int pcre2_get_substring(pcre2_context *, \
pcre2_match_data *, int, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_get_substring_length(pcre2_match_data *, int); \
PCRE2_EXP_DECL int pcre2_get_substring_list(pcre2_context *, \
pcre2_match_data *, PCRE2_UCHAR ***); \
PCRE2_EXP_DECL int pcre2_get_substring_number(const pcre2 *, \
PCRE2_SPTR); \
PCRE2_EXP_DECL void *pcre2_get_user_data(pcre2_context *); \
PCRE2_EXP_DECL \
pcre2_context *pcre2_init_context(pcre2_context *); \
PCRE2_EXP_DECL int pcre2_jit_compile(pcre2_context *, pcre2 *, \
pcre2_match_data *, PCRE2_UCHAR ***);
/* Functions for JIT processing */
#define PCRE2_JIT_FUNCTIONS \
PCRE2_EXP_DECL void pcre2_jit_compile(pcre2_context *, pcre2_code *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_jit_exec(pcre2_context *, const pcre2 *, \
PCRE2_EXP_DECL int pcre2_jit_exec(pcre2_context *, const pcre2_code *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *, pcre2_jit_stack *); \
PCRE2_EXP_DECL void pcre2_jit_free_unused_memory(pcre2_context *); \
@ -416,135 +471,120 @@ PCRE2_EXP_DECL \
pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_context *, size_t, \
size_t); \
PCRE2_EXP_DECL void pcre2_jit_stack_assign(pcre2_context *, \
const pcre2 *, pcre2_jit_callback, void *); \
const pcre2_code *, pcre2_jit_callback, void *); \
PCRE2_EXP_DECL void pcre2_jit_stack_free(pcre2_context *, \
pcre2_jit_stack *); \
pcre2_jit_stack *);
/* Other miscellaneous functions. */
#define PCRE2_OTHER_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_get_error_message(int, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL \
const unsigned char *pcre2_maketables(void); \
PCRE2_EXP_DECL int pcre2_pattern_to_host_byte_order(pcre2 *); \
PCRE2_EXP_DECL void pcre2_set_bsr_convention(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL void pcre2_set_callout(pcre2_context *, \
int (*)(pcre2_callout_block *, void *)); \
PCRE2_EXP_DECL void pcre2_set_character_tables(pcre2_context *, \
unsigned char *); \
PCRE2_EXP_DECL void pcre2_set_context_options(pcre2_context *, uint32_t, \
uint32_t); \
PCRE2_EXP_DECL void pcre2_set_match_limit(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL void pcre2_set_memory_management(pcre2_context *, \
void * (*)(size_t, void *), \
void (*)(void *, void *)); \
PCRE2_EXP_DECL void pcre2_set_newline_convention(pcre2_context *, \
uint32_t); \
PCRE2_EXP_DECL void pcre2_set_parens_nest_limit(pcre2_context *, \
uint32_t); \
PCRE2_EXP_DECL void pcre2_set_recursion_guard(pcre2_context *, \
int (*)(uint32_t, void *)); \
PCRE2_EXP_DECL void pcre2_set_recursion_limit(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL void pcre2_set_recursion_memory_management(\
pcre2_context *, void * (*)(size_t, void *), \
void (*)(void *, void *)); \
PCRE2_EXP_DECL void pcre2_set_user_data(pcre2_context *, void *); \
PCRE2_EXP_DECL int pcre2_version(PCRE2_UCHAR *, size_t);
const unsigned char *pcre2_maketables(pcre2_context *); \
PCRE2_EXP_DECL int pcre2_pattern_to_host_byte_order(pcre2_code *);
/* Define macros that generate width-specific names from generic versions. The
three-level macro scheme is necessary to get the macros expanded when we want
them to be. First we get the width from PCRE2_LOCAL_WIDTH, which is used for
generating three versions of each external function below. After that,
PCRE2_ADDWIDTH will be re-defined to use PCRE2_DATA_WIDTH, for use when macros
such as pcre2_compile are called by application code. */
generating three versions of everything below. After that, PCRE2_SUFFIX will be
re-defined to use PCRE2_CODE_UNIT_WIDTH, for use when macros such as
pcre2_compile are called by application code. */
#define PCRE2_JOIN(a,b) a ## b
#define PCRE2_GLUE(a,b) PCRE2_JOIN(a,b)
#define PCRE2_ADDWIDTH(a) PCRE2_GLUE(a,PCRE2_LOCAL_WIDTH)
#define PCRE2_SUFFIX(a) PCRE2_GLUE(a,PCRE2_LOCAL_WIDTH)
/* Data types */
#define PCRE2_UCHAR PCRE2_ADDWIDTH(PCRE2_UCHAR)
#define PCRE2_SPTR PCRE2_ADDWIDTH(PCRE2_SPTR)
#define PCRE2_UCHAR PCRE2_SUFFIX(PCRE2_UCHAR)
#define PCRE2_SPTR PCRE2_SUFFIX(PCRE2_SPTR)
#define pcre2 PCRE2_ADDWIDTH(pcre2_)
#define pcre2_jit_callback PCRE2_ADDWIDTH(pcre2_jit_callback_)
#define pcre2_jit_stack PCRE2_ADDWIDTH(pcre2_jit_stack_)
#define pcre2_code PCRE2_SUFFIX(pcre2_code_)
#define pcre2_jit_callback PCRE2_SUFFIX(pcre2_jit_callback_)
#define pcre2_jit_stack PCRE2_SUFFIX(pcre2_jit_stack_)
#define pcre2_real_code PCRE2_SUFFIX(pcre2_real_code_)
#define pcre2_real_context PCRE2_SUFFIX(pcre2_real_context_)
#define pcre2_real_jit_stack PCRE2_SUFFIX(pcre2_real_jit_stack_)
#define pcre2_real_match_data PCRE2_SUFFIX(pcre2_real_match_data_)
#define pcre2_real PCRE2_ADDWIDTH(pcre2_real_)
#define pcre2_real_context PCRE2_ADDWIDTH(pcre2_real_context_)
#define pcre2_real_jit_stack PCRE2_ADDWIDTH(pcre2_real_jit_stack_)
#define pcre2_real_match_data PCRE2_ADDWIDTH(pcre2_real_match_data_)
/* Data blocks */
#define pcre2_callout_block PCRE2_ADDWIDTH(pcre2_callout_block_)
#define pcre2_context PCRE2_ADDWIDTH(pcre2_context_)
#define pcre2_match_data PCRE2_ADDWIDTH(pcre2_match_data_)
#define pcre2_callout_block PCRE2_SUFFIX(pcre2_callout_block_)
#define pcre2_context PCRE2_SUFFIX(pcre2_context_)
#define pcre2_match_data PCRE2_SUFFIX(pcre2_match_data_)
/* Functions */
#define pcre2_compile PCRE2_ADDWIDTH(pcre2_compile_)
#define pcre2_config PCRE2_ADDWIDTH(pcre2_config_)
#define pcre2_context_size PCRE2_ADDWIDTH(pcre2_context_size_)
#define pcre2_copy_context PCRE2_ADDWIDTH(pcre2_copy_context_)
#define pcre2_copy_named_substring PCRE2_ADDWIDTH(pcre2_copy_named_substring_)
#define pcre2_copy_substring PCRE2_ADDWIDTH(pcre2_copy_substring_)
#define pcre2_create_match_data PCRE2_ADDWIDTH(pcre2_create_match_data_)
#define pcre2_dfa_exec PCRE2_ADDWIDTH(pcre2_dfa_exec_)
#define pcre2_exec PCRE2_ADDWIDTH(pcre2_exec_)
#define pcre2_free_compiled_code PCRE2_ADDWIDTH(pcre2_free_compiled_code_)
#define pcre2_free_context PCRE2_ADDWIDTH(pcre2_free_context_)
#define pcre2_free_match_data PCRE2_ADDWIDTH(pcre2_free_match_data_)
#define pcre2_free_substring PCRE2_ADDWIDTH(pcre2_free_substring_)
#define pcre2_free_substring_list PCRE2_ADDWIDTH(pcre2_free_substring_list_)
#define pcre2_get_bsr_convention PCRE2_ADDWIDTH(pcre2_get_bsr_convention_)
#define pcre2_get_callout PCRE2_ADDWIDTH(pcre2_get_callout_)
#define pcre2_get_character_tables PCRE2_ADDWIDTH(pcre2_get_character_tables_)
#define pcre2_get_context_options PCRE2_ADDWIDTH(pcre2_get_context_options_)
#define pcre2_get_error_message PCRE2_ADDWIDTH(pcre2_get_error_message_)
#define pcre2_get_error_offset PCRE2_ADDWIDTH(pcre2_get_error_offset_)
#define pcre2_get_error_reason PCRE2_ADDWIDTH(pcre2_get_error_reason_)
#define pcre2_get_info PCRE2_ADDWIDTH(pcre2_get_info_)
#define pcre2_get_leftchar PCRE2_ADDWIDTH(pcre2_get_leftchar_)
#define pcre2_get_mark PCRE2_ADDWIDTH(pcre2_get_mark_)
#define pcre2_get_match_limit PCRE2_ADDWIDTH(pcre2_get_match_limit_)
#define pcre2_get_memory_management PCRE2_ADDWIDTH(pcre2_get_memory_management_)
#define pcre2_get_named_substring PCRE2_ADDWIDTH(pcre2_get_named_substring_)
#define pcre2_get_named_substring_length PCRE2_ADDWIDTH(pcre2_get_named_substring_length_)
#define pcre2_get_newline_convention PCRE2_ADDWIDTH(pcre2_get_newline_convention_)
#define pcre2_get_ovector PCRE2_ADDWIDTH(pcre2_get_ovector_)
#define pcre2_get_ovector_slots PCRE2_ADDWIDTH(pcre2_get_ovector_slots_)
#define pcre2_get_parens_nest_limit PCRE2_ADDWIDTH(pcre2_get_parens_nest_limit_)
#define pcre2_get_recursion_guard PCRE2_ADDWIDTH(pcre2_get_recursion_guard_)
#define pcre2_get_recursion_limit PCRE2_ADDWIDTH(pcre2_get_recursion_limit_)
#define pcre2_get_recursion_memory_management PCRE2_ADDWIDTH(pcre2_get_recursion_memory_management_)
#define pcre2_get_rightchar PCRE2_ADDWIDTH(pcre2_get_rightchar_)
#define pcre2_get_startchar PCRE2_ADDWIDTH(pcre2_get_startchar_)
#define pcre2_get_stringtable_entries PCRE2_ADDWIDTH(pcre2_get_stringtable_entries_)
#define pcre2_get_substring PCRE2_ADDWIDTH(pcre2_get_substring_)
#define pcre2_get_substring_length PCRE2_ADDWIDTH(pcre2_get_substring_length_)
#define pcre2_get_substring_list PCRE2_ADDWIDTH(pcre2_get_substring_list_)
#define pcre2_get_substring_number PCRE2_ADDWIDTH(pcre2_get_substring_number_)
#define pcre2_get_user_data PCRE2_ADDWIDTH(pcre2_get_user_data_)
#define pcre2_init_context PCRE2_ADDWIDTH(pcre2_init_context_)
#define pcre2_jit_compile PCRE2_ADDWIDTH(pcre2_jit_compile_)
#define pcre2_jit_exec PCRE2_ADDWIDTH(pcre2_jit_exec_)
#define pcre2_jit_free_unused_memory PCRE2_ADDWIDTH(pcre2_jit_free_unused_memory_)
#define pcre2_jit_stack_alloc PCRE2_ADDWIDTH(pcre2_jit_stack_alloc_)
#define pcre2_jit_stack_assign PCRE2_ADDWIDTH(pcre2_jit_stack_assign_)
#define pcre2_jit_stack_free PCRE2_ADDWIDTH(pcre2_jit_stack_free_)
#define pcre2_maketables PCRE2_ADDWIDTH(pcre2_maketables_)
#define pcre2_pattern_to_host_byte_order PCRE2_ADDWIDTH(pcre2_pattern_to_host_byte_order_)
#define pcre2_set_bsr_convention PCRE2_ADDWIDTH(pcre2_set_bsr_convention_)
#define pcre2_set_callout PCRE2_ADDWIDTH(pcre2_set_callout_)
#define pcre2_set_character_tables PCRE2_ADDWIDTH(pcre2_set_character_tables_)
#define pcre2_set_context_options PCRE2_ADDWIDTH(pcre2_set_context_options_)
#define pcre2_set_match_limit PCRE2_ADDWIDTH(pcre2_set_match_limit_)
#define pcre2_set_memory_management PCRE2_ADDWIDTH(pcre2_set_memory_management_)
#define pcre2_set_newline_convention PCRE2_ADDWIDTH(pcre2_set_newline_convention_)
#define pcre2_set_recursion_guard PCRE2_ADDWIDTH(pcre2_set_recursion_guard_)
#define pcre2_set_parens_nest_limit PCRE2_ADDWIDTH(pcre2_set_parens_nest_limit_)
#define pcre2_set_recursion_limit PCRE2_ADDWIDTH(pcre2_set_recursion_limit_)
#define pcre2_set_recursion_memory_management PCRE2_ADDWIDTH(pcre2_set_recursion_memory_management_)
#define pcre2_set_user_data PCRE2_ADDWIDTH(pcre2_set_user_data_)
#define pcre2_version PCRE2_ADDWIDTH(pcre2_version_)
/* Functions: the complete list in alphabetical order */
#define pcre2_compile PCRE2_SUFFIX(pcre2_compile_)
#define pcre2_config PCRE2_SUFFIX(pcre2_config_)
#define pcre2_context_size PCRE2_SUFFIX(pcre2_context_size_)
#define pcre2_copy_context PCRE2_SUFFIX(pcre2_copy_context_)
#define pcre2_copy_named_substring PCRE2_SUFFIX(pcre2_copy_named_substring_)
#define pcre2_copy_substring PCRE2_SUFFIX(pcre2_copy_substring_)
#define pcre2_create_match_data PCRE2_SUFFIX(pcre2_create_match_data_)
#define pcre2_dfa_exec PCRE2_SUFFIX(pcre2_dfa_exec_)
#define pcre2_exec PCRE2_SUFFIX(pcre2_exec_)
#define pcre2_free_compiled_code PCRE2_SUFFIX(pcre2_free_compiled_code_)
#define pcre2_free_context PCRE2_SUFFIX(pcre2_free_context_)
#define pcre2_free_match_data PCRE2_SUFFIX(pcre2_free_match_data_)
#define pcre2_free_substring PCRE2_SUFFIX(pcre2_free_substring_)
#define pcre2_free_substring_list PCRE2_SUFFIX(pcre2_free_substring_list_)
#define pcre2_get_bsr_convention PCRE2_SUFFIX(pcre2_get_bsr_convention_)
#define pcre2_get_callout PCRE2_SUFFIX(pcre2_get_callout_)
#define pcre2_get_character_tables PCRE2_SUFFIX(pcre2_get_character_tables_)
#define pcre2_get_context_options PCRE2_SUFFIX(pcre2_get_context_options_)
#define pcre2_get_error_message PCRE2_SUFFIX(pcre2_get_error_message_)
#define pcre2_get_leftchar PCRE2_SUFFIX(pcre2_get_leftchar_)
#define pcre2_get_mark PCRE2_SUFFIX(pcre2_get_mark_)
#define pcre2_get_match_limit PCRE2_SUFFIX(pcre2_get_match_limit_)
#define pcre2_get_memory_management PCRE2_SUFFIX(pcre2_get_memory_management_)
#define pcre2_get_named_substring PCRE2_SUFFIX(pcre2_get_named_substring_)
#define pcre2_get_named_substring_length PCRE2_SUFFIX(pcre2_get_named_substring_length_)
#define pcre2_get_newline_convention PCRE2_SUFFIX(pcre2_get_newline_convention_)
#define pcre2_get_ovector PCRE2_SUFFIX(pcre2_get_ovector_)
#define pcre2_get_ovector_slots PCRE2_SUFFIX(pcre2_get_ovector_slots_)
#define pcre2_get_parens_nest_limit PCRE2_SUFFIX(pcre2_get_parens_nest_limit_)
#define pcre2_get_recursion_guard PCRE2_SUFFIX(pcre2_get_recursion_guard_)
#define pcre2_get_recursion_limit PCRE2_SUFFIX(pcre2_get_recursion_limit_)
#define pcre2_get_recursion_memory_management PCRE2_SUFFIX(pcre2_get_recursion_memory_management_)
#define pcre2_get_rightchar PCRE2_SUFFIX(pcre2_get_rightchar_)
#define pcre2_get_startchar PCRE2_SUFFIX(pcre2_get_startchar_)
#define pcre2_get_stringtable_entries PCRE2_SUFFIX(pcre2_get_stringtable_entries_)
#define pcre2_get_substring PCRE2_SUFFIX(pcre2_get_substring_)
#define pcre2_get_substring_length PCRE2_SUFFIX(pcre2_get_substring_length_)
#define pcre2_get_substring_list PCRE2_SUFFIX(pcre2_get_substring_list_)
#define pcre2_get_substring_number PCRE2_SUFFIX(pcre2_get_substring_number_)
#define pcre2_get_user_data PCRE2_SUFFIX(pcre2_get_user_data_)
#define pcre2_init_context PCRE2_SUFFIX(pcre2_init_context_)
#define pcre2_jit_compile PCRE2_SUFFIX(pcre2_jit_compile_)
#define pcre2_jit_exec PCRE2_SUFFIX(pcre2_jit_exec_)
#define pcre2_jit_free_unused_memory PCRE2_SUFFIX(pcre2_jit_free_unused_memory_)
#define pcre2_jit_stack_alloc PCRE2_SUFFIX(pcre2_jit_stack_alloc_)
#define pcre2_jit_stack_assign PCRE2_SUFFIX(pcre2_jit_stack_assign_)
#define pcre2_jit_stack_free PCRE2_SUFFIX(pcre2_jit_stack_free_)
#define pcre2_maketables PCRE2_SUFFIX(pcre2_maketables_)
#define pcre2_pattern_info PCRE2_SUFFIX(pcre2_pattern_info_)
#define pcre2_pattern_to_host_byte_order PCRE2_SUFFIX(pcre2_pattern_to_host_byte_order_)
#define pcre2_set_bsr_convention PCRE2_SUFFIX(pcre2_set_bsr_convention_)
#define pcre2_set_callout PCRE2_SUFFIX(pcre2_set_callout_)
#define pcre2_set_character_tables PCRE2_SUFFIX(pcre2_set_character_tables_)
#define pcre2_set_context_options PCRE2_SUFFIX(pcre2_set_context_options_)
#define pcre2_set_match_limit PCRE2_SUFFIX(pcre2_set_match_limit_)
#define pcre2_set_memory_management PCRE2_SUFFIX(pcre2_set_memory_management_)
#define pcre2_set_newline_convention PCRE2_SUFFIX(pcre2_set_newline_convention_)
#define pcre2_set_recursion_guard PCRE2_SUFFIX(pcre2_set_recursion_guard_)
#define pcre2_set_parens_nest_limit PCRE2_SUFFIX(pcre2_set_parens_nest_limit_)
#define pcre2_set_recursion_limit PCRE2_SUFFIX(pcre2_set_recursion_limit_)
#define pcre2_set_recursion_memory_management PCRE2_SUFFIX(pcre2_set_recursion_memory_management_)
#define pcre2_set_user_data PCRE2_SUFFIX(pcre2_set_user_data_)
#define pcre2_version PCRE2_SUFFIX(pcre2_version_)
/* Now generate all three sets of width-specific structures and function
prototypes. */
@ -552,41 +592,75 @@ prototypes. */
#define PCRE2_LOCAL_WIDTH 8
PCRE2_TYPES_LIST
PCRE2_STRUCTURE_LIST
PCRE2_FUNCTION_LIST
PCRE2_GENERAL_INFO_FUNCTIONS
PCRE2_CONTEXT_FUNCTIONS
PCRE2_COMPILE_FUNCTIONS
PCRE2_PATTERN_INFO_FUNCTIONS
PCRE2_MATCH_FUNCTIONS
PCRE2_SUBSTRING_FUNCTIONS
PCRE2_JIT_FUNCTIONS
PCRE2_OTHER_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
#define PCRE2_LOCAL_WIDTH 16
PCRE2_TYPES_LIST
PCRE2_STRUCTURE_LIST
PCRE2_FUNCTION_LIST
PCRE2_GENERAL_INFO_FUNCTIONS
PCRE2_CONTEXT_FUNCTIONS
PCRE2_COMPILE_FUNCTIONS
PCRE2_PATTERN_INFO_FUNCTIONS
PCRE2_MATCH_FUNCTIONS
PCRE2_SUBSTRING_FUNCTIONS
PCRE2_JIT_FUNCTIONS
PCRE2_OTHER_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
#define PCRE2_LOCAL_WIDTH 32
PCRE2_TYPES_LIST
PCRE2_STRUCTURE_LIST
PCRE2_FUNCTION_LIST
PCRE2_GENERAL_INFO_FUNCTIONS
PCRE2_CONTEXT_FUNCTIONS
PCRE2_COMPILE_FUNCTIONS
PCRE2_PATTERN_INFO_FUNCTIONS
PCRE2_MATCH_FUNCTIONS
PCRE2_SUBSTRING_FUNCTIONS
PCRE2_JIT_FUNCTIONS
PCRE2_OTHER_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
/* Undefine the list macros; they are no longer needed. */
#undef PCRE2_TYPES_LIST
#undef PCRE2_STRUCTURE_LIST
#undef PCRE2_FUNCTION_LIST
#undef PCRE2_ADDWIDTH
#undef PCRE2_GENERAL_INFO_FUNCTIONS
#undef PCRE2_CONTEXT_FUNCTIONS
#undef PCRE2_COMPILE_FUNCTIONS
#undef PCRE2_PATTERN_INFO_FUNCTIONS
#undef PCRE2_MATCH_FUNCTIONS
#undef PCRE2_SUBSTRING_FUNCTIONS
#undef PCRE2_JIT_FUNCTIONS
#undef PCRE2_OTHER_FUNCTIONS
/* Re-define PCRE2_ADDWIDTH to use the external width value, if defined.
Otherwise, undefine the other macros and make PCRE2_ADDWIDTH a no-op, to reduce
/* Re-define PCRE2_SUFFIX to use the external width value, if defined.
Otherwise, undefine the other macros and make PCRE2_SUFFIX a no-op, to reduce
confusion. */
#ifdef PCRE2_DATA_WIDTH
#if PCRE2_DATA_WIDTH != 8 && PCRE2_DATA_WIDTH != 16 && PCRE2_DATA_WIDTH != 32
#error PCRE2_DATA_WIDTH must be 8, 16, or 32
#undef PCRE2_SUFFIX
#ifdef PCRE2_CODE_UNIT_WIDTH
#if PCRE2_CODE_UNIT_WIDTH != 8 && \
PCRE2_CODE_UNIT_WIDTH != 16 && \
PCRE2_CODE_UNIT_WIDTH != 32
#error PCRE2_CODE_UNIT_WIDTH must be 8, 16, or 32
#endif
#define PCRE2_ADDWIDTH(a) PCRE2_GLUE(a,PCRE2_DATA_WIDTH)
#define PCRE2_SUFFIX(a) PCRE2_GLUE(a, PCRE2_CODE_UNIT_WIDTH)
#else
#undef PCRE2_JOIN
#undef PCRE2_GLUE
#define PCRE2_ADDWIDTH(a) a
#define PCRE2_SUFFIX(a) a
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif

321
src/pcre2_byte_order.c Normal file
View File

@ -0,0 +1,321 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This module contains an internal function that tests a compiled pattern to
see if it was compiled with the opposite endianness. If so, it uses an
auxiliary local function to flip the appropriate bytes. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/* FIXME: this is currently a placeholder function */
#ifdef NEVER
/*************************************************
* Swap byte functions *
*************************************************/
/* The following functions swap the bytes of a pcre_uint16
and pcre_uint32 value.
Arguments:
value any number
Returns: the byte swapped value
*/
static pcre_uint32
swap_uint32(pcre_uint32 value)
{
return ((value & 0x000000ff) << 24) |
((value & 0x0000ff00) << 8) |
((value & 0x00ff0000) >> 8) |
(value >> 24);
}
static pcre_uint16
swap_uint16(pcre_uint16 value)
{
return (value >> 8) | (value << 8);
}
#endif /* NEVER */
/*************************************************
* Fix up a byte-flipped compiled regex *
*************************************************/
/* This function swaps the bytes of a compiled pattern, usually one that has
been saved and reloaded.
Argument: a pointer to the compiled pattern
Returns: 0 if the swap is successful, negative on error
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_pattern_to_host_byte_order(pcre2_code *code)
{
code=code;
return -1;
#ifdef NEVER
REAL_PCRE *re = (REAL_PCRE *)argument_re;
pcre_study_data *study;
#ifndef COMPILE_PCRE8
pcre_uchar *ptr;
int length;
#if defined SUPPORT_UTF && defined COMPILE_PCRE16
BOOL utf;
BOOL utf16_char;
#endif /* SUPPORT_UTF && COMPILE_PCRE16 */
#endif /* !COMPILE_PCRE8 */
if (re == NULL) return PCRE_ERROR_NULL;
if (re->magic_number == MAGIC_NUMBER)
{
if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
re->tables = tables;
return 0;
}
if (re->magic_number != REVERSED_MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;
if ((swap_uint32(re->flags) & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
re->magic_number = MAGIC_NUMBER;
re->size = swap_uint32(re->size);
re->options = swap_uint32(re->options);
re->flags = swap_uint32(re->flags);
re->limit_match = swap_uint32(re->limit_match);
re->limit_recursion = swap_uint32(re->limit_recursion);
#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
re->first_char = swap_uint16(re->first_char);
re->req_char = swap_uint16(re->req_char);
#elif defined COMPILE_PCRE32
re->first_char = swap_uint32(re->first_char);
re->req_char = swap_uint32(re->req_char);
#endif
re->max_lookbehind = swap_uint16(re->max_lookbehind);
re->top_bracket = swap_uint16(re->top_bracket);
re->top_backref = swap_uint16(re->top_backref);
re->name_table_offset = swap_uint16(re->name_table_offset);
re->name_entry_size = swap_uint16(re->name_entry_size);
re->name_count = swap_uint16(re->name_count);
re->ref_count = swap_uint16(re->ref_count);
re->tables = tables;
if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)
{
study = (pcre_study_data *)extra_data->study_data;
study->size = swap_uint32(study->size);
study->flags = swap_uint32(study->flags);
study->minlength = swap_uint32(study->minlength);
}
#ifndef COMPILE_PCRE8
ptr = (pcre_uchar *)re + re->name_table_offset;
length = re->name_count * re->name_entry_size;
#if defined SUPPORT_UTF && defined COMPILE_PCRE16
utf = (re->options & PCRE_UTF16) != 0;
utf16_char = FALSE;
#endif /* SUPPORT_UTF && COMPILE_PCRE16 */
while(TRUE)
{
/* Swap previous characters. */
while (length-- > 0)
{
#if defined COMPILE_PCRE16
*ptr = swap_uint16(*ptr);
#elif defined COMPILE_PCRE32
*ptr = swap_uint32(*ptr);
#endif
ptr++;
}
#if defined SUPPORT_UTF && defined COMPILE_PCRE16
if (utf16_char)
{
if (HAS_EXTRALEN(ptr[-1]))
{
/* We know that there is only one extra character in UTF-16. */
*ptr = swap_uint16(*ptr);
ptr++;
}
}
utf16_char = FALSE;
#endif /* SUPPORT_UTF */
/* Get next opcode. */
length = 0;
#if defined COMPILE_PCRE16
*ptr = swap_uint16(*ptr);
#elif defined COMPILE_PCRE32
*ptr = swap_uint32(*ptr);
#endif
switch (*ptr)
{
case OP_END:
return 0;
#if defined SUPPORT_UTF && defined COMPILE_PCRE16
case OP_CHAR:
case OP_CHARI:
case OP_NOT:
case OP_NOTI:
case OP_STAR:
case OP_MINSTAR:
case OP_PLUS:
case OP_MINPLUS:
case OP_QUERY:
case OP_MINQUERY:
case OP_UPTO:
case OP_MINUPTO:
case OP_EXACT:
case OP_POSSTAR:
case OP_POSPLUS:
case OP_POSQUERY:
case OP_POSUPTO:
case OP_STARI:
case OP_MINSTARI:
case OP_PLUSI:
case OP_MINPLUSI:
case OP_QUERYI:
case OP_MINQUERYI:
case OP_UPTOI:
case OP_MINUPTOI:
case OP_EXACTI:
case OP_POSSTARI:
case OP_POSPLUSI:
case OP_POSQUERYI:
case OP_POSUPTOI:
case OP_NOTSTAR:
case OP_NOTMINSTAR:
case OP_NOTPLUS:
case OP_NOTMINPLUS:
case OP_NOTQUERY:
case OP_NOTMINQUERY:
case OP_NOTUPTO:
case OP_NOTMINUPTO:
case OP_NOTEXACT:
case OP_NOTPOSSTAR:
case OP_NOTPOSPLUS:
case OP_NOTPOSQUERY:
case OP_NOTPOSUPTO:
case OP_NOTSTARI:
case OP_NOTMINSTARI:
case OP_NOTPLUSI:
case OP_NOTMINPLUSI:
case OP_NOTQUERYI:
case OP_NOTMINQUERYI:
case OP_NOTUPTOI:
case OP_NOTMINUPTOI:
case OP_NOTEXACTI:
case OP_NOTPOSSTARI:
case OP_NOTPOSPLUSI:
case OP_NOTPOSQUERYI:
case OP_NOTPOSUPTOI:
if (utf) utf16_char = TRUE;
#endif
/* Fall through. */
default:
length = PRIV(OP_lengths)[*ptr] - 1;
break;
case OP_CLASS:
case OP_NCLASS:
/* Skip the character bit map. */
ptr += 32/sizeof(pcre_uchar);
length = 0;
break;
case OP_XCLASS:
/* Reverse the size of the XCLASS instance. */
ptr++;
#if defined COMPILE_PCRE16
*ptr = swap_uint16(*ptr);
#elif defined COMPILE_PCRE32
*ptr = swap_uint32(*ptr);
#endif
#ifndef COMPILE_PCRE32
if (LINK_SIZE > 1)
{
/* LINK_SIZE can be 1 or 2 in 16 bit mode. */
ptr++;
*ptr = swap_uint16(*ptr);
}
#endif
ptr++;
length = (GET(ptr, -LINK_SIZE)) - (1 + LINK_SIZE + 1);
#if defined COMPILE_PCRE16
*ptr = swap_uint16(*ptr);
#elif defined COMPILE_PCRE32
*ptr = swap_uint32(*ptr);
#endif
if ((*ptr & XCL_MAP) != 0)
{
/* Skip the character bit map. */
ptr += 32/sizeof(pcre_uchar);
length -= 32/sizeof(pcre_uchar);
}
break;
}
ptr++;
}
/* Control should never reach here in 16/32 bit mode. */
#endif /* !COMPILE_PCRE8 */
#endif /* NEVER */
return 0;
}
/* End of pcre2_byte_order.c */

96
src/pcre2_compile.c Normal file
View File

@ -0,0 +1,96 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/* FIXME: this is currently a placeholder function */
/*************************************************
* Free compiled code *
*************************************************/
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_free_compiled_code(pcre2_context *context, pcre2_code *code)
{
context=context;code=code;
return;
}
/*************************************************
* Compile a Regular Expression *
*************************************************/
/* This function reads a regular expression in the form of a string and returns
a pointer to a block of store holding a compiled version of the expression.
Arguments:
context points to a PCRE2 context
pattern the regular expression
patlen the length of the pattern, or < 0 for zero-terminated
options option bits
errorcode pointer to error code variable (positive error code)
erroroffset pointer for offset in pattern where error was detected
Returns: pointer to compiled data block, or NULL on error,
with errorcode and erroroffset set
*/
/* FIXME: this is currently a placeholder function */
PCRE2_EXP_DEFN pcre2_code * PCRE2_CALL_CONVENTION
pcre2_compile(pcre2_context *context, PCRE2_SPTR pattern, int patlen,
uint32_t options, int *errorcode, size_t *erroroffset)
{
context = context; pattern = pattern; patlen = patlen; options = options;
*errorcode = 1;
*erroroffset = 0;
return NULL;
}
/* End of pcre2_compile.c */

138
src/pcre2_config.c Normal file
View File

@ -0,0 +1,138 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/*************************************************
* Return info about what features are configured *
*************************************************/
/* This function has an extensible interface so that additional items can be
added compatibly.
Arguments:
what what information is required
where where to put the information
Returns: 0 if data returned, negative on error
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_config(int what, void *where)
{
switch (what)
{
case PCRE2_CONFIG_BSR:
#ifdef BSR_ANYCRLF
*((int *)where) = 1;
#else
*((int *)where) = 0;
#endif
break;
case PCRE2_CONFIG_JIT:
#ifdef SUPPORT_JIT
*((int *)where) = 1;
#else
*((int *)where) = 0;
#endif
break;
case PCRE2_CONFIG_JITTARGET:
#ifdef SUPPORT_JIT
*((const char **)where) = PRIV(jit_get_target)();
#else
*((const char **)where) = NULL;
#endif
break;
case PCRE2_CONFIG_LINK_SIZE:
*((int *)where) = LINK_SIZE;
break;
case PCRE2_CONFIG_MATCH_LIMIT:
*((unsigned long int *)where) = MATCH_LIMIT;
break;
case PCRE2_CONFIG_MATCH_LIMIT_RECURSION:
*((unsigned long int *)where) = MATCH_LIMIT_RECURSION;
break;
case PCRE2_CONFIG_NEWLINE:
*((int *)where) = NEWLINE;
break;
case PCRE2_CONFIG_PARENS_LIMIT:
*((unsigned long int *)where) = PARENS_NEST_LIMIT;
break;
case PCRE2_CONFIG_POSIX_MALLOC_THRESHOLD:
*((int *)where) = POSIX_MALLOC_THRESHOLD;
break;
case PCRE2_CONFIG_STACKRECURSE:
#ifdef NO_RECURSE
*((int *)where) = 0;
#else
*((int *)where) = 1;
#endif
break;
case PCRE2_CONFIG_UTF:
#if defined SUPPORT_UTF
*((int *)where) = 1;
#else
*((int *)where) = 0;
#endif
break;
default: return PCRE2_ERROR_BADOPTION;
}
return 0;
}
/* End of pcre2_config.c */

357
src/pcre2_context.c Normal file
View File

@ -0,0 +1,357 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
#define CSIZE sizeof(struct pcre2_real_context)
/*************************************************
* Default malloc/free functions *
*************************************************/
/* Ignore the "user data" argument in each case. */
static void *default_malloc(size_t size, void *data)
{
data = data;
return malloc(size);
}
static void default_free(void *block, void *data)
{
data = data;
free(block);
}
/*************************************************
* Create/initialize, copy, free a context *
*************************************************/
PCRE2_EXP_DEFN size_t PCRE2_CALL_CONVENTION
pcre2_context_size(void)
{
return CSIZE;
}
PCRE2_EXP_DEFN pcre2_context * PCRE2_CALL_CONVENTION
pcre2_init_context(pcre2_context *context)
{
if (context == NULL)
{
context = malloc(CSIZE);
if (context == NULL) return NULL;
}
context->callout = NULL;
context->malloc = default_malloc;
context->free = default_free;
context->stack_malloc = default_malloc;
context->stack_free = default_free;
context->stack_guard = NULL;
context->user_data = NULL;
context->tables = PRIV(default_tables);
#ifdef BSR_ANYCRLF
context->bsr_convention = PCRE2_BSR_ANYCRLF;
#else
context->bsr_convention = PCRE2_BSR_UNICODE;
#endif
context->newline_convention = NEWLINE;
context->options = 0;
context->match_limit = MATCH_LIMIT;
context->parens_nest_limit = PARENS_NEST_LIMIT;
context->recursion_limit = MATCH_LIMIT_RECURSION;
return context;
}
PCRE2_EXP_DEFN pcre2_context * PCRE2_CALL_CONVENTION
pcre2_copy_context(pcre2_context *context)
{
pcre2_context *new = context->malloc(CSIZE, context->user_data);
if (new == NULL) return NULL;
memcpy(new, context, CSIZE);
return new;
}
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_free_context(pcre2_context *context)
{
context->free(context, context->user_data);
}
/*************************************************
* Extract settings from a context *
*************************************************/
PCRE2_EXP_DEFN uint32_t PCRE2_CALL_CONVENTION
pcre2_get_bsr_convention(pcre2_context *context)
{
return context->bsr_convention;
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
(*pcre2_get_callout(pcre2_context *context))(pcre2_callout_block *, void *)
{
return context->callout;
}
PCRE2_EXP_DEFN const unsigned char * PCRE2_CALL_CONVENTION
pcre2_get_character_tables(pcre2_context *context)
{
return context->tables;
}
PCRE2_EXP_DEFN uint32_t PCRE2_CALL_CONVENTION
pcre2_get_context_options(pcre2_context *context)
{
return context->options;
}
PCRE2_EXP_DEFN uint32_t PCRE2_CALL_CONVENTION
pcre2_get_match_limit(pcre2_context *context)
{
return context->match_limit;
}
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_get_memory_management(pcre2_context *context,
void *(**mptr)(size_t, void *),
void (**fptr)(void *, void *))
{
*mptr = context->malloc;
*fptr = context->free;
}
PCRE2_EXP_DEFN uint32_t PCRE2_CALL_CONVENTION
pcre2_get_newline_convention(pcre2_context *context)
{
return context->newline_convention;
}
PCRE2_EXP_DEFN uint32_t PCRE2_CALL_CONVENTION
pcre2_get_parens_nest_limit(pcre2_context *context)
{
return context->parens_nest_limit;
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
(*pcre2_get_recursion_guard(pcre2_context *context))(uint32_t, void *)
{
return context->stack_guard;
}
PCRE2_EXP_DEFN uint32_t PCRE2_CALL_CONVENTION
pcre2_get_recursion_limit(pcre2_context *context)
{
return context->recursion_limit;
}
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_get_recursion_memory_management(pcre2_context *context,
void *(**mptr)(size_t, void *),
void (**fptr)(void *, void *))
{
*mptr = context->stack_malloc;
*fptr = context->stack_free;
}
PCRE2_EXP_DEFN void * PCRE2_CALL_CONVENTION
pcre2_get_user_data(pcre2_context *context)
{
return context->user_data;
}
/*************************************************
* Set values in contexts *
*************************************************/
/* All these functions return 1 for success or 0 if invalid data is given. Only
some of the functions are able to test the validity of the data. */
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_bsr_convention(pcre2_context *context, uint32_t value)
{
switch(value)
{
case PCRE2_BSR_ANYCRLF:
case PCRE2_BSR_UNICODE:
context->bsr_convention = value;
return 1;
default:
return 0;
}
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_callout(pcre2_context *context,
int (*callout)(pcre2_callout_block *, void *))
{
context->callout = callout;
return 1;
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_character_tables(pcre2_context *context, const unsigned char *tables)
{
context->tables = tables;
return 1;
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_context_options(pcre2_context *context, uint32_t unset_bits,
uint32_t set_bits)
{
if ((set_bits & ~PCRE2_CONTEXT_OPTIONS) != 0) return 0;
context->options = (context->options & ~unset_bits) | set_bits;
return 1;
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_match_limit(pcre2_context *context, uint32_t limit)
{
context->match_limit = limit;
return 1;
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_memory_management(pcre2_context *context,
void * (*mymalloc)(size_t, void*),
void (*myfree)(void *, void *))
{
context->malloc = context->stack_malloc = mymalloc;
context->free = context->stack_free = myfree;
return 1;
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_newline_convention(pcre2_context *context, uint32_t newline)
{
switch(newline)
{
case PCRE2_NEWLINE_CR:
case PCRE2_NEWLINE_LF:
case PCRE2_NEWLINE_CRLF:
case PCRE2_NEWLINE_ANY:
case PCRE2_NEWLINE_ANYCRLF:
context->newline_convention = newline;
return 1;
default:
return 0;
}
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_parens_nest_limit(pcre2_context *context, uint32_t limit)
{
context->parens_nest_limit = limit;
return 1;
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_recursion_guard(pcre2_context *context,
int (*guard)(uint32_t, void *))
{
context->stack_guard = guard;
return 1;
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_recursion_limit(pcre2_context *context, uint32_t limit)
{
context->recursion_limit = limit;
return 1;
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_recursion_memory_management(pcre2_context *context,
void *(*mymalloc)(size_t, void *),
void (*myfree)(void *, void *))
{
context->stack_malloc = mymalloc;
context->stack_free = myfree;
return 1;
}
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_user_data(pcre2_context *context, void *data)
{
context->user_data = data;
return 1;
}
/* End of pcre2_context.c */

88
src/pcre2_dfa_exec.c Normal file
View File

@ -0,0 +1,88 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/*************************************************
* Match a pattern using the DFA algorithm *
*************************************************/
/* This function matches a compiled pattern to a subject string, using the
alternate matching algorithm that finds all matches at once.
Arguments:
context points to a PCRE2 context
code points to the compiled pattern
subject subject string
length length of subject string
startoffset where to start matching in the subject
options option bits
match_data points to a match data structure
workspace pointer to workspace
wscount size of workspace
Returns: > 0 => number of match offset pairs placed in offsets
= 0 => offsets overflowed; longest matches are present
-1 => failed to match
< -1 => some kind of unexpected problem
*/
/* FIXME: this is currently a placeholder function */
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_dfa_exec(pcre2_context *context, const pcre2_code *code,
PCRE2_SPTR subject, int length, size_t startoffset, uint32_t options,
pcre2_match_data *match_data, int *workspace, size_t wscount)
{
context = context; code = code; subject = subject; length = length;
startoffset = startoffset; options = options; match_data = match_data;
workspace = workspace; wscount = wscount;
return PCRE2_ERROR_NOMATCH;
}
/* End of pcre2_dfa_exec.c */

89
src/pcre2_error.c Normal file
View File

@ -0,0 +1,89 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/* FIXME: this is currently a placeholder function */
/*************************************************
* Return error message *
*************************************************/
/* This function copies an error message into a buffer whose units are of an
appropriate width. Error numbers are positive for compile-time errors, and
negative for exec-time errors.
Arguments:
enumber error number
buffer where to put the message (zero terminated)
size size of the buffer
Returns: length of message if all is well
-1 on error
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_get_error_message(int enumber, PCRE2_UCHAR *buffer, size_t size)
{
size_t i;
const char *message = "Dummy error message";
enumber=enumber;
if (size == 0) return -1;
for (i = 0; *message != 0; i++)
{
if (i >= size - 1)
{
buffer[i] = 0; /* Terminate partial message */
return -1;
}
buffer[i] = *message++;
}
buffer[i] = 0;
return i;
}
/* End of pcre2_error.c */

84
src/pcre2_exec.c Normal file
View File

@ -0,0 +1,84 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/*************************************************
* Execute a Regular Expression *
*************************************************/
/* This function applies a compiled re to a subject string and picks out
portions of the string if it matches. Two elements in the vector are set for
each substring: the offsets to the start and end of the substring.
Arguments:
context points a PCRE2 context
code points to the compiled expression
subject points to the subject string
length length of subject string (may contain binary zeros)
start_offset where to start in the subject string
options option bits
match_data points to a match_data block
Returns: > 0 => success; value is the number of ovector pairs filled
= 0 => success, but ovector is not big enough
-1 => failed to match (PCRE_ERROR_NOMATCH)
< -1 => some kind of unexpected problem
*/
/* FIXME: this is currently a placeholder function */
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_exec(pcre2_context *context, const pcre2_code *code,
PCRE2_SPTR subject, int length, size_t start_offset, uint32_t options,
pcre2_match_data *match_data)
{
context=context;code=code;subject=subject;length=length;
start_offset=start_offset; options=options; match_data=match_data;
return PCRE2_ERROR_NOMATCH;
}
/* End of pcre2_exec.c */

View File

@ -1,14 +1,50 @@
/* This is a placeholder, just enough to allow dummy functions to compile */
#include <ctype.h>
#include <limits.h>
#include <stddef.h>
/* This is a placeholder, just enough to allow dummy functions to compile, but
with some of the new PCRE2 context stuff added. */
#include <ctype.h>
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "pcre2.h"
#define PUBL(name) pcre_##name
#define PRIV(name) _pcre_##name
#define PUBL(name) pcre2_##name
#define PRIV(name) _pcre2_##name
#define PCRE2_CALL_CONVENTION
extern const uint8_t PRIV(default_tables)[];
/* What follows is "real" code for PCRE2. */
/* Only these bits are allowed when setting context options. */
#define PCRE2_CONTEXT_OPTIONS (\
PCRE2_ALT_BSUX|PCRE2_DOLLAR_ENDONLY|PCRE2_DUPNAMES|PCRE2_ALLOW_EMPTY_CLASS|\
PCRE2_MATCH_UNSET_BACKREF|PCRE2_NEVER_UTF|PCRE2_NEVER_UCP|PCRE2_UTF|\
PCRE2_UCP)
/* The real context structure */
struct pcre2_real_context {
const unsigned char *tables;
int (*callout)(pcre2_callout_block *, void *);
void * (*malloc)(size_t, void *);
void (*free)(void *, void *);
void * (*stack_malloc)(size_t, void *);
void (*stack_free)(void *, void *);
int (*stack_guard)(uint32_t, void *);
void *user_data;
uint16_t bsr_convention;
uint16_t newline_convention;
uint32_t options;
uint32_t match_limit;
uint32_t parens_nest_limit;
uint32_t recursion_limit;
};
/* End of pcre2_internal.h */

82
src/pcre2_jit_compile.c Normal file
View File

@ -0,0 +1,82 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/*************************************************
* JIT compile a Regular Expression *
*************************************************/
/* This function used JIT to convert a previously-compiled pattern into machine
code.
Arguments:
context points to a PCRE2 context
code a compiled pattern
options JIT option bits
Returns: nothing
*/
/* FIXME: this is currently a placeholder function */
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_jit_compile(pcre2_context *context, pcre2_code *code, uint32_t options)
{
#ifndef SUPPORT_JIT
(void)context;
(void)code;
(void)options;
#else /* SUPPORT_JIT */
context = context; code=code; options = options; /* Dummy.... */
#endif /* SUPPORT_JIT */
}
/* End of pcre2_jit_compile.c */

100
src/pcre2_jit_exec.c Normal file
View File

@ -0,0 +1,100 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/*************************************************
* Do a JIT pattern match *
*************************************************/
/* This function runs a JIT pattern match.
Arguments:
context points a PCRE2 context
code points to the compiled expression
subject points to the subject string
length length of subject string (may contain binary zeros)
start_offset where to start in the subject string
options option bits
match_data points to a match_data block
jit_stack points to a JIT stack
Returns: > 0 => success; value is the number of ovector pairs filled
= 0 => success, but ovector is not big enough
-1 => failed to match (PCRE_ERROR_NOMATCH)
< -1 => some kind of unexpected problem
*/
/* FIXME: this is currently a placeholder function */
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_jit_exec(pcre2_context *context, const pcre2_code *code,
PCRE2_SPTR subject, int length, size_t start_offset, uint32_t options,
pcre2_match_data *match_data, pcre2_jit_stack *jit_stack)
{
#ifndef SUPPORT_JIT
(void)context;
(void)code;
(void)subject;
(void)length;
(void)start_offset;
(void)options;
(void)match_data;
(void)jit_stack;
return PCRE2_ERROR_NOMATCH;
#else /* SUPPORT_JIT */
/* Dummy code */
context=context;code=code;subject=subject;length=length;
start_offset=start_offset; options=options; match_data=match_data;
jit_stack=jit_stack;
return PCRE2_ERROR_NOMATCH;
#endif /* SUPPORT_JIT */
}
/* End of pcre2_jit_exec.c */

128
src/pcre2_jit_misc.c Normal file
View File

@ -0,0 +1,128 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/* FIXME: these are dummy functions */
/*************************************************
* Free unused JIT memory *
*************************************************/
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_jit_free_unused_memory(pcre2_context *context)
{
#ifndef SUPPORT_JIT
(void)context; /* Suppress warning */
#else /* SUPPORT_JIT */
context=context; /* Dummy */
#endif /* SUPPORT_JIT */
}
/*************************************************
* Allocate a JIT stack *
*************************************************/
PCRE2_EXP_DEFN pcre2_jit_stack * PCRE2_CALL_CONVENTION
pcre2_jit_stack_alloc(pcre2_context *context, size_t startsize, size_t maxsize)
{
#ifndef SUPPORT_JIT
(void)context;
(void)startsize;
(void)maxsize;
return NULL;
#else /* SUPPORT_JIT */
context=context;startsize=startsize;maxsize=maxsize;
return NULL;
#endif
}
/*************************************************
* Assign a JIT stack to a pattern *
*************************************************/
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_jit_stack_assign(pcre2_context *context, const pcre2_code *code,
pcre2_jit_callback callback, void *callback_data)
{
#ifndef SUPPORT_JIT
(void)context;
(void)code;
(void)callback;
(void)callback_data;
#else /* SUPPORT_JIT */
context=context;code=code;callback=callback;callback_data=callback_data;
#endif /* SUPPORT_JIT */
}
/*************************************************
* Free a JIT stack *
*************************************************/
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_jit_stack_free(pcre2_context *context, pcre2_jit_stack *jit_stack)
{
#ifndef SUPPORT_JIT
(void)context;
(void)jit_stack;
#else /* SUPPORT_JIT */
context=context;jit_stack=jit_stack;
#endif /* SUPPORT_JIT */
}
/* End of pcre2_jit_misc.c */

158
src/pcre2_maketables.c Normal file
View File

@ -0,0 +1,158 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This module contains the external function pcre_maketables(), which builds
character tables for PCRE in the current locale. The file is compiled on its
own as part of the PCRE library. However, it is also included in the
compilation of dftables.c, in which case the macro DFTABLES is defined. */
#ifndef DFTABLES
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "pcre2_internal.h"
#endif
/*************************************************
* Create PCRE2 character tables *
*************************************************/
/* This function builds a set of character tables for use by PCRE2 and returns
a pointer to them. They are build using the ctype functions, and consequently
their contents will depend upon the current locale setting. When compiled as
part of the library, the store is obtained via the context malloc, but when
compiled inside dftables, use malloc().
Arguments: a PCRE2 context (for malloc)
Returns: pointer to the contiguous block of data
*/
/* FIXME: temporarily a dummy, until pcre2_internal is complete. */
PCRE2_EXP_DEFN const unsigned char * PCRE2_CALL_CONVENTION
pcre2_maketables(pcre2_context *context)
{
context=context;
return NULL;
#ifdef NEVER
unsigned char *yield, *p;
int i;
#ifndef DFTABLES
yield = (unsigned char*)context->malloc(tables_length);
#else
yield = (unsigned char*)malloc(tables_length);
#endif
if (yield == NULL) return NULL;
p = yield;
/* First comes the lower casing table */
for (i = 0; i < 256; i++) *p++ = tolower(i);
/* Next the case-flipping table */
for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);
/* Then the character class tables. Don't try to be clever and save effort on
exclusive ones - in some locales things may be different.
Note that the table for "space" includes everything "isspace" gives, including
VT in the default locale. This makes it work for the POSIX class [:space:].
From release 8.34 is is also correct for Perl space, because Perl added VT at
release 5.18.
Note also that it is possible for a character to be alnum or alpha without
being lower or upper, such as "male and female ordinals" (\xAA and \xBA) in the
fr_FR locale (at least under Debian Linux's locales as of 12/2005). So we must
test for alnum specially. */
memset(p, 0, cbit_length);
for (i = 0; i < 256; i++)
{
if (isdigit(i)) p[cbit_digit + i/8] |= 1 << (i&7);
if (isupper(i)) p[cbit_upper + i/8] |= 1 << (i&7);
if (islower(i)) p[cbit_lower + i/8] |= 1 << (i&7);
if (isalnum(i)) p[cbit_word + i/8] |= 1 << (i&7);
if (i == '_') p[cbit_word + i/8] |= 1 << (i&7);
if (isspace(i)) p[cbit_space + i/8] |= 1 << (i&7);
if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);
if (isgraph(i)) p[cbit_graph + i/8] |= 1 << (i&7);
if (isprint(i)) p[cbit_print + i/8] |= 1 << (i&7);
if (ispunct(i)) p[cbit_punct + i/8] |= 1 << (i&7);
if (iscntrl(i)) p[cbit_cntrl + i/8] |= 1 << (i&7);
}
p += cbit_length;
/* Finally, the character type table. In this, we used to exclude VT from the
white space chars, because Perl didn't recognize it as such for \s and for
comments within regexes. However, Perl changed at release 5.18, so PCRE changed
at release 8.34. */
for (i = 0; i < 256; i++)
{
int x = 0;
if (isspace(i)) x += ctype_space;
if (isalpha(i)) x += ctype_letter;
if (isdigit(i)) x += ctype_digit;
if (isxdigit(i)) x += ctype_xdigit;
if (isalnum(i) || i == '_') x += ctype_word;
/* Note: strchr includes the terminating zero in the characters it considers.
In this instance, that is ok because we want binary zero to be flagged as a
meta-character, which in this sense is any character that terminates a run
of data characters. */
if (strchr("\\*+?{^.$|()[", i) != 0) x += ctype_meta;
*p++ = x;
}
return yield;
#endif
}
/* End of pcre2_maketables.c */

154
src/pcre2_match_data.c Normal file
View File

@ -0,0 +1,154 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/* FIXME: these are all dummy functions */
/*************************************************
* Create a match data block *
*************************************************/
PCRE2_EXP_DEFN pcre2_match_data * PCRE2_CALL_CONVENTION
pcre2_create_match_data(pcre2_context *context, size_t ovecsize)
{
context=context;ovecsize=ovecsize;
return NULL;
}
/*************************************************
* Free a match data block *
*************************************************/
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_free_match_data(pcre2_context *context, pcre2_match_data *match_data)
{
context=context;match_data=match_data;
return;
}
/*************************************************
* Get left-most code unit in match *
*************************************************/
PCRE2_EXP_DEFN size_t PCRE2_CALL_CONVENTION
pcre2_get_leftchar(pcre2_match_data *match_data)
{
match_data=match_data;
return 0;
}
/*************************************************
* Get last mark in match *
*************************************************/
PCRE2_EXP_DEFN PCRE2_SPTR PCRE2_CALL_CONVENTION
pcre2_get_mark(pcre2_match_data *match_data)
{
match_data=match_data;
return NULL;
}
/*************************************************
* Get pointer to ovector *
*************************************************/
PCRE2_EXP_DEFN size_t * PCRE2_CALL_CONVENTION
pcre2_get_ovector(pcre2_match_data *match_data)
{
match_data=match_data;
return NULL;
}
/*************************************************
* Get number of ovector slots *
*************************************************/
PCRE2_EXP_DEFN size_t PCRE2_CALL_CONVENTION
pcre2_get_ovector_slots(pcre2_match_data *match_data)
{
match_data=match_data;
return 0;
}
/*************************************************
* Get right-most code unit in match *
*************************************************/
PCRE2_EXP_DEFN size_t PCRE2_CALL_CONVENTION
pcre2_get_rightchar(pcre2_match_data *match_data)
{
match_data=match_data;
return 0;
}
/*************************************************
* Get starting code unit in match *
*************************************************/
PCRE2_EXP_DEFN size_t PCRE2_CALL_CONVENTION
pcre2_get_startchar(pcre2_match_data *match_data)
{
match_data=match_data;
return 0;
}
/* End of pcre2_match_data.c */

71
src/pcre2_pattern_info.c Normal file
View File

@ -0,0 +1,71 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/*************************************************
* Return info about compiled pattern *
*************************************************/
/*
Arguments:
code points to compiled code
what what information is required
where where to put the information
Returns: 0 if data returned, negative on error
*/
/* FIXME: this is currently a placeholder function */
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_pattern_info(const pcre2_code *code, uint32_t what, void *where)
{
code=code;what=what;where=where;
return -1;
}
/* End of pcre2_pattern_info.c */

1
src/pcre2_printint.c Normal file
View File

@ -0,0 +1 @@
/* This is a placeholder for pcre2_printint.c */

352
src/pcre2_substring.c Normal file
View File

@ -0,0 +1,352 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/* FIXME: most of these are currently placeholder functions */
/*************************************************
* Copy named captured string to given buffer *
*************************************************/
/* This function copies a single captured substring into a given buffer,
identifying it by name. If the regex permits duplicate names, the first
substring that is set is chosen.
Arguments:
match_data points to the match data
stringname the name of the required substring
buffer where to put the substring
size the size of the buffer
Returns: if successful:
the length of the copied string, not including the zero
that is put on the end; can be zero
if not successful, a negative error code:
PCRE2_ERROR_NOMEMORY: buffer too small
PCRE2_ERROR_NOSUBSTRING: no such captured substring
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_copy_named_substring(pcre2_match_data *match_data, PCRE2_SPTR stringname,
PCRE2_UCHAR *buffer, size_t size)
{
match_data=match_data;stringname=stringname;buffer=buffer;size=size;
return PCRE2_ERROR_NOSUBSTRING;
}
/*************************************************
* Copy numbered captured string to given buffer *
*************************************************/
/* This function copies a single captured substring into a given buffer,
identifying it by number.
Arguments:
match_data points to the match data
stringnumber the number of the required substring
buffer where to put the substring
size the size of the buffer
Returns: if successful:
the length of the copied string, not including the zero
that is put on the end; can be zero
if not successful, a negative error code:
PCRE2_ERROR_NOMEMORY: buffer too small
PCRE2_ERROR_NOSUBSTRING: no such captured substring
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_copy_substring(pcre2_match_data *match_data, int stringnumber,
PCRE2_UCHAR *buffer, size_t size)
{
match_data=match_data;stringnumber=stringnumber;buffer=buffer;size=size;
return PCRE2_ERROR_NOSUBSTRING;
}
/*************************************************
* Free memory obtained by get_substring *
*************************************************/
/* This function exists for the benefit of people calling PCRE from non-C
programs that can call its functions, but not free() itself.
Arguments:
context points to a PCRE2 context
string the result of a previous pcre2_get_substring()
Returns: nothing
*/
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_free_substring(pcre2_context *context, PCRE2_UCHAR *string)
{
context->free(string, context->user_data);
return;
}
/*************************************************
* Free memory obtained by get_substring_list *
*************************************************/
/* This function exists for the benefit of people calling PCRE from non-C
programs that can call its functions, but not free() itself.
Arguments:
context points to a PCRE2 context
list the result of a previous pcre2_get_substring_list()
Returns: nothing
*/
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_free_substring_list(pcre2_context *context, PCRE2_SPTR *list)
{
context->free(list, context->user_data);
return;
}
/*************************************************
* Extract named captured string *
*************************************************/
/* This function copies a single captured substring, identified by name, into
new memory. If the regex permits duplicate names, the first substring that is
set is chosen.
Arguments:
context points to a PCRE2 context
match_data pointer to match_data
stringname the name of the required substring
stringptr where to put the pointer
Returns: if successful:
the length of the copied string, not including the zero
that is put on the end; can be zero
if not successful, a negative value:
PCRE2_ERROR_NOMEMORY: couldn't get memory
PCRE2_ERROR_NOSUBSTRING: no such captured substring
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_get_named_substring(pcre2_context *context, pcre2_match_data *match_data,
PCRE2_SPTR stringname, PCRE2_UCHAR **stringptr)
{
context=context;match_data=match_data;stringname=stringname;stringptr=stringptr;
return PCRE2_ERROR_NOSUBSTRING;
}
/*************************************************
* Get length of a named substring *
*************************************************/
/* This function returns the length of a named captured substring. If the regex
permits duplicate names, the first substring that is set is chosen.
Arguments:
match_data pointer to match data
stringname the name of the required substring
Returns: a non-negative length if successful
a negative error code otherwise
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_get_named_substring_length(pcre2_match_data *match_data,
PCRE2_SPTR stringname)
{
match_data=match_data;stringname=stringname;
return PCRE2_ERROR_NOSUBSTRING;
}
/*************************************************
* Find (multiple) entries for named string *
*************************************************/
/* This is used by the local get_first_set() function, as well as being
generally available. It is used when duplicated names are permitted.
Arguments:
code the compiled regex
stringname the name whose entries required
firstptr where to put the pointer to the first entry
lastptr where to put the pointer to the last entry
Returns: the length of each entry, or a negative number
(PCRE2_ERROR_NOSUBSTRING) if not found
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_get_stringtable_entries(const pcre2_code *code, PCRE2_SPTR stringname,
PCRE2_UCHAR **firstptr, PCRE2_UCHAR **lastptr)
{
code=code;stringname=stringname;firstptr=firstptr;lastptr=lastptr;
return PCRE2_ERROR_NOSUBSTRING;
}
/*************************************************
* Extract captured string to new memory *
*************************************************/
/* This function copies a single captured substring into a piece of new
memory.
Arguments:
context points to a PCRE2 context
match_data points to match data
stringnumber the number of the required substring
stringptr where to put a pointer to the substring
Returns: if successful:
the length of the string, not including the zero that
is put on the end; can be zero
if not successful a negative error code:
PCRE2_ERROR_NOMEMORY: failed to get memory
PCRE2_ERROR_NOSUBSTRING: substring not present
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_get_substring(pcre2_context *context, pcre2_match_data *match_data,
int stringnumber, PCRE2_UCHAR **stringptr)
{
context=context;match_data=match_data;stringnumber=stringnumber;
stringptr=stringptr;
return PCRE2_ERROR_NOSUBSTRING;
}
/*************************************************
* Get length of a numbered substring *
*************************************************/
/* This function returns the length of a captured substring.
Arguments:
match_data pointer to match data
stringnumber the number of the required substring
Returns: a non-negative length if successful
a negative error code otherwise
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_get_substring_length(pcre2_match_data *match_data,
int stringnumber)
{
match_data=match_data;stringnumber=stringnumber;
return PCRE2_ERROR_NOSUBSTRING;
}
/*************************************************
* Extract all captured strings to new memory *
*************************************************/
/* This function gets one chunk of memory and builds a list of pointers and all
the captured substrings in it. A NULL pointer is put on the end of the list.
Arguments:
context points to a PCRE2 context
match_data points to the match data
listptr set to point to the list of pointers
Returns: if successful: 0
if not successful, a negative error code:
PCRE2_ERROR_NOMEMORY: failed to get memory
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_get_substring_list(pcre2_context *context, pcre2_match_data *match_data,
PCRE2_UCHAR ***listptr)
{
context=context;match_data=match_data;listptr=listptr;
return PCRE2_ERROR_NOMEMORY;
}
/*************************************************
* Find number for named string *
*************************************************/
/* This function is used by the local get_first_set() function, as well
as being generally available. It assumes that names are unique.
Arguments:
code the compiled regex
stringname the name whose number is required
Returns: the number of the named parentheses, or a negative number
(PCRE2_ERROR_NOSUBSTRING) if not found
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_get_substring_number(const pcre2_code *code, PCRE2_SPTR stringname)
{
code=code;stringname=stringname;
return PCRE2_ERROR_NOSUBSTRING;
}
/* End of pcre2_substring.c */

View File

@ -88,7 +88,8 @@ Returns: number of characters, excluding trailing zero
or PCRE_ERROR_BADLENGTH if buffer too small
*/
PCRE2_EXP_DEFN int pcre2_version(PCRE2_UCHAR *buffer, size_t size)
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_version(PCRE2_UCHAR *buffer, size_t size)
{
PCRE2_UCHAR *t = buffer;
const char *v = (XSTRING(Z PCRE2_PRERELEASE)[1] == 0)?

9
src/pcre2grep.c Normal file
View File

@ -0,0 +1,9 @@
/* This is a dummy placeholder */
#include <stdio.h>
int main(void)
{
printf("This is a dummy placeholder file for pcre2grep.\n");
return 0;
}

454
src/pcre2posix.c Normal file
View File

@ -0,0 +1,454 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This module is a wrapper that provides a POSIX API to the underlying PCRE2
functions. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* Ensure that the PCRE2POSIX_EXP_xxx macros are set appropriately for
compiling these functions. This must come before including pcre2posix.h, where
they are set for an application (using these functions) if they have not
previously been set. */
#if defined(_WIN32) && !defined(PCRE2_STATIC)
# define PCRE2POSIX_EXP_DECL extern __declspec(dllexport)
# define PCRE2POSIX_EXP_DEFN __declspec(dllexport)
#endif
/* We include pcre2.h before pcre2_internal.h so that the PCRE2 library
functions are declared as "import" for Windows by defining PCRE2_EXP_DECL as
"import". This is needed even though pcre2_internal.h itself includes pcre2.h,
because it does so after it has set PCRE2_EXP_DECL to "export" if it is not
already set. */
#include "pcre2.h"
#include "pcre2_internal.h"
#include "pcre2posix.h"
/* FIXME: The compile/match functions have not yet been converted to PCRE2.
They currently always fail. */
/* FIXME: This needs re-designing to be less silly. */
/* Table to translate PCRE2 compile time error codes into POSIX error codes. */
static const int eint[] = {
0, /* no error */
REG_EESCAPE, /* \ at end of pattern */
REG_EESCAPE, /* \c at end of pattern */
REG_EESCAPE, /* unrecognized character follows \ */
REG_BADBR, /* numbers out of order in {} quantifier */
/* 5 */
REG_BADBR, /* number too big in {} quantifier */
REG_EBRACK, /* missing terminating ] for character class */
REG_ECTYPE, /* invalid escape sequence in character class */
REG_ERANGE, /* range out of order in character class */
REG_BADRPT, /* nothing to repeat */
/* 10 */
REG_BADRPT, /* operand of unlimited repeat could match the empty string */
REG_ASSERT, /* internal error: unexpected repeat */
REG_BADPAT, /* unrecognized character after (? */
REG_BADPAT, /* POSIX named classes are supported only within a class */
REG_EPAREN, /* missing ) */
/* 15 */
REG_ESUBREG, /* reference to non-existent subpattern */
REG_INVARG, /* erroffset passed as NULL */
REG_INVARG, /* unknown option bit(s) set */
REG_EPAREN, /* missing ) after comment */
REG_ESIZE, /* parentheses nested too deeply */
/* 20 */
REG_ESIZE, /* regular expression too large */
REG_ESPACE, /* failed to get memory */
REG_EPAREN, /* unmatched parentheses */
REG_ASSERT, /* internal error: code overflow */
REG_BADPAT, /* unrecognized character after (?< */
/* 25 */
REG_BADPAT, /* lookbehind assertion is not fixed length */
REG_BADPAT, /* malformed number or name after (?( */
REG_BADPAT, /* conditional group contains more than two branches */
REG_BADPAT, /* assertion expected after (?( */
REG_BADPAT, /* (?R or (?[+-]digits must be followed by ) */
/* 30 */
REG_ECTYPE, /* unknown POSIX class name */
REG_BADPAT, /* POSIX collating elements are not supported */
REG_INVARG, /* this version of PCRE2 is not compiled with PCRE2_UTF8 support */
REG_BADPAT, /* spare error */
REG_BADPAT, /* character value in \x{} or \o{} is too large */
/* 35 */
REG_BADPAT, /* invalid condition (?(0) */
REG_BADPAT, /* \C not allowed in lookbehind assertion */
REG_EESCAPE, /* PCRE2 does not support \L, \l, \N, \U, or \u */
REG_BADPAT, /* number after (?C is > 255 */
REG_BADPAT, /* closing ) for (?C expected */
/* 40 */
REG_BADPAT, /* recursive call could loop indefinitely */
REG_BADPAT, /* unrecognized character after (?P */
REG_BADPAT, /* syntax error in subpattern name (missing terminator) */
REG_BADPAT, /* two named subpatterns have the same name */
REG_BADPAT, /* invalid UTF-8 string */
/* 45 */
REG_BADPAT, /* support for \P, \p, and \X has not been compiled */
REG_BADPAT, /* malformed \P or \p sequence */
REG_BADPAT, /* unknown property name after \P or \p */
REG_BADPAT, /* subpattern name is too long (maximum 32 characters) */
REG_BADPAT, /* too many named subpatterns (maximum 10,000) */
/* 50 */
REG_BADPAT, /* repeated subpattern is too long */
REG_BADPAT, /* octal value is greater than \377 (not in UTF-8 mode) */
REG_BADPAT, /* internal error: overran compiling workspace */
REG_BADPAT, /* internal error: previously-checked referenced subpattern not found */
REG_BADPAT, /* DEFINE group contains more than one branch */
/* 55 */
REG_BADPAT, /* repeating a DEFINE group is not allowed */
REG_INVARG, /* inconsistent NEWLINE options */
REG_BADPAT, /* \g is not followed followed by an (optionally braced) non-zero number */
REG_BADPAT, /* a numbered reference must not be zero */
REG_BADPAT, /* an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT) */
/* 60 */
REG_BADPAT, /* (*VERB) not recognized */
REG_BADPAT, /* number is too big */
REG_BADPAT, /* subpattern name expected */
REG_BADPAT, /* digit expected after (?+ */
REG_BADPAT, /* ] is an invalid data character in JavaScript compatibility mode */
/* 65 */
REG_BADPAT, /* different names for subpatterns of the same number are not allowed */
REG_BADPAT, /* (*MARK) must have an argument */
REG_INVARG, /* this version of PCRE2 is not compiled with PCRE2_UCP support */
REG_BADPAT, /* \c must be followed by an ASCII character */
REG_BADPAT, /* \k is not followed by a braced, angle-bracketed, or quoted name */
/* 70 */
REG_BADPAT, /* internal error: unknown opcode in find_fixedlength() */
REG_BADPAT, /* \N is not supported in a class */
REG_BADPAT, /* too many forward references */
REG_BADPAT, /* disallowed UTF-8/16/32 code point (>= 0xd800 && <= 0xdfff) */
REG_BADPAT, /* invalid UTF-16 string (should not occur) */
/* 75 */
REG_BADPAT, /* overlong MARK name */
REG_BADPAT, /* character value in \u.... sequence is too large */
REG_BADPAT, /* invalid UTF-32 string (should not occur) */
REG_BADPAT, /* setting UTF is disabled by the application */
REG_BADPAT, /* non-hex character in \\x{} (closing brace missing?) */
/* 80 */
REG_BADPAT, /* non-octal character in \o{} (closing brace missing?) */
REG_BADPAT, /* missing opening brace after \o */
REG_BADPAT, /* parentheses too deeply nested */
REG_BADPAT, /* invalid range in character class */
REG_BADPAT, /* group name must start with a non-digit */
/* 85 */
REG_BADPAT /* parentheses too deeply nested (stack check) */
};
/* Table of texts corresponding to POSIX error codes */
static const char *const pstring[] = {
"", /* Dummy for value 0 */
"internal error", /* REG_ASSERT */
"invalid repeat counts in {}", /* BADBR */
"pattern error", /* BADPAT */
"? * + invalid", /* BADRPT */
"unbalanced {}", /* EBRACE */
"unbalanced []", /* EBRACK */
"collation error - not relevant", /* ECOLLATE */
"bad class", /* ECTYPE */
"bad escape sequence", /* EESCAPE */
"empty expression", /* EMPTY */
"unbalanced ()", /* EPAREN */
"bad range inside []", /* ERANGE */
"expression too big", /* ESIZE */
"failed to get memory", /* ESPACE */
"bad back reference", /* ESUBREG */
"bad argument", /* INVARG */
"match failed" /* NOMATCH */
};
/*************************************************
* Translate error code to string *
*************************************************/
PCRE2POSIX_EXP_DEFN size_t PCRE2_CALL_CONVENTION
regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
{
const char *message, *addmessage;
size_t length, addlength;
message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))?
"unknown error code" : pstring[errcode];
length = strlen(message) + 1;
addmessage = " at offset ";
addlength = (preg != NULL && (int)preg->re_erroffset != -1)?
strlen(addmessage) + 6 : 0;
if (errbuf_size > 0)
{
if (addlength > 0 && errbuf_size >= length + addlength)
sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset);
else
{
strncpy(errbuf, message, errbuf_size - 1);
errbuf[errbuf_size-1] = 0;
}
}
return length + addlength;
}
/*************************************************
* Free store held by a regex *
*************************************************/
PCRE2POSIX_EXP_DEFN void PCRE2_CALL_CONVENTION
regfree(regex_t *preg)
{
free(preg->re_pcre2_code);
}
/*************************************************
* Compile a regular expression *
*************************************************/
/*
Arguments:
preg points to a structure for recording the compiled expression
pattern the pattern to compile
cflags compilation flags
Returns: 0 on success
various non-zero codes on failure
*/
PCRE2POSIX_EXP_DEFN int PCRE2_CALL_CONVENTION
regcomp(regex_t *preg, const char *pattern, int cflags)
{
/* FIXME: */
preg=preg;pattern=pattern;cflags=cflags;
return REG_BADPAT;
#ifdef NEVER
const char *errorptr;
int erroffset;
int errorcode;
int options = 0;
int re_nsub = 0;
if ((cflags & REG_ICASE) != 0) options |= PCRE2_CASELESS;
if ((cflags & REG_NEWLINE) != 0) options |= PCRE2_MULTILINE;
if ((cflags & REG_DOTALL) != 0) options |= PCRE2_DOTALL;
if ((cflags & REG_NOSUB) != 0) options |= PCRE2_NO_AUTO_CAPTURE;
if ((cflags & REG_UTF8) != 0) options |= PCRE2_UTF8;
if ((cflags & REG_UCP) != 0) options |= PCRE2_UCP;
if ((cflags & REG_UNGREEDY) != 0) options |= PCRE2_UNGREEDY;
preg->re_pcre = pcre_compile2(pattern, options, &errorcode, &errorptr,
&erroffset, NULL);
preg->re_erroffset = erroffset;
/* Safety: if the error code is too big for the translation vector (which
should not happen, but we all make mistakes), return REG_BADPAT. */
if (preg->re_pcre == NULL)
{
return (errorcode < (int)(sizeof(eint)/sizeof(const int)))?
eint[errorcode] : REG_BADPAT;
}
(void)pcre_fullinfo((const pcre *)preg->re_pcre, NULL, PCRE2_INFO_CAPTURECOUNT,
&re_nsub);
preg->re_nsub = (size_t)re_nsub;
return 0;
#endif /* NEVER */
}
/*************************************************
* Match a regular expression *
*************************************************/
/* Unfortunately, PCRE requires 3 ints of working space for each captured
substring, so we have to get and release working store instead of just using
the POSIX structures as was done in earlier releases when PCRE needed only 2
ints. However, if the number of possible capturing brackets is small, use a
block of store on the stack, to reduce the use of malloc/free. The threshold is
in a macro that can be changed at configure time.
If REG_NOSUB was specified at compile time, the PCRE_NO_AUTO_CAPTURE flag will
be set. When this is the case, the nmatch and pmatch arguments are ignored, and
the only result is yes/no/error. */
PCRE2POSIX_EXP_DEFN int PCRE2_CALL_CONVENTION
regexec(const regex_t *preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags)
{
/* FIXME */
preg=preg;string=string;nmatch=nmatch;pmatch=pmatch;eflags=eflags;
return REG_NOMATCH;
#ifdef NEVER
int rc, so, eo;
int options = 0;
int *ovector = NULL;
int small_ovector[POSIX_MALLOC_THRESHOLD * 3];
BOOL allocated_ovector = FALSE;
BOOL nosub =
(REAL_PCRE2_OPTIONS((const pcre *)preg->re_pcre) & PCRE2_NO_AUTO_CAPTURE) != 0;
if ((eflags & REG_NOTBOL) != 0) options |= PCRE2_NOTBOL;
if ((eflags & REG_NOTEOL) != 0) options |= PCRE2_NOTEOL;
if ((eflags & REG_NOTEMPTY) != 0) options |= PCRE2_NOTEMPTY;
((regex_t *)preg)->re_erroffset = (size_t)(-1); /* Only has meaning after compile */
/* When no string data is being returned, or no vector has been passed in which
to put it, ensure that nmatch is zero. Otherwise, ensure the vector for holding
the return data is large enough. */
if (nosub || pmatch == NULL) nmatch = 0;
else if (nmatch > 0)
{
if (nmatch <= POSIX_MALLOC_THRESHOLD)
{
ovector = &(small_ovector[0]);
}
else
{
if (nmatch > INT_MAX/(sizeof(int) * 3)) return REG_ESPACE;
ovector = (int *)malloc(sizeof(int) * nmatch * 3);
if (ovector == NULL) return REG_ESPACE;
allocated_ovector = TRUE;
}
}
/* REG_STARTEND is a BSD extension, to allow for non-NUL-terminated strings.
The man page from OS X says "REG_STARTEND affects only the location of the
string, not how it is matched". That is why the "so" value is used to bump the
start location rather than being passed as a PCRE2 "starting offset". */
if ((eflags & REG_STARTEND) != 0)
{
so = pmatch[0].rm_so;
eo = pmatch[0].rm_eo;
}
else
{
so = 0;
eo = (int)strlen(string);
}
rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string + so, (eo - so),
0, options, ovector, (int)(nmatch * 3));
if (rc == 0) rc = (int)nmatch; /* All captured slots were filled in */
/* Successful match */
if (rc >= 0)
{
size_t i;
if (!nosub)
{
for (i = 0; i < (size_t)rc; i++)
{
pmatch[i].rm_so = ovector[i*2];
pmatch[i].rm_eo = ovector[i*2+1];
}
if (allocated_ovector) free(ovector);
for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1;
}
return 0;
}
/* Unsuccessful match */
if (allocated_ovector) free(ovector);
switch(rc)
{
/* ========================================================================== */
/* These cases are never obeyed. This is a fudge that causes a compile-time
error if the vector eint, which is indexed by compile-time error number, is
not the correct length. It seems to be the only way to do such a check at
compile time, as the sizeof() operator does not work in the C preprocessor.
As all the PCRE2_ERROR_xxx values are negative, we can use 0 and 1. */
case 0:
case (sizeof(eint)/sizeof(int) == ERRCOUNT):
return REG_ASSERT;
/* ========================================================================== */
case PCRE2_ERROR_NOMATCH: return REG_NOMATCH;
case PCRE2_ERROR_NULL: return REG_INVARG;
case PCRE2_ERROR_BADOPTION: return REG_INVARG;
case PCRE2_ERROR_BADMAGIC: return REG_INVARG;
case PCRE2_ERROR_UNKNOWN_NODE: return REG_ASSERT;
case PCRE2_ERROR_NOMEMORY: return REG_ESPACE;
case PCRE2_ERROR_MATCHLIMIT: return REG_ESPACE;
case PCRE2_ERROR_BADUTF8: return REG_INVARG;
case PCRE2_ERROR_BADUTF8_OFFSET: return REG_INVARG;
case PCRE2_ERROR_BADMODE: return REG_INVARG;
default: return REG_ASSERT;
}
#endif /* NEVER */
}
/* End of pcre2posix.c */

145
src/pcre2posix.h Normal file
View File

@ -0,0 +1,145 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* Have to include stdlib.h in order to ensure that size_t is defined. */
#include <stdlib.h>
/* Allow for C++ users */
#ifdef __cplusplus
extern "C" {
#endif
/* Options, mostly defined by POSIX, but with some extras. */
#define REG_ICASE 0x0001 /* Maps to PCRE2_CASELESS */
#define REG_NEWLINE 0x0002 /* Maps to PCRE2_MULTILINE */
#define REG_NOTBOL 0x0004 /* Maps to PCRE2_NOTBOL */
#define REG_NOTEOL 0x0008 /* Maps to PCRE2_NOTEOL */
#define REG_DOTALL 0x0010 /* NOT defined by POSIX; maps to PCRE2_DOTALL */
#define REG_NOSUB 0x0020 /* Maps to PCRE2_NO_AUTO_CAPTURE */
#define REG_UTF 0x0040 /* NOT defined by POSIX; maps to PCRE2_UTF */
#define REG_STARTEND 0x0080 /* BSD feature: pass subject string by so,eo */
#define REG_NOTEMPTY 0x0100 /* NOT defined by POSIX; maps to PCRE2_NOTEMPTY */
#define REG_UNGREEDY 0x0200 /* NOT defined by POSIX; maps to PCRE2_UNGREEDY */
#define REG_UCP 0x0400 /* NOT defined by POSIX; maps to PCRE2_UCP */
/* This is not used by PCRE, but by defining it we make it easier
to slot PCRE into existing programs that make POSIX calls. */
#define REG_EXTENDED 0
/* Error values. Not all these are relevant or used by the wrapper. */
enum {
REG_ASSERT = 1, /* internal error ? */
REG_BADBR, /* invalid repeat counts in {} */
REG_BADPAT, /* pattern error */
REG_BADRPT, /* ? * + invalid */
REG_EBRACE, /* unbalanced {} */
REG_EBRACK, /* unbalanced [] */
REG_ECOLLATE, /* collation error - not relevant */
REG_ECTYPE, /* bad class */
REG_EESCAPE, /* bad escape sequence */
REG_EMPTY, /* empty expression */
REG_EPAREN, /* unbalanced () */
REG_ERANGE, /* bad range inside [] */
REG_ESIZE, /* expression too big */
REG_ESPACE, /* failed to get memory */
REG_ESUBREG, /* bad back reference */
REG_INVARG, /* bad argument */
REG_NOMATCH /* match failed */
};
/* The structure representing a compiled regular expression. */
typedef struct {
void *re_pcre2_code;
size_t re_nsub;
size_t re_erroffset;
} regex_t;
/* The structure in which a captured offset is returned. */
typedef int regoff_t;
typedef struct {
regoff_t rm_so;
regoff_t rm_eo;
} regmatch_t;
/* When an application links to a PCRE DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE, the appropriate
export settings are needed, and are set in pcre2posix.c before including this
file. */
#if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL)
# define PCREPOSIX_EXP_DECL extern __declspec(dllimport)
# define PCREPOSIX_EXP_DEFN __declspec(dllimport)
#endif
/* By default, we use the standard "extern" declarations. */
#ifndef PCREPOSIX_EXP_DECL
# ifdef __cplusplus
# define PCREPOSIX_EXP_DECL extern "C"
# define PCREPOSIX_EXP_DEFN extern "C"
# else
# define PCREPOSIX_EXP_DECL extern
# define PCREPOSIX_EXP_DEFN extern
# endif
#endif
/* The functions */
PCREPOSIX_EXP_DECL int regcomp(regex_t *, const char *, int);
PCREPOSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t,
regmatch_t *, int);
PCREPOSIX_EXP_DECL size_t regerror(int, const regex_t *, char *, size_t);
PCREPOSIX_EXP_DECL void regfree(regex_t *);
#ifdef __cplusplus
} /* extern "C" */
#endif
/* End of pcre2posix.h */

9
src/pcre2test.c Normal file
View File

@ -0,0 +1,9 @@
/* This is a dummy placeholder */
#include <stdio.h>
int main(void)
{
printf("This is a dummy placeholder file for pcre2test.\n");
return 0;
}