📄 readme
字号:
README file for PCRE (Perl-compatible regular expression library)-----------------------------------------------------------------The latest release of PCRE is always available from ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-xxx.tar.gzPlease read the NEWS file if you are upgrading from a previous release.The PCRE APIs-------------PCRE is written in C, and it has its own API. The distribution now includes aset of C++ wrapper functions, courtesy of Google Inc. (see the pcrecpp man pagefor details).Also included are a set of C wrapper functions that are based on the POSIXAPI. These end up in the library called libpcreposix. Note that this justprovides a POSIX calling interface to PCRE: the regular expressions themselvesstill follow Perl syntax and semantics. The header file for the POSIX-stylefunctions is called pcreposix.h. The official POSIX name is regex.h, but Ididn't want to risk possible problems with existing files of that name bydistributing it that way. To use it with an existing program that uses thePOSIX API, it will have to be renamed or pointed at by a link.If you are using the POSIX interface to PCRE and there is already a POSIX regexlibrary installed on your system, you must take care when linking programs toensure that they link with PCRE's libpcreposix library. Otherwise they may pickup the "real" POSIX functions of the same name.Documentation for PCRE----------------------If you install PCRE in the normal way, you will end up with an installed set ofman pages whose names all start with "pcre". The one that is called "pcre"lists all the others. In addition to these man pages, the PCRE documentation issupplied in two other forms; however, as there is no standard place to installthem, they are left in the doc directory of the unpacked source distribution.These forms are: 1. Files called doc/pcre.txt, doc/pcregrep.txt, and doc/pcretest.txt. The first of these is a concatenation of the text forms of all the section 3 man pages except those that summarize individual functions. The other two are the text forms of the section 1 man pages for the pcregrep and pcretest commands. Text forms are provided for ease of scanning with text editors or similar tools. 2. A subdirectory called doc/html contains all the documentation in HTML form, hyperlinked in various ways, and rooted in a file called doc/index.html.Contributions by users of PCRE------------------------------You can find contributions from PCRE users in the directory ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contribwhere there is also a README file giving brief descriptions of what they are.Several of them provide support for compiling PCRE on various flavours ofWindows systems (I myself do not use Windows). Some are complete in themselves;others are pointers to URLs containing relevant files.Building PCRE on a Unix-like system-----------------------------------If you are using HP's ANSI C++ compiler (aCC), please see the special notein the section entitled "Using HP's ANSI C++ compiler (aCC)" below.To build PCRE on a Unix-like system, first run the "configure" command from thePCRE distribution directory, with your current directory set to the directorywhere you want the files to be created. This command is a standard GNU"autoconf" configuration script, for which generic instructions are supplied inINSTALL.Most commonly, people build PCRE within its own distribution directory, and inthis case, on many systems, just running "./configure" is sufficient, but theusual methods of changing standard defaults are available. For example:CFLAGS='-O2 -Wall' ./configure --prefix=/opt/localspecifies that the C compiler should be run with the flags '-O2 -Wall' insteadof the default, and that "make install" should install PCRE under /opt/localinstead of the default /usr/local.If you want to build in a different directory, just run "configure" with thatdirectory as current. For example, suppose you have unpacked the PCRE sourceinto /source/pcre/pcre-xxx, but you want to build it in /build/pcre/pcre-xxx:cd /build/pcre/pcre-xxx/source/pcre/pcre-xxx/configurePCRE is written in C and is normally compiled as a C library. However, it ispossible to build it as a C++ library, though the provided building apparatusdoes not have any features to support this.There are some optional features that can be included or omitted from the PCRElibrary. You can read more about them in the pcrebuild man page.. If you want to suppress the building of the C++ wrapper library, you can add --disable-cpp to the "configure" command. Otherwise, when "configure" is run, will try to find a C++ compiler and C++ header files, and if it succeeds, it will try to build the C++ wrapper.. If you want to make use of the support for UTF-8 character strings in PCRE, you must add --enable-utf8 to the "configure" command. Without it, the code for handling UTF-8 is not included in the library. (Even when included, it still has to be enabled by an option at run time.). If, in addition to support for UTF-8 character strings, you want to include support for the \P, \p, and \X sequences that recognize Unicode character properties, you must add --enable-unicode-properties to the "configure" command. This adds about 90K to the size of the library (in the form of a property table); only the basic two-letter properties such as Lu are supported.. You can build PCRE to recognize either CR or LF as the newline character, instead of whatever your compiler uses for "\n", by adding --newline-is-cr or --newline-is-lf to the "configure" command, respectively. Only do this if you really understand what you are doing. On traditional Unix-like systems, the newline character is LF.. When called via the POSIX interface, PCRE uses malloc() to get additional storage for processing capturing parentheses if there are more than 10 of them. You can increase this threshold by setting, for example, --with-posix-malloc-threshold=20 on the "configure" command.. PCRE has a counter that can be set to limit the amount of resources it uses. 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 pcre_exec() can supply their own value. There is discussion on the pcreapi man page.. The default maximum compiled pattern size is around 64K. You can increase this by adding --with-link-size=3 to the "configure" command. You can increase it even more by setting --with-link-size=4, but this is unlikely ever to be necessary. If you build PCRE with an increased link size, test 2 (and 5 if you are using UTF-8) will fail. Part of the output of these tests is a representation of the compiled pattern, and this changes with the link size.. You can build PCRE so that its internal match() function that is called from pcre_exec() does not call itself recursively. Instead, it uses blocks of data from the heap via special functions pcre_stack_malloc() and pcre_stack_free() to save data that would otherwise be saved on the stack. To build PCRE like this, use --disable-stack-for-recursion on the "configure" command. PCRE runs more slowly in this mode, but it may be necessary in environments with limited stack sizes. This applies only to the pcre_exec() function; it does not apply to pcre_dfa_exec(), which does not use deeply nested recursion.The "configure" script builds eight files for the basic C library:. pcre.h is the header file for C programs that call PCRE. Makefile is the makefile that builds the library. config.h contains build-time configuration options for the library. pcre-config is a script that shows the settings of "configure" options. libpcre.pc is data for the pkg-config command. libtool is a script that builds shared and/or static libraries. RunTest is a script for running tests on the library. RunGrepTest is a script for running tests on the pcregrep commandIn addition, if a C++ compiler is found, the following are also built:. pcrecpp.h is the header file for programs that call PCRE via the C++ wrapper. pcre_stringpiece.h is the header for the C++ "stringpiece" functionsThe "configure" script also creates config.status, which is an executablescript that can be run to recreate the configuration, and config.log, whichcontains compiler output from tests that "configure" runs.Once "configure" has run, you can run "make". It builds two libraries, calledlibpcre and libpcreposix, a test program called pcretest, and the pcregrepcommand. If a C++ compiler was found on your system, it also builds the C++wrapper library, which is called libpcrecpp, and some test programs calledpcrecpp_unittest, pcre_scanner_unittest, and pcre_stringpiece_unittest.The command "make test" runs all the appropriate tests. Details of the PCREtests are given in a separate section of this document, below.You can use "make install" to copy the libraries, the public header filespcre.h, pcreposix.h, pcrecpp.h, and pcre_stringpiece.h (the last two only ifthe C++ wrapper was built), and the man pages to appropriate live directorieson your system, in the normal way.If you want to remove PCRE from your system, you can run "make uninstall".This removes all the files that "make install" installed. However, it does notremove any directories, because these are often shared with other programs.Retrieving configuration information on Unix-like systems---------------------------------------------------------Running "make install" also installs the command pcre-config, which can be usedto recall information about the PCRE configuration and installation. Forexample: pcre-config --versionprints the version number, and pcre-config --libsoutputs information about where the library is installed. This command can beincluded in makefiles for programs that use PCRE, saving the programmer fromhaving to remember too many details.The pkg-config command is another system for saving and retrieving informationabout installed libraries. Instead of separate commands for each library, asingle command is used. For example: pkg-config --cflags pcreThe data is held in *.pc files that are installed in a directory calledpkgconfig.Shared libraries on Unix-like systems-------------------------------------The default distribution builds PCRE as shared libraries and static libraries,as long as the operating system supports shared libraries. Shared librarysupport 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 staticlibraries. They are placed in a subdirectory called .libs when they are newlybuilt. The programs pcretest and pcregrep are built to use these uninstalledlibraries (by means of wrapper scripts in the case of shared libraries). Whenyou use "make install" to install shared libraries, pcregrep and pcretest areautomatically re-built to use the newly installed shared libraries before beinginstalled themselves. However, the versions left in the source directory stilluse the uninstalled libraries.To build PCRE using static libraries only you must use --disable-shared whenconfiguring it. For example:./configure --prefix=/usr/gnu --disable-sharedThen run "make" in the usual way. Similarly, you can use --disable-static tobuild only shared libraries.Cross-compiling on a Unix-like system-------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -