?? internal.h
字號(hào):
/************************************************** Perl-Compatible Regular Expressions **************************************************//* This is a library of functions to support regular expressions whose syntaxand semantics are as close as possible to those of the Perl 5 language. Seethe file doc/Tech.Notes for some information on the internals.Written by: Philip Hazel <ph10@cam.ac.uk> Copyright (c) 1997-2004 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 outside. *//* Get the definitions provided by running "configure" */#include "config.h"/* 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;/* Include the public PCRE header */#include "pcre.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 */static void *pcre_memmove(unsigned char *dest, const unsigned char *src, size_t n){int i;dest += n;src += n;for (i = 0; i < n; ++i) *(--dest) = *(--src);}#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/* In case there is no definition of offsetof() provided - though any properStandard C system should have one. */#ifndef offsetof#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))#endif/* These are the public options that can change during matching. */#define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)/* Private options flags start at the most significant end of the four bytes,but skip the top bit so we can use ints for convenience without getting tangledwith negative values. The public options defined in pcre.h start at the leastsignificant end. Make sure they don't overlap, though now that we have expandedto four bytes, there is plenty of space. */#define PCRE_FIRSTSET 0x40000000 /* first_byte is set */#define PCRE_REQCHSET 0x20000000 /* req_byte is set */#define PCRE_STARTLINE 0x10000000 /* start after \n for multiline */#define PCRE_ICHANGED 0x08000000 /* i option changes within regex */#define PCRE_NOPARTIAL 0x04000000 /* can't use partial with this regex *//* Options for the "extra" block produced by pcre_study(). */#define PCRE_STUDY_MAPPED 0x01 /* a map of starting chars exists *//* Masks for identifying the public options which are permitted at compiletime, run time or study time, respectively. */#define PUBLIC_OPTIONS \ (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \ PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \ PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT)#define PUBLIC_EXEC_OPTIONS \ (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -