66 #if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
70 #if defined(SUPPORT_LIBREADLINE)
71 #include <readline/readline.h>
72 #include <readline/history.h>
74 #if defined(HAVE_EDITLINE_READLINE_H)
75 #include <editline/readline.h>
77 #include <readline/readline.h>
90 #if defined(_WIN32) || defined(WIN32)
93 #define INPUT_MODE "r"
94 #define OUTPUT_MODE "wb"
97 #define isatty _isatty
101 #define fileno _fileno
107 #define _setmode(handle, mode) setmode(handle, mode)
113 #include <sys/time.h>
114 #include <sys/resource.h>
115 #if defined NATIVE_ZOS
116 #define INPUT_MODE "r"
117 #define OUTPUT_MODE "w"
119 #define INPUT_MODE "rb"
120 #define OUTPUT_MODE "wb"
126 void vms_setsymbol(
char *,
char *,
int );
130 #define PRIV(name) name
152 #ifdef SUPPORT_PCRE16
153 void pcre16_printint(
pcre *external_re, FILE *
f,
BOOL print_lengths);
155 #ifdef SUPPORT_PCRE32
156 void pcre32_printint(
pcre *external_re, FILE *
f,
BOOL print_lengths);
163 #define PCRE_INCLUDED
175 #define PRINTABLE(c) ((c) >= 64 && (c) < 255)
177 #define PRINTABLE(c) ((c) >= 32 && (c) < 127)
180 #define PRINTOK(c) (locale_set? (((c) < 256) && isprint(c)) : PRINTABLE(c))
183 #if !defined SUPPORT_PCRE8 && !defined NOPOSIX
192 #include "pcreposix.h"
222 #define PCHARS8(lv, p, offset, len, f) \
223 lv = pchars((pcre_uint8 *)(p) + offset, len, f)
225 #define PCHARSV8(p, offset, len, f) \
226 (void)pchars((pcre_uint8 *)(p) + offset, len, f)
228 #define READ_CAPTURE_NAME8(p, cn8, cn16, cn32, re) \
229 p = read_capture_name8(p, cn8, re)
231 #define STRLEN8(p) ((int)strlen((char *)p))
233 #define SET_PCRE_CALLOUT8(callout) \
234 pcre_callout = callout
236 #define SET_PCRE_STACK_GUARD8(stack_guard) \
237 pcre_stack_guard = stack_guard
239 #define PCRE_ASSIGN_JIT_STACK8(extra, callback, userdata) \
240 pcre_assign_jit_stack(extra, callback, userdata)
242 #define PCRE_COMPILE8(re, pat, options, error, erroffset, tables) \
243 re = pcre_compile((char *)pat, options, error, erroffset, tables)
245 #define PCRE_COPY_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
246 namesptr, cbuffer, size) \
247 rc = pcre_copy_named_substring(re, (char *)bptr, offsets, count, \
248 (char *)namesptr, cbuffer, size)
250 #define PCRE_COPY_SUBSTRING8(rc, bptr, offsets, count, i, cbuffer, size) \
251 rc = pcre_copy_substring((char *)bptr, offsets, count, i, cbuffer, size)
253 #define PCRE_DFA_EXEC8(count, re, extra, bptr, len, start_offset, options, \
254 offsets, size_offsets, workspace, size_workspace) \
255 count = pcre_dfa_exec(re, extra, (char *)bptr, len, start_offset, options, \
256 offsets, size_offsets, workspace, size_workspace)
258 #define PCRE_EXEC8(count, re, extra, bptr, len, start_offset, options, \
259 offsets, size_offsets) \
260 count = pcre_exec(re, extra, (char *)bptr, len, start_offset, options, \
261 offsets, size_offsets)
263 #define PCRE_FREE_STUDY8(extra) \
264 pcre_free_study(extra)
266 #define PCRE_FREE_SUBSTRING8(substring) \
267 pcre_free_substring(substring)
269 #define PCRE_FREE_SUBSTRING_LIST8(listptr) \
270 pcre_free_substring_list(listptr)
272 #define PCRE_GET_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
273 getnamesptr, subsptr) \
274 rc = pcre_get_named_substring(re, (char *)bptr, offsets, count, \
275 (char *)getnamesptr, subsptr)
277 #define PCRE_GET_STRINGNUMBER8(n, rc, ptr) \
278 n = pcre_get_stringnumber(re, (char *)ptr)
280 #define PCRE_GET_SUBSTRING8(rc, bptr, offsets, count, i, subsptr) \
281 rc = pcre_get_substring((char *)bptr, offsets, count, i, subsptr)
283 #define PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr) \
284 rc = pcre_get_substring_list((const char *)bptr, offsets, count, listptr)
286 #define PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables) \
287 rc = pcre_pattern_to_host_byte_order(re, extra, tables)
289 #define PCRE_PRINTINT8(re, outfile, debug_lengths) \
290 pcre_printint(re, outfile, debug_lengths)
292 #define PCRE_STUDY8(extra, re, options, error) \
293 extra = pcre_study(re, options, error)
295 #define PCRE_JIT_STACK_ALLOC8(startsize, maxsize) \
296 pcre_jit_stack_alloc(startsize, maxsize)
298 #define PCRE_JIT_STACK_FREE8(stack) \
299 pcre_jit_stack_free(stack)
301 #define pcre8_maketables pcre_maketables
307 #ifdef SUPPORT_PCRE16
309 #define PCHARS16(lv, p, offset, len, f) \
310 lv = pchars16((PCRE_SPTR16)(p) + offset, len, f)
312 #define PCHARSV16(p, offset, len, f) \
313 (void)pchars16((PCRE_SPTR16)(p) + offset, len, f)
315 #define READ_CAPTURE_NAME16(p, cn8, cn16, cn32, re) \
316 p = read_capture_name16(p, cn16, re)
318 #define STRLEN16(p) ((int)strlen16((PCRE_SPTR16)p))
320 #define SET_PCRE_CALLOUT16(callout) \
321 pcre16_callout = (int (*)(pcre16_callout_block *))callout
323 #define SET_PCRE_STACK_GUARD16(stack_guard) \
324 pcre16_stack_guard = (int (*)(void))stack_guard
326 #define PCRE_ASSIGN_JIT_STACK16(extra, callback, userdata) \
327 pcre16_assign_jit_stack((pcre16_extra *)extra, \
328 (pcre16_jit_callback)callback, userdata)
330 #define PCRE_COMPILE16(re, pat, options, error, erroffset, tables) \
331 re = (pcre *)pcre16_compile((PCRE_SPTR16)pat, options, error, erroffset, \
334 #define PCRE_COPY_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
335 namesptr, cbuffer, size) \
336 rc = pcre16_copy_named_substring((pcre16 *)re, (PCRE_SPTR16)bptr, offsets, \
337 count, (PCRE_SPTR16)namesptr, (PCRE_UCHAR16 *)cbuffer, size/2)
339 #define PCRE_COPY_SUBSTRING16(rc, bptr, offsets, count, i, cbuffer, size) \
340 rc = pcre16_copy_substring((PCRE_SPTR16)bptr, offsets, count, i, \
341 (PCRE_UCHAR16 *)cbuffer, size/2)
343 #define PCRE_DFA_EXEC16(count, re, extra, bptr, len, start_offset, options, \
344 offsets, size_offsets, workspace, size_workspace) \
345 count = pcre16_dfa_exec((pcre16 *)re, (pcre16_extra *)extra, \
346 (PCRE_SPTR16)bptr, len, start_offset, options, offsets, size_offsets, \
347 workspace, size_workspace)
349 #define PCRE_EXEC16(count, re, extra, bptr, len, start_offset, options, \
350 offsets, size_offsets) \
351 count = pcre16_exec((pcre16 *)re, (pcre16_extra *)extra, (PCRE_SPTR16)bptr, \
352 len, start_offset, options, offsets, size_offsets)
354 #define PCRE_FREE_STUDY16(extra) \
355 pcre16_free_study((pcre16_extra *)extra)
357 #define PCRE_FREE_SUBSTRING16(substring) \
358 pcre16_free_substring((PCRE_SPTR16)substring)
360 #define PCRE_FREE_SUBSTRING_LIST16(listptr) \
361 pcre16_free_substring_list((PCRE_SPTR16 *)listptr)
363 #define PCRE_GET_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
364 getnamesptr, subsptr) \
365 rc = pcre16_get_named_substring((pcre16 *)re, (PCRE_SPTR16)bptr, offsets, \
366 count, (PCRE_SPTR16)getnamesptr, (PCRE_SPTR16 *)(void*)subsptr)
368 #define PCRE_GET_STRINGNUMBER16(n, rc, ptr) \
369 n = pcre16_get_stringnumber(re, (PCRE_SPTR16)ptr)
371 #define PCRE_GET_SUBSTRING16(rc, bptr, offsets, count, i, subsptr) \
372 rc = pcre16_get_substring((PCRE_SPTR16)bptr, offsets, count, i, \
373 (PCRE_SPTR16 *)(void*)subsptr)
375 #define PCRE_GET_SUBSTRING_LIST16(rc, bptr, offsets, count, listptr) \
376 rc = pcre16_get_substring_list((PCRE_SPTR16)bptr, offsets, count, \
377 (PCRE_SPTR16 **)(void*)listptr)
379 #define PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables) \
380 rc = pcre16_pattern_to_host_byte_order((pcre16 *)re, (pcre16_extra *)extra, \
383 #define PCRE_PRINTINT16(re, outfile, debug_lengths) \
384 pcre16_printint(re, outfile, debug_lengths)
386 #define PCRE_STUDY16(extra, re, options, error) \
387 extra = (pcre_extra *)pcre16_study((pcre16 *)re, options, error)
389 #define PCRE_JIT_STACK_ALLOC16(startsize, maxsize) \
390 (pcre_jit_stack *)pcre16_jit_stack_alloc(startsize, maxsize)
392 #define PCRE_JIT_STACK_FREE16(stack) \
393 pcre16_jit_stack_free((pcre16_jit_stack *)stack)
399 #ifdef SUPPORT_PCRE32
401 #define PCHARS32(lv, p, offset, len, f) \
402 lv = pchars32((PCRE_SPTR32)(p) + offset, len, use_utf, f)
404 #define PCHARSV32(p, offset, len, f) \
405 (void)pchars32((PCRE_SPTR32)(p) + offset, len, use_utf, f)
407 #define READ_CAPTURE_NAME32(p, cn8, cn16, cn32, re) \
408 p = read_capture_name32(p, cn32, re)
410 #define STRLEN32(p) ((int)strlen32((PCRE_SPTR32)p))
412 #define SET_PCRE_CALLOUT32(callout) \
413 pcre32_callout = (int (*)(pcre32_callout_block *))callout
415 #define SET_PCRE_STACK_GUARD32(stack_guard) \
416 pcre32_stack_guard = (int (*)(void))stack_guard
418 #define PCRE_ASSIGN_JIT_STACK32(extra, callback, userdata) \
419 pcre32_assign_jit_stack((pcre32_extra *)extra, \
420 (pcre32_jit_callback)callback, userdata)
422 #define PCRE_COMPILE32(re, pat, options, error, erroffset, tables) \
423 re = (pcre *)pcre32_compile((PCRE_SPTR32)pat, options, error, erroffset, \
426 #define PCRE_COPY_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \
427 namesptr, cbuffer, size) \
428 rc = pcre32_copy_named_substring((pcre32 *)re, (PCRE_SPTR32)bptr, offsets, \
429 count, (PCRE_SPTR32)namesptr, (PCRE_UCHAR32 *)cbuffer, size/4)
431 #define PCRE_COPY_SUBSTRING32(rc, bptr, offsets, count, i, cbuffer, size) \
432 rc = pcre32_copy_substring((PCRE_SPTR32)bptr, offsets, count, i, \
433 (PCRE_UCHAR32 *)cbuffer, size/4)
435 #define PCRE_DFA_EXEC32(count, re, extra, bptr, len, start_offset, options, \
436 offsets, size_offsets, workspace, size_workspace) \
437 count = pcre32_dfa_exec((pcre32 *)re, (pcre32_extra *)extra, \
438 (PCRE_SPTR32)bptr, len, start_offset, options, offsets, size_offsets, \
439 workspace, size_workspace)
441 #define PCRE_EXEC32(count, re, extra, bptr, len, start_offset, options, \
442 offsets, size_offsets) \
443 count = pcre32_exec((pcre32 *)re, (pcre32_extra *)extra, (PCRE_SPTR32)bptr, \
444 len, start_offset, options, offsets, size_offsets)
446 #define PCRE_FREE_STUDY32(extra) \
447 pcre32_free_study((pcre32_extra *)extra)
449 #define PCRE_FREE_SUBSTRING32(substring) \
450 pcre32_free_substring((PCRE_SPTR32)substring)
452 #define PCRE_FREE_SUBSTRING_LIST32(listptr) \
453 pcre32_free_substring_list((PCRE_SPTR32 *)listptr)
455 #define PCRE_GET_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \
456 getnamesptr, subsptr) \
457 rc = pcre32_get_named_substring((pcre32 *)re, (PCRE_SPTR32)bptr, offsets, \
458 count, (PCRE_SPTR32)getnamesptr, (PCRE_SPTR32 *)(void*)subsptr)
460 #define PCRE_GET_STRINGNUMBER32(n, rc, ptr) \
461 n = pcre32_get_stringnumber(re, (PCRE_SPTR32)ptr)
463 #define PCRE_GET_SUBSTRING32(rc, bptr, offsets, count, i, subsptr) \
464 rc = pcre32_get_substring((PCRE_SPTR32)bptr, offsets, count, i, \
465 (PCRE_SPTR32 *)(void*)subsptr)
467 #define PCRE_GET_SUBSTRING_LIST32(rc, bptr, offsets, count, listptr) \
468 rc = pcre32_get_substring_list((PCRE_SPTR32)bptr, offsets, count, \
469 (PCRE_SPTR32 **)(void*)listptr)
471 #define PCRE_PATTERN_TO_HOST_BYTE_ORDER32(rc, re, extra, tables) \
472 rc = pcre32_pattern_to_host_byte_order((pcre32 *)re, (pcre32_extra *)extra, \
475 #define PCRE_PRINTINT32(re, outfile, debug_lengths) \
476 pcre32_printint(re, outfile, debug_lengths)
478 #define PCRE_STUDY32(extra, re, options, error) \
479 extra = (pcre_extra *)pcre32_study((pcre32 *)re, options, error)
481 #define PCRE_JIT_STACK_ALLOC32(startsize, maxsize) \
482 (pcre_jit_stack *)pcre32_jit_stack_alloc(startsize, maxsize)
484 #define PCRE_JIT_STACK_FREE32(stack) \
485 pcre32_jit_stack_free((pcre32_jit_stack *)stack)
500 #if (defined (SUPPORT_PCRE8) + defined (SUPPORT_PCRE16) + \
501 defined (SUPPORT_PCRE32)) >= 2
503 #define CHAR_SIZE (1 << pcre_mode)
511 #if defined(SUPPORT_PCRE8) && defined(SUPPORT_PCRE16) && defined(SUPPORT_PCRE32)
513 #define PCHARS(lv, p, offset, len, f) \
514 if (pcre_mode == PCRE32_MODE) \
515 PCHARS32(lv, p, offset, len, f); \
516 else if (pcre_mode == PCRE16_MODE) \
517 PCHARS16(lv, p, offset, len, f); \
519 PCHARS8(lv, p, offset, len, f)
521 #define PCHARSV(p, offset, len, f) \
522 if (pcre_mode == PCRE32_MODE) \
523 PCHARSV32(p, offset, len, f); \
524 else if (pcre_mode == PCRE16_MODE) \
525 PCHARSV16(p, offset, len, f); \
527 PCHARSV8(p, offset, len, f)
529 #define READ_CAPTURE_NAME(p, cn8, cn16, cn32, re) \
530 if (pcre_mode == PCRE32_MODE) \
531 READ_CAPTURE_NAME32(p, cn8, cn16, cn32, re); \
532 else if (pcre_mode == PCRE16_MODE) \
533 READ_CAPTURE_NAME16(p, cn8, cn16, cn32, re); \
535 READ_CAPTURE_NAME8(p, cn8, cn16, cn32, re)
537 #define SET_PCRE_CALLOUT(callout) \
538 if (pcre_mode == PCRE32_MODE) \
539 SET_PCRE_CALLOUT32(callout); \
540 else if (pcre_mode == PCRE16_MODE) \
541 SET_PCRE_CALLOUT16(callout); \
543 SET_PCRE_CALLOUT8(callout)
545 #define SET_PCRE_STACK_GUARD(stack_guard) \
546 if (pcre_mode == PCRE32_MODE) \
547 SET_PCRE_STACK_GUARD32(stack_guard); \
548 else if (pcre_mode == PCRE16_MODE) \
549 SET_PCRE_STACK_GUARD16(stack_guard); \
551 SET_PCRE_STACK_GUARD8(stack_guard)
553 #define STRLEN(p) (pcre_mode == PCRE32_MODE ? STRLEN32(p) : pcre_mode == PCRE16_MODE ? STRLEN16(p) : STRLEN8(p))
555 #define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \
556 if (pcre_mode == PCRE32_MODE) \
557 PCRE_ASSIGN_JIT_STACK32(extra, callback, userdata); \
558 else if (pcre_mode == PCRE16_MODE) \
559 PCRE_ASSIGN_JIT_STACK16(extra, callback, userdata); \
561 PCRE_ASSIGN_JIT_STACK8(extra, callback, userdata)
563 #define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \
564 if (pcre_mode == PCRE32_MODE) \
565 PCRE_COMPILE32(re, pat, options, error, erroffset, tables); \
566 else if (pcre_mode == PCRE16_MODE) \
567 PCRE_COMPILE16(re, pat, options, error, erroffset, tables); \
569 PCRE_COMPILE8(re, pat, options, error, erroffset, tables)
571 #define PCRE_CONFIG pcre_config
573 #define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
574 namesptr, cbuffer, size) \
575 if (pcre_mode == PCRE32_MODE) \
576 PCRE_COPY_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \
577 namesptr, cbuffer, size); \
578 else if (pcre_mode == PCRE16_MODE) \
579 PCRE_COPY_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
580 namesptr, cbuffer, size); \
582 PCRE_COPY_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
583 namesptr, cbuffer, size)
585 #define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \
586 if (pcre_mode == PCRE32_MODE) \
587 PCRE_COPY_SUBSTRING32(rc, bptr, offsets, count, i, cbuffer, size); \
588 else if (pcre_mode == PCRE16_MODE) \
589 PCRE_COPY_SUBSTRING16(rc, bptr, offsets, count, i, cbuffer, size); \
591 PCRE_COPY_SUBSTRING8(rc, bptr, offsets, count, i, cbuffer, size)
593 #define PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset, options, \
594 offsets, size_offsets, workspace, size_workspace) \
595 if (pcre_mode == PCRE32_MODE) \
596 PCRE_DFA_EXEC32(count, re, extra, bptr, len, start_offset, options, \
597 offsets, size_offsets, workspace, size_workspace); \
598 else if (pcre_mode == PCRE16_MODE) \
599 PCRE_DFA_EXEC16(count, re, extra, bptr, len, start_offset, options, \
600 offsets, size_offsets, workspace, size_workspace); \
602 PCRE_DFA_EXEC8(count, re, extra, bptr, len, start_offset, options, \
603 offsets, size_offsets, workspace, size_workspace)
605 #define PCRE_EXEC(count, re, extra, bptr, len, start_offset, options, \
606 offsets, size_offsets) \
607 if (pcre_mode == PCRE32_MODE) \
608 PCRE_EXEC32(count, re, extra, bptr, len, start_offset, options, \
609 offsets, size_offsets); \
610 else if (pcre_mode == PCRE16_MODE) \
611 PCRE_EXEC16(count, re, extra, bptr, len, start_offset, options, \
612 offsets, size_offsets); \
614 PCRE_EXEC8(count, re, extra, bptr, len, start_offset, options, \
615 offsets, size_offsets)
617 #define PCRE_FREE_STUDY(extra) \
618 if (pcre_mode == PCRE32_MODE) \
619 PCRE_FREE_STUDY32(extra); \
620 else if (pcre_mode == PCRE16_MODE) \
621 PCRE_FREE_STUDY16(extra); \
623 PCRE_FREE_STUDY8(extra)
625 #define PCRE_FREE_SUBSTRING(substring) \
626 if (pcre_mode == PCRE32_MODE) \
627 PCRE_FREE_SUBSTRING32(substring); \
628 else if (pcre_mode == PCRE16_MODE) \
629 PCRE_FREE_SUBSTRING16(substring); \
631 PCRE_FREE_SUBSTRING8(substring)
633 #define PCRE_FREE_SUBSTRING_LIST(listptr) \
634 if (pcre_mode == PCRE32_MODE) \
635 PCRE_FREE_SUBSTRING_LIST32(listptr); \
636 else if (pcre_mode == PCRE16_MODE) \
637 PCRE_FREE_SUBSTRING_LIST16(listptr); \
639 PCRE_FREE_SUBSTRING_LIST8(listptr)
641 #define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
642 getnamesptr, subsptr) \
643 if (pcre_mode == PCRE32_MODE) \
644 PCRE_GET_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \
645 getnamesptr, subsptr); \
646 else if (pcre_mode == PCRE16_MODE) \
647 PCRE_GET_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
648 getnamesptr, subsptr); \
650 PCRE_GET_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
651 getnamesptr, subsptr)
653 #define PCRE_GET_STRINGNUMBER(n, rc, ptr) \
654 if (pcre_mode == PCRE32_MODE) \
655 PCRE_GET_STRINGNUMBER32(n, rc, ptr); \
656 else if (pcre_mode == PCRE16_MODE) \
657 PCRE_GET_STRINGNUMBER16(n, rc, ptr); \
659 PCRE_GET_STRINGNUMBER8(n, rc, ptr)
661 #define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \
662 if (pcre_mode == PCRE32_MODE) \
663 PCRE_GET_SUBSTRING32(rc, bptr, use_offsets, count, i, subsptr); \
664 else if (pcre_mode == PCRE16_MODE) \
665 PCRE_GET_SUBSTRING16(rc, bptr, use_offsets, count, i, subsptr); \
667 PCRE_GET_SUBSTRING8(rc, bptr, use_offsets, count, i, subsptr)
669 #define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \
670 if (pcre_mode == PCRE32_MODE) \
671 PCRE_GET_SUBSTRING_LIST32(rc, bptr, offsets, count, listptr); \
672 else if (pcre_mode == PCRE16_MODE) \
673 PCRE_GET_SUBSTRING_LIST16(rc, bptr, offsets, count, listptr); \
675 PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr)
677 #define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \
678 (pcre_mode == PCRE32_MODE ? \
679 PCRE_JIT_STACK_ALLOC32(startsize, maxsize) \
680 : pcre_mode == PCRE16_MODE ? \
681 PCRE_JIT_STACK_ALLOC16(startsize, maxsize) \
682 : PCRE_JIT_STACK_ALLOC8(startsize, maxsize))
684 #define PCRE_JIT_STACK_FREE(stack) \
685 if (pcre_mode == PCRE32_MODE) \
686 PCRE_JIT_STACK_FREE32(stack); \
687 else if (pcre_mode == PCRE16_MODE) \
688 PCRE_JIT_STACK_FREE16(stack); \
690 PCRE_JIT_STACK_FREE8(stack)
692 #define PCRE_MAKETABLES \
693 (pcre_mode == PCRE32_MODE ? pcre32_maketables() : pcre_mode == PCRE16_MODE ? pcre16_maketables() : pcre_maketables())
695 #define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \
696 if (pcre_mode == PCRE32_MODE) \
697 PCRE_PATTERN_TO_HOST_BYTE_ORDER32(rc, re, extra, tables); \
698 else if (pcre_mode == PCRE16_MODE) \
699 PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables); \
701 PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables)
703 #define PCRE_PRINTINT(re, outfile, debug_lengths) \
704 if (pcre_mode == PCRE32_MODE) \
705 PCRE_PRINTINT32(re, outfile, debug_lengths); \
706 else if (pcre_mode == PCRE16_MODE) \
707 PCRE_PRINTINT16(re, outfile, debug_lengths); \
709 PCRE_PRINTINT8(re, outfile, debug_lengths)
711 #define PCRE_STUDY(extra, re, options, error) \
712 if (pcre_mode == PCRE32_MODE) \
713 PCRE_STUDY32(extra, re, options, error); \
714 else if (pcre_mode == PCRE16_MODE) \
715 PCRE_STUDY16(extra, re, options, error); \
717 PCRE_STUDY8(extra, re, options, error)
729 #if defined(SUPPORT_PCRE32) && defined(SUPPORT_PCRE16)
735 #elif defined(SUPPORT_PCRE32) && defined(SUPPORT_PCRE8)
746 #define glue(a,b) a##b
747 #define G(a,b) glue(a,b)
752 #define PCHARS(lv, p, offset, len, f) \
753 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
754 G(PCHARS,BITONE)(lv, p, offset, len, f); \
756 G(PCHARS,BITTWO)(lv, p, offset, len, f)
758 #define PCHARSV(p, offset, len, f) \
759 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
760 G(PCHARSV,BITONE)(p, offset, len, f); \
762 G(PCHARSV,BITTWO)(p, offset, len, f)
764 #define READ_CAPTURE_NAME(p, cn8, cn16, cn32, re) \
765 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
766 G(READ_CAPTURE_NAME,BITONE)(p, cn8, cn16, cn32, re); \
768 G(READ_CAPTURE_NAME,BITTWO)(p, cn8, cn16, cn32, re)
770 #define SET_PCRE_CALLOUT(callout) \
771 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
772 G(SET_PCRE_CALLOUT,BITONE)(callout); \
774 G(SET_PCRE_CALLOUT,BITTWO)(callout)
776 #define SET_PCRE_STACK_GUARD(stack_guard) \
777 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
778 G(SET_PCRE_STACK_GUARD,BITONE)(stack_guard); \
780 G(SET_PCRE_STACK_GUARD,BITTWO)(stack_guard)
782 #define STRLEN(p) ((pcre_mode == G(G(PCRE,BITONE),_MODE)) ? \
783 G(STRLEN,BITONE)(p) : G(STRLEN,BITTWO)(p))
785 #define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \
786 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
787 G(PCRE_ASSIGN_JIT_STACK,BITONE)(extra, callback, userdata); \
789 G(PCRE_ASSIGN_JIT_STACK,BITTWO)(extra, callback, userdata)
791 #define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \
792 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
793 G(PCRE_COMPILE,BITONE)(re, pat, options, error, erroffset, tables); \
795 G(PCRE_COMPILE,BITTWO)(re, pat, options, error, erroffset, tables)
797 #define PCRE_CONFIG G(G(pcre,BITONE),_config)
799 #define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
800 namesptr, cbuffer, size) \
801 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
802 G(PCRE_COPY_NAMED_SUBSTRING,BITONE)(rc, re, bptr, offsets, count, \
803 namesptr, cbuffer, size); \
805 G(PCRE_COPY_NAMED_SUBSTRING,BITTWO)(rc, re, bptr, offsets, count, \
806 namesptr, cbuffer, size)
808 #define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \
809 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
810 G(PCRE_COPY_SUBSTRING,BITONE)(rc, bptr, offsets, count, i, cbuffer, size); \
812 G(PCRE_COPY_SUBSTRING,BITTWO)(rc, bptr, offsets, count, i, cbuffer, size)
814 #define PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset, options, \
815 offsets, size_offsets, workspace, size_workspace) \
816 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
817 G(PCRE_DFA_EXEC,BITONE)(count, re, extra, bptr, len, start_offset, options, \
818 offsets, size_offsets, workspace, size_workspace); \
820 G(PCRE_DFA_EXEC,BITTWO)(count, re, extra, bptr, len, start_offset, options, \
821 offsets, size_offsets, workspace, size_workspace)
823 #define PCRE_EXEC(count, re, extra, bptr, len, start_offset, options, \
824 offsets, size_offsets) \
825 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
826 G(PCRE_EXEC,BITONE)(count, re, extra, bptr, len, start_offset, options, \
827 offsets, size_offsets); \
829 G(PCRE_EXEC,BITTWO)(count, re, extra, bptr, len, start_offset, options, \
830 offsets, size_offsets)
832 #define PCRE_FREE_STUDY(extra) \
833 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
834 G(PCRE_FREE_STUDY,BITONE)(extra); \
836 G(PCRE_FREE_STUDY,BITTWO)(extra)
838 #define PCRE_FREE_SUBSTRING(substring) \
839 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
840 G(PCRE_FREE_SUBSTRING,BITONE)(substring); \
842 G(PCRE_FREE_SUBSTRING,BITTWO)(substring)
844 #define PCRE_FREE_SUBSTRING_LIST(listptr) \
845 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
846 G(PCRE_FREE_SUBSTRING_LIST,BITONE)(listptr); \
848 G(PCRE_FREE_SUBSTRING_LIST,BITTWO)(listptr)
850 #define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
851 getnamesptr, subsptr) \
852 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
853 G(PCRE_GET_NAMED_SUBSTRING,BITONE)(rc, re, bptr, offsets, count, \
854 getnamesptr, subsptr); \
856 G(PCRE_GET_NAMED_SUBSTRING,BITTWO)(rc, re, bptr, offsets, count, \
857 getnamesptr, subsptr)
859 #define PCRE_GET_STRINGNUMBER(n, rc, ptr) \
860 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
861 G(PCRE_GET_STRINGNUMBER,BITONE)(n, rc, ptr); \
863 G(PCRE_GET_STRINGNUMBER,BITTWO)(n, rc, ptr)
865 #define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \
866 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
867 G(PCRE_GET_SUBSTRING,BITONE)(rc, bptr, use_offsets, count, i, subsptr); \
869 G(PCRE_GET_SUBSTRING,BITTWO)(rc, bptr, use_offsets, count, i, subsptr)
871 #define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \
872 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
873 G(PCRE_GET_SUBSTRING_LIST,BITONE)(rc, bptr, offsets, count, listptr); \
875 G(PCRE_GET_SUBSTRING_LIST,BITTWO)(rc, bptr, offsets, count, listptr)
877 #define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \
878 (pcre_mode == G(G(PCRE,BITONE),_MODE)) ? \
879 G(PCRE_JIT_STACK_ALLOC,BITONE)(startsize, maxsize) \
880 : G(PCRE_JIT_STACK_ALLOC,BITTWO)(startsize, maxsize)
882 #define PCRE_JIT_STACK_FREE(stack) \
883 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
884 G(PCRE_JIT_STACK_FREE,BITONE)(stack); \
886 G(PCRE_JIT_STACK_FREE,BITTWO)(stack)
888 #define PCRE_MAKETABLES \
889 (pcre_mode == G(G(PCRE,BITONE),_MODE)) ? \
890 G(G(pcre,BITONE),_maketables)() : G(G(pcre,BITTWO),_maketables)()
892 #define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \
893 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
894 G(PCRE_PATTERN_TO_HOST_BYTE_ORDER,BITONE)(rc, re, extra, tables); \
896 G(PCRE_PATTERN_TO_HOST_BYTE_ORDER,BITTWO)(rc, re, extra, tables)
898 #define PCRE_PRINTINT(re, outfile, debug_lengths) \
899 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
900 G(PCRE_PRINTINT,BITONE)(re, outfile, debug_lengths); \
902 G(PCRE_PRINTINT,BITTWO)(re, outfile, debug_lengths)
904 #define PCRE_STUDY(extra, re, options, error) \
905 if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
906 G(PCRE_STUDY,BITONE)(extra, re, options, error); \
908 G(PCRE_STUDY,BITTWO)(extra, re, options, error)
917 #elif defined SUPPORT_PCRE8
919 #define PCHARS PCHARS8
920 #define PCHARSV PCHARSV8
921 #define READ_CAPTURE_NAME READ_CAPTURE_NAME8
922 #define SET_PCRE_CALLOUT SET_PCRE_CALLOUT8
923 #define SET_PCRE_STACK_GUARD SET_PCRE_STACK_GUARD8
924 #define STRLEN STRLEN8
925 #define PCRE_ASSIGN_JIT_STACK PCRE_ASSIGN_JIT_STACK8
926 #define PCRE_COMPILE PCRE_COMPILE8
927 #define PCRE_CONFIG pcre_config
928 #define PCRE_COPY_NAMED_SUBSTRING PCRE_COPY_NAMED_SUBSTRING8
929 #define PCRE_COPY_SUBSTRING PCRE_COPY_SUBSTRING8
930 #define PCRE_DFA_EXEC PCRE_DFA_EXEC8
931 #define PCRE_EXEC PCRE_EXEC8
932 #define PCRE_FREE_STUDY PCRE_FREE_STUDY8
933 #define PCRE_FREE_SUBSTRING PCRE_FREE_SUBSTRING8
934 #define PCRE_FREE_SUBSTRING_LIST PCRE_FREE_SUBSTRING_LIST8
935 #define PCRE_GET_NAMED_SUBSTRING PCRE_GET_NAMED_SUBSTRING8
936 #define PCRE_GET_STRINGNUMBER PCRE_GET_STRINGNUMBER8
937 #define PCRE_GET_SUBSTRING PCRE_GET_SUBSTRING8
938 #define PCRE_GET_SUBSTRING_LIST PCRE_GET_SUBSTRING_LIST8
939 #define PCRE_JIT_STACK_ALLOC PCRE_JIT_STACK_ALLOC8
940 #define PCRE_JIT_STACK_FREE PCRE_JIT_STACK_FREE8
941 #define PCRE_MAKETABLES pcre_maketables()
942 #define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER8
943 #define PCRE_PRINTINT PCRE_PRINTINT8
944 #define PCRE_STUDY PCRE_STUDY8
948 #elif defined SUPPORT_PCRE16
950 #define PCHARS PCHARS16
951 #define PCHARSV PCHARSV16
952 #define READ_CAPTURE_NAME READ_CAPTURE_NAME16
953 #define SET_PCRE_CALLOUT SET_PCRE_CALLOUT16
954 #define SET_PCRE_STACK_GUARD SET_PCRE_STACK_GUARD16
955 #define STRLEN STRLEN16
956 #define PCRE_ASSIGN_JIT_STACK PCRE_ASSIGN_JIT_STACK16
957 #define PCRE_COMPILE PCRE_COMPILE16
958 #define PCRE_CONFIG pcre16_config
959 #define PCRE_COPY_NAMED_SUBSTRING PCRE_COPY_NAMED_SUBSTRING16
960 #define PCRE_COPY_SUBSTRING PCRE_COPY_SUBSTRING16
961 #define PCRE_DFA_EXEC PCRE_DFA_EXEC16
962 #define PCRE_EXEC PCRE_EXEC16
963 #define PCRE_FREE_STUDY PCRE_FREE_STUDY16
964 #define PCRE_FREE_SUBSTRING PCRE_FREE_SUBSTRING16
965 #define PCRE_FREE_SUBSTRING_LIST PCRE_FREE_SUBSTRING_LIST16
966 #define PCRE_GET_NAMED_SUBSTRING PCRE_GET_NAMED_SUBSTRING16
967 #define PCRE_GET_STRINGNUMBER PCRE_GET_STRINGNUMBER16
968 #define PCRE_GET_SUBSTRING PCRE_GET_SUBSTRING16
969 #define PCRE_GET_SUBSTRING_LIST PCRE_GET_SUBSTRING_LIST16
970 #define PCRE_JIT_STACK_ALLOC PCRE_JIT_STACK_ALLOC16
971 #define PCRE_JIT_STACK_FREE PCRE_JIT_STACK_FREE16
972 #define PCRE_MAKETABLES pcre16_maketables()
973 #define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER16
974 #define PCRE_PRINTINT PCRE_PRINTINT16
975 #define PCRE_STUDY PCRE_STUDY16
979 #elif defined SUPPORT_PCRE32
981 #define PCHARS PCHARS32
982 #define PCHARSV PCHARSV32
983 #define READ_CAPTURE_NAME READ_CAPTURE_NAME32
984 #define SET_PCRE_CALLOUT SET_PCRE_CALLOUT32
985 #define SET_PCRE_STACK_GUARD SET_PCRE_STACK_GUARD32
986 #define STRLEN STRLEN32
987 #define PCRE_ASSIGN_JIT_STACK PCRE_ASSIGN_JIT_STACK32
988 #define PCRE_COMPILE PCRE_COMPILE32
989 #define PCRE_CONFIG pcre32_config
990 #define PCRE_COPY_NAMED_SUBSTRING PCRE_COPY_NAMED_SUBSTRING32
991 #define PCRE_COPY_SUBSTRING PCRE_COPY_SUBSTRING32
992 #define PCRE_DFA_EXEC PCRE_DFA_EXEC32
993 #define PCRE_EXEC PCRE_EXEC32
994 #define PCRE_FREE_STUDY PCRE_FREE_STUDY32
995 #define PCRE_FREE_SUBSTRING PCRE_FREE_SUBSTRING32
996 #define PCRE_FREE_SUBSTRING_LIST PCRE_FREE_SUBSTRING_LIST32
997 #define PCRE_GET_NAMED_SUBSTRING PCRE_GET_NAMED_SUBSTRING32
998 #define PCRE_GET_STRINGNUMBER PCRE_GET_STRINGNUMBER32
999 #define PCRE_GET_SUBSTRING PCRE_GET_SUBSTRING32
1000 #define PCRE_GET_SUBSTRING_LIST PCRE_GET_SUBSTRING_LIST32
1001 #define PCRE_JIT_STACK_ALLOC PCRE_JIT_STACK_ALLOC32
1002 #define PCRE_JIT_STACK_FREE PCRE_JIT_STACK_FREE32
1003 #define PCRE_MAKETABLES pcre32_maketables()
1004 #define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER32
1005 #define PCRE_PRINTINT PCRE_PRINTINT32
1006 #define PCRE_STUDY PCRE_STUDY32
1015 #ifndef CLOCKS_PER_SEC
1017 #define CLOCKS_PER_SEC CLK_TCK
1019 #define CLOCKS_PER_SEC 100
1024 #define DFA_WS_DIMENSION 1000
1029 #define LOOPREPEAT 500000
1056 #ifdef COMPILE_PCRE16
1057 #error COMPILE_PCRE16 must not be set when compiling pcretest.c
1060 #ifdef COMPILE_PCRE32
1061 #error COMPILE_PCRE32 must not be set when compiling pcretest.c
1071 #ifdef SUPPORT_PCRE16
1078 #elif LINK_SIZE == 3 || LINK_SIZE == 4
1082 #error LINK_SIZE must be either 2, 3, or 4
1085 static int buffer16_size = 0;
1086 static pcre_uint16 *buffer16 =
NULL;
1087 static const pcre_uint16 OP_lengths16[] = {
OP_LENGTHS };
1090 #ifdef SUPPORT_PCRE32
1096 static int buffer32_size = 0;
1097 static pcre_uint32 *buffer32 =
NULL;
1098 static const pcre_uint32 OP_lengths32[] = {
OP_LENGTHS };
1105 #if defined SUPPORT_PCRE8
1107 #elif defined SUPPORT_PCRE16
1109 #elif defined SUPPORT_PCRE32
1127 #define PCRE_STUDY_ALLJIT (PCRE_STUDY_JIT_COMPILE | \
1128 PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE | PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE)
1135 "NULL argument passed",
1137 "magic number missing",
1138 "unknown opcode - pattern overwritten?",
1141 "match limit exceeded",
1142 "callout error code",
1146 "not used - internal error",
1147 "internal error - pattern overwritten?",
1149 "item unsupported for DFA matching",
1150 "backreference condition or recursion test not supported for DFA matching",
1151 "match limit not supported for DFA matching",
1152 "workspace size exceeded in DFA matching",
1153 "too much recursion for DFA matching",
1154 "recursion limit exceeded",
1155 "not used - internal error",
1156 "invalid combination of newline options",
1159 "nested recursion at the same subject position",
1160 "JIT stack limit reached",
1161 "pattern compiled in wrong mode: 8-bit/16-bit error",
1162 "pattern compiled with other endianness",
1163 "invalid data in workspace for DFA restart",
1185 0, 1, 2, 3, 4, 5, 6, 7,
1186 8, 9, 10, 11, 12, 13, 14, 15,
1187 16, 17, 18, 19, 20, 21, 22, 23,
1188 24, 25, 26, 27, 28, 29, 30, 31,
1189 32, 33, 34, 35, 36, 37, 38, 39,
1190 40, 41, 42, 43, 44, 45, 46, 47,
1191 48, 49, 50, 51, 52, 53, 54, 55,
1192 56, 57, 58, 59, 60, 61, 62, 63,
1193 64, 97, 98, 99,100,101,102,103,
1194 104,105,106,107,108,109,110,111,
1195 112,113,114,115,116,117,118,119,
1196 120,121,122, 91, 92, 93, 94, 95,
1197 96, 97, 98, 99,100,101,102,103,
1198 104,105,106,107,108,109,110,111,
1199 112,113,114,115,116,117,118,119,
1200 120,121,122,123,124,125,126,127,
1201 128,129,130,131,132,133,134,135,
1202 136,137,138,139,140,141,142,143,
1203 144,145,146,147,148,149,150,151,
1204 152,153,154,155,156,157,158,159,
1205 160,161,162,163,164,165,166,167,
1206 168,169,170,171,172,173,174,175,
1207 176,177,178,179,180,181,182,183,
1208 184,185,186,187,188,189,190,191,
1209 192,193,194,195,196,197,198,199,
1210 200,201,202,203,204,205,206,207,
1211 208,209,210,211,212,213,214,215,
1212 216,217,218,219,220,221,222,223,
1213 224,225,226,227,228,229,230,231,
1214 232,233,234,235,236,237,238,239,
1215 240,241,242,243,244,245,246,247,
1216 248,249,250,251,252,253,254,255,
1220 0, 1, 2, 3, 4, 5, 6, 7,
1221 8, 9, 10, 11, 12, 13, 14, 15,
1222 16, 17, 18, 19, 20, 21, 22, 23,
1223 24, 25, 26, 27, 28, 29, 30, 31,
1224 32, 33, 34, 35, 36, 37, 38, 39,
1225 40, 41, 42, 43, 44, 45, 46, 47,
1226 48, 49, 50, 51, 52, 53, 54, 55,
1227 56, 57, 58, 59, 60, 61, 62, 63,
1228 64, 97, 98, 99,100,101,102,103,
1229 104,105,106,107,108,109,110,111,
1230 112,113,114,115,116,117,118,119,
1231 120,121,122, 91, 92, 93, 94, 95,
1232 96, 65, 66, 67, 68, 69, 70, 71,
1233 72, 73, 74, 75, 76, 77, 78, 79,
1234 80, 81, 82, 83, 84, 85, 86, 87,
1235 88, 89, 90,123,124,125,126,127,
1236 128,129,130,131,132,133,134,135,
1237 136,137,138,139,140,141,142,143,
1238 144,145,146,147,148,149,150,151,
1239 152,153,154,155,156,157,158,159,
1240 160,161,162,163,164,165,166,167,
1241 168,169,170,171,172,173,174,175,
1242 176,177,178,179,180,181,182,183,
1243 184,185,186,187,188,189,190,191,
1244 192,193,194,195,196,197,198,199,
1245 200,201,202,203,204,205,206,207,
1246 208,209,210,211,212,213,214,215,
1247 216,217,218,219,220,221,222,223,
1248 224,225,226,227,228,229,230,231,
1249 232,233,234,235,236,237,238,239,
1250 240,241,242,243,244,245,246,247,
1251 248,249,250,251,252,253,254,255,
1258 0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00,
1259 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1260 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1261 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1263 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
1264 0x7e,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,
1265 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1266 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1268 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
1269 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1270 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1271 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1273 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1274 0xfe,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
1275 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1276 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1278 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1279 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x07,
1280 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1281 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1283 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
1284 0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07,
1285 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1286 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1288 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
1289 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
1290 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1291 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1293 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
1294 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
1295 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1296 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1298 0x00,0x00,0x00,0x00,0xfe,0xff,0x00,0xfc,
1299 0x01,0x00,0x00,0xf8,0x01,0x00,0x00,0x78,
1300 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1301 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1303 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
1304 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
1305 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1306 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1317 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1318 0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
1319 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1320 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1321 0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
1322 0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00,
1323 0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,
1324 0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80,
1325 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12,
1326 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
1327 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
1328 0x12,0x12,0x12,0x80,0x80,0x00,0x80,0x10,
1329 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12,
1330 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
1331 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
1332 0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00,
1333 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1334 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1335 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1336 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1337 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1338 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1339 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1340 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1341 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1342 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1343 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1344 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1345 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1346 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1347 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1348 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
1356 8,9,10,11,12,13,14,15,
1357 16,17,18,19,20,21,22,23,
1358 24,25,26,27,28,29,30,31,
1359 32,33,34,35,36,37,38,39,
1360 40,41,42,43,44,45,46,47,
1361 48,49,50,51,52,53,54,55,
1362 56,57,58,59,60,61,62,63,
1363 64,97,98,99,100,101,102,103,
1364 104,105,106,107,108,109,110,111,
1365 112,113,114,115,116,117,118,119,
1366 120,121,122,91,92,93,94,95,
1367 96,97,98,99,100,101,102,103,
1368 104,105,106,107,108,109,110,111,
1369 112,113,114,115,116,117,118,119,
1370 120,121,122,123,124,125,126,127,
1371 128,129,130,131,132,133,134,135,
1372 136,137,138,139,140,141,142,143,
1373 144,145,146,147,148,149,150,151,
1374 152,153,154,155,156,157,158,159,
1375 160,161,162,163,164,165,166,167,
1376 168,169,170,171,172,173,174,175,
1377 176,177,178,179,180,181,182,183,
1378 184,185,186,187,188,189,190,191,
1379 224,225,226,227,228,229,230,231,
1380 232,233,234,235,236,237,238,239,
1381 240,241,242,243,244,245,246,215,
1382 248,249,250,251,252,253,254,223,
1383 224,225,226,227,228,229,230,231,
1384 232,233,234,235,236,237,238,239,
1385 240,241,242,243,244,245,246,247,
1386 248,249,250,251,252,253,254,255,
1388 8,9,10,11,12,13,14,15,
1389 16,17,18,19,20,21,22,23,
1390 24,25,26,27,28,29,30,31,
1391 32,33,34,35,36,37,38,39,
1392 40,41,42,43,44,45,46,47,
1393 48,49,50,51,52,53,54,55,
1394 56,57,58,59,60,61,62,63,
1395 64,97,98,99,100,101,102,103,
1396 104,105,106,107,108,109,110,111,
1397 112,113,114,115,116,117,118,119,
1398 120,121,122,91,92,93,94,95,
1399 96,65,66,67,68,69,70,71,
1400 72,73,74,75,76,77,78,79,
1401 80,81,82,83,84,85,86,87,
1402 88,89,90,123,124,125,126,127,
1403 128,129,130,131,132,133,134,135,
1404 136,137,138,139,140,141,142,143,
1405 144,145,146,147,148,149,150,151,
1406 152,153,154,155,156,157,158,159,
1407 160,161,162,163,164,165,166,167,
1408 168,169,170,171,172,173,174,175,
1409 176,177,178,179,180,181,182,183,
1410 184,185,186,187,188,189,190,191,
1411 224,225,226,227,228,229,230,231,
1412 232,233,234,235,236,237,238,239,
1413 240,241,242,243,244,245,246,215,
1414 248,249,250,251,252,253,254,223,
1415 192,193,194,195,196,197,198,199,
1416 200,201,202,203,204,205,206,207,
1417 208,209,210,211,212,213,214,247,
1418 216,217,218,219,220,221,222,255,
1424 126,0,0,0,126,0,0,0,
1432 254,255,255,7,0,0,0,0,
1434 255,255,127,127,0,0,0,0,
1436 0,0,0,0,254,255,255,7,
1438 0,0,0,128,255,255,127,255,
1440 254,255,255,135,254,255,255,7,
1442 255,255,127,255,255,255,127,255,
1443 0,0,0,0,254,255,255,255,
1444 255,255,255,255,255,255,255,127,
1445 0,0,0,0,254,255,255,255,
1446 255,255,255,255,255,255,255,255,
1447 0,2,0,0,255,255,255,255,
1448 255,255,255,255,255,255,255,127,
1449 0,0,0,0,255,255,255,255,
1450 255,255,255,255,255,255,255,255,
1451 0,0,0,0,254,255,0,252,
1452 1,0,0,248,1,0,0,120,
1453 0,0,0,0,254,255,255,255,
1454 0,0,128,0,0,0,128,0,
1455 255,255,255,255,0,0,0,0,
1457 255,255,255,255,0,0,0,0,
1464 128,128,128,128,0,0,128,0,
1465 28,28,28,28,28,28,28,28,
1466 28,28,0,0,0,0,0,128,
1467 0,26,26,26,26,26,26,18,
1468 18,18,18,18,18,18,18,18,
1469 18,18,18,18,18,18,18,18,
1470 18,18,18,128,128,0,128,16,
1471 0,26,26,26,26,26,26,18,
1472 18,18,18,18,18,18,18,18,
1473 18,18,18,18,18,18,18,18,
1474 18,18,18,128,128,0,0,0,
1483 18,18,18,18,18,18,18,18,
1484 18,18,18,18,18,18,18,18,
1485 18,18,18,18,18,18,18,0,
1486 18,18,18,18,18,18,18,18,
1487 18,18,18,18,18,18,18,18,
1488 18,18,18,18,18,18,18,18,
1489 18,18,18,18,18,18,18,0,
1490 18,18,18,18,18,18,18,18
1496 #ifndef HAVE_STRERROR
1511 if (n < 0 || n >=
sys_nerr)
return "unknown error number";
1532 const char *s =
NULL;
1533 if (!isc) printf(
" Newline sequence is ");
1536 case CHAR_CR: s =
"CR";
break;
1537 case CHAR_LF: s =
"LF";
break;
1539 case -1: s =
"ANY";
break;
1540 case -2: s =
"ANYCRLF";
break;
1543 printf(
"a non-standard value: 0x%04x\n", rc);
1563 #if !defined NOUTF || defined SUPPORT_PCRE16 || defined SUPPORT_PCRE32
1580 utf82ord(
pcre_uint8 *utf8bytes, pcre_uint32 *vptr)
1582 pcre_uint32 c = *utf8bytes++;
1586 for (
i = -1;
i < 6;
i++)
1588 if ((d & 0x80) == 0)
break;
1592 if (
i == -1) { *vptr = c;
return 1; }
1593 if (
i == 0 ||
i == 6)
return 0;
1600 for (j = 0; j <
i; j++)
1603 if ((c & 0xc0) != 0x80)
return -(j+1);
1605 d |= (c & 0x3f) << s;
1610 for (j = 0; j < utf8_table1_size; j++)
1611 if (d <= (pcre_uint32)utf8_table1[j])
break;
1612 if (j !=
i)
return -(
i+1);
1623 #if defined SUPPORT_PCRE8 && !defined NOUTF
1639 ord2utf8(pcre_uint32 cvalue,
pcre_uint8 *utf8bytes)
1642 if (cvalue > 0x7fffffffu)
1644 for (
i = 0;
i < utf8_table1_size;
i++)
1645 if (cvalue <= (pcre_uint32)utf8_table1[
i])
break;
1647 for (j =
i; j > 0; j--)
1649 *utf8bytes-- = 0x80 | (cvalue & 0x3f);
1652 *utf8bytes = utf8_table2[
i] | cvalue;
1658 #ifdef SUPPORT_PCRE16
1693 if (buffer16_size < 2*
len + 2)
1695 if (buffer16 !=
NULL)
free(buffer16);
1696 buffer16_size = 2*
len + 2;
1697 buffer16 = (pcre_uint16 *)
malloc(buffer16_size);
1698 if (buffer16 ==
NULL)
1700 fprintf(stderr,
"pcretest: malloc(%d) failed for buffer16\n", buffer16_size);
1709 while (
len-- > 0) *pp++ = *p++;
1717 int chlen = utf82ord(p, &c);
1718 if (chlen <= 0)
return -1;
1719 if (c > 0x10ffff)
return -2;
1722 if (c < 0x10000) *pp++ = c;
else
1724 if (!utf)
return -3;
1726 *pp++ = 0xD800 | (c >> 10);
1727 *pp++ = 0xDC00 | (c & 0x3ff);
1733 return pp - buffer16;
1737 #ifdef SUPPORT_PCRE32
1772 if (buffer32_size < 4*
len + 4)
1774 if (buffer32 !=
NULL)
free(buffer32);
1775 buffer32_size = 4*
len + 4;
1776 buffer32 = (pcre_uint32 *)
malloc(buffer32_size);
1777 if (buffer32 ==
NULL)
1779 fprintf(stderr,
"pcretest: malloc(%d) failed for buffer32\n", buffer32_size);
1788 while (
len-- > 0) *pp++ = *p++;
1796 int chlen = utf82ord(p, &c);
1797 if (chlen <= 0)
return -1;
1800 if (c > 0x10ffff)
return -2;
1801 if (!
data && (c & 0xfffff800u) == 0xd800u)
return -3;
1811 return pp - buffer32;
1827 valid_utf32(pcre_uint32 *
string,
int length)
1829 register pcre_uint32 *p;
1830 register pcre_uint32 c;
1832 for (p =
string; length-- > 0; p++)
1835 if (c > 0x10ffffu)
return FALSE;
1836 if ((c & 0xfffff800u) == 0xd800u)
return FALSE;
1886 #if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
1887 if (isatty(fileno(
f)))
1891 if (s ==
NULL)
return (here == start)?
NULL : start;
1893 if (
len > 0) add_history(s);
1894 if (
len > rlen - 1)
len = rlen - 1;
1895 memcpy(here, s,
len);
1906 if (
f == stdin) printf(
"%s", prompt);
1907 if (fgets((
char *)here, rlen,
f) ==
NULL)
1908 return (here == start)?
NULL : start;
1911 dlen = (
int)strlen((
char *)here);
1912 if (dlen > 0 && here[dlen - 1] ==
'\n')
return start;
1922 if (new_buffer ==
NULL || new_pbuffer ==
NULL)
1924 fprintf(stderr,
"pcretest: malloc(%d) failed\n", new_buffer_size);
1933 start = new_buffer + (start -
buffer);
1934 here = new_buffer + (here -
buffer);
1985 char tempbuffer[16];
1988 if (
f !=
NULL) fprintf(
f,
"%c", c);
1996 if (
f !=
NULL) fprintf(
f,
"\\x{%02x}", c);
2001 if (
f !=
NULL) fprintf(
f,
"\\x%02x", c);
2006 if (
f !=
NULL)
n = fprintf(
f,
"\\x{%02x}", c);
2007 else n = sprintf(tempbuffer,
"\\x{%02x}", c);
2009 return n >= 0 ?
n : 0;
2014 #ifdef SUPPORT_PCRE8
2022 static int pchars(
pcre_uint8 *p,
int length, FILE *
f)
2028 length = strlen((
char *)p);
2030 while (length-- > 0)
2035 int rc = utf82ord(p, &c);
2036 if (rc > 0 && rc <= length + 1)
2055 #ifdef SUPPORT_PCRE16
2063 while (*pp != 0) pp++;
2064 return (
int)(pp - p);
2070 #ifdef SUPPORT_PCRE32
2078 while (*pp != 0) pp++;
2079 return (
int)(pp - p);
2085 #ifdef SUPPORT_PCRE16
2093 static int pchars16(
PCRE_SPTR16 p,
int length, FILE *
f)
2098 length = strlen16(p);
2100 while (length-- > 0)
2102 pcre_uint32 c = *p++ & 0xffff;
2104 if (
use_utf && c >= 0xD800 && c < 0xDC00 && length > 0)
2106 int d = *p & 0xffff;
2107 if (d >= 0xDC00 && d <= 0xDFFF)
2109 c = ((c & 0x3ff) << 10) + (d & 0x3ff) + 0x10000;
2124 #ifdef SUPPORT_PCRE32
2139 length = strlen32(p);
2141 while (length-- > 0)
2143 pcre_uint32 c = *p++;
2153 #ifdef SUPPORT_PCRE8
2162 while (
isalnum(*p)) *npp++ = *p++;
2167 fprintf(
outfile,
"no parentheses with name \"");
2179 #ifdef SUPPORT_PCRE16
2189 pcre_uint16 *npp = *pp;
2190 while (
isalnum(*p)) *npp++ = *p++;
2195 fprintf(
outfile,
"no parentheses with name \"");
2206 #ifdef SUPPORT_PCRE32
2216 pcre_uint32 *npp = *pp;
2217 while (
isalnum(*p)) *npp++ = *p++;
2222 fprintf(
outfile,
"no parentheses with name \"");
2256 int i, current_position, pre_start, post_start, subject_length;
2260 fprintf(
f,
"Callout %d: last capture = %d\n",
2268 fprintf(
f,
"%2d: <unset>\n",
i/2);
2271 fprintf(
f,
"%2d: ",
i/2);
2284 if (
f !=
NULL) fprintf(
f,
"--->");
2300 if (
f !=
NULL) fprintf(
f,
"\n");
2316 for (
i = 0;
i < pre_start;
i++) fprintf(
outfile,
" ");
2321 for (
i = 0;
i < post_start - 1;
i++) fprintf(
outfile,
" ");
2325 for (
i = 0;
i < subject_length - pre_start - post_start + 4;
i++)
2337 fprintf(
outfile,
"Latest Mark: <unset>\n");
2340 fprintf(
outfile,
"Latest Mark: ");
2350 if (callout_data != 0)
2352 fprintf(
outfile,
"Callout data = %d\n", callout_data);
2353 return callout_data;
2374 fprintf(
outfile,
"malloc %3d %p\n", (
int)
size, block);
2381 fprintf(
outfile,
"free %p\n", block);
2391 fprintf(
outfile,
"stack_malloc %3d %p\n", (
int)
size, block);
2398 fprintf(
outfile,
"stack_free %p\n", block);
2426 #ifdef SUPPORT_PCRE32
2432 #ifdef SUPPORT_PCRE16
2438 #ifdef SUPPORT_PCRE8
2446 fprintf(
outfile,
"Error %d from pcre%s_fullinfo(%d)\n", rc,
2449 fprintf(
outfile,
"Running in %d-bit mode but pattern was compiled in "
2450 "%d-bit mode\n", 8 * CHAR_SIZE,
2475 return ((
value & 0x000000ff) << 24) |
2476 ((
value & 0x0000ff00) << 8) |
2477 ((
value & 0x00ff0000) >> 8) |
2500 #if defined SUPPORT_PCRE8 || defined SUPPORT_PCRE16
2505 #ifdef SUPPORT_PCRE16
2544 #ifdef SUPPORT_PCRE16
2550 while (length-- > 0)
2558 if ((ptr[-1] & 0xfc00) == 0xd800)
2636 if (utf) utf16_char =
TRUE;
2641 length = OP_lengths16[op] - 1;
2647 ptr += 32/
sizeof(pcre_uint16);
2654 length = (
int)((((
unsigned int)(ptr[0]) << 16) | (
unsigned int)(ptr[1]))
2657 length = (
int)((
unsigned int)(ptr[0]) - (1 +
LINK_SIZE + 1));
2674 ptr += 32/
sizeof(pcre_uint16);
2675 length -= 32/
sizeof(pcre_uint16);
2687 #if defined SUPPORT_PCRE32
2728 while (length-- > 0)
2746 length = OP_lengths32[op] - 1;
2752 ptr += 32/
sizeof(pcre_uint32);
2758 length = (
int)((
unsigned int)(ptr[0]) - (1 +
LINK_SIZE + 1));
2770 ptr += 32/
sizeof(pcre_uint32);
2771 length -= 32/
sizeof(pcre_uint32);
2786 #if defined SUPPORT_PCRE32
2788 regexflip_32(ere, extra);
2790 #if defined SUPPORT_PCRE8 || defined SUPPORT_PCRE16
2792 regexflip8_or_16(ere, extra);
2804 int start_offset,
int options,
int *use_offsets,
int use_size_offsets,
2805 int flag,
unsigned long int *limit,
int errnumber,
const char *msg)
2812 extra->
flags |= flag;
2818 PCRE_EXEC(count, re, extra, bptr,
len, start_offset, options,
2819 use_offsets, use_size_offsets);
2821 if (count == errnumber)
2833 fprintf(
outfile,
"Minimum %s limit = %d\n", msg, mid);
2838 mid = (
min + mid)/2;
2843 extra->
flags &= ~flag;
2907 fprintf(
f,
"Unknown %s at: <%s\n", stype, p);
2920 printf(
"Usage: pcretest [options] [<input file> [<output file>]]\n\n");
2921 printf(
"Input and output default to stdin and stdout.\n");
2922 #if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
2923 printf(
"If input is a terminal, readline() is used to read from it.\n");
2925 printf(
"This version of pcretest is not linked with readline().\n");
2927 printf(
"\nOptions:\n");
2928 #ifdef SUPPORT_PCRE16
2929 printf(
" -16 use the 16-bit library\n");
2931 #ifdef SUPPORT_PCRE32
2932 printf(
" -32 use the 32-bit library\n");
2934 printf(
" -b show compiled code\n");
2935 printf(
" -C show PCRE compile-time options and exit\n");
2936 printf(
" -C arg show a specific compile-time option and exit\n");
2937 printf(
" with its value if numeric (else 0). The arg can be:\n");
2938 printf(
" linksize internal link size [2, 3, 4]\n");
2939 printf(
" pcre8 8 bit library support enabled [0, 1]\n");
2940 printf(
" pcre16 16 bit library support enabled [0, 1]\n");
2941 printf(
" pcre32 32 bit library support enabled [0, 1]\n");
2942 printf(
" utf Unicode Transformation Format supported [0, 1]\n");
2943 printf(
" ucp Unicode Properties supported [0, 1]\n");
2944 printf(
" jit Just-in-time compiler supported [0, 1]\n");
2945 printf(
" newline Newline type [CR, LF, CRLF, ANYCRLF, ANY]\n");
2946 printf(
" bsr \\R type [ANYCRLF, ANY]\n");
2947 printf(
" -d debug: show compiled code and information (-b and -i)\n");
2949 printf(
" -dfa force DFA matching for all subjects\n");
2951 printf(
" -help show usage information\n");
2952 printf(
" -i show information about compiled patterns\n"
2953 " -M find MATCH_LIMIT minimum for each subject\n"
2954 " -m output memory used information\n"
2955 " -O set PCRE_NO_AUTO_POSSESS on each pattern\n"
2956 " -o <n> set size of offsets vector to <n>\n");
2957 #if !defined NOPOSIX
2958 printf(
" -p use POSIX interface\n");
2960 printf(
" -q quiet: do not output PCRE version number at start\n");
2961 printf(
" -S <n> set stack size to <n> megabytes\n");
2962 printf(
" -s force each pattern to be studied at basic level\n"
2963 " -s+ force each pattern to be studied, using JIT if available\n"
2964 " -s++ ditto, verifying when JIT was actually used\n"
2965 " -s+n force each pattern to be studied, using JIT if available,\n"
2966 " where 1 <= n <= 7 selects JIT options\n"
2967 " -s++n ditto, verifying when JIT was actually used\n"
2968 " -t time compilation and execution\n");
2969 printf(
" -t <n> time compilation and execution, repeating <n> times\n");
2970 printf(
" -tm time execution (matching) only\n");
2971 printf(
" -tm <n> time execution (matching) only, repeating <n> times\n");
2972 printf(
" -T same as -t, but show total times at the end\n");
2973 printf(
" -TM same as -tm, but show total time at the end\n");
2988 FILE *infile = stdin;
2992 int default_find_match_limit =
FALSE;
2993 pcre_uint32 default_options = 0;
2997 int showtotaltimes = 0;
3000 int force_study = -1;
3001 int force_study_options = 0;
3003 int size_offsets = 45;
3004 int size_offsets_max;
3005 int *offsets =
NULL;
3008 int all_use_dfa = 0;
3014 size_t dbuffer_size = 1u << 14;
3015 clock_t total_compile_time = 0;
3016 clock_t total_study_time = 0;
3017 clock_t total_match_time = 0;
3019 #if !defined NOPOSIX
3023 int *dfa_workspace =
NULL;
3034 pcre_uint32 copynames[1024];
3035 pcre_uint32 getnames[1024];
3037 #ifdef SUPPORT_PCRE32
3038 pcre_uint32 *cn32ptr;
3039 pcre_uint32 *gn32ptr;
3042 #ifdef SUPPORT_PCRE16
3043 pcre_uint16 *copynames16 = (pcre_uint16 *)copynames;
3044 pcre_uint16 *getnames16 = (pcre_uint16 *)getnames;
3045 pcre_uint16 *cn16ptr;
3046 pcre_uint16 *gn16ptr;
3049 #ifdef SUPPORT_PCRE8
3072 #if defined(_WIN32) || defined(WIN32)
3073 _setmode( _fileno( stdout ), _O_BINARY );
3079 #if defined SUPPORT_PCRE8
3081 #elif defined SUPPORT_PCRE16
3083 #elif defined SUPPORT_PCRE32
3089 while (argc > 1 && argv[op][0] ==
'-')
3092 char *arg = argv[op];
3094 if (
strcmp(arg,
"-m") == 0) showstore = 1;
3095 else if (
strcmp(arg,
"-s") == 0) force_study = 0;
3097 else if (
strncmp(arg,
"-s+", 3) == 0)
3100 if (*arg ==
'+') { arg++; verify_jit =
TRUE; }
3104 else if (*arg >=
'1' && *arg <=
'7')
3108 else if (
strcmp(arg,
"-8") == 0)
3110 #ifdef SUPPORT_PCRE8
3113 printf(
"** This version of PCRE was built without 8-bit support\n");
3117 else if (
strcmp(arg,
"-16") == 0)
3119 #ifdef SUPPORT_PCRE16
3122 printf(
"** This version of PCRE was built without 16-bit support\n");
3126 else if (
strcmp(arg,
"-32") == 0)
3128 #ifdef SUPPORT_PCRE32
3131 printf(
"** This version of PCRE was built without 32-bit support\n");
3137 else if (
strcmp(arg,
"-i") == 0) showinfo = 1;
3138 else if (
strcmp(arg,
"-d") == 0) showinfo =
debug = 1;
3139 else if (
strcmp(arg,
"-M") == 0) default_find_match_limit =
TRUE;
3142 else if (
strcmp(arg,
"-dfa") == 0) all_use_dfa = 1;
3144 else if (
strcmp(arg,
"-o") == 0 && argc > 2 &&
3151 else if (
strcmp(arg,
"-t") == 0 ||
strcmp(arg,
"-tm") == 0 ||
3155 int both = arg[2] == 0;
3156 showtotaltimes = arg[1] ==
'T';
3165 if (both) timeit = timeitm;
3167 else if (
strcmp(arg,
"-S") == 0 && argc > 2 &&
3171 #if defined(_WIN32) || defined(WIN32) || defined(__minix) || defined(NATIVE_ZOS) || defined(__VMS)
3172 printf(
"PCRE: -S not supported on this OS\n");
3177 getrlimit(RLIMIT_STACK, &rlim);
3178 rlim.rlim_cur = stack_size * 1024 * 1024;
3179 rc = setrlimit(RLIMIT_STACK, &rlim);
3182 printf(
"PCRE: setrlimit() failed with error %d\n", rc);
3189 #if !defined NOPOSIX
3190 else if (
strcmp(arg,
"-p") == 0) posix = 1;
3192 else if (
strcmp(arg,
"-C") == 0)
3195 unsigned long int lrc;
3199 if (
strcmp(argv[op + 1],
"linksize") == 0)
3206 vms_setsymbol(
"LINKSIZE",0,yield );
3209 else if (
strcmp(argv[op + 1],
"pcre8") == 0)
3211 #ifdef SUPPORT_PCRE8
3219 vms_setsymbol(
"PCRE8",0,yield );
3222 else if (
strcmp(argv[op + 1],
"pcre16") == 0)
3224 #ifdef SUPPORT_PCRE16
3232 vms_setsymbol(
"PCRE16",0,yield );
3235 else if (
strcmp(argv[op + 1],
"pcre32") == 0)
3237 #ifdef SUPPORT_PCRE32
3245 vms_setsymbol(
"PCRE32",0,yield );
3248 else if (
strcmp(argv[op + 1],
"utf") == 0)
3250 #ifdef SUPPORT_PCRE8
3254 #ifdef SUPPORT_PCRE16
3258 #ifdef SUPPORT_PCRE32
3265 vms_setsymbol(
"UTF",0,yield );
3268 else if (
strcmp(argv[op + 1],
"ucp") == 0)
3274 else if (
strcmp(argv[op + 1],
"jit") == 0)
3280 else if (
strcmp(argv[op + 1],
"newline") == 0)
3285 else if (
strcmp(argv[op + 1],
"bsr") == 0)
3288 printf(
"%s\n", rc?
"ANYCRLF" :
"ANY");
3290 else if (
strcmp(argv[op + 1],
"ebcdic") == 0)
3299 else if (
strcmp(argv[op + 1],
"ebcdic-nl") == 0)
3309 printf(
"Unknown -C option: %s\n", argv[op + 1]);
3316 printf(
"PCRE version %s\n",
version);
3317 printf(
"Compiled with\n");
3320 printf(
" EBCDIC code support: LF is 0x%02x\n",
CHAR_LF);
3326 #ifdef SUPPORT_PCRE8
3327 printf(
" 8-bit support\n");
3329 printf (
" %sUTF-8 support\n", rc ?
"" :
"No ");
3331 #ifdef SUPPORT_PCRE16
3332 printf(
" 16-bit support\n");
3334 printf (
" %sUTF-16 support\n", rc ?
"" :
"No ");
3336 #ifdef SUPPORT_PCRE32
3337 printf(
" 32-bit support\n");
3339 printf (
" %sUTF-32 support\n", rc ?
"" :
"No ");
3343 printf(
" %sUnicode properties support\n", rc?
"" :
"No ");
3349 printf(
" Just-in-time compiler support: %s\n", arch);
3352 printf(
" No just-in-time compiler support\n");
3356 printf(
" \\R matches %s\n", rc?
"CR, LF, or CRLF only" :
3357 "all Unicode newlines");
3359 printf(
" Internal link size = %d\n", rc);
3361 printf(
" POSIX malloc threshold = %d\n", rc);
3363 printf(
" Parentheses nest limit = %ld\n", lrc);
3365 printf(
" Default match limit = %ld\n", lrc);
3367 printf(
" Default recursion depth limit = %ld\n", lrc);
3369 printf(
" Match recursion uses %s", rc?
"stack" :
"heap");
3373 printf(
": %sframe size = %d bytes", rc?
"approximate " :
"", -stack_size);
3378 else if (
strcmp(arg,
"-help") == 0 ||
3379 strcmp(arg,
"--help") == 0)
3387 printf(
"** Unknown or malformed option %s\n", arg);
3398 size_offsets_max = size_offsets;
3399 offsets = (
int *)
malloc(size_offsets_max *
sizeof(
int));
3400 if (offsets ==
NULL)
3402 printf(
"** Failed to get %d bytes of memory for offsets vector\n",
3403 (
int)(size_offsets_max *
sizeof(
int)));
3415 printf(
"** Failed to open %s\n", argv[op]);
3426 printf(
"** Failed to open %s\n", argv[op+1]);
3434 #ifdef SUPPORT_PCRE8
3441 #ifdef SUPPORT_PCRE16
3448 #ifdef SUPPORT_PCRE32
3466 #if !defined NOPOSIX
3476 unsigned long int get_options;
3477 unsigned long int true_size, true_study_size = 0;
3482 int no_force_study = 0;
3483 int do_debug =
debug;
3486 int do_showinfo = showinfo;
3487 int do_showrest = 0;
3488 int do_showcaprest = 0;
3493 int dfa_matched = 0;
3498 SET_PCRE_STACK_GUARD(
NULL);
3501 if (infile != stdin) fprintf(
outfile,
"%s", (
char *)
buffer);
3506 if (*p == 0)
continue;
3510 if (*p ==
'<' && p[1] ==
' ')
3514 if (
strncmp((
char *)p,
"forbid ", 7) == 0)
3519 while (!
isspace(*p) && pp < lockout +
sizeof(lockout) - 1)
3525 printf(
"** Unrecognized special command '%s'\n", p);
3534 if (*p ==
'<' && strchr((
char *)(p+1),
'<') ==
NULL)
3548 pp = p + (
int)strlen((
char *)p);
3552 f = fopen((
char *)p,
"rb");
3558 if (fread(sbuf, 1, 8,
f) != 8)
goto FAIL_READ;
3561 (sbuf[0] << 24) | (sbuf[1] << 16) | (sbuf[2] << 8) | sbuf[3];
3563 (sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7];
3568 printf(
"** Failed to get %d bytes of memory for pcre object\n",
3573 if (fread(re, 1, true_size,
f) != true_size)
goto FAIL_READ;
3584 fprintf(
outfile,
"Data in %s is not a compiled PCRE regex\n", p);
3592 fprintf(
outfile,
"Compiled pattern%s loaded from %s\n",
3593 do_flip && (p[-1] ==
'<') ?
" (byte-inverted)" :
"", p);
3597 if (true_study_size != 0)
3607 if (fread(psd, 1, true_study_size,
f) != true_study_size)
3610 fprintf(
outfile,
"Failed to read data from %s\n", p);
3613 PCRE_FREE_STUDY(extra);
3619 fprintf(
outfile,
"Study data loaded from %s\n", p);
3622 else fprintf(
outfile,
"No study data\n");
3628 PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra,
NULL);
3631 pcre_uint32 flags_in_host_byte_order;
3637 fprintf(
outfile,
"Error %d from pcre%s_fullinfo(%d)\n", rc,
3640 fprintf(
outfile,
"Running in %d-bit mode but pattern was compiled in "
3641 "%d-bit mode\n", 8 * CHAR_SIZE, 8 * (flags_in_host_byte_order &
PCRE_MODE_MASK));
3669 fprintf(
outfile,
"** Delimiter must not be alphanumeric or \\\n");
3680 if (*pp ==
'\\' && pp[1] != 0) pp++;
3684 if (*pp != 0)
break;
3687 fprintf(
outfile,
"** Unexpected EOF\n");
3691 if (infile != stdin) fprintf(
outfile,
"%s", (
char *)pp);
3703 if (pp[1] ==
'\\') *pp++ =
'\\';
3709 strcpy((
char *)
pbuffer, (
char *)p);
3713 options = default_options;
3724 if (strchr((
char *)lockout, *pp) !=
NULL)
3726 if (*pp ==
'<' && strchr((
char *)lockout,
'>') !=
NULL)
3729 if (x == 0)
goto SKIP_DATA;
3731 for (ppp = lockout; *ppp != 0; ppp++)
3738 printf(
"** Error in modifier forbid data - giving up.\n");
3745 while (*ppp !=
'>') ppp++;
3746 printf(
"** The %.*s modifier is locked out - giving up.\n",
3747 (
int)(ppp - pp + 1), pp);
3759 printf(
"** The /%c modifier is locked out - giving up.\n", *pp);
3770 case 'g': do_g = 1;
break;
3777 if (do_showrest) do_showcaprest = 1;
else do_showrest = 1;
3780 case '=': do_allcaps = 1;
break;
3782 case 'B': do_debug = 1;
break;
3784 case 'D': do_debug = do_showinfo = 1;
break;
3786 case 'F': do_flip = 1;
break;
3787 case 'G': do_G = 1;
break;
3788 case 'I': do_showinfo = 1;
break;
3790 case 'K': do_mark = 1;
break;
3795 #if !defined NOPOSIX
3796 case 'P': do_posix = 1;
break;
3808 fprintf(
outfile,
"** Missing 0 or 1 after /Q\n");
3835 if (*pp >=
'1' && *pp <=
'7')
3854 case 'W': options |=
PCRE_UCP;
break;
3872 fprintf(
outfile,
"** Missing table number after /T\n");
3876 fprintf(
outfile,
"** Bad table number \"%c\" after /T\n", pp[-1]);
3885 while (*ppp != 0 && *ppp !=
'\n' && *ppp !=
'\r' && *ppp !=
' ') ppp++;
3887 if (setlocale(LC_CTYPE, (
const char *)pp) ==
NULL)
3889 fprintf(
outfile,
"** Failed to set locale \"%s\"\n", pp);
3893 tables = PCRE_MAKETABLES;
3899 while (*pp != 0) pp++;
3907 if (x == 0)
goto SKIP_DATA;
3909 while (*pp++ !=
'>');
3919 fprintf(
outfile,
"** Unknown modifier '%c'\n", pp[-1]);
3928 #if !defined NOPOSIX
3929 if (posix || do_posix)
3942 rc =
regcomp(&preg, (
char *)p, cflags);
3950 fprintf(
outfile,
"Failed: POSIX code %d: %s\n", rc,
buffer);
3963 #ifdef SUPPORT_PCRE16
3966 switch(to16(
FALSE, p, options &
PCRE_UTF8, (
int)strlen((
char *)p)))
3969 fprintf(
outfile,
"**Failed: invalid UTF-8 string cannot be "
3970 "converted to UTF-16\n");
3974 fprintf(
outfile,
"**Failed: character value greater than 0x10ffff "
3975 "cannot be converted to UTF-16\n");
3979 fprintf(
outfile,
"**Failed: character value greater than 0xffff "
3980 "cannot be converted to 16-bit in non-UTF mode\n");
3990 #ifdef SUPPORT_PCRE32
3996 fprintf(
outfile,
"**Failed: invalid UTF-8 string cannot be "
3997 "converted to UTF-32\n");
4001 fprintf(
outfile,
"**Failed: character value greater than 0x10ffff "
4002 "cannot be converted to UTF-32\n");
4006 fprintf(
outfile,
"**Failed: character value is ill-formed UTF-32\n");
4023 for (
i = 0;
i < timeit;
i++)
4025 PCRE_COMPILE(re, p, options, &
error, &erroroffset,
tables);
4028 total_compile_time += (time_taken = clock() -
start_time);
4029 fprintf(
outfile,
"Compile time %.4f milliseconds\n",
4030 (((
double)time_taken * 1000.0) / (
double)timeit) /
4034 PCRE_COMPILE(re, p, options, &
error, &erroroffset,
tables);
4041 fprintf(
outfile,
"Failed: %s at offset %d\n",
error, erroroffset);
4043 if (infile != stdin)
4054 if (
len == 0)
break;
4078 int name_count, name_entry_size, real_pcre_size;
4083 #ifdef SUPPORT_PCRE8
4087 #ifdef SUPPORT_PCRE16
4091 #ifdef SUPPORT_PCRE32
4096 fprintf(
outfile,
"Memory allocation (code space): %d\n",
4097 (
int)(
size - real_pcre_size - name_count * name_entry_size));
4105 if (do_study || (force_study >= 0 && !no_force_study))
4112 for (
i = 0;
i < timeit;
i++)
4116 total_study_time = (time_taken = clock() -
start_time);
4119 PCRE_FREE_STUDY(extra);
4121 fprintf(
outfile,
" Study time %.4f milliseconds\n",
4122 (((
double)time_taken * 1000.0) / (
double)timeit) /
4128 else if (extra !=
NULL)
4136 fprintf(
outfile,
"Memory allocation (JIT code): %d\n", (
int)jitsize);
4150 extra->
mark = &markptr;
4160 fprintf(
outfile,
"------------------------------------------------------------------\n");
4168 unsigned long int all_options;
4169 pcre_uint32 first_char, need_char;
4171 int count, backrefmax, first_char_set, need_char_set, okpartial, jchanged,
4172 hascrorlf, maxlookbehind, match_empty;
4173 int nameentrysize, namecount;
4193 fprintf(
outfile,
"Capturing subpattern count = %d\n", count);
4196 fprintf(
outfile,
"Max back reference = %d\n", backrefmax);
4198 if (maxlookbehind > 0)
4199 fprintf(
outfile,
"Max lookbehind = %d\n", maxlookbehind);
4205 fprintf(
outfile,
"Recursion limit = %u\n", recursion_limit);
4209 fprintf(
outfile,
"Named capturing subpatterns:\n");
4210 while (namecount-- > 0)
4212 int imm2_size = pcre_mode ==
PCRE8_MODE ? 2 : 1;
4213 int length = (
int)STRLEN(nametable + imm2_size);
4215 PCHARSV(nametable, imm2_size, length,
outfile);
4216 while (length++ < nameentrysize - imm2_size) putc(
' ',
outfile);
4217 #ifdef SUPPORT_PCRE32
4221 #ifdef SUPPORT_PCRE16
4225 #ifdef SUPPORT_PCRE8
4227 fprintf(
outfile,
"%3d\n", ((
int)nametable[0] << 8) | (
int)nametable[1]);
4229 nametable += nameentrysize * CHAR_SIZE;
4233 if (!okpartial) fprintf(
outfile,
"Partial matching not supported\n");
4234 if (hascrorlf) fprintf(
outfile,
"Contains explicit CR or LF match\n");
4235 if (match_empty) fprintf(
outfile,
"May match empty string\n");
4238 if (do_flip) all_options =
swap_uint32(all_options);
4240 if (get_options == 0) fprintf(
outfile,
"No options\n");
4241 else fprintf(
outfile,
"Options:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
4247 ((get_options &
PCRE_DOTALL) != 0)?
" dotall" :
"",
4251 ((get_options &
PCRE_EXTRA) != 0)?
" extra" :
"",
4255 ((get_options &
PCRE_UTF8) != 0)?
" utf" :
"",
4256 ((get_options &
PCRE_UCP) != 0)?
" ucp" :
"",
4262 if (jchanged) fprintf(
outfile,
"Duplicate name status changes\n");
4267 fprintf(
outfile,
"Forced newline sequence: CR\n");
4271 fprintf(
outfile,
"Forced newline sequence: LF\n");
4275 fprintf(
outfile,
"Forced newline sequence: CRLF\n");
4279 fprintf(
outfile,
"Forced newline sequence: ANYCRLF\n");
4283 fprintf(
outfile,
"Forced newline sequence: ANY\n");
4290 if (first_char_set == 2)
4292 fprintf(
outfile,
"First char at start or follows newline\n");
4294 else if (first_char_set == 1)
4296 const char *caseless =
4301 fprintf(
outfile,
"First char = \'%c\'%s\n", first_char, caseless);
4304 fprintf(
outfile,
"First char = ");
4306 fprintf(
outfile,
"%s\n", caseless);
4311 fprintf(
outfile,
"No first char\n");
4314 if (need_char_set == 0)
4316 fprintf(
outfile,
"No need char\n");
4320 const char *caseless =
4325 fprintf(
outfile,
"Need char = \'%c\'%s\n", need_char, caseless);
4328 fprintf(
outfile,
"Need char = ");
4330 fprintf(
outfile,
"%s\n", caseless);
4342 if (do_study || (force_study >= 0 && showinfo && !no_force_study))
4345 fprintf(
outfile,
"Study returned NULL\n");
4352 fprintf(
outfile,
"Subject length lower bound = %d\n", minlength);
4356 if (start_bits ==
NULL)
4357 fprintf(
outfile,
"No starting char list\n");
4362 fprintf(
outfile,
"Starting chars: ");
4363 for (
i = 0;
i < 256;
i++)
4365 if ((start_bits[
i/8] & (1<<(
i&7))) != 0)
4398 fprintf(
outfile,
"JIT study was successful\n");
4401 fprintf(
outfile,
"JIT study was not successful\n");
4403 fprintf(
outfile,
"JIT support is not available in this version of PCRE\n");
4414 if (to_file !=
NULL)
4416 FILE *
f = fopen((
char *)to_file,
"wb");
4419 fprintf(
outfile,
"Unable to open %s: %s\n", to_file,
strerror(errno));
4426 sbuf[0] = (
pcre_uint8)((true_size >> 24) & 255);
4427 sbuf[1] = (
pcre_uint8)((true_size >> 16) & 255);
4428 sbuf[2] = (
pcre_uint8)((true_size >> 8) & 255);
4430 sbuf[4] = (
pcre_uint8)((true_study_size >> 24) & 255);
4431 sbuf[5] = (
pcre_uint8)((true_study_size >> 16) & 255);
4432 sbuf[6] = (
pcre_uint8)((true_study_size >> 8) & 255);
4433 sbuf[7] = (
pcre_uint8)((true_study_size) & 255);
4435 if (fwrite(sbuf, 1, 8,
f) < 8 ||
4436 fwrite(re, 1, true_size,
f) < true_size)
4438 fprintf(
outfile,
"Write error on %s: %s\n", to_file,
strerror(errno));
4442 fprintf(
outfile,
"Compiled pattern written to %s\n", to_file);
4448 if (fwrite(extra->
study_data, 1, true_study_size,
f) <
4451 fprintf(
outfile,
"Write error on %s: %s\n", to_file,
4454 else fprintf(
outfile,
"Study data written to %s\n", to_file);
4463 PCRE_FREE_STUDY(extra);
4468 setlocale(LC_CTYPE,
"C");
4479 #ifdef SUPPORT_PCRE8
4482 #ifdef SUPPORT_PCRE16
4485 #ifdef SUPPORT_PCRE32
4489 int *use_offsets = offsets;
4490 int use_size_offsets = size_offsets;
4491 int callout_data = 0;
4492 int callout_data_set = 0;
4495 int copystrings = 0;
4496 int find_match_limit = default_find_match_limit;
4500 int start_offset = 0;
4501 int start_offset_sign = 1;
4508 #ifdef SUPPORT_PCRE32
4509 cn32ptr = copynames;
4512 #ifdef SUPPORT_PCRE16
4513 cn16ptr = copynames16;
4514 gn16ptr = getnames16;
4516 #ifdef SUPPORT_PCRE8
4517 cn8ptr = copynames8;
4547 if (infile != stdin) fprintf(
outfile,
"%s", (
char *)
buffer);
4554 if (
len == 0)
break;
4569 for (q = p;
n > 0 && *q; q +=
n)
n = utf82ord(q, &cc);
4572 fprintf(
outfile,
"**Failed: invalid UTF-8 string cannot be used as input in UTF mode\n");
4578 #ifdef SUPPORT_VALGRIND
4581 if (dbuffer !=
NULL)
4583 VALGRIND_MAKE_MEM_UNDEFINED(dbuffer, dbuffer_size * CHAR_SIZE);
4590 while (dbuffer ==
NULL || (
size_t)
len >= dbuffer_size)
4593 dbuffer = (
pcre_uint8 *)realloc(dbuffer, dbuffer_size * CHAR_SIZE);
4594 if (dbuffer ==
NULL)
4596 fprintf(stderr,
"pcretest: realloc(%d) failed\n", (
int)dbuffer_size);
4601 #ifdef SUPPORT_PCRE8
4604 #ifdef SUPPORT_PCRE16
4605 q16 = (pcre_uint16 *) dbuffer;
4607 #ifdef SUPPORT_PCRE32
4608 q32 = (pcre_uint32 *) dbuffer;
4611 while ((c = *p++) != 0)
4624 if (
use_utf && HASUTF8EXTRALEN(c)) { GETUTF8INC(c, p); }
4630 else switch ((c = *p++))
4633 case 'b': c =
'\b';
break;
4635 case 'f': c =
'\f';
break;
4636 case 'n': c =
'\n';
break;
4637 case 'r': c =
'\r';
break;
4638 case 't': c =
'\t';
break;
4639 case 'v': c =
'\v';
break;
4641 case '0':
case '1':
case '2':
case '3':
4642 case '4':
case '5':
case '6':
case '7':
4644 while (
i++ < 2 &&
isdigit(*p) && *p !=
'8' && *p !=
'9')
4645 c = c * 8 + *p++ -
'0';
4653 for (pt++;
isdigit(*pt) && *pt !=
'8' && *pt !=
'9'; pt++)
4656 fprintf(
outfile,
"** Too many octal digits in \\o{...} item; "
4657 "using only the first twelve.\n");
4658 else c = c * 8 + *pt -
'0';
4660 if (*pt ==
'}') p = pt + 1;
4661 else fprintf(
outfile,
"** Missing } after \\o{ (assumed)\n");
4679 fprintf(
outfile,
"** Too many hex digits in \\x{...} item; "
4680 "using only the first eight.\n");
4681 else c = c * 16 +
tolower(*pt) - ((
isdigit(*pt))?
'0' :
'a' - 10);
4703 #if !defined NOUTF && defined SUPPORT_PCRE8
4719 start_offset_sign = -1;
4722 while(
isdigit(*p)) start_offset = start_offset * 10 + *p++ -
'0';
4723 start_offset *= start_offset_sign;
4737 while(
isdigit(*p))
n =
n * 10 + *p++ -
'0';
4738 copystrings |= 1 <<
n;
4742 READ_CAPTURE_NAME(p, &cn8ptr, &cn16ptr, &cn32ptr, re);
4751 SET_PCRE_CALLOUT(
NULL);
4772 if (*(++p) ==
'-') { sign = -1; p++; }
4774 callout_data = callout_data * 10 + *p++ -
'0';
4775 callout_data *= sign;
4776 callout_data_set = 1;
4782 #if !defined NOPOSIX
4783 if (posix || do_posix)
4784 printf(
"** Can't use dfa matching in POSIX mode: \\D ignored\n");
4800 while(
isdigit(*p))
n =
n * 10 + *p++ -
'0';
4801 getstrings |= 1 <<
n;
4805 READ_CAPTURE_NAME(p, &gn8ptr, &gn16ptr, &gn32ptr, re);
4810 while(
isdigit(*p))
n =
n * 10 + *p++ -
'0';
4815 if (jit_stack !=
NULL) { PCRE_JIT_STACK_FREE(jit_stack); }
4816 jit_stack = PCRE_JIT_STACK_ALLOC(1,
n * 1024);
4826 find_match_limit = 1;
4839 if (
n > (INT_MAX-10)/10)
4841 printf(
"** \\O argument is too big\n");
4845 n =
n * 10 + *p++ -
'0';
4847 if (
n > size_offsets_max)
4849 size_offsets_max =
n;
4851 use_offsets = offsets = (
int *)
malloc(size_offsets_max *
sizeof(
int));
4852 if (offsets ==
NULL)
4854 printf(
"** Failed to get %d bytes of memory for offsets vector\n",
4855 (
int)(size_offsets_max *
sizeof(
int)));
4860 use_size_offsets =
n;
4861 if (
n == 0) use_offsets =
NULL;
4862 else use_offsets = offsets + size_offsets_max -
n;
4871 while(
isdigit(*p))
n =
n * 10 + *p++ -
'0';
4882 while(
isdigit(*p))
n =
n * 10 + *p++ -
'0';
4917 if (x == 0)
goto NEXT_DATA;
4919 while (*p++ !=
'>');
4929 #ifdef SUPPORT_PCRE8
4937 fprintf(
outfile,
"** Character \\x{%x} is greater than 0x7fffffff "
4938 "and so cannot be converted to UTF-8\n", c);
4941 q8 += ord2utf8(c, q8);
4948 fprintf(
outfile,
"** Character \\x{%x} is greater than 255 "
4949 "and UTF-8 mode is not enabled.\n", c);
4950 fprintf(
outfile,
"** Truncation will probably give the wrong "
4957 #ifdef SUPPORT_PCRE16
4965 fprintf(
outfile,
"** Failed: character \\x{%x} is greater than "
4966 "0x10ffff and so cannot be converted to UTF-16\n", c);
4969 else if (c >= 0x10000u)
4972 *q16++ = 0xD800 | (c >> 10);
4973 *q16++ = 0xDC00 | (c & 0x3ff);
4983 fprintf(
outfile,
"** Character \\x{%x} is greater than 0xffff "
4984 "and UTF-16 mode is not enabled.\n", c);
4985 fprintf(
outfile,
"** Truncation will probably give the wrong "
4993 #ifdef SUPPORT_PCRE32
5004 #ifdef SUPPORT_PCRE8
5011 #ifdef SUPPORT_PCRE16
5015 len = (
int)(q16 - (pcre_uint16 *)dbuffer);
5018 #ifdef SUPPORT_PCRE32
5022 len = (
int)(q32 - (pcre_uint32 *)dbuffer);
5035 #if !defined NOPOSIX
5036 if (posix || do_posix)
5038 #ifdef SUPPORT_VALGRIND
5039 VALGRIND_MAKE_MEM_NOACCESS(dbuffer +
len + 1, dbuffer_size - (
len + 1));
5042 bptr += dbuffer_size -
len - 1;
5048 #ifdef SUPPORT_VALGRIND
5049 VALGRIND_MAKE_MEM_NOACCESS(dbuffer +
len * CHAR_SIZE, (dbuffer_size -
len) * CHAR_SIZE);
5051 bptr =
memmove(bptr + (dbuffer_size -
len) * CHAR_SIZE, bptr,
len * CHAR_SIZE);
5055 if ((all_use_dfa || use_dfa) && find_match_limit)
5057 printf(
"** Match limit not relevant for DFA matching: ignored\n");
5058 find_match_limit = 0;
5064 #if !defined NOPOSIX
5065 if (posix || do_posix)
5070 if (use_size_offsets > 0)
5076 rc =
regexec(&preg, (
const char *)bptr, use_size_offsets, pmatch, eflags);
5081 fprintf(
outfile,
"No match: POSIX code %d: %s\n", rc,
buffer);
5085 fprintf(
outfile,
"Matched with REG_NOSUB\n");
5090 for (
i = 0;
i < (size_t)use_size_offsets;
i++)
5092 if (pmatch[
i].rm_so >= 0)
5095 PCHARSV(dbuffer, pmatch[
i].rm_so,
5096 pmatch[
i].rm_eo - pmatch[
i].rm_so,
outfile);
5098 if (do_showcaprest || (
i == 0 && do_showrest))
5101 PCHARSV(dbuffer, pmatch[
i].rm_eo,
len - pmatch[
i].rm_eo,
5119 if (verify_jit && jit_stack ==
NULL && extra !=
NULL)
5120 { PCRE_ASSIGN_JIT_STACK(extra,
jit_callback, jit_stack); }
5134 if (all_use_dfa || use_dfa)
5138 fprintf(
outfile,
"Timing DFA restarts is not supported\n");
5141 if (dfa_workspace ==
NULL)
5143 for (
i = 0;
i < timeitm;
i++)
5145 PCRE_DFA_EXEC(count, re, extra, bptr,
len, start_offset,
5146 (options | g_notempty), use_offsets, use_size_offsets,
5153 for (
i = 0;
i < timeitm;
i++)
5155 PCRE_EXEC(count, re, extra, bptr,
len, start_offset,
5156 (options | g_notempty), use_offsets, use_size_offsets);
5158 total_match_time += (time_taken = clock() -
start_time);
5159 fprintf(
outfile,
"Execute time %.4f milliseconds\n",
5160 (((
double)time_taken * 1000.0) / (
double)timeitm) /
5171 if (find_match_limit)
5173 if (extra !=
NULL) { PCRE_FREE_STUDY(extra); }
5178 options|g_notempty, use_offsets, use_size_offsets,
5183 options|g_notempty, use_offsets, use_size_offsets,
5190 else if (callout_data_set)
5199 PCRE_EXEC(count, re, extra, bptr,
len, start_offset,
5200 options | g_notempty, use_offsets, use_size_offsets);
5208 else if (all_use_dfa || use_dfa)
5210 if (dfa_workspace ==
NULL)
5212 if (dfa_matched++ == 0)
5213 dfa_workspace[0] = -1;
5214 PCRE_DFA_EXEC(count, re, extra, bptr,
len, start_offset,
5215 (options | g_notempty), use_offsets, use_size_offsets, dfa_workspace,
5219 fprintf(
outfile,
"Matched, but offsets vector is too small to show all matches\n");
5220 count = use_size_offsets/2;
5227 PCRE_EXEC(count, re, extra, bptr,
len, start_offset,
5228 options | g_notempty, use_offsets, use_size_offsets);
5231 fprintf(
outfile,
"Matched, but too many substrings\n");
5233 count = (use_size_offsets == 2)? 1 : use_size_offsets/3;
5242 void *cnptr, *gnptr;
5245 if (all_use_dfa || use_dfa) maxcount = use_size_offsets/2;
else
5248 maxcount = (use_size_offsets == 2)? 1 : use_size_offsets/3;
5252 if (count > maxcount)
5255 "** PCRE error: returned count %d is too big for offset size %d\n",
5256 count, use_size_offsets);
5257 count = use_size_offsets/3;
5260 fprintf(
outfile,
"** /%c loop abandoned\n", do_g?
'g' :
'G');
5261 do_g = do_G =
FALSE;
5270 if (all_use_dfa || use_dfa)
5272 fprintf(
outfile,
"** Show all captures ignored after DFA matching\n");
5279 if (count * 2 > use_size_offsets) count = use_size_offsets/2;
5286 for (
i = 0;
i < count * 2;
i += 2)
5288 if (use_offsets[
i] < 0)
5290 if (use_offsets[
i] != -1)
5291 fprintf(
outfile,
"ERROR: bad negative value %d for offset %d\n",
5293 if (use_offsets[
i+1] != -1)
5294 fprintf(
outfile,
"ERROR: bad negative value %d for offset %d\n",
5295 use_offsets[
i+1],
i+1);
5296 fprintf(
outfile,
"%2d: <unset>\n",
i/2);
5300 int start = use_offsets[
i];
5301 int end = use_offsets[
i+1];
5305 start = use_offsets[
i+1];
5306 end = use_offsets[
i];
5307 fprintf(
outfile,
"Start of matched string is beyond its end - "
5308 "displaying from end to start.\n");
5312 PCHARSV(bptr, start, end - start,
outfile);
5319 if (do_showcaprest || (
i == 0 && do_showrest))
5322 PCHARSV(bptr, use_offsets[
i+1],
len - use_offsets[
i+1],
5329 if (markptr !=
NULL)
5332 PCHARSV(markptr, 0, -1,
outfile);
5336 for (
i = 0;
i < 32;
i++)
5338 if ((copystrings & (1 <<
i)) != 0)
5341 char copybuffer[256];
5342 PCRE_COPY_SUBSTRING(rc, bptr, use_offsets, count,
i,
5343 copybuffer,
sizeof(copybuffer));
5345 fprintf(
outfile,
"copy substring %d failed %d\n",
i, rc);
5349 PCHARSV(copybuffer, 0, rc,
outfile);
5350 fprintf(
outfile,
" (%d)\n", rc);
5359 char copybuffer[256];
5361 #ifdef SUPPORT_PCRE32
5364 if (*(pcre_uint32 *)cnptr == 0)
break;
5367 #ifdef SUPPORT_PCRE16
5370 if (*(pcre_uint16 *)cnptr == 0)
break;
5373 #ifdef SUPPORT_PCRE8
5380 PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, use_offsets, count,
5381 cnptr, copybuffer,
sizeof(copybuffer));
5385 fprintf(
outfile,
"copy substring ");
5386 PCHARSV(cnptr, 0, -1,
outfile);
5387 fprintf(
outfile,
" failed %d\n", rc);
5392 PCHARSV(copybuffer, 0, rc,
outfile);
5393 fprintf(
outfile,
" (%d) ", rc);
5394 PCHARSV(cnptr, 0, -1,
outfile);
5398 cnptr = (
char *)cnptr + (STRLEN(cnptr) + 1) * CHAR_SIZE;
5401 for (
i = 0;
i < 32;
i++)
5403 if ((getstrings & (1 <<
i)) != 0)
5406 const char *substring;
5407 PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count,
i, &substring);
5409 fprintf(
outfile,
"get substring %d failed %d\n",
i, rc);
5413 PCHARSV(substring, 0, rc,
outfile);
5414 fprintf(
outfile,
" (%d)\n", rc);
5415 PCRE_FREE_SUBSTRING(substring);
5424 const char *substring;
5426 #ifdef SUPPORT_PCRE32
5429 if (*(pcre_uint32 *)gnptr == 0)
break;
5432 #ifdef SUPPORT_PCRE16
5435 if (*(pcre_uint16 *)gnptr == 0)
break;
5438 #ifdef SUPPORT_PCRE8
5445 PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, use_offsets, count,
5449 fprintf(
outfile,
"get substring ");
5450 PCHARSV(gnptr, 0, -1,
outfile);
5451 fprintf(
outfile,
" failed %d\n", rc);
5456 PCHARSV(substring, 0, rc,
outfile);
5457 fprintf(
outfile,
" (%d) ", rc);
5458 PCHARSV(gnptr, 0, -1,
outfile);
5459 PCRE_FREE_SUBSTRING(substring);
5463 gnptr = (
char *)gnptr + (STRLEN(gnptr) + 1) * CHAR_SIZE;
5469 const char **stringlist;
5470 PCRE_GET_SUBSTRING_LIST(rc, bptr, use_offsets, count, &stringlist);
5472 fprintf(
outfile,
"get substring list failed %d\n", rc);
5475 for (
i = 0;
i < count;
i++)
5478 PCHARSV(stringlist[
i], 0, -1,
outfile);
5481 if (stringlist[
i] !=
NULL)
5482 fprintf(
outfile,
"string list not terminated by NULL\n");
5483 PCRE_FREE_SUBSTRING_LIST(stringlist);
5493 fprintf(
outfile,
"Partial match");
5494 if (use_size_offsets > 2 && use_offsets[0] != use_offsets[2])
5495 fprintf(
outfile,
" at offset %d", use_offsets[2]);
5496 if (markptr !=
NULL)
5499 PCHARSV(markptr, 0, -1,
outfile);
5501 if (use_size_offsets > 1)
5504 PCHARSV(bptr, use_offsets[0], use_offsets[1] - use_offsets[0],
5530 if (g_notempty != 0)
5534 use_offsets[0] = start_offset;
5551 start_offset <
len - 1 && (
5552 #ifdef SUPPORT_PCRE8
5554 bptr[start_offset] ==
'\r' &&
5555 bptr[start_offset + 1] ==
'\n') ||
5557 #ifdef SUPPORT_PCRE16
5562 #ifdef SUPPORT_PCRE32
5571 while (start_offset + onechar <
len)
5573 if ((bptr[start_offset+onechar] & 0xc0) != 0x80)
break;
5577 use_offsets[1] = start_offset + onechar;
5586 if (markptr ==
NULL)
5592 fprintf(
outfile,
"No match, mark = ");
5593 PCHARSV(markptr, 0, -1,
outfile);
5602 fprintf(
outfile,
"Error %d (%s UTF-%d string)", count,
5605 if (use_size_offsets >= 2)
5606 fprintf(
outfile,
" offset=%d reason=%d", use_offsets[0],
5612 fprintf(
outfile,
"Error %d (bad UTF-%d offset)\n", count,
5618 (-count) < (
int)(
sizeof(
errtexts)/
sizeof(
const char *)))
5621 fprintf(
outfile,
"Error %d (Unexpected value)\n", count);
5631 if (!do_g && !do_G)
break;
5633 if (use_offsets ==
NULL)
5635 fprintf(
outfile,
"Cannot do global matching without an ovector\n");
5639 if (use_size_offsets < 2)
5641 fprintf(
outfile,
"Cannot do global matching with an ovector size < 2\n");
5654 if (use_offsets[0] == use_offsets[1])
5656 if (use_offsets[0] ==
len)
break;
5672 if (g_notempty == 0 && use_offsets[1] <= start_offset)
5674 if (start_offset >=
len)
break;
5678 while (start_offset <
len)
5680 if ((bptr[start_offset] & 0xc0) != 0x80)
break;
5685 else start_offset = use_offsets[1];
5692 bptr += use_offsets[1] * CHAR_SIZE;
5693 len -= use_offsets[1];
5697 NEXT_DATA:
continue;
5702 #if !defined NOPOSIX
5709 PCRE_FREE_STUDY(extra);
5714 setlocale(LC_CTYPE,
"C");
5717 if (jit_stack !=
NULL)
5719 PCRE_JIT_STACK_FREE(jit_stack);
5724 if (infile == stdin) fprintf(
outfile,
"\n");
5728 fprintf(
outfile,
"--------------------------------------\n");
5731 fprintf(
outfile,
"Total compile time %.4f milliseconds\n",
5732 (((
double)total_compile_time * 1000.0) / (
double)timeit) /
5734 fprintf(
outfile,
"Total study time %.4f milliseconds\n",
5735 (((
double)total_study_time * 1000.0) / (
double)timeit) /
5738 fprintf(
outfile,
"Total execute time %.4f milliseconds\n",
5739 (((
double)total_match_time * 1000.0) / (
double)timeitm) /
5745 if (infile !=
NULL && infile != stdin) fclose(infile);
5753 #ifdef SUPPORT_PCRE16
5754 if (buffer16 !=
NULL)
free(buffer16);
5756 #ifdef SUPPORT_PCRE32
5757 if (buffer32 !=
NULL)
free(buffer32);
5761 if (dfa_workspace !=
NULL)
5762 free(dfa_workspace);
static const char * str(char *buf, int n)
unsigned int
A callback function used to compare two keys in a database.
static int readline(MDB_val *out, MDB_val *buf)
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
int strncmp(const char *str1, const char *str2, size_t count)
int strcmp(const char *str1, const char *str2)
#define TRUE
bool replacment for C indicating true.
#define FALSE
bool replacment for C indicating false.
double f(double x_, const double &y_)
#define PCRE_CONFIG_LINK_SIZE
#define PCRE_INFO_NAMETABLE
#define PCRE_INFO_MAXLOOKBEHIND
#define PCRE_CONFIG_UNICODE_PROPERTIES
#define PCRE_INFO_NAMEENTRYSIZE
#define PCRE_ERROR_BADUTF8_OFFSET
#define PCRE_NO_UTF8_CHECK
#define PCRE_INFO_FIRSTCHARACTERFLAGS
#define PCRE_INFO_OPTIONS
#define PCRE_STUDY_EXTRA_NEEDED
#define PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE
#define PCRE_CONFIG_JITTARGET
int pcre16_fullinfo(const pcre16 *, const pcre16_extra *, int, void *)
#define PCRE_ERROR_PARTIAL
#define PCRE_CONFIG_UTF16
#define PCRE_EXTRA_CALLOUT_DATA
#define PCRE_ERROR_BADMODE
#define PCRE_INFO_CAPTURECOUNT
int pcre16_get_stringnumber(const pcre16 *, const unsigned short *)
int pcre32_config(int, void *)
#define PCRE_EXTRA_STUDY_DATA
void *(* pcre32_malloc)(size_t)
void *(* pcre_malloc)(size_t)
void(* pcre32_free)(void *)
void *(* pcre16_malloc)(size_t)
void(* pcre16_free)(void *)
#define PCRE_INFO_JITSIZE
#define PCRE_AUTO_CALLOUT
int pcre32_get_stringnumber(const pcre32 *, const unsigned int *)
#define PCRE_INFO_BACKREFMAX
#define PCRE_ERROR_SHORTUTF8
#define PCRE_EXTRA_MATCH_LIMIT
void *(* pcre_stack_malloc)(size_t)
#define PCRE_CONFIG_MATCH_LIMIT
#define PCRE_DFA_SHORTEST
#define PCRE_INFO_HASCRORLF
int pcre_get_stringnumber(const pcre *, const char *)
struct real_pcre_jit_stack pcre_jit_stack
void(* pcre32_stack_free)(void *)
void(* pcre_free)(void *)
#define PCRE_INFO_NAMECOUNT
#define PCRE_INFO_FIRSTTABLE
#define PCRE_NEWLINE_CRLF
#define PCRE_INFO_REQUIREDCHAR
void *(* pcre32_stack_malloc)(size_t)
#define PCRE_INFO_FIRSTCHARACTER
void(* pcre16_stack_free)(void *)
const char * pcre_version(void)
#define PCRE_NO_START_OPTIMISE
#define PCRE_NO_AUTO_CAPTURE
#define PCRE_ERROR_RECURSIONLIMIT
#define PCRE_PARTIAL_SOFT
#define PCRE_INFO_REQUIREDCHARFLAGS
#define PCRE_CONFIG_PARENS_LIMIT
#define PCRE_CONFIG_MATCH_LIMIT_RECURSION
#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
#define PCRE_INFO_MINLENGTH
#define PCRE_INFO_MATCHLIMIT
const char * pcre32_version(void)
int pcre_config(int, void *)
#define PCRE_CONFIG_UTF32
#define PCRE_INFO_MATCH_EMPTY
#define PCRE_NO_START_OPTIMIZE
#define PCRE_EXTRA_EXECUTABLE_JIT
#define PCRE_INFO_JCHANGED
#define PCRE_ERROR_MATCHLIMIT
#define PCRE_INFO_OKPARTIAL
#define PCRE_CONFIG_NEWLINE
#define PCRE_CONFIG_STACKRECURSE
int pcre32_fullinfo(const pcre32 *, const pcre32_extra *, int, void *)
#define PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE
#define PCRE_EXTRA_MATCH_LIMIT_RECURSION
#define PCRE_JAVASCRIPT_COMPAT
void(* pcre_stack_free)(void *)
#define PCRE_ERROR_NOMATCH
#define PCRE_DOLLAR_ENDONLY
#define PCRE_PARTIAL_HARD
#define PCRE_STUDY_JIT_COMPILE
const char * pcre16_version(void)
void *(* pcre16_stack_malloc)(size_t)
int pcre_fullinfo(const pcre *, const pcre_extra *, int, void *)
int pcre16_config(int, void *)
#define PCRE_NEWLINE_ANYCRLF
#define PCRE_ERROR_BADUTF8
#define PCRE_INFO_RECURSIONLIMIT
#define PCRE_NOTEMPTY_ATSTART
#define PCRE_NO_AUTO_POSSESS
#define PCRE_NEWLINE_BITS
#define REAL_PCRE_MAGIC(re)
#define REVERSED_MAGIC_NUMBER
struct real_pcre8_or_16 real_pcre
#define PCRE_FCH_CASELESS
#define REAL_PCRE_OPTIONS(re)
#define PCRE_RCH_CASELESS
#define REAL_PCRE_SIZE(re)
#define REAL_PCRE_FLAGS(re)
static const unsigned char * tables(int mode)
void pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)
static unsigned long int match_limit