| 672 |
/* The purpose of this function to allow valgrind |
/* The purpose of this function to allow valgrind |
| 673 |
for reporting invalid reads and writes. */ |
for reporting invalid reads and writes. */ |
| 674 |
static unsigned char *tables_copy; |
static unsigned char *tables_copy; |
|
pcre *regex; |
|
| 675 |
const char *errorptr; |
const char *errorptr; |
| 676 |
int erroroffset; |
int erroroffset; |
| 677 |
const unsigned char *default_tables; |
const unsigned char *default_tables; |
| 678 |
#ifdef SUPPORT_PCRE8 |
#ifdef SUPPORT_PCRE8 |
| 679 |
|
pcre *regex; |
| 680 |
char null_str[1] = { 0 }; |
char null_str[1] = { 0 }; |
| 681 |
#else |
#else |
| 682 |
PCRE_SCHAR16 null_str[1] = { 0 }; |
pcre16 *regex; |
| 683 |
|
PCRE_UCHAR16 null_str[1] = { 0 }; |
| 684 |
#endif |
#endif |
| 685 |
|
|
| 686 |
if (mode) { |
if (mode) { |
| 721 |
return tables_copy; |
return tables_copy; |
| 722 |
} |
} |
| 723 |
|
|
| 724 |
static pcre_jit_stack* callback(void *arg) |
#ifdef SUPPORT_PCRE8 |
| 725 |
|
static pcre_jit_stack* callback8(void *arg) |
| 726 |
{ |
{ |
| 727 |
return (pcre_jit_stack *)arg; |
return (pcre_jit_stack *)arg; |
| 728 |
} |
} |
| 729 |
|
#endif |
| 730 |
|
|
| 731 |
|
#ifdef SUPPORT_PCRE16 |
| 732 |
|
static pcre16_jit_stack* callback16(void *arg) |
| 733 |
|
{ |
| 734 |
|
return (pcre16_jit_stack *)arg; |
| 735 |
|
} |
| 736 |
|
#endif |
| 737 |
|
|
| 738 |
#ifdef SUPPORT_PCRE8 |
#ifdef SUPPORT_PCRE8 |
| 739 |
static void setstack8(pcre_extra *extra) |
static void setstack8(pcre_extra *extra) |
| 750 |
if (!stack) |
if (!stack) |
| 751 |
stack = pcre_jit_stack_alloc(1, 1024 * 1024); |
stack = pcre_jit_stack_alloc(1, 1024 * 1024); |
| 752 |
/* Extra can be NULL. */ |
/* Extra can be NULL. */ |
| 753 |
pcre_assign_jit_stack(extra, callback, stack); |
pcre_assign_jit_stack(extra, callback8, stack); |
| 754 |
} |
} |
| 755 |
#endif /* SUPPORT_PCRE8 */ |
#endif /* SUPPORT_PCRE8 */ |
| 756 |
|
|
| 757 |
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
| 758 |
static void setstack16(pcre_extra *extra) |
static void setstack16(pcre16_extra *extra) |
| 759 |
{ |
{ |
| 760 |
static pcre_jit_stack *stack; |
static pcre16_jit_stack *stack; |
| 761 |
|
|
| 762 |
if (!extra) { |
if (!extra) { |
| 763 |
if (stack) |
if (stack) |
| 769 |
if (!stack) |
if (!stack) |
| 770 |
stack = pcre16_jit_stack_alloc(1, 1024 * 1024); |
stack = pcre16_jit_stack_alloc(1, 1024 * 1024); |
| 771 |
/* Extra can be NULL. */ |
/* Extra can be NULL. */ |
| 772 |
pcre16_assign_jit_stack(extra, callback, stack); |
pcre16_assign_jit_stack(extra, callback16, stack); |
| 773 |
} |
} |
| 774 |
#endif /* SUPPORT_PCRE8 */ |
#endif /* SUPPORT_PCRE8 */ |
| 775 |
|
|
| 776 |
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
| 777 |
|
|
| 778 |
static int convert_utf8_to_utf16(const char *input, PCRE_SCHAR16 *output, int *offsetmap, int max_length) |
static int convert_utf8_to_utf16(const char *input, PCRE_UCHAR16 *output, int *offsetmap, int max_length) |
| 779 |
{ |
{ |
| 780 |
unsigned char *iptr = (unsigned char*)input; |
unsigned char *iptr = (unsigned char*)input; |
| 781 |
unsigned short *optr = (unsigned short *)output; |
unsigned short *optr = (unsigned short *)output; |
| 823 |
return (int)(optr - (unsigned short *)output); |
return (int)(optr - (unsigned short *)output); |
| 824 |
} |
} |
| 825 |
|
|
| 826 |
static int copy_char8_to_char16(const char *input, PCRE_SCHAR16 *output, int max_length) |
static int copy_char8_to_char16(const char *input, PCRE_UCHAR16 *output, int max_length) |
| 827 |
{ |
{ |
| 828 |
unsigned char *iptr = (unsigned char*)input; |
unsigned char *iptr = (unsigned char*)input; |
| 829 |
unsigned short *optr = (unsigned short *)output; |
unsigned short *optr = (unsigned short *)output; |
| 840 |
} |
} |
| 841 |
|
|
| 842 |
#define REGTEST_MAX_LENGTH 4096 |
#define REGTEST_MAX_LENGTH 4096 |
| 843 |
static PCRE_SCHAR16 regtest_buf[REGTEST_MAX_LENGTH]; |
static PCRE_UCHAR16 regtest_buf[REGTEST_MAX_LENGTH]; |
| 844 |
static int regtest_offsetmap[REGTEST_MAX_LENGTH]; |
static int regtest_offsetmap[REGTEST_MAX_LENGTH]; |
| 845 |
|
|
| 846 |
#endif /* SUPPORT_PCRE16 */ |
#endif /* SUPPORT_PCRE16 */ |
| 860 |
{ |
{ |
| 861 |
struct regression_test_case *current = regression_test_cases; |
struct regression_test_case *current = regression_test_cases; |
| 862 |
const char *error; |
const char *error; |
| 863 |
|
const char *cpu_info; |
| 864 |
int i, err_offs; |
int i, err_offs; |
| 865 |
int is_successful, is_ascii_pattern, is_ascii_input; |
int is_successful, is_ascii_pattern, is_ascii_input; |
| 866 |
int total = 0; |
int total = 0; |
| 876 |
int disabled_flags8 = 0; |
int disabled_flags8 = 0; |
| 877 |
#endif |
#endif |
| 878 |
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
| 879 |
pcre *re16; |
pcre16 *re16; |
| 880 |
pcre_extra *extra16; |
pcre16_extra *extra16; |
| 881 |
int ovector16_1[32]; |
int ovector16_1[32]; |
| 882 |
int ovector16_2[32]; |
int ovector16_2[32]; |
| 883 |
int return_value16_1, return_value16_2; |
int return_value16_1, return_value16_2; |
| 890 |
utf or ucp may make tests fail, if the pcre_exec result is the SAME, it is |
utf or ucp may make tests fail, if the pcre_exec result is the SAME, it is |
| 891 |
still considered successful from pcre_jit_test point of view. */ |
still considered successful from pcre_jit_test point of view. */ |
| 892 |
|
|
| 893 |
printf("Running JIT regression\n"); |
#ifdef SUPPORT_PCRE8 |
| 894 |
|
pcre_config(PCRE_CONFIG_JITTARGET, &cpu_info); |
| 895 |
|
#else |
| 896 |
|
pcre16_config(PCRE_CONFIG_JITTARGET, &cpu_info); |
| 897 |
|
#endif |
| 898 |
|
|
| 899 |
|
printf("Running JIT regression tests\n"); |
| 900 |
|
printf(" target CPU of SLJIT compiler: %s\n", cpu_info); |
| 901 |
|
|
| 902 |
#ifdef SUPPORT_PCRE8 |
#ifdef SUPPORT_PCRE8 |
| 903 |
pcre_config(PCRE_CONFIG_UTF8, &utf8); |
pcre_config(PCRE_CONFIG_UTF8, &utf8); |
| 906 |
disabled_flags8 |= PCRE_UTF8; |
disabled_flags8 |= PCRE_UTF8; |
| 907 |
if (!ucp8) |
if (!ucp8) |
| 908 |
disabled_flags8 |= PCRE_UCP; |
disabled_flags8 |= PCRE_UCP; |
| 909 |
printf(" in 8 bit mode with utf8 %s and ucp %s:\n", utf8 ? "enabled" : "disabled", ucp8 ? "enabled" : "disabled"); |
printf(" in 8 bit mode with utf8 %s and ucp %s:\n", utf8 ? "enabled" : "disabled", ucp8 ? "enabled" : "disabled"); |
| 910 |
#endif |
#endif |
| 911 |
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
| 912 |
pcre16_config(PCRE_CONFIG_UTF16, &utf16); |
pcre16_config(PCRE_CONFIG_UTF16, &utf16); |
| 915 |
disabled_flags16 |= PCRE_UTF8; |
disabled_flags16 |= PCRE_UTF8; |
| 916 |
if (!ucp16) |
if (!ucp16) |
| 917 |
disabled_flags16 |= PCRE_UCP; |
disabled_flags16 |= PCRE_UCP; |
| 918 |
printf(" in 16 bit mode with utf16 %s and ucp %s:\n", utf16 ? "enabled" : "disabled", ucp16 ? "enabled" : "disabled"); |
printf(" in 16 bit mode with utf16 %s and ucp %s:\n", utf16 ? "enabled" : "disabled", ucp16 ? "enabled" : "disabled"); |
| 919 |
#endif |
#endif |
| 920 |
|
|
| 921 |
while (current->pattern) { |
while (current->pattern) { |