⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcre_internal.h

📁 技术管理量不要让站长把时间都花费在为您修正说明上。压缩包解压
💻 H
📖 第 1 页 / 共 3 页
字号:
/**************************************************      Perl-Compatible Regular Expressions       **************************************************//* PCRE is a library of functions to support regular expressions whose syntaxand semantics are as close as possible to those of the Perl 5 language.                       Written by Philip Hazel           Copyright (c) 1997-2006 University of Cambridge-----------------------------------------------------------------------------Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:    * Redistributions of source code must retain the above copyright notice,      this list of conditions and the following disclaimer.    * Redistributions in binary form must reproduce the above copyright      notice, this list of conditions and the following disclaimer in the      documentation and/or other materials provided with the distribution.    * Neither the name of the University of Cambridge nor the names of its      contributors may be used to endorse or promote products derived from      this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BELIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ORCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OFSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESSINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER INCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF SUCH DAMAGE.-----------------------------------------------------------------------------*//* This header contains definitions that are shared between the differentmodules, but which are not relevant to the exported API. This includes somefunctions whose names all begin with "_pcre_". */#ifndef PCRE_INTERNAL_H#define PCRE_INTERNAL_H/* Define DEBUG to get debugging output on stdout. */#if 0#define DEBUG#endif/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdefinline, and there are *still* stupid compilers about that don't like indentedpre-processor statements, or at least there were when I first wrote this. Afterall, it had only been about 10 years then... */#ifdef DEBUG#define DPRINTF(p) printf p#else#define DPRINTF(p) /*nothing*/#endif/* Get the definitions provided by running "configure" */#ifdef PHP_WIN32# include "config.w32.h"#else# include <php_config.h>#endif/* Standard C headers plus the external interface definition. The only timesetjmp and stdarg are used is when NO_RECURSE is set. */#include <ctype.h>#include <limits.h>#include <setjmp.h>#include <stdarg.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#ifndef PCRE_SPY#define PCRE_DEFINITION       /* Win32 __declspec(export) trigger for .dll */#endif/* We need to have types that specify unsigned 16-bit and 32-bit integers. Wecannot determine these outside the compilation (e.g. by running a program aspart of "configure") because PCRE is often cross-compiled for use on othersystems. Instead we make use of the maximum sizes that are available atpreprocessor time in standard C environments. */#if USHRT_MAX == 65535  typedef unsigned short pcre_uint16;#elif UINT_MAX == 65535  typedef unsigned int pcre_uint16;#else  #error Cannot determine a type for 16-bit unsigned integers#endif#if UINT_MAX == 4294967295  typedef unsigned int pcre_uint32;#elif ULONG_MAX == 4294967295  typedef unsigned long int pcre_uint32;#else  #error Cannot determine a type for 32-bit unsigned integers#endif/* All character handling must be done as unsigned characters. Otherwise thereare problems with top-bit-set characters and functions such as isspace().However, we leave the interface to the outside world as char *, because thatshould make things easier for callers. We define a short type for unsigned charto save lots of typing. I tried "uchar", but it causes problems on DigitalUnix, where it is defined in sys/types, so use "uschar" instead. */typedef unsigned char uschar;/* When PCRE is compiled as a C++ library, the subject pointer can be replacedwith a custom type. This makes it possible, for example, to allow pcre_exec()to process subject strings that are discontinuous by using a smart pointerclass. It must always be possible to inspect all of the subject string inpcre_exec() because of the way it backtracks. Two macros are required in thenormal case, for sign-unspecified and unsigned char pointers. The former isused for the external interface and appears in pcre.h, which is why its namemust begin with PCRE_. */#ifdef CUSTOM_SUBJECT_PTR#define PCRE_SPTR CUSTOM_SUBJECT_PTR#define USPTR CUSTOM_SUBJECT_PTR#else#define PCRE_SPTR const char *#define USPTR const unsigned char *#endif/* Include the public PCRE header and the definitions of UCP character propertyvalues. */#include "pcre.h"#include "ucp.h"/* When compiling for use with the Virtual Pascal compiler, these functionsneed to have their names changed. PCRE must be compiled with the -DVPCOMPAToption on the command line. */#ifdef VPCOMPAT#define strncmp(s1,s2,m) _strncmp(s1,s2,m)#define memcpy(d,s,n)    _memcpy(d,s,n)#define memmove(d,s,n)   _memmove(d,s,n)#define memset(s,c,n)    _memset(s,c,n)#else  /* VPCOMPAT *//* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPYis set. Otherwise, include an emulating function for those systems that haveneither (there some non-Unix environments where this is the case). This assumesthat all calls to memmove are moving strings upwards in store, which is thecase in PCRE. */#if ! HAVE_MEMMOVE#undef  memmove        /* some systems may have a macro */#if HAVE_BCOPY#define memmove(a, b, c) bcopy(b, a, c)#else  /* HAVE_BCOPY */void *pcre_memmove(unsigned char *dest, const unsigned char *src, size_t n){size_t i;dest += n;src += n;for (i = 0; i < n; ++i) *(--dest) =  *(--src);return dest;}#define memmove(a, b, c) pcre_memmove(a, b, c)#endif   /* not HAVE_BCOPY */#endif   /* not HAVE_MEMMOVE */#endif   /* not VPCOMPAT *//* PCRE keeps offsets in its compiled code as 2-byte quantities (always storedin big-endian order) by default. These are used, for example, to link from thestart of a subpattern to its alternatives and its end. The use of 2 bytes peroffset limits the size of the compiled regex to around 64K, which is big enoughfor almost everybody. However, I received a request for an even bigger limit.For this reason, and also to make the code easier to maintain, the storing andloading of offsets from the byte string is now handled by the macros that aredefined here.The macros are controlled by the value of LINK_SIZE. This defaults to 2 inthe config.h file, but can be overridden by using -D on the command line. Thisis automated on Unix systems via the "configure" command. */#if LINK_SIZE == 2#define PUT(a,n,d)   \  (a[n] = (d) >> 8), \  (a[(n)+1] = (d) & 255)#define GET(a,n) \  (((a)[n] << 8) | (a)[(n)+1])#define MAX_PATTERN_SIZE (1 << 16)#elif LINK_SIZE == 3#define PUT(a,n,d)       \  (a[n] = (d) >> 16),    \  (a[(n)+1] = (d) >> 8), \  (a[(n)+2] = (d) & 255)#define GET(a,n) \  (((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])#define MAX_PATTERN_SIZE (1 << 24)#elif LINK_SIZE == 4#define PUT(a,n,d)        \  (a[n] = (d) >> 24),     \  (a[(n)+1] = (d) >> 16), \  (a[(n)+2] = (d) >> 8),  \  (a[(n)+3] = (d) & 255)#define GET(a,n) \  (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])#define MAX_PATTERN_SIZE (1 << 30)   /* Keep it positive */#else#error LINK_SIZE must be either 2, 3, or 4#endif/* Convenience macro defined in terms of the others */#define PUTINC(a,n,d)   PUT(a,n,d), a += LINK_SIZE/* PCRE uses some other 2-byte quantities that do not change when the size ofoffsets changes. There are used for repeat counts and for other things such ascapturing parenthesis numbers in back references. */#define PUT2(a,n,d)   \  a[n] = (d) >> 8; \  a[(n)+1] = (d) & 255#define GET2(a,n) \  (((a)[n] << 8) | (a)[(n)+1])#define PUT2INC(a,n,d)  PUT2(a,n,d), a += 2/* When UTF-8 encoding is being used, a character is no longer just a singlebyte. The macros for character handling generate simple sequences when used inbyte-mode, and more complicated ones for UTF-8 characters. */#ifndef SUPPORT_UTF8#define GETCHAR(c, eptr) c = *eptr;#define GETCHARTEST(c, eptr) c = *eptr;#define GETCHARINC(c, eptr) c = *eptr++;#define GETCHARINCTEST(c, eptr) c = *eptr++;#define GETCHARLEN(c, eptr, len) c = *eptr;#define BACKCHAR(eptr)#else   /* SUPPORT_UTF8 *//* Get the next UTF-8 character, not advancing the pointer. This is called whenwe know we are in UTF-8 mode. */#define GETCHAR(c, eptr) \  c = *eptr; \  if ((c & 0xc0) == 0xc0) \    { \    int gcii; \    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \    int gcss = 6*gcaa; \    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \    for (gcii = 1; gcii <= gcaa; gcii++) \      { \      gcss -= 6; \      c |= (eptr[gcii] & 0x3f) << gcss; \      } \    }/* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing thepointer. */#define GETCHARTEST(c, eptr) \  c = *eptr; \  if (utf8 && (c & 0xc0) == 0xc0) \    { \    int gcii; \    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \    int gcss = 6*gcaa; \    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \    for (gcii = 1; gcii <= gcaa; gcii++) \      { \      gcss -= 6; \      c |= (eptr[gcii] & 0x3f) << gcss; \      } \    }/* Get the next UTF-8 character, advancing the pointer. This is called when weknow we are in UTF-8 mode. */#define GETCHARINC(c, eptr) \  c = *eptr++; \  if ((c & 0xc0) == 0xc0) \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -