PageRenderTime 63ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/harbour-2.0.0/external/pcre/pcreinal.h

#
C Header | 1581 lines | 1090 code | 205 blank | 286 comment | 46 complexity | 65565e64b338325f63e7f72ff6484e7d MD5 | raw file
Possible License(s): AGPL-1.0, BSD-3-Clause, CC-BY-SA-3.0, LGPL-3.0, GPL-2.0, LGPL-2.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. /*************************************************
  2. * Perl-Compatible Regular Expressions *
  3. *************************************************/
  4. /* PCRE is a library of functions to support regular expressions whose syntax
  5. and semantics are as close as possible to those of the Perl 5 language.
  6. Written by Philip Hazel
  7. Copyright (c) 1997-2009 University of Cambridge
  8. -----------------------------------------------------------------------------
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. * Redistributions of source code must retain the above copyright notice,
  12. this list of conditions and the following disclaimer.
  13. * Redistributions in binary form must reproduce the above copyright
  14. notice, this list of conditions and the following disclaimer in the
  15. documentation and/or other materials provided with the distribution.
  16. * Neither the name of the University of Cambridge nor the names of its
  17. contributors may be used to endorse or promote products derived from
  18. this software without specific prior written permission.
  19. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  23. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  24. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  25. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  28. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29. POSSIBILITY OF SUCH DAMAGE.
  30. -----------------------------------------------------------------------------
  31. */
  32. /* This header contains definitions that are shared between the different
  33. modules, but which are not relevant to the exported API. This includes some
  34. functions whose names all begin with "_pcre_". */
  35. #ifndef PCRE_INTERNAL_H
  36. #define PCRE_INTERNAL_H
  37. /* Define DEBUG to get debugging output on stdout. */
  38. #if 0
  39. #define DEBUG
  40. #endif
  41. /* We do not support both EBCDIC and UTF-8 at the same time. The "configure"
  42. script prevents both being selected, but not everybody uses "configure". */
  43. #if defined EBCDIC && defined SUPPORT_UTF8
  44. #error The use of both EBCDIC and SUPPORT_UTF8 is not supported.
  45. #endif
  46. /* If SUPPORT_UCP is defined, SUPPORT_UTF8 must also be defined. The
  47. "configure" script ensures this, but not everybody uses "configure". */
  48. #if defined SUPPORT_UCP && !defined SUPPORT_UTF8
  49. #define SUPPORT_UTF8 1
  50. #endif
  51. /* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
  52. inline, and there are *still* stupid compilers about that don't like indented
  53. pre-processor statements, or at least there were when I first wrote this. After
  54. all, it had only been about 10 years then...
  55. It turns out that the Mac Debugging.h header also defines the macro DPRINTF, so
  56. be absolutely sure we get our version. */
  57. #undef DPRINTF
  58. #ifdef DEBUG
  59. #define DPRINTF(p) printf p
  60. #else
  61. #define DPRINTF(p) /* Nothing */
  62. #endif
  63. /* Standard C headers plus the external interface definition. The only time
  64. setjmp and stdarg are used is when NO_RECURSE is set. */
  65. #include <ctype.h>
  66. #include <limits.h>
  67. #include <setjmp.h>
  68. #include <stdarg.h>
  69. #include <stddef.h>
  70. #include <stdio.h>
  71. #include <stdlib.h>
  72. #include <string.h>
  73. /* When compiling a DLL for Windows, the exported symbols have to be declared
  74. using some MS magic. I found some useful information on this web page:
  75. http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the
  76. information there, using __declspec(dllexport) without "extern" we have a
  77. definition; with "extern" we have a declaration. The settings here override the
  78. setting in pcre.h (which is included below); it defines only PCRE_EXP_DECL,
  79. which is all that is needed for applications (they just import the symbols). We
  80. use:
  81. PCRE_EXP_DECL for declarations
  82. PCRE_EXP_DEFN for definitions of exported functions
  83. PCRE_EXP_DATA_DEFN for definitions of exported variables
  84. The reason for the two DEFN macros is that in non-Windows environments, one
  85. does not want to have "extern" before variable definitions because it leads to
  86. compiler warnings. So we distinguish between functions and variables. In
  87. Windows, the two should always be the same.
  88. The reason for wrapping this in #ifndef PCRE_EXP_DECL is so that pcretest,
  89. which is an application, but needs to import this file in order to "peek" at
  90. internals, can #include pcre.h first to get an application's-eye view.
  91. In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon,
  92. special-purpose environments) might want to stick other stuff in front of
  93. exported symbols. That's why, in the non-Windows case, we set PCRE_EXP_DEFN and
  94. PCRE_EXP_DATA_DEFN only if they are not already set. */
  95. #ifndef PCRE_EXP_DECL
  96. # ifdef _WIN32
  97. # ifndef PCRE_STATIC
  98. # define PCRE_EXP_DECL extern __declspec(dllexport)
  99. # define PCRE_EXP_DEFN __declspec(dllexport)
  100. # define PCRE_EXP_DATA_DEFN __declspec(dllexport)
  101. # else
  102. # define PCRE_EXP_DECL extern
  103. # define PCRE_EXP_DEFN
  104. # define PCRE_EXP_DATA_DEFN
  105. # endif
  106. # else
  107. # ifdef __cplusplus
  108. # define PCRE_EXP_DECL extern "C"
  109. # else
  110. # define PCRE_EXP_DECL extern
  111. # endif
  112. # ifndef PCRE_EXP_DEFN
  113. # define PCRE_EXP_DEFN PCRE_EXP_DECL
  114. # endif
  115. # ifndef PCRE_EXP_DATA_DEFN
  116. # define PCRE_EXP_DATA_DEFN
  117. # endif
  118. # endif
  119. #endif
  120. /* When compiling with the MSVC compiler, it is sometimes necessary to include
  121. a "calling convention" before exported function names. (This is secondhand
  122. information; I know nothing about MSVC myself). For example, something like
  123. void __cdecl function(....)
  124. might be needed. In order so make this easy, all the exported functions have
  125. PCRE_CALL_CONVENTION just before their names. It is rarely needed; if not
  126. set, we ensure here that it has no effect. */
  127. #ifndef PCRE_CALL_CONVENTION
  128. #define PCRE_CALL_CONVENTION
  129. #endif
  130. /* We need to have types that specify unsigned 16-bit and 32-bit integers. We
  131. cannot determine these outside the compilation (e.g. by running a program as
  132. part of "configure") because PCRE is often cross-compiled for use on other
  133. systems. Instead we make use of the maximum sizes that are available at
  134. preprocessor time in standard C environments. */
  135. #if USHRT_MAX == 65535
  136. typedef unsigned short pcre_uint16;
  137. typedef short pcre_int16;
  138. #elif UINT_MAX == 65535
  139. typedef unsigned int pcre_uint16;
  140. typedef int pcre_int16;
  141. #else
  142. #error Cannot determine a type for 16-bit unsigned integers
  143. #endif
  144. #if UINT_MAX == 4294967295
  145. typedef unsigned int pcre_uint32;
  146. typedef int pcre_int32;
  147. #elif ULONG_MAX == 4294967295
  148. typedef unsigned long int pcre_uint32;
  149. typedef long int pcre_int32;
  150. #else
  151. #error Cannot determine a type for 32-bit unsigned integers
  152. #endif
  153. /* All character handling must be done as unsigned characters. Otherwise there
  154. are problems with top-bit-set characters and functions such as isspace().
  155. However, we leave the interface to the outside world as char *, because that
  156. should make things easier for callers. We define a short type for unsigned char
  157. to save lots of typing. I tried "uchar", but it causes problems on Digital
  158. Unix, where it is defined in sys/types, so use "uschar" instead. */
  159. typedef unsigned char uschar;
  160. /* This is an unsigned int value that no character can ever have. UTF-8
  161. characters only go up to 0x7fffffff (though Unicode doesn't go beyond
  162. 0x0010ffff). */
  163. #define NOTACHAR 0xffffffff
  164. /* PCRE is able to support several different kinds of newline (CR, LF, CRLF,
  165. "any" and "anycrlf" at present). The following macros are used to package up
  166. testing for newlines. NLBLOCK, PSSTART, and PSEND are defined in the various
  167. modules to indicate in which datablock the parameters exist, and what the
  168. start/end of string field names are. */
  169. #define NLTYPE_FIXED 0 /* Newline is a fixed length string */
  170. #define NLTYPE_ANY 1 /* Newline is any Unicode line ending */
  171. #define NLTYPE_ANYCRLF 2 /* Newline is CR, LF, or CRLF */
  172. /* This macro checks for a newline at the given position */
  173. #define IS_NEWLINE(p) \
  174. ((NLBLOCK->nltype != NLTYPE_FIXED)? \
  175. ((p) < NLBLOCK->PSEND && \
  176. _pcre_is_newline((p), NLBLOCK->nltype, NLBLOCK->PSEND, &(NLBLOCK->nllen),\
  177. utf8)) \
  178. : \
  179. ((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \
  180. (p)[0] == NLBLOCK->nl[0] && \
  181. (NLBLOCK->nllen == 1 || (p)[1] == NLBLOCK->nl[1]) \
  182. ) \
  183. )
  184. /* This macro checks for a newline immediately preceding the given position */
  185. #define WAS_NEWLINE(p) \
  186. ((NLBLOCK->nltype != NLTYPE_FIXED)? \
  187. ((p) > NLBLOCK->PSSTART && \
  188. _pcre_was_newline((p), NLBLOCK->nltype, NLBLOCK->PSSTART, \
  189. &(NLBLOCK->nllen), utf8)) \
  190. : \
  191. ((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \
  192. (p)[-NLBLOCK->nllen] == NLBLOCK->nl[0] && \
  193. (NLBLOCK->nllen == 1 || (p)[-NLBLOCK->nllen+1] == NLBLOCK->nl[1]) \
  194. ) \
  195. )
  196. /* When PCRE is compiled as a C++ library, the subject pointer can be replaced
  197. with a custom type. This makes it possible, for example, to allow pcre_exec()
  198. to process subject strings that are discontinuous by using a smart pointer
  199. class. It must always be possible to inspect all of the subject string in
  200. pcre_exec() because of the way it backtracks. Two macros are required in the
  201. normal case, for sign-unspecified and unsigned char pointers. The former is
  202. used for the external interface and appears in pcre.h, which is why its name
  203. must begin with PCRE_. */
  204. #ifdef CUSTOM_SUBJECT_PTR
  205. #define PCRE_SPTR CUSTOM_SUBJECT_PTR
  206. #define USPTR CUSTOM_SUBJECT_PTR
  207. #else
  208. #define PCRE_SPTR const char *
  209. #define USPTR const unsigned char *
  210. #endif
  211. /* Include the public PCRE header and the definitions of UCP character property
  212. values. */
  213. #include "pcre.h"
  214. #include "ucp.h"
  215. /* When compiling for use with the Virtual Pascal compiler, these functions
  216. need to have their names changed. PCRE must be compiled with the -DVPCOMPAT
  217. option on the command line. */
  218. #ifdef VPCOMPAT
  219. #define strlen(s) _strlen(s)
  220. #define strncmp(s1,s2,m) _strncmp(s1,s2,m)
  221. #define memcmp(s,c,n) _memcmp(s,c,n)
  222. #define memcpy(d,s,n) _memcpy(d,s,n)
  223. #define memmove(d,s,n) _memmove(d,s,n)
  224. #define memset(s,c,n) _memset(s,c,n)
  225. #else /* VPCOMPAT */
  226. /* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),
  227. define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY
  228. is set. Otherwise, include an emulating function for those systems that have
  229. neither (there some non-Unix environments where this is the case). */
  230. #ifndef HAVE_MEMMOVE
  231. #undef memmove /* some systems may have a macro */
  232. #ifdef HAVE_BCOPY
  233. #define memmove(a, b, c) bcopy(b, a, c)
  234. #else /* HAVE_BCOPY */
  235. static void *
  236. pcre_memmove(void *d, const void *s, size_t n)
  237. {
  238. size_t i;
  239. unsigned char *dest = (unsigned char *)d;
  240. const unsigned char *src = (const unsigned char *)s;
  241. if (dest > src)
  242. {
  243. dest += n;
  244. src += n;
  245. for (i = 0; i < n; ++i) *(--dest) = *(--src);
  246. return (void *)dest;
  247. }
  248. else
  249. {
  250. for (i = 0; i < n; ++i) *dest++ = *src++;
  251. return (void *)(dest - n);
  252. }
  253. }
  254. #define memmove(a, b, c) pcre_memmove(a, b, c)
  255. #endif /* not HAVE_BCOPY */
  256. #endif /* not HAVE_MEMMOVE */
  257. #endif /* not VPCOMPAT */
  258. /* PCRE keeps offsets in its compiled code as 2-byte quantities (always stored
  259. in big-endian order) by default. These are used, for example, to link from the
  260. start of a subpattern to its alternatives and its end. The use of 2 bytes per
  261. offset limits the size of the compiled regex to around 64K, which is big enough
  262. for almost everybody. However, I received a request for an even bigger limit.
  263. For this reason, and also to make the code easier to maintain, the storing and
  264. loading of offsets from the byte string is now handled by the macros that are
  265. defined here.
  266. The macros are controlled by the value of LINK_SIZE. This defaults to 2 in
  267. the config.h file, but can be overridden by using -D on the command line. This
  268. is automated on Unix systems via the "configure" command. */
  269. #if LINK_SIZE == 2
  270. #define PUT(a,n,d) \
  271. (a[n] = (d) >> 8), \
  272. (a[(n)+1] = (d) & 255)
  273. #define GET(a,n) \
  274. (((a)[n] << 8) | (a)[(n)+1])
  275. #define MAX_PATTERN_SIZE (1 << 16)
  276. #elif LINK_SIZE == 3
  277. #define PUT(a,n,d) \
  278. (a[n] = (d) >> 16), \
  279. (a[(n)+1] = (d) >> 8), \
  280. (a[(n)+2] = (d) & 255)
  281. #define GET(a,n) \
  282. (((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])
  283. #define MAX_PATTERN_SIZE (1 << 24)
  284. #elif LINK_SIZE == 4
  285. #define PUT(a,n,d) \
  286. (a[n] = (d) >> 24), \
  287. (a[(n)+1] = (d) >> 16), \
  288. (a[(n)+2] = (d) >> 8), \
  289. (a[(n)+3] = (d) & 255)
  290. #define GET(a,n) \
  291. (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
  292. #define MAX_PATTERN_SIZE (1 << 30) /* Keep it positive */
  293. #else
  294. #error LINK_SIZE must be either 2, 3, or 4
  295. #endif
  296. /* Convenience macro defined in terms of the others */
  297. #define PUTINC(a,n,d) PUT(a,n,d), a += LINK_SIZE
  298. /* PCRE uses some other 2-byte quantities that do not change when the size of
  299. offsets changes. There are used for repeat counts and for other things such as
  300. capturing parenthesis numbers in back references. */
  301. #define PUT2(a,n,d) \
  302. a[n] = (d) >> 8; \
  303. a[(n)+1] = (d) & 255
  304. #define GET2(a,n) \
  305. (((a)[n] << 8) | (a)[(n)+1])
  306. #define PUT2INC(a,n,d) PUT2(a,n,d), a += 2
  307. /* When UTF-8 encoding is being used, a character is no longer just a single
  308. byte. The macros for character handling generate simple sequences when used in
  309. byte-mode, and more complicated ones for UTF-8 characters. BACKCHAR should
  310. never be called in byte mode. To make sure it can never even appear when UTF-8
  311. support is omitted, we don't even define it. */
  312. #ifndef SUPPORT_UTF8
  313. #define GETCHAR(c, eptr) c = *eptr;
  314. #define GETCHARTEST(c, eptr) c = *eptr;
  315. #define GETCHARINC(c, eptr) c = *eptr++;
  316. #define GETCHARINCTEST(c, eptr) c = *eptr++;
  317. #define GETCHARLEN(c, eptr, len) c = *eptr;
  318. /* #define BACKCHAR(eptr) */
  319. #else /* SUPPORT_UTF8 */
  320. /* Get the next UTF-8 character, not advancing the pointer. This is called when
  321. we know we are in UTF-8 mode. */
  322. #define GETCHAR(c, eptr) \
  323. c = *eptr; \
  324. if (c >= 0xc0) \
  325. { \
  326. int gcii; \
  327. int gcaa = _pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */ \
  328. int gcss = 6*gcaa; \
  329. c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
  330. for (gcii = 1; gcii <= gcaa; gcii++) \
  331. { \
  332. gcss -= 6; \
  333. c |= (eptr[gcii] & 0x3f) << gcss; \
  334. } \
  335. }
  336. /* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing the
  337. pointer. */
  338. #define GETCHARTEST(c, eptr) \
  339. c = *eptr; \
  340. if (utf8 && c >= 0xc0) \
  341. { \
  342. int gcii; \
  343. int gcaa = _pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */ \
  344. int gcss = 6*gcaa; \
  345. c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
  346. for (gcii = 1; gcii <= gcaa; gcii++) \
  347. { \
  348. gcss -= 6; \
  349. c |= (eptr[gcii] & 0x3f) << gcss; \
  350. } \
  351. }
  352. /* Get the next UTF-8 character, advancing the pointer. This is called when we
  353. know we are in UTF-8 mode. */
  354. #define GETCHARINC(c, eptr) \
  355. c = *eptr++; \
  356. if (c >= 0xc0) \
  357. { \
  358. int gcaa = _pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */ \
  359. int gcss = 6*gcaa; \
  360. c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
  361. while (gcaa-- > 0) \
  362. { \
  363. gcss -= 6; \
  364. c |= (*eptr++ & 0x3f) << gcss; \
  365. } \
  366. }
  367. /* Get the next character, testing for UTF-8 mode, and advancing the pointer */
  368. #define GETCHARINCTEST(c, eptr) \
  369. c = *eptr++; \
  370. if (utf8 && c >= 0xc0) \
  371. { \
  372. int gcaa = _pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */ \
  373. int gcss = 6*gcaa; \
  374. c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
  375. while (gcaa-- > 0) \
  376. { \
  377. gcss -= 6; \
  378. c |= (*eptr++ & 0x3f) << gcss; \
  379. } \
  380. }
  381. /* Get the next UTF-8 character, not advancing the pointer, incrementing length
  382. if there are extra bytes. This is called when we know we are in UTF-8 mode. */
  383. #define GETCHARLEN(c, eptr, len) \
  384. c = *eptr; \
  385. if (c >= 0xc0) \
  386. { \
  387. int gcii; \
  388. int gcaa = _pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */ \
  389. int gcss = 6*gcaa; \
  390. c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
  391. for (gcii = 1; gcii <= gcaa; gcii++) \
  392. { \
  393. gcss -= 6; \
  394. c |= (eptr[gcii] & 0x3f) << gcss; \
  395. } \
  396. len += gcaa; \
  397. }
  398. /* Get the next UTF-8 character, testing for UTF-8 mode, not advancing the
  399. pointer, incrementing length if there are extra bytes. This is called when we
  400. know we are in UTF-8 mode. */
  401. #define GETCHARLENTEST(c, eptr, len) \
  402. c = *eptr; \
  403. if (utf8 && c >= 0xc0) \
  404. { \
  405. int gcii; \
  406. int gcaa = _pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */ \
  407. int gcss = 6*gcaa; \
  408. c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
  409. for (gcii = 1; gcii <= gcaa; gcii++) \
  410. { \
  411. gcss -= 6; \
  412. c |= (eptr[gcii] & 0x3f) << gcss; \
  413. } \
  414. len += gcaa; \
  415. }
  416. /* If the pointer is not at the start of a character, move it back until
  417. it is. This is called only in UTF-8 mode - we don't put a test within the macro
  418. because almost all calls are already within a block of UTF-8 only code. */
  419. #define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--
  420. #endif
  421. /* In case there is no definition of offsetof() provided - though any proper
  422. Standard C system should have one. */
  423. #ifndef offsetof
  424. #define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
  425. #endif
  426. /* These are the public options that can change during matching. */
  427. #define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
  428. /* Private flags containing information about the compiled regex. They used to
  429. live at the top end of the options word, but that got almost full, so now they
  430. are in a 16-bit flags word. From release 8.00, PCRE_NOPARTIAL is unused, as
  431. the restrictions on partial matching have been lifted. It remains for backwards
  432. compatibility. */
  433. #define PCRE_NOPARTIAL 0x0001 /* can't use partial with this regex */
  434. #define PCRE_FIRSTSET 0x0002 /* first_byte is set */
  435. #define PCRE_REQCHSET 0x0004 /* req_byte is set */
  436. #define PCRE_STARTLINE 0x0008 /* start after \n for multiline */
  437. #define PCRE_JCHANGED 0x0010 /* j option used in regex */
  438. #define PCRE_HASCRORLF 0x0020 /* explicit \r or \n in pattern */
  439. /* Options for the "extra" block produced by pcre_study(). */
  440. #define PCRE_STUDY_MAPPED 0x01 /* a map of starting chars exists */
  441. #define PCRE_STUDY_MINLEN 0x02 /* a minimum length field exists */
  442. /* Masks for identifying the public options that are permitted at compile
  443. time, run time, or study time, respectively. */
  444. #define PCRE_NEWLINE_BITS (PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|PCRE_NEWLINE_ANY| \
  445. PCRE_NEWLINE_ANYCRLF)
  446. #define PUBLIC_COMPILE_OPTIONS \
  447. (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
  448. PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
  449. PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT|PCRE_FIRSTLINE| \
  450. PCRE_DUPNAMES|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
  451. PCRE_JAVASCRIPT_COMPAT)
  452. #define PUBLIC_EXEC_OPTIONS \
  453. (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NOTEMPTY_ATSTART| \
  454. PCRE_NO_UTF8_CHECK|PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT|PCRE_NEWLINE_BITS| \
  455. PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE|PCRE_NO_START_OPTIMIZE)
  456. #define PUBLIC_DFA_EXEC_OPTIONS \
  457. (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NOTEMPTY_ATSTART| \
  458. PCRE_NO_UTF8_CHECK|PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT|PCRE_DFA_SHORTEST| \
  459. PCRE_DFA_RESTART|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
  460. PCRE_NO_START_OPTIMIZE)
  461. #define PUBLIC_STUDY_OPTIONS 0 /* None defined */
  462. /* Magic number to provide a small check against being handed junk. Also used
  463. to detect whether a pattern was compiled on a host of different endianness. */
  464. #define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */
  465. /* Negative values for the firstchar and reqchar variables */
  466. #define REQ_UNSET (-2)
  467. #define REQ_NONE (-1)
  468. /* The maximum remaining length of subject we are prepared to search for a
  469. req_byte match. */
  470. #define REQ_BYTE_MAX 1000
  471. /* Flags added to firstbyte or reqbyte; a "non-literal" item is either a
  472. variable-length repeat, or a anything other than literal characters. */
  473. #define REQ_CASELESS 0x0100 /* indicates caselessness */
  474. #define REQ_VARY 0x0200 /* reqbyte followed non-literal item */
  475. /* Miscellaneous definitions. The #ifndef is to pacify compiler warnings in
  476. environments where these macros are defined elsewhere. Unfortunately, there
  477. is no way to do the same for the typedef. */
  478. #ifndef FALSE
  479. typedef int BOOL;
  480. #define FALSE 0
  481. #define TRUE 1
  482. #endif
  483. /* If PCRE is to support UTF-8 on EBCDIC platforms, we cannot use normal
  484. character constants like '*' because the compiler would emit their EBCDIC code,
  485. which is different from their ASCII/UTF-8 code. Instead we define macros for
  486. the characters so that they always use the ASCII/UTF-8 code when UTF-8 support
  487. is enabled. When UTF-8 support is not enabled, the definitions use character
  488. literals. Both character and string versions of each character are needed, and
  489. there are some longer strings as well.
  490. This means that, on EBCDIC platforms, the PCRE library can handle either
  491. EBCDIC, or UTF-8, but not both. To support both in the same compiled library
  492. would need different lookups depending on whether PCRE_UTF8 was set or not.
  493. This would make it impossible to use characters in switch/case statements,
  494. which would reduce performance. For a theoretical use (which nobody has asked
  495. for) in a minority area (EBCDIC platforms), this is not sensible. Any
  496. application that did need both could compile two versions of the library, using
  497. macros to give the functions distinct names. */
  498. #ifndef SUPPORT_UTF8
  499. /* UTF-8 support is not enabled; use the platform-dependent character literals
  500. so that PCRE works on both ASCII and EBCDIC platforms, in non-UTF-mode only. */
  501. #define CHAR_HT '\t'
  502. #define CHAR_VT '\v'
  503. #define CHAR_FF '\f'
  504. #define CHAR_CR '\r'
  505. #define CHAR_NL '\n'
  506. #define CHAR_BS '\b'
  507. #define CHAR_BEL '\a'
  508. #ifdef EBCDIC
  509. #define CHAR_ESC '\047'
  510. #define CHAR_DEL '\007'
  511. #else
  512. #define CHAR_ESC '\033'
  513. #define CHAR_DEL '\177'
  514. #endif
  515. #define CHAR_SPACE ' '
  516. #define CHAR_EXCLAMATION_MARK '!'
  517. #define CHAR_QUOTATION_MARK '"'
  518. #define CHAR_NUMBER_SIGN '#'
  519. #define CHAR_DOLLAR_SIGN '$'
  520. #define CHAR_PERCENT_SIGN '%'
  521. #define CHAR_AMPERSAND '&'
  522. #define CHAR_APOSTROPHE '\''
  523. #define CHAR_LEFT_PARENTHESIS '('
  524. #define CHAR_RIGHT_PARENTHESIS ')'
  525. #define CHAR_ASTERISK '*'
  526. #define CHAR_PLUS '+'
  527. #define CHAR_COMMA ','
  528. #define CHAR_MINUS '-'
  529. #define CHAR_DOT '.'
  530. #define CHAR_SLASH '/'
  531. #define CHAR_0 '0'
  532. #define CHAR_1 '1'
  533. #define CHAR_2 '2'
  534. #define CHAR_3 '3'
  535. #define CHAR_4 '4'
  536. #define CHAR_5 '5'
  537. #define CHAR_6 '6'
  538. #define CHAR_7 '7'
  539. #define CHAR_8 '8'
  540. #define CHAR_9 '9'
  541. #define CHAR_COLON ':'
  542. #define CHAR_SEMICOLON ';'
  543. #define CHAR_LESS_THAN_SIGN '<'
  544. #define CHAR_EQUALS_SIGN '='
  545. #define CHAR_GREATER_THAN_SIGN '>'
  546. #define CHAR_QUESTION_MARK '?'
  547. #define CHAR_COMMERCIAL_AT '@'
  548. #define CHAR_A 'A'
  549. #define CHAR_B 'B'
  550. #define CHAR_C 'C'
  551. #define CHAR_D 'D'
  552. #define CHAR_E 'E'
  553. #define CHAR_F 'F'
  554. #define CHAR_G 'G'
  555. #define CHAR_H 'H'
  556. #define CHAR_I 'I'
  557. #define CHAR_J 'J'
  558. #define CHAR_K 'K'
  559. #define CHAR_L 'L'
  560. #define CHAR_M 'M'
  561. #define CHAR_N 'N'
  562. #define CHAR_O 'O'
  563. #define CHAR_P 'P'
  564. #define CHAR_Q 'Q'
  565. #define CHAR_R 'R'
  566. #define CHAR_S 'S'
  567. #define CHAR_T 'T'
  568. #define CHAR_U 'U'
  569. #define CHAR_V 'V'
  570. #define CHAR_W 'W'
  571. #define CHAR_X 'X'
  572. #define CHAR_Y 'Y'
  573. #define CHAR_Z 'Z'
  574. #define CHAR_LEFT_SQUARE_BRACKET '['
  575. #define CHAR_BACKSLASH '\\'
  576. #define CHAR_RIGHT_SQUARE_BRACKET ']'
  577. #define CHAR_CIRCUMFLEX_ACCENT '^'
  578. #define CHAR_UNDERSCORE '_'
  579. #define CHAR_GRAVE_ACCENT '`'
  580. #define CHAR_a 'a'
  581. #define CHAR_b 'b'
  582. #define CHAR_c 'c'
  583. #define CHAR_d 'd'
  584. #define CHAR_e 'e'
  585. #define CHAR_f 'f'
  586. #define CHAR_g 'g'
  587. #define CHAR_h 'h'
  588. #define CHAR_i 'i'
  589. #define CHAR_j 'j'
  590. #define CHAR_k 'k'
  591. #define CHAR_l 'l'
  592. #define CHAR_m 'm'
  593. #define CHAR_n 'n'
  594. #define CHAR_o 'o'
  595. #define CHAR_p 'p'
  596. #define CHAR_q 'q'
  597. #define CHAR_r 'r'
  598. #define CHAR_s 's'
  599. #define CHAR_t 't'
  600. #define CHAR_u 'u'
  601. #define CHAR_v 'v'
  602. #define CHAR_w 'w'
  603. #define CHAR_x 'x'
  604. #define CHAR_y 'y'
  605. #define CHAR_z 'z'
  606. #define CHAR_LEFT_CURLY_BRACKET '{'
  607. #define CHAR_VERTICAL_LINE '|'
  608. #define CHAR_RIGHT_CURLY_BRACKET '}'
  609. #define CHAR_TILDE '~'
  610. #define STR_HT "\t"
  611. #define STR_VT "\v"
  612. #define STR_FF "\f"
  613. #define STR_CR "\r"
  614. #define STR_NL "\n"
  615. #define STR_BS "\b"
  616. #define STR_BEL "\a"
  617. #ifdef EBCDIC
  618. #define STR_ESC "\047"
  619. #define STR_DEL "\007"
  620. #else
  621. #define STR_ESC "\033"
  622. #define STR_DEL "\177"
  623. #endif
  624. #define STR_SPACE " "
  625. #define STR_EXCLAMATION_MARK "!"
  626. #define STR_QUOTATION_MARK "\""
  627. #define STR_NUMBER_SIGN "#"
  628. #define STR_DOLLAR_SIGN "$"
  629. #define STR_PERCENT_SIGN "%"
  630. #define STR_AMPERSAND "&"
  631. #define STR_APOSTROPHE "'"
  632. #define STR_LEFT_PARENTHESIS "("
  633. #define STR_RIGHT_PARENTHESIS ")"
  634. #define STR_ASTERISK "*"
  635. #define STR_PLUS "+"
  636. #define STR_COMMA ","
  637. #define STR_MINUS "-"
  638. #define STR_DOT "."
  639. #define STR_SLASH "/"
  640. #define STR_0 "0"
  641. #define STR_1 "1"
  642. #define STR_2 "2"
  643. #define STR_3 "3"
  644. #define STR_4 "4"
  645. #define STR_5 "5"
  646. #define STR_6 "6"
  647. #define STR_7 "7"
  648. #define STR_8 "8"
  649. #define STR_9 "9"
  650. #define STR_COLON ":"
  651. #define STR_SEMICOLON ";"
  652. #define STR_LESS_THAN_SIGN "<"
  653. #define STR_EQUALS_SIGN "="
  654. #define STR_GREATER_THAN_SIGN ">"
  655. #define STR_QUESTION_MARK "?"
  656. #define STR_COMMERCIAL_AT "@"
  657. #define STR_A "A"
  658. #define STR_B "B"
  659. #define STR_C "C"
  660. #define STR_D "D"
  661. #define STR_E "E"
  662. #define STR_F "F"
  663. #define STR_G "G"
  664. #define STR_H "H"
  665. #define STR_I "I"
  666. #define STR_J "J"
  667. #define STR_K "K"
  668. #define STR_L "L"
  669. #define STR_M "M"
  670. #define STR_N "N"
  671. #define STR_O "O"
  672. #define STR_P "P"
  673. #define STR_Q "Q"
  674. #define STR_R "R"
  675. #define STR_S "S"
  676. #define STR_T "T"
  677. #define STR_U "U"
  678. #define STR_V "V"
  679. #define STR_W "W"
  680. #define STR_X "X"
  681. #define STR_Y "Y"
  682. #define STR_Z "Z"
  683. #define STR_LEFT_SQUARE_BRACKET "["
  684. #define STR_BACKSLASH "\\"
  685. #define STR_RIGHT_SQUARE_BRACKET "]"
  686. #define STR_CIRCUMFLEX_ACCENT "^"
  687. #define STR_UNDERSCORE "_"
  688. #define STR_GRAVE_ACCENT "`"
  689. #define STR_a "a"
  690. #define STR_b "b"
  691. #define STR_c "c"
  692. #define STR_d "d"
  693. #define STR_e "e"
  694. #define STR_f "f"
  695. #define STR_g "g"
  696. #define STR_h "h"
  697. #define STR_i "i"
  698. #define STR_j "j"
  699. #define STR_k "k"
  700. #define STR_l "l"
  701. #define STR_m "m"
  702. #define STR_n "n"
  703. #define STR_o "o"
  704. #define STR_p "p"
  705. #define STR_q "q"
  706. #define STR_r "r"
  707. #define STR_s "s"
  708. #define STR_t "t"
  709. #define STR_u "u"
  710. #define STR_v "v"
  711. #define STR_w "w"
  712. #define STR_x "x"
  713. #define STR_y "y"
  714. #define STR_z "z"
  715. #define STR_LEFT_CURLY_BRACKET "{"
  716. #define STR_VERTICAL_LINE "|"
  717. #define STR_RIGHT_CURLY_BRACKET "}"
  718. #define STR_TILDE "~"
  719. #define STRING_ACCEPT0 "ACCEPT\0"
  720. #define STRING_COMMIT0 "COMMIT\0"
  721. #define STRING_F0 "F\0"
  722. #define STRING_FAIL0 "FAIL\0"
  723. #define STRING_PRUNE0 "PRUNE\0"
  724. #define STRING_SKIP0 "SKIP\0"
  725. #define STRING_THEN "THEN"
  726. #define STRING_alpha0 "alpha\0"
  727. #define STRING_lower0 "lower\0"
  728. #define STRING_upper0 "upper\0"
  729. #define STRING_alnum0 "alnum\0"
  730. #define STRING_ascii0 "ascii\0"
  731. #define STRING_blank0 "blank\0"
  732. #define STRING_cntrl0 "cntrl\0"
  733. #define STRING_digit0 "digit\0"
  734. #define STRING_graph0 "graph\0"
  735. #define STRING_print0 "print\0"
  736. #define STRING_punct0 "punct\0"
  737. #define STRING_space0 "space\0"
  738. #define STRING_word0 "word\0"
  739. #define STRING_xdigit "xdigit"
  740. #define STRING_DEFINE "DEFINE"
  741. #define STRING_CR_RIGHTPAR "CR)"
  742. #define STRING_LF_RIGHTPAR "LF)"
  743. #define STRING_CRLF_RIGHTPAR "CRLF)"
  744. #define STRING_ANY_RIGHTPAR "ANY)"
  745. #define STRING_ANYCRLF_RIGHTPAR "ANYCRLF)"
  746. #define STRING_BSR_ANYCRLF_RIGHTPAR "BSR_ANYCRLF)"
  747. #define STRING_BSR_UNICODE_RIGHTPAR "BSR_UNICODE)"
  748. #define STRING_UTF8_RIGHTPAR "UTF8)"
  749. #else /* SUPPORT_UTF8 */
  750. /* UTF-8 support is enabled; always use UTF-8 (=ASCII) character codes. This
  751. works in both modes non-EBCDIC platforms, and on EBCDIC platforms in UTF-8 mode
  752. only. */
  753. #define CHAR_HT '\011'
  754. #define CHAR_VT '\013'
  755. #define CHAR_FF '\014'
  756. #define CHAR_CR '\015'
  757. #define CHAR_NL '\012'
  758. #define CHAR_BS '\010'
  759. #define CHAR_BEL '\007'
  760. #define CHAR_ESC '\033'
  761. #define CHAR_DEL '\177'
  762. #define CHAR_SPACE '\040'
  763. #define CHAR_EXCLAMATION_MARK '\041'
  764. #define CHAR_QUOTATION_MARK '\042'
  765. #define CHAR_NUMBER_SIGN '\043'
  766. #define CHAR_DOLLAR_SIGN '\044'
  767. #define CHAR_PERCENT_SIGN '\045'
  768. #define CHAR_AMPERSAND '\046'
  769. #define CHAR_APOSTROPHE '\047'
  770. #define CHAR_LEFT_PARENTHESIS '\050'
  771. #define CHAR_RIGHT_PARENTHESIS '\051'
  772. #define CHAR_ASTERISK '\052'
  773. #define CHAR_PLUS '\053'
  774. #define CHAR_COMMA '\054'
  775. #define CHAR_MINUS '\055'
  776. #define CHAR_DOT '\056'
  777. #define CHAR_SLASH '\057'
  778. #define CHAR_0 '\060'
  779. #define CHAR_1 '\061'
  780. #define CHAR_2 '\062'
  781. #define CHAR_3 '\063'
  782. #define CHAR_4 '\064'
  783. #define CHAR_5 '\065'
  784. #define CHAR_6 '\066'
  785. #define CHAR_7 '\067'
  786. #define CHAR_8 '\070'
  787. #define CHAR_9 '\071'
  788. #define CHAR_COLON '\072'
  789. #define CHAR_SEMICOLON '\073'
  790. #define CHAR_LESS_THAN_SIGN '\074'
  791. #define CHAR_EQUALS_SIGN '\075'
  792. #define CHAR_GREATER_THAN_SIGN '\076'
  793. #define CHAR_QUESTION_MARK '\077'
  794. #define CHAR_COMMERCIAL_AT '\100'
  795. #define CHAR_A '\101'
  796. #define CHAR_B '\102'
  797. #define CHAR_C '\103'
  798. #define CHAR_D '\104'
  799. #define CHAR_E '\105'
  800. #define CHAR_F '\106'
  801. #define CHAR_G '\107'
  802. #define CHAR_H '\110'
  803. #define CHAR_I '\111'
  804. #define CHAR_J '\112'
  805. #define CHAR_K '\113'
  806. #define CHAR_L '\114'
  807. #define CHAR_M '\115'
  808. #define CHAR_N '\116'
  809. #define CHAR_O '\117'
  810. #define CHAR_P '\120'
  811. #define CHAR_Q '\121'
  812. #define CHAR_R '\122'
  813. #define CHAR_S '\123'
  814. #define CHAR_T '\124'
  815. #define CHAR_U '\125'
  816. #define CHAR_V '\126'
  817. #define CHAR_W '\127'
  818. #define CHAR_X '\130'
  819. #define CHAR_Y '\131'
  820. #define CHAR_Z '\132'
  821. #define CHAR_LEFT_SQUARE_BRACKET '\133'
  822. #define CHAR_BACKSLASH '\134'
  823. #define CHAR_RIGHT_SQUARE_BRACKET '\135'
  824. #define CHAR_CIRCUMFLEX_ACCENT '\136'
  825. #define CHAR_UNDERSCORE '\137'
  826. #define CHAR_GRAVE_ACCENT '\140'
  827. #define CHAR_a '\141'
  828. #define CHAR_b '\142'
  829. #define CHAR_c '\143'
  830. #define CHAR_d '\144'
  831. #define CHAR_e '\145'
  832. #define CHAR_f '\146'
  833. #define CHAR_g '\147'
  834. #define CHAR_h '\150'
  835. #define CHAR_i '\151'
  836. #define CHAR_j '\152'
  837. #define CHAR_k '\153'
  838. #define CHAR_l '\154'
  839. #define CHAR_m '\155'
  840. #define CHAR_n '\156'
  841. #define CHAR_o '\157'
  842. #define CHAR_p '\160'
  843. #define CHAR_q '\161'
  844. #define CHAR_r '\162'
  845. #define CHAR_s '\163'
  846. #define CHAR_t '\164'
  847. #define CHAR_u '\165'
  848. #define CHAR_v '\166'
  849. #define CHAR_w '\167'
  850. #define CHAR_x '\170'
  851. #define CHAR_y '\171'
  852. #define CHAR_z '\172'
  853. #define CHAR_LEFT_CURLY_BRACKET '\173'
  854. #define CHAR_VERTICAL_LINE '\174'
  855. #define CHAR_RIGHT_CURLY_BRACKET '\175'
  856. #define CHAR_TILDE '\176'
  857. #define STR_HT "\011"
  858. #define STR_VT "\013"
  859. #define STR_FF "\014"
  860. #define STR_CR "\015"
  861. #define STR_NL "\012"
  862. #define STR_BS "\010"
  863. #define STR_BEL "\007"
  864. #define STR_ESC "\033"
  865. #define STR_DEL "\177"
  866. #define STR_SPACE "\040"
  867. #define STR_EXCLAMATION_MARK "\041"
  868. #define STR_QUOTATION_MARK "\042"
  869. #define STR_NUMBER_SIGN "\043"
  870. #define STR_DOLLAR_SIGN "\044"
  871. #define STR_PERCENT_SIGN "\045"
  872. #define STR_AMPERSAND "\046"
  873. #define STR_APOSTROPHE "\047"
  874. #define STR_LEFT_PARENTHESIS "\050"
  875. #define STR_RIGHT_PARENTHESIS "\051"
  876. #define STR_ASTERISK "\052"
  877. #define STR_PLUS "\053"
  878. #define STR_COMMA "\054"
  879. #define STR_MINUS "\055"
  880. #define STR_DOT "\056"
  881. #define STR_SLASH "\057"
  882. #define STR_0 "\060"
  883. #define STR_1 "\061"
  884. #define STR_2 "\062"
  885. #define STR_3 "\063"
  886. #define STR_4 "\064"
  887. #define STR_5 "\065"
  888. #define STR_6 "\066"
  889. #define STR_7 "\067"
  890. #define STR_8 "\070"
  891. #define STR_9 "\071"
  892. #define STR_COLON "\072"
  893. #define STR_SEMICOLON "\073"
  894. #define STR_LESS_THAN_SIGN "\074"
  895. #define STR_EQUALS_SIGN "\075"
  896. #define STR_GREATER_THAN_SIGN "\076"
  897. #define STR_QUESTION_MARK "\077"
  898. #define STR_COMMERCIAL_AT "\100"
  899. #define STR_A "\101"
  900. #define STR_B "\102"
  901. #define STR_C "\103"
  902. #define STR_D "\104"
  903. #define STR_E "\105"
  904. #define STR_F "\106"
  905. #define STR_G "\107"
  906. #define STR_H "\110"
  907. #define STR_I "\111"
  908. #define STR_J "\112"
  909. #define STR_K "\113"
  910. #define STR_L "\114"
  911. #define STR_M "\115"
  912. #define STR_N "\116"
  913. #define STR_O "\117"
  914. #define STR_P "\120"
  915. #define STR_Q "\121"
  916. #define STR_R "\122"
  917. #define STR_S "\123"
  918. #define STR_T "\124"
  919. #define STR_U "\125"
  920. #define STR_V "\126"
  921. #define STR_W "\127"
  922. #define STR_X "\130"
  923. #define STR_Y "\131"
  924. #define STR_Z "\132"
  925. #define STR_LEFT_SQUARE_BRACKET "\133"
  926. #define STR_BACKSLASH "\134"
  927. #define STR_RIGHT_SQUARE_BRACKET "\135"
  928. #define STR_CIRCUMFLEX_ACCENT "\136"
  929. #define STR_UNDERSCORE "\137"
  930. #define STR_GRAVE_ACCENT "\140"
  931. #define STR_a "\141"
  932. #define STR_b "\142"
  933. #define STR_c "\143"
  934. #define STR_d "\144"
  935. #define STR_e "\145"
  936. #define STR_f "\146"
  937. #define STR_g "\147"
  938. #define STR_h "\150"
  939. #define STR_i "\151"
  940. #define STR_j "\152"
  941. #define STR_k "\153"
  942. #define STR_l "\154"
  943. #define STR_m "\155"
  944. #define STR_n "\156"
  945. #define STR_o "\157"
  946. #define STR_p "\160"
  947. #define STR_q "\161"
  948. #define STR_r "\162"
  949. #define STR_s "\163"
  950. #define STR_t "\164"
  951. #define STR_u "\165"
  952. #define STR_v "\166"
  953. #define STR_w "\167"
  954. #define STR_x "\170"
  955. #define STR_y "\171"
  956. #define STR_z "\172"
  957. #define STR_LEFT_CURLY_BRACKET "\173"
  958. #define STR_VERTICAL_LINE "\174"
  959. #define STR_RIGHT_CURLY_BRACKET "\175"
  960. #define STR_TILDE "\176"
  961. #define STRING_ACCEPT0 STR_A STR_C STR_C STR_E STR_P STR_T "\0"
  962. #define STRING_COMMIT0 STR_C STR_O STR_M STR_M STR_I STR_T "\0"
  963. #define STRING_F0 STR_F "\0"
  964. #define STRING_FAIL0 STR_F STR_A STR_I STR_L "\0"
  965. #define STRING_PRUNE0 STR_P STR_R STR_U STR_N STR_E "\0"
  966. #define STRING_SKIP0 STR_S STR_K STR_I STR_P "\0"
  967. #define STRING_THEN STR_T STR_H STR_E STR_N
  968. #define STRING_alpha0 STR_a STR_l STR_p STR_h STR_a "\0"
  969. #define STRING_lower0 STR_l STR_o STR_w STR_e STR_r "\0"
  970. #define STRING_upper0 STR_u STR_p STR_p STR_e STR_r "\0"
  971. #define STRING_alnum0 STR_a STR_l STR_n STR_u STR_m "\0"
  972. #define STRING_ascii0 STR_a STR_s STR_c STR_i STR_i "\0"
  973. #define STRING_blank0 STR_b STR_l STR_a STR_n STR_k "\0"
  974. #define STRING_cntrl0 STR_c STR_n STR_t STR_r STR_l "\0"
  975. #define STRING_digit0 STR_d STR_i STR_g STR_i STR_t "\0"
  976. #define STRING_graph0 STR_g STR_r STR_a STR_p STR_h "\0"
  977. #define STRING_print0 STR_p STR_r STR_i STR_n STR_t "\0"
  978. #define STRING_punct0 STR_p STR_u STR_n STR_c STR_t "\0"
  979. #define STRING_space0 STR_s STR_p STR_a STR_c STR_e "\0"
  980. #define STRING_word0 STR_w STR_o STR_r STR_d "\0"
  981. #define STRING_xdigit STR_x STR_d STR_i STR_g STR_i STR_t
  982. #define STRING_DEFINE STR_D STR_E STR_F STR_I STR_N STR_E
  983. #define STRING_CR_RIGHTPAR STR_C STR_R STR_RIGHT_PARENTHESIS
  984. #define STRING_LF_RIGHTPAR STR_L STR_F STR_RIGHT_PARENTHESIS
  985. #define STRING_CRLF_RIGHTPAR STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
  986. #define STRING_ANY_RIGHTPAR STR_A STR_N STR_Y STR_RIGHT_PARENTHESIS
  987. #define STRING_ANYCRLF_RIGHTPAR STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
  988. #define STRING_BSR_ANYCRLF_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
  989. #define STRING_BSR_UNICODE_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_U STR_N STR_I STR_C STR_O STR_D STR_E STR_RIGHT_PARENTHESIS
  990. #define STRING_UTF8_RIGHTPAR STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS
  991. #endif /* SUPPORT_UTF8 */
  992. /* Escape items that are just an encoding of a particular data value. */
  993. #ifndef ESC_e
  994. #define ESC_e CHAR_ESC
  995. #endif
  996. #ifndef ESC_f
  997. #define ESC_f CHAR_FF
  998. #endif
  999. #ifndef ESC_n
  1000. #define ESC_n CHAR_NL
  1001. #endif
  1002. #ifndef ESC_r
  1003. #define ESC_r CHAR_CR
  1004. #endif
  1005. /* We can't officially use ESC_t because it is a POSIX reserved identifier
  1006. (presumably because of all the others like size_t). */
  1007. #ifndef ESC_tee
  1008. #define ESC_tee CHAR_HT
  1009. #endif
  1010. /* Codes for different types of Unicode property */
  1011. #define PT_ANY 0 /* Any property - matches all chars */
  1012. #define PT_LAMP 1 /* L& - the union of Lu, Ll, Lt */
  1013. #define PT_GC 2 /* General characteristic (e.g. L) */
  1014. #define PT_PC 3 /* Particular characteristic (e.g. Lu) */
  1015. #define PT_SC 4 /* Script (e.g. Han) */
  1016. /* Flag bits and data types for the extended class (OP_XCLASS) for classes that
  1017. contain UTF-8 characters with values greater than 255. */
  1018. #define XCL_NOT 0x01 /* Flag: this is a negative class */
  1019. #define XCL_MAP 0x02 /* Flag: a 32-byte map is present */
  1020. #define XCL_END 0 /* Marks end of individual items */
  1021. #define XCL_SINGLE 1 /* Single item (one multibyte char) follows */
  1022. #define XCL_RANGE 2 /* A range (two multibyte chars) follows */
  1023. #define XCL_PROP 3 /* Unicode property (2-byte property code follows) */
  1024. #define XCL_NOTPROP 4 /* Unicode inverted property (ditto) */
  1025. /* These are escaped items that aren't just an encoding of a particular data
  1026. value such as \n. They must have non-zero values, as check_escape() returns
  1027. their negation. Also, they must appear in the same order as in the opcode
  1028. definitions below, up to ESC_z. There's a dummy for OP_ANY because it
  1029. corresponds to "." rather than an escape sequence, and another for OP_ALLANY
  1030. (which is used for [^] in JavaScript compatibility mode).
  1031. The final escape must be ESC_REF as subsequent values are used for
  1032. backreferences (\1, \2, \3, etc). There are two tests in the code for an escape
  1033. greater than ESC_b and less than ESC_Z to detect the types that may be
  1034. repeated. These are the types that consume characters. If any new escapes are
  1035. put in between that don't consume a character, that code will have to change.
  1036. */
  1037. enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
  1038. ESC_W, ESC_w, ESC_dum1, ESC_dum2, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,
  1039. ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_g, ESC_k,
  1040. ESC_REF };
  1041. /* Opcode table: Starting from 1 (i.e. after OP_END), the values up to
  1042. OP_EOD must correspond in order to the list of escapes immediately above.
  1043. *** NOTE NOTE NOTE *** Whenever this list is updated, the two macro definitions
  1044. that follow must also be updated to match. There are also tables called
  1045. "coptable" and "poptable" in pcre_dfa_exec.c that must be updated. */
  1046. enum {
  1047. OP_END, /* 0 End of pattern */
  1048. /* Values corresponding to backslashed metacharacters */
  1049. OP_SOD, /* 1 Start of data: \A */
  1050. OP_SOM, /* 2 Start of match (subject + offset): \G */
  1051. OP_SET_SOM, /* 3 Set start of match (\K) */
  1052. OP_NOT_WORD_BOUNDARY, /* 4 \B */
  1053. OP_WORD_BOUNDARY, /* 5 \b */
  1054. OP_NOT_DIGIT, /* 6 \D */
  1055. OP_DIGIT, /* 7 \d */
  1056. OP_NOT_WHITESPACE, /* 8 \S */
  1057. OP_WHITESPACE, /* 9 \s */
  1058. OP_NOT_WORDCHAR, /* 10 \W */
  1059. OP_WORDCHAR, /* 11 \w */
  1060. OP_ANY, /* 12 Match any character (subject to DOTALL) */
  1061. OP_ALLANY, /* 13 Match any character (not subject to DOTALL) */
  1062. OP_ANYBYTE, /* 14 Match any byte (\C); different to OP_ANY for UTF-8 */
  1063. OP_NOTPROP, /* 15 \P (not Unicode property) */
  1064. OP_PROP, /* 16 \p (Unicode property) */
  1065. OP_ANYNL, /* 17 \R (any newline sequence) */
  1066. OP_NOT_HSPACE, /* 18 \H (not horizontal whitespace) */
  1067. OP_HSPACE, /* 19 \h (horizontal whitespace) */
  1068. OP_NOT_VSPACE, /* 20 \V (not vertical whitespace) */
  1069. OP_VSPACE, /* 21 \v (vertical whitespace) */
  1070. OP_EXTUNI, /* 22 \X (extended Unicode sequence */
  1071. OP_EODN, /* 23 End of data or \n at end of data: \Z. */
  1072. OP_EOD, /* 24 End of data: \z */
  1073. OP_OPT, /* 25 Set runtime options */
  1074. OP_CIRC, /* 26 Start of line - varies with multiline switch */
  1075. OP_DOLL, /* 27 End of line - varies with multiline switch */
  1076. OP_CHAR, /* 28 Match one character, casefully */
  1077. OP_CHARNC, /* 29 Match one character, caselessly */
  1078. OP_NOT, /* 30 Match one character, not the following one */
  1079. OP_STAR, /* 31 The maximizing and minimizing versions of */
  1080. OP_MINSTAR, /* 32 these six opcodes must come in pairs, with */
  1081. OP_PLUS, /* 33 the minimizing one second. */
  1082. OP_MINPLUS, /* 34 This first set applies to single characters.*/
  1083. OP_QUERY, /* 35 */
  1084. OP_MINQUERY, /* 36 */
  1085. OP_UPTO, /* 37 From 0 to n matches */
  1086. OP_MINUPTO, /* 38 */
  1087. OP_EXACT, /* 39 Exactly n matches */
  1088. OP_POSSTAR, /* 40 Possessified star */
  1089. OP_POSPLUS, /* 41 Possessified plus */
  1090. OP_POSQUERY, /* 42 Posesssified query */
  1091. OP_POSUPTO, /* 43 Possessified upto */
  1092. OP_NOTSTAR, /* 44 The maximizing and minimizing versions of */
  1093. OP_NOTMINSTAR, /* 45 these six opcodes must come in pairs, with */
  1094. OP_NOTPLUS, /* 46 the minimizing one second. They must be in */
  1095. OP_NOTMINPLUS, /* 47 exactly the same order as those above. */
  1096. OP_NOTQUERY, /* 48 This set applies to "not" single characters. */
  1097. OP_NOTMINQUERY, /* 49 */
  1098. OP_NOTUPTO, /* 50 From 0 to n matches */
  1099. OP_NOTMINUPTO, /* 51 */
  1100. OP_NOTEXACT, /* 52 Exactly n matches */
  1101. OP_NOTPOSSTAR, /* 53 Possessified versions */
  1102. OP_NOTPOSPLUS, /* 54 */
  1103. OP_NOTPOSQUERY, /* 55 */
  1104. OP_NOTPOSUPTO, /* 56 */
  1105. OP_TYPESTAR, /* 57 The maximizing and minimizing versions of */
  1106. OP_TYPEMINSTAR, /* 58 these six opcodes must come in pairs, with */
  1107. OP_TYPEPLUS, /* 59 the minimizing one second. These codes must */
  1108. OP_TYPEMINPLUS, /* 60 be in exactly the same ordeā€¦

Large files files are truncated, but you can click here to view the full file