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

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

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

revision 455 by ph10, Sat Sep 26 19:12:32 2009 UTC revision 512 by ph10, Tue Mar 30 11:11:52 2010 UTC
# Line 118  external symbols to prevent clashes. */ Line 118  external symbols to prevent clashes. */
118    
119  /* We also need the pcre_printint() function for printing out compiled  /* We also need the pcre_printint() function for printing out compiled
120  patterns. This function is in a separate file so that it can be included in  patterns. This function is in a separate file so that it can be included in
121  pcre_compile.c when that module is compiled with debugging enabled.  pcre_compile.c when that module is compiled with debugging enabled. It needs to
122    know which case is being compiled. */
 The definition of the macro PRINTABLE, which determines whether to print an  
 output character as-is or as a hex value when showing compiled patterns, is  
 contained in this file. We uses it here also, in cases when the locale has not  
 been explicitly changed, so as to get consistent output from systems that  
 differ in their output from isprint() even in the "C" locale. */  
123    
124    #define COMPILING_PCRETEST
125  #include "pcre_printint.src"  #include "pcre_printint.src"
126    
127  #define PRINTHEX(c) (locale_set? isprint(c) : PRINTABLE(c))  /* The definition of the macro PRINTABLE, which determines whether to print an
128    output character as-is or as a hex value when showing compiled patterns, is
129    contained in the printint.src file. We uses it here also, in cases when the
130    locale has not been explicitly changed, so as to get consistent output from
131    systems that differ in their output from isprint() even in the "C" locale. */
132    
133    #define PRINTHEX(c) (locale_set? isprint(c) : PRINTABLE(c))
134    
135  /* It is possible to compile this test program without including support for  /* It is possible to compile this test program without including support for
136  testing the POSIX interface, though this is not available via the standard  testing the POSIX interface, though this is not available via the standard
# Line 1039  while (!done) Line 1040  while (!done)
1040  #endif  #endif
1041    
1042    const char *error;    const char *error;
1043      unsigned char *markptr;
1044    unsigned char *p, *pp, *ppp;    unsigned char *p, *pp, *ppp;
1045    unsigned char *to_file = NULL;    unsigned char *to_file = NULL;
1046    const unsigned char *tables = NULL;    const unsigned char *tables = NULL;
1047    unsigned long int true_size, true_study_size = 0;    unsigned long int true_size, true_study_size = 0;
1048    size_t size, regex_gotten_store;    size_t size, regex_gotten_store;
1049      int do_mark = 0;
1050    int do_study = 0;    int do_study = 0;
1051    int do_debug = debug;    int do_debug = debug;
1052    int do_G = 0;    int do_G = 0;
# Line 1225  while (!done) Line 1228  while (!done)
1228        case 'G': do_G = 1; break;        case 'G': do_G = 1; break;
1229        case 'I': do_showinfo = 1; break;        case 'I': do_showinfo = 1; break;
1230        case 'J': options |= PCRE_DUPNAMES; break;        case 'J': options |= PCRE_DUPNAMES; break;
1231          case 'K': do_mark = 1; break;
1232        case 'M': log_store = 1; break;        case 'M': log_store = 1; break;
1233        case 'N': options |= PCRE_NO_AUTO_CAPTURE; break;        case 'N': options |= PCRE_NO_AUTO_CAPTURE; break;
1234    
# Line 1305  while (!done) Line 1309  while (!done)
1309      if ((options & PCRE_DOTALL) != 0) cflags |= REG_DOTALL;      if ((options & PCRE_DOTALL) != 0) cflags |= REG_DOTALL;
1310      if ((options & PCRE_NO_AUTO_CAPTURE) != 0) cflags |= REG_NOSUB;      if ((options & PCRE_NO_AUTO_CAPTURE) != 0) cflags |= REG_NOSUB;
1311      if ((options & PCRE_UTF8) != 0) cflags |= REG_UTF8;      if ((options & PCRE_UTF8) != 0) cflags |= REG_UTF8;
1312      if ((options & PCRE_UNGREEDY) != 0) cflags |= REG_UNGREEDY;      if ((options & PCRE_UNGREEDY) != 0) cflags |= REG_UNGREEDY;
1313    
1314      rc = regcomp(&preg, (char *)p, cflags);      rc = regcomp(&preg, (char *)p, cflags);
1315    
# Line 1419  while (!done) Line 1423  while (!done)
1423          true_study_size = ((pcre_study_data *)(extra->study_data))->size;          true_study_size = ((pcre_study_data *)(extra->study_data))->size;
1424        }        }
1425    
1426        /* If /K was present, we set up for handling MARK data. */
1427    
1428        if (do_mark)
1429          {
1430          if (extra == NULL)
1431            {
1432            extra = (pcre_extra *)malloc(sizeof(pcre_extra));
1433            extra->flags = 0;
1434            }
1435          extra->mark = &markptr;
1436          extra->flags |= PCRE_EXTRA_MARK;
1437          }
1438    
1439      /* If the 'F' option was present, we flip the bytes of all the integer      /* If the 'F' option was present, we flip the bytes of all the integer
1440      fields in the regex data block and the study block. This is to make it      fields in the regex data block and the study block. This is to make it
1441      possible to test PCRE's handling of byte-flipped patterns, e.g. those      possible to test PCRE's handling of byte-flipped patterns, e.g. those
# Line 1630  while (!done) Line 1647  while (!done)
1647            {            {
1648            uschar *start_bits = NULL;            uschar *start_bits = NULL;
1649            int minlength;            int minlength;
1650    
1651            new_info(re, extra, PCRE_INFO_MINLENGTH, &minlength);            new_info(re, extra, PCRE_INFO_MINLENGTH, &minlength);
1652            fprintf(outfile, "Subject length lower bound = %d\n", minlength);            fprintf(outfile, "Subject length lower bound = %d\n", minlength);
1653    
1654            new_info(re, extra, PCRE_INFO_FIRSTTABLE, &start_bits);            new_info(re, extra, PCRE_INFO_FIRSTTABLE, &start_bits);
1655            if (start_bits == NULL)            if (start_bits == NULL)
1656              fprintf(outfile, "No set of starting bytes\n");              fprintf(outfile, "No set of starting bytes\n");
# Line 1977  while (!done) Line 1994  while (!done)
1994          case 'N':          case 'N':
1995          if ((options & PCRE_NOTEMPTY) != 0)          if ((options & PCRE_NOTEMPTY) != 0)
1996            options = (options & ~PCRE_NOTEMPTY) | PCRE_NOTEMPTY_ATSTART;            options = (options & ~PCRE_NOTEMPTY) | PCRE_NOTEMPTY_ATSTART;
1997          else          else
1998            options |= PCRE_NOTEMPTY;            options |= PCRE_NOTEMPTY;
1999          continue;          continue;
2000    
# Line 2001  while (!done) Line 2018  while (!done)
2018          continue;          continue;
2019    
2020          case 'P':          case 'P':
2021          options |= ((options & PCRE_PARTIAL_SOFT) == 0)?          options |= ((options & PCRE_PARTIAL_SOFT) == 0)?
2022            PCRE_PARTIAL_SOFT : PCRE_PARTIAL_HARD;            PCRE_PARTIAL_SOFT : PCRE_PARTIAL_HARD;
2023          continue;          continue;
2024    
# Line 2144  while (!done) Line 2161  while (!done)
2161    
2162      for (;; gmatched++)    /* Loop for /g or /G */      for (;; gmatched++)    /* Loop for /g or /G */
2163        {        {
2164          markptr = NULL;
2165    
2166        if (timeitm > 0)        if (timeitm > 0)
2167          {          {
2168          register int i;          register int i;
# Line 2289  while (!done) Line 2308  while (!done)
2308              }              }
2309            }            }
2310    
2311            if (markptr != NULL) fprintf(outfile, "MK: %s\n", markptr);
2312    
2313          for (i = 0; i < 32; i++)          for (i = 0; i < 32; i++)
2314            {            {
2315            if ((copystrings & (1 << i)) != 0)            if ((copystrings & (1 << i)) != 0)
# Line 2372  while (!done) Line 2393  while (!done)
2393    
2394        else if (count == PCRE_ERROR_PARTIAL)        else if (count == PCRE_ERROR_PARTIAL)
2395          {          {
2396          fprintf(outfile, "Partial match");          if (markptr == NULL) fprintf(outfile, "Partial match");
2397              else fprintf(outfile, "Partial match, mark=%s", markptr);
2398          if (use_size_offsets > 1)          if (use_size_offsets > 1)
2399            {            {
2400            fprintf(outfile, ": ");            fprintf(outfile, ": ");
2401            pchars(bptr + use_offsets[0], use_offsets[1] - use_offsets[0],            pchars(bptr + use_offsets[0], use_offsets[1] - use_offsets[0],
2402              outfile);              outfile);
2403            }            }
2404          fprintf(outfile, "\n");          fprintf(outfile, "\n");
2405          break;  /* Out of the /g loop */          break;  /* Out of the /g loop */
2406          }          }
# Line 2439  while (!done) Line 2461  while (!done)
2461            {            {
2462            if (count == PCRE_ERROR_NOMATCH)            if (count == PCRE_ERROR_NOMATCH)
2463              {              {
2464              if (gmatched == 0) fprintf(outfile, "No match\n");              if (gmatched == 0)
2465                  {
2466                  if (markptr == NULL) fprintf(outfile, "No match\n");
2467                    else fprintf(outfile, "No match, mark = %s\n", markptr);
2468                  }
2469              }              }
2470            else fprintf(outfile, "Error %d\n", count);            else fprintf(outfile, "Error %d\n", count);
2471            break;  /* Out of the /g loop */            break;  /* Out of the /g loop */

Legend:
Removed from v.455  
changed lines
  Added in v.512

  ViewVC Help
Powered by ViewVC 1.1.5