/[pcre]/code/trunk/pcretest.c
ViewVC logotype

Diff of /code/trunk/pcretest.c

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

revision 914 by zherczeg, Mon Feb 13 06:04:50 2012 UTC revision 922 by ph10, Mon Feb 20 18:44:42 2012 UTC
# Line 1  Line 1 
1  /*************************************************  /*.************************************************
2  *             PCRE testing program               *  *             PCRE testing program               *
3  *************************************************/  *************************************************/
4    
# Line 2132  printf("  -q       quiet: do not output Line 2132  printf("  -q       quiet: do not output
2132  printf("  -S <n>   set stack size to <n> megabytes\n");  printf("  -S <n>   set stack size to <n> megabytes\n");
2133  printf("  -s       force each pattern to be studied at basic level\n"  printf("  -s       force each pattern to be studied at basic level\n"
2134         "  -s+      force each pattern to be studied, using JIT if available\n"         "  -s+      force each pattern to be studied, using JIT if available\n"
2135           "  -s++     ditto, verifying when JIT was actually used\n"
2136         "  -t       time compilation and execution\n");         "  -t       time compilation and execution\n");
2137  printf("  -t <n>   time compilation and execution, repeating <n> times\n");  printf("  -t <n>   time compilation and execution, repeating <n> times\n");
2138  printf("  -tm      time execution (matching) only\n");  printf("  -tm      time execution (matching) only\n");
# Line 2172  int posix = 0; Line 2173  int posix = 0;
2173  int debug = 0;  int debug = 0;
2174  int done = 0;  int done = 0;
2175  int all_use_dfa = 0;  int all_use_dfa = 0;
2176    int verify_jit = 0;
2177  int yield = 0;  int yield = 0;
2178  int stack_size;  int stack_size;
2179    
# Line 2233  version = pcre16_version(); Line 2235  version = pcre16_version();
2235  while (argc > 1 && argv[op][0] == '-')  while (argc > 1 && argv[op][0] == '-')
2236    {    {
2237    pcre_uint8 *endptr;    pcre_uint8 *endptr;
2238      char *arg = argv[op];
2239    
2240    if (strcmp(argv[op], "-m") == 0) showstore = 1;    if (strcmp(arg, "-m") == 0) showstore = 1;
2241    else if (strcmp(argv[op], "-s") == 0) force_study = 0;    else if (strcmp(arg, "-s") == 0) force_study = 0;
2242    else if (strcmp(argv[op], "-s+") == 0)  
2243      else if (strncmp(arg, "-s+", 3) == 0)
2244      {      {
2245        arg += 3;
2246        if (*arg == '+') { arg++; verify_jit = TRUE; }
2247    
2248        if (*arg != 0) goto BAD_ARG;
2249    
2250      force_study = 1;      force_study = 1;
2251      force_study_options = PCRE_STUDY_JIT_COMPILE      force_study_options = PCRE_STUDY_JIT_COMPILE
2252                          | PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE                          | PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE
2253                          | PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE;                          | PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE;
2254      }      }
2255    else if (strcmp(argv[op], "-16") == 0)    else if (strcmp(arg, "-16") == 0)
2256      {      {
2257  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
2258      use_pcre16 = 1;      use_pcre16 = 1;
# Line 2252  while (argc > 1 && argv[op][0] == '-') Line 2261  while (argc > 1 && argv[op][0] == '-')
2261      exit(1);      exit(1);
2262  #endif  #endif
2263      }      }
2264    else if (strcmp(argv[op], "-q") == 0) quiet = 1;    else if (strcmp(arg, "-q") == 0) quiet = 1;
2265    else if (strcmp(argv[op], "-b") == 0) debug = 1;    else if (strcmp(arg, "-b") == 0) debug = 1;
2266    else if (strcmp(argv[op], "-i") == 0) showinfo = 1;    else if (strcmp(arg, "-i") == 0) showinfo = 1;
2267    else if (strcmp(argv[op], "-d") == 0) showinfo = debug = 1;    else if (strcmp(arg, "-d") == 0) showinfo = debug = 1;
2268    else if (strcmp(argv[op], "-M") == 0) default_find_match_limit = TRUE;    else if (strcmp(arg, "-M") == 0) default_find_match_limit = TRUE;
2269  #if !defined NODFA  #if !defined NODFA
2270    else if (strcmp(argv[op], "-dfa") == 0) all_use_dfa = 1;    else if (strcmp(arg, "-dfa") == 0) all_use_dfa = 1;
2271  #endif  #endif
2272    else if (strcmp(argv[op], "-o") == 0 && argc > 2 &&    else if (strcmp(arg, "-o") == 0 && argc > 2 &&
2273        ((size_offsets = get_value((pcre_uint8 *)argv[op+1], &endptr)),        ((size_offsets = get_value((pcre_uint8 *)argv[op+1], &endptr)),
2274          *endptr == 0))          *endptr == 0))
2275      {      {
2276      op++;      op++;
2277      argc--;      argc--;
2278      }      }
2279    else if (strcmp(argv[op], "-t") == 0 || strcmp(argv[op], "-tm") == 0)    else if (strcmp(arg, "-t") == 0 || strcmp(arg, "-tm") == 0)
2280      {      {
2281      int both = argv[op][2] == 0;      int both = arg[2] == 0;
2282      int temp;      int temp;
2283      if (argc > 2 && (temp = get_value((pcre_uint8 *)argv[op+1], &endptr),      if (argc > 2 && (temp = get_value((pcre_uint8 *)argv[op+1], &endptr),
2284                       *endptr == 0))                       *endptr == 0))
# Line 2281  while (argc > 1 && argv[op][0] == '-') Line 2290  while (argc > 1 && argv[op][0] == '-')
2290      else timeitm = LOOPREPEAT;      else timeitm = LOOPREPEAT;
2291      if (both) timeit = timeitm;      if (both) timeit = timeitm;
2292      }      }
2293    else if (strcmp(argv[op], "-S") == 0 && argc > 2 &&    else if (strcmp(arg, "-S") == 0 && argc > 2 &&
2294        ((stack_size = get_value((pcre_uint8 *)argv[op+1], &endptr)),        ((stack_size = get_value((pcre_uint8 *)argv[op+1], &endptr)),
2295          *endptr == 0))          *endptr == 0))
2296      {      {
# Line 2304  while (argc > 1 && argv[op][0] == '-') Line 2313  while (argc > 1 && argv[op][0] == '-')
2313  #endif  #endif
2314      }      }
2315  #if !defined NOPOSIX  #if !defined NOPOSIX
2316    else if (strcmp(argv[op], "-p") == 0) posix = 1;    else if (strcmp(arg, "-p") == 0) posix = 1;
2317  #endif  #endif
2318    else if (strcmp(argv[op], "-C") == 0)    else if (strcmp(arg, "-C") == 0)
2319      {      {
2320      int rc;      int rc;
2321      unsigned long int lrc;      unsigned long int lrc;
# Line 2446  are set, either both UTFs are supported Line 2455  are set, either both UTFs are supported
2455      printf("\n");      printf("\n");
2456      goto EXIT;      goto EXIT;
2457      }      }
2458    else if (strcmp(argv[op], "-help") == 0 ||    else if (strcmp(arg, "-help") == 0 ||
2459             strcmp(argv[op], "--help") == 0)             strcmp(arg, "--help") == 0)
2460      {      {
2461      usage();      usage();
2462      goto EXIT;      goto EXIT;
2463      }      }
2464    else    else
2465      {      {
2466      printf("** Unknown or malformed option %s\n", argv[op]);      BAD_ARG:
2467        printf("** Unknown or malformed option %s\n", arg);
2468      usage();      usage();
2469      yield = 1;      yield = 1;
2470      goto EXIT;      goto EXIT;
# Line 2770  while (!done) Line 2780  while (!done)
2780          do_study = 1;          do_study = 1;
2781          if (*pp == '+')          if (*pp == '+')
2782            {            {
2783              if (*(++pp) == '+')
2784                {
2785                verify_jit = TRUE;
2786                pp++;
2787                }
2788            study_options |= PCRE_STUDY_JIT_COMPILE            study_options |= PCRE_STUDY_JIT_COMPILE
2789                          | PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE                          | PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE
2790                          | PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE;                          | PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE;
           pp++;  
2791            }            }
2792          }          }
2793        else        else
# Line 3380  while (!done) Line 3394  while (!done)
3394      int start_offset_sign = 1;      int start_offset_sign = 1;
3395      int g_notempty = 0;      int g_notempty = 0;
3396      int use_dfa = 0;      int use_dfa = 0;
3397        int jit_was_used = 0;
3398    
3399      *copynames = 0;      *copynames = 0;
3400      *getnames = 0;      *getnames = 0;
# Line 3965  while (!done) Line 3980  while (!done)
3980            count = use_size_offsets/3;            count = use_size_offsets/3;
3981            }            }
3982          }          }
3983    
3984          if (extra != NULL && (extra->flags & PCRE_EXTRA_USED_JIT) != 0)
3985            jit_was_used = TRUE;
3986    
3987        /* Matched */        /* Matched */
3988    
# Line 4023  while (!done) Line 4041  while (!done)
4041              fprintf(outfile, "%2d: ", i/2);              fprintf(outfile, "%2d: ", i/2);
4042              PCHARSV(bptr, use_offsets[i],              PCHARSV(bptr, use_offsets[i],
4043                use_offsets[i+1] - use_offsets[i], outfile);                use_offsets[i+1] - use_offsets[i], outfile);
4044                if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");
4045              fprintf(outfile, "\n");              fprintf(outfile, "\n");
4046              if (do_showcaprest || (i == 0 && do_showrest))              if (do_showcaprest || (i == 0 && do_showrest))
4047                {                {
# Line 4268  while (!done) Line 4287  while (!done)
4287                {                {
4288                if (markptr == NULL)                if (markptr == NULL)
4289                  {                  {
4290                  fprintf(outfile, "No match\n");                  fprintf(outfile, "No match");
4291                  }                  }
4292                else                else
4293                  {                  {
4294                  fprintf(outfile, "No match, mark = ");                  fprintf(outfile, "No match, mark = ");
4295                  PCHARSV(markptr, 0, -1, outfile);                  PCHARSV(markptr, 0, -1, outfile);
                 putc('\n', outfile);  
4296                  }                  }
4297                  if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");
4298                  putc('\n', outfile);
4299                }                }
4300              break;              break;
4301    

Legend:
Removed from v.914  
changed lines
  Added in v.922

  ViewVC Help
Powered by ViewVC 1.1.5