/[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 959 by ph10, Sat Feb 25 17:02:23 2012 UTC revision 960 by ph10, Thu Apr 19 17:30:38 2012 UTC
# Line 46  pcre_internal.h that depend on COMPILE_P Line 46  pcre_internal.h that depend on COMPILE_P
46  however, make use of SUPPORT_PCRE8 and SUPPORT_PCRE16 to ensure that it calls  however, make use of SUPPORT_PCRE8 and SUPPORT_PCRE16 to ensure that it calls
47  only supported library functions. */  only supported library functions. */
48    
   
49  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
50  #include "config.h"  #include "config.h"
51  #endif  #endif
# Line 60  only supported library functions. */ Line 59  only supported library functions. */
59  #include <errno.h>  #include <errno.h>
60    
61  /* Both libreadline and libedit are optionally supported. The user-supplied  /* Both libreadline and libedit are optionally supported. The user-supplied
62  original patch uses readline/readline.h for libedit, but in at least one system  original patch uses readline/readline.h for libedit, but in at least one system
63  it is installed as editline/readline.h, so the configuration code now looks for  it is installed as editline/readline.h, so the configuration code now looks for
64  that first, falling back to readline/readline.h. */  that first, falling back to readline/readline.h. */
65    
66  #if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)  #if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
# Line 611  version is called. ----- */ Line 610  version is called. ----- */
610  #endif  #endif
611  #endif  #endif
612    
613    #if !defined NODFA
614    #define DFA_WS_DIMENSION 1000
615    #endif
616    
617  /* This is the default loop count for timing. */  /* This is the default loop count for timing. */
618    
619  #define LOOPREPEAT 500000  #define LOOPREPEAT 500000
# Line 625  static int callout_fail_count; Line 628  static int callout_fail_count;
628  static int callout_fail_id;  static int callout_fail_id;
629  static int debug_lengths;  static int debug_lengths;
630  static int first_callout;  static int first_callout;
631  static int jit_was_used;  static int jit_was_used;
632  static int locale_set = 0;  static int locale_set = 0;
633  static int show_malloc;  static int show_malloc;
634  static int use_utf;  static int use_utf;
# Line 690  static int use_pcre16 = 1; Line 693  static int use_pcre16 = 1;
693  /* JIT study options for -s+n and /S+n where '1' <= n <= '7'. */  /* JIT study options for -s+n and /S+n where '1' <= n <= '7'. */
694    
695  static int jit_study_bits[] =  static int jit_study_bits[] =
696    {    {
697    PCRE_STUDY_JIT_COMPILE,    PCRE_STUDY_JIT_COMPILE,
698    PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE,    PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE,
699    PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE,    PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE,
700    PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE,    PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE,
701    PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE,    PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE,
702    PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE + PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE,    PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE + PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE,
703    PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE +    PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE +
704      PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE      PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE
705  };  };
706    
707  /* Textual explanations for runtime error codes */  /* Textual explanations for runtime error codes */
708    
# Line 732  static const char *errtexts[] = { Line 735  static const char *errtexts[] = {
735    NULL,  /* SHORTUTF8/16 is handled specially */    NULL,  /* SHORTUTF8/16 is handled specially */
736    "nested recursion at the same subject position",    "nested recursion at the same subject position",
737    "JIT stack limit reached",    "JIT stack limit reached",
738    "pattern compiled in wrong mode: 8-bit/16-bit error"    "pattern compiled in wrong mode: 8-bit/16-bit error",
739      "pattern compiled with other endianness",
740      "invalid data in workspace for DFA restart"
741  };  };
742    
743    
# Line 2160  printf("  -q       quiet: do not output Line 2165  printf("  -q       quiet: do not output
2165  printf("  -S <n>   set stack size to <n> megabytes\n");  printf("  -S <n>   set stack size to <n> megabytes\n");
2166  printf("  -s       force each pattern to be studied at basic level\n"  printf("  -s       force each pattern to be studied at basic level\n"
2167         "  -s+      force each pattern to be studied, using JIT if available\n"         "  -s+      force each pattern to be studied, using JIT if available\n"
2168         "  -s++     ditto, verifying when JIT was actually used\n"         "  -s++     ditto, verifying when JIT was actually used\n"
2169         "  -s+n     force each pattern to be studied, using JIT if available,\n"         "  -s+n     force each pattern to be studied, using JIT if available,\n"
2170         "             where 1 <= n <= 7 selects JIT options\n"         "             where 1 <= n <= 7 selects JIT options\n"
2171         "  -s++n    ditto, verifying when JIT was actually used\n"         "  -s++n    ditto, verifying when JIT was actually used\n"
2172         "  -t       time compilation and execution\n");         "  -t       time compilation and execution\n");
2173  printf("  -t <n>   time compilation and execution, repeating <n> times\n");  printf("  -t <n>   time compilation and execution, repeating <n> times\n");
2174  printf("  -tm      time execution (matching) only\n");  printf("  -tm      time execution (matching) only\n");
# Line 2198  int quiet = 0; Line 2203  int quiet = 0;
2203  int size_offsets = 45;  int size_offsets = 45;
2204  int size_offsets_max;  int size_offsets_max;
2205  int *offsets = NULL;  int *offsets = NULL;
 #if !defined NOPOSIX  
 int posix = 0;  
 #endif  
2206  int debug = 0;  int debug = 0;
2207  int done = 0;  int done = 0;
2208  int all_use_dfa = 0;  int all_use_dfa = 0;
# Line 2208  int verify_jit = 0; Line 2210  int verify_jit = 0;
2210  int yield = 0;  int yield = 0;
2211  int stack_size;  int stack_size;
2212    
2213    #if !defined NOPOSIX
2214    int posix = 0;
2215    #endif
2216    #if !defined NODFA
2217    int *dfa_workspace = NULL;
2218    #endif
2219    
2220  pcre_jit_stack *jit_stack = NULL;  pcre_jit_stack *jit_stack = NULL;
2221    
2222  /* These vectors store, end-to-end, a list of zero-terminated captured  /* These vectors store, end-to-end, a list of zero-terminated captured
# Line 2266  version = pcre16_version(); Line 2275  version = pcre16_version();
2275  while (argc > 1 && argv[op][0] == '-')  while (argc > 1 && argv[op][0] == '-')
2276    {    {
2277    pcre_uint8 *endptr;    pcre_uint8 *endptr;
2278    char *arg = argv[op];    char *arg = argv[op];
2279    
2280    if (strcmp(arg, "-m") == 0) showstore = 1;    if (strcmp(arg, "-m") == 0) showstore = 1;
2281    else if (strcmp(arg, "-s") == 0) force_study = 0;    else if (strcmp(arg, "-s") == 0) force_study = 0;
2282    
2283    else if (strncmp(arg, "-s+", 3) == 0)    else if (strncmp(arg, "-s+", 3) == 0)
2284      {      {
2285      arg += 3;      arg += 3;
2286      if (*arg == '+') { arg++; verify_jit = TRUE; }      if (*arg == '+') { arg++; verify_jit = TRUE; }
2287      force_study = 1;      force_study = 1;
2288      if (*arg == 0)      if (*arg == 0)
2289        force_study_options = jit_study_bits[6];        force_study_options = jit_study_bits[6];
2290      else if (*arg >= '1' && *arg <= '7')      else if (*arg >= '1' && *arg <= '7')
2291        force_study_options = jit_study_bits[*arg - '1'];        force_study_options = jit_study_bits[*arg - '1'];
2292      else goto BAD_ARG;      else goto BAD_ARG;
2293      }      }
2294    else if (strcmp(arg, "-16") == 0)    else if (strcmp(arg, "-16") == 0)
# Line 2493  are set, either both UTFs are supported Line 2502  are set, either both UTFs are supported
2502      }      }
2503    else    else
2504      {      {
2505      BAD_ARG:      BAD_ARG:
2506      printf("** Unknown or malformed option %s\n", arg);      printf("** Unknown or malformed option %s\n", arg);
2507      usage();      usage();
2508      yield = 1;      yield = 1;
# Line 2591  while (!done) Line 2600  while (!done)
2600    int do_showcaprest = 0;    int do_showcaprest = 0;
2601    int do_flip = 0;    int do_flip = 0;
2602    int erroroffset, len, delimiter, poffset;    int erroroffset, len, delimiter, poffset;
2603    
2604    #if !defined NODFA
2605      int dfa_matched = 0;
2606    #endif
2607    
2608    use_utf = 0;    use_utf = 0;
2609    debug_lengths = 1;    debug_lengths = 1;
# Line 2813  while (!done) Line 2826  while (!done)
2826            if (*(++pp) == '+')            if (*(++pp) == '+')
2827              {              {
2828              verify_jit = TRUE;              verify_jit = TRUE;
2829              pp++;              pp++;
2830              }              }
2831            if (*pp >= '1' && *pp <= '7')            if (*pp >= '1' && *pp <= '7')
2832              study_options |= jit_study_bits[*pp++ - '1'];              study_options |= jit_study_bits[*pp++ - '1'];
2833            else            else
2834              study_options |= jit_study_bits[6];              study_options |= jit_study_bits[6];
2835            }            }
2836          }          }
2837        else        else
# Line 3126  while (!done) Line 3139  while (!done)
3139            new_info(re, NULL, PCRE_INFO_OKPARTIAL, &okpartial) +            new_info(re, NULL, PCRE_INFO_OKPARTIAL, &okpartial) +
3140            new_info(re, NULL, PCRE_INFO_JCHANGED, &jchanged) +            new_info(re, NULL, PCRE_INFO_JCHANGED, &jchanged) +
3141            new_info(re, NULL, PCRE_INFO_HASCRORLF, &hascrorlf) +            new_info(re, NULL, PCRE_INFO_HASCRORLF, &hascrorlf) +
3142            new_info(re, NULL, PCRE_INFO_MAXLOOKBEHIND, &maxlookbehind)            new_info(re, NULL, PCRE_INFO_MAXLOOKBEHIND, &maxlookbehind)
3143            != 0)            != 0)
3144          goto SKIP_DATA;          goto SKIP_DATA;
3145    
# Line 3265  while (!done) Line 3278  while (!done)
3278            fprintf(outfile, "%s\n", caseless);            fprintf(outfile, "%s\n", caseless);
3279            }            }
3280          }          }
3281    
3282        if (maxlookbehind > 0)        if (maxlookbehind > 0)
3283          fprintf(outfile, "Max lookbehind = %d\n", maxlookbehind);          fprintf(outfile, "Max lookbehind = %d\n", maxlookbehind);
3284    
3285        /* Don't output study size; at present it is in any case a fixed        /* Don't output study size; at present it is in any case a fixed
3286        value, but it varies, depending on the computer architecture, and        value, but it varies, depending on the computer architecture, and
# Line 3908  while (!done) Line 3921  while (!done)
3921        }        }
3922  #endif  #endif
3923    
3924      /* Ensure that there is a JIT callback if we want to verify that JIT was      /* Ensure that there is a JIT callback if we want to verify that JIT was
3925      actually used. If jit_stack == NULL, no stack has yet been assigned. */      actually used. If jit_stack == NULL, no stack has yet been assigned. */
3926    
3927      if (verify_jit && jit_stack == NULL && extra != NULL)      if (verify_jit && jit_stack == NULL && extra != NULL)
# Line 3917  while (!done) Line 3930  while (!done)
3930      for (;; gmatched++)    /* Loop for /g or /G */      for (;; gmatched++)    /* Loop for /g or /G */
3931        {        {
3932        markptr = NULL;        markptr = NULL;
3933        jit_was_used = FALSE;        jit_was_used = FALSE;
3934    
3935        if (timeitm > 0)        if (timeitm > 0)
3936          {          {
# Line 3928  while (!done) Line 3941  while (!done)
3941  #if !defined NODFA  #if !defined NODFA
3942          if (all_use_dfa || use_dfa)          if (all_use_dfa || use_dfa)
3943            {            {
3944            int workspace[1000];            if ((options & PCRE_DFA_RESTART) != 0)
3945                {
3946                fprintf(outfile, "Timing DFA restarts is not supported\n");
3947                break;
3948                }
3949              if (dfa_workspace == NULL)
3950                dfa_workspace = (int *)malloc(DFA_WS_DIMENSION*sizeof(int));
3951            for (i = 0; i < timeitm; i++)            for (i = 0; i < timeitm; i++)
3952              {              {
3953              PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset,              PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset,
3954                (options | g_notempty), use_offsets, use_size_offsets, workspace,                (options | g_notempty), use_offsets, use_size_offsets,
3955                (sizeof(workspace)/sizeof(int)));                dfa_workspace, DFA_WS_DIMENSION);
3956              }              }
3957            }            }
3958          else          else
# Line 3999  while (!done) Line 4018  while (!done)
4018  #if !defined NODFA  #if !defined NODFA
4019        else if (all_use_dfa || use_dfa)        else if (all_use_dfa || use_dfa)
4020          {          {
4021          int workspace[1000];          if (dfa_workspace == NULL)
4022              dfa_workspace = (int *)malloc(DFA_WS_DIMENSION*sizeof(int));
4023            if (dfa_matched++ == 0)
4024              dfa_workspace[0] = -1;  /* To catch bad restart */
4025          PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset,          PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset,
4026            (options | g_notempty), use_offsets, use_size_offsets, workspace,            (options | g_notempty), use_offsets, use_size_offsets, dfa_workspace,
4027            (sizeof(workspace)/sizeof(int)));            DFA_WS_DIMENSION);
4028          if (count == 0)          if (count == 0)
4029            {            {
4030            fprintf(outfile, "Matched, but too many subsidiary matches\n");            fprintf(outfile, "Matched, but too many subsidiary matches\n");
# Line 4021  while (!done) Line 4043  while (!done)
4043            count = use_size_offsets/3;            count = use_size_offsets/3;
4044            }            }
4045          }          }
4046    
4047        /* Matched */        /* Matched */
4048    
4049        if (count >= 0)        if (count >= 0)
# Line 4079  while (!done) Line 4101  while (!done)
4101              fprintf(outfile, "%2d: ", i/2);              fprintf(outfile, "%2d: ", i/2);
4102              PCHARSV(bptr, use_offsets[i],              PCHARSV(bptr, use_offsets[i],
4103                use_offsets[i+1] - use_offsets[i], outfile);                use_offsets[i+1] - use_offsets[i], outfile);
4104              if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");              if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");
4105              fprintf(outfile, "\n");              fprintf(outfile, "\n");
4106              if (do_showcaprest || (i == 0 && do_showrest))              if (do_showcaprest || (i == 0 && do_showrest))
4107                {                {
# Line 4246  while (!done) Line 4268  while (!done)
4268            PCHARSV(bptr, use_offsets[0], use_offsets[1] - use_offsets[0],            PCHARSV(bptr, use_offsets[0], use_offsets[1] - use_offsets[0],
4269              outfile);              outfile);
4270            }            }
4271          if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");          if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");
4272          fprintf(outfile, "\n");          fprintf(outfile, "\n");
4273          break;  /* Out of the /g loop */          break;  /* Out of the /g loop */
4274          }          }
# Line 4333  while (!done) Line 4355  while (!done)
4355                  fprintf(outfile, "No match, mark = ");                  fprintf(outfile, "No match, mark = ");
4356                  PCHARSV(markptr, 0, -1, outfile);                  PCHARSV(markptr, 0, -1, outfile);
4357                  }                  }
4358                if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");                if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");
4359                putc('\n', outfile);                putc('\n', outfile);
4360                }                }
4361              break;              break;

Legend:
Removed from v.959  
changed lines
  Added in v.960

  ViewVC Help
Powered by ViewVC 1.1.5