00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include "autoconf.h"
00044 #include "config.h"
00045
00046 #include <limits.h>
00047 #include <string.h>
00048 #include <ctype.h>
00049 #include <stdlib.h>
00050 #include <stddef.h>
00051 #include "pcre.h"
00052
00053 #include "externs.h"
00054 #include "timeutil.h"
00055
00056
00057 #define LINK_SIZE 2
00058 #define MATCH_LIMIT 100000
00059 #define NEWLINE '\n'
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 #define PUT(a,n,d) \
00079 (a[n] = (d) >> 8), \
00080 (a[(n)+1] = (d) & 255)
00081
00082 #define GET(a,n) \
00083 (((a)[n] << 8) | (a)[(n)+1])
00084
00085 #define MAX_PATTERN_SIZE (1 << 16)
00086
00087
00088
00089
00090 #define PUTINC(a,n,d) PUT(a,n,d), a += LINK_SIZE
00091
00092
00093
00094
00095
00096
00097 #define PUT2(a,n,d) \
00098 a[n] = (d) >> 8; \
00099 a[(n)+1] = (d) & 255
00100
00101 #define GET2(a,n) \
00102 (((a)[n] << 8) | (a)[(n)+1])
00103
00104 #define PUT2INC(a,n,d) PUT2(a,n,d), a += 2
00105
00106
00107
00108 #define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
00109
00110
00111
00112
00113
00114
00115
00116 #define PCRE_FIRSTSET 0x40000000
00117 #define PCRE_REQCHSET 0x20000000
00118 #define PCRE_STARTLINE 0x10000000
00119 #define PCRE_ICHANGED 0x08000000
00120
00121
00122
00123 #define PCRE_STUDY_MAPPED 0x01
00124
00125
00126
00127
00128 #define PUBLIC_OPTIONS \
00129 (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
00130 PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
00131 PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK)
00132
00133 #define PUBLIC_EXEC_OPTIONS \
00134 (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK)
00135
00136 #define PUBLIC_STUDY_OPTIONS 0
00137
00138
00139
00140 #define MAGIC_NUMBER 0x50435245UL
00141
00142
00143
00144 #define REQ_UNSET (-2)
00145 #define REQ_NONE (-1)
00146
00147
00148
00149
00150 #define REQ_CASELESS 0x0100
00151 #define REQ_VARY 0x0200
00152
00153
00154
00155
00156
00157
00158
00159 #ifndef ESC_e
00160 #define ESC_e 27
00161 #endif
00162
00163 #ifndef ESC_f
00164 #define ESC_f '\f'
00165 #endif
00166
00167 #ifndef ESC_n
00168 #define ESC_n NEWLINE
00169 #endif
00170
00171 #ifndef ESC_r
00172 #define ESC_r '\r'
00173 #endif
00174
00175
00176
00177
00178 #ifndef ESC_tee
00179 #define ESC_tee '\t'
00180 #endif
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 enum { ESC_A = 1, ESC_G, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W,
00194 ESC_w, ESC_dum1, ESC_C, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_REF };
00195
00196
00197
00198
00199 #define XCL_NOT 0x01
00200 #define XCL_MAP 0x02
00201
00202 #define XCL_END 0
00203 #define XCL_SINGLE 1
00204 #define XCL_RANGE 2
00205
00206
00207
00208
00209
00210
00211
00212
00213 enum {
00214 OP_END,
00215
00216
00217
00218 OP_SOD,
00219 OP_SOM,
00220 OP_NOT_WORD_BOUNDARY,
00221 OP_WORD_BOUNDARY,
00222 OP_NOT_DIGIT,
00223 OP_DIGIT,
00224 OP_NOT_WHITESPACE,
00225 OP_WHITESPACE,
00226 OP_NOT_WORDCHAR,
00227 OP_WORDCHAR,
00228 OP_ANY,
00229 OP_ANYBYTE,
00230 OP_EODN,
00231 OP_EOD,
00232
00233 OP_OPT,
00234 OP_CIRC,
00235 OP_DOLL,
00236 OP_CHARS,
00237 OP_NOT,
00238
00239 OP_STAR,
00240 OP_MINSTAR,
00241 OP_PLUS,
00242 OP_MINPLUS,
00243 OP_QUERY,
00244 OP_MINQUERY,
00245 OP_UPTO,
00246 OP_MINUPTO,
00247 OP_EXACT,
00248
00249 OP_NOTSTAR,
00250 OP_NOTMINSTAR,
00251 OP_NOTPLUS,
00252 OP_NOTMINPLUS,
00253 OP_NOTQUERY,
00254 OP_NOTMINQUERY,
00255 OP_NOTUPTO,
00256 OP_NOTMINUPTO,
00257 OP_NOTEXACT,
00258
00259 OP_TYPESTAR,
00260 OP_TYPEMINSTAR,
00261 OP_TYPEPLUS,
00262 OP_TYPEMINPLUS,
00263 OP_TYPEQUERY,
00264 OP_TYPEMINQUERY,
00265 OP_TYPEUPTO,
00266 OP_TYPEMINUPTO,
00267 OP_TYPEEXACT,
00268
00269 OP_CRSTAR,
00270 OP_CRMINSTAR,
00271 OP_CRPLUS,
00272 OP_CRMINPLUS,
00273 OP_CRQUERY,
00274 OP_CRMINQUERY,
00275 OP_CRRANGE,
00276 OP_CRMINRANGE,
00277
00278 OP_CLASS,
00279 OP_NCLASS,
00280
00281
00282
00283 OP_XCLASS,
00284
00285
00286 OP_REF,
00287 OP_RECURSE,
00288 OP_CALLOUT,
00289
00290 OP_ALT,
00291 OP_KET,
00292 OP_KETRMAX,
00293 OP_KETRMIN,
00294
00295
00296
00297 OP_ASSERT,
00298 OP_ASSERT_NOT,
00299 OP_ASSERTBACK,
00300 OP_ASSERTBACK_NOT,
00301 OP_REVERSE,
00302
00303
00304
00305
00306 OP_ONCE,
00307 OP_COND,
00308 OP_CREF,
00309
00310 OP_BRAZERO,
00311 OP_BRAMINZERO,
00312
00313 OP_BRANUMBER,
00314
00315
00316 OP_BRA
00317
00318
00319 };
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330 #define OP_NAME_LIST \
00331 "End", "\\A", "\\G", "\\B", "\\b", "\\D", "\\d", \
00332 "\\S", "\\s", "\\W", "\\w", "Any", "Anybyte", "\\Z", "\\z", \
00333 "Opt", "^", "$", "chars", "not", \
00334 "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
00335 "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
00336 "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
00337 "*", "*?", "+", "+?", "?", "??", "{", "{", \
00338 "class", "nclass", "xclass", "Ref", "Recurse", "Callout", \
00339 "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not", \
00340 "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cond ref",\
00341 "Brazero", "Braminzero", "Branumber", "Bra"
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353 #define OP_LENGTHS \
00354 1, \
00355 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
00356 1, 1, 1, 1, 2, 1, 1, \
00357 2, \
00358 2, \
00359 \
00360 2, 2, 2, 2, 2, 2, \
00361 4, 4, 4, \
00362 \
00363 2, 2, 2, 2, 2, 2, \
00364 4, 4, 4, \
00365 \
00366 2, 2, 2, 2, 2, 2, \
00367 4, 4, 4, \
00368 \
00369 1, 1, 1, 1, 1, 1, \
00370 5, 5, \
00371 33, \
00372 33, \
00373 0, \
00374 3, \
00375 1+LINK_SIZE, \
00376 2, \
00377 1+LINK_SIZE, \
00378 1+LINK_SIZE, \
00379 1+LINK_SIZE, \
00380 1+LINK_SIZE, \
00381 1+LINK_SIZE, \
00382 1+LINK_SIZE, \
00383 1+LINK_SIZE, \
00384 1+LINK_SIZE, \
00385 1+LINK_SIZE, \
00386 1+LINK_SIZE, \
00387 1+LINK_SIZE, \
00388 3, \
00389 1, 1, \
00390 3, \
00391 1+LINK_SIZE \
00392
00393
00394
00395
00396
00397
00398
00399
00400 #define EXTRACT_BASIC_MAX 150
00401
00402
00403
00404 #define CREF_RECURSE 0xffff
00405
00406
00407
00408
00409
00410
00411 #define ERR1 "\\ at end of pattern"
00412 #define ERR2 "\\c at end of pattern"
00413 #define ERR3 "unrecognized character follows \\"
00414 #define ERR4 "numbers out of order in {} quantifier"
00415 #define ERR5 "number too big in {} quantifier"
00416 #define ERR6 "missing terminating ] for character class"
00417 #define ERR7 "invalid escape sequence in character class"
00418 #define ERR8 "range out of order in character class"
00419 #define ERR9 "nothing to repeat"
00420 #define ERR10 "operand of unlimited repeat could match the empty string"
00421 #define ERR11 "internal error: unexpected repeat"
00422 #define ERR12 "unrecognized character after (?"
00423 #define ERR13 "POSIX named classes are supported only within a class"
00424 #define ERR14 "missing )"
00425 #define ERR15 "reference to non-existent subpattern"
00426 #define ERR16 "erroffset passed as NULL"
00427 #define ERR17 "unknown option bit(s) set"
00428 #define ERR18 "missing ) after comment"
00429 #define ERR19 "parentheses nested too deeply"
00430 #define ERR20 "regular expression too large"
00431 #define ERR21 "failed to get memory"
00432 #define ERR22 "unmatched parentheses"
00433 #define ERR23 "internal error: code overflow"
00434 #define ERR24 "unrecognized character after (?<"
00435 #define ERR25 "lookbehind assertion is not fixed length"
00436 #define ERR26 "malformed number after (?("
00437 #define ERR27 "conditional group contains more than two branches"
00438 #define ERR28 "assertion expected after (?("
00439 #define ERR29 "(?R or (?digits must be followed by )"
00440 #define ERR30 "unknown POSIX class name"
00441 #define ERR31 "POSIX collating elements are not supported"
00442 #define ERR32 "this version of PCRE is not compiled with PCRE_UTF8 support"
00443 #define ERR33 "spare error"
00444 #define ERR34 "character value in \\x{...} sequence is too large"
00445 #define ERR35 "invalid condition (?(0)"
00446 #define ERR36 "\\C not allowed in lookbehind assertion"
00447 #define ERR37 "PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X"
00448 #define ERR38 "number after (?C is > 255"
00449 #define ERR39 "closing ) for (?C expected"
00450 #define ERR40 "recursive call could loop indefinitely"
00451 #define ERR41 "unrecognized character after (?P"
00452 #define ERR42 "syntax error after (?P"
00453 #define ERR43 "two named groups have the same name"
00454 #define ERR44 "invalid UTF-8 string"
00455
00456
00457
00458
00459
00460
00461
00462
00463 typedef unsigned char uschar;
00464
00465
00466
00467
00468 typedef struct real_pcre {
00469 unsigned long int magic_number;
00470 size_t size;
00471 const unsigned char *tables;
00472 unsigned long int options;
00473 unsigned short int top_bracket;
00474 unsigned short int top_backref;
00475 unsigned short int first_byte;
00476 unsigned short int req_byte;
00477 unsigned short int name_entry_size;
00478 unsigned short int name_count;
00479 } real_pcre;
00480
00481
00482
00483 typedef struct pcre_study_data {
00484 size_t size;
00485 uschar options;
00486 uschar start_bits[32];
00487 } pcre_study_data;
00488
00489
00490
00491
00492 typedef struct compile_data {
00493 const uschar *lcc;
00494 const uschar *fcc;
00495 const uschar *cbits;
00496 const uschar *ctypes;
00497 const uschar *start_code;
00498 uschar *name_table;
00499 int names_found;
00500 int name_entry_size;
00501 int top_backref;
00502 unsigned int backref_map;
00503 int req_varyopt;
00504 } compile_data;
00505
00506
00507
00508
00509 typedef struct branch_chain {
00510 struct branch_chain *outer;
00511 uschar *current;
00512 } branch_chain;
00513
00514
00515
00516
00517 typedef struct recursion_info {
00518 struct recursion_info *prevrec;
00519 int group_num;
00520 const uschar *after_call;
00521 const uschar *save_start;
00522 int *offset_save;
00523 int saved_max;
00524 } recursion_info;
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537 typedef struct match_data {
00538 unsigned long int match_call_count;
00539 unsigned long int match_limit;
00540 int *offset_vector;
00541 int offset_end;
00542 int offset_max;
00543 const uschar *lcc;
00544 const uschar *ctypes;
00545 bool offset_overflow;
00546 bool notbol;
00547 bool noteol;
00548 bool utf8;
00549 bool endonly;
00550 bool notempty;
00551 const uschar *start_code;
00552 const uschar *start_subject;
00553 const uschar *end_subject;
00554 const uschar *start_match;
00555 const uschar *end_match_ptr;
00556 int end_offset_top;
00557 int capture_last;
00558 int start_offset;
00559 recursion_info *recursive;
00560 void *callout_data;
00561 } match_data;
00562
00563
00564
00565 #define ctype_space 0x01
00566 #define ctype_letter 0x02
00567 #define ctype_digit 0x04
00568 #define ctype_xdigit 0x08
00569 #define ctype_word 0x10
00570 #define ctype_meta 0x80
00571
00572
00573
00574
00575 #define cbit_space 0
00576 #define cbit_xdigit 32
00577 #define cbit_digit 64
00578 #define cbit_upper 96
00579 #define cbit_lower 128
00580 #define cbit_word 160
00581 #define cbit_graph 192
00582 #define cbit_print 224
00583 #define cbit_punct 256
00584 #define cbit_cntrl 288
00585 #define cbit_length 320
00586
00587
00588
00589
00590 #define lcc_offset 0
00591 #define fcc_offset 256
00592 #define cbits_offset 512
00593 #define ctypes_offset (cbits_offset + cbit_length)
00594 #define tables_length (ctypes_offset + 256)
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610 static unsigned char pcre_default_tables[] = {
00611
00612
00613
00614 0, 1, 2, 3, 4, 5, 6, 7,
00615 8, 9, 10, 11, 12, 13, 14, 15,
00616 16, 17, 18, 19, 20, 21, 22, 23,
00617 24, 25, 26, 27, 28, 29, 30, 31,
00618 32, 33, 34, 35, 36, 37, 38, 39,
00619 40, 41, 42, 43, 44, 45, 46, 47,
00620 48, 49, 50, 51, 52, 53, 54, 55,
00621 56, 57, 58, 59, 60, 61, 62, 63,
00622 64, 97, 98, 99,100,101,102,103,
00623 104,105,106,107,108,109,110,111,
00624 112,113,114,115,116,117,118,119,
00625 120,121,122, 91, 92, 93, 94, 95,
00626 96, 97, 98, 99,100,101,102,103,
00627 104,105,106,107,108,109,110,111,
00628 112,113,114,115,116,117,118,119,
00629 120,121,122,123,124,125,126,127,
00630 128,129,130,131,132,133,134,135,
00631 136,137,138,139,140,141,142,143,
00632 144,145,146,147,148,149,150,151,
00633 152,153,154,155,156,157,158,159,
00634 160,161,162,163,164,165,166,167,
00635 168,169,170,171,172,173,174,175,
00636 176,177,178,179,180,181,182,183,
00637 184,185,186,187,188,189,190,191,
00638 192,193,194,195,196,197,198,199,
00639 200,201,202,203,204,205,206,207,
00640 208,209,210,211,212,213,214,215,
00641 216,217,218,219,220,221,222,223,
00642 224,225,226,227,228,229,230,231,
00643 232,233,234,235,236,237,238,239,
00644 240,241,242,243,244,245,246,247,
00645 248,249,250,251,252,253,254,255,
00646
00647
00648
00649 0, 1, 2, 3, 4, 5, 6, 7,
00650 8, 9, 10, 11, 12, 13, 14, 15,
00651 16, 17, 18, 19, 20, 21, 22, 23,
00652 24, 25, 26, 27, 28, 29, 30, 31,
00653 32, 33, 34, 35, 36, 37, 38, 39,
00654 40, 41, 42, 43, 44, 45, 46, 47,
00655 48, 49, 50, 51, 52, 53, 54, 55,
00656 56, 57, 58, 59, 60, 61, 62, 63,
00657 64, 97, 98, 99,100,101,102,103,
00658 104,105,106,107,108,109,110,111,
00659 112,113,114,115,116,117,118,119,
00660 120,121,122, 91, 92, 93, 94, 95,
00661 96, 65, 66, 67, 68, 69, 70, 71,
00662 72, 73, 74, 75, 76, 77, 78, 79,
00663 80, 81, 82, 83, 84, 85, 86, 87,
00664 88, 89, 90,123,124,125,126,127,
00665 128,129,130,131,132,133,134,135,
00666 136,137,138,139,140,141,142,143,
00667 144,145,146,147,148,149,150,151,
00668 152,153,154,155,156,157,158,159,
00669 160,161,162,163,164,165,166,167,
00670 168,169,170,171,172,173,174,175,
00671 176,177,178,179,180,181,182,183,
00672 184,185,186,187,188,189,190,191,
00673 192,193,194,195,196,197,198,199,
00674 200,201,202,203,204,205,206,207,
00675 208,209,210,211,212,213,214,215,
00676 216,217,218,219,220,221,222,223,
00677 224,225,226,227,228,229,230,231,
00678 232,233,234,235,236,237,238,239,
00679 240,241,242,243,244,245,246,247,
00680 248,249,250,251,252,253,254,255,
00681
00682
00683
00684
00685
00686
00687
00688 0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00,
00689 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00690 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00691 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00692
00693 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
00694 0x7e,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,
00695 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00696 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00697
00698 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
00699 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00700 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00701 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00702
00703 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00704 0xfe,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
00705 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00706 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00707
00708 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00709 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x07,
00710 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00711 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00712
00713 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
00714 0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07,
00715 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00716 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00717
00718 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
00719 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
00720 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00721 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00722
00723 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
00724 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
00725 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00726 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00727
00728 0x00,0x00,0x00,0x00,0xfe,0xff,0x00,0xfc,
00729 0x01,0x00,0x00,0xf8,0x01,0x00,0x00,0x78,
00730 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00731 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00732
00733 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
00734 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
00735 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00736 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00748 0x00,0x01,0x01,0x00,0x01,0x01,0x00,0x00,
00749 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00750 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00751 0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
00752 0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00,
00753 0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,
00754 0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80,
00755 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12,
00756 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
00757 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
00758 0x12,0x12,0x12,0x80,0x00,0x00,0x80,0x10,
00759 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12,
00760 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
00761 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
00762 0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00,
00763 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00764 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00765 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00766 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00767 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00768 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00769 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00770 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00771 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00772 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00773 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00774 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00775 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00776 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00777 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00778 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809 int
00810 pcre_copy_substring(const char *subject, int *ovector, int stringcount,
00811 int stringnumber, char *buffer, int size)
00812 {
00813 int yield;
00814 if (stringnumber < 0 || stringnumber >= stringcount)
00815 return PCRE_ERROR_NOSUBSTRING;
00816 stringnumber *= 2;
00817 yield = ovector[stringnumber+1] - ovector[stringnumber];
00818 if (size < yield + 1) return PCRE_ERROR_NOMEMORY;
00819 memcpy(buffer, subject + ovector[stringnumber], yield);
00820 buffer[yield] = 0;
00821 return yield;
00822 }
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840 const unsigned char *
00841 pcre_maketables(void)
00842 {
00843 unsigned char *yield, *p;
00844 int i;
00845
00846 yield = static_cast<unsigned char*>(malloc(tables_length));
00847
00848 if (yield == NULL) return NULL;
00849 p = yield;
00850
00851
00852
00853 for (i = 0; i < 256; i++) *p++ = tolower(i);
00854
00855
00856
00857 for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);
00858
00859
00860
00861
00862
00863
00864 memset(p, 0, cbit_length);
00865 for (i = 0; i < 256; i++)
00866 {
00867 if (isdigit(i))
00868 {
00869 p[cbit_digit + i/8] |= 1 << (i&7);
00870 p[cbit_word + i/8] |= 1 << (i&7);
00871 }
00872 if (isupper(i))
00873 {
00874 p[cbit_upper + i/8] |= 1 << (i&7);
00875 p[cbit_word + i/8] |= 1 << (i&7);
00876 }
00877 if (islower(i))
00878 {
00879 p[cbit_lower + i/8] |= 1 << (i&7);
00880 p[cbit_word + i/8] |= 1 << (i&7);
00881 }
00882 if (i == '_') p[cbit_word + i/8] |= 1 << (i&7);
00883 if (isspace(i)) p[cbit_space + i/8] |= 1 << (i&7);
00884 if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);
00885 if (isgraph(i)) p[cbit_graph + i/8] |= 1 << (i&7);
00886 if (isprint(i)) p[cbit_print + i/8] |= 1 << (i&7);
00887 if (ispunct(i)) p[cbit_punct + i/8] |= 1 << (i&7);
00888 if (iscntrl(i)) p[cbit_cntrl + i/8] |= 1 << (i&7);
00889 }
00890 p += cbit_length;
00891
00892
00893
00894
00895
00896 for (i = 0; i < 256; i++)
00897 {
00898 int x = 0;
00899 if (i != 0x0b && isspace(i)) x += ctype_space;
00900 if (isalpha(i)) x += ctype_letter;
00901 if (isdigit(i)) x += ctype_digit;
00902 if (isxdigit(i)) x += ctype_xdigit;
00903 if (isalnum(i) || i == '_') x += ctype_word;
00904 if (strchr("*+?{^.$|()[", i) != 0) x += ctype_meta;
00905 *p++ = x;
00906 }
00907
00908 return yield;
00909 }
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930 static void
00931 set_bit(uschar *start_bits, int c, bool caseless, compile_data *cd)
00932 {
00933 start_bits[c/8] |= (1 << (c&7));
00934 if (caseless && (cd->ctypes[c] & ctype_letter) != 0)
00935 start_bits[cd->fcc[c]/8] |= (1 << (cd->fcc[c]&7));
00936 }
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958 static bool
00959 set_start_bits(const uschar *code, uschar *start_bits, bool caseless,
00960 bool utf8, compile_data *cd)
00961 {
00962 register int c;
00963
00964
00965
00966
00967
00968
00969
00970 volatile int dummy;
00971
00972 do
00973 {
00974 const uschar *tcode = code + 1 + LINK_SIZE;
00975 bool try_next = true;
00976
00977 while (try_next)
00978 {
00979
00980
00981
00982 if ((int)*tcode >= OP_BRA || *tcode == OP_ASSERT)
00983 {
00984 if (!set_start_bits(tcode, start_bits, caseless, utf8, cd))
00985 return false;
00986 try_next = false;
00987 }
00988
00989 else switch(*tcode)
00990 {
00991 default:
00992 return false;
00993
00994
00995
00996 case OP_CALLOUT:
00997 tcode += 2;
00998 break;
00999
01000
01001
01002 case OP_BRANUMBER:
01003 tcode += 3;
01004 break;
01005
01006