github的一些开源项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

956 lines
44 KiB

  1. README file for PCRE2 (Perl-compatible regular expression library)
  2. ------------------------------------------------------------------
  3. PCRE2 is a re-working of the original PCRE1 library to provide an entirely new
  4. API. Since its initial release in 2015, there has been further development of
  5. the code and it now differs from PCRE1 in more than just the API. There are new
  6. features, and the internals have been improved. The original PCRE1 library is
  7. now obsolete and no longer maintained. The latest release of PCRE2 is available
  8. in .tar.gz, tar.bz2, or .zip form from this GitHub repository:
  9. https://github.com/PCRE2Project/pcre2/releases
  10. There is a mailing list for discussion about the development of PCRE2 at
  11. pcre2-dev@googlegroups.com. You can subscribe by sending an email to
  12. pcre2-dev+subscribe@googlegroups.com.
  13. You can access the archives and also subscribe or manage your subscription
  14. here:
  15. https://groups.google.com/g/pcre2-dev
  16. Please read the NEWS file if you are upgrading from a previous release. The
  17. contents of this README file are:
  18. The PCRE2 APIs
  19. Documentation for PCRE2
  20. Building PCRE2 on non-Unix-like systems
  21. Building PCRE2 without using autotools
  22. Building PCRE2 using autotools
  23. Retrieving configuration information
  24. Shared libraries
  25. Cross-compiling using autotools
  26. Making new tarballs
  27. Testing PCRE2
  28. Character tables
  29. File manifest
  30. The PCRE2 APIs
  31. --------------
  32. PCRE2 is written in C, and it has its own API. There are three sets of
  33. functions, one for the 8-bit library, which processes strings of bytes, one for
  34. the 16-bit library, which processes strings of 16-bit values, and one for the
  35. 32-bit library, which processes strings of 32-bit values. Unlike PCRE1, there
  36. are no C++ wrappers.
  37. The distribution does contain a set of C wrapper functions for the 8-bit
  38. library that are based on the POSIX regular expression API (see the pcre2posix
  39. man page). These are built into a library called libpcre2-posix. Note that this
  40. just provides a POSIX calling interface to PCRE2; the regular expressions
  41. themselves still follow Perl syntax and semantics. The POSIX API is restricted,
  42. and does not give full access to all of PCRE2's facilities.
  43. The header file for the POSIX-style functions is called pcre2posix.h. The
  44. official POSIX name is regex.h, but I did not want to risk possible problems
  45. with existing files of that name by distributing it that way. To use PCRE2 with
  46. an existing program that uses the POSIX API, pcre2posix.h will have to be
  47. renamed or pointed at by a link (or the program modified, of course). See the
  48. pcre2posix documentation for more details.
  49. Documentation for PCRE2
  50. -----------------------
  51. If you install PCRE2 in the normal way on a Unix-like system, you will end up
  52. with a set of man pages whose names all start with "pcre2". The one that is
  53. just called "pcre2" lists all the others. In addition to these man pages, the
  54. PCRE2 documentation is supplied in two other forms:
  55. 1. There are files called doc/pcre2.txt, doc/pcre2grep.txt, and
  56. doc/pcre2test.txt in the source distribution. The first of these is a
  57. concatenation of the text forms of all the section 3 man pages except the
  58. listing of pcre2demo.c and those that summarize individual functions. The
  59. other two are the text forms of the section 1 man pages for the pcre2grep
  60. and pcre2test commands. These text forms are provided for ease of scanning
  61. with text editors or similar tools. They are installed in
  62. <prefix>/share/doc/pcre2, where <prefix> is the installation prefix
  63. (defaulting to /usr/local).
  64. 2. A set of files containing all the documentation in HTML form, hyperlinked
  65. in various ways, and rooted in a file called index.html, is distributed in
  66. doc/html and installed in <prefix>/share/doc/pcre2/html.
  67. Building PCRE2 on non-Unix-like systems
  68. ---------------------------------------
  69. For a non-Unix-like system, please read the file NON-AUTOTOOLS-BUILD, though if
  70. your system supports the use of "configure" and "make" you may be able to build
  71. PCRE2 using autotools in the same way as for many Unix-like systems.
  72. PCRE2 can also be configured using CMake, which can be run in various ways
  73. (command line, GUI, etc). This creates Makefiles, solution files, etc. The file
  74. NON-AUTOTOOLS-BUILD has information about CMake.
  75. PCRE2 has been compiled on many different operating systems. It should be
  76. straightforward to build PCRE2 on any system that has a Standard C compiler and
  77. library, because it uses only Standard C functions.
  78. Building PCRE2 without using autotools
  79. --------------------------------------
  80. The use of autotools (in particular, libtool) is problematic in some
  81. environments, even some that are Unix or Unix-like. See the NON-AUTOTOOLS-BUILD
  82. file for ways of building PCRE2 without using autotools.
  83. Building PCRE2 using autotools
  84. ------------------------------
  85. The following instructions assume the use of the widely used "configure; make;
  86. make install" (autotools) process.
  87. If you have downloaded and unpacked a PCRE2 release tarball, run the
  88. "configure" command from the PCRE2 directory, with your current directory set
  89. to the directory where you want the files to be created. This command is a
  90. standard GNU "autoconf" configuration script, for which generic instructions
  91. are supplied in the file INSTALL.
  92. The files in the GitHub repository do not contain "configure". If you have
  93. downloaded the PCRE2 source files from GitHub, before you can run "configure"
  94. you must run the shell script called autogen.sh. This runs a number of
  95. autotools to create a "configure" script (you must of course have the autotools
  96. commands installed in order to do this).
  97. Most commonly, people build PCRE2 within its own distribution directory, and in
  98. this case, on many systems, just running "./configure" is sufficient. However,
  99. the usual methods of changing standard defaults are available. For example:
  100. CFLAGS='-O2 -Wall' ./configure --prefix=/opt/local
  101. This command specifies that the C compiler should be run with the flags '-O2
  102. -Wall' instead of the default, and that "make install" should install PCRE2
  103. under /opt/local instead of the default /usr/local.
  104. If you want to build in a different directory, just run "configure" with that
  105. directory as current. For example, suppose you have unpacked the PCRE2 source
  106. into /source/pcre2/pcre2-xxx, but you want to build it in
  107. /build/pcre2/pcre2-xxx:
  108. cd /build/pcre2/pcre2-xxx
  109. /source/pcre2/pcre2-xxx/configure
  110. PCRE2 is written in C and is normally compiled as a C library. However, it is
  111. possible to build it as a C++ library, though the provided building apparatus
  112. does not have any features to support this.
  113. There are some optional features that can be included or omitted from the PCRE2
  114. library. They are also documented in the pcre2build man page.
  115. . By default, both shared and static libraries are built. You can change this
  116. by adding one of these options to the "configure" command:
  117. --disable-shared
  118. --disable-static
  119. Setting --disable-shared ensures that PCRE2 libraries are built as static
  120. libraries. The binaries that are then created as part of the build process
  121. (for example, pcre2test and pcre2grep) are linked statically with one or more
  122. PCRE2 libraries, but may also be dynamically linked with other libraries such
  123. as libc. If you want these binaries to be fully statically linked, you can
  124. set LDFLAGS like this:
  125. LDFLAGS=--static ./configure --disable-shared
  126. Note the two hyphens in --static. Of course, this works only if static
  127. versions of all the relevant libraries are available for linking. See also
  128. "Shared libraries" below.
  129. . By default, only the 8-bit library is built. If you add --enable-pcre2-16 to
  130. the "configure" command, the 16-bit library is also built. If you add
  131. --enable-pcre2-32 to the "configure" command, the 32-bit library is also
  132. built. If you want only the 16-bit or 32-bit library, use --disable-pcre2-8
  133. to disable building the 8-bit library.
  134. . If you want to include support for just-in-time (JIT) compiling, which can
  135. give large performance improvements on certain platforms, add --enable-jit to
  136. the "configure" command. This support is available only for certain hardware
  137. architectures. If you try to enable it on an unsupported architecture, there
  138. will be a compile time error. If in doubt, use --enable-jit=auto, which
  139. enables JIT only if the current hardware is supported.
  140. . If you are enabling JIT under SELinux environment you may also want to add
  141. --enable-jit-sealloc, which enables the use of an executable memory allocator
  142. that is compatible with SELinux. Warning: this allocator is experimental!
  143. It does not support fork() operation and may crash when no disk space is
  144. available. This option has no effect if JIT is disabled.
  145. . If you do not want to make use of the default support for UTF-8 Unicode
  146. character strings in the 8-bit library, UTF-16 Unicode character strings in
  147. the 16-bit library, or UTF-32 Unicode character strings in the 32-bit
  148. library, you can add --disable-unicode to the "configure" command. This
  149. reduces the size of the libraries. It is not possible to configure one
  150. library with Unicode support, and another without, in the same configuration.
  151. It is also not possible to use --enable-ebcdic (see below) with Unicode
  152. support, so if this option is set, you must also use --disable-unicode.
  153. When Unicode support is available, the use of a UTF encoding still has to be
  154. enabled by setting the PCRE2_UTF option at run time or starting a pattern
  155. with (*UTF). When PCRE2 is compiled with Unicode support, its input can only
  156. either be ASCII or UTF-8/16/32, even when running on EBCDIC platforms.
  157. As well as supporting UTF strings, Unicode support includes support for the
  158. \P, \p, and \X sequences that recognize Unicode character properties.
  159. However, only a subset of Unicode properties are supported; see the
  160. pcre2pattern man page for details. Escape sequences such as \d and \w in
  161. patterns do not by default make use of Unicode properties, but can be made to
  162. do so by setting the PCRE2_UCP option or starting a pattern with (*UCP).
  163. . You can build PCRE2 to recognize either CR or LF or the sequence CRLF, or any
  164. of the preceding, or any of the Unicode newline sequences, or the NUL (zero)
  165. character as indicating the end of a line. Whatever you specify at build time
  166. is the default; the caller of PCRE2 can change the selection at run time. The
  167. default newline indicator is a single LF character (the Unix standard). You
  168. can specify the default newline indicator by adding --enable-newline-is-cr,
  169. --enable-newline-is-lf, --enable-newline-is-crlf,
  170. --enable-newline-is-anycrlf, --enable-newline-is-any, or
  171. --enable-newline-is-nul to the "configure" command, respectively.
  172. . By default, the sequence \R in a pattern matches any Unicode line ending
  173. sequence. This is independent of the option specifying what PCRE2 considers
  174. to be the end of a line (see above). However, the caller of PCRE2 can
  175. restrict \R to match only CR, LF, or CRLF. You can make this the default by
  176. adding --enable-bsr-anycrlf to the "configure" command (bsr = "backslash R").
  177. . In a pattern, the escape sequence \C matches a single code unit, even in a
  178. UTF mode. This can be dangerous because it breaks up multi-code-unit
  179. characters. You can build PCRE2 with the use of \C permanently locked out by
  180. adding --enable-never-backslash-C (note the upper case C) to the "configure"
  181. command. When \C is allowed by the library, individual applications can lock
  182. it out by calling pcre2_compile() with the PCRE2_NEVER_BACKSLASH_C option.
  183. . PCRE2 has a counter that limits the depth of nesting of parentheses in a
  184. pattern. This limits the amount of system stack that a pattern uses when it
  185. is compiled. The default is 250, but you can change it by setting, for
  186. example,
  187. --with-parens-nest-limit=500
  188. . PCRE2 has a counter that can be set to limit the amount of computing resource
  189. it uses when matching a pattern. If the limit is exceeded during a match, the
  190. match fails. The default is ten million. You can change the default by
  191. setting, for example,
  192. --with-match-limit=500000
  193. on the "configure" command. This is just the default; individual calls to
  194. pcre2_match() or pcre2_dfa_match() can supply their own value. There is more
  195. discussion in the pcre2api man page (search for pcre2_set_match_limit).
  196. . There is a separate counter that limits the depth of nested backtracking
  197. (pcre2_match()) or nested function calls (pcre2_dfa_match()) during a
  198. matching process, which indirectly limits the amount of heap memory that is
  199. used, and in the case of pcre2_dfa_match() the amount of stack as well. This
  200. counter also has a default of ten million, which is essentially "unlimited".
  201. You can change the default by setting, for example,
  202. --with-match-limit-depth=5000
  203. There is more discussion in the pcre2api man page (search for
  204. pcre2_set_depth_limit).
  205. . You can also set an explicit limit on the amount of heap memory used by
  206. the pcre2_match() and pcre2_dfa_match() interpreters:
  207. --with-heap-limit=500
  208. The units are kibibytes (units of 1024 bytes). This limit does not apply when
  209. the JIT optimization (which has its own memory control features) is used.
  210. There is more discussion on the pcre2api man page (search for
  211. pcre2_set_heap_limit).
  212. . In the 8-bit library, the default maximum compiled pattern size is around
  213. 64 kibibytes. You can increase this by adding --with-link-size=3 to the
  214. "configure" command. PCRE2 then uses three bytes instead of two for offsets
  215. to different parts of the compiled pattern. In the 16-bit library,
  216. --with-link-size=3 is the same as --with-link-size=4, which (in both
  217. libraries) uses four-byte offsets. Increasing the internal link size reduces
  218. performance in the 8-bit and 16-bit libraries. In the 32-bit library, the
  219. link size setting is ignored, as 4-byte offsets are always used.
  220. . Lookbehind assertions in which one or more branches can match a variable
  221. number of characters are supported only if there is a maximum matching length
  222. for each top-level branch. There is a limit to this maximum that defaults to
  223. 255 characters. You can alter this default by a setting such as
  224. --with-max-varlookbehind=100
  225. The limit can be changed at runtime by calling pcre2_set_max_varlookbehind().
  226. Lookbehind assertions in which every branch matches a fixed number of
  227. characters (not necessarily all the same) are not constrained by this limit.
  228. . For speed, PCRE2 uses four tables for manipulating and identifying characters
  229. whose code point values are less than 256. By default, it uses a set of
  230. tables for ASCII encoding that is part of the distribution. If you specify
  231. --enable-rebuild-chartables
  232. a program called pcre2_dftables is compiled and run in the default C locale
  233. when you obey "make". It builds a source file called pcre2_chartables.c. If
  234. you do not specify this option, pcre2_chartables.c is created as a copy of
  235. pcre2_chartables.c.dist. See "Character tables" below for further
  236. information.
  237. . It is possible to compile PCRE2 for use on systems that use EBCDIC as their
  238. character code (as opposed to ASCII/Unicode) by specifying
  239. --enable-ebcdic --disable-unicode
  240. This automatically implies --enable-rebuild-chartables (see above). However,
  241. when PCRE2 is built this way, it always operates in EBCDIC. It cannot support
  242. both EBCDIC and UTF-8/16/32. There is a second option, --enable-ebcdic-nl25,
  243. which specifies that the code value for the EBCDIC NL character is 0x25
  244. instead of the default 0x15.
  245. . If you specify --enable-debug, additional debugging code is included in the
  246. build. This option is intended for use by the PCRE2 maintainers.
  247. . In environments where valgrind is installed, if you specify
  248. --enable-valgrind
  249. PCRE2 will use valgrind annotations to mark certain memory regions as
  250. unaddressable. This allows it to detect invalid memory accesses, and is
  251. mostly useful for debugging PCRE2 itself.
  252. . In environments where the gcc compiler is used and lcov is installed, if you
  253. specify
  254. --enable-coverage
  255. the build process implements a code coverage report for the test suite. The
  256. report is generated by running "make coverage". If ccache is installed on
  257. your system, it must be disabled when building PCRE2 for coverage reporting.
  258. You can do this by setting the environment variable CCACHE_DISABLE=1 before
  259. running "make" to build PCRE2. There is more information about coverage
  260. reporting in the "pcre2build" documentation.
  261. . When JIT support is enabled, pcre2grep automatically makes use of it, unless
  262. you add --disable-pcre2grep-jit to the "configure" command.
  263. . There is support for calling external programs during matching in the
  264. pcre2grep command, using PCRE2's callout facility with string arguments. This
  265. support can be disabled by adding --disable-pcre2grep-callout to the
  266. "configure" command. There are two kinds of callout: one that generates
  267. output from inbuilt code, and another that calls an external program. The
  268. latter has special support for Windows and VMS; otherwise it assumes the
  269. existence of the fork() function. This facility can be disabled by adding
  270. --disable-pcre2grep-callout-fork to the "configure" command.
  271. . The pcre2grep program currently supports only 8-bit data files, and so
  272. requires the 8-bit PCRE2 library. It is possible to compile pcre2grep to use
  273. libz and/or libbz2, in order to read .gz and .bz2 files (respectively), by
  274. specifying one or both of
  275. --enable-pcre2grep-libz
  276. --enable-pcre2grep-libbz2
  277. Of course, the relevant libraries must be installed on your system.
  278. . The default starting size (in bytes) of the internal buffer used by pcre2grep
  279. can be set by, for example:
  280. --with-pcre2grep-bufsize=51200
  281. The value must be a plain integer. The default is 20480. The amount of memory
  282. used by pcre2grep is actually three times this number, to allow for "before"
  283. and "after" lines. If very long lines are encountered, the buffer is
  284. automatically enlarged, up to a fixed maximum size.
  285. . The default maximum size of pcre2grep's internal buffer can be set by, for
  286. example:
  287. --with-pcre2grep-max-bufsize=2097152
  288. The default is either 1048576 or the value of --with-pcre2grep-bufsize,
  289. whichever is the larger.
  290. . It is possible to compile pcre2test so that it links with the libreadline
  291. or libedit libraries, by specifying, respectively,
  292. --enable-pcre2test-libreadline or --enable-pcre2test-libedit
  293. If this is done, when pcre2test's input is from a terminal, it reads it using
  294. the readline() function. This provides line-editing and history facilities.
  295. Note that libreadline is GPL-licenced, so if you distribute a binary of
  296. pcre2test linked in this way, there may be licensing issues. These can be
  297. avoided by linking with libedit (which has a BSD licence) instead.
  298. Enabling libreadline causes the -lreadline option to be added to the
  299. pcre2test build. In many operating environments with a system-installed
  300. readline library this is sufficient. However, in some environments (e.g. if
  301. an unmodified distribution version of readline is in use), it may be
  302. necessary to specify something like LIBS="-lncurses" as well. This is
  303. because, to quote the readline INSTALL, "Readline uses the termcap functions,
  304. but does not link with the termcap or curses library itself, allowing
  305. applications which link with readline the option to choose an appropriate
  306. library." If you get error messages about missing functions tgetstr, tgetent,
  307. tputs, tgetflag, or tgoto, this is the problem, and linking with the ncurses
  308. library should fix it.
  309. . The C99 standard defines formatting modifiers z and t for size_t and
  310. ptrdiff_t values, respectively. By default, PCRE2 uses these modifiers in
  311. environments other than Microsoft Visual Studio versions earlier than 2013
  312. when __STDC_VERSION__ is defined and has a value greater than or equal to
  313. 199901L (indicating C99). However, there is at least one environment that
  314. claims to be C99 but does not support these modifiers. If
  315. --disable-percent-zt is specified, no use is made of the z or t modifiers.
  316. Instead of %td or %zu, %lu is used, with a cast for size_t values.
  317. . There is a special option called --enable-fuzz-support for use by people who
  318. want to run fuzzing tests on PCRE2. At present this applies only to the 8-bit
  319. library. If set, it causes an extra library called libpcre2-fuzzsupport.a to
  320. be built, but not installed. This contains a single function called
  321. LLVMFuzzerTestOneInput() whose arguments are a pointer to a string and the
  322. length of the string. When called, this function tries to compile the string
  323. as a pattern, and if that succeeds, to match it. This is done both with no
  324. options and with some random options bits that are generated from the string.
  325. Setting --enable-fuzz-support also causes a binary called pcre2fuzzcheck to
  326. be created. This is normally run under valgrind or used when PCRE2 is
  327. compiled with address sanitizing enabled. It calls the fuzzing function and
  328. outputs information about what it is doing. The input strings are specified
  329. by arguments: if an argument starts with "=" the rest of it is a literal
  330. input string. Otherwise, it is assumed to be a file name, and the contents
  331. of the file are the test string.
  332. . Releases before 10.30 could be compiled with --disable-stack-for-recursion,
  333. which caused pcre2_match() to use individual blocks on the heap for
  334. backtracking instead of recursive function calls (which use the stack). This
  335. is now obsolete because pcre2_match() was refactored always to use the heap
  336. (in a much more efficient way than before). This option is retained for
  337. backwards compatibility, but has no effect other than to output a warning.
  338. The "configure" script builds the following files for the basic C library:
  339. . Makefile the makefile that builds the library
  340. . src/config.h build-time configuration options for the library
  341. . src/pcre2.h the public PCRE2 header file
  342. . pcre2-config script that shows the building settings such as CFLAGS
  343. that were set for "configure"
  344. . libpcre2-8.pc )
  345. . libpcre2-16.pc ) data for the pkg-config command
  346. . libpcre2-32.pc )
  347. . libpcre2-posix.pc )
  348. . libtool script that builds shared and/or static libraries
  349. Versions of config.h and pcre2.h are distributed in the src directory of PCRE2
  350. tarballs under the names config.h.generic and pcre2.h.generic. These are
  351. provided for those who have to build PCRE2 without using "configure" or CMake.
  352. If you use "configure" or CMake, the .generic versions are not used.
  353. The "configure" script also creates config.status, which is an executable
  354. script that can be run to recreate the configuration, and config.log, which
  355. contains compiler output from tests that "configure" runs.
  356. Once "configure" has run, you can run "make". This builds whichever of the
  357. libraries libpcre2-8, libpcre2-16 and libpcre2-32 are configured, and a test
  358. program called pcre2test. If you enabled JIT support with --enable-jit, another
  359. test program called pcre2_jit_test is built as well. If the 8-bit library is
  360. built, libpcre2-posix, pcre2posix_test, and the pcre2grep command are also
  361. built. Running "make" with the -j option may speed up compilation on
  362. multiprocessor systems.
  363. The command "make check" runs all the appropriate tests. Details of the PCRE2
  364. tests are given below in a separate section of this document. The -j option of
  365. "make" can also be used when running the tests.
  366. You can use "make install" to install PCRE2 into live directories on your
  367. system. The following are installed (file names are all relative to the
  368. <prefix> that is set when "configure" is run):
  369. Commands (bin):
  370. pcre2test
  371. pcre2grep (if 8-bit support is enabled)
  372. pcre2-config
  373. Libraries (lib):
  374. libpcre2-8 (if 8-bit support is enabled)
  375. libpcre2-16 (if 16-bit support is enabled)
  376. libpcre2-32 (if 32-bit support is enabled)
  377. libpcre2-posix (if 8-bit support is enabled)
  378. Configuration information (lib/pkgconfig):
  379. libpcre2-8.pc
  380. libpcre2-16.pc
  381. libpcre2-32.pc
  382. libpcre2-posix.pc
  383. Header files (include):
  384. pcre2.h
  385. pcre2posix.h
  386. Man pages (share/man/man{1,3}):
  387. pcre2grep.1
  388. pcre2test.1
  389. pcre2-config.1
  390. pcre2.3
  391. pcre2*.3 (lots more pages, all starting "pcre2")
  392. HTML documentation (share/doc/pcre2/html):
  393. index.html
  394. *.html (lots more pages, hyperlinked from index.html)
  395. Text file documentation (share/doc/pcre2):
  396. AUTHORS
  397. COPYING
  398. ChangeLog
  399. LICENCE
  400. NEWS
  401. README
  402. pcre2.txt (a concatenation of the man(3) pages)
  403. pcre2test.txt the pcre2test man page
  404. pcre2grep.txt the pcre2grep man page
  405. pcre2-config.txt the pcre2-config man page
  406. If you want to remove PCRE2 from your system, you can run "make uninstall".
  407. This removes all the files that "make install" installed. However, it does not
  408. remove any directories, because these are often shared with other programs.
  409. Retrieving configuration information
  410. ------------------------------------
  411. Running "make install" installs the command pcre2-config, which can be used to
  412. recall information about the PCRE2 configuration and installation. For example:
  413. pcre2-config --version
  414. prints the version number, and
  415. pcre2-config --libs8
  416. outputs information about where the 8-bit library is installed. This command
  417. can be included in makefiles for programs that use PCRE2, saving the programmer
  418. from having to remember too many details. Run pcre2-config with no arguments to
  419. obtain a list of possible arguments.
  420. The pkg-config command is another system for saving and retrieving information
  421. about installed libraries. Instead of separate commands for each library, a
  422. single command is used. For example:
  423. pkg-config --libs libpcre2-16
  424. The data is held in *.pc files that are installed in a directory called
  425. <prefix>/lib/pkgconfig.
  426. Shared libraries
  427. ----------------
  428. The default distribution builds PCRE2 as shared libraries and static libraries,
  429. as long as the operating system supports shared libraries. Shared library
  430. support relies on the "libtool" script which is built as part of the
  431. "configure" process.
  432. The libtool script is used to compile and link both shared and static
  433. libraries. They are placed in a subdirectory called .libs when they are newly
  434. built. The programs pcre2test and pcre2grep are built to use these uninstalled
  435. libraries (by means of wrapper scripts in the case of shared libraries). When
  436. you use "make install" to install shared libraries, pcre2grep and pcre2test are
  437. automatically re-built to use the newly installed shared libraries before being
  438. installed themselves. However, the versions left in the build directory still
  439. use the uninstalled libraries.
  440. To build PCRE2 using static libraries only you must use --disable-shared when
  441. configuring it. For example:
  442. ./configure --prefix=/usr/gnu --disable-shared
  443. Then run "make" in the usual way. Similarly, you can use --disable-static to
  444. build only shared libraries. Note, however, that when you build only static
  445. libraries, binary programs such as pcre2test and pcre2grep may still be
  446. dynamically linked with other libraries (for example, libc) unless you set
  447. LDFLAGS to --static when running "configure".
  448. Cross-compiling using autotools
  449. -------------------------------
  450. You can specify CC and CFLAGS in the normal way to the "configure" command, in
  451. order to cross-compile PCRE2 for some other host. However, you should NOT
  452. specify --enable-rebuild-chartables, because if you do, the pcre2_dftables.c
  453. source file is compiled and run on the local host, in order to generate the
  454. inbuilt character tables (the pcre2_chartables.c file). This will probably not
  455. work, because pcre2_dftables.c needs to be compiled with the local compiler,
  456. not the cross compiler.
  457. When --enable-rebuild-chartables is not specified, pcre2_chartables.c is
  458. created by making a copy of pcre2_chartables.c.dist, which is a default set of
  459. tables that assumes ASCII code. Cross-compiling with the default tables should
  460. not be a problem.
  461. If you need to modify the character tables when cross-compiling, you should
  462. move pcre2_chartables.c.dist out of the way, then compile pcre2_dftables.c by
  463. hand and run it on the local host to make a new version of
  464. pcre2_chartables.c.dist. See the pcre2build section "Creating character tables
  465. at build time" for more details.
  466. Making new tarballs
  467. -------------------
  468. The command "make dist" creates three PCRE2 tarballs, in tar.gz, tar.bz2, and
  469. zip formats. The command "make distcheck" does the same, but then does a trial
  470. build of the new distribution to ensure that it works.
  471. If you have modified any of the man page sources in the doc directory, you
  472. should first run the PrepareRelease script before making a distribution. This
  473. script creates the .txt and HTML forms of the documentation from the man pages.
  474. Testing PCRE2
  475. -------------
  476. To test the basic PCRE2 library on a Unix-like system, run the RunTest script.
  477. There is another script called RunGrepTest that tests the pcre2grep command.
  478. When the 8-bit library is built, a test program for the POSIX wrapper, called
  479. pcre2posix_test, is compiled, and when JIT support is enabled, a test program
  480. called pcre2_jit_test is built. The scripts and the program tests are all run
  481. when you obey "make check". For other environments, see the instructions in
  482. NON-AUTOTOOLS-BUILD.
  483. The RunTest script runs the pcre2test test program (which is documented in its
  484. own man page) on each of the relevant testinput files in the testdata
  485. directory, and compares the output with the contents of the corresponding
  486. testoutput files. RunTest uses a file called testtry to hold the main output
  487. from pcre2test. Other files whose names begin with "test" are used as working
  488. files in some tests.
  489. Some tests are relevant only when certain build-time options were selected. For
  490. example, the tests for UTF-8/16/32 features are run only when Unicode support
  491. is available. RunTest outputs a comment when it skips a test.
  492. Many (but not all) of the tests that are not skipped are run twice if JIT
  493. support is available. On the second run, JIT compilation is forced. This
  494. testing can be suppressed by putting "-nojit" on the RunTest command line.
  495. The entire set of tests is run once for each of the 8-bit, 16-bit and 32-bit
  496. libraries that are enabled. If you want to run just one set of tests, call
  497. RunTest with either the -8, -16 or -32 option.
  498. If valgrind is installed, you can run the tests under it by putting "-valgrind"
  499. on the RunTest command line. To run pcre2test on just one or more specific test
  500. files, give their numbers as arguments to RunTest, for example:
  501. RunTest 2 7 11
  502. You can also specify ranges of tests such as 3-6 or 3- (meaning 3 to the
  503. end), or a number preceded by ~ to exclude a test. For example:
  504. Runtest 3-15 ~10
  505. This runs tests 3 to 15, excluding test 10, and just ~13 runs all the tests
  506. except test 13. Whatever order the arguments are in, the tests are always run
  507. in numerical order.
  508. You can also call RunTest with the single argument "list" to cause it to output
  509. a list of tests.
  510. The test sequence starts with "test 0", which is a special test that has no
  511. input file, and whose output is not checked. This is because it will be
  512. different on different hardware and with different configurations. The test
  513. exists in order to exercise some of pcre2test's code that would not otherwise
  514. be run.
  515. Tests 1 and 2 can always be run, as they expect only plain text strings (not
  516. UTF) and make no use of Unicode properties. The first test file can be fed
  517. directly into the perltest.sh script to check that Perl gives the same results.
  518. The only difference you should see is in the first few lines, where the Perl
  519. version is given instead of the PCRE2 version. The second set of tests check
  520. auxiliary functions, error detection, and run-time flags that are specific to
  521. PCRE2. It also uses the debugging flags to check some of the internals of
  522. pcre2_compile().
  523. If you build PCRE2 with a locale setting that is not the standard C locale, the
  524. character tables may be different (see next paragraph). In some cases, this may
  525. cause failures in the second set of tests. For example, in a locale where the
  526. isprint() function yields TRUE for characters in the range 128-255, the use of
  527. [:isascii:] inside a character class defines a different set of characters, and
  528. this shows up in this test as a difference in the compiled code, which is being
  529. listed for checking. For example, where the comparison test output contains
  530. [\x00-\x7f] the test might contain [\x00-\xff], and similarly in some other
  531. cases. This is not a bug in PCRE2.
  532. Test 3 checks pcre2_maketables(), the facility for building a set of character
  533. tables for a specific locale and using them instead of the default tables. The
  534. script uses the "locale" command to check for the availability of the "fr_FR",
  535. "french", or "fr" locale, and uses the first one that it finds. If the "locale"
  536. command fails, or if its output doesn't include "fr_FR", "french", or "fr" in
  537. the list of available locales, the third test cannot be run, and a comment is
  538. output to say why. If running this test produces an error like this:
  539. ** Failed to set locale "fr_FR"
  540. it means that the given locale is not available on your system, despite being
  541. listed by "locale". This does not mean that PCRE2 is broken. There are three
  542. alternative output files for the third test, because three different versions
  543. of the French locale have been encountered. The test passes if its output
  544. matches any one of them.
  545. Tests 4 and 5 check UTF and Unicode property support, test 4 being compatible
  546. with the perltest.sh script, and test 5 checking PCRE2-specific things.
  547. Tests 6 and 7 check the pcre2_dfa_match() alternative matching function, in
  548. non-UTF mode and UTF-mode with Unicode property support, respectively.
  549. Test 8 checks some internal offsets and code size features, but it is run only
  550. when Unicode support is enabled. The output is different in 8-bit, 16-bit, and
  551. 32-bit modes and for different link sizes, so there are different output files
  552. for each mode and link size.
  553. Tests 9 and 10 are run only in 8-bit mode, and tests 11 and 12 are run only in
  554. 16-bit and 32-bit modes. These are tests that generate different output in
  555. 8-bit mode. Each pair are for general cases and Unicode support, respectively.
  556. Test 13 checks the handling of non-UTF characters greater than 255 by
  557. pcre2_dfa_match() in 16-bit and 32-bit modes.
  558. Test 14 contains some special UTF and UCP tests that give different output for
  559. different code unit widths.
  560. Test 15 contains a number of tests that must not be run with JIT. They check,
  561. among other non-JIT things, the match-limiting features of the interpretive
  562. matcher.
  563. Test 16 is run only when JIT support is not available. It checks that an
  564. attempt to use JIT has the expected behaviour.
  565. Test 17 is run only when JIT support is available. It checks JIT complete and
  566. partial modes, match-limiting under JIT, and other JIT-specific features.
  567. Tests 18 and 19 are run only in 8-bit mode. They check the POSIX interface to
  568. the 8-bit library, without and with Unicode support, respectively.
  569. Test 20 checks the serialization functions by writing a set of compiled
  570. patterns to a file, and then reloading and checking them.
  571. Tests 21 and 22 test \C support when the use of \C is not locked out, without
  572. and with UTF support, respectively. Test 23 tests \C when it is locked out.
  573. Tests 24 and 25 test the experimental pattern conversion functions, without and
  574. with UTF support, respectively.
  575. Test 26 checks Unicode property support using tests that are generated
  576. automatically from the Unicode data tables.
  577. Character tables
  578. ----------------
  579. For speed, PCRE2 uses four tables for manipulating and identifying characters
  580. whose code point values are less than 256. By default, a set of tables that is
  581. built into the library is used. The pcre2_maketables() function can be called
  582. by an application to create a new set of tables in the current locale. This are
  583. passed to PCRE2 by calling pcre2_set_character_tables() to put a pointer into a
  584. compile context.
  585. The source file called pcre2_chartables.c contains the default set of tables.
  586. By default, this is created as a copy of pcre2_chartables.c.dist, which
  587. contains tables for ASCII coding. However, if --enable-rebuild-chartables is
  588. specified for ./configure, a new version of pcre2_chartables.c is built by the
  589. program pcre2_dftables (compiled from pcre2_dftables.c), which uses the ANSI C
  590. character handling functions such as isalnum(), isalpha(), isupper(),
  591. islower(), etc. to build the table sources. This means that the default C
  592. locale that is set for your system will control the contents of these default
  593. tables. You can change the default tables by editing pcre2_chartables.c and
  594. then re-building PCRE2. If you do this, you should take care to ensure that the
  595. file does not get automatically re-generated. The best way to do this is to
  596. move pcre2_chartables.c.dist out of the way and replace it with your customized
  597. tables.
  598. When the pcre2_dftables program is run as a result of specifying
  599. --enable-rebuild-chartables, it uses the default C locale that is set on your
  600. system. It does not pay attention to the LC_xxx environment variables. In other
  601. words, it uses the system's default locale rather than whatever the compiling
  602. user happens to have set. If you really do want to build a source set of
  603. character tables in a locale that is specified by the LC_xxx variables, you can
  604. run the pcre2_dftables program by hand with the -L option. For example:
  605. ./pcre2_dftables -L pcre2_chartables.c.special
  606. The second argument names the file where the source code for the tables is
  607. written. The first two 256-byte tables provide lower casing and case flipping
  608. functions, respectively. The next table consists of a number of 32-byte bit
  609. maps which identify certain character classes such as digits, "word"
  610. characters, white space, etc. These are used when building 32-byte bit maps
  611. that represent character classes for code points less than 256. The final
  612. 256-byte table has bits indicating various character types, as follows:
  613. 1 white space character
  614. 2 letter
  615. 4 lower case letter
  616. 8 decimal digit
  617. 16 alphanumeric or '_'
  618. You can also specify -b (with or without -L) when running pcre2_dftables. This
  619. causes the tables to be written in binary instead of as source code. A set of
  620. binary tables can be loaded into memory by an application and passed to
  621. pcre2_compile() in the same way as tables created dynamically by calling
  622. pcre2_maketables(). The tables are just a string of bytes, independent of
  623. hardware characteristics such as endianness. This means they can be bundled
  624. with an application that runs in different environments, to ensure consistent
  625. behaviour.
  626. See also the pcre2build section "Creating character tables at build time".
  627. File manifest
  628. -------------
  629. The distribution should contain the files listed below.
  630. (A) Source files for the PCRE2 library functions and their headers are found in
  631. the src directory:
  632. src/pcre2_dftables.c auxiliary program for building pcre2_chartables.c
  633. when --enable-rebuild-chartables is specified
  634. src/pcre2_chartables.c.dist a default set of character tables that assume
  635. ASCII coding; unless --enable-rebuild-chartables is
  636. specified, used by copying to pcre2_chartables.c
  637. src/pcre2posix.c )
  638. src/pcre2_auto_possess.c )
  639. src/pcre2_chkdint.c )
  640. src/pcre2_compile.c )
  641. src/pcre2_config.c )
  642. src/pcre2_context.c )
  643. src/pcre2_convert.c )
  644. src/pcre2_dfa_match.c )
  645. src/pcre2_error.c )
  646. src/pcre2_extuni.c )
  647. src/pcre2_find_bracket.c )
  648. src/pcre2_jit_compile.c )
  649. src/pcre2_jit_match.c ) sources for the functions in the library,
  650. src/pcre2_jit_misc.c ) and some internal functions that they use
  651. src/pcre2_maketables.c )
  652. src/pcre2_match.c )
  653. src/pcre2_match_data.c )
  654. src/pcre2_newline.c )
  655. src/pcre2_ord2utf.c )
  656. src/pcre2_pattern_info.c )
  657. src/pcre2_script_run.c )
  658. src/pcre2_serialize.c )
  659. src/pcre2_string_utils.c )
  660. src/pcre2_study.c )
  661. src/pcre2_substitute.c )
  662. src/pcre2_substring.c )
  663. src/pcre2_tables.c )
  664. src/pcre2_ucd.c )
  665. src/pcre2_ucptables.c )
  666. src/pcre2_valid_utf.c )
  667. src/pcre2_xclass.c )
  668. src/pcre2_printint.c debugging function that is used by pcre2test,
  669. src/pcre2_fuzzsupport.c function for (optional) fuzzing support
  670. src/config.h.in template for config.h, when built by "configure"
  671. src/pcre2.h.in template for pcre2.h when built by "configure"
  672. src/pcre2posix.h header for the external POSIX wrapper API
  673. src/pcre2_internal.h header for internal use
  674. src/pcre2_intmodedep.h a mode-specific internal header
  675. src/pcre2_jit_neon_inc.h header used by JIT
  676. src/pcre2_jit_simd_inc.h header used by JIT
  677. src/pcre2_ucp.h header for Unicode property handling
  678. sljit/* source files for the JIT compiler
  679. (B) Source files for programs that use PCRE2:
  680. src/pcre2demo.c simple demonstration of coding calls to PCRE2
  681. src/pcre2grep.c source of a grep utility that uses PCRE2
  682. src/pcre2test.c comprehensive test program
  683. src/pcre2_jit_test.c JIT test program
  684. src/pcre2posix_test.c POSIX wrapper API test program
  685. (C) Auxiliary files:
  686. 132html script to turn "man" pages into HTML
  687. AUTHORS information about the author of PCRE2
  688. ChangeLog log of changes to the code
  689. CleanTxt script to clean nroff output for txt man pages
  690. Detrail script to remove trailing spaces
  691. HACKING some notes about the internals of PCRE2
  692. INSTALL generic installation instructions
  693. LICENCE conditions for the use of PCRE2
  694. COPYING the same, using GNU's standard name
  695. Makefile.in ) template for Unix Makefile, which is built by
  696. ) "configure"
  697. Makefile.am ) the automake input that was used to create
  698. ) Makefile.in
  699. NEWS important changes in this release
  700. NON-AUTOTOOLS-BUILD notes on building PCRE2 without using autotools
  701. PrepareRelease script to make preparations for "make dist"
  702. README this file
  703. RunTest a Unix shell script for running tests
  704. RunGrepTest a Unix shell script for pcre2grep tests
  705. aclocal.m4 m4 macros (generated by "aclocal")
  706. config.guess ) files used by libtool,
  707. config.sub ) used only when building a shared library
  708. configure a configuring shell script (built by autoconf)
  709. configure.ac ) the autoconf input that was used to build
  710. ) "configure" and config.h
  711. depcomp ) script to find program dependencies, generated by
  712. ) automake
  713. doc/*.3 man page sources for PCRE2
  714. doc/*.1 man page sources for pcre2grep and pcre2test
  715. doc/index.html.src the base HTML page
  716. doc/html/* HTML documentation
  717. doc/pcre2.txt plain text version of the man pages
  718. doc/pcre2test.txt plain text documentation of test program
  719. install-sh a shell script for installing files
  720. libpcre2-8.pc.in template for libpcre2-8.pc for pkg-config
  721. libpcre2-16.pc.in template for libpcre2-16.pc for pkg-config
  722. libpcre2-32.pc.in template for libpcre2-32.pc for pkg-config
  723. libpcre2-posix.pc.in template for libpcre2-posix.pc for pkg-config
  724. ltmain.sh file used to build a libtool script
  725. missing ) common stub for a few missing GNU programs while
  726. ) installing, generated by automake
  727. mkinstalldirs script for making install directories
  728. perltest.sh Script for running a Perl test program
  729. pcre2-config.in source of script which retains PCRE2 information
  730. testdata/testinput* test data for main library tests
  731. testdata/testoutput* expected test results
  732. testdata/grep* input and output for pcre2grep tests
  733. testdata/* other supporting test files
  734. (D) Auxiliary files for cmake support
  735. cmake/COPYING-CMAKE-SCRIPTS
  736. cmake/FindPackageHandleStandardArgs.cmake
  737. cmake/FindEditline.cmake
  738. cmake/FindReadline.cmake
  739. CMakeLists.txt
  740. config-cmake.h.in
  741. (E) Auxiliary files for building PCRE2 "by hand"
  742. src/pcre2.h.generic ) a version of the public PCRE2 header file
  743. ) for use in non-"configure" environments
  744. src/config.h.generic ) a version of config.h for use in non-"configure"
  745. ) environments
  746. (F) Auxiliary files for building PCRE2 under OpenVMS
  747. vms/configure.com )
  748. vms/openvms_readme.txt ) These files were contributed by a PCRE2 user.
  749. vms/pcre2.h_patch )
  750. vms/stdint.h )
  751. Philip Hazel
  752. Email local part: Philip.Hazel
  753. Email domain: gmail.com
  754. Last updated: 15 April 2024