/[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 895 by ph10, Fri Jan 20 12:12:03 2012 UTC revision 1017 by ph10, Sun Aug 26 16:30:50 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 59  only supported library functions. */ Line 58  only supported library functions. */
58  #include <locale.h>  #include <locale.h>
59  #include <errno.h>  #include <errno.h>
60    
61  #ifdef SUPPORT_LIBREADLINE  /* 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
63    it is installed as editline/readline.h, so the configuration code now looks for
64    that first, falling back to readline/readline.h. */
65    
66    #if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
67  #ifdef HAVE_UNISTD_H  #ifdef HAVE_UNISTD_H
68  #include <unistd.h>  #include <unistd.h>
69  #endif  #endif
70    #if defined(SUPPORT_LIBREADLINE)
71  #include <readline/readline.h>  #include <readline/readline.h>
72  #include <readline/history.h>  #include <readline/history.h>
73    #else
74    #if defined(HAVE_EDITLINE_READLINE_H)
75    #include <editline/readline.h>
76    #else
77    #include <readline/readline.h>
78    #endif
79    #endif
80  #endif  #endif
   
81    
82  /* A number of things vary for Windows builds. Originally, pcretest opened its  /* A number of things vary for Windows builds. Originally, pcretest opened its
83  input and output without "b"; then I was told that "b" was needed in some  input and output without "b"; then I was told that "b" was needed in some
# Line 105  input mode under Windows. */ Line 116  input mode under Windows. */
116  #define OUTPUT_MODE  "wb"  #define OUTPUT_MODE  "wb"
117  #endif  #endif
118    
119    #define PRIV(name) name
120    
121  /* We have to include pcre_internal.h because we need the internal info for  /* We have to include pcre_internal.h because we need the internal info for
122  displaying the results of pcre_study() and we also need to know about the  displaying the results of pcre_study() and we also need to know about the
# Line 141  to keep two copies, we include the sourc Line 153  to keep two copies, we include the sourc
153  external symbols to prevent clashes. */  external symbols to prevent clashes. */
154    
155  #define PCRE_INCLUDED  #define PCRE_INCLUDED
 #undef PRIV  
 #define PRIV(name) name  
156    
157  #include "pcre_tables.c"  #include "pcre_tables.c"
158    
# Line 600  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 614  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;
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 675  static int use_pcre16 = 0; Line 690  static int use_pcre16 = 0;
690  static int use_pcre16 = 1;  static int use_pcre16 = 1;
691  #endif  #endif
692    
693    /* JIT study options for -s+n and /S+n where '1' <= n <= '7'. */
694    
695    static int jit_study_bits[] =
696      {
697      PCRE_STUDY_JIT_COMPILE,
698      PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE,
699      PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE,
700      PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE,
701      PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE,
702      PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE + PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE,
703      PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE +
704        PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE
705    };
706    
707  /* Textual explanations for runtime error codes */  /* Textual explanations for runtime error codes */
708    
709  static const char *errtexts[] = {  static const char *errtexts[] = {
# Line 706  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 1064  return sys_errlist[n]; Line 1095  return sys_errlist[n];
1095    
1096  static pcre_jit_stack* jit_callback(void *arg)  static pcre_jit_stack* jit_callback(void *arg)
1097  {  {
1098    jit_was_used = TRUE;
1099  return (pcre_jit_stack *)arg;  return (pcre_jit_stack *)arg;
1100  }  }
1101    
# Line 1271  pcre_uint8 *here = start; Line 1303  pcre_uint8 *here = start;
1303    
1304  for (;;)  for (;;)
1305    {    {
1306    int rlen = (int)(buffer_size - (here - buffer));    size_t rlen = (size_t)(buffer_size - (here - buffer));
1307    
1308    if (rlen > 1000)    if (rlen > 1000)
1309      {      {
1310      int dlen;      int dlen;
1311    
1312      /* If libreadline support is required, use readline() to read a line if the      /* If libreadline or libedit support is required, use readline() to read a
1313      input is a terminal. Note that readline() removes the trailing newline, so      line if the input is a terminal. Note that readline() removes the trailing
1314      we must put it back again, to be compatible with fgets(). */      newline, so we must put it back again, to be compatible with fgets(). */
1315    
1316  #ifdef SUPPORT_LIBREADLINE  #if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
1317      if (isatty(fileno(f)))      if (isatty(fileno(f)))
1318        {        {
1319        size_t len;        size_t len;
# Line 2097  usage(void) Line 2129  usage(void)
2129  {  {
2130  printf("Usage:     pcretest [options] [<input file> [<output file>]]\n\n");  printf("Usage:     pcretest [options] [<input file> [<output file>]]\n\n");
2131  printf("Input and output default to stdin and stdout.\n");  printf("Input and output default to stdin and stdout.\n");
2132  #ifdef SUPPORT_LIBREADLINE  #if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
2133  printf("If input is a terminal, readline() is used to read from it.\n");  printf("If input is a terminal, readline() is used to read from it.\n");
2134  #else  #else
2135  printf("This version of pcretest is not linked with readline().\n");  printf("This version of pcretest is not linked with readline().\n");
# Line 2133  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"
2169           "  -s+n     force each pattern to be studied, using JIT if available,\n"
2170           "             where 1 <= n <= 7 selects JIT options\n"
2171           "  -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 2167  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;
2209    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 2234  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];
2279    
2280      if (strcmp(arg, "-m") == 0) showstore = 1;
2281      else if (strcmp(arg, "-s") == 0) force_study = 0;
2282    
2283    if (strcmp(argv[op], "-m") == 0) showstore = 1;    else if (strncmp(arg, "-s+", 3) == 0)
   else if (strcmp(argv[op], "-s") == 0) force_study = 0;  
   else if (strcmp(argv[op], "-s+") == 0)  
2284      {      {
2285        arg += 3;
2286        if (*arg == '+') { arg++; verify_jit = TRUE; }
2287      force_study = 1;      force_study = 1;
2288      force_study_options = PCRE_STUDY_JIT_COMPILE;      if (*arg == 0)
2289          force_study_options = jit_study_bits[6];
2290        else if (*arg >= '1' && *arg <= '7')
2291          force_study_options = jit_study_bits[*arg - '1'];
2292        else goto BAD_ARG;
2293      }      }
2294    else if (strcmp(argv[op], "-16") == 0)    else if (strcmp(arg, "-16") == 0)
2295      {      {
2296  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
2297      use_pcre16 = 1;      use_pcre16 = 1;
# Line 2251  while (argc > 1 && argv[op][0] == '-') Line 2300  while (argc > 1 && argv[op][0] == '-')
2300      exit(1);      exit(1);
2301  #endif  #endif
2302      }      }
2303    else if (strcmp(argv[op], "-q") == 0) quiet = 1;    else if (strcmp(arg, "-q") == 0) quiet = 1;
2304    else if (strcmp(argv[op], "-b") == 0) debug = 1;    else if (strcmp(arg, "-b") == 0) debug = 1;
2305    else if (strcmp(argv[op], "-i") == 0) showinfo = 1;    else if (strcmp(arg, "-i") == 0) showinfo = 1;
2306    else if (strcmp(argv[op], "-d") == 0) showinfo = debug = 1;    else if (strcmp(arg, "-d") == 0) showinfo = debug = 1;
2307    else if (strcmp(argv[op], "-M") == 0) default_find_match_limit = TRUE;    else if (strcmp(arg, "-M") == 0) default_find_match_limit = TRUE;
2308  #if !defined NODFA  #if !defined NODFA
2309    else if (strcmp(argv[op], "-dfa") == 0) all_use_dfa = 1;    else if (strcmp(arg, "-dfa") == 0) all_use_dfa = 1;
2310  #endif  #endif
2311    else if (strcmp(argv[op], "-o") == 0 && argc > 2 &&    else if (strcmp(arg, "-o") == 0 && argc > 2 &&
2312        ((size_offsets = get_value((pcre_uint8 *)argv[op+1], &endptr)),        ((size_offsets = get_value((pcre_uint8 *)argv[op+1], &endptr)),
2313          *endptr == 0))          *endptr == 0))
2314      {      {
2315      op++;      op++;
2316      argc--;      argc--;
2317      }      }
2318    else if (strcmp(argv[op], "-t") == 0 || strcmp(argv[op], "-tm") == 0)    else if (strcmp(arg, "-t") == 0 || strcmp(arg, "-tm") == 0)
2319      {      {
2320      int both = argv[op][2] == 0;      int both = arg[2] == 0;
2321      int temp;      int temp;
2322      if (argc > 2 && (temp = get_value((pcre_uint8 *)argv[op+1], &endptr),      if (argc > 2 && (temp = get_value((pcre_uint8 *)argv[op+1], &endptr),
2323                       *endptr == 0))                       *endptr == 0))
# Line 2280  while (argc > 1 && argv[op][0] == '-') Line 2329  while (argc > 1 && argv[op][0] == '-')
2329      else timeitm = LOOPREPEAT;      else timeitm = LOOPREPEAT;
2330      if (both) timeit = timeitm;      if (both) timeit = timeitm;
2331      }      }
2332    else if (strcmp(argv[op], "-S") == 0 && argc > 2 &&    else if (strcmp(arg, "-S") == 0 && argc > 2 &&
2333        ((stack_size = get_value((pcre_uint8 *)argv[op+1], &endptr)),        ((stack_size = get_value((pcre_uint8 *)argv[op+1], &endptr)),
2334          *endptr == 0))          *endptr == 0))
2335      {      {
# Line 2303  while (argc > 1 && argv[op][0] == '-') Line 2352  while (argc > 1 && argv[op][0] == '-')
2352  #endif  #endif
2353      }      }
2354  #if !defined NOPOSIX  #if !defined NOPOSIX
2355    else if (strcmp(argv[op], "-p") == 0) posix = 1;    else if (strcmp(arg, "-p") == 0) posix = 1;
2356  #endif  #endif
2357    else if (strcmp(argv[op], "-C") == 0)    else if (strcmp(arg, "-C") == 0)
2358      {      {
2359      int rc;      int rc;
2360      unsigned long int lrc;      unsigned long int lrc;
# Line 2412  are set, either both UTFs are supported Line 2461  are set, either both UTFs are supported
2461      if (rc)      if (rc)
2462        {        {
2463        const char *arch;        const char *arch;
2464        (void)PCRE_CONFIG(PCRE_CONFIG_JITTARGET, &arch);        (void)PCRE_CONFIG(PCRE_CONFIG_JITTARGET, (void *)(&arch));
2465        printf("  Just-in-time compiler support: %s\n", arch);        printf("  Just-in-time compiler support: %s\n", arch);
2466        }        }
2467      else      else
2468        printf("  No just-in-time compiler support\n");        printf("  No just-in-time compiler support\n");
2469      (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);      (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);
# Line 2438  are set, either both UTFs are supported Line 2487  are set, either both UTFs are supported
2487      (void)PCRE_CONFIG(PCRE_CONFIG_STACKRECURSE, &rc);      (void)PCRE_CONFIG(PCRE_CONFIG_STACKRECURSE, &rc);
2488      printf("  Match recursion uses %s", rc? "stack" : "heap");      printf("  Match recursion uses %s", rc? "stack" : "heap");
2489      if (showstore)      if (showstore)
2490        {        {
2491        PCRE_EXEC(stack_size, NULL, NULL, NULL, -1, -1, 0, NULL, 0);        PCRE_EXEC(stack_size, NULL, NULL, NULL, -999, -999, 0, NULL, 0);
2492        printf(": %sframe size = %d bytes", rc? "approximate " : "", -stack_size);        printf(": %sframe size = %d bytes", rc? "approximate " : "", -stack_size);
2493        }        }
2494      printf("\n");      printf("\n");
2495      goto EXIT;      goto EXIT;
2496      }      }
2497    else if (strcmp(argv[op], "-help") == 0 ||    else if (strcmp(arg, "-help") == 0 ||
2498             strcmp(argv[op], "--help") == 0)             strcmp(arg, "--help") == 0)
2499      {      {
2500      usage();      usage();
2501      goto EXIT;      goto EXIT;
2502      }      }
2503    else    else
2504      {      {
2505      printf("** Unknown or malformed option %s\n", argv[op]);      BAD_ARG:
2506        printf("** Unknown or malformed option %s\n", arg);
2507      usage();      usage();
2508      yield = 1;      yield = 1;
2509      goto EXIT;      goto EXIT;
# Line 2551  while (!done) Line 2601  while (!done)
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;
2610    
# Line 2598  while (!done) Line 2652  while (!done)
2652        (sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7];        (sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7];
2653    
2654      re = (pcre *)new_malloc(true_size);      re = (pcre *)new_malloc(true_size);
2655        if (re == NULL)
2656          {
2657          printf("** Failed to get %d bytes of memory for pcre object\n",
2658            (int)true_size);
2659          yield = 1;
2660          goto EXIT;
2661          }
2662      regex_gotten_store = first_gotten_store;      regex_gotten_store = first_gotten_store;
2663    
2664      if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ;      if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ;
# Line 2612  while (!done) Line 2673  while (!done)
2673        else        else
2674          {          {
2675          fprintf(outfile, "Data in %s is not a compiled PCRE regex\n", p);          fprintf(outfile, "Data in %s is not a compiled PCRE regex\n", p);
2676            new_free(re);
2677          fclose(f);          fclose(f);
2678          continue;          continue;
2679          }          }
# Line 2641  while (!done) Line 2703  while (!done)
2703            {            {
2704            PCRE_FREE_STUDY(extra);            PCRE_FREE_STUDY(extra);
2705            }            }
2706          if (re != NULL) new_free(re);          new_free(re);
2707          fclose(f);          fclose(f);
2708          continue;          continue;
2709          }          }
# Line 2662  while (!done) Line 2724  while (!done)
2724            use_pcre16? "16" : "", PCRE_INFO_OPTIONS);            use_pcre16? "16" : "", PCRE_INFO_OPTIONS);
2725          fprintf(outfile, "Running in %s-bit mode but pattern was compiled in "          fprintf(outfile, "Running in %s-bit mode but pattern was compiled in "
2726            "%s-bit mode\n", use_pcre16? "16":"8", use_pcre16? "8":"16");            "%s-bit mode\n", use_pcre16? "16":"8", use_pcre16? "8":"16");
2727            new_free(re);
2728            fclose(f);
2729          continue;          continue;
2730          }          }
2731        }        }
2732    
2733      /* Need to know if UTF-8 for printing data strings. */      /* Need to know if UTF-8 for printing data strings. */
2734    
2735      if (new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options) < 0) continue;      if (new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options) < 0)
2736          {
2737          new_free(re);
2738          fclose(f);
2739          continue;
2740          }
2741      use_utf = (get_options & PCRE_UTF8) != 0;      use_utf = (get_options & PCRE_UTF8) != 0;
2742    
2743      fclose(f);      fclose(f);
# Line 2769  while (!done) Line 2838  while (!done)
2838          do_study = 1;          do_study = 1;
2839          if (*pp == '+')          if (*pp == '+')
2840            {            {
2841            study_options |= PCRE_STUDY_JIT_COMPILE;            if (*(++pp) == '+')
2842            pp++;              {
2843                verify_jit = TRUE;
2844                pp++;
2845                }
2846              if (*pp >= '1' && *pp <= '7')
2847                study_options |= jit_study_bits[*pp++ - '1'];
2848              else
2849                study_options |= jit_study_bits[6];
2850            }            }
2851          }          }
2852        else        else
# Line 3063  while (!done) Line 3139  while (!done)
3139        {        {
3140        unsigned long int all_options;        unsigned long int all_options;
3141        int count, backrefmax, first_char, need_char, okpartial, jchanged,        int count, backrefmax, first_char, need_char, okpartial, jchanged,
3142          hascrorlf;          hascrorlf, maxlookbehind;
3143        int nameentrysize, namecount;        int nameentrysize, namecount;
3144        const pcre_uint8 *nametable;        const pcre_uint8 *nametable;
3145    
# Line 3077  while (!done) Line 3153  while (!done)
3153            new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable) +            new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable) +
3154            new_info(re, NULL, PCRE_INFO_OKPARTIAL, &okpartial) +            new_info(re, NULL, PCRE_INFO_OKPARTIAL, &okpartial) +
3155            new_info(re, NULL, PCRE_INFO_JCHANGED, &jchanged) +            new_info(re, NULL, PCRE_INFO_JCHANGED, &jchanged) +
3156            new_info(re, NULL, PCRE_INFO_HASCRORLF, &hascrorlf)            new_info(re, NULL, PCRE_INFO_HASCRORLF, &hascrorlf) +
3157              new_info(re, NULL, PCRE_INFO_MAXLOOKBEHIND, &maxlookbehind)
3158            != 0)            != 0)
3159          goto SKIP_DATA;          goto SKIP_DATA;
3160    
# Line 3217  while (!done) Line 3294  while (!done)
3294            }            }
3295          }          }
3296    
3297          if (maxlookbehind > 0)
3298            fprintf(outfile, "Max lookbehind = %d\n", maxlookbehind);
3299    
3300        /* 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
3301        value, but it varies, depending on the computer architecture, and        value, but it varies, depending on the computer architecture, and
3302        so messes up the test suite. (And with the /F option, it might be        so messes up the test suite. (And with the /F option, it might be
# Line 3385  while (!done) Line 3465  while (!done)
3465      cn16ptr = copynames;      cn16ptr = copynames;
3466      gn16ptr = getnames;      gn16ptr = getnames;
3467  #endif  #endif
3468  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
3469      cn8ptr = copynames8;      cn8ptr = copynames8;
3470      gn8ptr = getnames8;      gn8ptr = getnames8;
3471  #endif  #endif
3472    
3473      SET_PCRE_CALLOUT(callout);      SET_PCRE_CALLOUT(callout);
3474      first_callout = 1;      first_callout = 1;
# Line 3483  while (!done) Line 3563  while (!done)
3563              {              {
3564              if (++i == 9)              if (++i == 9)
3565                fprintf(outfile, "** Too many hex digits in \\x{...} item; "                fprintf(outfile, "** Too many hex digits in \\x{...} item; "
3566                                 "using only the first eight.\n");                                 "using only the first eight.\n");
3567              else c = c * 16 + tolower(*pt) - ((isdigit(*pt))? '0' : 'a' - 10);              else c = c * 16 + tolower(*pt) - ((isdigit(*pt))? '0' : 'a' - 10);
3568              }              }
3569            if (*pt == '}')            if (*pt == '}')
3570              {              {
3571              p = pt + 1;              p = pt + 1;
# Line 3654  while (!done) Line 3734  while (!done)
3734            }            }
3735          use_size_offsets = n;          use_size_offsets = n;
3736          if (n == 0) use_offsets = NULL;   /* Ensures it can't write to it */          if (n == 0) use_offsets = NULL;   /* Ensures it can't write to it */
3737              else use_offsets = offsets + size_offsets_max - n;  /* To catch overruns */
3738          continue;          continue;
3739    
3740          case 'P':          case 'P':
# Line 3856  while (!done) Line 3937  while (!done)
3937        }        }
3938  #endif  #endif
3939    
3940        /* Ensure that there is a JIT callback if we want to verify that JIT was
3941        actually used. If jit_stack == NULL, no stack has yet been assigned. */
3942    
3943        if (verify_jit && jit_stack == NULL && extra != NULL)
3944           { PCRE_ASSIGN_JIT_STACK(extra, jit_callback, jit_stack); }
3945    
3946      for (;; gmatched++)    /* Loop for /g or /G */      for (;; gmatched++)    /* Loop for /g or /G */
3947        {        {
3948        markptr = NULL;        markptr = NULL;
3949          jit_was_used = FALSE;
3950    
3951        if (timeitm > 0)        if (timeitm > 0)
3952          {          {
# Line 3869  while (!done) Line 3957  while (!done)
3957  #if !defined NODFA  #if !defined NODFA
3958          if (all_use_dfa || use_dfa)          if (all_use_dfa || use_dfa)
3959            {            {
3960            int workspace[1000];            if ((options & PCRE_DFA_RESTART) != 0)
3961                {
3962                fprintf(outfile, "Timing DFA restarts is not supported\n");
3963                break;
3964                }
3965              if (dfa_workspace == NULL)
3966                dfa_workspace = (int *)malloc(DFA_WS_DIMENSION*sizeof(int));
3967            for (i = 0; i < timeitm; i++)            for (i = 0; i < timeitm; i++)
3968              {              {
3969              PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset,              PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset,
3970                (options | g_notempty), use_offsets, use_size_offsets, workspace,                (options | g_notempty), use_offsets, use_size_offsets,
3971                (sizeof(workspace)/sizeof(int)));                dfa_workspace, DFA_WS_DIMENSION);
3972              }              }
3973            }            }
3974          else          else
# Line 3900  while (!done) Line 3994  while (!done)
3994    
3995        if (find_match_limit)        if (find_match_limit)
3996          {          {
3997          if (extra == NULL)          if (extra != NULL) { PCRE_FREE_STUDY(extra); }
3998            {          extra = (pcre_extra *)malloc(sizeof(pcre_extra));
3999            extra = (pcre_extra *)malloc(sizeof(pcre_extra));          extra->flags = 0;
           extra->flags = 0;  
           }  
         else extra->flags &= ~PCRE_EXTRA_EXECUTABLE_JIT;  
4000    
4001          (void)check_match_limit(re, extra, bptr, len, start_offset,          (void)check_match_limit(re, extra, bptr, len, start_offset,
4002            options|g_notempty, use_offsets, use_size_offsets,            options|g_notempty, use_offsets, use_size_offsets,
# Line 3940  while (!done) Line 4031  while (!done)
4031  #if !defined NODFA  #if !defined NODFA
4032        else if (all_use_dfa || use_dfa)        else if (all_use_dfa || use_dfa)
4033          {          {
4034          int workspace[1000];          if (dfa_workspace == NULL)
4035              dfa_workspace = (int *)malloc(DFA_WS_DIMENSION*sizeof(int));
4036            if (dfa_matched++ == 0)
4037              dfa_workspace[0] = -1;  /* To catch bad restart */
4038          PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset,          PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset,
4039            (options | g_notempty), use_offsets, use_size_offsets, workspace,            (options | g_notempty), use_offsets, use_size_offsets, dfa_workspace,
4040            (sizeof(workspace)/sizeof(int)));            DFA_WS_DIMENSION);
4041          if (count == 0)          if (count == 0)
4042            {            {
4043            fprintf(outfile, "Matched, but too many subsidiary matches\n");            fprintf(outfile, "Matched, but too many subsidiary matches\n");
# Line 4020  while (!done) Line 4114  while (!done)
4114              fprintf(outfile, "%2d: ", i/2);              fprintf(outfile, "%2d: ", i/2);
4115              PCHARSV(bptr, use_offsets[i],              PCHARSV(bptr, use_offsets[i],
4116                use_offsets[i+1] - use_offsets[i], outfile);                use_offsets[i+1] - use_offsets[i], outfile);
4117                if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");
4118              fprintf(outfile, "\n");              fprintf(outfile, "\n");
4119              if (do_showcaprest || (i == 0 && do_showrest))              if (do_showcaprest || (i == 0 && do_showrest))
4120                {                {
# Line 4186  while (!done) Line 4281  while (!done)
4281            PCHARSV(bptr, use_offsets[0], use_offsets[1] - use_offsets[0],            PCHARSV(bptr, use_offsets[0], use_offsets[1] - use_offsets[0],
4282              outfile);              outfile);
4283            }            }
4284            if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");
4285          fprintf(outfile, "\n");          fprintf(outfile, "\n");
4286          break;  /* Out of the /g loop */          break;  /* Out of the /g loop */
4287          }          }
# Line 4265  while (!done) Line 4361  while (!done)
4361                {                {
4362                if (markptr == NULL)                if (markptr == NULL)
4363                  {                  {
4364                  fprintf(outfile, "No match\n");                  fprintf(outfile, "No match");
4365                  }                  }
4366                else                else
4367                  {                  {
4368                  fprintf(outfile, "No match, mark = ");                  fprintf(outfile, "No match, mark = ");
4369                  PCHARSV(markptr, 0, -1, outfile);                  PCHARSV(markptr, 0, -1, outfile);
                 putc('\n', outfile);  
4370                  }                  }
4371                  if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");
4372                  putc('\n', outfile);
4373                }                }
4374              break;              break;
4375    
# Line 4293  while (!done) Line 4390  while (!done)
4390              break;              break;
4391    
4392              default:              default:
4393              if (count < 0 && (-count) < sizeof(errtexts)/sizeof(const char *))              if (count < 0 &&
4394                    (-count) < (int)(sizeof(errtexts)/sizeof(const char *)))
4395                fprintf(outfile, "Error %d (%s)\n", count, errtexts[-count]);                fprintf(outfile, "Error %d (%s)\n", count, errtexts[-count]);
4396              else              else
4397                fprintf(outfile, "Error %d (Unexpected value)\n", count);                fprintf(outfile, "Error %d (Unexpected value)\n", count);
# Line 4379  free(offsets); Line 4477  free(offsets);
4477  if (buffer16 != NULL) free(buffer16);  if (buffer16 != NULL) free(buffer16);
4478  #endif  #endif
4479    
4480    #if !defined NODFA
4481    if (dfa_workspace != NULL)
4482      free(dfa_workspace);
4483    #endif
4484    
4485  return yield;  return yield;
4486  }  }
4487    

Legend:
Removed from v.895  
changed lines
  Added in v.1017

  ViewVC Help
Powered by ViewVC 1.1.5