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

📄 pcreinternal.h

📁 This software aims to create an applet and panel tools to manage a wireless interface card, such as
💻 H
📖 第 1 页 / 共 3 页
字号:
   PCRE_PARTIAL)

#define PUBLIC_STUDY_OPTIONS 0   /* None defined */

/* Magic number to provide a small check against being handed junk. */

#define MAGIC_NUMBER  0x50435245UL   /* 'PCRE' */

/* Negative values for the firstchar and reqchar variables */

#define REQ_UNSET (-2)
#define REQ_NONE  (-1)

/* Flags added to firstbyte or reqbyte; a "non-literal" item is either a
variable-length repeat, or a anything other than literal characters. */

#define REQ_CASELESS 0x0100    /* indicates caselessness */
#define REQ_VARY     0x0200    /* reqbyte followed non-literal item */

/* Miscellaneous definitions */

typedef int BOOL;

#define FALSE   0
#define TRUE    1

/* Escape items that are just an encoding of a particular data value. Note that
ESC_n is defined as yet another macro, which is set in config.h to either \n
(the default) or \r (which some people want). */

#ifndef ESC_e
#define ESC_e 27
#endif

#ifndef ESC_f
#define ESC_f '\f'
#endif

#ifndef ESC_n
#define ESC_n NEWLINE
#endif

#ifndef ESC_r
#define ESC_r '\r'
#endif

/* We can't officially use ESC_t because it is a POSIX reserved identifier
(presumably because of all the others like size_t). */

#ifndef ESC_tee
#define ESC_tee '\t'
#endif

/* These are escaped items that aren't just an encoding of a particular data
value such as \n. They must have non-zero values, as check_escape() returns
their negation. Also, they must appear in the same order as in the opcode
definitions below, up to ESC_z. There's a dummy for OP_ANY because it
corresponds to "." rather than an escape sequence. The final one must be
ESC_REF as subsequent values are used for \1, \2, \3, etc. There is are two
tests in the code for an escape greater than ESC_b and less than ESC_Z to
detect the types that may be repeated. These are the types that consume
characters. If any new escapes are put in between that don't consume a
character, that code will have to change. */

enum { ESC_A = 1, ESC_G, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W,
       ESC_w, ESC_dum1, ESC_C, ESC_P, ESC_p, ESC_X, ESC_Z, ESC_z, ESC_E,
       ESC_Q, ESC_REF };

/* Flag bits and data types for the extended class (OP_XCLASS) for classes that
contain UTF-8 characters with values greater than 255. */

#define XCL_NOT    0x01    /* Flag: this is a negative class */
#define XCL_MAP    0x02    /* Flag: a 32-byte map is present */

#define XCL_END       0    /* Marks end of individual items */
#define XCL_SINGLE    1    /* Single item (one multibyte char) follows */
#define XCL_RANGE     2    /* A range (two multibyte chars) follows */
#define XCL_PROP      3    /* Unicode property (one property code) follows */
#define XCL_NOTPROP   4    /* Unicode inverted property (ditto) */


/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
OP_EOD must correspond in order to the list of escapes immediately above.
Note that whenever this list is updated, the two macro definitions that follow
must also be updated to match. */

enum {
  OP_END,            /* 0 End of pattern */

  /* Values corresponding to backslashed metacharacters */

  OP_SOD,            /* 1 Start of data: \A */
  OP_SOM,            /* 2 Start of match (subject + offset): \G */
  OP_NOT_WORD_BOUNDARY,  /*  3 \B */
  OP_WORD_BOUNDARY,      /*  4 \b */
  OP_NOT_DIGIT,          /*  5 \D */
  OP_DIGIT,              /*  6 \d */
  OP_NOT_WHITESPACE,     /*  7 \S */
  OP_WHITESPACE,         /*  8 \s */
  OP_NOT_WORDCHAR,       /*  9 \W */
  OP_WORDCHAR,           /* 10 \w */
  OP_ANY,            /* 11 Match any character */
  OP_ANYBYTE,        /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */
  OP_NOTPROP,        /* 13 \P (not Unicode property) */
  OP_PROP,           /* 14 \p (Unicode property) */
  OP_EXTUNI,         /* 15 \X (extended Unicode sequence */
  OP_EODN,           /* 16 End of data or \n at end of data: \Z. */
  OP_EOD,            /* 17 End of data: \z */

  OP_OPT,            /* 18 Set runtime options */
  OP_CIRC,           /* 19 Start of line - varies with multiline switch */
  OP_DOLL,           /* 20 End of line - varies with multiline switch */
  OP_CHAR,           /* 21 Match one character, casefully */
  OP_CHARNC,         /* 22 Match one character, caselessly */
  OP_NOT,            /* 23 Match anything but the following char */

  OP_STAR,           /* 24 The maximizing and minimizing versions of */
  OP_MINSTAR,        /* 25 all these opcodes must come in pairs, with */
  OP_PLUS,           /* 26 the minimizing one second. */
  OP_MINPLUS,        /* 27 This first set applies to single characters */
  OP_QUERY,          /* 28 */
  OP_MINQUERY,       /* 29 */
  OP_UPTO,           /* 30 From 0 to n matches */
  OP_MINUPTO,        /* 31 */
  OP_EXACT,          /* 32 Exactly n matches */

  OP_NOTSTAR,        /* 33 The maximizing and minimizing versions of */
  OP_NOTMINSTAR,     /* 34 all these opcodes must come in pairs, with */
  OP_NOTPLUS,        /* 35 the minimizing one second. */
  OP_NOTMINPLUS,     /* 36 This set applies to "not" single characters */
  OP_NOTQUERY,       /* 37 */
  OP_NOTMINQUERY,    /* 38 */
  OP_NOTUPTO,        /* 39 From 0 to n matches */
  OP_NOTMINUPTO,     /* 40 */
  OP_NOTEXACT,       /* 41 Exactly n matches */

  OP_TYPESTAR,       /* 42 The maximizing and minimizing versions of */
  OP_TYPEMINSTAR,    /* 43 all these opcodes must come in pairs, with */
  OP_TYPEPLUS,       /* 44 the minimizing one second. These codes must */
  OP_TYPEMINPLUS,    /* 45 be in exactly the same order as those above. */
  OP_TYPEQUERY,      /* 46 This set applies to character types such as \d */
  OP_TYPEMINQUERY,   /* 47 */
  OP_TYPEUPTO,       /* 48 From 0 to n matches */
  OP_TYPEMINUPTO,    /* 49 */
  OP_TYPEEXACT,      /* 50 Exactly n matches */

  OP_CRSTAR,         /* 51 The maximizing and minimizing versions of */
  OP_CRMINSTAR,      /* 52 all these opcodes must come in pairs, with */
  OP_CRPLUS,         /* 53 the minimizing one second. These codes must */
  OP_CRMINPLUS,      /* 54 be in exactly the same order as those above. */
  OP_CRQUERY,        /* 55 These are for character classes and back refs */
  OP_CRMINQUERY,     /* 56 */
  OP_CRRANGE,        /* 57 These are different to the three sets above. */
  OP_CRMINRANGE,     /* 58 */

  OP_CLASS,          /* 59 Match a character class, chars < 256 only */
  OP_NCLASS,         /* 60 Same, but the bitmap was created from a negative
                           class - the difference is relevant only when a UTF-8
                           character > 255 is encountered. */

  OP_XCLASS,         /* 61 Extended class for handling UTF-8 chars within the
                           class. This does both positive and negative. */

  OP_REF,            /* 62 Match a back reference */
  OP_RECURSE,        /* 63 Match a numbered subpattern (possibly recursive) */
  OP_CALLOUT,        /* 64 Call out to external function if provided */

  OP_ALT,            /* 65 Start of alternation */
  OP_KET,            /* 66 End of group that doesn't have an unbounded repeat */
  OP_KETRMAX,        /* 67 These two must remain together and in this */
  OP_KETRMIN,        /* 68 order. They are for groups the repeat for ever. */

  /* The assertions must come before ONCE and COND */

  OP_ASSERT,         /* 69 Positive lookahead */
  OP_ASSERT_NOT,     /* 70 Negative lookahead */
  OP_ASSERTBACK,     /* 71 Positive lookbehind */
  OP_ASSERTBACK_NOT, /* 72 Negative lookbehind */
  OP_REVERSE,        /* 73 Move pointer back - used in lookbehind assertions */

  /* ONCE and COND must come after the assertions, with ONCE first, as there's
  a test for >= ONCE for a subpattern that isn't an assertion. */

  OP_ONCE,           /* 74 Once matched, don't back up into the subpattern */
  OP_COND,           /* 75 Conditional group */
  OP_CREF,           /* 76 Used to hold an extraction string number (cond ref) */

  OP_BRAZERO,        /* 77 These two must remain together and in this */
  OP_BRAMINZERO,     /* 78 order. */

  OP_BRANUMBER,      /* 79 Used for extracting brackets whose number is greater
                           than can fit into an opcode. */

  OP_BRA             /* 80 This and greater values are used for brackets that
                           extract substrings up to EXTRACT_BASIC_MAX. After
                           that, use is made of OP_BRANUMBER. */
};

/* WARNING WARNING WARNING: There is an implicit assumption in pcre.c and
study.c that all opcodes are less than 128 in value. This makes handling UTF-8
character sequences easier. */

/* The highest extraction number before we have to start using additional
bytes. (Originally PCRE didn't have support for extraction counts highter than
this number.) The value is limited by the number of opcodes left after OP_BRA,
i.e. 255 - OP_BRA. We actually set it a bit lower to leave room for additional
opcodes. */

#define EXTRACT_BASIC_MAX  100


/* This macro defines textual names for all the opcodes. There are used only
for debugging, in pcre.c when DEBUG is defined, and also in pcretest.c. The
macro is referenced only in printint.c. */

#define OP_NAME_LIST \
  "End", "\\A", "\\G", "\\B", "\\b", "\\D", "\\d",                \
  "\\S", "\\s", "\\W", "\\w", "Any", "Anybyte",                   \
  "notprop", "prop", "extuni",                                    \
  "\\Z", "\\z",                                                   \
  "Opt", "^", "$", "char", "charnc", "not",                       \
  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \
  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \
  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \
  "*", "*?", "+", "+?", "?", "??", "{", "{",                      \
  "class", "nclass", "xclass", "Ref", "Recurse", "Callout",       \
  "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not",     \
  "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cond ref",\
  "Brazero", "Braminzero", "Branumber", "Bra"


/* This macro defines the length of fixed length operations in the compiled
regex. The lengths are used when searching for specific things, and also in the
debugging printing of a compiled regex. We use a macro so that it can be
incorporated both into pcre.c and pcretest.c without being publicly exposed.

As things have been extended, some of these are no longer fixed lenths, but are
minima instead. For example, the length of a single-character repeat may vary
in UTF-8 mode. The code that uses this table must know about such things. */

#define OP_LENGTHS \
  1,                             /* End                                    */ \
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* \A, \G, \B, \B, \D, \d, \S, \s, \W, \w */ \
  1, 1,                          /* Any, Anybyte                           */ \
  2, 2, 1,                       /* NOTPROP, PROP, EXTUNI                  */ \
  1, 1, 2, 1, 1,                 /* \Z, \z, Opt, ^, $                      */ \
  2,                             /* Char  - the minimum length             */ \
  2,                             /* Charnc  - the minimum length           */ \
  2,                             /* not                                    */ \
  /* Positive single-char repeats                            ** These are  */ \

⌨️ 快捷键说明

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