diff options
author | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2014-09-28 17:39:28 +0000 |
---|---|---|
committer | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2014-09-28 17:39:28 +0000 |
commit | f30ff3deb77413a8059cfe06dc6db30047e8dcde (patch) | |
tree | 73e5c69fb89a5edfc680ae9b23b8f819058e7c6d /doc/html | |
parent | 8ad769e3db843fd70ad105d2af2205a94c3b521e (diff) | |
download | pcre2-f30ff3deb77413a8059cfe06dc6db30047e8dcde.tar.gz |
More draft documentation.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@82 6239d852-aaf2-0410-a92c-79f79f948069
Diffstat (limited to 'doc/html')
-rw-r--r-- | doc/html/NON-AUTOTOOLS-BUILD.txt | 402 | ||||
-rw-r--r-- | doc/html/README.txt | 833 | ||||
-rw-r--r-- | doc/html/pcre2-config.html | 102 | ||||
-rw-r--r-- | doc/html/pcre2.html | 182 | ||||
-rw-r--r-- | doc/html/pcre2grep.html | 759 |
5 files changed, 2277 insertions, 1 deletions
diff --git a/doc/html/NON-AUTOTOOLS-BUILD.txt b/doc/html/NON-AUTOTOOLS-BUILD.txt new file mode 100644 index 0000000..6f36fe6 --- /dev/null +++ b/doc/html/NON-AUTOTOOLS-BUILD.txt @@ -0,0 +1,402 @@ +Building PCRE2 without using autotools +-------------------------------------- + +This document has been converted from the PCRE1 document, but is not yet +complete. I have removed a number of quite old sections about building in +various environments, as they applied only to PCRE1 and are probably out of +date. + + +This document contains the following sections: + + General + Generic instructions for the PCRE2 C library + Building for virtual Pascal + Stack size in Windows environments + Linking programs in Windows environments + Calling conventions in Windows environments + Comments about Win32 builds + Building PCRE2 on Windows with CMake + Testing with RunTest.bat + Building PCRE2 on native z/OS and z/VM + + +GENERAL + +I (Philip Hazel) have no experience of Windows or VMS sytems and how their +libraries work. The items in the PCRE2 distribution and Makefile that relate to +anything other than Linux systems are untested by me. + +The basic PCRE2 library consists entirely of code written in Standard C, and so +should compile successfully on any system that has a Standard C compiler and +library. + +The PCRE2 distribution includes a "configure" file for use by the +configure/make (autotools) build system, as found in many Unix-like +environments. The README file contains information about the options for +"configure". + +There is also support for CMake, which some users prefer, especially in Windows +environments, though it can also be run in Unix-like environments. See the +section entitled "Building PCRE2 on Windows with CMake" below. + +Versions of src/config.h and src/pcre2.h are distributed in the PCRE2 tarballs +under the names src/config.h.generic and src/pcre2.h.generic. These are +provided for those who build PCRE2 without using "configure" or CMake. If you +use "configure" or CMake, the .generic versions are not used. + + +GENERIC INSTRUCTIONS FOR THE PCRE2 C LIBRARY + +The following are generic instructions for building the PCRE2 C library "by +hand". If you are going to use CMake, this section does not apply to you; you +can skip ahead to the CMake section. + + (1) Copy or rename the file src/config.h.generic as src/config.h, and edit the + macro settings that it contains to whatever is appropriate for your + environment. In particular, you can alter the definition of the NEWLINE + macro to specify what character(s) you want to be interpreted as line + terminators. + + When you compile any of the PCRE2 modules, you must specify + -DHAVE_CONFIG_H to your compiler so that src/config.h is included in the + sources. + + An alternative approach is not to edit src/config.h, but to use -D on the + compiler command line to make any changes that you need to the + configuration options. In this case -DHAVE_CONFIG_H must not be set. + + NOTE: There have been occasions when the way in which certain parameters + in src/config.h are used has changed between releases. (In the + configure/make world, this is handled automatically.) When upgrading to a + new release, you are strongly advised to review src/config.h.generic + before re-using what you had previously. + + (2) Copy or rename the file src/pcre2.h.generic as src/pcre2.h. + + (3) EITHER: + Copy or rename file src/pcre2_chartables.c.dist as + src/pcre2_chartables.c. + + OR: + Compile src/dftables.c as a stand-alone program (using -DHAVE_CONFIG_H + if you have set up src/config.h), and then run it with the single + argument "src/pcre2_chartables.c". This generates a set of standard + character tables and writes them to that file. The tables are generated + using the default C locale for your system. If you want to use a locale + that is specified by LC_xxx environment variables, add the -L option to + the dftables command. You must use this method if you are building on a + system that uses EBCDIC code. + + The tables in src/pcre2_chartables.c are defaults. The caller of PCRE2 can + specify alternative tables at run time. + + (4) For an 8-bit library, compile the following source files, setting + -DPCRE2_CODE_UNIT_WIDTH=8 as a compiler option. Also set -DHAVE_CONFIG_H + if you have set up src/config.h with your configuration, or else use other + -D settings to change the configuration as required. + + pcre2_auto_possess.c + pcre2_chartables.c + pcre2_compile.c + pcre2_config.c + pcre2_context.c + pcre2_dfa_match.c + pcre2_error.c + pcre2_jit_compile.c + pcre2_jit_match.c + pcre2_jit_misc.c + pcre2_maketables.c + pcre2_match.c + pcre2_match_data.c + pcre2_newline.c + pcre2_ord2utf.c + pcre2_pattern_info.c + pcre2_string_utils.c + pcre2_study.c + pcre2_substring.c + pcre2_tables.c + pcre2_ucd.c + pcre2_valid_utf.c + pcre2_xclass.c + + Make sure that you include -I. in the compiler command (or equivalent for + an unusual compiler) so that all included PCRE2 header files are first + sought in the src directory under the current directory. Otherwise you run + the risk of picking up a previously-installed file from somewhere else. + + Note that you must compile pcre2_jit_xxx.c, even if you have not defined + SUPPORT_JIT in src/config.h, because when JIT support is not configured, + dummy functions are compiled. When JIT support IS configured, the JIT + sources #include other files from the sljit subdirectory, where there + should be 16 files, all of whose names begin with "sljit". + + (5) Now link all the compiled code into an object library in whichever form + your system keeps such libraries. This is the basic PCRE2 C 8-bit library. + If your system has static and shared libraries, you may have to do this + once for each type. + + (6) If you want to build a 16-bit library or 32-bit library (as well as, or + instead of the 8-bit library) just supply 16 or 32 as the value of + -DPCRE2_CODE_UNIT_WIDTH when you are compiling. + + (7) If you want to build the POSIX wrapper functions (which apply only to the + 8-bit library), ensure that you have the pcre2posix.h file and then + compile pcre2posix.c. Link the result (on its own) as the pcre2posix + library. + + (8) The pcre2test program can be linked with any combination of the 8-bit, + 16-bit and 32-bit libraries (depending on what you selected in + src/config.h). Compile pcre2test.c; don't forget -DHAVE_CONFIG_H if + necessary, but do NOT define PCRE2_CODE_UNIT_WIDTH. Then link with the + appropriate library/ies. If you compiled an 8-bit library, pcre2test also + needs the pcre2posix wrapper library. + + (9) Run pcre2test on the testinput files in the testdata directory, and check + that the output matches the corresponding testoutput files. There are + comments about what each test does in the section entitled "Testing PCRE2" + in the README file. If you compiled more than one of the 8-bit, 16-bit and + 32-bit libraries, you need to run pcre2test with the -16 option to do + 16-bit tests and with the -32 option to do 32-bit tests. + + Some tests are relevant only when certain build-time options are selected. + For example, test 4 is for Unicode support, and will not run if you have + built PCRE2 without it. See the comments at the start of each testinput + file. If you have a suitable Unix-like shell, the RunTest script will run + the appropriate tests for you. The command "RunTest list" will output a + list of all the tests. + + Note that the supplied files are in Unix format, with just LF characters + as line terminators. You may need to edit them to change this if your + system uses a different convention. + +(10) If you have built PCRE2 with SUPPORT_JIT, the JIT features can be tested + by running pcre2test with the -jit option. This is done automatically by + the RunTest script. You might also like to build and run the freestanding + JIT test program, pcre2_jit_test.c. + +(11) If you want to use the pcre2grep command, compile and link pcre2grep.c; it + uses only the basic 8-bit PCRE2 library (it does not need the pcre2posix + library). + + +BUILDING FOR VIRTUAL PASCAL + +FIXME FOR PCRE2 + +A script for building PCRE2 using Borland's C++ compiler for use with VPASCAL +was contributed by Alexander Tokarev. Stefan Weber updated the script and added +additional files. The following files in the distribution are for building +PCRE2 for use with VP/Borland: makevp_c.txt, makevp_l.txt, makevp.bat, +pcre2gexp.pas. + + +STACK SIZE IN WINDOWS ENVIRONMENTS + +The default processor stack size of 1Mb in some Windows environments is too +small for matching patterns that need much recursion. In particular, test 2 may +fail because of this. Normally, running out of stack causes a crash, but there +have been cases where the test program has just died silently. See your linker +documentation for how to increase stack size if you experience problems. The +Linux default of 8Mb is a reasonable choice for the stack, though even that can +be too small for some pattern/subject combinations. + +PCRE2 has a compile configuration option to disable the use of stack for +recursion so that heap is used instead. However, pattern matching is +significantly slower when this is done. There is more about stack usage in the +"pcre2stack" documentation. + + +LINKING PROGRAMS IN WINDOWS ENVIRONMENTS + +If you want to statically link a program against a PCRE2 library in the form of +a non-dll .a file, you must define PCRE2_STATIC before including src/pcre2.h. + + +CALLING CONVENTIONS IN WINDOWS ENVIRONMENTS + +It is possible to compile programs to use different calling conventions using +MSVC. Search the web for "calling conventions" for more information. To make it +easier to change the calling convention for the exported functions in the +PCRE2 library, the macro PCRE2_CALL_CONVENTION is present in all the external +definitions. It can be set externally when compiling (e.g. in CFLAGS). If it is +not set, it defaults to empty; the default calling convention is then used +(which is what is wanted most of the time). + + +COMMENTS ABOUT WIN32 BUILDS (see also "BUILDING PCRE2 ON WINDOWS WITH CMAKE") + +There are two ways of building PCRE2 using the "configure, make, make install" +paradigm on Windows systems: using MinGW or using Cygwin. These are not at all +the same thing; they are completely different from each other. There is also +support for building using CMake, which some users find a more straightforward +way of building PCRE2 under Windows. + +The MinGW home page (http://www.mingw.org/) says this: + + MinGW: A collection of freely available and freely distributable Windows + specific header files and import libraries combined with GNU toolsets that + allow one to produce native Windows programs that do not rely on any + 3rd-party C runtime DLLs. + +The Cygwin home page (http://www.cygwin.com/) says this: + + Cygwin is a Linux-like environment for Windows. It consists of two parts: + + . A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing + substantial Linux API functionality + + . A collection of tools which provide Linux look and feel. + +On both MinGW and Cygwin, PCRE2 should build correctly using: + + ./configure && make && make install + +This should create two libraries called libpcre2-8 and libpcre2-posix. These +are independent libraries: when you link with libpcre2-posix you must also link +with libpcre2-8, which contains the basic functions. + +Using Cygwin's compiler generates libraries and executables that depend on +cygwin1.dll. If a library that is generated this way is distributed, +cygwin1.dll has to be distributed as well. Since cygwin1.dll is under the GPL +licence, this forces not only PCRE2 to be under the GPL, but also the entire +application. A distributor who wants to keep their own code proprietary must +purchase an appropriate Cygwin licence. + +MinGW has no such restrictions. The MinGW compiler generates a library or +executable that can run standalone on Windows without any third party dll or +licensing issues. + +But there is more complication: + +If a Cygwin user uses the -mno-cygwin Cygwin gcc flag, what that really does is +to tell Cygwin's gcc to use the MinGW gcc. Cygwin's gcc is only acting as a +front end to MinGW's gcc (if you install Cygwin's gcc, you get both Cygwin's +gcc and MinGW's gcc). So, a user can: + +. Build native binaries by using MinGW or by getting Cygwin and using + -mno-cygwin. + +. Build binaries that depend on cygwin1.dll by using Cygwin with the normal + compiler flags. + +The test files that are supplied with PCRE2 are in UNIX format, with LF +characters as line terminators. Unless your PCRE2 library uses a default +newline option that includes LF as a valid newline, it may be necessary to +change the line terminators in the test files to get some of the tests to work. + + +BUILDING PCRE2 ON WINDOWS WITH CMAKE + +CMake is an alternative configuration facility that can be used instead of +"configure". CMake creates project files (make files, solution files, etc.) +tailored to numerous development environments, including Visual Studio, +Borland, Msys, MinGW, NMake, and Unix. If possible, use short paths with no +spaces in the names for your CMake installation and your PCRE2 source and build +directories. + +The following instructions were contributed by a PCRE1 user, but they should +also work for PCRE2. If they are not followed exactly, errors may occur. In the +event that errors do occur, it is recommended that you delete the CMake cache +before attempting to repeat the CMake build process. In the CMake GUI, the +cache can be deleted by selecting "File > Delete Cache". + +1. Install the latest CMake version available from http://www.cmake.org/, and + ensure that cmake\bin is on your path. + +2. Unzip (retaining folder structure) the PCRE2 source tree into a source + directory such as C:\pcre2. You should ensure your local date and time + is not earlier than the file dates in your source dir if the release is + very new. + +3. Create a new, empty build directory, preferably a subdirectory of the + source dir. For example, C:\pcre2\pcre2-xx\build. + +4. Run cmake-gui from the Shell envirornment of your build tool, for example, + Msys for Msys/MinGW or Visual Studio Command Prompt for VC/VC++. Do not try + to start Cmake from the Windows Start menu, as this can lead to errors. + +5. Enter C:\pcre2\pcre2-xx and C:\pcre2\pcre2-xx\build for the source and + build directories, respectively. + +6. Hit the "Configure" button. + +7. Select the particular IDE / build tool that you are using (Visual + Studio, MSYS makefiles, MinGW makefiles, etc.) + +8. The GUI will then list several configuration options. This is where + you can enable Unicode support or other PCRE2 optional features. + +9. Hit "Configure" again. The adjacent "Generate" button should now be + active. + +10. Hit "Generate". + +11. The build directory should now contain a usable build system, be it a + solution file for Visual Studio, makefiles for MinGW, etc. Exit from + cmake-gui and use the generated build system with your compiler or IDE. + E.g., for MinGW you can run "make", or for Visual Studio, open the PCRE2 + solution, select the desired configuration (Debug, or Release, etc.) and + build the ALL_BUILD project. + +12. If during configuration with cmake-gui you've elected to build the test + programs, you can execute them by building the test project. E.g., for + MinGW: "make check"; for Visual Studio build the RUN_TESTS project. The + most recent build configuration is targeted by the tests. A summary of + test results is presented. Complete test output is subsequently + available for review in Testing\Temporary under your build dir. + + +TESTING WITH RUNTEST.BAT FIXME FIXME NOT YET TESTED/UPDATED FIXME + +If configured with CMake, building the test project ("make check" or building +ALL_TESTS in Visual Studio) creates (and runs) pcre2_test.bat (and depending +on your configuration options, possibly other test programs) in the build +directory. Pcre_test.bat runs RunTest.Bat with correct source and exe paths. + +For manual testing with RunTest.bat, provided the build dir is a subdirectory +of the source directory: Open command shell window. Chdir to the location +of your pcre2test.exe and pcre2grep.exe programs. Call RunTest.bat with +"..\RunTest.Bat" or "..\..\RunTest.bat" as appropriate. + +To run only a particular test with RunTest.Bat provide a test number argument. + +Otherwise: + +1. Copy RunTest.bat into the directory where pcre2test.exe and pcre2grep.exe + have been created. + +2. Edit RunTest.bat to indentify the full or relative location of + the pcre2 source (wherein which the testdata folder resides), e.g.: + + set srcdir=C:\pcre2\pcre2-10.00 + +3. In a Windows command environment, chdir to the location of your bat and + exe programs. + +4. Run RunTest.bat. Test outputs will automatically be compared to expected + results, and discrepancies will be identified in the console output. + +To independently test the just-in-time compiler, run pcre2_jit_test.exe. + + +BUILDING PCRE2 ON NATIVE Z/OS AND Z/VM + +z/OS and z/VM are operating systems for mainframe computers, produced by IBM. +The character code used is EBCDIC, not ASCII or Unicode. In z/OS, UNIX APIs and +applications can be supported through UNIX System Services, and in such an +environment PCRE2 can be built in the same way as in other systems. However, in +native z/OS (without UNIX System Services) and in z/VM, special ports are +required. For details, please see this web site: + + http://www.zaconsultants.net + +There is also a mirror here: + + http://www.vsoft-software.com/downloads.html + +The site currently has ports for PCRE1 releases, but PCRE2 should follow in due +course. + +========================== +Last Updated: 28 September 2014 diff --git a/doc/html/README.txt b/doc/html/README.txt index 7ad597a..95c8747 100644 --- a/doc/html/README.txt +++ b/doc/html/README.txt @@ -1 +1,832 @@ -This is a placeholder README file for a work in progress. +README file for PCRE2 (Perl-compatible regular expression library) +------------------------------------------------------------------ + +PCRE2 is a re-implementation of the original PCRE library with an entirely new +API. The latest release of PCRE2 is always available in three alternative +formats from: + +FIXME: THIS WILL NOT BE THE CASE UNTIL THERE IS A FORMAL RELEASE. + + ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre2/pcre2-xxx.tar.gz + ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre2/pcre2-xxx.tar.bz2 + ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre2/pcre2-xxx.zip + +There is a mailing list for discussion about the development of PCRE (both the +original and new APIs) at pcre-dev@exim.org. You can access the archives and +subscribe or manage your subscription here: + + https://lists.exim.org/mailman/listinfo/pcre-dev + +Please read the NEWS file if you are upgrading from a previous release. +The contents of this README file are: + + The PCRE2 APIs + Documentation for PCRE2 + Contributions by users of PCRE2 + Building PCRE2 on non-Unix-like systems + Building PCRE2 without using autotools + Building PCRE2 using autotools + Retrieving configuration information + Shared libraries + Cross-compiling using autotools + Making new tarballs + Testing PCRE2 + Character tables + File manifest + + +The PCRE2 APIs +-------------- + +PCRE2 is written in C, and it has its own API. There are three sets of +functions, one for the 8-bit library, which processes strings of bytes, one for +the 16-bit library, which processes strings of 16-bit values, and one for the +32-bit library, which processes strings of 32-bit values. As this is a new API, +there as yet no C++ wrappers. + +The distribution does contain a set of C wrapper functions for the 8-bit +library that are based on the POSIX regular expression API (see the pcre2posix +man page). These end up in the library called libpcre2posix. Note that this +just provides a POSIX calling interface to PCRE2; the regular expressions +themselves still follow Perl syntax and semantics. The POSIX API is restricted, +and does not give full access to all of PCRE2's facilities. + +The header file for the POSIX-style functions is called pcre2posix.h. The +official POSIX name is regex.h, but I did not want to risk possible problems +with existing files of that name by distributing it that way. To use PCRE2 with +an existing program that uses the POSIX API, pcre2posix.h will have to be +renamed or pointed at by a link. + +If you are using the POSIX interface to PCRE2 and there is already a POSIX +regex library installed on your system, as well as worrying about the regex.h +header file (as mentioned above), you must also take care when linking programs +to ensure that they link with PCRE2's libpcre2posix library. Otherwise they may +pick up the POSIX functions of the same name from the other library. + +One way of avoiding this confusion is to compile PCRE2 with the addition of +-Dregcomp=PCRE2regcomp (and similarly for the other POSIX functions) to the +compiler flags (CFLAGS if you are using "configure" -- see below). This has the +effect of renaming the functions so that the names no longer clash. Of course, +you have to do the same thing for your applications, or write them using the +new names. + + +Documentation for PCRE2 +---------------------- + +If you install PCRE2 in the normal way on a Unix-like system, you will end up +with a set of man pages whose names all start with "pcre2". The one that is +just called "pcre2" lists all the others. In addition to these man pages, the +PCRE2 documentation is supplied in two other forms: + + 1. There are files called doc/pcre2.txt, doc/pcre2grep.txt, and + doc/pcre2test.txt in the source distribution. The first of these is a + concatenation of the text forms of all the section 3 man pages except the + listing of pcre2demo.c and those that summarize individual functions. The + other two are the text forms of the section 1 man pages for the pcre2grep + and pcre2test commands. These text forms are provided for ease of scanning + with text editors or similar tools. They are installed in + <prefix>/share/doc/pcre2, where <prefix> is the installation prefix + (defaulting to /usr/local). + + 2. A set of files containing all the documentation in HTML form, hyperlinked + in various ways, and rooted in a file called index.html, is distributed in + doc/html and installed in <prefix>/share/doc/pcre2/html. + + +Building PCRE2 on non-Unix-like systems +-------------------------------------- + +For a non-Unix-like system, please read the comments in the file +NON-AUTOTOOLS-BUILD, though if your system supports the use of "configure" and +"make" you may be able to build PCRE2 using autotools in the same way as for +many Unix-like systems. + +PCRE2 can also be configured using CMake, which can be run in various ways +(command line, GUI, etc). This creates Makefiles, solution files, etc. The file +NON-AUTOTOOLS-BUILD has information about CMake. + +PCRE2 has been compiled on many different operating systems. It should be +straightforward to build PCRE2 on any system that has a Standard C compiler and +library, because it uses only Standard C functions. + + +Building PCRE2 without using autotools +------------------------------------- + +The use of autotools (in particular, libtool) is problematic in some +environments, even some that are Unix or Unix-like. See the NON-AUTOTOOLS-BUILD +file for ways of building PCRE2 without using autotools. + + +Building PCRE2 using autotools +----------------------------- + +The following instructions assume the use of the widely used "configure; make; +make install" (autotools) process. + +To build PCRE2 on system that supports autotools, first run the "configure" +command from the PCRE2 distribution directory, with your current directory set +to the directory where you want the files to be created. This command is a +standard GNU "autoconf" configuration script, for which generic instructions +are supplied in the file INSTALL. + +Most commonly, people build PCRE2 within its own distribution directory, and in +this case, on many systems, just running "./configure" is sufficient. However, +the usual methods of changing standard defaults are available. For example: + +CFLAGS='-O2 -Wall' ./configure --prefix=/opt/local + +This command specifies that the C compiler should be run with the flags '-O2 +-Wall' instead of the default, and that "make install" should install PCRE2 +under /opt/local instead of the default /usr/local. + +If you want to build in a different directory, just run "configure" with that +directory as current. For example, suppose you have unpacked the PCRE2 source +into /source/pcre2/pcre2-xxx, but you want to build it in +/build/pcre2/pcre2-xxx: + +cd /build/pcre2/pcre2-xxx +/source/pcre2/pcre2-xxx/configure + +PCRE2 is written in C and is normally compiled as a C library. However, it is +possible to build it as a C++ library, though the provided building apparatus +does not have any features to support this. + +There are some optional features that can be included or omitted from the PCRE2 +library. They are also documented in the pcre2build man page. + +. By default, both shared and static libraries are built. You can change this + by adding one of these options to the "configure" command: + + --disable-shared + --disable-static + + (See also "Shared libraries on Unix-like systems" below.) + +. By default, only the 8-bit library is built. If you add --enable-pcre16 to + the "configure" command, the 16-bit library is also built. If you add + --enable-pcre32 to the "configure" command, the 32-bit library is also built. + If you want only the 16-bit or 32-bit library, use --disable-pcre8 to disable + building the 8-bit library. + +. If you want to include support for just-in-time compiling, which can give + large performance improvements on certain platforms, add --enable-jit to the + "configure" command. This support is available only for certain hardware + architectures. If you try to enable it on an unsupported architecture, there + will be a compile time error. FIXME: NOT YET IMPLEMENTED. + +. When JIT support is enabled, pcre2grep automatically makes use of it, unless + you add --disable-pcre2grep-jit to the "configure" command. + +. If you want to make use of the support for UTF-8 Unicode character strings in + the 8-bit library, UTF-16 Unicode character strings in the 16-bit library, + and UTF-32 Unicode character strings in the 32-bit library, you must add + --enable-unicode to the "configure" command. Without it, the code for + handling UTF-8, UTF-16 and UTF-8 is not included. It is not possible to + configure one library with UTF support and the other without in the same + configuration. + + Even when --enable-unicode is included, the use of a UTF encoding still has + to be enabled by an option at run time. When PCRE2 is compiled with this + option, its input can only either be ASCII or UTF-8/16/32, even when running + on EBCDIC platforms. It is not possible to use both --enable-unicode and + --enable-ebcdic at the same time. + + When --enable-unicode is specified, as well as supporting UTF strings, PCRE2 + includes support for the \P, \p, and \X sequences that recognize Unicode + character properties. However, only the basic two-letter properties such as + Lu are supported. + +. You can build PCRE2 to recognize either CR or LF or the sequence CRLF or any + of the preceding, or any of the Unicode newline sequences as indicating the + end of a line. Whatever you specify at build time is the default; the caller + of PCRE2 can change the selection at run time. The default newline indicator + is a single LF character (the Unix standard). You can specify the default + newline indicator by adding --enable-newline-is-cr or --enable-newline-is-lf + or --enable-newline-is-crlf or --enable-newline-is-anycrlf or + --enable-newline-is-any to the "configure" command, respectively. + + If you specify --enable-newline-is-cr or --enable-newline-is-crlf, some of + the standard tests will fail, because the lines in the test files end with + LF. Even if the files are edited to change the line endings, there are likely + to be some failures. With --enable-newline-is-anycrlf or + --enable-newline-is-any, many tests should succeed, but there may be some + failures. + +. By default, the sequence \R in a pattern matches any Unicode line ending + sequence. This is independent of the option specifying what PCRE2 considers + to be the end of a line (see above). However, the caller of PCRE2 can + restrict \R to match only CR, LF, or CRLF. You can make this the default by + adding --enable-bsr-anycrlf to the "configure" command (bsr = "backslash R"). + +. PCRE2 has a counter that limits the depth of nesting of parentheses in a + pattern. This limits the amount of system stack that a pattern uses when it + is compiled. The default is 250, but you can change it by setting, for + example, + + --with-parens-nest-limit=500 + +. PCRE2 has a counter that can be set to limit the amount of resources it uses + when matching a pattern. If the limit is exceeded during a match, the match + fails. The default is ten million. You can change the default by setting, for + example, + + --with-match-limit=500000 + + on the "configure" command. This is just the default; individual calls to + pcre2_match() can supply their own value. There is more discussion on the + pcre2api man page. + +. There is a separate counter that limits the depth of recursive function calls + during a matching process. This also has a default of ten million, which is + essentially "unlimited". You can change the default by setting, for example, + + --with-match-limit-recursion=500000 + + Recursive function calls use up the runtime stack; running out of stack can + cause programs to crash in strange ways. There is a discussion about stack + sizes in the pcre2stack man page. + +. In the 8-bit library, the default maximum compiled pattern size is around + 64K. You can increase this by adding --with-link-size=3 to the "configure" + command. PCRE2 then uses three bytes instead of two for offsets to different + parts of the compiled pattern. In the 16-bit library, --with-link-size=3 is + the same as --with-link-size=4, which (in both libraries) uses four-byte + offsets. Increasing the internal link size reduces performance. In the 32-bit + library, the link size setting is ignored, as 4-byte offsets are always used. + +. You can build PCRE2 so that its internal match() function that is called from + pcre2_match() does not call itself recursively. Instead, it uses memory + blocks obtained from the heap to save data that would otherwise be saved on + the stack. To build PCRE2 like this, use + + --disable-stack-for-recursion + + on the "configure" command. PCRE2 runs more slowly in this mode, but it may + be necessary in environments with limited stack sizes. This applies only to + the normal execution of the pcre2_match() function; if JIT support is being + successfully used, it is not relevant. Equally, it does not apply to + pcre2_dfa_match(), which does not use deeply nested recursion. There is a + discussion about stack sizes in the pcre2stack man page. + +. For speed, PCRE2 uses four tables for manipulating and identifying characters + whose code point values are less than 256. By default, it uses a set of + tables for ASCII encoding that is part of the distribution. If you specify + + --enable-rebuild-chartables + + a program called dftables is compiled and run in the default C locale when + you obey "make". It builds a source file called pcre2_chartables.c. If you do + not specify this option, pcre2_chartables.c is created as a copy of + pcre2_chartables.c.dist. See "Character tables" below for further + information. + +. It is possible to compile PCRE2 for use on systems that use EBCDIC as their + character code (as opposed to ASCII/Unicode) by specifying + + --enable-ebcdic + + This automatically implies --enable-rebuild-chartables (see above). However, + when PCRE2 is built this way, it always operates in EBCDIC. It cannot support + both EBCDIC and UTF-8/16/32. There is a second option, --enable-ebcdic-nl25, + which specifies that the code value for the EBCDIC NL character is 0x25 + instead of the default 0x15. + +. In environments where valgrind is installed, if you specify + + --enable-valgrind + + PCRE2 will use valgrind annotations to mark certain memory regions as + unaddressable. This allows it to detect invalid memory accesses, and is + mostly useful for debugging PCRE2 itself. + +. In environments where the gcc compiler is used and lcov version 1.6 or above + is installed, if you specify + + --enable-coverage + + the build process implements a code coverage report for the test suite. The + report is generated by running "make coverage". If ccache is installed on + your system, it must be disabled when building PCRE2 for coverage reporting. + You can do this by setting the environment variable CCACHE_DISABLE=1 before + running "make" to build PCRE2. There is more information about coverage + reporting in the "pcre2build" documentation. + +. The pcre2grep program currently supports only 8-bit data files, and so + requires the 8-bit PCRE2 library. It is possible to compile pcre2grep to use + libz and/or libbz2, in order to read .gz and .bz2 files (respectively), by + specifying one or both of + + --enable-pcre2grep-libz + --enable-pcre2grep-libbz2 + + Of course, the relevant libraries must be installed on your system. + +. The default size (in bytes) of the internal buffer used by pcre2grep can be + set by, for example: + + --with-pcre2grep-bufsize=51200 + + The value must be a plain integer. The default is 20480. + +. It is possible to compile pcre2test so that it links with the libreadline + or libedit libraries, by specifying, respectively, + + --enable-pcre2test-libreadline or --enable-pcre2test-libedit + + If this is done, when pcre2test's input is from a terminal, it reads it using + the readline() function. This provides line-editing and history facilities. + Note that libreadline is GPL-licenced, so if you distribute a binary of + pcre2test linked in this way, there may be licensing issues. These can be + avoided by linking with libedit (which has a BSD licence) instead. + + Enabling libreadline causes the -lreadline option to be added to the + pcre2test build. In many operating environments with a sytem-installed + readline library this is sufficient. However, in some environments (e.g. if + an unmodified distribution version of readline is in use), it may be + necessary to specify something like LIBS="-lncurses" as well. This is + because, to quote the readline INSTALL, "Readline uses the termcap functions, + but does not link with the termcap or curses library itself, allowing + applications which link with readline the to choose an appropriate library." + If you get error messages about missing functions tgetstr, tgetent, tputs, + tgetflag, or tgoto, this is the problem, and linking with the ncurses library + should fix it. + +The "configure" script builds the following files for the basic C library: + +. Makefile the makefile that builds the library +. src/config.h build-time configuration options for the library +. src/pcre2.h the public PCRE2 header file +. pcre2-config script that shows the building settings such as CFLAGS + that were set for "configure" +. libpcre2-8.pc ) +. libpcre2-16.pc ) data for the pkg-config command +. libpcre2-32.pc ) +. libpcre2-posix.pc ) +. libtool script that builds shared and/or static libraries + +Versions of config.h and pcre2.h are distributed in the src directory of PCRE2 +tarballs under the names config.h.generic and pcre2.h.generic. These are +provided for those who have to build PCRE2 without using "configure" or CMake. +If you use "configure" or CMake, the .generic versions are not used. + +The "configure" script also creates config.status, which is an executable +script that can be run to recreate the configuration, and config.log, which +contains compiler output from tests that "configure" runs. + +Once "configure" has run, you can run "make". This builds whichever of the +libraries libpcre2-8, libpcre2-16 and libpcre2-32 are configured, and a test +program called pcre2test. If you enabled JIT support with --enable-jit, another +test program called pcre2_jit_test is built as well. FIXME: still to be +implemented. If the 8-bit library is built, libpcre2-posix and the pcre2grep +command are also built. + +The command "make check" runs all the appropriate tests. Details of the PCRE2 +tests are given below in a separate section of this document. + +You can use "make install" to install PCRE2 into live directories on your +system. The following are installed (file names are all relative to the +<prefix> that is set when "configure" is run): + + Commands (bin): + pcre2test + pcre2grep (if 8-bit support is enabled) + pcre2-config + + Libraries (lib): + libpcre2-8 (if 8-bit support is enabled) + libpcre2-16 (if 16-bit support is enabled) + libpcre2-32 (if 32-bit support is enabled) + libpcre2-posix (if 8-bit support is enabled) + + Configuration information (lib/pkgconfig): + libpcre2-8.pc + libpcre2-16.pc + libpcre2-32.pc + libpcre2-posix.pc + + Header files (include): + pcre2.h + pcre2posix.h + + Man pages (share/man/man{1,3}): + pcre2grep.1 + pcre2test.1 + pcre2-config.1 + pcre2.3 + pcre2*.3 (lots more pages, all starting "pcre2") + + HTML documentation (share/doc/pcre2/html): + index.html + *.html (lots more pages, hyperlinked from index.html) + + Text file documentation (share/doc/pcre2): + AUTHORS + COPYING + ChangeLog + LICENCE + NEWS + README + pcre2.txt (a concatenation of the man(3) pages) + pcre2test.txt the pcre2test man page + pcre2grep.txt the pcre2grep man page + pcre2-config.txt the pcre2-config man page + +If you want to remove PCRE2 from your system, you can run "make uninstall". +This removes all the files that "make install" installed. However, it does not +remove any directories, because these are often shared with other programs. + + +Retrieving configuration information +------------------------------------ + +Running "make install" installs the command pcre2-config, which can be used to +recall information about the PCRE2 configuration and installation. For example: + + pcre2-config --version + +prints the version number, and + + pcre2-config --libs8 + +outputs information about where the 8-bit library is installed. This command +can be included in makefiles for programs that use PCRE2, saving the programmer +from having to remember too many details. Run pcre2-config with no arguments to +obtain a list of possible arguments. + +The pkg-config command is another system for saving and retrieving information +about installed libraries. Instead of separate commands for each library, a +single command is used. For example: + + pkg-config --libs libpcre2-16 + +The data is held in *.pc files that are installed in a directory called +<prefix>/lib/pkgconfig. + + +Shared libraries +---------------- + +The default distribution builds PCRE2 as shared libraries and static libraries, +as long as the operating system supports shared libraries. Shared library +support relies on the "libtool" script which is built as part of the +"configure" process. + +The libtool script is used to compile and link both shared and static +libraries. They are placed in a subdirectory called .libs when they are newly +built. The programs pcre2test and pcre2grep are built to use these uninstalled +libraries (by means of wrapper scripts in the case of shared libraries). When +you use "make install" to install shared libraries, pcre2grep and pcre2test are +automatically re-built to use the newly installed shared libraries before being +installed themselves. However, the versions left in the build directory still +use the uninstalled libraries. + +To build PCRE2 using static libraries only you must use --disable-shared when +configuring it. For example: + +./configure --prefix=/usr/gnu --disable-shared + +Then run "make" in the usual way. Similarly, you can use --disable-static to +build only shared libraries. + + +Cross-compiling using autotools +------------------------------- + +You can specify CC and CFLAGS in the normal way to the "configure" command, in +order to cross-compile PCRE2 for some other host. However, you should NOT +specify --enable-rebuild-chartables, because if you do, the dftables.c source +file is compiled and run on the local host, in order to generate the inbuilt +character tables (the pcre2_chartables.c file). This will probably not work, +because dftables.c needs to be compiled with the local compiler, not the cross +compiler. + +When --enable-rebuild-chartables is not specified, pcre2_chartables.c is +created by making a copy of pcre2_chartables.c.dist, which is a default set of +tables that assumes ASCII code. Cross-compiling with the default tables should +not be a problem. + +If you need to modify the character tables when cross-compiling, you should +move pcre2_chartables.c.dist out of the way, then compile dftables.c by hand +and run it on the local host to make a new version of pcre2_chartables.c.dist. +Then when you cross-compile PCRE2 this new version of the tables will be used. + + +Making new tarballs +------------------- + +The command "make dist" creates three PCRE2 tarballs, in tar.gz, tar.bz2, and +zip formats. The command "make distcheck" does the same, but then does a trial +build of the new distribution to ensure that it works. + +If you have modified any of the man page sources in the doc directory, you +should first run the PrepareRelease script before making a distribution. This +script creates the .txt and HTML forms of the documentation from the man pages. + + +Testing PCRE2 +------------ + +To test the basic PCRE2 library on a Unix-like system, run the RunTest script. +There is another script called RunGrepTest that tests the options of the +pcre2grep command. When JIT support is enabled, another test program called +pcre2_jit_test is built. Both the scripts and all the program tests are run if +you obey "make check". For other environments, see the instructions in +NON-AUTOTOOLS-BUILD. + +The RunTest script runs the pcre2test test program (which is documented in its +own man page) on each of the relevant testinput files in the testdata +directory, and compares the output with the contents of the corresponding +testoutput files. RunTest uses a file called testtry to hold the main output +from pcre2test. Other files whose names begin with "test" are used as working +files in some tests. + +Some tests are relevant only when certain build-time options were selected. For +example, the tests for UTF-8/16/32 support are run only if --enable-unicode was +used. RunTest outputs a comment when it skips a test. + +Many of the tests that are not skipped are run twice if JIT support is +available. On the second run, JIT compilation is forced. This testing can be +suppressed by putting "nojit" on the RunTest command line. + +The entire set of tests is run once for each of the 8-bit, 16-bit and 32-bit +libraries that are enabled. If you want to run just one set of tests, call +RunTest with either the -8, -16 or -32 option. + +If valgrind is installed, you can run the tests under it by putting "valgrind" +on the RunTest command line. To run pcre2test on just one or more specific test +files, give their numbers as arguments to RunTest, for example: + + RunTest 2 7 11 + +You can also specify ranges of tests such as 3-6 or 3- (meaning 3 to the +end), or a number preceded by ~ to exclude a test. For example: + + Runtest 3-15 ~10 + +This runs tests 3 to 15, excluding test 10, and just ~13 runs all the tests +except test 13. Whatever order the arguments are in, the tests are always run +in numerical order. + +You can also call RunTest with the single argument "list" to cause it to output +a list of tests. + +The first two tests can always be run, as they expect only plain text strings +(not UTF) and make no use of Unicode properties. The first test file can be fed +directly into the perltest.pl script to check that Perl gives the same results. +The only difference you should see is in the first few lines, where the Perl +version is given instead of the PCRE2 version. The second set of tests check +auxiliary functions, error detection, and run-time flags that are specific to +PCRE2, as well as the POSIX wrapper API. It also uses the debugging flags to +check some of the internals of pcre2_compile(). + +If you build PCRE2 with a locale setting that is not the standard C locale, the +character tables may be different (see next paragraph). In some cases, this may +cause failures in the second set of tests. For example, in a locale where the +isprint() function yields TRUE for characters in the range 128-255, the use of +[:isascii:] inside a character class defines a different set of characters, and +this shows up in this test as a difference in the compiled code, which is being +listed for checking. Where the comparison test output contains [\x00-\x7f] the +test will contain [\x00-\xff], and similarly in some other cases. This is not a +bug in PCRE2. + +The third set of tests checks pcre2_maketables(), the facility for building a +set of character tables for a specific locale and using them instead of the +default tables. The script uses the "locale" command to check for the +availability of the "fr_FR", "french", or "fr" locale, and uses the first one +that it finds. If the "locale" command fails, or if its output doesn't include +"fr_FR", "french", or "fr" in the list of available locales, the third test +cannot be run, and a comment is output to say why. If running this test +produces an error like this + + ** Failed to set locale "fr_FR" + +it means that the given locale is not available on your system, despite being +listed by "locale". This does not mean that PCRE2 is broken. There are three +alternative output files for the third test, because three different versions +of the French locale have been encountered. The test passes if its output +matches any one of them. + +The fourth and fifth tests check UTF and Unicode property support, the fourth +being compatible with the perltest.pl script, and the fifth checking +PCRE2-specific things. + +The sixth and seventh tests check the pcre2_dfa_match() alternative matching +function, in non-UTF mode and UTF-mode with Unicode property support, +respectively. + +The eighth test checks some internal offsets and code size features; it is +run only when the default "link size" of 2 is set (in other cases the sizes +change) and when Unicode support is enabled. + +The ninth and tenth tests are run only in 8-bit mode, and the eleventh and +twelfth tests are run only in 16-bit and 32-bit modes. These are tests that +generate different output in 8-bit mode. Each pair are for general cases and +Unicode support, respectively. The thirteenth test checks the handling of +non-UTF characters greater than 255 by pcre2_dfa_match() in 16-bit and 32-bit +modes. + +The fourteenth test is run only when JIT support is not available, and the +fifteenth test is run only when JIT support is available. They test some +JIT-specific features such as information output from pcre2test about JIT +compilation. + +The sixteenth and seventeenth tests are run only in 8-bit mode. They check the +POSIX interface to the 8-bit library, withouth and with Unicode support, +respectively. + + +Character tables +---------------- + +For speed, PCRE2 uses four tables for manipulating and identifying characters +whose code point values are less than 256. By default, a set of tables that is +built into the library is used. The pcre2_maketables() function can be called +by an application to create a new set of tables in the current locale. This are +passed to PCRE2 by calling pcre2_set_character_tables() to put a pointer into a +compile context. + +The source file called pcre2_chartables.c contains the default set of tables. +By default, this is created as a copy of pcre2_chartables.c.dist, which +contains tables for ASCII coding. However, if --enable-rebuild-chartables is +specified for ./configure, a different version of pcre2_chartables.c is built +by the program dftables (compiled from dftables.c), which uses the ANSI C +character handling functions such as isalnum(), isalpha(), isupper(), +islower(), etc. to build the table sources. This means that the default C +locale which is set for your system will control the contents of these default +tables. You can change the default tables by editing pcre2_chartables.c and +then re-building PCRE2. If you do this, you should take care to ensure that the +file does not get automatically re-generated. The best way to do this is to +move pcre2_chartables.c.dist out of the way and replace it with your customized +tables. + +When the dftables program is run as a result of --enable-rebuild-chartables, +it uses the default C locale that is set on your system. It does not pay +attention to the LC_xxx environment variables. In other words, it uses the +system's default locale rather than whatever the compiling user happens to have +set. If you really do want to build a source set of character tables in a +locale that is specified by the LC_xxx variables, you can run the dftables +program by hand with the -L option. For example: + + ./dftables -L pcre2_chartables.c.special + +The first two 256-byte tables provide lower casing and case flipping functions, +respectively. The next table consists of three 32-byte bit maps which identify +digits, "word" characters, and white space, respectively. These are used when +building 32-byte bit maps that represent character classes for code points less +than 256. The final 256-byte table has bits indicating various character types, +as follows: + + 1 white space character + 2 letter + 4 decimal digit + 8 hexadecimal digit + 16 alphanumeric or '_' + 128 regular expression metacharacter or binary zero + +You should not alter the set of characters that contain the 128 bit, as that +will cause PCRE2 to malfunction. + + +File manifest +------------- + +The distribution should contain the files listed below. + +(A) Source files for the PCRE2 library functions and their headers are found in + the src directory: + + src/dftables.c auxiliary program for building pcre2_chartables.c + when --enable-rebuild-chartables is specified + + src/pcre2_chartables.c.dist a default set of character tables that assume + ASCII coding; unless --enable-rebuild-chartables is + specified, used by copying to pcre2_chartables.c + + src/pcre2posix.c ) + src/pcre2_auto_possess.c ) + src/pcre2_compile.c ) + src/pcre2_config.c ) + src/pcre2_context.c ) + src/pcre2_dfa_match.c ) + src/pcre2_error.c ) + src/pcre2_exec.c ) + src/pcre2_jit_compile.c ) + src/pcre2_jit_match.c ) sources for the functions in the library, + src/pcre2_jit_misc.c ) and some internal functions that they use + src/pcre2_maketables.c ) + src/pcre2_match.c ) + src/pcre2_match_data.c ) + src/pcre2_newline.c ) + src/pcre2_ord2utf.c ) + src/pcre2_pattern_info.c ) + src/pcre2_string_utils.c ) + src/pcre2_study.c ) + src/pcre2_substring.c ) + src/pcre2_tables.c ) + src/pcre2_ucd.c ) + src/pcre2_valid_utf.c ) + src/pcre2_xclass.c ) + + src/pcre2_printint.c debugging function that is used by pcre2test, + + src/config.h.in template for config.h, when built by "configure" + src/pcre2.h.in template for pcre2.h when built by "configure" + src/pcre2posix.h header for the external POSIX wrapper API + src/pcre2_internal.h header for internal use + src/pcre2_intmodedep.h a mode-specific internal header + src/pcre2_ucp.h header for Unicode property handling + + sljit/* 16 files that make up the JIT compiler FIXME + +(B) Source files for programs that use PCRE2: + + src/pcre2demo.c simple demonstration of coding calls to PCRE2 + src/pcre2grep.c source of a grep utility that uses PCRE2 + src/pcre2test.c comprehensive test program + +(C) Auxiliary files: + + 132html script to turn "man" pages into HTML + AUTHORS information about the author of PCRE2 + ChangeLog log of changes to the code + CleanTxt script to clean nroff output for txt man pages + Detrail script to remove trailing spaces + HACKING some notes about the internals of PCRE2 + INSTALL generic installation instructions + LICENCE conditions for the use of PCRE2 + COPYING the same, using GNU's standard name + Makefile.in ) template for Unix Makefile, which is built by + ) "configure" + Makefile.am ) the automake input that was used to create + ) Makefile.in + NEWS important changes in this release + NON-AUTOTOOLS-BUILD notes on building PCRE2 without using autotools + PrepareRelease script to make preparations for "make dist" + README this file + RunTest a Unix shell script for running tests + RunGrepTest a Unix shell script for pcre2grep tests + aclocal.m4 m4 macros (generated by "aclocal") + config.guess ) files used by libtool, + config.sub ) used only when building a shared library + configure a configuring shell script (built by autoconf) + configure.ac ) the autoconf input that was used to build + ) "configure" and config.h + depcomp ) script to find program dependencies, generated by + ) automake + doc/*.3 man page sources for PCRE2 + doc/*.1 man page sources for pcre2grep and pcre2test + doc/index.html.src the base HTML page + doc/html/* HTML documentation + doc/pcre2.txt plain text version of the man pages + doc/pcre2test.txt plain text documentation of test program + doc/perltest.txt plain text documentation of Perl test program + install-sh a shell script for installing files + libpcre2-8.pc.in template for libpcre2-8.pc for pkg-config + libpcre2-16.pc.in template for libpcre2-16.pc for pkg-config + libpcre2-32.pc.in template for libpcre2-32.pc for pkg-config + libpcre2posix.pc.in template for libpcre2posix.pc for pkg-config + ltmain.sh file used to build a libtool script + missing ) common stub for a few missing GNU programs while + ) installing, generated by automake + mkinstalldirs script for making install directories + perltest.pl Perl test program + pcre2-config.in source of script which retains PCRE2 information + pcre2_jit_test.c test program for the JIT compiler + testdata/testinput* test data for main library tests + testdata/testoutput* expected test results + testdata/grep* input and output for pcre2grep tests + testdata/* other supporting test files + +(D) Auxiliary files for cmake support + + cmake/COPYING-CMAKE-SCRIPTS + cmake/FindPackageHandleStandardArgs.cmake + cmake/FindEditline.cmake + cmake/FindReadline.cmake + CMakeLists.txt + config-cmake.h.in + +(E) Auxiliary files for VPASCAL FIXME FIXME + + makevp.bat + makevp_c.txt + makevp_l.txt + pcre2gexp.pas + +(F) Auxiliary files for building PCRE2 "by hand" + + pcre2.h.generic ) a version of the public PCRE2 header file + ) for use in non-"configure" environments + config.h.generic ) a version of config.h for use in non-"configure" + ) environments + +(F) Miscellaneous + + RunTest.bat a script for running tests under Windows FIXME + +Philip Hazel +Email local part: ph10 +Email domain: cam.ac.uk +Last updated: 27 October 2014 diff --git a/doc/html/pcre2-config.html b/doc/html/pcre2-config.html new file mode 100644 index 0000000..b71d760 --- /dev/null +++ b/doc/html/pcre2-config.html @@ -0,0 +1,102 @@ +<html> +<head> +<title>pcre2-config specification</title> +</head> +<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB"> +<h1>pcre2-config man page</h1> +<p> +Return to the <a href="index.html">PCRE2 index page</a>. +</p> +<p> +This page is part of the PCRE2 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. +<br> +<ul> +<li><a name="TOC1" href="#SEC1">SYNOPSIS</a> +<li><a name="TOC2" href="#SEC2">DESCRIPTION</a> +<li><a name="TOC3" href="#SEC3">OPTIONS</a> +<li><a name="TOC4" href="#SEC4">SEE ALSO</a> +<li><a name="TOC5" href="#SEC5">AUTHOR</a> +<li><a name="TOC6" href="#SEC6">REVISION</a> +</ul> +<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br> +<P> +<b>pcre2-config [--prefix] [--exec-prefix] [--version]</b> +<b> [--libs8] [--libs16] [--libs32] [--libs-posix]</b> +<b> [--cflags] [--cflags-posix]</b> +</P> +<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br> +<P> +<b>pcre2-config</b> returns the configuration of the installed PCRE2 libraries +and the options required to compile a program to use them. Some of the options +apply only to the 8-bit, or 16-bit, or 32-bit libraries, respectively, and are +not available for libraries that have not been built. If an unavailable option +is encountered, the "usage" information is output. +</P> +<br><a name="SEC3" href="#TOC1">OPTIONS</a><br> +<P> +<b>--prefix</b> +Writes the directory prefix used in the PCRE2 installation for architecture +independent files (<i>/usr</i> on many systems, <i>/usr/local</i> on some +systems) to the standard output. +</P> +<P> +<b>--exec-prefix</b> +Writes the directory prefix used in the PCRE2 installation for architecture +dependent files (normally the same as <b>--prefix</b>) to the standard output. +</P> +<P> +<b>--version</b> +Writes the version number of the installed PCRE2 libraries to the standard +output. +</P> +<P> +<b>--libs8</b> +Writes to the standard output the command line options required to link +with the 8-bit PCRE2 library (<b>-lpcre2-8</b> on many systems). +</P> +<P> +<b>--libs16</b> +Writes to the standard output the command line options required to link +with the 16-bit PCRE2 library (<b>-lpcre2-16</b> on many systems). +</P> +<P> +<b>--libs32</b> +Writes to the standard output the command line options required to link +with the 32-bit PCRE2 library (<b>-lpcre2-32</b> on many systems). +</P> +<P> +<b>--libs-posix</b> +Writes to the standard output the command line options required to link with +PCRE2's POSIX API wrapper library (<b>-lpcre2-posix</b> <b>-lpcre2-8</b> on many +systems). +</P> +<P> +<b>--cflags</b> +Writes to the standard output the command line options required to compile +files that use PCRE2 (this may include some <b>-I</b> options, but is blank on +many systems). +</P> +<P> +<b>--cflags-posix</b> +Writes to the standard output the command line options required to compile +files that use PCRE2's POSIX API wrapper library (this may include some +<b>-I</b> options, but is blank on many systems). +</P> +<br><a name="SEC4" href="#TOC1">SEE ALSO</a><br> +<P> +<b>pcre2(3)</b> +</P> +<br><a name="SEC5" href="#TOC1">AUTHOR</a><br> +<P> +This manual page was originally written by Mark Baker for the Debian GNU/Linux +system. It has been subsequently revised as a generic PCRE2 man page. +</P> +<br><a name="SEC6" href="#TOC1">REVISION</a><br> +<P> +Last updated: 28 September 2014 +<br> +<p> +Return to the <a href="index.html">PCRE2 index page</a>. +</p> diff --git a/doc/html/pcre2.html b/doc/html/pcre2.html new file mode 100644 index 0000000..f8672b8 --- /dev/null +++ b/doc/html/pcre2.html @@ -0,0 +1,182 @@ +<html> +<head> +<title>pcre2 specification</title> +</head> +<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB"> +<h1>pcre2 man page</h1> +<p> +Return to the <a href="index.html">PCRE2 index page</a>. +</p> +<p> +This page is part of the PCRE2 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. +<br> +<ul> +<li><a name="TOC1" href="#SEC1">INTRODUCTION</a> +<li><a name="TOC2" href="#SEC2">SECURITY CONSIDERATIONS</a> +<li><a name="TOC3" href="#SEC3">USER DOCUMENTATION</a> +<li><a name="TOC4" href="#SEC4">AUTHOR</a> +<li><a name="TOC5" href="#SEC5">REVISION</a> +</ul> +<br><a name="SEC1" href="#TOC1">INTRODUCTION</a><br> +<P> +PCRE2 is the name used for a revised API for the PCRE library, which is a set +of functions, written in C, that implement regular expression pattern matching +using the same syntax and semantics as Perl, with just a few differences. Some +features that appeared in Python and the original PCRE before they appeared in +Perl are also available using the Python syntax, there is some support for one +or two .NET and Oniguruma syntax items, and there are options for requesting +some minor changes that give better ECMAScript (aka JavaScript) compatibility. +</P> +<P> +The source code for PCRE2 can be compiled to support 8-bit, 16-bit, or 32-bit +code units, which means that up to three separate libraries may be installed. +The original work to extend PCRE to 16-bit and 32-bit code units was done by +Zoltan Herczeg and Christian Persch, respectively. In all three cases, strings +can be interpreted either as one character per code unit, or as UTF-encoded +Unicode, with support for Unicode general category properties. Unicode is +optional at build time, and must be enabled explicitly at run time. The version +of Unicode in use can be discovered by running +<pre> + pcre2test -C +</PRE> +</P> +<P> +The three libraries contain identical sets of functions, with names ending in +_8, _16, or _32, respectively (for example, <b>pcre2_compile_8()</b>). However, +by defining PCRE2_CODE_UNIT_WIDTH to be 8, 16, or 32, a program that uses just +one code unit width can be written using generic names such as +<b>pcre2_compile()</b>, and the documentation is written assuming that this is +the case. +</P> +<P> +In addition to the Perl-compatible matching function, PCRE2 contains an +alternative function that matches the same compiled patterns in a different +way. In certain circumstances, the alternative function has some advantages. +For a discussion of the two matching algorithms, see the +<a href="pcre2matching.html"><b>pcre2matching</b></a> +page. +</P> +<P> +Details of exactly which Perl regular expression features are and are not +supported by PCRE2 are given in separate documents. See the +<a href="pcre2pattern.html"><b>pcre2pattern</b></a> +and +<a href="pcre2compat.html"><b>pcre2compat</b></a> +pages. There is a syntax summary in the +<a href="pcre2syntax.html"><b>pcre2syntax</b></a> +page. +</P> +<P> +Some features of PCRE2 can be included, excluded, or changed when the library +is built. The +<a href="pcre2_config.html"><b>pcre2_config()</b></a> +function makes it possible for a client to discover which features are +available. The features themselves are described in the +<a href="pcre2build.html"><b>pcre2build</b></a> +page. Documentation about building PCRE2 for various operating systems can be +found in the +<a href="README.txt"><b>README</b></a> +and +<a href="NON-AUTOTOOLS-BUILD.txt"><b>NON-AUTOTOOLS_BUILD</b></a> +files in the source distribution. +</P> +<P> +The libraries contains a number of undocumented internal functions and data +tables that are used by more than one of the exported external functions, but +which are not intended for use by external callers. Their names all begin with +"_pcre2", which hopefully will not provoke any name clashes. In some +environments, it is possible to control which external symbols are exported +when a shared library is built, and in these cases the undocumented symbols are +not exported. +</P> +<br><a name="SEC2" href="#TOC1">SECURITY CONSIDERATIONS</a><br> +<P> +If you are using PCRE2 in a non-UTF application that permits users to supply +arbitrary patterns for compilation, you should be aware of a feature that +allows users to turn on UTF support from within a pattern, provided that PCRE2 +was built with Unicode support. For example, an 8-bit pattern that begins with +"(*UTF)" turns on UTF-8 mode, which interprets patterns and subjects as strings +of UTF-8 code units instead of individual 8-bit characters. This causes both +the pattern and any data against which it is matched to be checked for UTF-8 +validity. If the data string is very long, such a check might use sufficiently +many resources as to cause your application to lose performance. +</P> +<P> +One way of guarding against this possibility is to use the +<b>pcre2_pattern_info()</b> function to check the compiled pattern's options for +UTF. Alternatively, you can set the PCRE2_NEVER_UTF option at compile time. +This causes an compile time error if a pattern contains a UTF-setting sequence. +</P> +<P> +If your application is one that supports UTF, be aware that validity checking +can take time. If the same data string is to be matched many times, you can use +the PCRE2_NO_UTF_CHECK option for the second and subsequent matches to avoid +running redundant checks. +</P> +<P> +Another way that performance can be hit is by running a pattern that has a very +large search tree against a string that will never match. Nested unlimited +repeats in a pattern are a common example. PCRE2 provides some protection +against this: see the <b>pcre2_set_match_limit()</b> function in the +<a href="pcre2api.html"><b>pcre2api</b></a> +page. +</P> +<br><a name="SEC3" href="#TOC1">USER DOCUMENTATION</a><br> +<P> +The user documentation for PCRE2 comprises a number of different sections. In +the "man" format, each of these is a separate "man page". In the HTML format, +each is a separate page, linked from the index page. In the plain text format, +the descriptions of the <b>pcre2grep</b> and <b>pcre2test</b> programs are in +files called <b>pcre2grep.txt</b> and <b>pcre2test.txt</b>, respectively. The +remaining sections, except for the <b>pcre2demo</b> section (which is a program +listing), and the short pages for individual functions, are concatenated in +<b>pcre2.txt</b>, for ease of searching. The sections are as follows: +<pre> + pcre2 this document FIXME CHECK THIS LIST + pcre2-config show PCRE2 installation configuration information + pcre2api details of PCRE2's native C API + pcre2build building PCRE2 + pcre2callout details of the callout feature + pcre2compat discussion of Perl compatibility + pcre2demo a demonstration C program that uses PCRE2 + pcre2grep description of the <b>pcre2grep</b> command (8-bit only) + pcre2jit discussion of the just-in-time optimization support + pcre2limits details of size and other limits + pcre2matching discussion of the two matching algorithms + pcre2partial details of the partial matching facility + pcre2pattern syntax and semantics of supported regular expressions + pcre2perform discussion of performance issues + pcre2posix the POSIX-compatible C API for the 8-bit library + pcre2sample discussion of the pcre2demo program + pcre2stack discussion of stack usage + pcre2syntax quick syntax reference + pcre2test description of the <b>pcre2test</b> testing command + pcre2unicode discussion of Unicode and UTF support +</pre> +In the "man" and HTML formats, there is also a short page for each C library +function, listing its arguments and results. +</P> +<br><a name="SEC4" href="#TOC1">AUTHOR</a><br> +<P> +Philip Hazel +<br> +University Computing Service +<br> +Cambridge CB2 3QH, England. +<br> +</P> +<P> +Putting an actual email address here is a spam magnet. If you want to email me, +use my two initials, followed by the two digits 10, at the domain cam.ac.uk. +</P> +<br><a name="SEC5" href="#TOC1">REVISION</a><br> +<P> +Last updated: 28 September 2014 +<br> +Copyright © 1997-2014 University of Cambridge. +<br> +<p> +Return to the <a href="index.html">PCRE2 index page</a>. +</p> diff --git a/doc/html/pcre2grep.html b/doc/html/pcre2grep.html new file mode 100644 index 0000000..6528a38 --- /dev/null +++ b/doc/html/pcre2grep.html @@ -0,0 +1,759 @@ +<html> +<head> +<title>pcre2grep specification</title> +</head> +<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB"> +<h1>pcre2grep man page</h1> +<p> +Return to the <a href="index.html">PCRE2 index page</a>. +</p> +<p> +This page is part of the PCRE2 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. +<br> +<ul> +<li><a name="TOC1" href="#SEC1">SYNOPSIS</a> +<li><a name="TOC2" href="#SEC2">DESCRIPTION</a> +<li><a name="TOC3" href="#SEC3">SUPPORT FOR COMPRESSED FILES</a> +<li><a name="TOC4" href="#SEC4">BINARY FILES</a> +<li><a name="TOC5" href="#SEC5">OPTIONS</a> +<li><a name="TOC6" href="#SEC6">ENVIRONMENT VARIABLES</a> +<li><a name="TOC7" href="#SEC7">NEWLINES</a> +<li><a name="TOC8" href="#SEC8">OPTIONS COMPATIBILITY</a> +<li><a name="TOC9" href="#SEC9">OPTIONS WITH DATA</a> +<li><a name="TOC10" href="#SEC10">MATCHING ERRORS</a> +<li><a name="TOC11" href="#SEC11">DIAGNOSTICS</a> +<li><a name="TOC12" href="#SEC12">SEE ALSO</a> +<li><a name="TOC13" href="#SEC13">AUTHOR</a> +<li><a name="TOC14" href="#SEC14">REVISION</a> +</ul> +<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br> +<P> +<b>pcre2grep [options] [long options] [pattern] [path1 path2 ...]</b> +</P> +<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br> +<P> +<b>pcre2grep</b> searches files for character patterns, in the same way as other +grep commands do, but it uses the PCRE2 regular expression library to support +patterns that are compatible with the regular expressions of Perl 5. See +<a href="pcre2syntax.html"><b>pcre2syntax</b>(3)</a> +for a quick-reference summary of pattern syntax, or +<a href="pcre2pattern.html"><b>pcre2pattern</b>(3)</a> +for a full description of the syntax and semantics of the regular expressions +that PCRE2 supports. +</P> +<P> +Patterns, whether supplied on the command line or in a separate file, are given +without delimiters. For example: +<pre> + pcre2grep Thursday /etc/motd +</pre> +If you attempt to use delimiters (for example, by surrounding a pattern with +slashes, as is common in Perl scripts), they are interpreted as part of the +pattern. Quotes can of course be used to delimit patterns on the command line +because they are interpreted by the shell, and indeed quotes are required if a +pattern contains white space or shell metacharacters. +</P> +<P> +The first argument that follows any option settings is treated as the single +pattern to be matched when neither <b>-e</b> nor <b>-f</b> is present. +Conversely, when one or both of these options are used to specify patterns, all +arguments are treated as path names. At least one of <b>-e</b>, <b>-f</b>, or an +argument pattern must be provided. +</P> +<P> +If no files are specified, <b>pcre2grep</b> reads the standard input. The +standard input can also be referenced by a name consisting of a single hyphen. +For example: +<pre> + pcre2grep some-pattern /file1 - /file3 +</pre> +By default, each line that matches a pattern is copied to the standard +output, and if there is more than one file, the file name is output at the +start of each line, followed by a colon. However, there are options that can +change how <b>pcre2grep</b> behaves. In particular, the <b>-M</b> option makes it +possible to search for patterns that span line boundaries. What defines a line +boundary is controlled by the <b>-N</b> (<b>--newline</b>) option. +</P> +<P> +The amount of memory used for buffering files that are being scanned is +controlled by a parameter that can be set by the <b>--buffer-size</b> option. +The default value for this parameter is specified when <b>pcre2grep</b> is built, +with the default default being 20K. A block of memory three times this size is +used (to allow for buffering "before" and "after" lines). An error occurs if a +line overflows the buffer. +</P> +<P> +Patterns can be no longer than 8K or BUFSIZ bytes, whichever is the greater. +BUFSIZ is defined in <b><stdio.h></b>. When there is more than one pattern +(specified by the use of <b>-e</b> and/or <b>-f</b>), each pattern is applied to +each line in the order in which they are defined, except that all the <b>-e</b> +patterns are tried before the <b>-f</b> patterns. +</P> +<P> +By default, as soon as one pattern matches a line, no further patterns are +considered. However, if <b>--colour</b> (or <b>--color</b>) is used to colour the +matching substrings, or if <b>--only-matching</b>, <b>--file-offsets</b>, or +<b>--line-offsets</b> is used to output only the part of the line that matched +(either shown literally, or as an offset), scanning resumes immediately +following the match, so that further matches on the same line can be found. If +there are multiple patterns, they are all tried on the remainder of the line, +but patterns that follow the one that matched are not tried on the earlier part +of the line. +</P> +<P> +This behaviour means that the order in which multiple patterns are specified +can affect the output when one of the above options is used. This is no longer +the same behaviour as GNU grep, which now manages to display earlier matches +for later patterns (as long as there is no overlap). +</P> +<P> +Patterns that can match an empty string are accepted, but empty string +matches are never recognized. An example is the pattern "(super)?(man)?", in +which all components are optional. This pattern finds all occurrences of both +"super" and "man"; the output differs from matching with "super|man" when only +the matching substrings are being shown. +</P> +<P> +If the <b>LC_ALL</b> or <b>LC_CTYPE</b> environment variable is set, +<b>pcre2grep</b> uses the value to set a locale when calling the PCRE2 library. +The <b>--locale</b> option can be used to override this. +</P> +<br><a name="SEC3" href="#TOC1">SUPPORT FOR COMPRESSED FILES</a><br> +<P> +It is possible to compile <b>pcre2grep</b> so that it uses <b>libz</b> or +<b>libbz2</b> to read files whose names end in <b>.gz</b> or <b>.bz2</b>, +respectively. You can find out whether your binary has support for one or both +of these file types by running it with the <b>--help</b> option. If the +appropriate support is not present, files are treated as plain text. The +standard input is always so treated. +</P> +<br><a name="SEC4" href="#TOC1">BINARY FILES</a><br> +<P> +By default, a file that contains a binary zero byte within the first 1024 bytes +is identified as a binary file, and is processed specially. (GNU grep also +identifies binary files in this manner.) See the <b>--binary-files</b> option +for a means of changing the way binary files are handled. +</P> +<br><a name="SEC5" href="#TOC1">OPTIONS</a><br> +<P> +The order in which some of the options appear can affect the output. For +example, both the <b>-h</b> and <b>-l</b> options affect the printing of file +names. Whichever comes later in the command line will be the one that takes +effect. Similarly, except where noted below, if an option is given twice, the +later setting is used. Numerical values for options may be followed by K or M, +to signify multiplication by 1024 or 1024*1024 respectively. +</P> +<P> +<b>--</b> +This terminates the list of options. It is useful if the next item on the +command line starts with a hyphen but is not an option. This allows for the +processing of patterns and filenames that start with hyphens. +</P> +<P> +<b>-A</b> <i>number</i>, <b>--after-context=</b><i>number</i> +Output <i>number</i> lines of context after each matching line. If filenames +and/or line numbers are being output, a hyphen separator is used instead of a +colon for the context lines. A line containing "--" is output between each +group of lines, unless they are in fact contiguous in the input file. The value +of <i>number</i> is expected to be relatively small. However, <b>pcre2grep</b> +guarantees to have up to 8K of following text available for context output. +</P> +<P> +<b>-a</b>, <b>--text</b> +Treat binary files as text. This is equivalent to +<b>--binary-files</b>=<i>text</i>. +</P> +<P> +<b>-B</b> <i>number</i>, <b>--before-context=</b><i>number</i> +Output <i>number</i> lines of context before each matching line. If filenames +and/or line numbers are being output, a hyphen separator is used instead of a +colon for the context lines. A line containing "--" is output between each +group of lines, unless they are in fact contiguous in the input file. The value +of <i>number</i> is expected to be relatively small. However, <b>pcre2grep</b> +guarantees to have up to 8K of preceding text available for context output. +</P> +<P> +<b>--binary-files=</b><i>word</i> +Specify how binary files are to be processed. If the word is "binary" (the +default), pattern matching is performed on binary files, but the only output is +"Binary file <name> matches" when a match succeeds. If the word is "text", +which is equivalent to the <b>-a</b> or <b>--text</b> option, binary files are +processed in the same way as any other file. In this case, when a match +succeeds, the output may be binary garbage, which can have nasty effects if +sent to a terminal. If the word is "without-match", which is equivalent to the +<b>-I</b> option, binary files are not processed at all; they are assumed not to +be of interest. +</P> +<P> +<b>--buffer-size=</b><i>number</i> +Set the parameter that controls how much memory is used for buffering files +that are being scanned. +</P> +<P> +<b>-C</b> <i>number</i>, <b>--context=</b><i>number</i> +Output <i>number</i> lines of context both before and after each matching line. +This is equivalent to setting both <b>-A</b> and <b>-B</b> to the same value. +</P> +<P> +<b>-c</b>, <b>--count</b> +Do not output individual lines from the files that are being scanned; instead +output the number of lines that would otherwise have been shown. If no lines +are selected, the number zero is output. If several files are are being +scanned, a count is output for each of them. However, if the +<b>--files-with-matches</b> option is also used, only those files whose counts +are greater than zero are listed. When <b>-c</b> is used, the <b>-A</b>, +<b>-B</b>, and <b>-C</b> options are ignored. +</P> +<P> +<b>--colour</b>, <b>--color</b> +If this option is given without any data, it is equivalent to "--colour=auto". +If data is required, it must be given in the same shell item, separated by an +equals sign. +</P> +<P> +<b>--colour=</b><i>value</i>, <b>--color=</b><i>value</i> +This option specifies under what circumstances the parts of a line that matched +a pattern should be coloured in the output. By default, the output is not +coloured. The value (which is optional, see above) may be "never", "always", or +"auto". In the latter case, colouring happens only if the standard output is +connected to a terminal. More resources are used when colouring is enabled, +because <b>pcre2grep</b> has to search for all possible matches in a line, not +just one, in order to colour them all. +<br> +<br> +The colour that is used can be specified by setting the environment variable +PCRE2GREP_COLOUR or PCRE2GREP_COLOR. The value of this variable should be a +string of two numbers, separated by a semicolon. They are copied directly into +the control string for setting colour on a terminal, so it is your +responsibility to ensure that they make sense. If neither of the environment +variables is set, the default is "1;31", which gives red. +</P> +<P> +<b>-D</b> <i>action</i>, <b>--devices=</b><i>action</i> +If an input path is not a regular file or a directory, "action" specifies how +it is to be processed. Valid values are "read" (the default) or "skip" +(silently skip the path). +</P> +<P> +<b>-d</b> <i>action</i>, <b>--directories=</b><i>action</i> +If an input path is a directory, "action" specifies how it is to be processed. +Valid values are "read" (the default in non-Windows environments, for +compatibility with GNU grep), "recurse" (equivalent to the <b>-r</b> option), or +"skip" (silently skip the path, the default in Windows environments). In the +"read" case, directories are read as if they were ordinary files. In some +operating systems the effect of reading a directory like this is an immediate +end-of-file; in others it may provoke an error. +</P> +<P> +<b>-e</b> <i>pattern</i>, <b>--regex=</b><i>pattern</i>, <b>--regexp=</b><i>pattern</i> +Specify a pattern to be matched. This option can be used multiple times in +order to specify several patterns. It can also be used as a way of specifying a +single pattern that starts with a hyphen. When <b>-e</b> is used, no argument +pattern is taken from the command line; all arguments are treated as file +names. There is no limit to the number of patterns. They are applied to each +line in the order in which they are defined until one matches. +<br> +<br> +If <b>-f</b> is used with <b>-e</b>, the command line patterns are matched first, +followed by the patterns from the file(s), independent of the order in which +these options are specified. Note that multiple use of <b>-e</b> is not the same +as a single pattern with alternatives. For example, X|Y finds the first +character in a line that is X or Y, whereas if the two patterns are given +separately, with X first, <b>pcre2grep</b> finds X if it is present, even if it +follows Y in the line. It finds Y only if there is no X in the line. This +matters only if you are using <b>-o</b> or <b>--colo(u)r</b> to show the part(s) +of the line that matched. +</P> +<P> +<b>--exclude</b>=<i>pattern</i> +Files (but not directories) whose names match the pattern are skipped without +being processed. This applies to all files, whether listed on the command line, +obtained from <b>--file-list</b>, or by scanning a directory. The pattern is a +PCRE2 regular expression, and is matched against the final component of the file +name, not the entire path. The <b>-F</b>, <b>-w</b>, and <b>-x</b> options do not +apply to this pattern. The option may be given any number of times in order to +specify multiple patterns. If a file name matches both an <b>--include</b> +and an <b>--exclude</b> pattern, it is excluded. There is no short form for this +option. +</P> +<P> +<b>--exclude-from=</b><i>filename</i> +Treat each non-empty line of the file as the data for an <b>--exclude</b> +option. What constitutes a newline when reading the file is the operating +system's default. The <b>--newline</b> option has no effect on this option. This +option may be given more than once in order to specify a number of files to +read. +</P> +<P> +<b>--exclude-dir</b>=<i>pattern</i> +Directories whose names match the pattern are skipped without being processed, +whatever the setting of the <b>--recursive</b> option. This applies to all +directories, whether listed on the command line, obtained from +<b>--file-list</b>, or by scanning a parent directory. The pattern is a PCRE2 +regular expression, and is matched against the final component of the directory +name, not the entire path. The <b>-F</b>, <b>-w</b>, and <b>-x</b> options do not +apply to this pattern. The option may be given any number of times in order to +specify more than one pattern. If a directory matches both <b>--include-dir</b> +and <b>--exclude-dir</b>, it is excluded. There is no short form for this +option. +</P> +<P> +<b>-F</b>, <b>--fixed-strings</b> +Interpret each data-matching pattern as a list of fixed strings, separated by +newlines, instead of as a regular expression. What constitutes a newline for +this purpose is controlled by the <b>--newline</b> option. The <b>-w</b> (match +as a word) and <b>-x</b> (match whole line) options can be used with <b>-F</b>. +They apply to each of the fixed strings. A line is selected if any of the fixed +strings are found in it (subject to <b>-w</b> or <b>-x</b>, if present). This +option applies only to the patterns that are matched against the contents of +files; it does not apply to patterns specified by any of the <b>--include</b> or +<b>--exclude</b> options. +</P> +<P> +<b>-f</b> <i>filename</i>, <b>--file=</b><i>filename</i> +Read patterns from the file, one per line, and match them against +each line of input. What constitutes a newline when reading the file is the +operating system's default. The <b>--newline</b> option has no effect on this +option. Trailing white space is removed from each line, and blank lines are +ignored. An empty file contains no patterns and therefore matches nothing. See +also the comments about multiple patterns versus a single pattern with +alternatives in the description of <b>-e</b> above. +<br> +<br> +If this option is given more than once, all the specified files are +read. A data line is output if any of the patterns match it. A filename can +be given as "-" to refer to the standard input. When <b>-f</b> is used, patterns +specified on the command line using <b>-e</b> may also be present; they are +tested before the file's patterns. However, no other pattern is taken from the +command line; all arguments are treated as the names of paths to be searched. +</P> +<P> +<b>--file-list</b>=<i>filename</i> +Read a list of files and/or directories that are to be scanned from the given +file, one per line. Trailing white space is removed from each line, and blank +lines are ignored. These paths are processed before any that are listed on the +command line. The filename can be given as "-" to refer to the standard input. +If <b>--file</b> and <b>--file-list</b> are both specified as "-", patterns are +read first. This is useful only when the standard input is a terminal, from +which further lines (the list of files) can be read after an end-of-file +indication. If this option is given more than once, all the specified files are +read. +</P> +<P> +<b>--file-offsets</b> +Instead of showing lines or parts of lines that match, show each match as an +offset from the start of the file and a length, separated by a comma. In this +mode, no context is shown. That is, the <b>-A</b>, <b>-B</b>, and <b>-C</b> +options are ignored. If there is more than one match in a line, each of them is +shown separately. This option is mutually exclusive with <b>--line-offsets</b> +and <b>--only-matching</b>. +</P> +<P> +<b>-H</b>, <b>--with-filename</b> +Force the inclusion of the filename at the start of output lines when searching +a single file. By default, the filename is not shown in this case. For matching +lines, the filename is followed by a colon; for context lines, a hyphen +separator is used. If a line number is also being output, it follows the file +name. +</P> +<P> +<b>-h</b>, <b>--no-filename</b> +Suppress the output filenames when searching multiple files. By default, +filenames are shown when multiple files are searched. For matching lines, the +filename is followed by a colon; for context lines, a hyphen separator is used. +If a line number is also being output, it follows the file name. +</P> +<P> +<b>--help</b> +Output a help message, giving brief details of the command options and file +type support, and then exit. Anything else on the command line is +ignored. +</P> +<P> +<b>-I</b> +Treat binary files as never matching. This is equivalent to +<b>--binary-files</b>=<i>without-match</i>. +</P> +<P> +<b>-i</b>, <b>--ignore-case</b> +Ignore upper/lower case distinctions during comparisons. +</P> +<P> +<b>--include</b>=<i>pattern</i> +If any <b>--include</b> patterns are specified, the only files that are +processed are those that match one of the patterns (and do not match an +<b>--exclude</b> pattern). This option does not affect directories, but it +applies to all files, whether listed on the command line, obtained from +<b>--file-list</b>, or by scanning a directory. The pattern is a PCRE2 regular +expression, and is matched against the final component of the file name, not +the entire path. The <b>-F</b>, <b>-w</b>, and <b>-x</b> options do not apply to +this pattern. The option may be given any number of times. If a file name +matches both an <b>--include</b> and an <b>--exclude</b> pattern, it is excluded. +There is no short form for this option. +</P> +<P> +<b>--include-from=</b><i>filename</i> +Treat each non-empty line of the file as the data for an <b>--include</b> +option. What constitutes a newline for this purpose is the operating system's +default. The <b>--newline</b> option has no effect on this option. This option +may be given any number of times; all the files are read. +</P> +<P> +<b>--include-dir</b>=<i>pattern</i> +If any <b>--include-dir</b> patterns are specified, the only directories that +are processed are those that match one of the patterns (and do not match an +<b>--exclude-dir</b> pattern). This applies to all directories, whether listed +on the command line, obtained from <b>--file-list</b>, or by scanning a parent +directory. The pattern is a PCRE2 regular expression, and is matched against the +final component of the directory name, not the entire path. The <b>-F</b>, +<b>-w</b>, and <b>-x</b> options do not apply to this pattern. The option may be +given any number of times. If a directory matches both <b>--include-dir</b> and +<b>--exclude-dir</b>, it is excluded. There is no short form for this option. +</P> +<P> +<b>-L</b>, <b>--files-without-match</b> +Instead of outputting lines from the files, just output the names of the files +that do not contain any lines that would have been output. Each file name is +output once, on a separate line. +</P> +<P> +<b>-l</b>, <b>--files-with-matches</b> +Instead of outputting lines from the files, just output the names of the files +containing lines that would have been output. Each file name is output +once, on a separate line. Searching normally stops as soon as a matching line +is found in a file. However, if the <b>-c</b> (count) option is also used, +matching continues in order to obtain the correct count, and those files that +have at least one match are listed along with their counts. Using this option +with <b>-c</b> is a way of suppressing the listing of files with no matches. +</P> +<P> +<b>--label</b>=<i>name</i> +This option supplies a name to be used for the standard input when file names +are being output. If not supplied, "(standard input)" is used. There is no +short form for this option. +</P> +<P> +<b>--line-buffered</b> +When this option is given, input is read and processed line by line, and the +output is flushed after each write. By default, input is read in large chunks, +unless <b>pcre2grep</b> can determine that it is reading from a terminal (which +is currently possible only in Unix-like environments). Output to terminal is +normally automatically flushed by the operating system. This option can be +useful when the input or output is attached to a pipe and you do not want +<b>pcre2grep</b> to buffer up large amounts of data. However, its use will affect +performance, and the <b>-M</b> (multiline) option ceases to work. +</P> +<P> +<b>--line-offsets</b> +Instead of showing lines or parts of lines that match, show each match as a +line number, the offset from the start of the line, and a length. The line +number is terminated by a colon (as usual; see the <b>-n</b> option), and the +offset and length are separated by a comma. In this mode, no context is shown. +That is, the <b>-A</b>, <b>-B</b>, and <b>-C</b> options are ignored. If there is +more than one match in a line, each of them is shown separately. This option is +mutually exclusive with <b>--file-offsets</b> and <b>--only-matching</b>. +</P> +<P> +<b>--locale</b>=<i>locale-name</i> +This option specifies a locale to be used for pattern matching. It overrides +the value in the <b>LC_ALL</b> or <b>LC_CTYPE</b> environment variables. If no +locale is specified, the PCRE2 library's default (usually the "C" locale) is +used. There is no short form for this option. +</P> +<P> +<b>--match-limit</b>=<i>number</i> +Processing some regular expression patterns can require a very large amount of +memory, leading in some cases to a program crash if not enough is available. +Other patterns may take a very long time to search for all possible matching +strings. The <b>pcre2_exec()</b> function that is called by <b>pcre2grep</b> to do +the matching has two parameters that can limit the resources that it uses. +<br> +<br> +The <b>--match-limit</b> option provides a means of limiting resource usage +when processing patterns that are not going to match, but which have a very +large number of possibilities in their search trees. The classic example is a +pattern that uses nested unlimited repeats. Internally, PCRE2 uses a function +called <b>match()</b> which it calls repeatedly (sometimes recursively). The +limit set by <b>--match-limit</b> is imposed on the number of times this +function is called during a match, which has the effect of limiting the amount +of backtracking that can take place. +<br> +<br> +The <b>--recursion-limit</b> option is similar to <b>--match-limit</b>, but +instead of limiting the total number of times that <b>match()</b> is called, it +limits the depth of recursive calls, which in turn limits the amount of memory +that can be used. The recursion depth is a smaller number than the total number +of calls, because not all calls to <b>match()</b> are recursive. This limit is +of use only if it is set smaller than <b>--match-limit</b>. +<br> +<br> +There are no short forms for these options. The default settings are specified +when the PCRE2 library is compiled, with the default default being 10 million. +</P> +<P> +<b>-M</b>, <b>--multiline</b> +Allow patterns to match more than one line. When this option is given, patterns +may usefully contain literal newline characters and internal occurrences of ^ +and $ characters. The output for a successful match may consist of more than +one line, the last of which is the one in which the match ended. If the matched +string ends with a newline sequence the output ends at the end of that line. +<br> +<br> +When this option is set, the PCRE2 library is called in "multiline" mode. +There is a limit to the number of lines that can be matched, imposed by the way +that <b>pcre2grep</b> buffers the input file as it scans it. However, +<b>pcre2grep</b> ensures that at least 8K characters or the rest of the document +(whichever is the shorter) are available for forward matching, and similarly +the previous 8K characters (or all the previous characters, if fewer than 8K) +are guaranteed to be available for lookbehind assertions. This option does not +work when input is read line by line (see \fP--line-buffered\fP.) +</P> +<P> +<b>-N</b> <i>newline-type</i>, <b>--newline</b>=<i>newline-type</i> +The PCRE2 library supports five different conventions for indicating +the ends of lines. They are the single-character sequences CR (carriage return) +and LF (linefeed), the two-character sequence CRLF, an "anycrlf" convention, +which recognizes any of the preceding three types, and an "any" convention, in +which any Unicode line ending sequence is assumed to end a line. The Unicode +sequences are the three just mentioned, plus VT (vertical tab, U+000B), FF +(form feed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and +PS (paragraph separator, U+2029). +<br> +<br> +When the PCRE2 library is built, a default line-ending sequence is specified. +This is normally the standard sequence for the operating system. Unless +otherwise specified by this option, <b>pcre2grep</b> uses the library's default. +The possible values for this option are CR, LF, CRLF, ANYCRLF, or ANY. This +makes it possible to use <b>pcre2grep</b> to scan files that have come from other +environments without having to modify their line endings. If the data that is +being scanned does not agree with the convention set by this option, +<b>pcre2grep</b> may behave in strange ways. Note that this option does not +apply to files specified by the <b>-f</b>, <b>--exclude-from</b>, or +<b>--include-from</b> options, which are expected to use the operating system's +standard newline sequence. +</P> +<P> +<b>-n</b>, <b>--line-number</b> +Precede each output line by its line number in the file, followed by a colon +for matching lines or a hyphen for context lines. If the filename is also being +output, it precedes the line number. This option is forced if +<b>--line-offsets</b> is used. +</P> +<P> +<b>--no-jit</b> +If the PCRE2 library is built with support for just-in-time compiling (which +speeds up matching), <b>pcre2grep</b> automatically makes use of this, unless it +was explicitly disabled at build time. This option can be used to disable the +use of JIT at run time. It is provided for testing and working round problems. +It should never be needed in normal use. +</P> +<P> +<b>-o</b>, <b>--only-matching</b> +Show only the part of the line that matched a pattern instead of the whole +line. In this mode, no context is shown. That is, the <b>-A</b>, <b>-B</b>, and +<b>-C</b> options are ignored. If there is more than one match in a line, each +of them is shown separately. If <b>-o</b> is combined with <b>-v</b> (invert the +sense of the match to find non-matching lines), no output is generated, but the +return code is set appropriately. If the matched portion of the line is empty, +nothing is output unless the file name or line number are being printed, in +which case they are shown on an otherwise empty line. This option is mutually +exclusive with <b>--file-offsets</b> and <b>--line-offsets</b>. +</P> +<P> +<b>-o</b><i>number</i>, <b>--only-matching</b>=<i>number</i> +Show only the part of the line that matched the capturing parentheses of the +given number. Up to 32 capturing parentheses are supported, and -o0 is +equivalent to <b>-o</b> without a number. Because these options can be given +without an argument (see above), if an argument is present, it must be given in +the same shell item, for example, -o3 or --only-matching=2. The comments given +for the non-argument case above also apply to this case. If the specified +capturing parentheses do not exist in the pattern, or were not set in the +match, nothing is output unless the file name or line number are being printed. +<br> +<br> +If this option is given multiple times, multiple substrings are output, in the +order the options are given. For example, -o3 -o1 -o3 causes the substrings +matched by capturing parentheses 3 and 1 and then 3 again to be output. By +default, there is no separator (but see the next option). +</P> +<P> +<b>--om-separator</b>=<i>text</i> +Specify a separating string for multiple occurrences of <b>-o</b>. The default +is an empty string. Separating strings are never coloured. +</P> +<P> +<b>-q</b>, <b>--quiet</b> +Work quietly, that is, display nothing except error messages. The exit +status indicates whether or not any matches were found. +</P> +<P> +<b>-r</b>, <b>--recursive</b> +If any given path is a directory, recursively scan the files it contains, +taking note of any <b>--include</b> and <b>--exclude</b> settings. By default, a +directory is read as a normal file; in some operating systems this gives an +immediate end-of-file. This option is a shorthand for setting the <b>-d</b> +option to "recurse". +</P> +<P> +<b>--recursion-limit</b>=<i>number</i> +See <b>--match-limit</b> above. +</P> +<P> +<b>-s</b>, <b>--no-messages</b> +Suppress error messages about non-existent or unreadable files. Such files are +quietly skipped. However, the return code is still 2, even if matches were +found in other files. +</P> +<P> +<b>-u</b>, <b>--utf-8</b> +Operate in UTF-8 mode. This option is available only if PCRE2 has been compiled +with UTF-8 support. All patterns (including those for any <b>--exclude</b> and +<b>--include</b> options) and all subject lines that are scanned must be valid +strings of UTF-8 characters. +</P> +<P> +<b>-V</b>, <b>--version</b> +Write the version numbers of <b>pcre2grep</b> and the PCRE2 library to the +standard output and then exit. Anything else on the command line is +ignored. +</P> +<P> +<b>-v</b>, <b>--invert-match</b> +Invert the sense of the match, so that lines which do <i>not</i> match any of +the patterns are the ones that are found. +</P> +<P> +<b>-w</b>, <b>--word-regex</b>, <b>--word-regexp</b> +Force the patterns to match only whole words. This is equivalent to having \b +at the start and end of the pattern. This option applies only to the patterns +that are matched against the contents of files; it does not apply to patterns +specified by any of the <b>--include</b> or <b>--exclude</b> options. +</P> +<P> +<b>-x</b>, <b>--line-regex</b>, <b>--line-regexp</b> +Force the patterns to be anchored (each must start matching at the beginning of +a line) and in addition, require them to match entire lines. This is equivalent +to having ^ and $ characters at the start and end of each alternative branch in +every pattern. This option applies only to the patterns that are matched +against the contents of files; it does not apply to patterns specified by any +of the <b>--include</b> or <b>--exclude</b> options. +</P> +<br><a name="SEC6" href="#TOC1">ENVIRONMENT VARIABLES</a><br> +<P> +The environment variables <b>LC_ALL</b> and <b>LC_CTYPE</b> are examined, in that +order, for a locale. The first one that is set is used. This can be overridden +by the <b>--locale</b> option. If no locale is set, the PCRE2 library's default +(usually the "C" locale) is used. +</P> +<br><a name="SEC7" href="#TOC1">NEWLINES</a><br> +<P> +The <b>-N</b> (<b>--newline</b>) option allows <b>pcre2grep</b> to scan files with +different newline conventions from the default. Any parts of the input files +that are written to the standard output are copied identically, with whatever +newline sequences they have in the input. However, the setting of this option +does not affect the interpretation of files specified by the <b>-f</b>, +<b>--exclude-from</b>, or <b>--include-from</b> options, which are assumed to use +the operating system's standard newline sequence, nor does it affect the way in +which <b>pcre2grep</b> writes informational messages to the standard error and +output streams. For these it uses the string "\n" to indicate newlines, +relying on the C I/O library to convert this to an appropriate sequence. +</P> +<br><a name="SEC8" href="#TOC1">OPTIONS COMPATIBILITY</a><br> +<P> +Many of the short and long forms of <b>pcre2grep</b>'s options are the same +as in the GNU <b>grep</b> program. Any long option of the form +<b>--xxx-regexp</b> (GNU terminology) is also available as <b>--xxx-regex</b> +(PCRE2 terminology). However, the <b>--file-list</b>, <b>--file-offsets</b>, +<b>--include-dir</b>, <b>--line-offsets</b>, <b>--locale</b>, <b>--match-limit</b>, +<b>-M</b>, <b>--multiline</b>, <b>-N</b>, <b>--newline</b>, <b>--om-separator</b>, +<b>--recursion-limit</b>, <b>-u</b>, and <b>--utf-8</b> options are specific to +<b>pcre2grep</b>, as is the use of the <b>--only-matching</b> option with a +capturing parentheses number. +</P> +<P> +Although most of the common options work the same way, a few are different in +<b>pcre2grep</b>. For example, the <b>--include</b> option's argument is a glob +for GNU <b>grep</b>, but a regular expression for <b>pcre2grep</b>. If both the +<b>-c</b> and <b>-l</b> options are given, GNU grep lists only file names, +without counts, but <b>pcre2grep</b> gives the counts. +</P> +<br><a name="SEC9" href="#TOC1">OPTIONS WITH DATA</a><br> +<P> +There are four different ways in which an option with data can be specified. +If a short form option is used, the data may follow immediately, or (with one +exception) in the next command line item. For example: +<pre> + -f/some/file + -f /some/file +</pre> +The exception is the <b>-o</b> option, which may appear with or without data. +Because of this, if data is present, it must follow immediately in the same +item, for example -o3. +</P> +<P> +If a long form option is used, the data may appear in the same command line +item, separated by an equals character, or (with two exceptions) it may appear +in the next command line item. For example: +<pre> + --file=/some/file + --file /some/file +</pre> +Note, however, that if you want to supply a file name beginning with ~ as data +in a shell command, and have the shell expand ~ to a home directory, you must +separate the file name from the option, because the shell does not treat ~ +specially unless it is at the start of an item. +</P> +<P> +The exceptions to the above are the <b>--colour</b> (or <b>--color</b>) and +<b>--only-matching</b> options, for which the data is optional. If one of these +options does have data, it must be given in the first form, using an equals +character. Otherwise <b>pcre2grep</b> will assume that it has no data. +</P> +<br><a name="SEC10" href="#TOC1">MATCHING ERRORS</a><br> +<P> +It is possible to supply a regular expression that takes a very long time to +fail to match certain lines. Such patterns normally involve nested indefinite +repeats, for example: (a+)*\d when matched against a line of a's with no final +digit. The PCRE2 matching function has a resource limit that causes it to abort +in these circumstances. If this happens, <b>pcre2grep</b> outputs an error +message and the line that caused the problem to the standard error stream. If +there are more than 20 such errors, <b>pcre2grep</b> gives up. +</P> +<P> +The <b>--match-limit</b> option of <b>pcre2grep</b> can be used to set the overall +resource limit; there is a second option called <b>--recursion-limit</b> that +sets a limit on the amount of memory (usually stack) that is used (see the +discussion of these options above). +</P> +<br><a name="SEC11" href="#TOC1">DIAGNOSTICS</a><br> +<P> +Exit status is 0 if any matches were found, 1 if no matches were found, and 2 +for syntax errors, overlong lines, non-existent or inaccessible files (even if +matches were found in other files) or too many matching errors. Using the +<b>-s</b> option to suppress error messages about inaccessible files does not +affect the return code. +</P> +<br><a name="SEC12" href="#TOC1">SEE ALSO</a><br> +<P> +<b>pcre2pattern</b>(3), <b>pcre2syntax</b>(3), <b>pcre2test</b>(1). +</P> +<br><a name="SEC13" href="#TOC1">AUTHOR</a><br> +<P> +Philip Hazel +<br> +University Computing Service +<br> +Cambridge CB2 3QH, England. +<br> +</P> +<br><a name="SEC14" href="#TOC1">REVISION</a><br> +<P> +Last updated: 28 September 2014 +<br> +Copyright © 1997-2014 University of Cambridge. +<br> +<p> +Return to the <a href="index.html">PCRE2 index page</a>. +</p> |