/[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 805 by zherczeg, Wed Dec 14 11:18:01 2011 UTC revision 806 by zherczeg, Thu Dec 15 11:57:39 2011 UTC
# Line 638  static struct regression_test_case regre Line 638  static struct regression_test_case regre
638          { CMA, 0 | F_FORCECONV, "\\d*\\s*\\w*\xed\xa0\x80\xed\xa0\x80", "\xed\xa0\x80\xed\xa0\x80" },          { CMA, 0 | F_FORCECONV, "\\d*\\s*\\w*\xed\xa0\x80\xed\xa0\x80", "\xed\xa0\x80\xed\xa0\x80" },
639          { CMA, 0 | F_FORCECONV | F_NOMATCH, "\\d*?\\D*?\\s*?\\S*?\\w*?\\W*?##", "\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80#" },          { CMA, 0 | F_FORCECONV | F_NOMATCH, "\\d*?\\D*?\\s*?\\S*?\\w*?\\W*?##", "\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80#" },
640          { CMA | PCRE_EXTENDED, 0 | F_FORCECONV, "\xed\xa0\x80 \xed\xb0\x80 !", "\xed\xa0\x80\xed\xb0\x80!" },          { CMA | PCRE_EXTENDED, 0 | F_FORCECONV, "\xed\xa0\x80 \xed\xb0\x80 !", "\xed\xa0\x80\xed\xb0\x80!" },
641            { CMA, 0 | F_FORCECONV, "\xed\xa0\x80+#[^#]+\xed\xa0\x80", "\xed\xa0\x80#a\xed\xa0\x80" },
642            { CMA, 0 | F_FORCECONV, "(\xed\xa0\x80+)#\\1", "\xed\xa0\x80\xed\xa0\x80#\xed\xa0\x80\xed\xa0\x80" },
643    
644          /* Deep recursion. */          /* Deep recursion. */
645          { MUA, 0, "((((?:(?:(?:\\w)+)?)*|(?>\\w)+?)+|(?>\\w)?\?)*)?\\s", "aaaaa+ " },          { MUA, 0, "((((?:(?:(?:\\w)+)?)*|(?>\\w)+?)+|(?>\\w)?\?)*)?\\s", "aaaaa+ " },
# Line 654  static struct regression_test_case regre Line 656  static struct regression_test_case regre
656          { 0, 0, NULL, NULL }          { 0, 0, NULL, NULL }
657  };  };
658    
659  static const unsigned char *tables(int release)  static const unsigned char *tables(int mode)
660  {  {
661          /* The purpose of this function to allow valgrind          /* The purpose of this function to allow valgrind
662          for reporting invalid reads and writes. */          for reporting invalid reads and writes. */
# Line 669  static const unsigned char *tables(int r Line 671  static const unsigned char *tables(int r
671          PCRE_SCHAR16 null_str[1] = { 0 };          PCRE_SCHAR16 null_str[1] = { 0 };
672  #endif  #endif
673    
674          if (release) {          if (mode) {
675                  if (tables_copy)                  if (tables_copy)
676                          free(tables_copy);                          free(tables_copy);
677                  tables_copy = NULL;                  tables_copy = NULL;
# Line 697  static const unsigned char *tables(int r Line 699  static const unsigned char *tables(int r
699          if (!default_tables)          if (!default_tables)
700                  return NULL;                  return NULL;
701    
702          /* This value cannot get from pcre_fullinfo. Since this is a test program,          /* Unfortunately this value cannot get from pcre_fullinfo.
703          we can live with it at the moment. */          Since this is a test program, this is acceptable at the moment. */
704          tables_copy = (unsigned char *)malloc(1088);          tables_copy = (unsigned char *)malloc(1088);
705          if (!tables_copy)          if (!tables_copy)
706                  return NULL;                  return NULL;
# Line 712  static pcre_jit_stack* callback(void *ar Line 714  static pcre_jit_stack* callback(void *ar
714          return (pcre_jit_stack *)arg;          return (pcre_jit_stack *)arg;
715  }  }
716    
717  static void setstack(pcre_extra *extra, int alloc_again)  static void setstack(pcre_extra *extra)
718  {  {
719          static pcre_jit_stack *stack;          static pcre_jit_stack *stack;
720    
721          if (alloc_again) {          if (!extra) {
722                  if (stack)                  if (stack)
723                          pcre_jit_stack_free(stack);                          pcre_jit_stack_free(stack);
724                  stack = pcre_jit_stack_alloc(1, 1024 * 1024);                  stack = NULL;
725                    return;
726          }          }
727    
728            if (!stack)
729                    stack = pcre_jit_stack_alloc(1, 1024 * 1024);
730          /* Extra can be NULL. */          /* Extra can be NULL. */
731          pcre_assign_jit_stack(extra, callback, stack);          pcre_assign_jit_stack(extra, callback, stack);
732  }  }
# Line 913  static int regression_tests(void) Line 919  static int regression_tests(void)
919    
920                  counter++;                  counter++;
921                  if ((counter & 0x3) != 0)                  if ((counter & 0x3) != 0)
922                          setstack(NULL, 1);                          setstack(NULL);
923    
924  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
925                  return_value8_1 = -1000;                  return_value8_1 = -1000;
# Line 923  static int regression_tests(void) Line 929  static int regression_tests(void)
929                  for (i = 0; i < 32; ++i)                  for (i = 0; i < 32; ++i)
930                          ovector8_2[i] = -2;                          ovector8_2[i] = -2;
931                  if (re8) {                  if (re8) {
932                          setstack(extra8, 0);                          setstack(extra8);
933                          return_value8_1 = pcre_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,                          return_value8_1 = pcre_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
934                                  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);
935                          return_value8_2 = pcre_exec(re8, NULL, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,                          return_value8_2 = pcre_exec(re8, NULL, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
# Line 939  static int regression_tests(void) Line 945  static int regression_tests(void)
945                  for (i = 0; i < 32; ++i)                  for (i = 0; i < 32; ++i)
946                          ovector16_2[i] = -2;                          ovector16_2[i] = -2;
947                  if (re16) {                  if (re16) {
948                          setstack(extra16, 0);                          setstack(extra16);
949                          if ((current->flags & PCRE_UTF8) || (current->start_offset & F_FORCECONV))                          if ((current->flags & PCRE_UTF8) || (current->start_offset & F_FORCECONV))
950                                  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);
951                          else                          else
# Line 1079  static int regression_tests(void) Line 1085  static int regression_tests(void)
1085                  current++;                  current++;
1086          }          }
1087          tables(1);          tables(1);
1088            setstack(NULL);
1089    
1090          if (total == successful) {          if (total == successful) {
1091                  printf("\nAll JIT regression tests are successfully passed.\n");                  printf("\nAll JIT regression tests are successfully passed.\n");

Legend:
Removed from v.805  
changed lines
  Added in v.806

  ViewVC Help
Powered by ViewVC 1.1.5