/[pcre]/code/branches/pcre16/pcre_jit_test.c
ViewVC logotype

Diff of /code/branches/pcre16/pcre_jit_test.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 794 by zherczeg, Thu Dec 8 07:36:41 2011 UTC revision 795 by zherczeg, Sat Dec 10 02:20:06 2011 UTC
# Line 56  POSSIBILITY OF SUCH DAMAGE. Line 56  POSSIBILITY OF SUCH DAMAGE.
56   Non-letter characters:   Non-letter characters:
57     \xc2\xa1 = 0xa1 =  (Inverted Exclamation Mark)     \xc2\xa1 = 0xa1 =  (Inverted Exclamation Mark)
58     \xf3\xa9\xb7\x80 = 0xe9dc0 = 957888     \xf3\xa9\xb7\x80 = 0xe9dc0 = 957888
59       \xed\xa0\x80 = 55296 = 0xd800 (Invalid UTF character)
60       \xed\xb0\x80 = 56320 = 0xdc00 (Invalid UTF character)
61   Newlines:   Newlines:
62     \xc2\x85 = 0x85 = 133 (NExt Line = NEL)     \xc2\x85 = 0x85 = 133 (NExt Line = NEL)
63     \xe2\x80\xa8 = 0x2028 = 8232 (Line Separator)     \xe2\x80\xa8 = 0x2028 = 8232 (Line Separator)
# Line 99  int main(void) Line 101  int main(void)
101  #error SUPPORT_PCRE8 or SUPPORT_PCRE16 must be defined  #error SUPPORT_PCRE8 or SUPPORT_PCRE16 must be defined
102  #endif  #endif
103    
104  #define MUA     (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)  #define MUA     (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)
105  #define MUAP    (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)  #define MUAP    (PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
106  #define CMUA    (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)  #define CMUA    (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF)
107  #define CMUAP   (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)  #define CMUAP   (PCRE_CASELESS | PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
108  #define MA      (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)  #define MA      (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)
109  #define MAP     (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)  #define MAP     (PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF | PCRE_UCP)
110  #define CMA     (PCRE_CASELESS | PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)  #define CMA     (PCRE_CASELESS | PCRE_MULTILINE | PCRE_NEWLINE_ANYCRLF)
111    
112    #define OFFSET_MASK     0xffff
113    #define F_DIFF          0x010000
114    #define F_FORCECONV     0x020000
115    #define F_NO8           0x100000
116    #define F_NO16          0x200000
117    
118  struct regression_test_case {  struct regression_test_case {
119          int flags;          int flags;
# Line 521  static struct regression_test_case regre Line 529  static struct regression_test_case regre
529          { MUA, 0, "(?(?!(b))a*|b*)+k", "ababbalbbadabak" },          { MUA, 0, "(?(?!(b))a*|b*)+k", "ababbalbbadabak" },
530          { MUA, 0, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },          { MUA, 0, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },
531          { MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },          { MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+aaaak", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb aaaaaaak" },
532          { MUA | PCRE_BUG, 0, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },          { MUA, 0 | F_DIFF, "(?(?!(b))(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },
533          { MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },          { MUA, 0, "(?(?!b)(?:aaaaaa|a)|(?:bbbbbb|b))+bbbbk", "aaaaaaaaaaaaaa bbbbbbbbbbbbbbb bbbbbbbk" },
534          { MUA, 0, "(?(?=a)a*|b*)+k", "ababbalbbadabak" },          { MUA, 0, "(?(?=a)a*|b*)+k", "ababbalbbadabak" },
535          { MUA, 0, "(?(?!b)a*|b*)+k", "ababbalbbadabak" },          { MUA, 0, "(?(?!b)a*|b*)+k", "ababbalbbadabak" },
# Line 535  static struct regression_test_case regre Line 543  static struct regression_test_case regre
543          { MUA, 0, "((?=\\w{5})\\w(?(?=\\w*k)\\d|[a-f_])*\\w\\s)+", "mol m10kk m088k _f_a_ mbkkl" },          { MUA, 0, "((?=\\w{5})\\w(?(?=\\w*k)\\d|[a-f_])*\\w\\s)+", "mol m10kk m088k _f_a_ mbkkl" },
544          { MUA, 0, "(c)?\?(?(1)a|b)", "cdcaa" },          { MUA, 0, "(c)?\?(?(1)a|b)", "cdcaa" },
545          { MUA, 0, "(c)?\?(?(1)a|b)", "cbb" },          { MUA, 0, "(c)?\?(?(1)a|b)", "cbb" },
546          { MUA | PCRE_BUG, 0, "(?(?=(a))(aaaa|a?))+aak", "aaaaab aaaaak" },          { MUA, 0 | F_DIFF, "(?(?=(a))(aaaa|a?))+aak", "aaaaab aaaaak" },
547          { MUA, 0, "(?(?=a)(aaaa|a?))+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?=a)(aaaa|a?))+aak", "aaaaab aaaaak" },
548          { MUA, 0, "(?(?!(b))(aaaa|a?))+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?!(b))(aaaa|a?))+aak", "aaaaab aaaaak" },
549          { MUA, 0, "(?(?!b)(aaaa|a?))+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?!b)(aaaa|a?))+aak", "aaaaab aaaaak" },
550          { MUA | PCRE_BUG, 0, "(?(?=(a))a*)+aak", "aaaaab aaaaak" },          { MUA, 0 | F_DIFF, "(?(?=(a))a*)+aak", "aaaaab aaaaak" },
551          { MUA, 0, "(?(?=a)a*)+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?=a)a*)+aak", "aaaaab aaaaak" },
552          { MUA, 0, "(?(?!(b))a*)+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?!(b))a*)+aak", "aaaaab aaaaak" },
553          { MUA, 0, "(?(?!b)a*)+aak", "aaaaab aaaaak" },          { MUA, 0, "(?(?!b)a*)+aak", "aaaaab aaaaak" },
# Line 601  static struct regression_test_case regre Line 609  static struct regression_test_case regre
609          { MUA, 0, "((?(R)(?:aaaa|a)|(?:(aaaa)|(a)))+)(?1)$", "aaaaaaaaaa aaaa" },          { MUA, 0, "((?(R)(?:aaaa|a)|(?:(aaaa)|(a)))+)(?1)$", "aaaaaaaaaa aaaa" },
610          { MUA, 0, "(?P<Name>a(?(R&Name)a|b))(?1)", "aab abb abaa" },          { MUA, 0, "(?P<Name>a(?(R&Name)a|b))(?1)", "aab abb abaa" },
611    
612            /* 16 bit specific tests. */
613            { CMA, 0 | F_FORCECONV, "\xc3\xa1", "\xc3\x81\xc3\xa1" },
614            { CMA, 0 | F_FORCECONV, "\xe1\xbd\xb8", "\xe1\xbf\xb8\xe1\xbd\xb8" },
615            { CMA, 0 | F_FORCECONV, "[\xc3\xa1]", "\xc3\x81\xc3\xa1" },
616            { CMA, 0 | F_FORCECONV, "[\xe1\xbd\xb8]", "\xe1\xbf\xb8\xe1\xbd\xb8" },
617            { CMA, 0 | F_FORCECONV | F_NO8, "\xed\xa0\x80\\x{d800}\xed\xb0\x80\\x{dc00}", "\xed\xa0\x80\xed\xa0\x80\xed\xb0\x80\xed\xb0\x80" },
618            { CMA, 0 | F_FORCECONV | F_NO8, "[\xed\xa0\x80\\x{d800}]{1,2}?[\xed\xb0\x80\\x{dc00}]{1,2}?#", "\xed\xa0\x80\xed\xa0\x80\xed\xb0\x80\xed\xb0\x80#" },
619            { CMA, 0 | F_FORCECONV, "[\xed\xa0\x80\xed\xb0\x80#]{0,3}(?<=\xed\xb0\x80.)", "\xed\xa0\x80#\xed\xa0\x80##\xed\xb0\x80\xed\xa0\x80" },
620            { CMA, 0 | F_FORCECONV, "[\xed\xa0\x80-\xed\xb3\xbf]", "\xed\x9f\xbf\xed\xa0\x83" },
621            { CMA, 0 | F_FORCECONV, "[\xed\xa0\x80-\xed\xb3\xbf]", "\xed\xb4\x80\xed\xb3\xb0" },
622            { CMA, 0 | F_FORCECONV | F_NO8, "[\\x{d800}-\\x{dcff}]", "\xed\x9f\xbf\xed\xa0\x83" },
623            { CMA, 0 | F_FORCECONV | F_NO8, "[\\x{d800}-\\x{dcff}]", "\xed\xb4\x80\xed\xb3\xb0" },
624            { CMA, 0 | F_FORCECONV, "[\xed\xa0\x80-\xef\xbf\xbf]+[\x1-\xed\xb0\x80]+#", "\xed\xa0\x85\xc3\x81\xed\xa0\x85\xef\xbf\xb0\xc2\x85\xed\xa9\x89#" },
625    
626          /* Deep recursion. */          /* Deep recursion. */
627          { MUA, 0, "((((?:(?:(?:\\w)+)?)*|(?>\\w)+?)+|(?>\\w)?\?)*)?\\s", "aaaaa+ " },          { MUA, 0, "((((?:(?:(?:\\w)+)?)*|(?>\\w)+?)+|(?>\\w)?\?)*)?\\s", "aaaaa+ " },
628          { MUA, 0, "(?:((?:(?:(?:\\w*?)+)??|(?>\\w)?|\\w*+)*)+)+?\\s", "aa+ " },          { MUA, 0, "(?:((?:(?:(?:\\w*?)+)??|(?>\\w)?|\\w*+)*)+)+?\\s", "aa+ " },
# Line 721  static int regression_tests(void) Line 743  static int regression_tests(void)
743          int ovector8_2[32];          int ovector8_2[32];
744          int return_value8_1, return_value8_2;          int return_value8_1, return_value8_2;
745          int utf8 = 0, ucp8 = 0;          int utf8 = 0, ucp8 = 0;
746          int disabled_flags8 = PCRE_BUG;          int disabled_flags8 = 0;
747  #endif  #endif
748  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
749          pcre *re16;          pcre *re16;
# Line 730  static int regression_tests(void) Line 752  static int regression_tests(void)
752          int ovector16_2[32];          int ovector16_2[32];
753          int return_value16_1, return_value16_2;          int return_value16_1, return_value16_2;
754          int utf16 = 0, ucp16 = 0;          int utf16 = 0, ucp16 = 0;
755          int disabled_flags16 = PCRE_BUG;          int disabled_flags16 = 0;
756          int length16;          int length16;
757  #endif  #endif
758    
# Line 765  static int regression_tests(void) Line 787  static int regression_tests(void)
787    
788                  error = NULL;                  error = NULL;
789  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
790                  re8 = pcre_compile(current->pattern,                  re8 = NULL;
791                          current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | disabled_flags8),                  if (!(current->start_offset & F_NO8))
792                          &error, &err_offs, NULL);                          re8 = pcre_compile(current->pattern,
793                                    current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | disabled_flags8),
794                                    &error, &err_offs, NULL);
795    
796                  extra8 = NULL;                  extra8 = NULL;
797                  if (re8) {                  if (re8) {
# Line 784  static int regression_tests(void) Line 808  static int regression_tests(void)
808                                  pcre_free(re8);                                  pcre_free(re8);
809                                  re8 = NULL;                                  re8 = NULL;
810                          }                          }
811                  } else if (utf8 && ucp8)                  } else if (utf8 && ucp8 && !(current->start_offset & F_NO8))
812                          printf("\n8 bit: Cannot compile pattern: %s\n", current->pattern);                          printf("\n8 bit: Cannot compile pattern: %s\n", current->pattern);
813  #endif  #endif
814  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
815                  if (current->flags & PCRE_UTF8)                  if ((current->flags & PCRE_UTF8) || (current->start_offset & F_FORCECONV))
816                          convert_utf8_to_utf16(current->pattern, regtest_buf, NULL, REGTEST_MAX_LENGTH);                          convert_utf8_to_utf16(current->pattern, regtest_buf, NULL, REGTEST_MAX_LENGTH);
817                  else                  else
818                          copy_char8_to_char16(current->pattern, regtest_buf, REGTEST_MAX_LENGTH);                          copy_char8_to_char16(current->pattern, regtest_buf, REGTEST_MAX_LENGTH);
819                  re16 = pcre16_compile(regtest_buf,  
820                          current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | disabled_flags16),                  re16 = NULL;
821                          &error, &err_offs, NULL);                  if (!(current->start_offset & F_NO16))
822                            re16 = pcre16_compile(regtest_buf,
823                                    current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | disabled_flags16),
824                                    &error, &err_offs, NULL);
825    
826                  extra16 = NULL;                  extra16 = NULL;
827                  if (re16) {                  if (re16) {
# Line 811  static int regression_tests(void) Line 838  static int regression_tests(void)
838                                  pcre_free(re16);                                  pcre_free(re16);
839                                  re16 = NULL;                                  re16 = NULL;
840                          }                          }
841                  } else if (utf16 && ucp16)                  } else if (utf16 && ucp16 && !(current->start_offset & F_NO16))
842                          printf("\n16 bit: Cannot compile pattern: %s\n", current->pattern);                          printf("\n16 bit: Cannot compile pattern: %s\n", current->pattern);
843  #endif  #endif
844    
# Line 822  static int regression_tests(void) Line 849  static int regression_tests(void)
849  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
850                  return_value8_1 = -1000;                  return_value8_1 = -1000;
851                  return_value8_2 = -1000;                  return_value8_2 = -1000;
852                    for (i = 0; i < 32; ++i)
853                            ovector8_1[i] = -2;
854                    for (i = 0; i < 32; ++i)
855                            ovector8_2[i] = -2;
856                  if (re8) {                  if (re8) {
857                          setstack(extra8, 0);                          setstack(extra8, 0);
858                          for (i = 0; i < 32; ++i)                          return_value8_1 = pcre_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
                                 ovector8_1[i] = -2;  
                         return_value8_1 = pcre_exec(re8, extra8, current->input, strlen(current->input), current->start_offset,  
859                                  current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector8_1, 32);                                  current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector8_1, 32);
860                            return_value8_2 = pcre_exec(re8, NULL, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
                         for (i = 0; i < 32; ++i)  
                                 ovector8_2[i] = -2;  
                         return_value8_2 = pcre_exec(re8, NULL, current->input, strlen(current->input), current->start_offset,  
861                                  current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector8_2, 32);                                  current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector8_2, 32);
862                  }                  }
863  #endif  #endif
# Line 839  static int regression_tests(void) Line 865  static int regression_tests(void)
865  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
866                  return_value16_1 = -1000;                  return_value16_1 = -1000;
867                  return_value16_2 = -1000;                  return_value16_2 = -1000;
868                    for (i = 0; i < 32; ++i)
869                            ovector16_1[i] = -2;
870                    for (i = 0; i < 32; ++i)
871                            ovector16_2[i] = -2;
872                  if (re16) {                  if (re16) {
873                          setstack(extra16, 0);                          setstack(extra16, 0);
874                          if (current->flags & PCRE_UTF8)                          if ((current->flags & PCRE_UTF8) || (current->start_offset & F_FORCECONV))
875                                  length16 = convert_utf8_to_utf16(current->input, regtest_buf, regtest_offsetmap, REGTEST_MAX_LENGTH);                                  length16 = convert_utf8_to_utf16(current->input, regtest_buf, regtest_offsetmap, REGTEST_MAX_LENGTH);
876                          else                          else
877                                  length16 = copy_char8_to_char16(current->input, regtest_buf, REGTEST_MAX_LENGTH);                                  length16 = copy_char8_to_char16(current->input, regtest_buf, REGTEST_MAX_LENGTH);
878                            return_value16_1 = pcre16_exec(re16, extra16, regtest_buf, length16, current->start_offset & OFFSET_MASK,
                         for (i = 0; i < 32; ++i)  
                                 ovector16_1[i] = -2;  
                         return_value16_1 = pcre16_exec(re16, extra16, regtest_buf, length16, current->start_offset,  
879                                  current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector16_1, 32);                                  current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector16_1, 32);
880                            return_value16_2 = pcre16_exec(re16, NULL, regtest_buf, length16, current->start_offset & OFFSET_MASK,
                         for (i = 0; i < 32; ++i)  
                                 ovector16_2[i] = -2;  
                         return_value16_2 = pcre16_exec(re16, NULL, regtest_buf, length16, current->start_offset,  
881                                  current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector16_2, 32);                                  current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector16_2, 32);
882                  }                  }
883  #endif  #endif
884    
885                  /* If PCRE_BUG is set, just run the test, but do not compare the results.                  /* If F_DIFF is set, just run the test, but do not compare the results.
886                  Segfaults can still be captured. */                  Segfaults can still be captured. */
887    
888                  is_succesful = 1;                  is_succesful = 1;
889                  if (!(current->flags & PCRE_BUG)) {                  if (!(current->start_offset & F_DIFF)) {
890  #if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16  #if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16
891                          if (utf8 == utf16) {                          if (utf8 == utf16 && !(current->start_offset & F_FORCECONV)) {
892                                  /* All results must be the same. */                                  /* All results must be the same. */
893                                  if (return_value8_1 != return_value8_2 || return_value8_1 != return_value16_1 || return_value8_1 != return_value16_2) {                                  if (return_value8_1 != return_value8_2 || return_value8_1 != return_value16_1 || return_value8_1 != return_value16_2) {
894                                          printf("\n8 and 16 bit: Return value differs(%d:%d:%d:%d): [%d] '%s' @ '%s'\n",                                          printf("\n8 and 16 bit: Return value differs(%d:%d:%d:%d): [%d] '%s' @ '%s'\n",
# Line 947  static int regression_tests(void) Line 971  static int regression_tests(void)
971                  }                  }
972  #endif  #endif
973    
974                  /* printf("[%d-%d]%s", ovector1[0], ovector1[1], (current->flags & PCRE_CASELESS) ? "C" : ""); */                  /* printf("[%d-%d|%d-%d]%s", ovector8_1[0], ovector8_1[1], ovector16_1[0], ovector16_1[1], (current->flags & PCRE_CASELESS) ? "C" : ""); */
975                  printf(".");                  printf(".");
976                  fflush(stdout);                  fflush(stdout);
977                  current++;                  current++;
# Line 962  static int regression_tests(void) Line 986  static int regression_tests(void)
986          }          }
987  }  }
988    
   
989  /* End of pcre_jit_test.c */  /* End of pcre_jit_test.c */

Legend:
Removed from v.794  
changed lines
  Added in v.795

  ViewVC Help
Powered by ViewVC 1.1.5