pcre-8.38/ 0000755 0002221 0002221 00000000000 12624604204 007372 5 0000000 0000000 pcre-8.38/pcre_scanner.h 0000644 0002221 0002221 00000014710 12272731751 012137 0000000 0000000 // Copyright (c) 2005, Google Inc.
// All rights reserved.
//
// 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 Google Inc. 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.
//
// Author: Sanjay Ghemawat
//
// Regular-expression based scanner for parsing an input stream.
//
// Example 1: parse a sequence of "var = number" entries from input:
//
// Scanner scanner(input);
// string var;
// int number;
// scanner.SetSkipExpression("\\s+"); // Skip any white space we encounter
// while (scanner.Consume("(\\w+) = (\\d+)", &var, &number)) {
// ...;
// }
#ifndef _PCRE_SCANNER_H
#define _PCRE_SCANNER_H
#include
#include
#include
#include
#include
namespace pcrecpp {
class PCRECPP_EXP_DEFN Scanner {
public:
Scanner();
explicit Scanner(const std::string& input);
~Scanner();
// Return current line number. The returned line-number is
// one-based. I.e. it returns 1 + the number of consumed newlines.
//
// Note: this method may be slow. It may take time proportional to
// the size of the input.
int LineNumber() const;
// Return the byte-offset that the scanner is looking in the
// input data;
int Offset() const;
// Return true iff the start of the remaining input matches "re"
bool LookingAt(const RE& re) const;
// Return true iff all of the following are true
// a. the start of the remaining input matches "re",
// b. if any arguments are supplied, matched sub-patterns can be
// parsed and stored into the arguments.
// If it returns true, it skips over the matched input and any
// following input that matches the "skip" regular expression.
bool Consume(const RE& re,
const Arg& arg0 = RE::no_arg,
const Arg& arg1 = RE::no_arg,
const Arg& arg2 = RE::no_arg
// TODO: Allow more arguments?
);
// Set the "skip" regular expression. If after consuming some data,
// a prefix of the input matches this RE, it is automatically
// skipped. For example, a programming language scanner would use
// a skip RE that matches white space and comments.
//
// scanner.SetSkipExpression("\\s+|//.*|/[*](.|\n)*?[*]/");
//
// Skipping repeats as long as it succeeds. We used to let people do
// this by writing "(...)*" in the regular expression, but that added
// up to lots of recursive calls within the pcre library, so now we
// control repetition explicitly via the function call API.
//
// You can pass NULL for "re" if you do not want any data to be skipped.
void Skip(const char* re); // DEPRECATED; does *not* repeat
void SetSkipExpression(const char* re);
// Temporarily pause "skip"ing. This
// Skip("Foo"); code ; DisableSkip(); code; EnableSkip()
// is similar to
// Skip("Foo"); code ; Skip(NULL); code ; Skip("Foo");
// but avoids creating/deleting new RE objects.
void DisableSkip();
// Reenable previously paused skipping. Any prefix of the input
// that matches the skip pattern is immediately dropped.
void EnableSkip();
/***** Special wrappers around SetSkip() for some common idioms *****/
// Arranges to skip whitespace, C comments, C++ comments.
// The overall RE is a disjunction of the following REs:
// \\s whitespace
// //.*\n C++ comment
// /[*](.|\n)*?[*]/ C comment (x*? means minimal repetitions of x)
// We get repetition via the semantics of SetSkipExpression, not by using *
void SkipCXXComments() {
SetSkipExpression("\\s|//.*\n|/[*](?:\n|.)*?[*]/");
}
void set_save_comments(bool comments) {
save_comments_ = comments;
}
bool save_comments() {
return save_comments_;
}
// Append to vector ranges the comments found in the
// byte range [start,end] (inclusive) of the input data.
// Only comments that were extracted entirely within that
// range are returned: no range splitting of atomically-extracted
// comments is performed.
void GetComments(int start, int end, std::vector *ranges);
// Append to vector ranges the comments added
// since the last time this was called. This
// functionality is provided for efficiency when
// interleaving scanning with parsing.
void GetNextComments(std::vector *ranges);
private:
std::string data_; // All the input data
StringPiece input_; // Unprocessed input
RE* skip_; // If non-NULL, RE for skipping input
bool should_skip_; // If true, use skip_
bool skip_repeat_; // If true, repeat skip_ as long as it works
bool save_comments_; // If true, aggregate the skip expression
// the skipped comments
// TODO: later consider requiring that the StringPieces be added
// in order by their start position
std::vector *comments_;
// the offset into comments_ that has been returned by GetNextComments
int comments_offset_;
// helper function to consume *skip_ and honour
// save_comments_
void ConsumeSkip();
};
} // namespace pcrecpp
#endif /* _PCRE_SCANNER_H */
pcre-8.38/LICENCE 0000644 0002221 0002221 00000006156 12517666032 010317 0000000 0000000 PCRE LICENCE
------------
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.
Release 8 of PCRE is distributed under the terms of the "BSD" licence, as
specified below. The documentation for PCRE, supplied in the "doc"
directory, is distributed under the same terms as the software itself. The data
in the testdata directory is not copyrighted and is in the public domain.
The basic library functions are written in C and are freestanding. Also
included in the distribution is a set of C++ wrapper functions, and a
just-in-time compiler that can be used to optimize pattern matching. These
are both optional features that can be omitted when the library is built.
THE BASIC LIBRARY FUNCTIONS
---------------------------
Written by: Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
University of Cambridge Computing Service,
Cambridge, England.
Copyright (c) 1997-2015 University of Cambridge
All rights reserved.
PCRE JUST-IN-TIME COMPILATION SUPPORT
-------------------------------------
Written by: Zoltan Herczeg
Email local part: hzmester
Emain domain: freemail.hu
Copyright(c) 2010-2015 Zoltan Herczeg
All rights reserved.
STACK-LESS JUST-IN-TIME COMPILER
--------------------------------
Written by: Zoltan Herczeg
Email local part: hzmester
Emain domain: freemail.hu
Copyright(c) 2009-2015 Zoltan Herczeg
All rights reserved.
THE C++ WRAPPER FUNCTIONS
-------------------------
Contributed by: Google Inc.
Copyright (c) 2007-2012, Google Inc.
All rights reserved.
THE "BSD" LICENCE
-----------------
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 name of Google
Inc. nor the names of their 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.
End
pcre-8.38/makevp_c.txt 0000644 0002221 0002221 00000000531 12272732026 011642 0000000 0000000 pcre_byte_order.c
pcre_chartables.c
pcre_compile.c
pcre_config.c
pcre_dfa_exec.c
pcre_exec.c
pcre_fullinfo.c
pcre_get.c
pcre_globals.c
pcre_jit_compile.c
pcre_maketables.c
pcre_newline.c
pcre_ord2utf8.c
pcre_refcount.c
pcre_string_utils.c
pcre_study.c
pcre_tables.c
pcre_ucd.c
pcre_valid_utf8.c
pcre_version.c
pcre_xclass.c
pcre-8.38/PrepareRelease 0000755 0002221 0002221 00000016217 12272732026 012151 0000000 0000000 #/bin/sh
# Script to prepare the files for building a PCRE release. It does some
# processing of the documentation, detrails files, and creates pcre.h.generic
# and config.h.generic (for use by builders who can't run ./configure).
# You must run this script before runnning "make dist". If its first argument
# is "doc", it stops after preparing the documentation. There are no other
# arguments. The script makes use of the following files:
# 132html A Perl script that converts a .1 or .3 man page into HTML. It
# "knows" the relevant troff constructs that are used in the PCRE
# man pages.
# CheckMan A Perl script that checks man pages for typos in the mark up.
# CleanTxt A Perl script that cleans up the output of "nroff -man" by
# removing backspaces and other redundant text so as to produce
# a readable .txt file.
# Detrail A Perl script that removes trailing spaces from files.
# doc/index.html.src
# A file that is copied as index.html into the doc/html directory
# when the HTML documentation is built. It works like this so that
# doc/html can be deleted and re-created from scratch.
# README & NON-AUTOTOOLS-BUILD
# These files are copied into the doc/html directory, with .txt
# extensions so that they can by hyperlinked from the HTML
# documentation, because some people just go to the HTML without
# looking for text files.
# First, sort out the documentation. Remove pcredemo.3 first because it won't
# pass the markup check (it is created below, using markup that none of the
# other pages use).
cd doc
echo Processing documentation
/bin/rm -f pcredemo.3
# Check the remaining man pages
perl ../CheckMan *.1 *.3
if [ $? != 0 ] ; then exit 1; fi
# Make Text form of the documentation. It needs some mangling to make it
# tidy for online reading. Concatenate all the .3 stuff, but omit the
# individual function pages.
cat <pcre.txt
-----------------------------------------------------------------------------
This file contains a concatenation of the PCRE man pages, converted to plain
text format for ease of searching with a text editor, or for use on systems
that do not have a man page processor. The small individual files that give
synopses of each function in the library have not been included. Neither has
the pcredemo program. There are separate text files for the pcregrep and
pcretest commands.
-----------------------------------------------------------------------------
End
echo "Making pcre.txt"
for file in pcre pcre16 pcre32 pcrebuild pcrematching pcreapi pcrecallout \
pcrecompat pcrepattern pcresyntax pcreunicode pcrejit pcrepartial \
pcreprecompile pcreperform pcreposix pcrecpp pcresample \
pcrelimits pcrestack ; do
echo " Processing $file.3"
nroff -c -man $file.3 >$file.rawtxt
perl ../CleanTxt <$file.rawtxt >>pcre.txt
/bin/rm $file.rawtxt
echo "------------------------------------------------------------------------------" >>pcre.txt
if [ "$file" != "pcresample" ] ; then
echo " " >>pcre.txt
echo " " >>pcre.txt
fi
done
# The three commands
for file in pcretest pcregrep pcre-config ; do
echo Making $file.txt
nroff -c -man $file.1 >$file.rawtxt
perl ../CleanTxt <$file.rawtxt >$file.txt
/bin/rm $file.rawtxt
done
# Make pcredemo.3 from the pcredemo.c source file
echo "Making pcredemo.3"
perl <<"END" >pcredemo.3
open(IN, "../pcredemo.c") || die "Failed to open pcredemo.c\n";
open(OUT, ">pcredemo.3") || die "Failed to open pcredemo.3\n";
print OUT ".\\\" Start example.\n" .
".de EX\n" .
". nr mE \\\\n(.f\n" .
". nf\n" .
". nh\n" .
". ft CW\n" .
"..\n" .
".\n" .
".\n" .
".\\\" End example.\n" .
".de EE\n" .
". ft \\\\n(mE\n" .
". fi\n" .
". hy \\\\n(HY\n" .
"..\n" .
".\n" .
".EX\n" ;
while ()
{
s/\\/\\e/g;
print OUT;
}
print OUT ".EE\n";
close(IN);
close(OUT);
END
if [ $? != 0 ] ; then exit 1; fi
# Make HTML form of the documentation.
echo "Making HTML documentation"
/bin/rm html/*
cp index.html.src html/index.html
cp ../README html/README.txt
cp ../NON-AUTOTOOLS-BUILD html/NON-AUTOTOOLS-BUILD.txt
for file in *.1 ; do
base=`basename $file .1`
echo " Making $base.html"
perl ../132html -toc $base <$file >html/$base.html
done
# Exclude table of contents for function summaries. It seems that expr
# forces an anchored regex. Also exclude them for small pages that have
# only one section.
for file in *.3 ; do
base=`basename $file .3`
toc=-toc
if [ `expr $base : '.*_'` -ne 0 ] ; then toc="" ; fi
if [ "$base" = "pcresample" ] || \
[ "$base" = "pcrestack" ] || \
[ "$base" = "pcrecompat" ] || \
[ "$base" = "pcrelimits" ] || \
[ "$base" = "pcreperform" ] || \
[ "$base" = "pcreunicode" ] ; then
toc=""
fi
echo " Making $base.html"
perl ../132html $toc $base <$file >html/$base.html
if [ $? != 0 ] ; then exit 1; fi
done
# End of documentation processing; stop if only documentation required.
cd ..
echo Documentation done
if [ "$1" = "doc" ] ; then exit; fi
# These files are detrailed; do not detrail the test data because there may be
# significant trailing spaces. Do not detrail RunTest.bat, because it has CRLF
# line endings and the detrail script removes all trailing white space. The
# configure files are also omitted from the detrailing. We don't bother with
# those pcre[16|32]_xx files that just define COMPILE_PCRE16 and then #include the
# common file, because they aren't going to change.
files="\
Makefile.am \
Makefile.in \
configure.ac \
README \
LICENCE \
COPYING \
AUTHORS \
NEWS \
NON-UNIX-USE \
NON-AUTOTOOLS-BUILD \
INSTALL \
132html \
CleanTxt \
Detrail \
ChangeLog \
CMakeLists.txt \
RunGrepTest \
RunTest \
pcre-config.in \
libpcre.pc.in \
libpcre16.pc.in \
libpcre32.pc.in \
libpcreposix.pc.in \
libpcrecpp.pc.in \
config.h.in \
pcre_chartables.c.dist \
pcredemo.c \
pcregrep.c \
pcretest.c \
dftables.c \
pcreposix.c \
pcreposix.h \
pcre.h.in \
pcre_internal.h \
pcre_byte_order.c \
pcre_compile.c \
pcre_config.c \
pcre_dfa_exec.c \
pcre_exec.c \
pcre_fullinfo.c \
pcre_get.c \
pcre_globals.c \
pcre_jit_compile.c \
pcre_jit_test.c \
pcre_maketables.c \
pcre_newline.c \
pcre_ord2utf8.c \
pcre16_ord2utf16.c \
pcre32_ord2utf32.c \
pcre_printint.c \
pcre_refcount.c \
pcre_string_utils.c \
pcre_study.c \
pcre_tables.c \
pcre_valid_utf8.c \
pcre_version.c \
pcre_xclass.c \
pcre16_utf16_utils.c \
pcre32_utf32_utils.c \
pcre16_valid_utf16.c \
pcre32_valid_utf32.c \
pcre_scanner.cc \
pcre_scanner.h \
pcre_scanner_unittest.cc \
pcrecpp.cc \
pcrecpp.h \
pcrecpparg.h.in \
pcrecpp_unittest.cc \
pcre_stringpiece.cc \
pcre_stringpiece.h.in \
pcre_stringpiece_unittest.cc \
perltest.pl \
ucp.h \
makevp.bat \
pcre.def \
libpcre.def \
libpcreposix.def"
echo Detrailing
perl ./Detrail $files doc/p* doc/html/*
echo Done
#End
pcre-8.38/RunTest.bat 0000644 0002221 0002221 00000042156 12272731753 011427 0000000 0000000 @echo off
@rem This file must use CRLF linebreaks to function properly
@rem and requires both pcretest and pcregrep
@rem This file was originally contributed by Ralf Junker, and touched up by
@rem Daniel Richard G. Tests 10-12 added by Philip H.
@rem Philip H also changed test 3 to use "wintest" files.
@rem
@rem Updated by Tom Fortmann to support explicit test numbers on the command line.
@rem Added argument validation and added error reporting.
@rem
@rem MS Windows batch file to run pcretest on testfiles with the correct
@rem options.
@rem
@rem Sheri Pierce added logic to skip feature dependent tests
@rem tests 4 5 9 15 and 18 require utf support
@rem tests 6 7 10 16 and 19 require ucp support
@rem 11 requires ucp and link size 2
@rem 12 requires presence of jit support
@rem 13 requires absence of jit support
@rem Sheri P also added override tests for study and jit testing
@rem Zoltan Herczeg added libpcre16 support
@rem Zoltan Herczeg added libpcre32 support
setlocal enabledelayedexpansion
if [%srcdir%]==[] (
if exist testdata\ set srcdir=.)
if [%srcdir%]==[] (
if exist ..\testdata\ set srcdir=..)
if [%srcdir%]==[] (
if exist ..\..\testdata\ set srcdir=..\..)
if NOT exist %srcdir%\testdata\ (
Error: echo distribution testdata folder not found!
call :conferror
exit /b 1
goto :eof
)
if [%pcretest%]==[] set pcretest=.\pcretest.exe
echo source dir is %srcdir%
echo pcretest=%pcretest%
if NOT exist %pcretest% (
echo Error: %pcretest% not found!
echo.
call :conferror
exit /b 1
)
%pcretest% -C linksize >NUL
set link_size=%ERRORLEVEL%
%pcretest% -C pcre8 >NUL
set support8=%ERRORLEVEL%
%pcretest% -C pcre16 >NUL
set support16=%ERRORLEVEL%
%pcretest% -C pcre32 >NUL
set support32=%ERRORLEVEL%
%pcretest% -C utf >NUL
set utf=%ERRORLEVEL%
%pcretest% -C ucp >NUL
set ucp=%ERRORLEVEL%
%pcretest% -C jit >NUL
set jit=%ERRORLEVEL%
if %support8% EQU 1 (
if not exist testout8 md testout8
if not exist testoutstudy8 md testoutstudy8
if not exist testoutjit8 md testoutjit8
)
if %support16% EQU 1 (
if not exist testout16 md testout16
if not exist testoutstudy16 md testoutstudy16
if not exist testoutjit16 md testoutjit16
)
if %support16% EQU 1 (
if not exist testout32 md testout32
if not exist testoutstudy32 md testoutstudy32
if not exist testoutjit32 md testoutjit32
)
set do1=no
set do2=no
set do3=no
set do4=no
set do5=no
set do6=no
set do7=no
set do8=no
set do9=no
set do10=no
set do11=no
set do12=no
set do13=no
set do14=no
set do15=no
set do16=no
set do17=no
set do18=no
set do19=no
set do20=no
set do21=no
set do22=no
set do23=no
set do24=no
set do25=no
set do26=no
set all=yes
for %%a in (%*) do (
set valid=no
for %%v in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26) do if %%v == %%a set valid=yes
if "!valid!" == "yes" (
set do%%a=yes
set all=no
) else (
echo Invalid test number - %%a!
echo Usage %0 [ test_number ] ...
echo Where test_number is one or more optional test numbers 1 through 26, default is all tests.
exit /b 1
)
)
set failed="no"
if "%all%" == "yes" (
set do1=yes
set do2=yes
set do3=yes
set do4=yes
set do5=yes
set do6=yes
set do7=yes
set do8=yes
set do9=yes
set do10=yes
set do11=yes
set do12=yes
set do13=yes
set do14=yes
set do15=yes
set do16=yes
set do17=yes
set do18=yes
set do19=yes
set do20=yes
set do21=yes
set do22=yes
set do23=yes
set do24=yes
set do25=yes
set do26=yes
)
@echo RunTest.bat's pcretest output is written to newly created subfolders named
@echo testout, testoutstudy and testoutjit.
@echo.
set mode=
set bits=8
:nextMode
if "%mode%" == "" (
if %support8% EQU 0 goto modeSkip
echo.
echo ---- Testing 8-bit library ----
echo.
)
if "%mode%" == "-16" (
if %support16% EQU 0 goto modeSkip
echo.
echo ---- Testing 16-bit library ----
echo.
)
if "%mode%" == "-32" (
if %support32% EQU 0 goto modeSkip
echo.
echo ---- Testing 32-bit library ----
echo.
)
if "%do1%" == "yes" call :do1
if "%do2%" == "yes" call :do2
if "%do3%" == "yes" call :do3
if "%do4%" == "yes" call :do4
if "%do5%" == "yes" call :do5
if "%do6%" == "yes" call :do6
if "%do7%" == "yes" call :do7
if "%do8%" == "yes" call :do8
if "%do9%" == "yes" call :do9
if "%do10%" == "yes" call :do10
if "%do11%" == "yes" call :do11
if "%do12%" == "yes" call :do12
if "%do13%" == "yes" call :do13
if "%do14%" == "yes" call :do14
if "%do15%" == "yes" call :do15
if "%do16%" == "yes" call :do16
if "%do17%" == "yes" call :do17
if "%do18%" == "yes" call :do18
if "%do19%" == "yes" call :do19
if "%do20%" == "yes" call :do20
if "%do21%" == "yes" call :do21
if "%do22%" == "yes" call :do22
if "%do23%" == "yes" call :do23
if "%do24%" == "yes" call :do24
if "%do25%" == "yes" call :do25
if "%do26%" == "yes" call :do26
:modeSkip
if "%mode%" == "" (
set mode=-16
set bits=16
goto nextMode
)
if "%mode%" == "-16" (
set mode=-32
set bits=32
goto nextMode
)
@rem If mode is -32, testing is finished
if %failed% == "yes" (
echo In above output, one or more of the various tests failed!
exit /b 1
)
echo All OK
goto :eof
:runsub
@rem Function to execute pcretest and compare the output
@rem Arguments are as follows:
@rem
@rem 1 = test number
@rem 2 = outputdir
@rem 3 = test name use double quotes
@rem 4 - 9 = pcretest options
if [%1] == [] (
echo Missing test number argument!
exit /b 1
)
if [%2] == [] (
echo Missing outputdir!
exit /b 1
)
if [%3] == [] (
echo Missing test name argument!
exit /b 1
)
set testinput=testinput%1
set testoutput=testoutput%1
if exist %srcdir%\testdata\win%testinput% (
set testinput=wintestinput%1
set testoutput=wintestoutput%1
)
echo Test %1: %3
%pcretest% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% >%2%bits%\%testoutput%
if errorlevel 1 (
echo. failed executing command-line:
echo. %pcretest% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% ^>%2%bits%\%testoutput%
set failed="yes"
goto :eof
)
set type=
if [%1]==[11] (
set type=-%bits%
)
if [%1]==[18] (
set type=-%bits%
)
if [%1]==[21] (
set type=-%bits%
)
if [%1]==[22] (
set type=-%bits%
)
fc /n %srcdir%\testdata\%testoutput%%type% %2%bits%\%testoutput% >NUL
if errorlevel 1 (
echo. failed comparison: fc /n %srcdir%\testdata\%testoutput% %2%bits%\%testoutput%
if [%1]==[2] (
echo.
echo ** Test 2 requires a lot of stack. PCRE can be configured to
echo ** use heap for recursion. Otherwise, to pass Test 2
echo ** you generally need to allocate 8 mb stack to PCRE.
echo ** See the 'pcrestack' page for a discussion of PCRE's
echo ** stack usage.
echo.
)
if [%1]==[3] (
echo.
echo ** Test 3 failure usually means french locale is not
echo ** available on the system, rather than a bug or problem with PCRE.
echo.
goto :eof
)
set failed="yes"
goto :eof
)
echo. Passed.
goto :eof
:do1
call :runsub 1 testout "Main functionality (Compatible with Perl >= 5.10)" -q
call :runsub 1 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 1 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do2
call :runsub 2 testout "API, errors, internals, and non-Perl stuff" -q
call :runsub 2 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 2 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do3
call :runsub 3 testout "Locale-specific features" -q
call :runsub 3 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 3 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do4
if %utf% EQU 0 (
echo Test 4 Skipped due to absence of UTF-%bits% support.
goto :eof
)
call :runsub 4 testout "UTF-%bits% support - (Compatible with Perl >= 5.10)" -q
call :runsub 4 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 4 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do5
if %utf% EQU 0 (
echo Test 5 Skipped due to absence of UTF-%bits% support.
goto :eof
)
call :runsub 5 testout "API, internals, and non-Perl stuff for UTF-%bits%" -q
call :runsub 5 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 5 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do6
if %ucp% EQU 0 (
echo Test 6 Skipped due to absence of Unicode property support.
goto :eof
)
call :runsub 6 testout "Unicode property support (Compatible with Perl >= 5.10)" -q
call :runsub 6 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 6 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do7
if %ucp% EQU 0 (
echo Test 7 Skipped due to absence of Unicode property support.
goto :eof
)
call :runsub 7 testout "API, internals, and non-Perl stuff for Unicode property support" -q
call :runsub 7 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 7 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do8
call :runsub 8 testout "DFA matching main functionality" -q -dfa
call :runsub 8 testoutstudy "Test with Study Override" -q -dfa -s
goto :eof
:do9
if %utf% EQU 0 (
echo Test 9 Skipped due to absence of UTF-%bits% support.
goto :eof
)
call :runsub 9 testout "DFA matching with UTF-%bits%" -q -dfa
call :runsub 9 testoutstudy "Test with Study Override" -q -dfa -s
goto :eof
:do10
if %ucp% EQU 0 (
echo Test 10 Skipped due to absence of Unicode property support.
goto :eof
)
call :runsub 10 testout "DFA matching with Unicode properties" -q -dfa
call :runsub 10 testoutstudy "Test with Study Override" -q -dfa -s
goto :eof
:do11
if NOT %link_size% EQU 2 (
echo Test 11 Skipped because link size is not 2.
goto :eof
)
if %ucp% EQU 0 (
echo Test 11 Skipped due to absence of Unicode property support.
goto :eof
)
call :runsub 11 testout "Internal offsets and code size tests" -q
call :runsub 11 testoutstudy "Test with Study Override" -q -s
goto :eof
:do12
if %jit% EQU 0 (
echo Test 12 Skipped due to absence of JIT support.
goto :eof
)
call :runsub 12 testout "JIT-specific features (JIT available)" -q
goto :eof
:do13
if %jit% EQU 1 (
echo Test 13 Skipped due to presence of JIT support.
goto :eof
)
call :runsub 13 testout "JIT-specific features (JIT not available)" -q
goto :eof
:do14
if NOT %bits% EQU 8 (
echo Test 14 Skipped when running 16/32-bit tests.
goto :eof
)
copy /Y %srcdir%\testdata\saved16 testsaved16
copy /Y %srcdir%\testdata\saved32 testsaved32
call :runsub 14 testout "Specials for the basic 8-bit library" -q
call :runsub 14 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 14 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do15
if NOT %bits% EQU 8 (
echo Test 15 Skipped when running 16/32-bit tests.
goto :eof
)
if %utf% EQU 0 (
echo Test 15 Skipped due to absence of UTF-%bits% support.
goto :eof
)
call :runsub 15 testout "Specials for the 8-bit library with UTF-%bits% support" -q
call :runsub 15 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 15 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do16
if NOT %bits% EQU 8 (
echo Test 16 Skipped when running 16/32-bit tests.
goto :eof
)
if %ucp% EQU 0 (
echo Test 16 Skipped due to absence of Unicode property support.
goto :eof
)
call :runsub 16 testout "Specials for the 8-bit library with Unicode propery support" -q
call :runsub 16 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 16 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do17
if %bits% EQU 8 (
echo Test 17 Skipped when running 8-bit tests.
goto :eof
)
call :runsub 17 testout "Specials for the basic 16/32-bit library" -q
call :runsub 17 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 17 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do18
if %bits% EQU 8 (
echo Test 18 Skipped when running 8-bit tests.
goto :eof
)
if %utf% EQU 0 (
echo Test 18 Skipped due to absence of UTF-%bits% support.
goto :eof
)
call :runsub 18 testout "Specials for the 16/32-bit library with UTF-%bits% support" -q
call :runsub 18 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 18 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do19
if %bits% EQU 8 (
echo Test 19 Skipped when running 8-bit tests.
goto :eof
)
if %ucp% EQU 0 (
echo Test 19 Skipped due to absence of Unicode property support.
goto :eof
)
call :runsub 19 testout "Specials for the 16/32-bit library with Unicode property support" -q
call :runsub 19 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 19 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do20
if %bits% EQU 8 (
echo Test 20 Skipped when running 8-bit tests.
goto :eof
)
call :runsub 20 testout "DFA specials for the basic 16/32-bit library" -q -dfa
call :runsub 20 testoutstudy "Test with Study Override" -q -dfa -s
goto :eof
:do21
if %bits% EQU 8 (
echo Test 21 Skipped when running 8-bit tests.
goto :eof
)
if NOT %link_size% EQU 2 (
echo Test 21 Skipped because link size is not 2.
goto :eof
)
copy /Y %srcdir%\testdata\saved8 testsaved8
copy /Y %srcdir%\testdata\saved16LE-1 testsaved16LE-1
copy /Y %srcdir%\testdata\saved16BE-1 testsaved16BE-1
copy /Y %srcdir%\testdata\saved32LE-1 testsaved32LE-1
copy /Y %srcdir%\testdata\saved32BE-1 testsaved32BE-1
call :runsub 21 testout "Reloads for the basic 16/32-bit library" -q
call :runsub 21 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 21 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do22
if %bits% EQU 8 (
echo Test 22 Skipped when running 8-bit tests.
goto :eof
)
if %utf% EQU 0 (
echo Test 22 Skipped due to absence of UTF-%bits% support.
goto :eof
)
if NOT %link_size% EQU 2 (
echo Test 22 Skipped because link size is not 2.
goto :eof
)
copy /Y %srcdir%\testdata\saved16LE-2 testsaved16LE-2
copy /Y %srcdir%\testdata\saved16BE-2 testsaved16BE-2
copy /Y %srcdir%\testdata\saved32LE-2 testsaved32LE-2
copy /Y %srcdir%\testdata\saved32BE-2 testsaved32BE-2
call :runsub 22 testout "Reloads for the 16/32-bit library with UTF-16/32 support" -q
call :runsub 22 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 22 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do23
if NOT %bits% EQU 16 (
echo Test 23 Skipped when running 8/32-bit tests.
goto :eof
)
call :runsub 23 testout "Specials for the 16-bit library" -q
call :runsub 23 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 23 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do24
if NOT %bits% EQU 16 (
echo Test 24 Skipped when running 8/32-bit tests.
goto :eof
)
if %utf% EQU 0 (
echo Test 24 Skipped due to absence of UTF-%bits% support.
goto :eof
)
call :runsub 24 testout "Specials for the 16-bit library with UTF-16 support" -q
call :runsub 24 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 24 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do25
if NOT %bits% EQU 32 (
echo Test 25 Skipped when running 8/16-bit tests.
goto :eof
)
call :runsub 25 testout "Specials for the 32-bit library" -q
call :runsub 25 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 25 testoutjit "Test with JIT Override" -q -s+
goto :eof
:do26
if NOT %bits% EQU 32 (
echo Test 26 Skipped when running 8/16-bit tests.
goto :eof
)
if %utf% EQU 0 (
echo Test 26 Skipped due to absence of UTF-%bits% support.
goto :eof
)
call :runsub 26 testout "Specials for the 32-bit library with UTF-32 support" -q
call :runsub 26 testoutstudy "Test with Study Override" -q -s
if %jit% EQU 1 call :runsub 26 testoutjit "Test with JIT Override" -q -s+
goto :eof
:conferror
@echo.
@echo Either your build is incomplete or you have a configuration error.
@echo.
@echo If configured with cmake and executed via "make test" or the MSVC "RUN_TESTS"
@echo project, pcre_test.bat defines variables and automatically calls RunTest.bat.
@echo For manual testing of all available features, after configuring with cmake
@echo and building, you can run the built pcre_test.bat. For best results with
@echo cmake builds and tests avoid directories with full path names that include
@echo spaces for source or build.
@echo.
@echo Otherwise, if the build dir is in a subdir of the source dir, testdata needed
@echo for input and verification should be found automatically when (from the
@echo location of the the built exes) you call RunTest.bat. By default RunTest.bat
@echo runs all tests compatible with the linked pcre library but it can be given
@echo a test number as an argument.
@echo.
@echo If the build dir is not under the source dir you can either copy your exes
@echo to the source folder or copy RunTest.bat and the testdata folder to the
@echo location of your built exes and then run RunTest.bat.
@echo.
goto :eof
pcre-8.38/pcre16_study.c 0000644 0002221 0002221 00000004175 12272732026 012020 0000000 0000000 /*************************************************
* 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
Copyright (c) 1997-2012 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.
-----------------------------------------------------------------------------
*/
/* Generate code with 16 bit character support. */
#define COMPILE_PCRE16
#include "pcre_study.c"
/* End of pcre16_study.c */
pcre-8.38/pcre16_chartables.c 0000644 0002221 0002221 00000004207 12272731750 012757 0000000 0000000 /*************************************************
* 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
Copyright (c) 1997-2012 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.
-----------------------------------------------------------------------------
*/
/* Generate code with 16 bit character support. */
#define COMPILE_PCRE16
#include "pcre_chartables.c"
/* End of pcre16_chartables.c */
pcre-8.38/pcre_jit_test.c 0000644 0002221 0002221 00000215250 12570347111 012322 0000000 0000000 /*************************************************
* 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.
Main Library written by Philip Hazel
Copyright (c) 1997-2012 University of Cambridge
This JIT compiler regression test program was written by Zoltan Herczeg
Copyright (c) 2010-2012
-----------------------------------------------------------------------------
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
#include
#include "pcre.h"
#include "pcre_internal.h"
/*
Letter characters:
\xe6\x92\xad = 0x64ad = 25773 (kanji)
Non-letter characters:
\xc2\xa1 = 0xa1 = (Inverted Exclamation Mark)
\xf3\xa9\xb7\x80 = 0xe9dc0 = 957888
\xed\xa0\x80 = 55296 = 0xd800 (Invalid UTF character)
\xed\xb0\x80 = 56320 = 0xdc00 (Invalid UTF character)
Newlines:
\xc2\x85 = 0x85 = 133 (NExt Line = NEL)
\xe2\x80\xa8 = 0x2028 = 8232 (Line Separator)
Othercase pairs:
\xc3\xa9 = 0xe9 = 233 (e')
\xc3\x89 = 0xc9 = 201 (E')
\xc3\xa1 = 0xe1 = 225 (a')
\xc3\x81 = 0xc1 = 193 (A')
\x53 = 0x53 = S
\x73 = 0x73 = s
\xc5\xbf = 0x17f = 383 (long S)
\xc8\xba = 0x23a = 570
\xe2\xb1\xa5 = 0x2c65 = 11365
\xe1\xbd\xb8 = 0x1f78 = 8056
\xe1\xbf\xb8 = 0x1ff8 = 8184
\xf0\x90\x90\x80 = 0x10400 = 66560
\xf0\x90\x90\xa8 = 0x10428 = 66600
\xc7\x84 = 0x1c4 = 452
\xc7\x85 = 0x1c5 = 453
\xc7\x86 = 0x1c6 = 454
Caseless sets:
ucp_Armenian - \x{531}-\x{556} -> \x{561}-\x{586}
ucp_Coptic - \x{2c80}-\x{2ce3} -> caseless: XOR 0x1
ucp_Latin - \x{ff21}-\x{ff3a} -> \x{ff41]-\x{ff5a}
Mark property:
\xcc\x8d = 0x30d = 781
Special:
\xc2\x80 = 0x80 = 128 (lowest 2 byte character)
\xdf\xbf = 0x7ff = 2047 (highest 2 byte character)
\xe0\xa0\x80 = 0x800 = 2048 (lowest 2 byte character)
\xef\xbf\xbf = 0xffff = 65535 (highest 3 byte character)
\xf0\x90\x80\x80 = 0x10000 = 65536 (lowest 4 byte character)
\xf4\x8f\xbf\xbf = 0x10ffff = 1114111 (highest allowed utf character)
*/
static int regression_tests(void);
int main(void)
{
int jit = 0;
#if defined SUPPORT_PCRE8
pcre_config(PCRE_CONFIG_JIT, &jit);
#elif defined SUPPORT_PCRE16
pcre16_config(PCRE_CONFIG_JIT, &jit);
#elif defined SUPPORT_PCRE32
pcre32_config(PCRE_CONFIG_JIT, &jit);
#endif
if (!jit) {
printf("JIT must be enabled to run pcre_jit_test\n");
return 1;
}
return regression_tests();
}
/* --------------------------------------------------------------------------------------- */
#if !(defined SUPPORT_PCRE8) && !(defined SUPPORT_PCRE16) && !(defined SUPPORT_PCRE32)
#error SUPPORT_PCRE8 or SUPPORT_PCRE16 or SUPPORT_PCRE32 must be defined
#endif
#define MUA (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)
#define MUAP (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
#define CMUA (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)
#define CMUAP (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
#define MA (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)
#define MAP (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
#define CMA (PCRE_CASELESS | PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)
#define OFFSET_MASK 0x00ffff
#define F_NO8 0x010000
#define F_NO16 0x020000
#define F_NO32 0x020000
#define F_NOMATCH 0x040000
#define F_DIFF 0x080000
#define F_FORCECONV 0x100000
#define F_PROPERTY 0x200000
#define F_STUDY 0x400000
struct regression_test_case {
int flags;
int start_offset;
const char *pattern;
const char *input;
};
static struct regression_test_case regression_test_cases[] = {
/* Constant strings. */
{ MUA, 0, "AbC", "AbAbC" },
{ MUA, 0, "ACCEPT", "AACACCACCEACCEPACCEPTACCEPTT" },
{ CMUA, 0, "aA#\xc3\xa9\xc3\x81", "aA#Aa#\xc3\x89\xc3\xa1" },
{ MA, 0, "[^a]", "aAbB" },
{ CMA, 0, "[^m]", "mMnN" },
{ MA, 0, "a[^b][^#]", "abacd" },
{ CMA, 0, "A[^B][^E]", "abacd" },
{ CMUA, 0, "[^x][^#]", "XxBll" },
{ MUA, 0, "[^a]", "aaa\xc3\xa1#Ab" },
{ CMUA, 0, "[^A]", "aA\xe6\x92\xad" },
{ MUA, 0, "\\W(\\W)?\\w", "\r\n+bc" },
{ MUA, 0, "\\W(\\W)?\\w", "\n\r+bc" },
{ MUA, 0, "\\W(\\W)?\\w", "\r\r+bc" },
{ MUA, 0, "\\W(\\W)?\\w", "\n\n+bc" },
{ MUA, 0, "[axd]", "sAXd" },
{ CMUA, 0, "[axd]", "sAXd" },
{ CMUA, 0 | F_NOMATCH, "[^axd]", "DxA" },
{ MUA, 0, "[a-dA-C]", "\xe6\x92\xad\xc3\xa9.B" },
{ MUA, 0, "[^a-dA-C]", "\xe6\x92\xad\xc3\xa9" },
{ CMUA, 0, "[^\xc3\xa9]", "\xc3\xa9\xc3\x89." },
{ MUA, 0, "[^\xc3\xa9]", "\xc3\xa9\xc3\x89." },
{ MUA, 0, "[^a]", "\xc2\x80[]" },
{ CMUA, 0, "\xf0\x90\x90\xa7", "\xf0\x90\x91\x8f" },
{ CMA, 0, "1a2b3c4", "1a2B3c51A2B3C4" },
{ PCRE_CASELESS, 0, "\xff#a", "\xff#\xff\xfe##\xff#A" },
{ PCRE_CASELESS, 0, "\xfe", "\xff\xfc#\xfe\xfe" },
{ PCRE_CASELESS, 0, "a1", "Aa1" },
{ MA, 0, "\\Ca", "cda" },
{ CMA, 0, "\\Ca", "CDA" },
{ MA, 0 | F_NOMATCH, "\\Cx", "cda" },
{ CMA, 0 | F_NOMATCH, "\\Cx", "CDA" },
{ CMUAP, 0, "\xf0\x90\x90\x80\xf0\x90\x90\xa8", "\xf0\x90\x90\xa8\xf0\x90\x90\x80" },
{ CMUAP, 0, "\xf0\x90\x90\x80{2}", "\xf0\x90\x90\x80#\xf0\x90\x90\xa8\xf0\x90\x90\x80" },
{ CMUAP, 0, "\xf0\x90\x90\xa8{2}", "\xf0\x90\x90\x80#\xf0\x90\x90\xa8\xf0\x90\x90\x80" },
{ CMUAP, 0, "\xe1\xbd\xb8\xe1\xbf\xb8", "\xe1\xbf\xb8\xe1\xbd\xb8" },
{ MA, 0, "[3-57-9]", "5" },
/* Assertions. */
{ MUA, 0, "\\b[^A]", "A_B#" },
{ MA, 0 | F_NOMATCH, "\\b\\W", "\n*" },
{ MUA, 0, "\\B[^,]\\b[^s]\\b", "#X" },
{ MAP, 0, "\\B", "_\xa1" },
{ MAP, 0, "\\b_\\b[,A]\\B", "_," },
{ MUAP, 0, "\\b", "\xe6\x92\xad!" },
{ MUAP, 0, "\\B", "_\xc2\xa1\xc3\xa1\xc2\x85" },
{ MUAP, 0, "\\b[^A]\\B[^c]\\b[^_]\\B", "_\xc3\xa1\xe2\x80\xa8" },
{ MUAP, 0, "\\b\\w+\\B", "\xc3\x89\xc2\xa1\xe6\x92\xad\xc3\x81\xc3\xa1" },
{ MUA, 0 | F_NOMATCH, "\\b.", "\xcd\xbe" },
{ CMUAP, 0, "\\By", "\xf0\x90\x90\xa8y" },
{ MA, 0 | F_NOMATCH, "\\R^", "\n" },
{ MA, 1 | F_NOMATCH, "^", "\n" },
{ 0, 0, "^ab", "ab" },
{ 0, 0 | F_NOMATCH, "^ab", "aab" },
{ PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "^a", "\r\raa\n\naa\r\naa" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF, 0, "^-", "\xe2\x80\xa8--\xc2\x85-\r\n-" },
{ PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "^-", "a--b--\x85--" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "^-", "a--\xe2\x80\xa8--" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "^-", "a--\xc2\x85--" },
{ 0, 0, "ab$", "ab" },
{ 0, 0 | F_NOMATCH, "ab$", "abab\n\n" },
{ PCRE_DOLLAR_ENDONLY, 0 | F_NOMATCH, "ab$", "abab\r\n" },
{ PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "a$", "\r\raa\n\naa\r\naa" },
{ PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "a$", "aaa" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF, 0, "#$", "#\xc2\x85###\r#" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY, 0, "#$", "#\xe2\x80\xa9" },
{ PCRE_NOTBOL | PCRE_NEWLINE_ANY, 0 | F_NOMATCH, "^a", "aa\naa" },
{ PCRE_NOTBOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "^a", "aa\naa" },
{ PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0 | F_NOMATCH, "a$", "aa\naa" },
{ PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0 | F_NOMATCH, "a$", "aa\r\n" },
{ PCRE_UTF8 | PCRE_DOLLAR_ENDONLY | PCRE_NEWLINE_ANY, 0 | F_PROPERTY, "\\p{Any}{2,}$", "aa\r\n" },
{ PCRE_NOTEOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "a$", "aa\naa" },
{ PCRE_NEWLINE_CR, 0, ".\\Z", "aaa" },
{ PCRE_NEWLINE_CR | PCRE_UTF8, 0, "a\\Z", "aaa\r" },
{ PCRE_NEWLINE_CR, 0, ".\\Z", "aaa\n" },
{ PCRE_NEWLINE_CRLF, 0, ".\\Z", "aaa\r" },
{ PCRE_NEWLINE_CRLF | PCRE_UTF8, 0, ".\\Z", "aaa\n" },
{ PCRE_NEWLINE_CRLF, 0, ".\\Z", "aaa\r\n" },
{ PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa" },
{ PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\r" },
{ PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\n" },
{ PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\r\n" },
{ PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\xe2\x80\xa8" },
{ PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa" },
{ PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\r" },
{ PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\n" },
{ PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".\\Z", "aaa\r\n" },
{ PCRE_NEWLINE_ANY | PCRE_UTF8, 0, ".\\Z", "aaa\xc2\x85" },
{ PCRE_NEWLINE_ANY | PCRE_UTF8, 0, ".\\Z", "aaa\xe2\x80\xa8" },
{ MA, 0, "\\Aa", "aaa" },
{ MA, 1 | F_NOMATCH, "\\Aa", "aaa" },
{ MA, 1, "\\Ga", "aaa" },
{ MA, 1 | F_NOMATCH, "\\Ga", "aba" },
{ MA, 0, "a\\z", "aaa" },
{ MA, 0 | F_NOMATCH, "a\\z", "aab" },
/* Brackets. */
{ MUA, 0, "(ab|bb|cd)", "bacde" },
{ MUA, 0, "(?:ab|a)(bc|c)", "ababc" },
{ MUA, 0, "((ab|(cc))|(bb)|(?:cd|efg))", "abac" },
{ CMUA, 0, "((aB|(Cc))|(bB)|(?:cd|EFg))", "AcCe" },
{ MUA, 0, "((ab|(cc))|(bb)|(?:cd|ebg))", "acebebg" },
{ MUA, 0, "(?:(a)|(?:b))(cc|(?:d|e))(a|b)k", "accabdbbccbk" },
/* Greedy and non-greedy ? operators. */
{ MUA, 0, "(?:a)?a", "laab" },
{ CMUA, 0, "(A)?A", "llaab" },
{ MUA, 0, "(a)?\?a", "aab" }, /* ?? is the prefix of trygraphs in GCC. */
{ MUA, 0, "(a)?a", "manm" },
{ CMUA, 0, "(a|b)?\?d((?:e)?)", "ABABdx" },
{ MUA, 0, "(a|b)?\?d((?:e)?)", "abcde" },
{ MUA, 0, "((?:ab)?\?g|b(?:g(nn|d)?\?)?)?\?(?:n)?m", "abgnbgnnbgdnmm" },
/* Greedy and non-greedy + operators */
{ MUA, 0, "(aa)+aa", "aaaaaaa" },
{ MUA, 0, "(aa)+?aa", "aaaaaaa" },
{ MUA, 0, "(?:aba|ab|a)+l", "ababamababal" },
{ MUA, 0, "(?:aba|ab|a)+?l", "ababamababal" },
{ MUA, 0, "(a(?:bc|cb|b|c)+?|ss)+e", "accssabccbcacbccbbXaccssabccbcacbccbbe" },
{ MUA, 0, "(a(?:bc|cb|b|c)+|ss)+?e", "accssabccbcacbccbbXaccssabccbcacbccbbe" },
{ MUA, 0, "(?:(b(c)+?)+)?\?(?:(bc)+|(cb)+)+(?:m)+", "bccbcccbcbccbcbPbccbcccbcbccbcbmmn" },
/* Greedy and non-greedy * operators */
{ CMUA, 0, "(?:AA)*AB", "aaaaaaamaaaaaaab" },
{ MUA, 0, "(?:aa)*?ab", "aaaaaaamaaaaaaab" },
{ MUA, 0, "(aa|ab)*ab", "aaabaaab" },
{ CMUA, 0, "(aa|Ab)*?aB", "aaabaaab" },
{ MUA, 0, "(a|b)*(?:a)*(?:b)*m", "abbbaaababanabbbaaababamm" },
{ MUA, 0, "(a|b)*?(?:a)*?(?:b)*?m", "abbbaaababanabbbaaababamm" },
{ MA, 0, "a(a(\\1*)a|(b)b+){0}a", "aa" },
{ MA, 0, "((?:a|)*){0}a", "a" },
/* Combining ? + * operators */
{ MUA, 0, "((bm)+)?\?(?:a)*(bm)+n|((am)+?)?(?:a)+(am)*n", "bmbmabmamaaamambmaman" },
{ MUA, 0, "(((ab)?cd)*ef)+g", "abcdcdefcdefefmabcdcdefcdefefgg" },
{ MUA, 0, "(((ab)?\?cd)*?ef)+?g", "abcdcdefcdefefmabcdcdefcdefefgg" },
{ MUA, 0, "(?:(ab)?c|(?:ab)+?d)*g", "ababcdccababddg" },
{ MUA, 0, "(?:(?:ab)?\?c|(ab)+d)*?g", "ababcdccababddg" },
/* Single character iterators. */
{ MUA, 0, "(a+aab)+aaaab", "aaaabcaaaabaabcaabcaaabaaaab" },
{ MUA, 0, "(a*a*aab)+x", "aaaaabaabaaabmaabx" },
{ MUA, 0, "(a*?(b|ab)a*?)+x", "aaaabcxbbaabaacbaaabaabax" },
{ MUA, 0, "(a+(ab|ad)a+)+x", "aaabaaaadaabaaabaaaadaaax" },
{ MUA, 0, "(a?(a)a?)+(aaa)", "abaaabaaaaaaaa" },
{ MUA, 0, "(a?\?(a)a?\?)+(b)", "aaaacaaacaacacbaaab" },
{ MUA, 0, "(a{0,4}(b))+d", "aaaaaabaabcaaaaabaaaaabd" },
{ MUA, 0, "(a{0,4}?[^b])+d+(a{0,4}[^b])d+", "aaaaadaaaacaadddaaddd" },
{ MUA, 0, "(ba{2})+c", "baabaaabacbaabaac" },
{ MUA, 0, "(a*+bc++)+", "aaabbcaaabcccab" },
{ MUA, 0, "(a?+[^b])+", "babaacacb" },
{ MUA, 0, "(a{0,3}+b)(a{0,3}+b)(a{0,3}+)[^c]", "abaabaaacbaabaaaac" },
{ CMUA, 0, "([a-c]+[d-f]+?)+?g", "aBdacdehAbDaFgA" },
{ CMUA, 0, "[c-f]+k", "DemmFke" },
{ MUA, 0, "([DGH]{0,4}M)+", "GGDGHDGMMHMDHHGHM" },
{ MUA, 0, "([a-c]{4,}s)+", "abasabbasbbaabsbba" },
{ CMUA, 0, "[ace]{3,7}", "AcbDAcEEcEd" },
{ CMUA, 0, "[ace]{3,7}?", "AcbDAcEEcEd" },
{ CMUA, 0, "[ace]{3,}", "AcbDAcEEcEd" },
{ CMUA, 0, "[ace]{3,}?", "AcbDAcEEcEd" },
{ MUA, 0, "[ckl]{2,}?g", "cdkkmlglglkcg" },
{ CMUA, 0, "[ace]{5}?", "AcCebDAcEEcEd" },
{ MUA, 0, "([AbC]{3,5}?d)+", "BACaAbbAEAACCbdCCbdCCAAbb" },
{ MUA, 0, "([^ab]{0,}s){2}", "abaabcdsABamsDDs" },
{ MUA, 0, "\\b\\w+\\B", "x,a_cd" },
{ MUAP, 0, "\\b[^\xc2\xa1]+\\B", "\xc3\x89\xc2\xa1\xe6\x92\xad\xc3\x81\xc3\xa1" },
{ CMUA, 0, "[^b]+(a*)([^c]?d{3})", "aaaaddd" },
{ CMUAP, 0, "\xe1\xbd\xb8{2}", "\xe1\xbf\xb8#\xe1\xbf\xb8\xe1\xbd\xb8" },
{ CMUA, 0, "[^\xf0\x90\x90\x80]{2,4}@", "\xf0\x90\x90\xa8\xf0\x90\x90\x80###\xf0\x90\x90\x80@@@" },
{ CMUA, 0, "[^\xe1\xbd\xb8][^\xc3\xa9]", "\xe1\xbd\xb8\xe1\xbf\xb8\xc3\xa9\xc3\x89#" },
{ MUA, 0, "[^\xe1\xbd\xb8][^\xc3\xa9]", "\xe1\xbd\xb8\xe1\xbf\xb8\xc3\xa9\xc3\x89#" },
{ MUA, 0, "[^\xe1\xbd\xb8]{3,}?", "##\xe1\xbd\xb8#\xe1\xbd\xb8#\xc3\x89#\xe1\xbd\xb8" },
/* Bracket repeats with limit. */
{ MUA, 0, "(?:(ab){2}){5}M", "abababababababababababM" },
{ MUA, 0, "(?:ab|abab){1,5}M", "abababababababababababM" },
{ MUA, 0, "(?>ab|abab){1,5}M", "abababababababababababM" },
{ MUA, 0, "(?:ab|abab){1,5}?M", "abababababababababababM" },
{ MUA, 0, "(?>ab|abab){1,5}?M", "abababababababababababM" },
{ MUA, 0, "(?:(ab){1,4}?){1,3}?M", "abababababababababababababM" },
{ MUA, 0, "(?:(ab){1,4}){1,3}abababababababababababM", "ababababababababababababM" },
{ MUA, 0 | F_NOMATCH, "(?:(ab){1,4}){1,3}abababababababababababM", "abababababababababababM" },
{ MUA, 0, "(ab){4,6}?M", "abababababababM" },
/* Basic character sets. */
{ MUA, 0, "(?:\\s)+(?:\\S)+", "ab \t\xc3\xa9\xe6\x92\xad " },
{ MUA, 0, "(\\w)*(k)(\\W)?\?", "abcdef abck11" },
{ MUA, 0, "\\((\\d)+\\)\\D", "a() (83 (8)2 (9)ab" },
{ MUA, 0, "\\w(\\s|(?:\\d)*,)+\\w\\wb", "a 5, 4,, bb 5, 4,, aab" },
{ MUA, 0, "(\\v+)(\\V+)", "\x0e\xc2\x85\xe2\x80\xa8\x0b\x09\xe2\x80\xa9" },
{ MUA, 0, "(\\h+)(\\H+)", "\xe2\x80\xa8\xe2\x80\x80\x20\xe2\x80\x8a\xe2\x81\x9f\xe3\x80\x80\x09\x20\xc2\xa0\x0a" },
{ MUA, 0, "x[bcef]+", "xaxdxecbfg" },
{ MUA, 0, "x[bcdghij]+", "xaxexfxdgbjk" },
{ MUA, 0, "x[^befg]+", "xbxexacdhg" },
{ MUA, 0, "x[^bcdl]+", "xlxbxaekmd" },
{ MUA, 0, "x[^bcdghi]+", "xbxdxgxaefji" },
{ MUA, 0, "x[B-Fb-f]+", "xaxAxgxbfBFG" },
{ CMUA, 0, "\\x{e9}+", "#\xf0\x90\x90\xa8\xc3\xa8\xc3\xa9\xc3\x89\xc3\x88" },
{ CMUA, 0, "[^\\x{e9}]+", "\xc3\xa9#\xf0\x90\x90\xa8\xc3\xa8\xc3\x88\xc3\x89" },
{ MUA, 0, "[\\x02\\x7e]+", "\xc3\x81\xe1\xbf\xb8\xf0\x90\x90\xa8\x01\x02\x7e\x7f" },
{ MUA, 0, "[^\\x02\\x7e]+", "\x02\xc3\x81\xe1\xbf\xb8\xf0\x90\x90\xa8\x01\x7f\x7e" },
{ MUA, 0, "[\\x{81}-\\x{7fe}]+", "#\xe1\xbf\xb8\xf0\x90\x90\xa8\xc2\x80\xc2\x81\xdf\xbe\xdf\xbf" },
{ MUA, 0, "[^\\x{81}-\\x{7fe}]+", "\xc2\x81#\xe1\xbf\xb8\xf0\x90\x90\xa8\xc2\x80\xdf\xbf\xdf\xbe" },
{ MUA, 0, "[\\x{801}-\\x{fffe}]+", "#\xc3\xa9\xf0\x90\x90\x80\xe0\xa0\x80\xe0\xa0\x81\xef\xbf\xbe\xef\xbf\xbf" },
{ MUA, 0, "[^\\x{801}-\\x{fffe}]+", "\xe0\xa0\x81#\xc3\xa9\xf0\x90\x90\x80\xe0\xa0\x80\xef\xbf\xbf\xef\xbf\xbe" },
{ MUA, 0, "[\\x{10001}-\\x{10fffe}]+", "#\xc3\xa9\xe2\xb1\xa5\xf0\x90\x80\x80\xf0\x90\x80\x81\xf4\x8f\xbf\xbe\xf4\x8f\xbf\xbf" },
{ MUA, 0, "[^\\x{10001}-\\x{10fffe}]+", "\xf0\x90\x80\x81#\xc3\xa9\xe2\xb1\xa5\xf0\x90\x80\x80\xf4\x8f\xbf\xbf\xf4\x8f\xbf\xbe" },
/* Unicode properties. */
{ MUAP, 0, "[1-5\xc3\xa9\\w]", "\xc3\xa1_" },
{ MUAP, 0 | F_PROPERTY, "[\xc3\x81\\p{Ll}]", "A_\xc3\x89\xc3\xa1" },
{ MUAP, 0, "[\\Wd-h_x-z]+", "a\xc2\xa1#_yhzdxi" },
{ MUAP, 0 | F_NOMATCH | F_PROPERTY, "[\\P{Any}]", "abc" },
{ MUAP, 0 | F_NOMATCH | F_PROPERTY, "[^\\p{Any}]", "abc" },
{ MUAP, 0 | F_NOMATCH | F_PROPERTY, "[\\P{Any}\xc3\xa1-\xc3\xa8]", "abc" },
{ MUAP, 0 | F_NOMATCH | F_PROPERTY, "[^\\p{Any}\xc3\xa1-\xc3\xa8]", "abc" },
{ MUAP, 0 | F_NOMATCH | F_PROPERTY, "[\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },
{ MUAP, 0 | F_NOMATCH | F_PROPERTY, "[^\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },
{ MUAP, 0 | F_PROPERTY, "[\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },
{ MUAP, 0 | F_PROPERTY, "[^\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },
{ MUAP, 0, "[b-\xc3\xa9\\s]", "a\xc\xe6\x92\xad" },
{ CMUAP, 0, "[\xc2\x85-\xc2\x89\xc3\x89]", "\xc2\x84\xc3\xa9" },
{ MUAP, 0, "[^b-d^&\\s]{3,}", "db^ !a\xe2\x80\xa8_ae" },
{ MUAP, 0 | F_PROPERTY, "[^\\S\\P{Any}][\\sN]{1,3}[\\P{N}]{4}", "\xe2\x80\xaa\xa N\x9\xc3\xa9_0" },
{ MUA, 0 | F_PROPERTY, "[^\\P{L}\x9!D-F\xa]{2,3}", "\x9,.DF\xa.CG\xc3\x81" },
{ CMUAP, 0, "[\xc3\xa1-\xc3\xa9_\xe2\x80\xa0-\xe2\x80\xaf]{1,5}[^\xe2\x80\xa0-\xe2\x80\xaf]", "\xc2\xa1\xc3\x89\xc3\x89\xe2\x80\xaf_\xe2\x80\xa0" },
{ MUAP, 0 | F_PROPERTY, "[\xc3\xa2-\xc3\xa6\xc3\x81-\xc3\x84\xe2\x80\xa8-\xe2\x80\xa9\xe6\x92\xad\\p{Zs}]{2,}", "\xe2\x80\xa7\xe2\x80\xa9\xe6\x92\xad \xe6\x92\xae" },
{ MUAP, 0 | F_PROPERTY, "[\\P{L&}]{2}[^\xc2\x85-\xc2\x89\\p{Ll}\\p{Lu}]{2}", "\xc3\xa9\xe6\x92\xad.a\xe6\x92\xad|\xc2\x8a#" },
{ PCRE_UCP, 0, "[a-b\\s]{2,5}[^a]", "AB baaa" },
/* Possible empty brackets. */
{ MUA, 0, "(?:|ab||bc|a)+d", "abcxabcabd" },
{ MUA, 0, "(|ab||bc|a)+d", "abcxabcabd" },
{ MUA, 0, "(?:|ab||bc|a)*d", "abcxabcabd" },
{ MUA, 0, "(|ab||bc|a)*d", "abcxabcabd" },
{ MUA, 0, "(?:|ab||bc|a)+?d", "abcxabcabd" },
{ MUA, 0, "(|ab||bc|a)+?d", "abcxabcabd" },
{ MUA, 0, "(?:|ab||bc|a)*?d", "abcxabcabd" },
{ MUA, 0, "(|ab||bc|a)*?d", "abcxabcabd" },
{ MUA, 0, "(((a)*?|(?:ba)+)+?|(?:|c|ca)*)*m", "abaacaccabacabalabaacaccabacabamm" },
{ MUA, 0, "(?:((?:a)*|(ba)+?)+|(|c|ca)*?)*?m", "abaacaccabacabalabaacaccabacabamm" },
/* Start offset. */
{ MUA, 3, "(\\d|(?:\\w)*\\w)+", "0ac01Hb" },
{ MUA, 4 | F_NOMATCH, "(\\w\\W\\w)+", "ab#d" },
{ MUA, 2 | F_NOMATCH, "(\\w\\W\\w)+", "ab#d" },
{ MUA, 1, "(\\w\\W\\w)+", "ab#d" },
/* Newline. */
{ PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "\\W{0,2}[^#]{3}", "\r\n#....." },
{ PCRE_MULTILINE | PCRE_NEWLINE_CR, 0, "\\W{0,2}[^#]{3}", "\r\n#....." },
{ PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 0, "\\W{1,3}[^#]", "\r\n##...." },
{ MUA | PCRE_NO_UTF8_CHECK, 1, "^.a", "\n\x80\nxa" },
{ MUA, 1, "^", "\r\n" },
{ PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 1 | F_NOMATCH, "^", "\r\n" },
{ PCRE_MULTILINE | PCRE_NEWLINE_CRLF, 1, "^", "\r\na" },
/* Any character except newline or any newline. */
{ PCRE_NEWLINE_CRLF, 0, ".", "\r" },
{ PCRE_NEWLINE_CRLF | PCRE_UTF8, 0, ".(.).", "a\xc3\xa1\r\n\n\r\r" },
{ PCRE_NEWLINE_ANYCRLF, 0, ".(.)", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa8" },
{ PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0, ".(.)", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa8" },
{ PCRE_NEWLINE_ANY | PCRE_UTF8, 0, "(.).", "a\rb\nc\r\n\xc2\x85\xe2\x80\xa9$de" },
{ PCRE_NEWLINE_ANYCRLF | PCRE_UTF8, 0 | F_NOMATCH, ".(.).", "\xe2\x80\xa8\nb\r" },
{ PCRE_NEWLINE_ANY, 0, "(.)(.)", "#\x85#\r#\n#\r\n#\x84" },
{ PCRE_NEWLINE_ANY | PCRE_UTF8, 0, "(.+)#", "#\rMn\xc2\x85#\n###" },
{ PCRE_BSR_ANYCRLF, 0, "\\R", "\r" },
{ PCRE_BSR_ANYCRLF, 0, "\\R", "\x85#\r\n#" },
{ PCRE_BSR_UNICODE | PCRE_UTF8, 0, "\\R", "ab\xe2\x80\xa8#c" },
{ PCRE_BSR_UNICODE | PCRE_UTF8, 0, "\\R", "ab\r\nc" },
{ PCRE_NEWLINE_CRLF | PCRE_BSR_UNICODE | PCRE_UTF8, 0, "(\\R.)+", "\xc2\x85\r\n#\xe2\x80\xa8\n\r\n\r" },
{ MUA, 0 | F_NOMATCH, "\\R+", "ab" },
{ MUA, 0, "\\R+", "ab\r\n\r" },
{ MUA, 0, "\\R*", "ab\r\n\r" },
{ MUA, 0, "\\R*", "\r\n\r" },
{ MUA, 0, "\\R{2,4}", "\r\nab\r\r" },
{ MUA, 0, "\\R{2,4}", "\r\nab\n\n\n\r\r\r" },
{ MUA, 0, "\\R{2,}", "\r\nab\n\n\n\r\r\r" },
{ MUA, 0, "\\R{0,3}", "\r\n\r\n\r\n\r\n\r\n" },
{ MUA, 0 | F_NOMATCH, "\\R+\\R\\R", "\r\n\r\n" },
{ MUA, 0, "\\R+\\R\\R", "\r\r\r" },
{ MUA, 0, "\\R*\\R\\R", "\n\r" },
{ MUA, 0 | F_NOMATCH, "\\R{2,4}\\R\\R", "\r\r\r" },
{ MUA, 0, "\\R{2,4}\\R\\R", "\r\r\r\r" },
/* Atomic groups (no fallback from "next" direction). */
{ MUA, 0 | F_NOMATCH, "(?>ab)ab", "bab" },
{ MUA, 0 | F_NOMATCH, "(?>(ab))ab", "bab" },
{ MUA, 0, "(?>ab)+abc(?>de)*def(?>gh)?ghe(?>ij)+?k(?>lm)*?n(?>op)?\?op",
"bababcdedefgheijijklmlmnop" },
{ MUA, 0, "(?>a(b)+a|(ab)?\?(b))an", "abban" },
{ MUA, 0, "(?>ab+a|(?:ab)?\?b)an", "abban" },
{ MUA, 0, "((?>ab|ad|)*?)(?>|c)*abad", "abababcababad" },
{ MUA, 0, "(?>(aa|b|)*+(?>(##)|###)*d|(aa)(?>(baa)?)m)", "aabaa#####da" },
{ MUA, 0, "((?>a|)+?)b", "aaacaaab" },
{ MUA, 0, "(?>x|)*$", "aaa" },
{ MUA, 0, "(?>(x)|)*$", "aaa" },
{ MUA, 0, "(?>x|())*$", "aaa" },
{ MUA, 0, "((?>[cxy]a|[a-d])*?)b", "aaa+ aaab" },
{ MUA, 0, "((?>[cxy](a)|[a-d])*?)b", "aaa+ aaab" },
{ MUA, 0, "(?>((?>(a+))))bab|(?>((?>(a+))))bb", "aaaabaaabaabab" },
{ MUA, 0, "(?>(?>a+))bab|(?>(?>a+))bb", "aaaabaaabaabab" },
{ MUA, 0, "(?>(a)c|(?>(c)|(a))a)b*?bab", "aaaabaaabaabab" },
{ MUA, 0, "(?>ac|(?>c|a)a)b*?bab", "aaaabaaabaabab" },
{ MUA, 0, "(?>(b)b|(a))*b(?>(c)|d)?x", "ababcaaabdbx" },
{ MUA, 0, "(?>bb|a)*b(?>c|d)?x", "ababcaaabdbx" },
{ MUA, 0, "(?>(bb)|a)*b(?>c|(d))?x", "ababcaaabdbx" },
{ MUA, 0, "(?>(a))*?(?>(a))+?(?>(a))??x", "aaaaaacccaaaaabax" },
{ MUA, 0, "(?>a)*?(?>a)+?(?>a)??x", "aaaaaacccaaaaabax" },
{ MUA, 0, "(?>(a)|)*?(?>(a)|)+?(?>(a)|)??x", "aaaaaacccaaaaabax" },
{ MUA, 0, "(?>a|)*?(?>a|)+?(?>a|)??x", "aaaaaacccaaaaabax" },
{ MUA, 0, "(?>a(?>(a{0,2}))*?b|aac)+b", "aaaaaaacaaaabaaaaacaaaabaacaaabb" },
{ CMA, 0, "(?>((?>a{32}|b+|(a*))?(?>c+|d*)?\?)+e)+?f", "aaccebbdde bbdaaaccebbdee bbdaaaccebbdeef" },
{ MUA, 0, "(?>(?:(?>aa|a||x)+?b|(?>aa|a||(x))+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },
{ MUA, 0, "(?>(?:(?>aa|a||(x))+?b|(?>aa|a||x)+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },
{ MUA, 0 | F_PROPERTY, "\\X", "\xcc\x8d\xcc\x8d" },
{ MUA, 0 | F_PROPERTY, "\\X", "\xcc\x8d\xcc\x8d#\xcc\x8d\xcc\x8d" },
{ MUA, 0 | F_PROPERTY, "\\X+..", "\xcc\x8d#\xcc\x8d#\xcc\x8d\xcc\x8d" },
{ MUA, 0 | F_PROPERTY, "\\X{2,4}", "abcdef" },
{ MUA, 0 | F_PROPERTY, "\\X{2,4}?", "abcdef" },
{ MUA, 0 | F_NOMATCH | F_PROPERTY, "\\X{2,4}..", "#\xcc\x8d##" },
{ MUA, 0 | F_PROPERTY, "\\X{2,4}..", "#\xcc\x8d#\xcc\x8d##" },
{ MUA, 0, "(c(ab)?+ab)+", "cabcababcab" },
{ MUA, 0, "(?>(a+)b)+aabab", "aaaabaaabaabab" },
/* Possessive quantifiers. */
{ MUA, 0, "(?:a|b)++m", "mababbaaxababbaam" },
{ MUA, 0, "(?:a|b)*+m", "mababbaaxababbaam" },
{ MUA, 0, "(?:a|b)*+m", "ababbaaxababbaam" },
{ MUA, 0, "(a|b)++m", "mababbaaxababbaam" },
{ MUA, 0, "(a|b)*+m", "mababbaaxababbaam" },
{ MUA, 0, "(a|b)*+m", "ababbaaxababbaam" },
{ MUA, 0, "(a|b(*ACCEPT))++m", "maaxab" },
{ MUA, 0, "(?:b*)++m", "bxbbxbbbxm" },
{ MUA, 0, "(?:b*)++m", "bxbbxbbbxbbm" },
{ MUA, 0, "(?:b*)*+m", "bxbbxbbbxm" },
{ MUA, 0, "(?:b*)*+m", "bxbbxbbbxbbm" },
{ MUA, 0, "(b*)++m", "bxbbxbbbxm" },
{ MUA, 0, "(b*)++m", "bxbbxbbbxbbm" },
{ MUA, 0, "(b*)*+m", "bxbbxbbbxm" },
{ MUA, 0, "(b*)*+m", "bxbbxbbbxbbm" },
{ MUA, 0, "(?:a|(b))++m", "mababbaaxababbaam" },
{ MUA, 0, "(?:(a)|b)*+m", "mababbaaxababbaam" },
{ MUA, 0, "(?:(a)|(b))*+m", "ababbaaxababbaam" },
{ MUA, 0, "(a|(b))++m", "mababbaaxababbaam" },
{ MUA, 0, "((a)|b)*+m", "mababbaaxababbaam" },
{ MUA, 0, "((a)|(b))*+m", "ababbaaxababbaam" },
{ MUA, 0, "(a|(b)(*ACCEPT))++m", "maaxab" },
{ MUA, 0, "(?:(b*))++m", "bxbbxbbbxm" },
{ MUA, 0, "(?:(b*))++m", "bxbbxbbbxbbm" },
{ MUA, 0, "(?:(b*))*+m", "bxbbxbbbxm" },
{ MUA, 0, "(?:(b*))*+m", "bxbbxbbbxbbm" },
{ MUA, 0, "((b*))++m", "bxbbxbbbxm" },
{ MUA, 0, "((b*))++m", "bxbbxbbbxbbm" },
{ MUA, 0, "((b*))*+m", "bxbbxbbbxm" },
{ MUA, 0, "((b*))*+m", "bxbbxbbbxbbm" },
{ MUA, 0 | F_NOMATCH, "(?>(b{2,4}))(?:(?:(aa|c))++m|(?:(aa|c))+n)", "bbaacaaccaaaacxbbbmbn" },
{ MUA, 0, "((?:b)++a)+(cd)*+m", "bbababbacdcdnbbababbacdcdm" },
{ MUA, 0, "((?:(b))++a)+((c)d)*+m", "bbababbacdcdnbbababbacdcdm" },
{ MUA, 0, "(?:(?:(?:ab)*+k)++(?:n(?:cd)++)*+)*+m", "ababkkXababkkabkncXababkkabkncdcdncdXababkkabkncdcdncdkkabkncdXababkkabkncdcdncdkkabkncdm" },
{ MUA, 0, "(?:((ab)*+(k))++(n(?:c(d))++)*+)*+m", "ababkkXababkkabkncXababkkabkncdcdncdXababkkabkncdcdncdkkabkncdXababkkabkncdcdncdkkabkncdm" },
/* Back references. */
{ MUA, 0, "(aa|bb)(\\1*)(ll|)(\\3*)bbbbbbc", "aaaaaabbbbbbbbc" },
{ CMUA, 0, "(aa|bb)(\\1+)(ll|)(\\3+)bbbbbbc", "bBbbBbCbBbbbBbbcbbBbbbBBbbC" },
{ CMA, 0, "(a{2,4})\\1", "AaAaaAaA" },
{ MUA, 0, "(aa|bb)(\\1?)aa(\\1?)(ll|)(\\4+)bbc", "aaaaaaaabbaabbbbaabbbbc" },
{ MUA, 0, "(aa|bb)(\\1{0,5})(ll|)(\\3{0,5})cc", "bbxxbbbbxxaaaaaaaaaaaaaaaacc" },
{ MUA, 0, "(aa|bb)(\\1{3,5})(ll|)(\\3{3,5})cc", "bbbbbbbbbbbbaaaaaaccbbbbbbbbbbbbbbcc" },
{ MUA, 0, "(aa|bb)(\\1{3,})(ll|)(\\3{3,})cc", "bbbbbbbbbbbbaaaaaaccbbbbbbbbbbbbbbcc" },
{ MUA, 0, "(\\w+)b(\\1+)c", "GabGaGaDbGaDGaDc" },
{ MUA, 0, "(?:(aa)|b)\\1?b", "bb" },
{ CMUA, 0, "(aa|bb)(\\1*?)aa(\\1+?)", "bBBbaaAAaaAAaa" },
{ MUA, 0, "(aa|bb)(\\1*?)(dd|)cc(\\3+?)", "aaaaaccdd" },
{ CMUA, 0, "(?:(aa|bb)(\\1?\?)cc){2}(\\1?\?)", "aAaABBbbAAaAcCaAcCaA" },
{ MUA, 0, "(?:(aa|bb)(\\1{3,5}?)){2}(dd|)(\\3{3,5}?)", "aaaaaabbbbbbbbbbaaaaaaaaaaaaaa" },
{ CMA, 0, "(?:(aa|bb)(\\1{3,}?)){2}(dd|)(\\3{3,}?)", "aaaaaabbbbbbbbbbaaaaaaaaaaaaaa" },
{ MUA, 0, "(?:(aa|bb)(\\1{0,3}?)){2}(dd|)(\\3{0,3}?)b(\\1{0,3}?)(\\1{0,3})", "aaaaaaaaaaaaaaabaaaaa" },
{ MUA, 0, "(a(?:\\1|)a){3}b", "aaaaaaaaaaab" },
{ MA, 0, "(a?)b(\\1\\1*\\1+\\1?\\1*?\\1+?\\1??\\1*+\\1++\\1?+\\1{4}\\1{3,5}\\1{4,}\\1{0,5}\\1{3,5}?\\1{4,}?\\1{0,5}?\\1{3,5}+\\1{4,}+\\1{0,5}+#){2}d", "bb#b##d" },
{ MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{2,}", ".www." },
{ MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{0,2}", "wwwww." },
{ MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{1,2}ww", "wwww" },
{ MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{1,2}ww", "wwwww" },
{ PCRE_UCP, 0 | F_PROPERTY, "(\\P{N})\\1{2,}", ".www." },
{ CMUAP, 0, "(\xf0\x90\x90\x80)\\1", "\xf0\x90\x90\xa8\xf0\x90\x90\xa8" },
{ MUA | PCRE_DUPNAMES, 0 | F_NOMATCH, "\\k{1,3}(?aa)(?bb)", "aabb" },
{ MUA | PCRE_DUPNAMES | PCRE_JAVASCRIPT_COMPAT, 0, "\\k{1,3}(?aa)(?bb)", "aabb" },
{ MUA | PCRE_DUPNAMES | PCRE_JAVASCRIPT_COMPAT, 0, "\\k*(?aa)(?bb)", "aabb" },
{ MUA | PCRE_DUPNAMES, 0, "(?aa)(?bb)\\k{0,3}aaaaaa", "aabbaaaaaa" },
{ MUA | PCRE_DUPNAMES, 0, "(?aa)(?bb)\\k{2,5}bb", "aabbaaaabb" },
{ MUA | PCRE_DUPNAMES, 0, "(?:(?aa)|(?bb))\\k{0,3}m", "aaaaaaaabbbbaabbbbm" },
{ MUA | PCRE_DUPNAMES, 0 | F_NOMATCH, "\\k{1,3}?(?aa)(?bb)", "aabb" },
{ MUA | PCRE_DUPNAMES | PCRE_JAVASCRIPT_COMPAT, 0, "\\k{1,3}?(?aa)(?bb)", "aabb" },
{ MUA | PCRE_DUPNAMES, 0, "\\k*?(?aa)(?bb)", "aabb" },
{ MUA | PCRE_DUPNAMES, 0, "(?:(?aa)|(?bb))\\k{0,3}?m", "aaaaaabbbbbbaabbbbbbbbbbm" },
{ MUA | PCRE_DUPNAMES, 0, "(?:(?aa)|(?bb))\\k*?m", "aaaaaabbbbbbaabbbbbbbbbbm" },
{ MUA | PCRE_DUPNAMES, 0, "(?:(?aa)|(?bb))\\k{2,3}?", "aaaabbbbaaaabbbbbbbbbb" },
{ CMUA | PCRE_DUPNAMES, 0, "(?:(?AA)|(?BB))\\k{0,3}M", "aaaaaaaabbbbaabbbbm" },
{ CMUA | PCRE_DUPNAMES, 0, "(?:(?AA)|(?BB))\\k{1,3}M", "aaaaaaaabbbbaabbbbm" },
{ CMUA | PCRE_DUPNAMES, 0, "(?:(?AA)|(?BB))\\k{0,3}?M", "aaaaaabbbbbbaabbbbbbbbbbm" },
{ CMUA | PCRE_DUPNAMES, 0, "(?:(?AA)|(?BB))\\k{2,3}?", "aaaabbbbaaaabbbbbbbbbb" },
/* Assertions. */
{ MUA, 0, "(?=xx|yy|zz)\\w{4}", "abczzdefg" },
{ MUA, 0, "(?=((\\w+)b){3}|ab)", "dbbbb ab" },
{ MUA, 0, "(?!ab|bc|cd)[a-z]{2}", "Xabcdef" },
{ MUA, 0, "(?<=aaa|aa|a)a", "aaa" },
{ MUA, 2, "(?<=aaa|aa|a)a", "aaa" },
{ MA, 0, "(?<=aaa|aa|a)a", "aaa" },
{ MA, 2, "(?<=aaa|aa|a)a", "aaa" },
{ MUA, 0, "(\\d{2})(?!\\w+c|(((\\w?)m){2}n)+|\\1)", "x5656" },
{ MUA, 0, "((?=((\\d{2,6}\\w){2,}))\\w{5,20}K){2,}", "567v09708K12l00M00 567v09708K12l00M00K45K" },
{ MUA, 0, "(?=(?:(?=\\S+a)\\w*(b)){3})\\w+\\d", "bba bbab nbbkba nbbkba0kl" },
{ MUA, 0, "(?>a(?>(b+))a(?=(..)))*?k", "acabbcabbaabacabaabbakk" },
{ MUA, 0, "((?(?=(a))a)+k)", "bbak" },
{ MUA, 0, "((?(?=a)a)+k)", "bbak" },
{ MUA, 0 | F_NOMATCH, "(?=(?>(a))m)amk", "a k" },
{ MUA, 0 | F_NOMATCH, "(?!(?>(a))m)amk", "a k" },
{ MUA, 0 | F_NOMATCH, "(?>(?=(a))am)amk", "a k" },
{ MUA, 0, "(?=(?>a|(?=(?>(b+))a|c)[a-c]+)*?m)[a-cm]+k", "aaam bbam baaambaam abbabba baaambaamk" },
{ MUA, 0, "(?> ?\?\\b(?(?=\\w{1,4}(a))m)\\w{0,8}bc){2,}?", "bca ssbc mabd ssbc mabc" },
{ MUA, 0, "(?:(?=ab)?[^n][^n])+m", "ababcdabcdcdabnababcdabcdcdabm" },
{ MUA, 0, "(?:(?=a(b))?[^n][^n])+m", "ababcdabcdcdabnababcdabcdcdabm" },
{ MUA, 0, "(?:(?=.(.))??\\1.)+m", "aabbbcbacccanaabbbcbacccam" },
{ MUA, 0, "(?:(?=.)??[a-c])+m", "abacdcbacacdcaccam" },
{ MUA, 0, "((?!a)?(?!([^a]))?)+$", "acbab" },
{ MUA, 0, "((?!a)?\?(?!([^a]))?\?)+$", "acbab" },
/* Not empty, ACCEPT, FAIL */
{ MUA | PCRE_NOTEMPTY, 0 | F_NOMATCH, "a*", "bcx" },
{ MUA | PCRE_NOTEMPTY, 0, "a*", "bcaad" },
{ MUA | PCRE_NOTEMPTY, 0, "a*?", "bcaad" },
{ MUA | PCRE_NOTEMPTY_ATSTART, 0, "a*", "bcaad" },
{ MUA, 0, "a(*ACCEPT)b", "ab" },
{ MUA | PCRE_NOTEMPTY, 0 | F_NOMATCH, "a*(*ACCEPT)b", "bcx" },
{ MUA | PCRE_NOTEMPTY, 0, "a*(*ACCEPT)b", "bcaad" },
{ MUA | PCRE_NOTEMPTY, 0, "a*?(*ACCEPT)b", "bcaad" },
{ MUA | PCRE_NOTEMPTY, 0 | F_NOMATCH, "(?:z|a*(*ACCEPT)b)", "bcx" },
{ MUA | PCRE_NOTEMPTY, 0, "(?:z|a*(*ACCEPT)b)", "bcaad" },
{ MUA | PCRE_NOTEMPTY, 0, "(?:z|a*?(*ACCEPT)b)", "bcaad" },
{ MUA | PCRE_NOTEMPTY_ATSTART, 0, "a*(*ACCEPT)b", "bcx" },
{ MUA | PCRE_NOTEMPTY_ATSTART, 0 | F_NOMATCH, "a*(*ACCEPT)b", "" },
{ MUA, 0, "((a(*ACCEPT)b))", "ab" },
{ MUA, 0, "(a(*FAIL)a|a)", "aaa" },
{ MUA, 0, "(?=ab(*ACCEPT)b)a", "ab" },
{ MUA, 0, "(?=(?:x|ab(*ACCEPT)b))", "ab" },
{ MUA, 0, "(?=(a(b(*ACCEPT)b)))a", "ab" },
{ MUA | PCRE_NOTEMPTY, 0, "(?=a*(*ACCEPT))c", "c" },
/* Conditional blocks. */
{ MUA, 0, "(?(?=(a))a|b)+k", "ababbalbbadabak" },
{ MUA, 0, "(?(?!(b))a|b)+k", "ababbalbbadabak" },
{ MUA, 0, "(?(?=a)a|b)+k", "ababbalbbadabak" },
{ MUA, 0, "(?(?!b)a|b)+k", "ababbalbbadabak" },
{ MUA, 0, "(?(?=(a))a*|b*)+k", "ababbalbbadabak" },
{ MUA, 0, "(?(?!(b))a*|b*)+k", "ababbalbbadabak" },
{ MUA, 0, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },
{ MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },
{ MUA, 0 | F_DIFF, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },
{ MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },
{ MUA, 0, "(?(?=a)a*|b*)+k", "ababbalbbadabak" },
{ MUA, 0, "(?(?!b)a*|b*)+k", "ababbalbbadabak" },
{ MUA, 0, "(?(?=a)ab)", "a" },
{ MUA, 0, "(?(?a)?(?Pb)?(?(Name)c|d)*l", "bc ddd abccabccl" },
{ MUA, 0, "(?Pa)?(?Pb)?(?(Name)c|d)+?dd", "bcabcacdb bdddd" },
{ MUA, 0, "(?Pa)?(?Pb)?(?(Name)c|d)+l", "ababccddabdbccd abcccl" },
{ MUA, 0, "((?:a|aa)(?(1)aaa))x", "aax" },
{ MUA, 0, "(?(?!)a|b)", "ab" },
{ MUA, 0, "(?(?!)a)", "ab" },
{ MUA, 0 | F_NOMATCH, "(?(?!)a|b)", "ac" },
/* Set start of match. */
{ MUA, 0, "(?:\\Ka)*aaaab", "aaaaaaaa aaaaaaabb" },
{ MUA, 0, "(?>\\Ka\\Ka)*aaaab", "aaaaaaaa aaaaaaaaaabb" },
{ MUA, 0, "a+\\K(?<=\\Gaa)a", "aaaaaa" },
{ MUA | PCRE_NOTEMPTY, 0 | F_NOMATCH, "a\\K(*ACCEPT)b", "aa" },
{ MUA | PCRE_NOTEMPTY_ATSTART, 0, "a\\K(*ACCEPT)b", "aa" },
/* First line. */
{ MUA | PCRE_FIRSTLINE, 0 | F_PROPERTY, "\\p{Any}a", "bb\naaa" },
{ MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH | F_PROPERTY, "\\p{Any}a", "bb\r\naaa" },
{ MUA | PCRE_FIRSTLINE, 0, "(?<=a)", "a" },
{ MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "[^a][^b]", "ab" },
{ MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "a", "\na" },
{ MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "[abc]", "\na" },
{ MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "^a", "\na" },
{ MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "^(?<=\n)", "\na" },
{ MUA | PCRE_FIRSTLINE, 0, "\xf0\x90\x90\x80", "\xf0\x90\x90\x80" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "#", "\xc2\x85#" },
{ PCRE_MULTILINE | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "#", "\x85#" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "^#", "\xe2\x80\xa8#" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_PROPERTY, "\\p{Any}", "\r\na" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, ".", "\r" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "a", "\ra" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_NOMATCH, "ba", "bbb\r\nba" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_NOMATCH | F_PROPERTY, "\\p{Any}{4}|a", "\r\na" },
{ PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 1, ".", "\r\n" },
{ PCRE_FIRSTLINE | PCRE_NEWLINE_LF | PCRE_DOTALL, 0 | F_NOMATCH, "ab.", "ab" },
{ MUA | PCRE_FIRSTLINE, 1 | F_NOMATCH, "^[a-d0-9]", "\nxx\nd" },
/* Recurse. */
{ MUA, 0, "(a)(?1)", "aa" },
{ MUA, 0, "((a))(?1)", "aa" },
{ MUA, 0, "(b|a)(?1)", "aa" },
{ MUA, 0, "(b|(a))(?1)", "aa" },
{ MUA, 0 | F_NOMATCH, "((a)(b)(?:a*))(?1)", "aba" },
{ MUA, 0, "((a)(b)(?:a*))(?1)", "abab" },
{ MUA, 0, "((a+)c(?2))b(?1)", "aacaabaca" },
{ MUA, 0, "((?2)b|(a)){2}(?1)", "aabab" },
{ MUA, 0, "(?1)(a)*+(?2)(b(?1))", "aababa" },
{ MUA, 0, "(?1)(((a(*ACCEPT)))b)", "axaa" },
{ MUA, 0, "(?1)(?(DEFINE) (((ac(*ACCEPT)))b) )", "akaac" },
{ MUA, 0, "(a+)b(?1)b\\1", "abaaabaaaaa" },
{ MUA, 0 | F_NOMATCH, "(?(DEFINE)(aa|a))(?1)ab", "aab" },
{ MUA, 0, "(?(DEFINE)(a\\Kb))(?1)+ababc", "abababxabababc" },
{ MUA, 0, "(a\\Kb)(?1)+ababc", "abababxababababc" },
{ MUA, 0 | F_NOMATCH, "(a\\Kb)(?1)+ababc", "abababxababababxc" },
{ MUA, 0, "b|<(?R)*>", "<" },
{ MUA, 0, "(a\\K){0}(?:(?1)b|ac)", "ac" },
{ MUA, 0, "(?(DEFINE)(a(?2)|b)(b(?1)|(a)))(?:(?1)|(?2))m", "ababababnababababaam" },
{ MUA, 0, "(a)((?(R)a|b))(?2)", "aabbabaa" },
{ MUA, 0, "(a)((?(R2)a|b))(?2)", "aabbabaa" },
{ MUA, 0, "(a)((?(R1)a|b))(?2)", "ababba" },
{ MUA, 0, "(?(R0)aa|bb(?R))", "abba aabb bbaa" },
{ MUA, 0, "((?(R)(?:aaaa|a)|(?:(aaaa)|(a)))+)(?1)$", "aaaaaaaaaa aaaa" },
{ MUA, 0, "(?Pa(?(R&Name)a|b))(?1)", "aab abb abaa" },
{ MUA, 0, "((?(R)a|(?1)){3})", "XaaaaaaaaaX" },
{ MUA, 0, "((?:(?(R)a|(?1))){3})", "XaaaaaaaaaX" },
{ MUA, 0, "((?(R)a|(?1)){1,3})aaaaaa", "aaaaaaaaXaaaaaaaaa" },
{ MUA, 0, "((?(R)a|(?1)){1,3}?)M", "aaaM" },
/* 16 bit specific tests. */
{ CMA, 0 | F_FORCECONV, "\xc3\xa1", "\xc3\x81\xc3\xa1" },
{ CMA, 0 | F_FORCECONV, "\xe1\xbd\xb8", "\xe1\xbf\xb8\xe1\xbd\xb8" },
{ CMA, 0 | F_FORCECONV, "[\xc3\xa1]", "\xc3\x81\xc3\xa1" },
{ CMA, 0 | F_FORCECONV, "[\xe1\xbd\xb8]", "\xe1\xbf\xb8\xe1\xbd\xb8" },
{ CMA, 0 | F_FORCECONV, "[a-\xed\xb0\x80]", "A" },
{ CMA, 0 | F_NO8 | F_FORCECONV, "[a-\\x{dc00}]", "B" },
{ CMA, 0 | F_NO8 | F_NOMATCH | F_FORCECONV, "[b-\\x{dc00}]", "a" },
{ CMA, 0 | F_NO8 | F_FORCECONV, "\xed\xa0\x80\\x{d800}\xed\xb0\x80\\x{dc00}", "\xed\xa0\x80\xed\xa0\x80\xed\xb0\x80\xed\xb0\x80" },
{ CMA, 0 | F_NO8 | F_FORCECONV, "[\xed\xa0\x80\\x{d800}]{1,2}?[\xed\xb0\x80\\x{dc00}]{1,2}?#", "\xed\xa0\x80\xed\xa0\x80\xed\xb0\x80\xed\xb0\x80#" },
{ CMA, 0 | F_FORCECONV, "[\xed\xa0\x80\xed\xb0\x80#]{0,3}(?<=\xed\xb0\x80.)", "\xed\xa0\x80#\xed\xa0\x80##\xed\xb0\x80\xed\xa0\x80" },
{ CMA, 0 | F_FORCECONV, "[\xed\xa0\x80-\xed\xb3\xbf]", "\xed\x9f\xbf\xed\xa0\x83" },
{ CMA, 0 | F_FORCECONV, "[\xed\xa0\x80-\xed\xb3\xbf]", "\xed\xb4\x80\xed\xb3\xb0" },
{ CMA, 0 | F_NO8 | F_FORCECONV, "[\\x{d800}-\\x{dcff}]", "\xed\x9f\xbf\xed\xa0\x83" },
{ CMA, 0 | F_NO8 | F_FORCECONV, "[\\x{d800}-\\x{dcff}]", "\xed\xb4\x80\xed\xb3\xb0" },
{ CMA, 0 | F_FORCECONV, "[\xed\xa0\x80-\xef\xbf\xbf]+[\x1-\xed\xb0\x80]+#", "\xed\xa0\x85\xc3\x81\xed\xa0\x85\xef\xbf\xb0\xc2\x85\xed\xa9\x89#" },
{ CMA, 0 | F_FORCECONV, "[\xed\xa0\x80][\xed\xb0\x80]{2,}", "\xed\xa0\x80\xed\xb0\x80\xed\xa0\x80\xed\xb0\x80\xed\xb0\x80\xed\xb0\x80" },
{ MA, 0 | F_FORCECONV, "[^\xed\xb0\x80]{3,}?", "##\xed\xb0\x80#\xed\xb0\x80#\xc3\x89#\xed\xb0\x80" },
{ MA, 0 | F_NO8 | F_FORCECONV, "[^\\x{dc00}]{3,}?", "##\xed\xb0\x80#\xed\xb0\x80#\xc3\x89#\xed\xb0\x80" },
{ CMA, 0 | F_FORCECONV, ".\\B.", "\xed\xa0\x80\xed\xb0\x80" },
{ CMA, 0 | F_FORCECONV, "\\D+(?:\\d+|.)\\S+(?:\\s+|.)\\W+(?:\\w+|.)\xed\xa0\x80\xed\xa0\x80", "\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80" },
{ CMA, 0 | F_FORCECONV, "\\d*\\s*\\w*\xed\xa0\x80\xed\xa0\x80", "\xed\xa0\x80\xed\xa0\x80" },
{ CMA, 0 | F_FORCECONV | F_NOMATCH, "\\d*?\\D*?\\s*?\\S*?\\w*?\\W*?##", "\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80#" },
{ CMA | PCRE_EXTENDED, 0 | F_FORCECONV, "\xed\xa0\x80 \xed\xb0\x80 !", "\xed\xa0\x80\xed\xb0\x80!" },
{ CMA, 0 | F_FORCECONV, "\xed\xa0\x80+#[^#]+\xed\xa0\x80", "\xed\xa0\x80#a\xed\xa0\x80" },
{ CMA, 0 | F_FORCECONV, "(\xed\xa0\x80+)#\\1", "\xed\xa0\x80\xed\xa0\x80#\xed\xa0\x80\xed\xa0\x80" },
{ PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0 | F_NO8 | F_FORCECONV, "^-", "a--\xe2\x80\xa8--" },
{ PCRE_BSR_UNICODE, 0 | F_NO8 | F_FORCECONV, "\\R", "ab\xe2\x80\xa8" },
{ 0, 0 | F_NO8 | F_FORCECONV, "\\v", "ab\xe2\x80\xa9" },
{ 0, 0 | F_NO8 | F_FORCECONV, "\\h", "ab\xe1\xa0\x8e" },
{ 0, 0 | F_NO8 | F_FORCECONV, "\\v+?\\V+?#", "\xe2\x80\xa9\xe2\x80\xa9\xef\xbf\xbf\xef\xbf\xbf#" },
{ 0, 0 | F_NO8 | F_FORCECONV, "\\h+?\\H+?#", "\xe1\xa0\x8e\xe1\xa0\x8e\xef\xbf\xbf\xef\xbf\xbf#" },
/* Partial matching. */
{ MUA | PCRE_PARTIAL_SOFT, 0, "ab", "a" },
{ MUA | PCRE_PARTIAL_SOFT, 0, "ab|a", "a" },
{ MUA | PCRE_PARTIAL_HARD, 0, "ab|a", "a" },
{ MUA | PCRE_PARTIAL_SOFT, 0, "\\b#", "a" },
{ MUA | PCRE_PARTIAL_SOFT, 0, "(?<=a)b", "a" },
{ MUA | PCRE_PARTIAL_SOFT, 0, "abc|(?<=xxa)bc", "xxab" },
{ MUA | PCRE_PARTIAL_SOFT, 0, "a\\B", "a" },
{ MUA | PCRE_PARTIAL_HARD, 0, "a\\b", "a" },
/* (*MARK) verb. */
{ MUA, 0, "a(*MARK:aa)a", "ababaa" },
{ MUA, 0 | F_NOMATCH, "a(*:aa)a", "abab" },
{ MUA, 0, "a(*:aa)(b(*:bb)b|bc)", "abc" },
{ MUA, 0 | F_NOMATCH, "a(*:1)x|b(*:2)y", "abc" },
{ MUA, 0, "(?>a(*:aa))b|ac", "ac" },
{ MUA, 0, "(?(DEFINE)(a(*:aa)))(?1)", "a" },
{ MUA, 0 | F_NOMATCH, "(?(DEFINE)((a)(*:aa)))(?1)b", "aa" },
{ MUA, 0, "(?(DEFINE)(a(*:aa)))a(?1)b|aac", "aac" },
{ MUA, 0, "(a(*:aa)){0}(?:b(?1)b|c)+c", "babbab cc" },
{ MUA, 0, "(a(*:aa)){0}(?:b(?1)b)+", "babba" },
{ MUA, 0 | F_NOMATCH | F_STUDY, "(a(*:aa)){0}(?:b(?1)b)+", "ba" },
{ MUA, 0, "(a\\K(*:aa)){0}(?:b(?1)b|c)+c", "babbab cc" },
{ MUA, 0, "(a\\K(*:aa)){0}(?:b(?1)b)+", "babba" },
{ MUA, 0 | F_NOMATCH | F_STUDY, "(a\\K(*:aa)){0}(?:b(?1)b)+", "ba" },
{ MUA, 0 | F_NOMATCH | F_STUDY, "(*:mark)m", "a" },
/* (*COMMIT) verb. */
{ MUA, 0 | F_NOMATCH, "a(*COMMIT)b", "ac" },
{ MUA, 0, "aa(*COMMIT)b", "xaxaab" },
{ MUA, 0 | F_NOMATCH, "a(*COMMIT)(*:msg)b|ac", "ac" },
{ MUA, 0 | F_NOMATCH, "(a(*COMMIT)b)++", "abac" },
{ MUA, 0 | F_NOMATCH, "((a)(*COMMIT)b)++", "abac" },
{ MUA, 0 | F_NOMATCH, "(?=a(*COMMIT)b)ab|ad", "ad" },
/* (*PRUNE) verb. */
{ MUA, 0, "aa\\K(*PRUNE)b", "aaab" },
{ MUA, 0, "aa(*PRUNE:bb)b|a", "aa" },
{ MUA, 0, "(a)(a)(*PRUNE)b|(a)", "aa" },
{ MUA, 0, "(a)(a)(a)(a)(a)(a)(a)(a)(*PRUNE)b|(a)", "aaaaaaaa" },
{ MUA | PCRE_PARTIAL_SOFT, 0, "a(*PRUNE)a|", "a" },
{ MUA | PCRE_PARTIAL_SOFT, 0, "a(*PRUNE)a|m", "a" },
{ MUA, 0 | F_NOMATCH, "(?=a(*PRUNE)b)ab|ad", "ad" },
{ MUA, 0, "a(*COMMIT)(*PRUNE)d|bc", "abc" },
{ MUA, 0, "(?=a(*COMMIT)b)a(*PRUNE)c|bc", "abc" },
{ MUA, 0 | F_NOMATCH, "(*COMMIT)(?=a(*COMMIT)b)a(*PRUNE)c|bc", "abc" },
{ MUA, 0, "(?=(a)(*COMMIT)b)a(*PRUNE)c|bc", "abc" },
{ MUA, 0 | F_NOMATCH, "(*COMMIT)(?=(a)(*COMMIT)b)a(*PRUNE)c|bc", "abc" },
{ MUA, 0, "(a(*COMMIT)b){0}a(?1)(*PRUNE)c|bc", "abc" },
{ MUA, 0 | F_NOMATCH, "(a(*COMMIT)b){0}a(*COMMIT)(?1)(*PRUNE)c|bc", "abc" },
{ MUA, 0, "(a(*COMMIT)b)++(*PRUNE)d|c", "ababc" },
{ MUA, 0 | F_NOMATCH, "(*COMMIT)(a(*COMMIT)b)++(*PRUNE)d|c", "ababc" },
{ MUA, 0, "((a)(*COMMIT)b)++(*PRUNE)d|c", "ababc" },
{ MUA, 0 | F_NOMATCH, "(*COMMIT)((a)(*COMMIT)b)++(*PRUNE)d|c", "ababc" },
{ MUA, 0, "(?>a(*COMMIT)b)*abab(*PRUNE)d|ba", "ababab" },
{ MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)*abab(*PRUNE)d|ba", "ababab" },
{ MUA, 0, "(?>a(*COMMIT)b)+abab(*PRUNE)d|ba", "ababab" },
{ MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)+abab(*PRUNE)d|ba", "ababab" },
{ MUA, 0, "(?>a(*COMMIT)b)?ab(*PRUNE)d|ba", "aba" },
{ MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)?ab(*PRUNE)d|ba", "aba" },
{ MUA, 0, "(?>a(*COMMIT)b)*?n(*PRUNE)d|ba", "abababn" },
{ MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)*?n(*PRUNE)d|ba", "abababn" },
{ MUA, 0, "(?>a(*COMMIT)b)+?n(*PRUNE)d|ba", "abababn" },
{ MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)+?n(*PRUNE)d|ba", "abababn" },
{ MUA, 0, "(?>a(*COMMIT)b)??n(*PRUNE)d|bn", "abn" },
{ MUA, 0 | F_NOMATCH, "(*COMMIT)(?>a(*COMMIT)b)??n(*PRUNE)d|bn", "abn" },
/* (*SKIP) verb. */
{ MUA, 0 | F_NOMATCH, "(?=a(*SKIP)b)ab|ad", "ad" },
/* (*THEN) verb. */
{ MUA, 0, "((?:a(*THEN)|aab)(*THEN)c|a+)+m", "aabcaabcaabcaabcnacm" },
{ MUA, 0 | F_NOMATCH, "((?:a(*THEN)|aab)(*THEN)c|a+)+m", "aabcm" },
{ MUA, 0, "((?:a(*THEN)|aab)c|a+)+m", "aabcaabcnmaabcaabcm" },
{ MUA, 0, "((?:a|aab)(*THEN)c|a+)+m", "aam" },
{ MUA, 0, "((?:a(*COMMIT)|aab)(*THEN)c|a+)+m", "aam" },
{ MUA, 0, "(?(?=a(*THEN)b)ab|ad)", "ad" },
{ MUA, 0, "(?(?!a(*THEN)b)ad|add)", "add" },
{ MUA, 0 | F_NOMATCH, "(?(?=a)a(*THEN)b|ad)", "ad" },
{ MUA, 0, "(?!(?(?=a)ab|b(*THEN)d))bn|bnn", "bnn" },
/* Deep recursion. */
{ MUA, 0, "((((?:(?:(?:\\w)+)?)*|(?>\\w)+?)+|(?>\\w)?\?)*)?\\s", "aaaaa+ " },
{ MUA, 0, "(?:((?:(?:(?:\\w*?)+)??|(?>\\w)?|\\w*+)*)+)+?\\s", "aa+ " },
{ MUA, 0, "((a?)+)+b", "aaaaaaaaaaaa b" },
/* Deep recursion: Stack limit reached. */
{ MA, 0 | F_NOMATCH, "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaa" },
{ MA, 0 | F_NOMATCH, "(?:a+)+b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
{ MA, 0 | F_NOMATCH, "(?:a+?)+?b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
{ MA, 0 | F_NOMATCH, "(?:a*)*b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
{ MA, 0 | F_NOMATCH, "(?:a*?)*?b", "aaaaaaaaaaaaaaaaaaaaaaaa b" },
{ 0, 0, NULL, NULL }
};
static const unsigned char *tables(int mode)
{
/* The purpose of this function to allow valgrind
for reporting invalid reads and writes. */
static unsigned char *tables_copy;
const char *errorptr;
int erroroffset;
unsigned char *default_tables;
#if defined SUPPORT_PCRE8
pcre *regex;
char null_str[1] = { 0 };
#elif defined SUPPORT_PCRE16
pcre16 *regex;
PCRE_UCHAR16 null_str[1] = { 0 };
#elif defined SUPPORT_PCRE32
pcre32 *regex;
PCRE_UCHAR32 null_str[1] = { 0 };
#endif
if (mode) {
if (tables_copy)
free(tables_copy);
tables_copy = NULL;
return NULL;
}
if (tables_copy)
return tables_copy;
default_tables = NULL;
#if defined SUPPORT_PCRE8
regex = pcre_compile(null_str, 0, &errorptr, &erroroffset, NULL);
if (regex) {
pcre_fullinfo(regex, NULL, PCRE_INFO_DEFAULT_TABLES, &default_tables);
pcre_free(regex);
}
#elif defined SUPPORT_PCRE16
regex = pcre16_compile(null_str, 0, &errorptr, &erroroffset, NULL);
if (regex) {
pcre16_fullinfo(regex, NULL, PCRE_INFO_DEFAULT_TABLES, &default_tables);
pcre16_free(regex);
}
#elif defined SUPPORT_PCRE32
regex = pcre32_compile(null_str, 0, &errorptr, &erroroffset, NULL);
if (regex) {
pcre32_fullinfo(regex, NULL, PCRE_INFO_DEFAULT_TABLES, &default_tables);
pcre32_free(regex);
}
#endif
/* Shouldn't ever happen. */
if (!default_tables)
return NULL;
/* Unfortunately this value cannot get from pcre_fullinfo.
Since this is a test program, this is acceptable at the moment. */
tables_copy = (unsigned char *)malloc(1088);
if (!tables_copy)
return NULL;
memcpy(tables_copy, default_tables, 1088);
return tables_copy;
}
#ifdef SUPPORT_PCRE8
static pcre_jit_stack* callback8(void *arg)
{
return (pcre_jit_stack *)arg;
}
#endif
#ifdef SUPPORT_PCRE16
static pcre16_jit_stack* callback16(void *arg)
{
return (pcre16_jit_stack *)arg;
}
#endif
#ifdef SUPPORT_PCRE32
static pcre32_jit_stack* callback32(void *arg)
{
return (pcre32_jit_stack *)arg;
}
#endif
#ifdef SUPPORT_PCRE8
static pcre_jit_stack *stack8;
static pcre_jit_stack *getstack8(void)
{
if (!stack8)
stack8 = pcre_jit_stack_alloc(1, 1024 * 1024);
return stack8;
}
static void setstack8(pcre_extra *extra)
{
if (!extra) {
if (stack8)
pcre_jit_stack_free(stack8);
stack8 = NULL;
return;
}
pcre_assign_jit_stack(extra, callback8, getstack8());
}
#endif /* SUPPORT_PCRE8 */
#ifdef SUPPORT_PCRE16
static pcre16_jit_stack *stack16;
static pcre16_jit_stack *getstack16(void)
{
if (!stack16)
stack16 = pcre16_jit_stack_alloc(1, 1024 * 1024);
return stack16;
}
static void setstack16(pcre16_extra *extra)
{
if (!extra) {
if (stack16)
pcre16_jit_stack_free(stack16);
stack16 = NULL;
return;
}
pcre16_assign_jit_stack(extra, callback16, getstack16());
}
#endif /* SUPPORT_PCRE16 */
#ifdef SUPPORT_PCRE32
static pcre32_jit_stack *stack32;
static pcre32_jit_stack *getstack32(void)
{
if (!stack32)
stack32 = pcre32_jit_stack_alloc(1, 1024 * 1024);
return stack32;
}
static void setstack32(pcre32_extra *extra)
{
if (!extra) {
if (stack32)
pcre32_jit_stack_free(stack32);
stack32 = NULL;
return;
}
pcre32_assign_jit_stack(extra, callback32, getstack32());
}
#endif /* SUPPORT_PCRE32 */
#ifdef SUPPORT_PCRE16
static int convert_utf8_to_utf16(const char *input, PCRE_UCHAR16 *output, int *offsetmap, int max_length)
{
unsigned char *iptr = (unsigned char*)input;
PCRE_UCHAR16 *optr = output;
unsigned int c;
if (max_length == 0)
return 0;
while (*iptr && max_length > 1) {
c = 0;
if (offsetmap)
*offsetmap++ = (int)(iptr - (unsigned char*)input);
if (*iptr < 0xc0)
c = *iptr++;
else if (!(*iptr & 0x20)) {
c = ((iptr[0] & 0x1f) << 6) | (iptr[1] & 0x3f);
iptr += 2;
} else if (!(*iptr & 0x10)) {
c = ((iptr[0] & 0x0f) << 12) | ((iptr[1] & 0x3f) << 6) | (iptr[2] & 0x3f);
iptr += 3;
} else if (!(*iptr & 0x08)) {
c = ((iptr[0] & 0x07) << 18) | ((iptr[1] & 0x3f) << 12) | ((iptr[2] & 0x3f) << 6) | (iptr[3] & 0x3f);
iptr += 4;
}
if (c < 65536) {
*optr++ = c;
max_length--;
} else if (max_length <= 2) {
*optr = '\0';
return (int)(optr - output);
} else {
c -= 0x10000;
*optr++ = 0xd800 | ((c >> 10) & 0x3ff);
*optr++ = 0xdc00 | (c & 0x3ff);
max_length -= 2;
if (offsetmap)
offsetmap++;
}
}
if (offsetmap)
*offsetmap = (int)(iptr - (unsigned char*)input);
*optr = '\0';
return (int)(optr - output);
}
static int copy_char8_to_char16(const char *input, PCRE_UCHAR16 *output, int max_length)
{
unsigned char *iptr = (unsigned char*)input;
PCRE_UCHAR16 *optr = output;
if (max_length == 0)
return 0;
while (*iptr && max_length > 1) {
*optr++ = *iptr++;
max_length--;
}
*optr = '\0';
return (int)(optr - output);
}
#define REGTEST_MAX_LENGTH16 4096
static PCRE_UCHAR16 regtest_buf16[REGTEST_MAX_LENGTH16];
static int regtest_offsetmap16[REGTEST_MAX_LENGTH16];
#endif /* SUPPORT_PCRE16 */
#ifdef SUPPORT_PCRE32
static int convert_utf8_to_utf32(const char *input, PCRE_UCHAR32 *output, int *offsetmap, int max_length)
{
unsigned char *iptr = (unsigned char*)input;
PCRE_UCHAR32 *optr = output;
unsigned int c;
if (max_length == 0)
return 0;
while (*iptr && max_length > 1) {
c = 0;
if (offsetmap)
*offsetmap++ = (int)(iptr - (unsigned char*)input);
if (*iptr < 0xc0)
c = *iptr++;
else if (!(*iptr & 0x20)) {
c = ((iptr[0] & 0x1f) << 6) | (iptr[1] & 0x3f);
iptr += 2;
} else if (!(*iptr & 0x10)) {
c = ((iptr[0] & 0x0f) << 12) | ((iptr[1] & 0x3f) << 6) | (iptr[2] & 0x3f);
iptr += 3;
} else if (!(*iptr & 0x08)) {
c = ((iptr[0] & 0x07) << 18) | ((iptr[1] & 0x3f) << 12) | ((iptr[2] & 0x3f) << 6) | (iptr[3] & 0x3f);
iptr += 4;
}
*optr++ = c;
max_length--;
}
if (offsetmap)
*offsetmap = (int)(iptr - (unsigned char*)input);
*optr = 0;
return (int)(optr - output);
}
static int copy_char8_to_char32(const char *input, PCRE_UCHAR32 *output, int max_length)
{
unsigned char *iptr = (unsigned char*)input;
PCRE_UCHAR32 *optr = output;
if (max_length == 0)
return 0;
while (*iptr && max_length > 1) {
*optr++ = *iptr++;
max_length--;
}
*optr = '\0';
return (int)(optr - output);
}
#define REGTEST_MAX_LENGTH32 4096
static PCRE_UCHAR32 regtest_buf32[REGTEST_MAX_LENGTH32];
static int regtest_offsetmap32[REGTEST_MAX_LENGTH32];
#endif /* SUPPORT_PCRE32 */
static int check_ascii(const char *input)
{
const unsigned char *ptr = (unsigned char *)input;
while (*ptr) {
if (*ptr > 127)
return 0;
ptr++;
}
return 1;
}
static int regression_tests(void)
{
struct regression_test_case *current = regression_test_cases;
const char *error;
char *cpu_info;
int i, err_offs;
int is_successful, is_ascii;
int total = 0;
int successful = 0;
int successful_row = 0;
int counter = 0;
int study_mode;
int utf = 0, ucp = 0;
int disabled_flags = 0;
#ifdef SUPPORT_PCRE8
pcre *re8;
pcre_extra *extra8;
pcre_extra dummy_extra8;
int ovector8_1[32];
int ovector8_2[32];
int return_value8[2];
unsigned char *mark8_1, *mark8_2;
#endif
#ifdef SUPPORT_PCRE16
pcre16 *re16;
pcre16_extra *extra16;
pcre16_extra dummy_extra16;
int ovector16_1[32];
int ovector16_2[32];
int return_value16[2];
PCRE_UCHAR16 *mark16_1, *mark16_2;
int length16;
#endif
#ifdef SUPPORT_PCRE32
pcre32 *re32;
pcre32_extra *extra32;
pcre32_extra dummy_extra32;
int ovector32_1[32];
int ovector32_2[32];
int return_value32[2];
PCRE_UCHAR32 *mark32_1, *mark32_2;
int length32;
#endif
/* This test compares the behaviour of interpreter and JIT. Although disabling
utf or ucp may make tests fail, if the pcre_exec result is the SAME, it is
still considered successful from pcre_jit_test point of view. */
#if defined SUPPORT_PCRE8
pcre_config(PCRE_CONFIG_JITTARGET, &cpu_info);
#elif defined SUPPORT_PCRE16
pcre16_config(PCRE_CONFIG_JITTARGET, &cpu_info);
#elif defined SUPPORT_PCRE32
pcre32_config(PCRE_CONFIG_JITTARGET, &cpu_info);
#endif
printf("Running JIT regression tests\n");
printf(" target CPU of SLJIT compiler: %s\n", cpu_info);
#if defined SUPPORT_PCRE8
pcre_config(PCRE_CONFIG_UTF8, &utf);
pcre_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp);
#elif defined SUPPORT_PCRE16
pcre16_config(PCRE_CONFIG_UTF16, &utf);
pcre16_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp);
#elif defined SUPPORT_PCRE32
pcre32_config(PCRE_CONFIG_UTF32, &utf);
pcre32_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp);
#endif
if (!utf)
disabled_flags |= PCRE_UTF8 | PCRE_UTF16 | PCRE_UTF32;
if (!ucp)
disabled_flags |= PCRE_UCP;
#ifdef SUPPORT_PCRE8
printf(" in 8 bit mode with UTF-8 %s and ucp %s:\n", utf ? "enabled" : "disabled", ucp ? "enabled" : "disabled");
#endif
#ifdef SUPPORT_PCRE16
printf(" in 16 bit mode with UTF-16 %s and ucp %s:\n", utf ? "enabled" : "disabled", ucp ? "enabled" : "disabled");
#endif
#ifdef SUPPORT_PCRE32
printf(" in 32 bit mode with UTF-32 %s and ucp %s:\n", utf ? "enabled" : "disabled", ucp ? "enabled" : "disabled");
#endif
while (current->pattern) {
/* printf("\nPattern: %s :\n", current->pattern); */
total++;
is_ascii = 0;
if (!(current->start_offset & F_PROPERTY))
is_ascii = check_ascii(current->pattern) && check_ascii(current->input);
if (current->flags & PCRE_PARTIAL_SOFT)
study_mode = PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE;
else if (current->flags & PCRE_PARTIAL_HARD)
study_mode = PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE;
else
study_mode = PCRE_STUDY_JIT_COMPILE;
error = NULL;
#ifdef SUPPORT_PCRE8
re8 = NULL;
if (!(current->start_offset & F_NO8))
re8 = pcre_compile(current->pattern,
current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | disabled_flags),
&error, &err_offs, tables(0));
extra8 = NULL;
if (re8) {
error = NULL;
extra8 = pcre_study(re8, study_mode, &error);
if (!extra8) {
printf("\n8 bit: Cannot study pattern: %s\n", current->pattern);
pcre_free(re8);
re8 = NULL;
}
else if (!(extra8->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
printf("\n8 bit: JIT compiler does not support: %s\n", current->pattern);
pcre_free_study(extra8);
pcre_free(re8);
re8 = NULL;
}
extra8->flags |= PCRE_EXTRA_MARK;
} else if (((utf && ucp) || is_ascii) && !(current->start_offset & F_NO8))
printf("\n8 bit: Cannot compile pattern \"%s\": %s\n", current->pattern, error);
#endif
#ifdef SUPPORT_PCRE16
if ((current->flags & PCRE_UTF16) || (current->start_offset & F_FORCECONV))
convert_utf8_to_utf16(current->pattern, regtest_buf16, NULL, REGTEST_MAX_LENGTH16);
else
copy_char8_to_char16(current->pattern, regtest_buf16, REGTEST_MAX_LENGTH16);
re16 = NULL;
if (!(current->start_offset & F_NO16))
re16 = pcre16_compile(regtest_buf16,
current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | disabled_flags),
&error, &err_offs, tables(0));
extra16 = NULL;
if (re16) {
error = NULL;
extra16 = pcre16_study(re16, study_mode, &error);
if (!extra16) {
printf("\n16 bit: Cannot study pattern: %s\n", current->pattern);
pcre16_free(re16);
re16 = NULL;
}
else if (!(extra16->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
printf("\n16 bit: JIT compiler does not support: %s\n", current->pattern);
pcre16_free_study(extra16);
pcre16_free(re16);
re16 = NULL;
}
extra16->flags |= PCRE_EXTRA_MARK;
} else if (((utf && ucp) || is_ascii) && !(current->start_offset & F_NO16))
printf("\n16 bit: Cannot compile pattern \"%s\": %s\n", current->pattern, error);
#endif
#ifdef SUPPORT_PCRE32
if ((current->flags & PCRE_UTF32) || (current->start_offset & F_FORCECONV))
convert_utf8_to_utf32(current->pattern, regtest_buf32, NULL, REGTEST_MAX_LENGTH32);
else
copy_char8_to_char32(current->pattern, regtest_buf32, REGTEST_MAX_LENGTH32);
re32 = NULL;
if (!(current->start_offset & F_NO32))
re32 = pcre32_compile(regtest_buf32,
current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | disabled_flags),
&error, &err_offs, tables(0));
extra32 = NULL;
if (re32) {
error = NULL;
extra32 = pcre32_study(re32, study_mode, &error);
if (!extra32) {
printf("\n32 bit: Cannot study pattern: %s\n", current->pattern);
pcre32_free(re32);
re32 = NULL;
}
if (!(extra32->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
printf("\n32 bit: JIT compiler does not support: %s\n", current->pattern);
pcre32_free_study(extra32);
pcre32_free(re32);
re32 = NULL;
}
extra32->flags |= PCRE_EXTRA_MARK;
} else if (((utf && ucp) || is_ascii) && !(current->start_offset & F_NO32))
printf("\n32 bit: Cannot compile pattern \"%s\": %s\n", current->pattern, error);
#endif
counter++;
if ((counter & 0x3) != 0) {
#ifdef SUPPORT_PCRE8
setstack8(NULL);
#endif
#ifdef SUPPORT_PCRE16
setstack16(NULL);
#endif
#ifdef SUPPORT_PCRE32
setstack32(NULL);
#endif
}
#ifdef SUPPORT_PCRE8
return_value8[0] = -1000;
return_value8[1] = -1000;
for (i = 0; i < 32; ++i)
ovector8_1[i] = -2;
for (i = 0; i < 32; ++i)
ovector8_2[i] = -2;
if (re8) {
mark8_1 = NULL;
mark8_2 = NULL;
extra8->mark = &mark8_1;
if ((counter & 0x1) != 0) {
setstack8(extra8);
return_value8[0] = pcre_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector8_1, 32);
} else
return_value8[0] = pcre_jit_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector8_1, 32, getstack8());
memset(&dummy_extra8, 0, sizeof(pcre_extra));
dummy_extra8.flags = PCRE_EXTRA_MARK;
if (current->start_offset & F_STUDY) {
dummy_extra8.flags |= PCRE_EXTRA_STUDY_DATA;
dummy_extra8.study_data = extra8->study_data;
}
dummy_extra8.mark = &mark8_2;
return_value8[1] = pcre_exec(re8, &dummy_extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector8_2, 32);
}
#endif
#ifdef SUPPORT_PCRE16
return_value16[0] = -1000;
return_value16[1] = -1000;
for (i = 0; i < 32; ++i)
ovector16_1[i] = -2;
for (i = 0; i < 32; ++i)
ovector16_2[i] = -2;
if (re16) {
mark16_1 = NULL;
mark16_2 = NULL;
if ((current->flags & PCRE_UTF16) || (current->start_offset & F_FORCECONV))
length16 = convert_utf8_to_utf16(current->input, regtest_buf16, regtest_offsetmap16, REGTEST_MAX_LENGTH16);
else
length16 = copy_char8_to_char16(current->input, regtest_buf16, REGTEST_MAX_LENGTH16);
extra16->mark = &mark16_1;
if ((counter & 0x1) != 0) {
setstack16(extra16);
return_value16[0] = pcre16_exec(re16, extra16, regtest_buf16, length16, current->start_offset & OFFSET_MASK,
current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector16_1, 32);
} else
return_value16[0] = pcre16_jit_exec(re16, extra16, regtest_buf16, length16, current->start_offset & OFFSET_MASK,
current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector16_1, 32, getstack16());
memset(&dummy_extra16, 0, sizeof(pcre16_extra));
dummy_extra16.flags = PCRE_EXTRA_MARK;
if (current->start_offset & F_STUDY) {
dummy_extra16.flags |= PCRE_EXTRA_STUDY_DATA;
dummy_extra16.study_data = extra16->study_data;
}
dummy_extra16.mark = &mark16_2;
return_value16[1] = pcre16_exec(re16, &dummy_extra16, regtest_buf16, length16, current->start_offset & OFFSET_MASK,
current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector16_2, 32);
}
#endif
#ifdef SUPPORT_PCRE32
return_value32[0] = -1000;
return_value32[1] = -1000;
for (i = 0; i < 32; ++i)
ovector32_1[i] = -2;
for (i = 0; i < 32; ++i)
ovector32_2[i] = -2;
if (re32) {
mark32_1 = NULL;
mark32_2 = NULL;
if ((current->flags & PCRE_UTF32) || (current->start_offset & F_FORCECONV))
length32 = convert_utf8_to_utf32(current->input, regtest_buf32, regtest_offsetmap32, REGTEST_MAX_LENGTH32);
else
length32 = copy_char8_to_char32(current->input, regtest_buf32, REGTEST_MAX_LENGTH32);
extra32->mark = &mark32_1;
if ((counter & 0x1) != 0) {
setstack32(extra32);
return_value32[0] = pcre32_exec(re32, extra32, regtest_buf32, length32, current->start_offset & OFFSET_MASK,
current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector32_1, 32);
} else
return_value32[0] = pcre32_jit_exec(re32, extra32, regtest_buf32, length32, current->start_offset & OFFSET_MASK,
current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector32_1, 32, getstack32());
memset(&dummy_extra32, 0, sizeof(pcre32_extra));
dummy_extra32.flags = PCRE_EXTRA_MARK;
if (current->start_offset & F_STUDY) {
dummy_extra32.flags |= PCRE_EXTRA_STUDY_DATA;
dummy_extra32.study_data = extra32->study_data;
}
dummy_extra32.mark = &mark32_2;
return_value32[1] = pcre32_exec(re32, &dummy_extra32, regtest_buf32, length32, current->start_offset & OFFSET_MASK,
current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD | PCRE_NO_UTF8_CHECK), ovector32_2, 32);
}
#endif
/* printf("[%d-%d-%d|%d-%d|%d-%d|%d-%d]%s",
return_value8[0], return_value16[0], return_value32[0],
ovector8_1[0], ovector8_1[1],
ovector16_1[0], ovector16_1[1],
ovector32_1[0], ovector32_1[1],
(current->flags & PCRE_CASELESS) ? "C" : ""); */
/* If F_DIFF is set, just run the test, but do not compare the results.
Segfaults can still be captured. */
is_successful = 1;
if (!(current->start_offset & F_DIFF)) {
#if defined SUPPORT_UTF && ((defined(SUPPORT_PCRE8) + defined(SUPPORT_PCRE16) + defined(SUPPORT_PCRE32)) >= 2)
if (!(current->start_offset & F_FORCECONV)) {
int return_value;
/* All results must be the same. */
#ifdef SUPPORT_PCRE8
if ((return_value = return_value8[0]) != return_value8[1]) {
printf("\n8 bit: Return value differs(J8:%d,I8:%d): [%d] '%s' @ '%s'\n",
return_value8[0], return_value8[1], total, current->pattern, current->input);
is_successful = 0;
} else
#endif
#ifdef SUPPORT_PCRE16
if ((return_value = return_value16[0]) != return_value16[1]) {
printf("\n16 bit: Return value differs(J16:%d,I16:%d): [%d] '%s' @ '%s'\n",
return_value16[0], return_value16[1], total, current->pattern, current->input);
is_successful = 0;
} else
#endif
#ifdef SUPPORT_PCRE32
if ((return_value = return_value32[0]) != return_value32[1]) {
printf("\n32 bit: Return value differs(J32:%d,I32:%d): [%d] '%s' @ '%s'\n",
return_value32[0], return_value32[1], total, current->pattern, current->input);
is_successful = 0;
} else
#endif
#if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16
if (return_value8[0] != return_value16[0]) {
printf("\n8 and 16 bit: Return value differs(J8:%d,J16:%d): [%d] '%s' @ '%s'\n",
return_value8[0], return_value16[0],
total, current->pattern, current->input);
is_successful = 0;
} else
#endif
#if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE32
if (return_value8[0] != return_value32[0]) {
printf("\n8 and 32 bit: Return value differs(J8:%d,J32:%d): [%d] '%s' @ '%s'\n",
return_value8[0], return_value32[0],
total, current->pattern, current->input);
is_successful = 0;
} else
#endif
#if defined SUPPORT_PCRE16 && defined SUPPORT_PCRE32
if (return_value16[0] != return_value32[0]) {
printf("\n16 and 32 bit: Return value differs(J16:%d,J32:%d): [%d] '%s' @ '%s'\n",
return_value16[0], return_value32[0],
total, current->pattern, current->input);
is_successful = 0;
} else
#endif
if (return_value >= 0 || return_value == PCRE_ERROR_PARTIAL) {
if (return_value == PCRE_ERROR_PARTIAL) {
return_value = 2;
} else {
return_value *= 2;
}
#ifdef SUPPORT_PCRE8
return_value8[0] = return_value;
#endif
#ifdef SUPPORT_PCRE16
return_value16[0] = return_value;
#endif
#ifdef SUPPORT_PCRE32
return_value32[0] = return_value;
#endif
/* Transform back the results. */
if (current->flags & PCRE_UTF8) {
#ifdef SUPPORT_PCRE16
for (i = 0; i < return_value; ++i) {
if (ovector16_1[i] >= 0)
ovector16_1[i] = regtest_offsetmap16[ovector16_1[i]];
if (ovector16_2[i] >= 0)
ovector16_2[i] = regtest_offsetmap16[ovector16_2[i]];
}
#endif
#ifdef SUPPORT_PCRE32
for (i = 0; i < return_value; ++i) {
if (ovector32_1[i] >= 0)
ovector32_1[i] = regtest_offsetmap32[ovector32_1[i]];
if (ovector32_2[i] >= 0)
ovector32_2[i] = regtest_offsetmap32[ovector32_2[i]];
}
#endif
}
for (i = 0; i < return_value; ++i) {
#if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16
if (ovector8_1[i] != ovector8_2[i] || ovector8_1[i] != ovector16_1[i] || ovector8_1[i] != ovector16_2[i]) {
printf("\n8 and 16 bit: Ovector[%d] value differs(J8:%d,I8:%d,J16:%d,I16:%d): [%d] '%s' @ '%s' \n",
i, ovector8_1[i], ovector8_2[i], ovector16_1[i], ovector16_2[i],
total, current->pattern, current->input);
is_successful = 0;
}
#endif
#if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE32
if (ovector8_1[i] != ovector8_2[i] || ovector8_1[i] != ovector32_1[i] || ovector8_1[i] != ovector32_2[i]) {
printf("\n8 and 32 bit: Ovector[%d] value differs(J8:%d,I8:%d,J32:%d,I32:%d): [%d] '%s' @ '%s' \n",
i, ovector8_1[i], ovector8_2[i], ovector32_1[i], ovector32_2[i],
total, current->pattern, current->input);
is_successful = 0;
}
#endif
#if defined SUPPORT_PCRE16 && defined SUPPORT_PCRE16
if (ovector16_1[i] != ovector16_2[i] || ovector16_1[i] != ovector16_1[i] || ovector16_1[i] != ovector16_2[i]) {
printf("\n16 and 16 bit: Ovector[%d] value differs(J16:%d,I16:%d,J32:%d,I32:%d): [%d] '%s' @ '%s' \n",
i, ovector16_1[i], ovector16_2[i], ovector16_1[i], ovector16_2[i],
total, current->pattern, current->input);
is_successful = 0;
}
#endif
}
}
} else
#endif /* more than one of SUPPORT_PCRE8, SUPPORT_PCRE16 and SUPPORT_PCRE32 */
{
/* Only the 8 bit and 16 bit results must be equal. */
#ifdef SUPPORT_PCRE8
if (return_value8[0] != return_value8[1]) {
printf("\n8 bit: Return value differs(%d:%d): [%d] '%s' @ '%s'\n",
return_value8[0], return_value8[1], total, current->pattern, current->input);
is_successful = 0;
} else if (return_value8[0] >= 0 || return_value8[0] == PCRE_ERROR_PARTIAL) {
if (return_value8[0] == PCRE_ERROR_PARTIAL)
return_value8[0] = 2;
else
return_value8[0] *= 2;
for (i = 0; i < return_value8[0]; ++i)
if (ovector8_1[i] != ovector8_2[i]) {
printf("\n8 bit: Ovector[%d] value differs(%d:%d): [%d] '%s' @ '%s'\n",
i, ovector8_1[i], ovector8_2[i], total, current->pattern, current->input);
is_successful = 0;
}
}
#endif
#ifdef SUPPORT_PCRE16
if (return_value16[0] != return_value16[1]) {
printf("\n16 bit: Return value differs(%d:%d): [%d] '%s' @ '%s'\n",
return_value16[0], return_value16[1], total, current->pattern, current->input);
is_successful = 0;
} else if (return_value16[0] >= 0 || return_value16[0] == PCRE_ERROR_PARTIAL) {
if (return_value16[0] == PCRE_ERROR_PARTIAL)
return_value16[0] = 2;
else
return_value16[0] *= 2;
for (i = 0; i < return_value16[0]; ++i)
if (ovector16_1[i] != ovector16_2[i]) {
printf("\n16 bit: Ovector[%d] value differs(%d:%d): [%d] '%s' @ '%s'\n",
i, ovector16_1[i], ovector16_2[i], total, current->pattern, current->input);
is_successful = 0;
}
}
#endif
#ifdef SUPPORT_PCRE32
if (return_value32[0] != return_value32[1]) {
printf("\n32 bit: Return value differs(%d:%d): [%d] '%s' @ '%s'\n",
return_value32[0], return_value32[1], total, current->pattern, current->input);
is_successful = 0;
} else if (return_value32[0] >= 0 || return_value32[0] == PCRE_ERROR_PARTIAL) {
if (return_value32[0] == PCRE_ERROR_PARTIAL)
return_value32[0] = 2;
else
return_value32[0] *= 2;
for (i = 0; i < return_value32[0]; ++i)
if (ovector32_1[i] != ovector32_2[i]) {
printf("\n32 bit: Ovector[%d] value differs(%d:%d): [%d] '%s' @ '%s'\n",
i, ovector32_1[i], ovector32_2[i], total, current->pattern, current->input);
is_successful = 0;
}
}
#endif
}
}
if (is_successful) {
#ifdef SUPPORT_PCRE8
if (!(current->start_offset & F_NO8) && ((utf && ucp) || is_ascii)) {
if (return_value8[0] < 0 && !(current->start_offset & F_NOMATCH)) {
printf("8 bit: Test should match: [%d] '%s' @ '%s'\n",
total, current->pattern, current->input);
is_successful = 0;
}
if (return_value8[0] >= 0 && (current->start_offset & F_NOMATCH)) {
printf("8 bit: Test should not match: [%d] '%s' @ '%s'\n",
total, current->pattern, current->input);
is_successful = 0;
}
}
#endif
#ifdef SUPPORT_PCRE16
if (!(current->start_offset & F_NO16) && ((utf && ucp) || is_ascii)) {
if (return_value16[0] < 0 && !(current->start_offset & F_NOMATCH)) {
printf("16 bit: Test should match: [%d] '%s' @ '%s'\n",
total, current->pattern, current->input);
is_successful = 0;
}
if (return_value16[0] >= 0 && (current->start_offset & F_NOMATCH)) {
printf("16 bit: Test should not match: [%d] '%s' @ '%s'\n",
total, current->pattern, current->input);
is_successful = 0;
}
}
#endif
#ifdef SUPPORT_PCRE32
if (!(current->start_offset & F_NO32) && ((utf && ucp) || is_ascii)) {
if (return_value32[0] < 0 && !(current->start_offset & F_NOMATCH)) {
printf("32 bit: Test should match: [%d] '%s' @ '%s'\n",
total, current->pattern, current->input);
is_successful = 0;
}
if (return_value32[0] >= 0 && (current->start_offset & F_NOMATCH)) {
printf("32 bit: Test should not match: [%d] '%s' @ '%s'\n",
total, current->pattern, current->input);
is_successful = 0;
}
}
#endif
}
if (is_successful) {
#ifdef SUPPORT_PCRE8
if (mark8_1 != mark8_2) {
printf("8 bit: Mark value mismatch: [%d] '%s' @ '%s'\n",
total, current->pattern, current->input);
is_successful = 0;
}
#endif
#ifdef SUPPORT_PCRE16
if (mark16_1 != mark16_2) {
printf("16 bit: Mark value mismatch: [%d] '%s' @ '%s'\n",
total, current->pattern, current->input);
is_successful = 0;
}
#endif
#ifdef SUPPORT_PCRE32
if (mark32_1 != mark32_2) {
printf("32 bit: Mark value mismatch: [%d] '%s' @ '%s'\n",
total, current->pattern, current->input);
is_successful = 0;
}
#endif
}
#ifdef SUPPORT_PCRE8
if (re8) {
pcre_free_study(extra8);
pcre_free(re8);
}
#endif
#ifdef SUPPORT_PCRE16
if (re16) {
pcre16_free_study(extra16);
pcre16_free(re16);
}
#endif
#ifdef SUPPORT_PCRE32
if (re32) {
pcre32_free_study(extra32);
pcre32_free(re32);
}
#endif
if (is_successful) {
successful++;
successful_row++;
printf(".");
if (successful_row >= 60) {
successful_row = 0;
printf("\n");
}
} else
successful_row = 0;
fflush(stdout);
current++;
}
tables(1);
#ifdef SUPPORT_PCRE8
setstack8(NULL);
#endif
#ifdef SUPPORT_PCRE16
setstack16(NULL);
#endif
#ifdef SUPPORT_PCRE32
setstack32(NULL);
#endif
if (total == successful) {
printf("\nAll JIT regression tests are successfully passed.\n");
return 0;
} else {
printf("\nSuccessful test ratio: %d%% (%d failed)\n", successful * 100 / total, total - successful);
return 1;
}
}
/* End of pcre_jit_test.c */
pcre-8.38/pcregexp.pas 0000644 0002221 0002221 00000062727 12272732025 011654 0000000 0000000 {
pcRegExp - Perl compatible regular expressions for Virtual Pascal
(c) 2001 Peter S. Voronov aka Chem O'Dun
Based on PCRE library interface unit for Virtual Pascal.
(c) 2001 Alexander Tokarev
The current PCRE version is: 3.7
This software may be distributed under the terms of the modified BSD license
Copyright (c) 2001, Alexander Tokarev
All rights reserved.
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 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 HOLDER 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.
The PCRE library is written by: Philip Hazel
Copyright (c) 1997-2004 University of Cambridge
AngelsHolocaust 4-11-04 updated to use version v5.0
(INFO: this is regex-directed, NFA)
AH: 9-11-04 - pcre_free: removed var, pcre already gives the ptr, now
everything works as it should (no more crashes)
-> removed CheckRegExp because pcre handles errors perfectly
10-11-04 - added pcError (errorhandling), pcInit
13-11-04 - removed the ErrorPos = 0 check -> always print erroroffset
17-10-05 - support for \1-\9 backreferences in TpcRegExp.GetReplStr
17-02-06 - added RunTimeOptions: caller can set options while searching
19-02-06 - added SearchOfs(): let PCRE use the complete string and offset
into the string itself
20-12-06 - support for version 7.0
27.08.08 - support for v7.7
}
{$H+} {$DEFINE PCRE_3_7} {$DEFINE PCRE_5_0} {$DEFINE PCRE_7_0} {$DEFINE PCRE_7_7}
Unit pcregexp;
Interface
uses objects;
Type
PpcRegExp = ^TpcRegExp;
// TpcRegExp = object
TpcRegExp = object(TObject)
MatchesCount: integer;
RegExpC, RegExpExt : Pointer;
Matches:Pointer;
RegExp: shortstring;
SourceLen: integer;
PartialMatch : boolean;
Error : boolean;
ErrorMsg : Pchar;
ErrorPos : integer;
RunTimeOptions: Integer; // options which can be set by the caller
constructor Init(const ARegExp : shortstring; AOptions : integer; ALocale : Pointer);
function Search(AStr: Pchar; ALen : longint) : boolean; virtual;
function SearchNext( AStr: Pchar; ALen : longint) : boolean; virtual;
function SearchOfs ( AStr: Pchar; ALen, AOfs : longint) : boolean; virtual;
function MatchSub(ANom: integer; var Pos, Len : longint) : boolean; virtual;
function MatchFull(var Pos, Len : longint) : boolean; virtual;
function GetSubStr(ANom: integer; AStr: Pchar) : string; virtual;
function GetFullStr(AStr: Pchar) : string; virtual;
function GetReplStr(AStr: Pchar; const ARepl: string) : string; virtual;
function GetPreSubStr(AStr: Pchar) : string; virtual;
function GetPostSubStr(AStr: Pchar) : string; virtual;
function ErrorStr : string; virtual;
destructor Done; virtual;
end;
function pcGrepMatch(WildCard, aStr: string; AOptions:integer; ALocale : Pointer): Boolean;
function pcGrepSub(WildCard, aStr, aRepl: string; AOptions:integer; ALocale : Pointer): string;
function pcFastGrepMatch(WildCard, aStr: string): Boolean;
function pcFastGrepSub(WildCard, aStr, aRepl: string): string;
{$IFDEF PCRE_5_0}
function pcGetVersion : pchar;
{$ENDIF}
function pcError (var pRegExp : Pointer) : Boolean;
function pcInit (const Pattern: Shortstring; CaseSens: Boolean) : Pointer;
Const { Options }
PCRE_CASELESS = $0001;
PCRE_MULTILINE = $0002;
PCRE_DOTALL = $0004;
PCRE_EXTENDED = $0008;
PCRE_ANCHORED = $0010;
PCRE_DOLLAR_ENDONLY = $0020;
PCRE_EXTRA = $0040;
PCRE_NOTBOL = $0080;
PCRE_NOTEOL = $0100;
PCRE_UNGREEDY = $0200;
PCRE_NOTEMPTY = $0400;
{$IFDEF PCRE_5_0}
PCRE_UTF8 = $0800;
PCRE_NO_AUTO_CAPTURE = $1000;
PCRE_NO_UTF8_CHECK = $2000;
PCRE_AUTO_CALLOUT = $4000;
PCRE_PARTIAL = $8000;
{$ENDIF}
{$IFDEF PCRE_7_0}
PCRE_DFA_SHORTEST = $00010000;
PCRE_DFA_RESTART = $00020000;
PCRE_FIRSTLINE = $00040000;
PCRE_DUPNAMES = $00080000;
PCRE_NEWLINE_CR = $00100000;
PCRE_NEWLINE_LF = $00200000;
PCRE_NEWLINE_CRLF = $00300000;
PCRE_NEWLINE_ANY = $00400000;
PCRE_NEWLINE_ANYCRLF = $00500000;
PCRE_NEWLINE_BITS = PCRE_NEWLINE_CR or PCRE_NEWLINE_LF or PCRE_NEWLINE_ANY;
{$ENDIF}
{$IFDEF PCRE_7_7}
PCRE_BSR_ANYCRLF = $00800000;
PCRE_BSR_UNICODE = $01000000;
PCRE_JAVASCRIPT_COMPAT= $02000000;
{$ENDIF}
PCRE_COMPILE_ALLOWED_OPTIONS = PCRE_ANCHORED + PCRE_AUTO_CALLOUT + PCRE_CASELESS +
PCRE_DOLLAR_ENDONLY + PCRE_DOTALL + PCRE_EXTENDED +
PCRE_EXTRA + PCRE_MULTILINE + PCRE_NO_AUTO_CAPTURE +
PCRE_UNGREEDY + PCRE_UTF8 + PCRE_NO_UTF8_CHECK
{$IFDEF PCRE_7_0}
+ PCRE_DUPNAMES + PCRE_FIRSTLINE + PCRE_NEWLINE_BITS
{$ENDIF}
{$IFDEF PCRE_7_7}
+ PCRE_BSR_ANYCRLF + PCRE_BSR_UNICODE + PCRE_JAVASCRIPT_COMPAT
{$ENDIF}
;
PCRE_EXEC_ALLOWED_OPTIONS = PCRE_ANCHORED + PCRE_NOTBOL + PCRE_NOTEOL +
PCRE_NOTEMPTY + PCRE_NO_UTF8_CHECK + PCRE_PARTIAL
{$IFDEF PCRE_7_0}
+ PCRE_NEWLINE_BITS
{$ENDIF}
{$IFDEF PCRE_7_7}
+ PCRE_BSR_ANYCRLF + PCRE_BSR_UNICODE
{$ENDIF}
;
{$IFDEF PCRE_7_0}
PCRE_DFA_EXEC_ALLOWED_OPTIONS = PCRE_ANCHORED + PCRE_NOTBOL + PCRE_NOTEOL +
PCRE_NOTEMPTY + PCRE_NO_UTF8_CHECK + PCRE_PARTIAL +
PCRE_DFA_SHORTEST + PCRE_DFA_RESTART +
PCRE_NEWLINE_BITS
{$IFDEF PCRE_7_7}
+ PCRE_BSR_ANYCRLF + PCRE_BSR_UNICODE
{$ENDIF}
;
{$ENDIF}
{ Exec-time and get/set-time error codes }
PCRE_ERROR_NOMATCH = -1;
PCRE_ERROR_NULL = -2;
PCRE_ERROR_BADOPTION = -3;
PCRE_ERROR_BADMAGIC = -4;
PCRE_ERROR_UNKNOWN_MODE = -5;
PCRE_ERROR_NOMEMORY = -6;
PCRE_ERROR_NOSUBSTRING = -7;
{$IFDEF PCRE_5_0}
PCRE_ERROR_MATCHLIMIT = -8;
PCRE_ERROR_CALLOUT = -9; { Never used by PCRE itself }
PCRE_ERROR_BADUTF8 = -10;
PCRE_ERROR_BADUTF8_OFFSET = -11;
PCRE_ERROR_PARTIAL = -12;
PCRE_ERROR_BADPARTIAL = -13;
PCRE_ERROR_INTERNAL = -14;
PCRE_ERROR_BADCOUNT = -15;
{$ENDIF}
{$IFDEF PCRE_7_0}
PCRE_ERROR_DFA_UITEM = -16;
PCRE_ERROR_DFA_UCOND = -17;
PCRE_ERROR_DFA_UMLIMIT = -18;
PCRE_ERROR_DFA_WSSIZE = -19;
PCRE_ERROR_DFA_RECURSE = -20;
PCRE_ERROR_RECURSIONLIMIT = -21;
PCRE_ERROR_NULLWSLIMIT = -22;
PCRE_ERROR_BADNEWLINE = -23;
{$ENDIF}
{ Request types for pcre_fullinfo() }
PCRE_INFO_OPTIONS = 0;
PCRE_INFO_SIZE = 1;
PCRE_INFO_CAPTURECOUNT = 2;
PCRE_INFO_BACKREFMAX = 3;
PCRE_INFO_FIRSTBYTE = 4;
PCRE_INFO_FIRSTCHAR = 4; { For backwards compatibility }
PCRE_INFO_FIRSTTABLE = 5;
{$IFDEF PCRE_5_0}
PCRE_INFO_LASTLITERAL = 6;
PCRE_INFO_NAMEENTRYSIZE = 7;
PCRE_INFO_NAMECOUNT = 8;
PCRE_INFO_NAMETABLE = 9;
PCRE_INFO_STUDYSIZE = 10;
PCRE_INFO_DEFAULT_TABLES = 11;
{$ENDIF PCRE_5_0}
{$IFDEF PCRE_7_7}
PCRE_INFO_OKPARTIAL = 12;
PCRE_INFO_JCHANGED = 13;
PCRE_INFO_HASCRORLF = 14;
{$ENDIF}
{ Request types for pcre_config() }
{$IFDEF PCRE_5_0}
PCRE_CONFIG_UTF8 = 0;
PCRE_CONFIG_NEWLINE = 1;
PCRE_CONFIG_LINK_SIZE = 2;
PCRE_CONFIG_POSIX_MALLOC_THRESHOLD = 3;
PCRE_CONFIG_MATCH_LIMIT = 4;
PCRE_CONFIG_STACKRECURSE = 5;
PCRE_CONFIG_UNICODE_PROPERTIES = 6;
{$ENDIF PCRE_5_0}
{$IFDEF PCRE_7_0}
PCRE_CONFIG_MATCH_LIMIT_RECURSION = 7;
{$ENDIF}
{$IFDEF PCRE_7_7}
PCRE_CONFIG_BSR = 8;
{$ENDIF}
{ Bit flags for the pcre_extra structure }
{$IFDEF PCRE_5_0}
PCRE_EXTRA_STUDY_DATA = $0001;
PCRE_EXTRA_MATCH_LIMIT = $0002;
PCRE_EXTRA_CALLOUT_DATA = $0004;
PCRE_EXTRA_TABLES = $0008;
{$ENDIF PCRE_5_0}
{$IFDEF PCRE_7_0}
PCRE_EXTRA_MATCH_LIMIT_RECURSION = $0010;
{$ENDIF}
Const
// DefaultOptions : integer = 0;
DefaultLocaleTable : pointer = nil;
{$IFDEF PCRE_5_0}
{ The structure for passing additional data to pcre_exec(). This is defined in
such as way as to be extensible. Always add new fields at the end, in order to
remain compatible. }
type ppcre_extra = ^tpcre_extra;
tpcre_extra = record
flags : longint; { Bits for which fields are set }
study_data : pointer; { Opaque data from pcre_study() }
match_limit : longint; { Maximum number of calls to match() }
callout_data : pointer; { Data passed back in callouts }
tables : pointer; { Pointer to character tables }
match_limit_recursion: longint; { Max recursive calls to match() }
end;
type ppcre_callout_block = ^pcre_callout_block;
pcre_callout_block = record
version,
(* ------------------------ Version 0 ------------------------------- *)
callout_number : integer;
offset_vector : pointer;
subject : pchar;
subject_length, start_match, current_position, capture_top,
capture_last : integer;
callout_data : pointer;
(* ------------------- Added for Version 1 -------------------------- *)
pattern_position, next_item_length : integer;
end;
{$ENDIF PCRE_5_0}
{$OrgName+}
{$IFDEF VIRTUALPASCAL} {&Cdecl+} {$ENDIF VIRTUALPASCAL}
{ local replacement of external pcre memory management functions }
function pcre_malloc( size : integer ) : pointer;
procedure pcre_free( {var} p : pointer );
{$IFDEF PCRE_5_0}
const pcre_stack_malloc: function ( size : integer ): pointer = pcre_malloc;
pcre_stack_free: procedure ( {var} p : pointer ) = pcre_free;
function pcre_callout(var p : ppcre_callout_block) : integer;
{$ENDIF PCRE_5_0}
{$IFDEF VIRTUALPASCAL} {&Cdecl-} {$ENDIF VIRTUALPASCAL}
Implementation
Uses strings, collect, messages, dnapp, commands, advance0, stringsx
{$IFDEF VIRTUALPASCAL} ,vpsyslow {$ENDIF VIRTUALPASCAL};
Const
MAGIC_NUMBER = $50435245; { 'PCRE' }
MAX_MATCHES = 90; { changed in 3.5 version; should be divisible by 3, was 64}
Type
PMatchArray = ^TMatchArray;
TMatchArray = array[0..( MAX_MATCHES * 3 )] of integer;
PRegExpCollection = ^TRegExpCollection;
TRegExpCollection = object(TSortedCollection)
MaxRegExp : integer;
SearchRegExp : shortstring;
CompareModeInsert : boolean;
constructor Init(AMaxRegExp:integer);
procedure FreeItem(P: Pointer); virtual;
function Compare(P1, P2: Pointer): Integer; virtual;
function Find(ARegExp:shortstring;var P: PpcRegExp):boolean; virtual;
function CheckNew(ARegExp:shortstring):PpcRegExp;virtual;
end;
Var
PRegExpCache : PRegExpCollection;
{$IFDEF VIRTUALPASCAL} {&Cdecl+} {$ENDIF VIRTUALPASCAL}
{ imported original pcre functions }
function pcre_compile( const pattern : PChar; options : integer;
var errorptr : PChar; var erroroffset : integer;
const tables : PChar ) : pointer {pcre}; external;
{$IFDEF PCRE_7_0}
function pcre_compile2( const pattern : PChar; options : integer;
var errorcodeptr : Integer;
var errorptr : PChar; var erroroffset : integer;
const tables : PChar ) : pointer {pcre}; external;
{$ENDIF}
{$IFDEF PCRE_5_0}
function pcre_config( what : integer; where : pointer) : integer; external;
function pcre_copy_named_substring( const code : pointer {pcre};
const subject : pchar;
var ovector : integer;
stringcount : integer;
const stringname : pchar;
var buffer : pchar;
size : integer) : integer; external;
function pcre_copy_substring( const subject : pchar; var ovector : integer;
stringcount, stringnumber : integer;
var buffer : pchar; size : integer )
: integer; external;
function pcre_exec( const argument_re : pointer {pcre};
const extra_data : pointer {pcre_extra};
{$ELSE}
function pcre_exec( const external_re : pointer;
const external_extra : pointer;
{$ENDIF}
const subject : PChar;
length, start_offset, options : integer;
offsets : pointer;
offsetcount : integer ) : integer; external;
{$IFDEF PCRE_7_0}
function pcre_dfa_exec( const argument_re : pointer {pcre};
const extra_data : pointer {pcre_extra};
const subject : pchar;
length, start_offset, options : integer;
offsets : pointer;
offsetcount : integer;
workspace : pointer;
wscount : integer ) : integer; external;
{$ENDIF}
{$IFDEF PCRE_5_0}
procedure pcre_free_substring( const p : pchar ); external;
procedure pcre_free_substring_list( var p : pchar ); external;
function pcre_fullinfo( const argument_re : pointer {pcre};
const extra_data : pointer {pcre_extra};
what : integer;
where : pointer ) : integer; external;
function pcre_get_named_substring( const code : pointer {pcre};
const subject : pchar;
var ovector : integer;
stringcount : integer;
const stringname : pchar;
var stringptr : pchar ) : integer; external;
function pcre_get_stringnumber( const code : pointer {pcre};
const stringname : pchar ) : integer; external;
function pcre_get_stringtable_entries( const code : pointer {pcre};
const stringname : pchar;
var firstptr,
lastptr : pchar ) : integer; external;
function pcre_get_substring( const subject : pchar; var ovector : integer;
stringcount, stringnumber : integer;
var stringptr : pchar ) : integer; external;
function pcre_get_substring_list( const subject : pchar; var ovector : integer;
stringcount : integer;
listptr : pointer {const char ***listptr}) : integer; external;
function pcre_info( const argument_re : pointer {pcre};
var optptr : integer;
var first_byte : integer ) : integer; external;
function pcre_maketables : pchar; external;
{$ENDIF}
{$IFDEF PCRE_7_0}
function pcre_refcount( const argument_re : pointer {pcre};
adjust : integer ) : pchar; external;
{$ENDIF}
function pcre_study( const external_re : pointer {pcre};
options : integer;
var errorptr : PChar ) : pointer {pcre_extra}; external;
{$IFDEF PCRE_5_0}
function pcre_version : pchar; external;
{$ENDIF}
function pcre_malloc( size : integer ) : pointer;
begin
GetMem( result, size );
end;
procedure pcre_free( {var} p : pointer );
begin
if (p <> nil) then
FreeMem( p, 0 );
{@p := nil;}
end;
{$IFDEF PCRE_5_0}
(* Called from PCRE as a result of the (?C) item. We print out where we are in
the match. Yield zero unless more callouts than the fail count, or the callout
data is not zero. *)
function pcre_callout;
begin
end;
{$ENDIF}
{$IFDEF VIRTUALPASCAL} {&Cdecl-} {$ENDIF VIRTUALPASCAL}
// Always include the newest version of the library
{$IFDEF PCRE_7_7}
{$L pcre77.lib}
{$ELSE}
{$IFDEF PCRE_7_0}
{$L pcre70.lib}
{$ELSE}
{$IFDEF PCRE_5_0}
{$L pcre50.lib}
{$ELSE}
{$IFDEF PCRE_3_7}
{$L pcre37.lib}
{$ENDIF PCRE_3_7}
{$ENDIF PCRE_5_0}
{$ENDIF PCRE_7_0}
{$ENDIF PCRE_7_7}
{TpcRegExp}
constructor TpcRegExp.Init(const ARegExp:shortstring; AOptions:integer; ALocale : Pointer);
var
pRegExp : PChar;
begin
RegExp:=ARegExp;
RegExpC:=nil;
RegExpExt:=nil;
Matches:=nil;
MatchesCount:=0;
Error:=true;
ErrorMsg:=nil;
ErrorPos:=0;
RunTimeOptions := 0;
if length(RegExp) < 255 then
begin
RegExp[length(RegExp)+1]:=#0;
pRegExp:=@RegExp[1];
end
else
begin
GetMem(pRegExp,length(RegExp)+1);
pRegExp:=strpcopy(pRegExp,RegExp);
end;
RegExpC := pcre_compile( pRegExp,
AOptions and PCRE_COMPILE_ALLOWED_OPTIONS,
ErrorMsg, ErrorPos, ALocale);
if length(RegExp) = 255 then
StrDispose(pRegExp);
if RegExpC = nil then
exit;
ErrorMsg:=nil;
RegExpExt := pcre_study( RegExpC, 0, ErrorMsg );
if (RegExpExt = nil) and (ErrorMsg <> nil) then
begin
pcre_free(RegExpC);
exit;
end;
GetMem(Matches,SizeOf(TMatchArray));
Error:=false;
end;
destructor TpcRegExp.Done;
begin
if RegExpC <> nil then
pcre_free(RegExpC);
if RegExpExt <> nil then
pcre_free(RegExpExt);
if Matches <> nil then
FreeMem(Matches,SizeOf(TMatchArray));
end;
function TpcRegExp.SearchNext( AStr: Pchar; ALen : longint ) : boolean;
var Options: Integer;
begin // must handle PCRE_ERROR_PARTIAL here
Options := (RunTimeOptions or startup.MiscMultiData.cfgRegEx.DefaultOptions) and
PCRE_EXEC_ALLOWED_OPTIONS;
if MatchesCount > 0 then
MatchesCount:=pcre_exec( RegExpC, RegExpExt, AStr, ALen, PMatchArray(Matches)^[1],
Options, Matches, MAX_MATCHES ) else
MatchesCount:=pcre_exec( RegExpC, RegExpExt, AStr, ALen, 0,
Options, Matches, MAX_MATCHES );
{ if MatchesCount = 0 then
MatchesCount := MatchesCount div 3;}
PartialMatch := MatchesCount = PCRE_ERROR_PARTIAL;
SearchNext := MatchesCount > 0;
end;
function TpcRegExp.Search( AStr: Pchar; ALen : longint):boolean;
begin
MatchesCount:=0;
Search:=SearchNext(AStr,ALen);
SourceLen:=ALen;
end;
function TpcRegExp.SearchOfs( AStr: Pchar; ALen, AOfs: longint ) : boolean;
var Options: Integer;
begin
MatchesCount:=0;
Options := (RunTimeOptions or startup.MiscMultiData.cfgRegEx.DefaultOptions) and
PCRE_EXEC_ALLOWED_OPTIONS;
MatchesCount:=pcre_exec( RegExpC, RegExpExt, AStr, ALen, AOfs,
Options, Matches, MAX_MATCHES );
PartialMatch := MatchesCount = PCRE_ERROR_PARTIAL;
SearchOfs := MatchesCount > 0;
SourceLen := ALen-AOfs;
end;
function TpcRegExp.MatchSub(ANom:integer; var Pos,Len:longint):boolean;
begin
if (MatchesCount > 0) and (ANom <= (MatchesCount-1)) then
begin
ANom:=ANom*2;
Pos:=PMatchArray(Matches)^[ANom];
Len:=PMatchArray(Matches)^[ANom+1]-Pos;
MatchSub:=true;
end
else
MatchSub:=false;
end;
function TpcRegExp.MatchFull(var Pos,Len:longint):boolean;
begin
MatchFull:=MatchSub(0,Pos,Len);
end;
function TpcRegExp.GetSubStr(ANom: integer; AStr: Pchar):string;
var
s: ansistring;
pos,len: longint;
begin
s:='';
if MatchSub(ANom, pos, len) then
begin
setlength(s, len);
Move(AStr[pos], s[1], len);
end;
GetSubStr:=s;
end;
function TpcRegExp.GetPreSubStr(AStr: Pchar):string;
var
s: ansistring;
l: longint;
begin
s:='';
if (MatchesCount > 0) then
begin
l:=PMatchArray(Matches)^[0]-1;
if l > 0 then
begin
setlength(s,l);
Move(AStr[1],s[1],l);
end;
end;
GetPreSubStr:=s;
end;
function TpcRegExp.GetPostSubStr(AStr: Pchar):string;
var
s: ansistring;
l: longint;
ANom: integer;
begin
s:='';
if (MatchesCount > 0) then
begin
ANom:=(MatchesCount-1){*2} shl 1;
l:=SourceLen-PMatchArray(Matches)^[ANom+1]+1;
if l > 0 then
begin
setlength(s,l);
Move(AStr[PMatchArray(Matches)^[ANom+1]],s[1],l);
end;
end;
GetPostSubStr:=s;
end;
function TpcRegExp.GetFullStr(AStr: Pchar):string;
var
s: ansistring;
l: longint;
begin
GetFullStr:=GetSubStr(0,AStr);
end;
function TpcRegExp.GetReplStr(AStr: Pchar; const ARepl: string):string;
var
s: ansistring;
l,i,lasti: longint;
begin
l:=length(ARepl);
i:=1;
lasti:=1;
s:='';
while i <= l do
begin
case ARepl[i] of
'\' :
begin
if i < l then
begin
s:=s+copy(ARepl,lasti,i-lasti){+ARepl[i+1]};
{AH 17-10-05 support for POSIX \1-\9 backreferences}
case ARepl[i+1] of
'0' : s:=s+GetFullStr(AStr);
'1'..'9' : s:=s+GetSubStr(ord(ARepl[i+1])-ord('0'),AStr);
else s:=s+ARepl[i+1]; // copy the escaped character
end;
end;
inc(i);
lasti:=i+1;
end;
'$' :
begin
if i < l then
begin
s:=s+copy(ARepl,lasti,i-lasti);
case ARepl[i+1] of
'&' : s:=s+GetFullStr(AStr);
'1'..'9' : s:=s+GetSubStr(ord(ARepl[i+1])-ord('0'),AStr);
'`' : s:=s+GetPreSubStr(AStr);
#39 : s:=s+GetPostSubStr(AStr);
end;
end;
inc(i);
lasti:=i+1;
end;
end;
inc(i);
end;
if lasti <= {AH 25-10-2004 added =, else l==1 won't work} l then
s:=s+copy(ARepl,lasti,l-lasti+1);
GetReplStr:=s;
end;
function TpcRegExp.ErrorStr:string;
begin
ErrorStr:=StrPas(ErrorMsg);
end;
{TRegExpCollection}
constructor TRegExpCollection.Init(AMaxRegExp: integer);
begin
Inherited Init(1,1);
MaxRegExp:=AMaxRegExp;
CompareModeInsert:=true;
end;
procedure TRegExpCollection.FreeItem(P: Pointer);
begin
if P <> nil then
begin
Dispose(PpcRegExp(P),Done);
end;
end;
function TRegExpCollection.Compare(P1, P2: Pointer): Integer;
//var
// l,l1,l2,i : byte;
//// wPos: pchar;
begin
if CompareModeInsert then
begin
// l1:=length(PpcRegExp(P1)^.RegExp);
// l2:=length(PpcRegExp(P2)^.RegExp);
// if l1 > l2 then l:=l2 else
// l:=l1;
// for i:=1 to l do
// if PpcRegExp(P1).RegExp[i] <> PpcRegExp(P2).RegExp[i] then break;
// if i <=l then
// Compare:=ord(PpcRegExp(P1).RegExp[i])-ord(PpcRegExp(P2).RegExp[i]) else
// Compare:=l1-l2;
Compare := stringsx.PasStrCmp(PpcRegExp(P1).RegExp, PpcRegExp(P2).RegExp, False);
end
else
begin
// l1:=length(PpcRegExp(P1)^.RegExp);
// l2:=length(SearchRegExp);
// if l1 > l2 then l:=l2 else
// l:=l1;
// for i:=1 to l do
// if PpcRegExp(P1).RegExp[i] <> SearchRegExp[i] then
// begin
// Compare:=ord(PpcRegExp(P1).RegExp[i])-ord(SearchRegExp[i]);
// break;
// end;
// if i > l then Compare:=l1-l2;
Compare := stringsx.PasStrCmp(PpcRegExp(P1).RegExp, SearchRegExp, False);
end;
end;
function TRegExpCollection.Find(ARegExp:shortstring;var P: PpcRegExp):boolean;
var I : integer;
begin
CompareModeInsert:=false;
SearchRegExp:=ARegExp;
if Search(nil,I) then
begin
P:=PpcRegExp(At(I));
Find:=true;
end
else
begin
P:=nil;
Find:=false;
end;
CompareModeInsert:=true;
end;
function TRegExpCollection.CheckNew(ARegExp:shortstring):PpcRegExp;
var
P : PpcRegExp;
begin
if not Find(ARegExp,P) then
begin
if Count = MaxRegExp then
AtFree(0);
P:=New(ppcRegExp,Init(ARegExp,PCRE_CASELESS,nil));
Insert(P);
end;
CheckNew:=P;
end;
function pcGrepMatch(WildCard, aStr: string; AOptions:integer; ALocale : Pointer): Boolean;
var
PpcRE:PpcRegExp;
begin
PpcRE:=New(ppcRegExp,Init(WildCard,AOptions,Alocale));
pcGrepMatch:=PpcRE^.Search(pchar(AStr),Length(AStr));
Dispose(PpcRE,Done);
end;
function pcGrepSub(WildCard, aStr, aRepl: string; AOptions:integer; ALocale : Pointer): string;
var
PpcRE:PpcRegExp;
begin
PpcRE:=New(ppcRegExp,Init(WildCard,AOptions,Alocale));
if PpcRE^.Search(pchar(AStr),Length(AStr)) then
pcGrepSub:=PpcRE^.GetReplStr(pchar(AStr),ARepl)
else
pcGrepSub:='';
Dispose(PpcRE,Done);
end;
function pcFastGrepMatch(WildCard, aStr: string): Boolean;
var
PpcRE:PpcRegExp;
begin
PpcRE:=PRegExpCache^.CheckNew(WildCard);
pcFastGrepMatch:=PpcRE^.Search(pchar(AStr),Length(AStr));
end;
function pcFastGrepSub(WildCard, aStr, aRepl: string): string;
var
PpcRE:PpcRegExp;
begin
PpcRE:=PRegExpCache^.CheckNew(WildCard);
if PpcRE^.Search(pchar(AStr),Length(AStr)) then
pcFastGrepSub:=PpcRE^.GetReplStr(pchar(AStr),ARepl)
else
pcFastGrepSub:='';
end;
{$IFDEF PCRE_5_0}
function pcGetVersion : pchar; assembler; {$FRAME-}{$USES none}
asm
call pcre_version
end;
{$ENDIF PCRE_5_0}
function pcError;
var P: ppcRegExp absolute pRegExp;
begin
Result := (P = nil) or P^.Error;
If Result and (P <> nil) then
begin
{ if P^.ErrorPos = 0 then
MessageBox(GetString(erRegExpCompile)+'"'+P^.ErrorStr+'"', nil,mfConfirmation+mfOkButton)
else}
MessageBox(GetString(erRegExpCompile)+'"'+P^.ErrorStr+'"'+GetString(erRegExpCompPos),
@P^.ErrorPos,mfConfirmation+mfOkButton);
Dispose(P, Done);
P:=nil;
end;
end;
function pcInit;
var Options : Integer;
begin
If CaseSens then Options := 0 else Options := PCRE_CASELESS;
Result := New( PpcRegExp, Init( Pattern,
{DefaultOptions}
startup.MiscMultiData.cfgRegEx.DefaultOptions or Options,
DefaultLocaleTable) );
end;
Initialization
PRegExpCache:=New(PRegExpCollection,Init(64));
Finalization
Dispose(PRegExpCache,Done);
End.
pcre-8.38/pcre32_chartables.c 0000644 0002221 0002221 00000004207 12272731756 012763 0000000 0000000 /*************************************************
* 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
Copyright (c) 1997-2012 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.
-----------------------------------------------------------------------------
*/
/* Generate code with 32 bit character support. */
#define COMPILE_PCRE32
#include "pcre_chartables.c"
/* End of pcre32_chartables.c */
pcre-8.38/pcre_get.c 0000644 0002221 0002221 00000054211 12272731732 011257 0000000 0000000 /*************************************************
* 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
Copyright (c) 1997-2012 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 some convenience functions for extracting substrings
from the subject string after a regex match has succeeded. The original idea
for these functions came from Scott Wimer. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre_internal.h"
/*************************************************
* Find number for named string *
*************************************************/
/* This function is used by the get_first_set() function below, 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
(PCRE_ERROR_NOSUBSTRING) if not found
*/
#if defined COMPILE_PCRE8
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_get_stringnumber(const pcre *code, const char *stringname)
#elif defined COMPILE_PCRE16
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre16_get_stringnumber(const pcre16 *code, PCRE_SPTR16 stringname)
#elif defined COMPILE_PCRE32
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre32_get_stringnumber(const pcre32 *code, PCRE_SPTR32 stringname)
#endif
{
int rc;
int entrysize;
int top, bot;
pcre_uchar *nametable;
#ifdef COMPILE_PCRE8
if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
return rc;
if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
return rc;
if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
return rc;
#endif
#ifdef COMPILE_PCRE16
if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
return rc;
if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
return rc;
if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
return rc;
#endif
#ifdef COMPILE_PCRE32
if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
return rc;
if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
return rc;
if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
return rc;
#endif
bot = 0;
while (top > bot)
{
int mid = (top + bot) / 2;
pcre_uchar *entry = nametable + entrysize*mid;
int c = STRCMP_UC_UC((pcre_uchar *)stringname,
(pcre_uchar *)(entry + IMM2_SIZE));
if (c == 0) return GET2(entry, 0);
if (c > 0) bot = mid + 1; else top = mid;
}
return PCRE_ERROR_NOSUBSTRING;
}
/*************************************************
* Find (multiple) entries for named string *
*************************************************/
/* This is used by the get_first_set() function below, 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
(PCRE_ERROR_NOSUBSTRING) if not found
*/
#if defined COMPILE_PCRE8
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_get_stringtable_entries(const pcre *code, const char *stringname,
char **firstptr, char **lastptr)
#elif defined COMPILE_PCRE16
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre16_get_stringtable_entries(const pcre16 *code, PCRE_SPTR16 stringname,
PCRE_UCHAR16 **firstptr, PCRE_UCHAR16 **lastptr)
#elif defined COMPILE_PCRE32
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre32_get_stringtable_entries(const pcre32 *code, PCRE_SPTR32 stringname,
PCRE_UCHAR32 **firstptr, PCRE_UCHAR32 **lastptr)
#endif
{
int rc;
int entrysize;
int top, bot;
pcre_uchar *nametable, *lastentry;
#ifdef COMPILE_PCRE8
if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
return rc;
if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
return rc;
if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
return rc;
#endif
#ifdef COMPILE_PCRE16
if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
return rc;
if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
return rc;
if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
return rc;
#endif
#ifdef COMPILE_PCRE32
if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
return rc;
if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
return rc;
if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
return rc;
#endif
lastentry = nametable + entrysize * (top - 1);
bot = 0;
while (top > bot)
{
int mid = (top + bot) / 2;
pcre_uchar *entry = nametable + entrysize*mid;
int c = STRCMP_UC_UC((pcre_uchar *)stringname,
(pcre_uchar *)(entry + IMM2_SIZE));
if (c == 0)
{
pcre_uchar *first = entry;
pcre_uchar *last = entry;
while (first > nametable)
{
if (STRCMP_UC_UC((pcre_uchar *)stringname,
(pcre_uchar *)(first - entrysize + IMM2_SIZE)) != 0) break;
first -= entrysize;
}
while (last < lastentry)
{
if (STRCMP_UC_UC((pcre_uchar *)stringname,
(pcre_uchar *)(last + entrysize + IMM2_SIZE)) != 0) break;
last += entrysize;
}
#if defined COMPILE_PCRE8
*firstptr = (char *)first;
*lastptr = (char *)last;
#elif defined COMPILE_PCRE16
*firstptr = (PCRE_UCHAR16 *)first;
*lastptr = (PCRE_UCHAR16 *)last;
#elif defined COMPILE_PCRE32
*firstptr = (PCRE_UCHAR32 *)first;
*lastptr = (PCRE_UCHAR32 *)last;
#endif
return entrysize;
}
if (c > 0) bot = mid + 1; else top = mid;
}
return PCRE_ERROR_NOSUBSTRING;
}
/*************************************************
* Find first set of multiple named strings *
*************************************************/
/* This function allows for duplicate names in the table of named substrings.
It returns the number of the first one that was set in a pattern match.
Arguments:
code the compiled regex
stringname the name of the capturing substring
ovector the vector of matched substrings
Returns: the number of the first that is set,
or the number of the last one if none are set,
or a negative number on error
*/
#if defined COMPILE_PCRE8
static int
get_first_set(const pcre *code, const char *stringname, int *ovector)
#elif defined COMPILE_PCRE16
static int
get_first_set(const pcre16 *code, PCRE_SPTR16 stringname, int *ovector)
#elif defined COMPILE_PCRE32
static int
get_first_set(const pcre32 *code, PCRE_SPTR32 stringname, int *ovector)
#endif
{
const REAL_PCRE *re = (const REAL_PCRE *)code;
int entrysize;
pcre_uchar *entry;
#if defined COMPILE_PCRE8
char *first, *last;
#elif defined COMPILE_PCRE16
PCRE_UCHAR16 *first, *last;
#elif defined COMPILE_PCRE32
PCRE_UCHAR32 *first, *last;
#endif
#if defined COMPILE_PCRE8
if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)
return pcre_get_stringnumber(code, stringname);
entrysize = pcre_get_stringtable_entries(code, stringname, &first, &last);
#elif defined COMPILE_PCRE16
if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)
return pcre16_get_stringnumber(code, stringname);
entrysize = pcre16_get_stringtable_entries(code, stringname, &first, &last);
#elif defined COMPILE_PCRE32
if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)
return pcre32_get_stringnumber(code, stringname);
entrysize = pcre32_get_stringtable_entries(code, stringname, &first, &last);
#endif
if (entrysize <= 0) return entrysize;
for (entry = (pcre_uchar *)first; entry <= (pcre_uchar *)last; entry += entrysize)
{
int n = GET2(entry, 0);
if (ovector[n*2] >= 0) return n;
}
return GET2(entry, 0);
}
/*************************************************
* Copy captured string to given buffer *
*************************************************/
/* This function copies a single captured substring into a given buffer.
Note that we use memcpy() rather than strncpy() in case there are binary zeros
in the string.
Arguments:
subject the subject string that was matched
ovector pointer to the offsets table
stringcount the number of substrings that were captured
(i.e. the yield of the pcre_exec call, unless
that was zero, in which case it should be 1/3
of the offset table size)
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:
PCRE_ERROR_NOMEMORY (-6) buffer too small
PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
*/
#if defined COMPILE_PCRE8
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_copy_substring(const char *subject, int *ovector, int stringcount,
int stringnumber, char *buffer, int size)
#elif defined COMPILE_PCRE16
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre16_copy_substring(PCRE_SPTR16 subject, int *ovector, int stringcount,
int stringnumber, PCRE_UCHAR16 *buffer, int size)
#elif defined COMPILE_PCRE32
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre32_copy_substring(PCRE_SPTR32 subject, int *ovector, int stringcount,
int stringnumber, PCRE_UCHAR32 *buffer, int size)
#endif
{
int yield;
if (stringnumber < 0 || stringnumber >= stringcount)
return PCRE_ERROR_NOSUBSTRING;
stringnumber *= 2;
yield = ovector[stringnumber+1] - ovector[stringnumber];
if (size < yield + 1) return PCRE_ERROR_NOMEMORY;
memcpy(buffer, subject + ovector[stringnumber], IN_UCHARS(yield));
buffer[yield] = 0;
return yield;
}
/*************************************************
* 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:
code the compiled regex
subject the subject string that was matched
ovector pointer to the offsets table
stringcount the number of substrings that were captured
(i.e. the yield of the pcre_exec call, unless
that was zero, in which case it should be 1/3
of the offset table size)
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:
PCRE_ERROR_NOMEMORY (-6) buffer too small
PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
*/
#if defined COMPILE_PCRE8
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_copy_named_substring(const pcre *code, const char *subject,
int *ovector, int stringcount, const char *stringname,
char *buffer, int size)
#elif defined COMPILE_PCRE16
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre16_copy_named_substring(const pcre16 *code, PCRE_SPTR16 subject,
int *ovector, int stringcount, PCRE_SPTR16 stringname,
PCRE_UCHAR16 *buffer, int size)
#elif defined COMPILE_PCRE32
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre32_copy_named_substring(const pcre32 *code, PCRE_SPTR32 subject,
int *ovector, int stringcount, PCRE_SPTR32 stringname,
PCRE_UCHAR32 *buffer, int size)
#endif
{
int n = get_first_set(code, stringname, ovector);
if (n <= 0) return n;
#if defined COMPILE_PCRE8
return pcre_copy_substring(subject, ovector, stringcount, n, buffer, size);
#elif defined COMPILE_PCRE16
return pcre16_copy_substring(subject, ovector, stringcount, n, buffer, size);
#elif defined COMPILE_PCRE32
return pcre32_copy_substring(subject, ovector, stringcount, n, buffer, size);
#endif
}
/*************************************************
* Copy all captured strings to new store *
*************************************************/
/* This function gets one chunk of store and builds a list of pointers and all
of the captured substrings in it. A NULL pointer is put on the end of the list.
Arguments:
subject the subject string that was matched
ovector pointer to the offsets table
stringcount the number of substrings that were captured
(i.e. the yield of the pcre_exec call, unless
that was zero, in which case it should be 1/3
of the offset table size)
listptr set to point to the list of pointers
Returns: if successful: 0
if not successful:
PCRE_ERROR_NOMEMORY (-6) failed to get store
*/
#if defined COMPILE_PCRE8
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_get_substring_list(const char *subject, int *ovector, int stringcount,
const char ***listptr)
#elif defined COMPILE_PCRE16
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre16_get_substring_list(PCRE_SPTR16 subject, int *ovector, int stringcount,
PCRE_SPTR16 **listptr)
#elif defined COMPILE_PCRE32
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre32_get_substring_list(PCRE_SPTR32 subject, int *ovector, int stringcount,
PCRE_SPTR32 **listptr)
#endif
{
int i;
int size = sizeof(pcre_uchar *);
int double_count = stringcount * 2;
pcre_uchar **stringlist;
pcre_uchar *p;
for (i = 0; i < double_count; i += 2)
size += sizeof(pcre_uchar *) + IN_UCHARS(ovector[i+1] - ovector[i] + 1);
stringlist = (pcre_uchar **)(PUBL(malloc))(size);
if (stringlist == NULL) return PCRE_ERROR_NOMEMORY;
#if defined COMPILE_PCRE8
*listptr = (const char **)stringlist;
#elif defined COMPILE_PCRE16
*listptr = (PCRE_SPTR16 *)stringlist;
#elif defined COMPILE_PCRE32
*listptr = (PCRE_SPTR32 *)stringlist;
#endif
p = (pcre_uchar *)(stringlist + stringcount + 1);
for (i = 0; i < double_count; i += 2)
{
int len = ovector[i+1] - ovector[i];
memcpy(p, subject + ovector[i], IN_UCHARS(len));
*stringlist++ = p;
p += len;
*p++ = 0;
}
*stringlist = NULL;
return 0;
}
/*************************************************
* Free store 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() or (PUBL(free))()
directly.
Argument: the result of a previous pcre_get_substring_list()
Returns: nothing
*/
#if defined COMPILE_PCRE8
PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
pcre_free_substring_list(const char **pointer)
#elif defined COMPILE_PCRE16
PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
pcre16_free_substring_list(PCRE_SPTR16 *pointer)
#elif defined COMPILE_PCRE32
PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
pcre32_free_substring_list(PCRE_SPTR32 *pointer)
#endif
{
(PUBL(free))((void *)pointer);
}
/*************************************************
* Copy captured string to new store *
*************************************************/
/* This function copies a single captured substring into a piece of new
store
Arguments:
subject the subject string that was matched
ovector pointer to the offsets table
stringcount the number of substrings that were captured
(i.e. the yield of the pcre_exec call, unless
that was zero, in which case it should be 1/3
of the offset table size)
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:
PCRE_ERROR_NOMEMORY (-6) failed to get store
PCRE_ERROR_NOSUBSTRING (-7) substring not present
*/
#if defined COMPILE_PCRE8
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_get_substring(const char *subject, int *ovector, int stringcount,
int stringnumber, const char **stringptr)
#elif defined COMPILE_PCRE16
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre16_get_substring(PCRE_SPTR16 subject, int *ovector, int stringcount,
int stringnumber, PCRE_SPTR16 *stringptr)
#elif defined COMPILE_PCRE32
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre32_get_substring(PCRE_SPTR32 subject, int *ovector, int stringcount,
int stringnumber, PCRE_SPTR32 *stringptr)
#endif
{
int yield;
pcre_uchar *substring;
if (stringnumber < 0 || stringnumber >= stringcount)
return PCRE_ERROR_NOSUBSTRING;
stringnumber *= 2;
yield = ovector[stringnumber+1] - ovector[stringnumber];
substring = (pcre_uchar *)(PUBL(malloc))(IN_UCHARS(yield + 1));
if (substring == NULL) return PCRE_ERROR_NOMEMORY;
memcpy(substring, subject + ovector[stringnumber], IN_UCHARS(yield));
substring[yield] = 0;
#if defined COMPILE_PCRE8
*stringptr = (const char *)substring;
#elif defined COMPILE_PCRE16
*stringptr = (PCRE_SPTR16)substring;
#elif defined COMPILE_PCRE32
*stringptr = (PCRE_SPTR32)substring;
#endif
return yield;
}
/*************************************************
* Copy named captured string to new store *
*************************************************/
/* This function copies a single captured substring, identified by name, into
new store. If the regex permits duplicate names, the first substring that is
set is chosen.
Arguments:
code the compiled regex
subject the subject string that was matched
ovector pointer to the offsets table
stringcount the number of substrings that were captured
(i.e. the yield of the pcre_exec call, unless
that was zero, in which case it should be 1/3
of the offset table size)
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:
PCRE_ERROR_NOMEMORY (-6) couldn't get memory
PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
*/
#if defined COMPILE_PCRE8
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_get_named_substring(const pcre *code, const char *subject,
int *ovector, int stringcount, const char *stringname,
const char **stringptr)
#elif defined COMPILE_PCRE16
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre16_get_named_substring(const pcre16 *code, PCRE_SPTR16 subject,
int *ovector, int stringcount, PCRE_SPTR16 stringname,
PCRE_SPTR16 *stringptr)
#elif defined COMPILE_PCRE32
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre32_get_named_substring(const pcre32 *code, PCRE_SPTR32 subject,
int *ovector, int stringcount, PCRE_SPTR32 stringname,
PCRE_SPTR32 *stringptr)
#endif
{
int n = get_first_set(code, stringname, ovector);
if (n <= 0) return n;
#if defined COMPILE_PCRE8
return pcre_get_substring(subject, ovector, stringcount, n, stringptr);
#elif defined COMPILE_PCRE16
return pcre16_get_substring(subject, ovector, stringcount, n, stringptr);
#elif defined COMPILE_PCRE32
return pcre32_get_substring(subject, ovector, stringcount, n, stringptr);
#endif
}
/*************************************************
* Free store 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() or (PUBL(free))()
directly.
Argument: the result of a previous pcre_get_substring()
Returns: nothing
*/
#if defined COMPILE_PCRE8
PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
pcre_free_substring(const char *pointer)
#elif defined COMPILE_PCRE16
PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
pcre16_free_substring(PCRE_SPTR16 pointer)
#elif defined COMPILE_PCRE32
PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
pcre32_free_substring(PCRE_SPTR32 pointer)
#endif
{
(PUBL(free))((void *)pointer);
}
/* End of pcre_get.c */
pcre-8.38/132html 0000755 0002221 0002221 00000015534 12613723103 010440 0000000 0000000 #! /usr/bin/perl -w
# Script to turn PCRE man pages into HTML
# Subroutine to handle font changes and other escapes
sub do_line {
my($s) = $_[0];
$s =~ s/</g; # Deal with < and >
$s =~ s/>/>/g;
$s =~ s"\\fI(.*?)\\f[RP]"$1"g;
$s =~ s"\\fB(.*?)\\f[RP]"$1"g;
$s =~ s"\\e"\\"g;
$s =~ s/(?<=Copyright )\(c\)/©/g;
$s;
}
# Subroutine to ensure not in a paragraph
sub end_para {
if ($inpara)
{
print TEMP "\n" if ($inpre);
print TEMP "
\n";
}
$inpara = $inpre = 0;
$wrotetext = 0;
}
# Subroutine to start a new paragraph
sub new_para {
&end_para();
print TEMP "\n";
$inpara = 1;
}
# Main program
$innf = 0;
$inpara = 0;
$inpre = 0;
$wrotetext = 0;
$toc = 0;
$ref = 1;
while ($#ARGV >= 0 && $ARGV[0] =~ /^-/)
{
$toc = 1 if $ARGV[0] eq "-toc";
shift;
}
# Initial output to STDOUT
print <
$ARGV[0] specification
$ARGV[0] man page
Return to the PCRE index page.
This page is part of the PCRE HTML documentation. It was generated automatically
from the original man page. If there is any nonsense in it, please consult the
man page, in case the conversion went wrong.
End
print "
\n" if ($toc);
open(TEMP, ">/tmp/$$") || die "Can't open /tmp/$$ for output\n";
while ()
{
# Handle lines beginning with a dot
if (/^\./)
{
# Some of the PCRE man pages used to contain instances of .br. However,
# they should have all been removed because they cause trouble in some
# (other) automated systems that translate man pages to HTML. Complain if
# we find .br or .in (another macro that is deprecated).
if (/^\.br/ || /^\.in/)
{
print STDERR "\n*** Deprecated macro encountered - rewrite needed\n";
print STDERR "*** $_\n";
die "*** Processing abandoned\n";
}
# Instead of .br, relevent "literal" sections are enclosed in .nf/.fi.
elsif (/^\.nf/)
{
$innf = 1;
}
elsif (/^\.fi/)
{
$innf = 0;
}
# Handling .sp is subtle. If it is inside a literal section, do nothing if
# the next line is a non literal text line; similarly, if not inside a
# literal section, do nothing if a literal follows, unless we are inside
# a .nf/.ne section. The point being that the and
that delimit
# literal sections will do the spacing. Always skip if no previous output.
elsif (/^\.sp/)
{
if ($wrotetext)
{
$_ = ;
if ($inpre)
{
print TEMP "\n" if (/^[\s.]/);
}
else
{
print TEMP "
\n
\n" if ($innf || !/^[\s.]/);
}
redo; # Now process the lookahead line we just read
}
}
elsif (/^\.TP/ || /^\.PP/ || /^\.P/)
{
&new_para();
}
elsif (/^\.SH\s*("?)(.*)\1/)
{
# Ignore the NAME section
if ($2 =~ /^NAME\b/)
{
;
next;
}
&end_para();
my($title) = &do_line($2);
if ($toc)
{
printf("- $title\n",
$ref, $ref);
printf TEMP ("
$title
\n",
$ref);
$ref++;
}
else
{
print TEMP "
\n$title\n
\n";
}
}
elsif (/^\.SS\s*("?)(.*)\1/)
{
&end_para();
my($title) = &do_line($2);
print TEMP "
\n$title\n
\n";
}
elsif (/^\.B\s*(.*)/)
{
&new_para() if (!$inpara);
$_ = &do_line($1);
s/"(.*?)"/$1/g;
print TEMP "$_\n";
$wrotetext = 1;
}
elsif (/^\.I\s*(.*)/)
{
&new_para() if (!$inpara);
$_ = &do_line($1);
s/"(.*?)"/$1/g;
print TEMP "$_\n";
$wrotetext = 1;
}
# A comment that starts "HREF" takes the next line as a name that
# is turned into a hyperlink, using the text given, which might be
# in a special font. If it ends in () or (digits) or punctuation, they
# aren't part of the link.
elsif (/^\.\\"\s*HREF/)
{
$_=;
chomp;
$_ = &do_line($_);
$_ =~ s/\s+$//;
$_ =~ /^(?:<.>)?([^<(]+)(?:\(\))?(?:<\/.>)?(?:\(\d+\))?[.,;:]?$/;
print TEMP "$_\n";
}
# A comment that starts "HTML" inserts literal HTML
elsif (/^\.\\"\s*HTML\s*(.*)/)
{
print TEMP $1;
}
# A comment that starts < inserts that HTML at the end of the
# *next* input line - so as not to get a newline between them.
elsif (/^\.\\"\s*(<.*>)/)
{
my($markup) = $1;
$_=;
chomp;
$_ = &do_line($_);
$_ =~ s/\s+$//;
print TEMP "$_$markup\n";
}
# A comment that starts JOIN joins the next two lines together, with one
# space between them. Then that line is processed. This is used in some
# displays where two lines are needed for the "man" version. JOINSH works
# the same, except that it assumes this is a shell command, so removes
# continuation backslashes.
elsif (/^\.\\"\s*JOIN(SH)?/)
{
my($one,$two);
$one = ;
$two = ;
$one =~ s/\s*\\e\s*$// if (defined($1));
chomp($one);
$two =~ s/^\s+//;
$_ = "$one $two";
redo; # Process the joined lines
}
# .EX/.EE are used in the pcredemo page to bracket the entire program,
# which is unmodified except for turning backslash into "\e".
elsif (/^\.EX\s*$/)
{
print TEMP "\n";
while ()
{
last if /^\.EE\s*$/;
s/\\e/\\/g;
s/&/&/g;
s/</g;
s/>/>/g;
print TEMP;
}
}
# Ignore anything not recognized
next;
}
# Line does not begin with a dot. Replace blank lines with new paragraphs
if (/^\s*$/)
{
&end_para() if ($wrotetext);
next;
}
# Convert fonts changes and output an ordinary line. Ensure that indented
# lines are marked as literal.
$_ = &do_line($_);
&new_para() if (!$inpara);
if (/^\s/)
{
if (!$inpre)
{
print TEMP "\n";
$inpre = 1;
}
}
elsif ($inpre)
{
print TEMP "
\n";
$inpre = 0;
}
# Add
to the end of a non-literal line if we are within .nf/.fi
$_ .= "
\n" if (!$inpre && $innf);
print TEMP;
$wrotetext = 1;
}
# The TOC, if present, will have been written - terminate it
print "
\n" if ($toc);
# Copy the remainder to the standard output
close(TEMP);
open(TEMP, "/tmp/$$") || die "Can't open /tmp/$$ for input\n";
print while ();
print <
Return to the PCRE index page.
End
close(TEMP);
unlink("/tmp/$$");
# End
pcre-8.38/pcre16_compile.c 0000644 0002221 0002221 00000004201 12272731732 012271 0000000 0000000 /*************************************************
* 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
Copyright (c) 1997-2012 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.
-----------------------------------------------------------------------------
*/
/* Generate code with 16 bit character support. */
#define COMPILE_PCRE16
#include "pcre_compile.c"
/* End of pcre16_compile.c */
pcre-8.38/pcre32_dfa_exec.c 0000644 0002221 0002221 00000004203 12272731733 012400 0000000 0000000 /*************************************************
* 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
Copyright (c) 1997-2012 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.
-----------------------------------------------------------------------------
*/
/* Generate code with 32 bit character support. */
#define COMPILE_PCRE32
#include "pcre_dfa_exec.c"
/* End of pcre32_dfa_exec.c */
pcre-8.38/pcre32_utf32_utils.c 0000644 0002221 0002221 00000011734 12272731751 013034 0000000 0000000 /*************************************************
* 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
Copyright (c) 1997-2012 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 a function for converting any UTF-32 character
strings to host byte order. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* Generate code with 32 bit character support. */
#define COMPILE_PCRE32
#include "pcre_internal.h"
#ifdef SUPPORT_UTF
static pcre_uint32
swap_uint32(pcre_uint32 value)
{
return ((value & 0x000000ff) << 24) |
((value & 0x0000ff00) << 8) |
((value & 0x00ff0000) >> 8) |
(value >> 24);
}
#endif
/*************************************************
* Convert any UTF-32 string to host byte order *
*************************************************/
/* This function takes an UTF-32 string and converts
it to host byte order. The length can be explicitly set,
or automatically detected for zero terminated strings.
BOMs can be kept or discarded during the conversion.
Conversion can be done in place (output == input).
Arguments:
output the output buffer, its size must be greater
or equal than the input string
input any UTF-32 string
length the number of 32-bit units in the input string
can be less than zero for zero terminated strings
host_byte_order
A non-zero value means the input is in host byte
order, which can be dynamically changed by BOMs later.
Initially it contains the starting byte order and returns
with the last byte order so it can be used for stream
processing. It can be NULL, which set the host byte
order mode by default.
keep_boms for a non-zero value, the BOM (0xfeff) characters
are copied as well
Returns: the number of 32-bit units placed into the output buffer,
including the zero-terminator
*/
int
pcre32_utf32_to_host_byte_order(PCRE_UCHAR32 *output, PCRE_SPTR32 input,
int length, int *host_byte_order, int keep_boms)
{
#ifdef SUPPORT_UTF
/* This function converts any UTF-32 string to host byte order and optionally
removes any Byte Order Marks (BOMS). Returns with the remainig length. */
int host_bo = host_byte_order != NULL ? *host_byte_order : 1;
pcre_uchar *optr = (pcre_uchar *)output;
const pcre_uchar *iptr = (const pcre_uchar *)input;
const pcre_uchar *end;
/* The c variable must be unsigned. */
register pcre_uchar c;
if (length < 0)
end = iptr + STRLEN_UC(iptr) + 1;
else
end = iptr + length;
while (iptr < end)
{
c = *iptr++;
if (c == 0x0000feffu || c == 0xfffe0000u)
{
/* Detecting the byte order of the machine is unnecessary, it is
enough to know that the UTF-32 string has the same byte order or not. */
host_bo = c == 0x0000feffu;
if (keep_boms != 0)
*optr++ = 0x0000feffu;
}
else
*optr++ = host_bo ? c : swap_uint32(c);
}
if (host_byte_order != NULL)
*host_byte_order = host_bo;
#else /* SUPPORT_UTF */
(void)(output); /* Keep picky compilers happy */
(void)(input);
(void)(keep_boms);
(void)(host_byte_order);
#endif /* SUPPORT_UTF */
return length;
}
/* End of pcre32_utf32_utils.c */
pcre-8.38/CMakeLists.txt 0000644 0002221 0002221 00000100521 12272731751 012060 0000000 0000000 # CMakeLists.txt
#
#
# This file allows building PCRE with the CMake configuration and build
# tool. Download CMake in source or binary form from http://www.cmake.org/
#
# Original listfile by Christian Ehrlicher
# Refined and expanded by Daniel Richard G.
# 2007-09-14 mod by Sheri so 7.4 supported configuration options can be entered
# 2007-09-19 Adjusted by PH to retain previous default settings
# 2007-12-26 (a) On UNIX, use names libpcre instead of just pcre
# (b) Ensure pcretest and pcregrep link with the local library,
# not a previously-installed one.
# (c) Add PCRE_SUPPORT_LIBREADLINE, PCRE_SUPPORT_LIBZ, and
# PCRE_SUPPORT_LIBBZ2.
# 2008-01-20 Brought up to date to include several new features by Christian
# Ehrlicher.
# 2008-01-22 Sheri added options for backward compatibility of library names
# when building with minGW:
# if "ON", NON_STANDARD_LIB_PREFIX causes shared libraries to
# be built without "lib" as prefix. (The libraries will be named
# pcre.dll, pcreposix.dll and pcrecpp.dll).
# if "ON", NON_STANDARD_LIB_SUFFIX causes shared libraries to
# be built with suffix of "-0.dll". (The libraries will be named
# libpcre-0.dll, libpcreposix-0.dll and libpcrecpp-0.dll - same names
# built by default with Configure and Make.
# 2008-01-23 PH removed the automatic build of pcredemo.
# 2008-04-22 PH modified READLINE support so it finds NCURSES when needed.
# 2008-07-03 PH updated for revised UCP property support (change of files)
# 2009-03-23 PH applied Steven Van Ingelgem's patch to change the name
# CMAKE_BINARY_DIR to PROJECT_BINARY_DIR so that it works when PCRE
# is included within another project.
# 2009-03-23 PH applied a modified version of Steven Van Ingelgem's patches to
# add options to stop the building of pcregrep and the tests, and
# to disable the final configuration report.
# 2009-04-11 PH applied Christian Ehrlicher's patch to show compiler flags that
# are set by specifying a release type.
# 2010-01-02 PH added test for stdint.h
# 2010-03-02 PH added test for inttypes.h
# 2011-08-01 PH added PCREGREP_BUFSIZE
# 2011-08-22 PH added PCRE_SUPPORT_JIT
# 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov
# 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT
# 2011-10-04 Sheri added support for including coff data in windows shared libraries
# compiled with MINGW if pcre.rc and/or pcreposix.rc are placed in
# the source dir by the user prior to building
# 2011-10-04 Sheri changed various add_test's to use exes' location built instead
# of DEBUG location only (likely only matters in MSVC)
# 2011-10-04 Sheri added scripts to provide needed variables to RunTest and
# RunGrepTest (used for UNIX and Msys)
# 2011-10-04 Sheri added scripts to provide needed variables and to execute
# RunTest.bat in Win32 (for effortless testing with "make test")
# 2011-10-04 Sheri Increased minimum required cmake version
# 2012-01-06 PH removed pcre_info.c and added pcre_string_utils.c
# 2012-01-10 Zoltan Herczeg added libpcre16 support
# 2012-01-13 Stephen Kelly added out of source build support
# 2012-01-17 PH applied Stephen Kelly's patch to parse the version data out
# of the configure.ac file
# 2012-02-26 PH added support for libedit
# 2012-09-06 PH added support for PCRE_EBCDIC_NL25
# 2012-09-08 ChPe added PCRE32 support
# 2012-10-23 PH added support for VALGRIND and GCOV
# 2012-12-08 PH added patch from Daniel Richard G to quash some MSVC warnings
# 2013-07-01 PH realized that the "support" for GCOV was a total nonsense and
# so it has been removed.
# 2013-10-08 PH got rid of the "source" command, which is a bash-ism (use ".")
# 2013-11-05 PH added support for PARENS_NEST_LIMIT
PROJECT(PCRE C CXX)
# Increased minimum to 2.8.0 to support newer add_test features
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake
# external packages
FIND_PACKAGE( BZip2 )
FIND_PACKAGE( ZLIB )
FIND_PACKAGE( Readline )
FIND_PACKAGE( Editline )
# Configuration checks
INCLUDE(CheckIncludeFile)
INCLUDE(CheckIncludeFileCXX)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckTypeSize)
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
CHECK_INCLUDE_FILE_CXX(type_traits.h HAVE_TYPE_TRAITS_H)
CHECK_INCLUDE_FILE_CXX(bits/type_traits.h HAVE_BITS_TYPE_TRAITS_H)
CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY)
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
CHECK_FUNCTION_EXISTS(strtoq HAVE_STRTOQ)
CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
CHECK_TYPE_SIZE("long long" LONG_LONG)
CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG)
# User-configurable options
#
# (Note: CMakeSetup displays these in alphabetical order, regardless of
# the order we use here)
SET(BUILD_SHARED_LIBS OFF CACHE BOOL
"Build shared libraries instead of static ones.")
OPTION(PCRE_BUILD_PCRE8 "Build 8 bit PCRE library" ON)
OPTION(PCRE_BUILD_PCRE16 "Build 16 bit PCRE library" OFF)
OPTION(PCRE_BUILD_PCRE32 "Build 32 bit PCRE library" OFF)
OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON)
SET(PCRE_EBCDIC OFF CACHE BOOL
"Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems.)")
SET(PCRE_EBCDIC_NL25 OFF CACHE BOOL
"Use 0x25 as EBCDIC NL character instead of 0x15; implies EBCDIC.")
SET(PCRE_LINK_SIZE "2" CACHE STRING
"Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.")
SET(PCRE_PARENS_NEST_LIMIT "250" CACHE STRING
"Default nested parentheses limit. See PARENS_NEST_LIMIT in config.h.in for details.")
SET(PCRE_MATCH_LIMIT "10000000" CACHE STRING
"Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.")
SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING
"Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.")
SET(PCREGREP_BUFSIZE "20480" CACHE STRING
"Buffer size parameter for pcregrep. See PCREGREP_BUFSIZE in config.h.in for details.")
SET(PCRE_NEWLINE "LF" CACHE STRING
"What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF).")
SET(PCRE_NO_RECURSE OFF CACHE BOOL
"If ON, then don't use stack recursion when matching. See NO_RECURSE in config.h.in for details.")
SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CACHE STRING
"Threshold for malloc() usage. See POSIX_MALLOC_THRESHOLD in config.h.in for details.")
SET(PCRE_SUPPORT_JIT OFF CACHE BOOL
"Enable support for Just-in-time compiling.")
SET(PCRE_SUPPORT_PCREGREP_JIT ON CACHE BOOL
"Enable use of Just-in-time compiling in pcregrep.")
SET(PCRE_SUPPORT_UTF OFF CACHE BOOL
"Enable support for Unicode Transformation Format (UTF-8/UTF-16/UTF-32) encoding.")
SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL
"Enable support for Unicode properties (if set, UTF support will be enabled as well).")
SET(PCRE_SUPPORT_BSR_ANYCRLF OFF CACHE BOOL
"ON=Backslash-R matches only LF CR and CRLF, OFF=Backslash-R matches all Unicode Linebreaks")
SET(PCRE_SUPPORT_VALGRIND OFF CACHE BOOL
"Enable Valgrind support.")
OPTION(PCRE_SHOW_REPORT "Show the final configuration report" ON)
OPTION(PCRE_BUILD_PCREGREP "Build pcregrep" ON)
OPTION(PCRE_BUILD_TESTS "Build the tests" ON)
IF (MINGW)
OPTION(NON_STANDARD_LIB_PREFIX
"ON=Shared libraries built in mingw will be named pcre.dll, etc., instead of libpcre.dll, etc."
OFF)
OPTION(NON_STANDARD_LIB_SUFFIX
"ON=Shared libraries built in mingw will be named libpcre-0.dll, etc., instead of libpcre.dll, etc."
OFF)
ENDIF(MINGW)
IF(MSVC)
OPTION(INSTALL_MSVC_PDB
"ON=Install .pdb files built by MSVC, if generated"
OFF)
ENDIF(MSVC)
# bzip2 lib
IF(BZIP2_FOUND)
OPTION (PCRE_SUPPORT_LIBBZ2 "Enable support for linking pcregrep with libbz2." ON)
ENDIF(BZIP2_FOUND)
IF(PCRE_SUPPORT_LIBBZ2)
INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
ENDIF(PCRE_SUPPORT_LIBBZ2)
# zlib
IF(ZLIB_FOUND)
OPTION (PCRE_SUPPORT_LIBZ "Enable support for linking pcregrep with libz." ON)
ENDIF(ZLIB_FOUND)
IF(PCRE_SUPPORT_LIBZ)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
ENDIF(PCRE_SUPPORT_LIBZ)
# editline lib
IF(EDITLINE_FOUND)
OPTION (PCRE_SUPPORT_LIBEDIT "Enable support for linking pcretest with libedit." OFF)
ENDIF(EDITLINE_FOUND)
IF(PCRE_SUPPORT_LIBEDIT)
INCLUDE_DIRECTORIES(${EDITLINE_INCLUDE_DIR})
ENDIF(PCRE_SUPPORT_LIBEDIT)
# readline lib
IF(READLINE_FOUND)
OPTION (PCRE_SUPPORT_LIBREADLINE "Enable support for linking pcretest with libreadline." ON)
ENDIF(READLINE_FOUND)
IF(PCRE_SUPPORT_LIBREADLINE)
INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR})
ENDIF(PCRE_SUPPORT_LIBREADLINE)
# Prepare build configuration
SET(pcre_have_type_traits 0)
SET(pcre_have_bits_type_traits 0)
IF(HAVE_TYPE_TRAITS_H)
SET(pcre_have_type_traits 1)
ENDIF(HAVE_TYPE_TRAITS_H)
IF(HAVE_BITS_TYPE_TRAITS_H)
SET(pcre_have_bits_type_traits 1)
ENDIF(HAVE_BITS_TYPE_TRAITS_H)
SET(pcre_have_long_long 0)
SET(pcre_have_ulong_long 0)
IF(HAVE_LONG_LONG)
SET(pcre_have_long_long 1)
ENDIF(HAVE_LONG_LONG)
IF(HAVE_UNSIGNED_LONG_LONG)
SET(pcre_have_ulong_long 1)
ENDIF(HAVE_UNSIGNED_LONG_LONG)
IF(NOT BUILD_SHARED_LIBS)
SET(PCRE_STATIC 1)
ENDIF(NOT BUILD_SHARED_LIBS)
IF(NOT PCRE_BUILD_PCRE8 AND NOT PCRE_BUILD_PCRE16 AND NOT PCRE_BUILD_PCRE32)
MESSAGE(FATAL_ERROR "At least one of PCRE_BUILD_PCRE8, PCRE_BUILD_PCRE16 or PCRE_BUILD_PCRE32 must be enabled")
ENDIF(NOT PCRE_BUILD_PCRE8 AND NOT PCRE_BUILD_PCRE16 AND NOT PCRE_BUILD_PCRE32)
IF(PCRE_BUILD_PCRE8)
SET(SUPPORT_PCRE8 1)
ENDIF(PCRE_BUILD_PCRE8)
IF(PCRE_BUILD_PCRE16)
SET(SUPPORT_PCRE16 1)
ENDIF(PCRE_BUILD_PCRE16)
IF(PCRE_BUILD_PCRE32)
SET(SUPPORT_PCRE32 1)
ENDIF(PCRE_BUILD_PCRE32)
IF(PCRE_BUILD_PCRECPP AND NOT PCRE_BUILD_PCRE8)
MESSAGE(STATUS "** PCRE_BUILD_PCRE8 must be enabled for the C++ library support")
SET(PCRE_BUILD_PCRECPP OFF)
ENDIF(PCRE_BUILD_PCRECPP AND NOT PCRE_BUILD_PCRE8)
IF(PCRE_BUILD_PCREGREP AND NOT PCRE_BUILD_PCRE8)
MESSAGE(STATUS "** PCRE_BUILD_PCRE8 must be enabled for the pcregrep program")
SET(PCRE_BUILD_PCREGREP OFF)
ENDIF(PCRE_BUILD_PCREGREP AND NOT PCRE_BUILD_PCRE8)
IF(PCRE_SUPPORT_LIBREADLINE AND PCRE_SUPPORT_LIBEDIT)
MESSAGE(FATAL_ERROR "Only one of libreadline or libeditline can be specified")
ENDIF(PCRE_SUPPORT_LIBREADLINE AND PCRE_SUPPORT_LIBEDIT)
IF(PCRE_SUPPORT_BSR_ANYCRLF)
SET(BSR_ANYCRLF 1)
ENDIF(PCRE_SUPPORT_BSR_ANYCRLF)
IF(PCRE_SUPPORT_UTF OR PCRE_SUPPORT_UNICODE_PROPERTIES)
SET(SUPPORT_UTF 1)
SET(PCRE_SUPPORT_UTF ON)
ENDIF(PCRE_SUPPORT_UTF OR PCRE_SUPPORT_UNICODE_PROPERTIES)
IF(PCRE_SUPPORT_UNICODE_PROPERTIES)
SET(SUPPORT_UCP 1)
ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES)
IF(PCRE_SUPPORT_JIT)
SET(SUPPORT_JIT 1)
ENDIF(PCRE_SUPPORT_JIT)
IF(PCRE_SUPPORT_PCREGREP_JIT)
SET(SUPPORT_PCREGREP_JIT 1)
ENDIF(PCRE_SUPPORT_PCREGREP_JIT)
IF(PCRE_SUPPORT_VALGRIND)
SET(SUPPORT_VALGRIND 1)
ENDIF(PCRE_SUPPORT_VALGRIND)
# This next one used to contain
# SET(PCRETEST_LIBS ${READLINE_LIBRARY})
# but I was advised to add the NCURSES test as well, along with
# some modifications to cmake/FindReadline.cmake which should
# make it possible to override the default if necessary. PH
IF(PCRE_SUPPORT_LIBREADLINE)
SET(SUPPORT_LIBREADLINE 1)
SET(PCRETEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY})
ENDIF(PCRE_SUPPORT_LIBREADLINE)
# libedit is a plug-compatible alternative to libreadline
IF(PCRE_SUPPORT_LIBEDIT)
SET(SUPPORT_LIBEDIT 1)
SET(PCRETEST_LIBS ${EDITLINE_LIBRARY} ${NCURSES_LIBRARY})
ENDIF(PCRE_SUPPORT_LIBEDIT)
IF(PCRE_SUPPORT_LIBZ)
SET(SUPPORT_LIBZ 1)
SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${ZLIB_LIBRARIES})
ENDIF(PCRE_SUPPORT_LIBZ)
IF(PCRE_SUPPORT_LIBBZ2)
SET(SUPPORT_LIBBZ2 1)
SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${BZIP2_LIBRARIES})
ENDIF(PCRE_SUPPORT_LIBBZ2)
SET(NEWLINE "")
IF(PCRE_NEWLINE STREQUAL "LF")
SET(NEWLINE "10")
ENDIF(PCRE_NEWLINE STREQUAL "LF")
IF(PCRE_NEWLINE STREQUAL "CR")
SET(NEWLINE "13")
ENDIF(PCRE_NEWLINE STREQUAL "CR")
IF(PCRE_NEWLINE STREQUAL "CRLF")
SET(NEWLINE "3338")
ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
IF(PCRE_NEWLINE STREQUAL "ANY")
SET(NEWLINE "-1")
ENDIF(PCRE_NEWLINE STREQUAL "ANY")
IF(PCRE_NEWLINE STREQUAL "ANYCRLF")
SET(NEWLINE "-2")
ENDIF(PCRE_NEWLINE STREQUAL "ANYCRLF")
IF(NEWLINE STREQUAL "")
MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
ENDIF(NEWLINE STREQUAL "")
IF(PCRE_EBCDIC)
SET(EBCDIC 1)
IF(PCRE_NEWLINE STREQUAL "LF")
SET(NEWLINE "21")
ENDIF(PCRE_NEWLINE STREQUAL "LF")
IF(PCRE_NEWLINE STREQUAL "CRLF")
SET(NEWLINE "3349")
ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
ENDIF(PCRE_EBCDIC)
IF(PCRE_EBCDIC_NL25)
SET(EBCDIC 1)
SET(EBCDIC_NL25 1)
IF(PCRE_NEWLINE STREQUAL "LF")
SET(NEWLINE "37")
ENDIF(PCRE_NEWLINE STREQUAL "LF")
IF(PCRE_NEWLINE STREQUAL "CRLF")
SET(NEWLINE "3365")
ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
ENDIF(PCRE_EBCDIC_NL25)
IF(PCRE_NO_RECURSE)
SET(NO_RECURSE 1)
ENDIF(PCRE_NO_RECURSE)
# Output files
CONFIGURE_FILE(config-cmake.h.in
${PROJECT_BINARY_DIR}/config.h
@ONLY)
# Parse version numbers and date out of configure.ac
file(STRINGS ${PROJECT_SOURCE_DIR}/configure.ac
configure_lines
LIMIT_COUNT 50 # Read only the first 50 lines of the file
)
set(SEARCHED_VARIABLES "pcre_major" "pcre_minor" "pcre_prerelease" "pcre_date")
foreach(configure_line ${configure_lines})
foreach(_substitution_variable ${SEARCHED_VARIABLES})
string(TOUPPER ${_substitution_variable} _substitution_variable_upper)
if (NOT ${_substitution_variable_upper})
string(REGEX MATCH "m4_define\\(${_substitution_variable}, \\[(.*)\\]" MACTHED_STRING ${configure_line})
if (CMAKE_MATCH_1)
set(${_substitution_variable_upper} ${CMAKE_MATCH_1})
endif()
endif()
endforeach()
endforeach()
CONFIGURE_FILE(pcre.h.in
${PROJECT_BINARY_DIR}/pcre.h
@ONLY)
# What about pcre-config and libpcre.pc?
IF(PCRE_BUILD_PCRECPP)
CONFIGURE_FILE(pcre_stringpiece.h.in
${PROJECT_BINARY_DIR}/pcre_stringpiece.h
@ONLY)
CONFIGURE_FILE(pcrecpparg.h.in
${PROJECT_BINARY_DIR}/pcrecpparg.h
@ONLY)
ENDIF(PCRE_BUILD_PCRECPP)
# Character table generation
OPTION(PCRE_REBUILD_CHARTABLES "Rebuild char tables" OFF)
IF(PCRE_REBUILD_CHARTABLES)
ADD_EXECUTABLE(dftables dftables.c)
GET_TARGET_PROPERTY(DFTABLES_EXE dftables LOCATION)
ADD_CUSTOM_COMMAND(
COMMENT "Generating character tables (pcre_chartables.c) for current locale"
DEPENDS dftables
COMMAND ${DFTABLES_EXE}
ARGS ${PROJECT_BINARY_DIR}/pcre_chartables.c
OUTPUT ${PROJECT_BINARY_DIR}/pcre_chartables.c
)
ELSE(PCRE_REBUILD_CHARTABLES)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/pcre_chartables.c.dist
${PROJECT_BINARY_DIR}/pcre_chartables.c
COPYONLY)
ENDIF(PCRE_REBUILD_CHARTABLES)
# Source code
SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/pcre.h)
IF(PCRE_BUILD_PCRE8)
SET(PCRE_SOURCES
pcre_byte_order.c
pcre_chartables.c
pcre_compile.c
pcre_config.c
pcre_dfa_exec.c
pcre_exec.c
pcre_fullinfo.c
pcre_get.c
pcre_globals.c
pcre_jit_compile.c
pcre_maketables.c
pcre_newline.c
pcre_ord2utf8.c
pcre_refcount.c
pcre_string_utils.c
pcre_study.c
pcre_tables.c
pcre_ucd.c
pcre_valid_utf8.c
pcre_version.c
pcre_xclass.c
)
SET(PCREPOSIX_HEADERS pcreposix.h)
SET(PCREPOSIX_SOURCES pcreposix.c)
ENDIF(PCRE_BUILD_PCRE8)
IF(PCRE_BUILD_PCRE16)
SET(PCRE16_SOURCES
pcre16_byte_order.c
pcre16_chartables.c
pcre16_compile.c
pcre16_config.c
pcre16_dfa_exec.c
pcre16_exec.c
pcre16_fullinfo.c
pcre16_get.c
pcre16_globals.c
pcre16_jit_compile.c
pcre16_maketables.c
pcre16_newline.c
pcre16_ord2utf16.c
pcre16_refcount.c
pcre16_string_utils.c
pcre16_study.c
pcre16_tables.c
pcre16_ucd.c
pcre16_utf16_utils.c
pcre16_valid_utf16.c
pcre16_version.c
pcre16_xclass.c
)
ENDIF(PCRE_BUILD_PCRE16)
IF(PCRE_BUILD_PCRE32)
SET(PCRE32_SOURCES
pcre32_byte_order.c
pcre32_chartables.c
pcre32_compile.c
pcre32_config.c
pcre32_dfa_exec.c
pcre32_exec.c
pcre32_fullinfo.c
pcre32_get.c
pcre32_globals.c
pcre32_jit_compile.c
pcre32_maketables.c
pcre32_newline.c
pcre32_ord2utf32.c
pcre32_refcount.c
pcre32_string_utils.c
pcre32_study.c
pcre32_tables.c
pcre32_ucd.c
pcre32_utf32_utils.c
pcre32_valid_utf32.c
pcre32_version.c
pcre32_xclass.c
)
ENDIF(PCRE_BUILD_PCRE32)
IF(MINGW AND NOT PCRE_STATIC)
IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre.o
PRE-LINK
COMMAND windres ARGS pcre.rc pcre.o
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT Using pcre coff info in mingw build)
SET(PCRE_SOURCES
${PCRE_SOURCES} ${PROJECT_SOURCE_DIR}/pcre.o
)
ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
IF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcreposix.o
PRE-LINK
COMMAND windres ARGS pcreposix.rc pcreposix.o
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT Using pcreposix coff info in mingw build)
SET(PCREPOSIX_SOURCES
${PCREPOSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcreposix.o
)
ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
ENDIF(MINGW AND NOT PCRE_STATIC)
IF(MSVC AND NOT PCRE_STATIC)
IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
SET(PCRE_SOURCES
${PCRE_SOURCES} pcre.rc)
ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
IF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
SET(PCREPOSIX_SOURCES
${PCREPOSIX_SOURCES} pcreposix.rc)
ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
ENDIF(MSVC AND NOT PCRE_STATIC)
SET(PCRECPP_HEADERS
pcrecpp.h
pcre_scanner.h
${PROJECT_BINARY_DIR}/pcrecpparg.h
${PROJECT_BINARY_DIR}/pcre_stringpiece.h
)
SET(PCRECPP_SOURCES
pcrecpp.cc
pcre_scanner.cc
pcre_stringpiece.cc
)
# Build setup
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
IF(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
ENDIF(MSVC)
SET(CMAKE_INCLUDE_CURRENT_DIR 1)
# needed to make sure to not link debug libs
# against release libs and vice versa
IF(WIN32)
SET(CMAKE_DEBUG_POSTFIX "d")
ENDIF(WIN32)
SET(targets)
# Libraries
# pcre
IF(PCRE_BUILD_PCRE8)
ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
SET(targets ${targets} pcre)
ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES})
SET(targets ${targets} pcreposix)
TARGET_LINK_LIBRARIES(pcreposix pcre)
IF(MINGW AND NOT PCRE_STATIC)
IF(NON_STANDARD_LIB_PREFIX)
SET_TARGET_PROPERTIES(pcre pcreposix
PROPERTIES PREFIX ""
)
ENDIF(NON_STANDARD_LIB_PREFIX)
IF(NON_STANDARD_LIB_SUFFIX)
SET_TARGET_PROPERTIES(pcre pcreposix
PROPERTIES SUFFIX "-0.dll"
)
ENDIF(NON_STANDARD_LIB_SUFFIX)
ENDIF(MINGW AND NOT PCRE_STATIC)
ENDIF(PCRE_BUILD_PCRE8)
IF(PCRE_BUILD_PCRE16)
ADD_LIBRARY(pcre16 ${PCRE_HEADERS} ${PCRE16_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
SET(targets ${targets} pcre16)
IF(MINGW AND NOT PCRE_STATIC)
IF(NON_STANDARD_LIB_PREFIX)
SET_TARGET_PROPERTIES(pcre16
PROPERTIES PREFIX ""
)
ENDIF(NON_STANDARD_LIB_PREFIX)
IF(NON_STANDARD_LIB_SUFFIX)
SET_TARGET_PROPERTIES(pcre16
PROPERTIES SUFFIX "-0.dll"
)
ENDIF(NON_STANDARD_LIB_SUFFIX)
ENDIF(MINGW AND NOT PCRE_STATIC)
ENDIF(PCRE_BUILD_PCRE16)
IF(PCRE_BUILD_PCRE32)
ADD_LIBRARY(pcre32 ${PCRE_HEADERS} ${PCRE32_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
SET(targets ${targets} pcre32)
IF(MINGW AND NOT PCRE_STATIC)
IF(NON_STANDARD_LIB_PREFIX)
SET_TARGET_PROPERTIES(pcre32
PROPERTIES PREFIX ""
)
ENDIF(NON_STANDARD_LIB_PREFIX)
IF(NON_STANDARD_LIB_SUFFIX)
SET_TARGET_PROPERTIES(pcre32
PROPERTIES SUFFIX "-0.dll"
)
ENDIF(NON_STANDARD_LIB_SUFFIX)
ENDIF(MINGW AND NOT PCRE_STATIC)
ENDIF(PCRE_BUILD_PCRE32)
# pcrecpp
IF(PCRE_BUILD_PCRECPP)
ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES})
SET(targets ${targets} pcrecpp)
TARGET_LINK_LIBRARIES(pcrecpp pcre)
IF(MINGW AND NOT PCRE_STATIC)
IF(NON_STANDARD_LIB_PREFIX)
SET_TARGET_PROPERTIES(pcrecpp
PROPERTIES PREFIX ""
)
ENDIF(NON_STANDARD_LIB_PREFIX)
IF(NON_STANDARD_LIB_SUFFIX)
SET_TARGET_PROPERTIES(pcrecpp
PROPERTIES SUFFIX "-0.dll"
)
ENDIF(NON_STANDARD_LIB_SUFFIX)
ENDIF(MINGW AND NOT PCRE_STATIC)
ENDIF(PCRE_BUILD_PCRECPP)
# Executables
# Removed by PH (2008-01-23) because pcredemo shouldn't really be built
# automatically, and it gave trouble in some environments anyway.
# ADD_EXECUTABLE(pcredemo pcredemo.c)
# TARGET_LINK_LIBRARIES(pcredemo pcreposix)
# IF(NOT BUILD_SHARED_LIBS)
# # make sure to not use declspec(dllimport) in static mode on windows
# SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC")
# ENDIF(NOT BUILD_SHARED_LIBS)
IF(PCRE_BUILD_PCREGREP)
ADD_EXECUTABLE(pcregrep pcregrep.c)
SET(targets ${targets} pcregrep)
TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS})
ENDIF(PCRE_BUILD_PCREGREP)
# Testing
IF(PCRE_BUILD_TESTS)
ENABLE_TESTING()
SET(PCRETEST_SOURCES pcretest.c)
IF(PCRE_BUILD_PCRE8)
LIST(APPEND PCRETEST_SOURCES pcre_printint.c)
ENDIF(PCRE_BUILD_PCRE8)
IF(PCRE_BUILD_PCRE16)
LIST(APPEND PCRETEST_SOURCES pcre16_printint.c)
ENDIF(PCRE_BUILD_PCRE16)
IF(PCRE_BUILD_PCRE32)
LIST(APPEND PCRETEST_SOURCES pcre32_printint.c)
ENDIF(PCRE_BUILD_PCRE32)
ADD_EXECUTABLE(pcretest ${PCRETEST_SOURCES})
SET(targets ${targets} pcretest)
IF(PCRE_BUILD_PCRE8)
LIST(APPEND PCRETEST_LIBS pcreposix pcre)
ENDIF(PCRE_BUILD_PCRE8)
IF(PCRE_BUILD_PCRE16)
LIST(APPEND PCRETEST_LIBS pcre16)
ENDIF(PCRE_BUILD_PCRE16)
IF(PCRE_BUILD_PCRE32)
LIST(APPEND PCRETEST_LIBS pcre32)
ENDIF(PCRE_BUILD_PCRE32)
TARGET_LINK_LIBRARIES(pcretest ${PCRETEST_LIBS})
IF(PCRE_SUPPORT_JIT)
ADD_EXECUTABLE(pcre_jit_test pcre_jit_test.c)
SET(targets ${targets} pcre_jit_test)
SET(PCRE_JIT_TEST_LIBS )
IF(PCRE_BUILD_PCRE8)
LIST(APPEND PCRE_JIT_TEST_LIBS pcre)
ENDIF(PCRE_BUILD_PCRE8)
IF(PCRE_BUILD_PCRE16)
LIST(APPEND PCRE_JIT_TEST_LIBS pcre16)
ENDIF(PCRE_BUILD_PCRE16)
IF(PCRE_BUILD_PCRE32)
LIST(APPEND PCRE_JIT_TEST_LIBS pcre32)
ENDIF(PCRE_BUILD_PCRE32)
TARGET_LINK_LIBRARIES(pcre_jit_test ${PCRE_JIT_TEST_LIBS})
ENDIF(PCRE_SUPPORT_JIT)
IF(PCRE_BUILD_PCRECPP)
ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc)
SET(targets ${targets} pcrecpp_unittest)
TARGET_LINK_LIBRARIES(pcrecpp_unittest pcrecpp)
IF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC)
SET_TARGET_PROPERTIES(pcrecpp
PROPERTIES PREFIX ""
)
ENDIF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC)
ADD_EXECUTABLE(pcre_scanner_unittest pcre_scanner_unittest.cc)
SET(targets ${targets} pcre_scanner_unittest)
TARGET_LINK_LIBRARIES(pcre_scanner_unittest pcrecpp)
ADD_EXECUTABLE(pcre_stringpiece_unittest pcre_stringpiece_unittest.cc)
SET(targets ${targets} pcre_stringpiece_unittest)
TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp)
ENDIF(PCRE_BUILD_PCRECPP)
# exes in Debug location tested by the RunTest shell script
# via "make test"
IF(PCRE_BUILD_PCREGREP)
GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)
ENDIF(PCRE_BUILD_PCREGREP)
GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)
# =================================================
# Write out a CTest configuration file
#
FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest
"# This is a generated file.
MESSAGE(\"When testing is complete, review test output in the
\\\"${PROJECT_BINARY_DIR}/Testing/Temporary\\\" folder.\")
MESSAGE(\" \")
")
FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.sh
"#! /bin/sh
# This is a generated file.
srcdir=${PROJECT_SOURCE_DIR}
pcretest=${PCRETEST_EXE}
. ${PROJECT_SOURCE_DIR}/RunTest
if test \"$?\" != \"0\"; then exit 1; fi
# End
")
IF(UNIX)
ADD_TEST(pcre_test sh ${PROJECT_BINARY_DIR}/pcre_test.sh)
ENDIF(UNIX)
IF(PCRE_BUILD_PCREGREP)
FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_grep_test.sh
"#! /bin/sh
# This is a generated file.
srcdir=${PROJECT_SOURCE_DIR}
pcregrep=${PCREGREP_EXE}
pcretest=${PCRETEST_EXE}
. ${PROJECT_SOURCE_DIR}/RunGrepTest
if test \"$?\" != \"0\"; then exit 1; fi
# End
")
IF(UNIX)
ADD_TEST(pcre_grep_test sh ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
ENDIF(UNIX)
ENDIF(PCRE_BUILD_PCREGREP)
IF(WIN32)
# Provide environment for executing the bat file version of RunTest
FILE(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} winsrc)
FILE(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} winbin)
FILE(TO_NATIVE_PATH ${PCRETEST_EXE} winexe)
FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.bat
"\@REM This is a generated file.
\@echo off
setlocal
SET srcdir=\"${winsrc}\"
SET pcretest=\"${winexe}\"
if not [%CMAKE_CONFIG_TYPE%]==[] SET pcretest=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcretest.exe\"
call %srcdir%\\RunTest.Bat
if errorlevel 1 exit /b 1
echo RunTest.bat tests successfully completed
")
ADD_TEST(NAME pcre_test_bat
COMMAND pcre_test.bat)
SET_TESTS_PROPERTIES(pcre_test_bat PROPERTIES
PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed")
IF("$ENV{OSTYPE}" STREQUAL "msys")
# Both the sh and bat file versions of RunTest are run if make test is used
# in msys
ADD_TEST(pcre_test_sh sh.exe ${PROJECT_BINARY_DIR}/pcre_test.sh)
IF(PCRE_BUILD_PCREGREP)
ADD_TEST(pcre_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
ENDIF(PCRE_BUILD_PCREGREP)
ENDIF("$ENV{OSTYPE}" STREQUAL "msys")
ENDIF(WIN32)
# Changed to accommodate testing whichever location was just built
IF(PCRE_SUPPORT_JIT)
ADD_TEST(pcre_jit_test pcre_jit_test)
ENDIF(PCRE_SUPPORT_JIT)
IF(PCRE_BUILD_PCRECPP)
ADD_TEST(pcrecpp_test pcrecpp_unittest)
ADD_TEST(pcre_scanner_test pcre_scanner_unittest)
ADD_TEST(pcre_stringpiece_test pcre_stringpiece_unittest)
ENDIF(PCRE_BUILD_PCRECPP)
ENDIF(PCRE_BUILD_TESTS)
# Installation
SET(CMAKE_INSTALL_ALWAYS 1)
INSTALL(TARGETS ${targets}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)
FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html)
FILE(GLOB man1 ${PROJECT_SOURCE_DIR}/doc/*.1)
FILE(GLOB man3 ${PROJECT_SOURCE_DIR}/doc/*.3)
IF(PCRE_BUILD_PCRECPP)
INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include)
ELSE(PCRE_BUILD_PCRECPP)
# Remove pcrecpp.3
FOREACH(man ${man3})
GET_FILENAME_COMPONENT(man_tmp ${man} NAME)
IF(NOT man_tmp STREQUAL "pcrecpp.3")
SET(man3_new ${man3} ${man})
ENDIF(NOT man_tmp STREQUAL "pcrecpp.3")
ENDFOREACH(man ${man3})
SET(man3 ${man3_new})
ENDIF(PCRE_BUILD_PCRECPP)
INSTALL(FILES ${man1} DESTINATION man/man1)
INSTALL(FILES ${man3} DESTINATION man/man3)
INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)
IF(MSVC AND INSTALL_MSVC_PDB)
INSTALL(FILES ${PROJECT_BINARY_DIR}/pcre.pdb
${PROJECT_BINARY_DIR}/pcreposix.pdb
DESTINATION bin
CONFIGURATIONS RelWithDebInfo)
INSTALL(FILES ${PROJECT_BINARY_DIR}/pcred.pdb
${PROJECT_BINARY_DIR}/pcreposixd.pdb
DESTINATION bin
CONFIGURATIONS Debug)
ENDIF(MSVC AND INSTALL_MSVC_PDB)
# help, only for nice output
IF(BUILD_SHARED_LIBS)
SET(BUILD_STATIC_LIBS OFF)
ELSE(BUILD_SHARED_LIBS)
SET(BUILD_STATIC_LIBS ON)
ENDIF(BUILD_SHARED_LIBS)
IF(PCRE_SHOW_REPORT)
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype)
IF (CMAKE_C_FLAGS)
SET(cfsp " ")
ENDIF(CMAKE_C_FLAGS)
IF (CMAKE_CXX_FLAGS)
SET(cxxfsp " ")
ENDIF(CMAKE_CXX_FLAGS)
MESSAGE(STATUS "")
MESSAGE(STATUS "")
MESSAGE(STATUS "PCRE configuration summary:")
MESSAGE(STATUS "")
MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}")
MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}")
MESSAGE(STATUS " C++ compiler .................... : ${CMAKE_CXX_COMPILER}")
MESSAGE(STATUS " C compiler flags ................ : ${CMAKE_C_FLAGS}${cfsp}${CMAKE_C_FLAGS_${buildtype}}")
MESSAGE(STATUS " C++ compiler flags .............. : ${CMAKE_CXX_FLAGS}${cxxfsp}${CMAKE_CXX_FLAGS_${buildtype}}")
MESSAGE(STATUS "")
MESSAGE(STATUS " Build 8 bit PCRE library ........ : ${PCRE_BUILD_PCRE8}")
MESSAGE(STATUS " Build 16 bit PCRE library ....... : ${PCRE_BUILD_PCRE16}")
MESSAGE(STATUS " Build 32 bit PCRE library ....... : ${PCRE_BUILD_PCRE32}")
MESSAGE(STATUS " Build C++ library ............... : ${PCRE_BUILD_PCRECPP}")
MESSAGE(STATUS " Enable JIT compiling support .... : ${PCRE_SUPPORT_JIT}")
MESSAGE(STATUS " Enable UTF support .............. : ${PCRE_SUPPORT_UTF}")
MESSAGE(STATUS " Unicode properties .............. : ${PCRE_SUPPORT_UNICODE_PROPERTIES}")
MESSAGE(STATUS " Newline char/sequence ........... : ${PCRE_NEWLINE}")
MESSAGE(STATUS " \\R matches only ANYCRLF ......... : ${PCRE_SUPPORT_BSR_ANYCRLF}")
MESSAGE(STATUS " EBCDIC coding ................... : ${PCRE_EBCDIC}")
MESSAGE(STATUS " EBCDIC coding with NL=0x25 ...... : ${PCRE_EBCDIC_NL25}")
MESSAGE(STATUS " Rebuild char tables ............. : ${PCRE_REBUILD_CHARTABLES}")
MESSAGE(STATUS " No stack recursion .............. : ${PCRE_NO_RECURSE}")
MESSAGE(STATUS " POSIX mem threshold ............. : ${PCRE_POSIX_MALLOC_THRESHOLD}")
MESSAGE(STATUS " Internal link size .............. : ${PCRE_LINK_SIZE}")
MESSAGE(STATUS " Parentheses nest limit .......... : ${PCRE_PARENS_NEST_LIMIT}")
MESSAGE(STATUS " Match limit ..................... : ${PCRE_MATCH_LIMIT}")
MESSAGE(STATUS " Match limit recursion ........... : ${PCRE_MATCH_LIMIT_RECURSION}")
MESSAGE(STATUS " Build shared libs ............... : ${BUILD_SHARED_LIBS}")
MESSAGE(STATUS " Build static libs ............... : ${BUILD_STATIC_LIBS}")
MESSAGE(STATUS " Build pcregrep .................. : ${PCRE_BUILD_PCREGREP}")
MESSAGE(STATUS " Enable JIT in pcregrep .......... : ${PCRE_SUPPORT_PCREGREP_JIT}")
MESSAGE(STATUS " Buffer size for pcregrep ........ : ${PCREGREP_BUFSIZE}")
MESSAGE(STATUS " Build tests (implies pcretest .. : ${PCRE_BUILD_TESTS}")
MESSAGE(STATUS " and pcregrep)")
IF(ZLIB_FOUND)
MESSAGE(STATUS " Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}")
ELSE(ZLIB_FOUND)
MESSAGE(STATUS " Link pcregrep with libz ......... : Library not found" )
ENDIF(ZLIB_FOUND)
IF(BZIP2_FOUND)
MESSAGE(STATUS " Link pcregrep with libbz2 ....... : ${PCRE_SUPPORT_LIBBZ2}")
ELSE(BZIP2_FOUND)
MESSAGE(STATUS " Link pcregrep with libbz2 ....... : Library not found" )
ENDIF(BZIP2_FOUND)
IF(EDITLINE_FOUND)
MESSAGE(STATUS " Link pcretest with libeditline .. : ${PCRE_SUPPORT_LIBEDIT}")
ELSE(EDITLINE_FOUND)
MESSAGE(STATUS " Link pcretest with libeditline .. : Library not found" )
ENDIF(EDITLINE_FOUND)
IF(READLINE_FOUND)
MESSAGE(STATUS " Link pcretest with libreadline .. : ${PCRE_SUPPORT_LIBREADLINE}")
ELSE(READLINE_FOUND)
MESSAGE(STATUS " Link pcretest with libreadline .. : Library not found" )
ENDIF(READLINE_FOUND)
MESSAGE(STATUS " Support Valgrind .................: ${PCRE_SUPPORT_VALGRIND}")
MESSAGE(STATUS " Support coverage .................: ${PCRE_SUPPORT_COVERAGE}")
IF(MINGW AND NOT PCRE_STATIC)
MESSAGE(STATUS " Non-standard dll names (prefix) . : ${NON_STANDARD_LIB_PREFIX}")
MESSAGE(STATUS " Non-standard dll names (suffix) . : ${NON_STANDARD_LIB_SUFFIX}")
ENDIF(MINGW AND NOT PCRE_STATIC)
IF(MSVC)
MESSAGE(STATUS " Install MSVC .pdb files ..........: ${INSTALL_MSVC_PDB}")
ENDIF(MSVC)
MESSAGE(STATUS "")
ENDIF(PCRE_SHOW_REPORT)
# end CMakeLists.txt
pcre-8.38/Makefile.am 0000644 0002221 0002221 00000065201 12317533046 011356 0000000 0000000 ## Process this file with automake to produce Makefile.in.
ACLOCAL_AMFLAGS = -I m4
dist_doc_DATA = \
doc/pcre.txt \
doc/pcre-config.txt \
doc/pcregrep.txt \
doc/pcretest.txt \
AUTHORS \
COPYING \
ChangeLog \
LICENCE \
NEWS \
README
# Note that pcrecpp.html is not in this list; it is listed separately below.
dist_html_DATA = \
doc/html/NON-AUTOTOOLS-BUILD.txt \
doc/html/README.txt \
doc/html/index.html \
doc/html/pcre-config.html \
doc/html/pcre.html \
doc/html/pcre16.html \
doc/html/pcre32.html \
doc/html/pcre_assign_jit_stack.html \
doc/html/pcre_compile.html \
doc/html/pcre_compile2.html \
doc/html/pcre_config.html \
doc/html/pcre_copy_named_substring.html \
doc/html/pcre_copy_substring.html \
doc/html/pcre_dfa_exec.html \
doc/html/pcre_exec.html \
doc/html/pcre_free_study.html \
doc/html/pcre_free_substring.html \
doc/html/pcre_free_substring_list.html \
doc/html/pcre_fullinfo.html \
doc/html/pcre_get_named_substring.html \
doc/html/pcre_get_stringnumber.html \
doc/html/pcre_get_stringtable_entries.html \
doc/html/pcre_get_substring.html \
doc/html/pcre_get_substring_list.html \
doc/html/pcre_jit_exec.html \
doc/html/pcre_jit_stack_alloc.html \
doc/html/pcre_jit_stack_free.html \
doc/html/pcre_maketables.html \
doc/html/pcre_pattern_to_host_byte_order.html \
doc/html/pcre_refcount.html \
doc/html/pcre_study.html \
doc/html/pcre_utf16_to_host_byte_order.html \
doc/html/pcre_utf32_to_host_byte_order.html \
doc/html/pcre_version.html \
doc/html/pcreapi.html \
doc/html/pcrebuild.html \
doc/html/pcrecallout.html \
doc/html/pcrecompat.html \
doc/html/pcredemo.html \
doc/html/pcregrep.html \
doc/html/pcrejit.html \
doc/html/pcrelimits.html \
doc/html/pcrematching.html \
doc/html/pcrepartial.html \
doc/html/pcrepattern.html \
doc/html/pcreperform.html \
doc/html/pcreposix.html \
doc/html/pcreprecompile.html \
doc/html/pcresample.html \
doc/html/pcrestack.html \
doc/html/pcresyntax.html \
doc/html/pcretest.html \
doc/html/pcreunicode.html
pcrecpp_html = doc/html/pcrecpp.html
dist_noinst_DATA = $(pcrecpp_html)
if WITH_PCRE_CPP
html_DATA = $(pcrecpp_html)
endif
# The Libtool libraries to install. We'll add to this later.
lib_LTLIBRARIES =
# Unit tests you want to run when people type 'make check'.
# TESTS is for binary unit tests, check_SCRIPTS for script-based tests
TESTS =
check_SCRIPTS =
dist_noinst_SCRIPTS =
# Some of the binaries we make are to be installed, and others are
# (non-user-visible) helper programs needed to build libpcre, libpcre16
# or libpcre32.
bin_PROGRAMS =
noinst_PROGRAMS =
# Additional files to delete on 'make clean' and 'make maintainer-clean'.
CLEANFILES =
MAINTAINERCLEANFILES =
# Additional files to bundle with the distribution, over and above what
# the Autotools include by default.
EXTRA_DIST =
# These files contain additional m4 macros that are used by autoconf.
EXTRA_DIST += \
m4/ax_pthread.m4 m4/pcre_visibility.m4
# These files contain maintenance information
EXTRA_DIST += \
doc/perltest.txt \
NON-UNIX-USE \
NON-AUTOTOOLS-BUILD \
HACKING
# These files are used in the preparation of a release
EXTRA_DIST += \
PrepareRelease \
CheckMan \
CleanTxt \
Detrail \
132html \
doc/index.html.src
# These files are to do with building for Virtual Pascal
EXTRA_DIST += \
makevp.bat \
makevp_c.txt \
makevp_l.txt \
pcregexp.pas
# These files are usable versions of pcre.h and config.h that are distributed
# for the benefit of people who are building PCRE manually, without the
# Autotools support.
EXTRA_DIST += \
pcre.h.generic \
config.h.generic
# The only difference between pcre.h.in and pcre.h is the setting of the PCRE
# version number. Therefore, we can create the generic version just by copying.
pcre.h.generic: pcre.h.in configure.ac
rm -f $@
cp -p pcre.h $@
# It is more complicated for config.h.generic. We need the version that results
# from a default configuration so as to get all the default values for PCRE
# configuration macros such as MATCH_LIMIT and NEWLINE. We can get this by
# doing a configure in a temporary directory. However, some trickery is needed,
# because the source directory may already be configured. If you just try
# running configure in a new directory, it complains. For this reason, we move
# config.status out of the way while doing the default configuration. The
# 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).
config.h.generic: configure.ac
rm -rf $@ _generic
mkdir _generic
cs=$(srcdir)/config.status; test ! -f $$cs || mv -f $$cs $$cs.aside
cd _generic && $(abs_top_srcdir)/configure || :
cs=$(srcdir)/config.status; test ! -f $$cs.aside || mv -f $$cs.aside $$cs
test -f _generic/config.h
perl -n \
-e 'BEGIN{$$blank=0;}' \
-e 'if(/PCRE_EXP_DEFN/){print"/* #undef PCRE_EXP_DEFN */\n";$$blank=0;next;}' \
-e 'if(/to make a symbol visible/){next;}' \
-e 'if(/__attribute__ \(\(visibility/){next;}' \
-e 'if(/LT_OBJDIR/){print"/* This is ignored unless you are using libtool. */\n";}' \
-e 'if(/^#define\s((?:HAVE|SUPPORT|STDC)_\w+)/){print"/* #undef $$1 */\n";$$blank=0;next;}' \
-e 'if(/^#define\s(?!PACKAGE|VERSION)(\w+)/){print"#ifndef $$1\n$$_#endif\n";$$blank=0;next;}' \
-e 'if(/^\s*$$/){print unless $$blank; $$blank=1;} else{print;$$blank=0;}' \
_generic/config.h >$@
rm -rf _generic
MAINTAINERCLEANFILES += pcre.h.generic config.h.generic
# These are the header files we'll install. We do not distribute pcre.h because
# it is generated from pcre.h.in.
nodist_include_HEADERS = \
pcre.h
include_HEADERS = \
pcreposix.h
# These additional headers will be be installed if C++ support is enabled. We
# do not distribute pcrecpparg.h or pcre_stringpiece.h, as these are generated
# from corresponding .h.in files (which we do distribute).
if WITH_PCRE_CPP
nodist_include_HEADERS += \
pcrecpparg.h \
pcre_stringpiece.h
include_HEADERS += \
pcrecpp.h \
pcre_scanner.h
endif # WITH_PCRE_CPP
bin_SCRIPTS = pcre-config
## ---------------------------------------------------------------
## The dftables program is used to rebuild character tables before compiling
## PCRE, if --enable-rebuild-chartables is specified. It is not a user-visible
## program. The default (when --enable-rebuild-chartables is not specified) is
## to copy a distributed set of tables that are defined for ASCII code. In this
## case, dftables is not needed.
if WITH_REBUILD_CHARTABLES
noinst_PROGRAMS += dftables
dftables_SOURCES = dftables.c
pcre_chartables.c: dftables$(EXEEXT)
./dftables$(EXEEXT) $@
else
pcre_chartables.c: $(srcdir)/pcre_chartables.c.dist
rm -f $@
$(LN_S) $(srcdir)/pcre_chartables.c.dist $@
endif # WITH_REBUILD_CHARTABLES
BUILT_SOURCES = pcre_chartables.c
## The main pcre library
# Build the 8 bit library if it is enabled.
if WITH_PCRE8
lib_LTLIBRARIES += libpcre.la
libpcre_la_SOURCES = \
pcre_byte_order.c \
pcre_compile.c \
pcre_config.c \
pcre_dfa_exec.c \
pcre_exec.c \
pcre_fullinfo.c \
pcre_get.c \
pcre_globals.c \
pcre_internal.h \
pcre_jit_compile.c \
pcre_maketables.c \
pcre_newline.c \
pcre_ord2utf8.c \
pcre_refcount.c \
pcre_string_utils.c \
pcre_study.c \
pcre_tables.c \
pcre_ucd.c \
pcre_valid_utf8.c \
pcre_version.c \
pcre_xclass.c \
ucp.h
libpcre_la_CFLAGS = \
$(VISIBILITY_CFLAGS) \
$(AM_CFLAGS)
libpcre_la_LIBADD =
## This file is generated as part of the building process, so don't distribute.
nodist_libpcre_la_SOURCES = \
pcre_chartables.c
endif # WITH_PCRE8
# Build the 16 bit library if it is enabled.
if WITH_PCRE16
lib_LTLIBRARIES += libpcre16.la
libpcre16_la_SOURCES = \
pcre16_byte_order.c \
pcre16_chartables.c \
pcre16_compile.c \
pcre16_config.c \
pcre16_dfa_exec.c \
pcre16_exec.c \
pcre16_fullinfo.c \
pcre16_get.c \
pcre16_globals.c \
pcre16_jit_compile.c \
pcre16_maketables.c \
pcre16_newline.c \
pcre16_ord2utf16.c \
pcre16_refcount.c \
pcre16_string_utils.c \
pcre16_study.c \
pcre16_tables.c \
pcre16_ucd.c \
pcre16_utf16_utils.c \
pcre16_valid_utf16.c \
pcre16_version.c \
pcre16_xclass.c
libpcre16_la_CFLAGS = \
$(VISIBILITY_CFLAGS) \
$(AM_CFLAGS)
libpcre16_la_LIBADD =
## This file is generated as part of the building process, so don't distribute.
nodist_libpcre16_la_SOURCES = \
pcre_chartables.c
endif # WITH_PCRE16
# Build the 32 bit library if it is enabled.
if WITH_PCRE32
lib_LTLIBRARIES += libpcre32.la
libpcre32_la_SOURCES = \
pcre32_byte_order.c \
pcre32_chartables.c \
pcre32_compile.c \
pcre32_config.c \
pcre32_dfa_exec.c \
pcre32_exec.c \
pcre32_fullinfo.c \
pcre32_get.c \
pcre32_globals.c \
pcre32_jit_compile.c \
pcre32_maketables.c \
pcre32_newline.c \
pcre32_ord2utf32.c \
pcre32_refcount.c \
pcre32_string_utils.c \
pcre32_study.c \
pcre32_tables.c \
pcre32_ucd.c \
pcre32_utf32_utils.c \
pcre32_valid_utf32.c \
pcre32_version.c \
pcre32_xclass.c
libpcre32_la_CFLAGS = \
$(VISIBILITY_CFLAGS) \
$(AM_CFLAGS)
libpcre32_la_LIBADD =
## This file is generated as part of the building process, so don't distribute.
nodist_libpcre32_la_SOURCES = \
pcre_chartables.c
endif # WITH_PCRE32
# The pcre_chartables.c.dist file is the default version of pcre_chartables.c,
# used unless --enable-rebuild-chartables is specified.
EXTRA_DIST += pcre_chartables.c.dist
# The JIT compiler lives in a separate directory, but its files are #included
# when pcre_jit_compile.c is processed, so they must be distributed.
EXTRA_DIST += \
sljit/sljitConfig.h \
sljit/sljitConfigInternal.h \
sljit/sljitExecAllocator.c \
sljit/sljitLir.c \
sljit/sljitLir.h \
sljit/sljitNativeARM_32.c \
sljit/sljitNativeARM_64.c \
sljit/sljitNativeARM_T2_32.c \
sljit/sljitNativeMIPS_32.c \
sljit/sljitNativeMIPS_64.c \
sljit/sljitNativeMIPS_common.c \
sljit/sljitNativePPC_32.c \
sljit/sljitNativePPC_64.c \
sljit/sljitNativePPC_common.c \
sljit/sljitNativeSPARC_32.c \
sljit/sljitNativeSPARC_common.c \
sljit/sljitNativeTILEGX_64.c \
sljit/sljitNativeTILEGX-encoder.c \
sljit/sljitNativeX86_32.c \
sljit/sljitNativeX86_64.c \
sljit/sljitNativeX86_common.c \
sljit/sljitUtils.c
if WITH_PCRE8
libpcre_la_LDFLAGS = $(EXTRA_LIBPCRE_LDFLAGS)
endif # WITH_PCRE8
if WITH_PCRE16
libpcre16_la_LDFLAGS = $(EXTRA_LIBPCRE16_LDFLAGS)
endif # WITH_PCRE16
if WITH_PCRE32
libpcre32_la_LDFLAGS = $(EXTRA_LIBPCRE32_LDFLAGS)
endif # WITH_PCRE32
if WITH_VALGRIND
if WITH_PCRE8
libpcre_la_CFLAGS += $(VALGRIND_CFLAGS)
endif # WITH_PCRE8
if WITH_PCRE16
libpcre16_la_CFLAGS += $(VALGRIND_CFLAGS)
endif # WITH_PCRE16
if WITH_PCRE32
libpcre32_la_CFLAGS += $(VALGRIND_CFLAGS)
endif # WITH_PCRE32
endif # WITH_VALGRIND
if WITH_GCOV
if WITH_PCRE8
libpcre_la_CFLAGS += $(GCOV_CFLAGS)
endif # WITH_PCRE8
if WITH_PCRE16
libpcre16_la_CFLAGS += $(GCOV_CFLAGS)
endif # WITH_PCRE16
if WITH_PCRE32
libpcre32_la_CFLAGS += $(GCOV_CFLAGS)
endif # WITH_PCRE32
endif # WITH_GCOV
CLEANFILES += pcre_chartables.c
## If JIT support is enabled, arrange for the JIT test program to run.
if WITH_JIT
TESTS += pcre_jit_test
noinst_PROGRAMS += pcre_jit_test
pcre_jit_test_SOURCES = pcre_jit_test.c
pcre_jit_test_CFLAGS = $(AM_CFLAGS)
pcre_jit_test_LDADD =
if WITH_PCRE8
pcre_jit_test_LDADD += libpcre.la
endif # WITH_PCRE8
if WITH_PCRE16
pcre_jit_test_LDADD += libpcre16.la
endif # WITH_PCRE16
if WITH_PCRE32
pcre_jit_test_LDADD += libpcre32.la
endif # WITH_PCRE32
if WITH_GCOV
pcre_jit_test_CFLAGS += $(GCOV_CFLAGS)
pcre_jit_test_LDADD += $(GCOV_LIBS)
endif # WITH_GCOV
endif # WITH_JIT
## A version of the main pcre library that has a posix re API.
if WITH_PCRE8
lib_LTLIBRARIES += libpcreposix.la
libpcreposix_la_SOURCES = \
pcreposix.c
libpcreposix_la_CFLAGS = $(VISIBILITY_CFLAGS) $(AM_CFLAGS)
libpcreposix_la_LDFLAGS = $(EXTRA_LIBPCREPOSIX_LDFLAGS)
libpcreposix_la_LIBADD = libpcre.la
if WITH_GCOV
libpcreposix_la_CFLAGS += $(GCOV_CFLAGS)
endif # WITH_GCOV
endif # WITH_PCRE8
## There's a C++ library as well.
if WITH_PCRE_CPP
lib_LTLIBRARIES += libpcrecpp.la
libpcrecpp_la_SOURCES = \
pcrecpp_internal.h \
pcrecpp.cc \
pcre_scanner.cc \
pcre_stringpiece.cc
libpcrecpp_la_CXXFLAGS = $(VISIBILITY_CXXFLAGS) $(AM_CXXFLAGS)
libpcrecpp_la_LDFLAGS = $(EXTRA_LIBPCRECPP_LDFLAGS)
libpcrecpp_la_LIBADD = libpcre.la
TESTS += pcrecpp_unittest
noinst_PROGRAMS += pcrecpp_unittest
pcrecpp_unittest_SOURCES = pcrecpp_unittest.cc
pcrecpp_unittest_CXXFLAGS = $(AM_CXXFLAGS)
pcrecpp_unittest_LDADD = libpcrecpp.la
TESTS += pcre_scanner_unittest
noinst_PROGRAMS += pcre_scanner_unittest
pcre_scanner_unittest_SOURCES = pcre_scanner_unittest.cc
pcre_scanner_unittest_CXXFLAGS = $(AM_CXXFLAGS)
pcre_scanner_unittest_LDADD = libpcrecpp.la
TESTS += pcre_stringpiece_unittest
noinst_PROGRAMS += pcre_stringpiece_unittest
pcre_stringpiece_unittest_SOURCES = pcre_stringpiece_unittest.cc
pcre_stringpiece_unittest_CXXFLAGS = $(AM_CXXFLAGS)
pcre_stringpiece_unittest_LDADD = libpcrecpp.la
if WITH_GCOV
libpcrecpp_la_CXXFLAGS += $(GCOV_CXXFLAGS)
pcrecpp_unittest_LDADD += $(GCOV_LIBS)
pcre_scanner_unittest_LDADD += $(GCOV_LIBS)
pcre_stringpiece_unittest_LDADD += $(GCOV_LIBS)
endif # WITH_GCOV
endif # WITH_PCRE_CPP
## The main unit tests
# 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.
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 += pcre_printint.c
pcretest_LDADD += libpcre.la libpcreposix.la
endif # WITH_PCRE8
if WITH_PCRE16
pcretest_SOURCES += pcre16_printint.c
pcretest_LDADD += libpcre16.la
endif # WITH_PCRE16
if WITH_PCRE32
pcretest_SOURCES += pcre32_printint.c
pcretest_LDADD += libpcre32.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
TESTS += RunGrepTest
dist_noinst_SCRIPTS += RunGrepTest
bin_PROGRAMS += pcregrep
pcregrep_SOURCES = pcregrep.c
pcregrep_CFLAGS = $(AM_CFLAGS)
pcregrep_LDADD = $(LIBZ) $(LIBBZ2)
pcregrep_LDADD += libpcre.la libpcreposix.la
if WITH_GCOV
pcregrep_CFLAGS += $(GCOV_CFLAGS)
pcregrep_LDADD += $(GCOV_LIBS)
endif # WITH_GCOV
endif # WITH_PCRE8
EXTRA_DIST += \
testdata/grepbinary \
testdata/grepfilelist \
testdata/grepinput \
testdata/grepinput3 \
testdata/grepinput8 \
testdata/grepinputv \
testdata/grepinputx \
testdata/greplist \
testdata/grepoutput \
testdata/grepoutput8 \
testdata/grepoutputN \
testdata/greppatN4 \
testdata/saved16 \
testdata/saved16BE-1 \
testdata/saved16BE-2 \
testdata/saved16LE-1 \
testdata/saved16LE-2 \
testdata/saved32 \
testdata/saved32BE-1 \
testdata/saved32BE-2 \
testdata/saved32LE-1 \
testdata/saved32LE-2 \
testdata/saved8 \
testdata/testinput1 \
testdata/testinput2 \
testdata/testinput3 \
testdata/testinput4 \
testdata/testinput5 \
testdata/testinput6 \
testdata/testinput7 \
testdata/testinput8 \
testdata/testinput9 \
testdata/testinput10 \
testdata/testinput11 \
testdata/testinput12 \
testdata/testinput13 \
testdata/testinput14 \
testdata/testinput15 \
testdata/testinput16 \
testdata/testinput17 \
testdata/testinput18 \
testdata/testinput19 \
testdata/testinput20 \
testdata/testinput21 \
testdata/testinput22 \
testdata/testinput23 \
testdata/testinput24 \
testdata/testinput25 \
testdata/testinput26 \
testdata/testinputEBC \
testdata/testoutput1 \
testdata/testoutput2 \
testdata/testoutput3 \
testdata/testoutput3A \
testdata/testoutput3B \
testdata/testoutput4 \
testdata/testoutput5 \
testdata/testoutput6 \
testdata/testoutput7 \
testdata/testoutput8 \
testdata/testoutput9 \
testdata/testoutput10 \
testdata/testoutput11-8 \
testdata/testoutput11-16 \
testdata/testoutput11-32 \
testdata/testoutput12 \
testdata/testoutput13 \
testdata/testoutput14 \
testdata/testoutput15 \
testdata/testoutput16 \
testdata/testoutput17 \
testdata/testoutput18-16 \
testdata/testoutput18-32 \
testdata/testoutput19 \
testdata/testoutput20 \
testdata/testoutput21-16 \
testdata/testoutput21-32 \
testdata/testoutput22-16 \
testdata/testoutput22-32 \
testdata/testoutput23 \
testdata/testoutput24 \
testdata/testoutput25 \
testdata/testoutput26 \
testdata/testoutputEBC \
testdata/wintestinput3 \
testdata/wintestoutput3 \
perltest.pl
CLEANFILES += \
testsavedregex \
teststderr \
testtemp* \
testtry \
testNinput \
testtrygrep \
teststderrgrep \
testNinputgrep
# PCRE demonstration program. No longer built automatcally. The point is that
# the users should build it themselves. So just distribute the source.
# noinst_PROGRAMS += pcredemo
# pcredemo_SOURCES = pcredemo.c
# pcredemo_LDADD = libpcre.la
EXTRA_DIST += pcredemo.c
## Utility rules, documentation, etc.
# A compatibility line, the old build system worked with 'make test'
test: check ;
# A PCRE user submitted the following addition, saying that it "will allow
# anyone using the 'mingw32' compiler to simply type 'make pcre.dll' and get a
# nice DLL for Windows use". (It is used by the pcre.dll target.)
DLL_OBJS= pcre_byte_order.o pcre_compile.o pcre_config.o \
pcre_dfa_exec.o pcre_exec.o pcre_fullinfo.o pcre_get.o \
pcre_globals.o pcre_jit_compile.o pcre_maketables.o \
pcre_newline.o pcre_ord2utf8.o pcre_refcount.o \
pcre_study.o pcre_tables.o pcre_ucd.o \
pcre_valid_utf8.o pcre_version.o pcre_chartables.o \
pcre_xclass.o
# A PCRE user submitted the following addition, saying that it "will allow
# anyone using the 'mingw32' compiler to simply type 'make pcre.dll' and get a
# nice DLL for Windows use".
pcre.dll: $(DLL_OBJS)
$(CC) -shared -o pcre.dll -Wl,"--strip-all" -Wl,"--export-all-symbols" $(DLL_OBJS)
# We have .pc files for pkg-config users.
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libpcre.pc libpcreposix.pc
if WITH_PCRE16
pkgconfig_DATA += libpcre16.pc
endif
if WITH_PCRE32
pkgconfig_DATA += libpcre32.pc
endif
if WITH_PCRE_CPP
pkgconfig_DATA += libpcrecpp.pc
endif
# Note that pcrecpp.3 is not in this list, but is included separately below.
dist_man_MANS = \
doc/pcre-config.1 \
doc/pcre.3 \
doc/pcre16.3 \
doc/pcre32.3 \
doc/pcre_assign_jit_stack.3 \
doc/pcre_compile.3 \
doc/pcre_compile2.3 \
doc/pcre_config.3 \
doc/pcre_copy_named_substring.3 \
doc/pcre_copy_substring.3 \
doc/pcre_dfa_exec.3 \
doc/pcre_exec.3 \
doc/pcre_free_study.3 \
doc/pcre_free_substring.3 \
doc/pcre_free_substring_list.3 \
doc/pcre_fullinfo.3 \
doc/pcre_get_named_substring.3 \
doc/pcre_get_stringnumber.3 \
doc/pcre_get_stringtable_entries.3 \
doc/pcre_get_substring.3 \
doc/pcre_get_substring_list.3 \
doc/pcre_jit_exec.3 \
doc/pcre_jit_stack_alloc.3 \
doc/pcre_jit_stack_free.3 \
doc/pcre_maketables.3 \
doc/pcre_pattern_to_host_byte_order.3 \
doc/pcre_refcount.3 \
doc/pcre_study.3 \
doc/pcre_utf16_to_host_byte_order.3 \
doc/pcre_utf32_to_host_byte_order.3 \
doc/pcre_version.3 \
doc/pcreapi.3 \
doc/pcrebuild.3 \
doc/pcrecallout.3 \
doc/pcrecompat.3 \
doc/pcredemo.3 \
doc/pcregrep.1 \
doc/pcrejit.3 \
doc/pcrelimits.3 \
doc/pcrematching.3 \
doc/pcrepartial.3 \
doc/pcrepattern.3 \
doc/pcreperform.3 \
doc/pcreposix.3 \
doc/pcreprecompile.3 \
doc/pcresample.3 \
doc/pcrestack.3 \
doc/pcresyntax.3 \
doc/pcretest.1 \
doc/pcreunicode.3
# 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
pcrecpp_man = doc/pcrecpp.3
EXTRA_DIST += $(pcrecpp_man)
if WITH_PCRE_CPP
man_MANS = $(pcrecpp_man)
endif
# gcov/lcov code coverage reporting
if WITH_GCOV
# Coverage reporting targets:
#
# coverage: Create a coverage report from 'make check'
# coverage-baseline: Capture baseline coverage information
# coverage-reset: This zeros the coverage counters only
# coverage-report: This creates the coverage report only
# coverage-clean-report: This removes the generated coverage report
# without cleaning the coverage data itself
# coverage-clean-data: This removes the captured coverage data without
# removing the coverage files created at compile time (*.gcno)
# coverage-clean: This cleans all coverage data including the generated
# coverage report.
COVERAGE_TEST_NAME = $(PACKAGE)
COVERAGE_NAME = $(PACKAGE)-$(VERSION)
COVERAGE_OUTPUT_FILE = $(COVERAGE_NAME)-coverage.info
COVERAGE_OUTPUT_DIR = $(COVERAGE_NAME)-coverage
COVERAGE_LCOV_EXTRA_FLAGS =
COVERAGE_GENHTML_EXTRA_FLAGS =
coverage_quiet = $(coverage_quiet_$(V))
coverage_quiet_ = $(coverage_quiet_$(AM_DEFAULT_VERBOSITY))
coverage_quiet_0 = --quiet
coverage-check: all
-$(MAKE) $(AM_MAKEFLAGS) -k check
coverage-baseline:
$(LCOV) $(coverage_quiet) \
--directory $(top_builddir) \
--output-file "$(COVERAGE_OUTPUT_FILE)" \
--capture \
--initial
coverage-report:
$(LCOV) $(coverage_quiet) \
--directory $(top_builddir) \
--capture \
--output-file "$(COVERAGE_OUTPUT_FILE).tmp" \
--test-name "$(COVERAGE_TEST_NAME)" \
--no-checksum \
--compat-libtool \
$(COVERAGE_LCOV_EXTRA_FLAGS)
$(LCOV) $(coverage_quiet) \
--directory $(top_builddir) \
--output-file "$(COVERAGE_OUTPUT_FILE)" \
--remove "$(COVERAGE_OUTPUT_FILE).tmp" \
"/tmp/*" \
"/usr/include/*" \
"$(includedir)/*"
-@rm -f "$(COVERAGE_OUTPUT_FILE).tmp"
LANG=C $(GENHTML) $(coverage_quiet) \
--prefix $(top_builddir) \
--output-directory "$(COVERAGE_OUTPUT_DIR)" \
--title "$(PACKAGE) $(VERSION) Code Coverage Report" \
--show-details "$(COVERAGE_OUTPUT_FILE)" \
--legend \
$(COVERAGE_GENHTML_EXTRA_FLAGS)
@echo "Code coverage report written to file://$(abs_builddir)/$(COVERAGE_OUTPUT_DIR)/index.html"
coverage-reset:
-$(LCOV) $(coverage_quiet) --zerocounters --directory $(top_builddir)
coverage-clean-report:
-rm -f "$(COVERAGE_OUTPUT_FILE)" "$(COVERAGE_OUTPUT_FILE).tmp"
-rm -rf "$(COVERAGE_OUTPUT_DIR)"
coverage-clean-data:
-find $(top_builddir) -name "*.gcda" -delete
coverage-clean: coverage-reset coverage-clean-report coverage-clean-data
-find $(top_builddir) -name "*.gcno" -delete
coverage-distclean: coverage-clean
coverage: coverage-reset coverage-baseline coverage-check coverage-report
clean-local: coverage-clean
distclean-local: coverage-distclean
.PHONY: coverage coverage-baseline coverage-check coverage-report coverage-reset coverage-clean-report coverage-clean-data coverage-clean coverage-distclean
else
coverage:
@echo "Configuring with --enable-coverage required to generate code coverage report."
endif # WITH_GCOV
## CMake support
EXTRA_DIST += \
cmake/COPYING-CMAKE-SCRIPTS \
cmake/FindPackageHandleStandardArgs.cmake \
cmake/FindReadline.cmake \
cmake/FindEditline.cmake \
CMakeLists.txt \
config-cmake.h.in
## end Makefile.am
pcre-8.38/pcre_stringpiece_unittest.cc 0000644 0002221 0002221 00000007025 12405567113 015115 0000000 0000000 // Copyright 2003 and onwards Google Inc.
// Author: Sanjay Ghemawat
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include