/[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 78 by nigel, Sat Feb 24 21:40:45 2007 UTC revision 79 by nigel, Sat Feb 24 21:40:52 2007 UTC
# Line 62  Makefile. */ Line 62  Makefile. */
62  #include "pcreposix.h"  #include "pcreposix.h"
63  #endif  #endif
64    
65    /* It is also possible, for the benefit of the version imported into Exim, to
66    build pcretest without support for UTF8 (define NOUTF8), without the interface
67    to the DFA matcher (NODFA), and without the doublecheck of the old "info"
68    function (define NOINFOCHECK). */
69    
70    
71  #ifndef CLOCKS_PER_SEC  #ifndef CLOCKS_PER_SEC
72  #ifdef CLK_TCK  #ifdef CLK_TCK
73  #define CLOCKS_PER_SEC CLK_TCK  #define CLOCKS_PER_SEC CLK_TCK
# Line 135  Returns: > 0 => the number of bytes c Line 141  Returns: > 0 => the number of bytes c
141             -6 to 0 => malformed UTF-8 character at offset = (-return)             -6 to 0 => malformed UTF-8 character at offset = (-return)
142  */  */
143    
144    #if !defined NOUTF8
145    
146  static int  static int
147  utf82ord(unsigned char *buffer, int *vptr)  utf82ord(unsigned char *buffer, int *vptr)
148  {  {
# Line 176  if (j != i) return -(i+1); Line 184  if (j != i) return -(i+1);
184  return i+1;  return i+1;
185  }  }
186    
187    #endif
188    
189    
190    
191  /*************************************************  /*************************************************
# Line 193  int yield = 0; Line 203  int yield = 0;
203    
204  while (length-- > 0)  while (length-- > 0)
205    {    {
206    #if !defined NOUTF8
207    if (use_utf8)    if (use_utf8)
208      {      {
209      int rc = utf82ord(p, &c);      int rc = utf82ord(p, &c);
# Line 215  while (length-- > 0) Line 226  while (length-- > 0)
226        continue;        continue;
227        }        }
228      }      }
229    #endif
230    
231     /* Not UTF-8, or malformed UTF-8  */     /* Not UTF-8, or malformed UTF-8  */
232    
# Line 464  while (argc > 1 && argv[op][0] == '-') Line 476  while (argc > 1 && argv[op][0] == '-')
476    else if (strcmp(argv[op], "-t") == 0) timeit = 1;    else if (strcmp(argv[op], "-t") == 0) timeit = 1;
477    else if (strcmp(argv[op], "-i") == 0) showinfo = 1;    else if (strcmp(argv[op], "-i") == 0) showinfo = 1;
478    else if (strcmp(argv[op], "-d") == 0) showinfo = debug = 1;    else if (strcmp(argv[op], "-d") == 0) showinfo = debug = 1;
479    #if !defined NODFA
480    else if (strcmp(argv[op], "-dfa") == 0) all_use_dfa = 1;    else if (strcmp(argv[op], "-dfa") == 0) all_use_dfa = 1;
481    #endif
482    else if (strcmp(argv[op], "-o") == 0 && argc > 2 &&    else if (strcmp(argv[op], "-o") == 0 && argc > 2 &&
483        ((size_offsets = get_value((unsigned char *)argv[op+1], &endptr)),        ((size_offsets = get_value((unsigned char *)argv[op+1], &endptr)),
484          *endptr == 0))          *endptr == 0))
# Line 502  while (argc > 1 && argv[op][0] == '-') Line 516  while (argc > 1 && argv[op][0] == '-')
516      printf("Usage:   pcretest [-d] [-i] [-o <n>] [-p] [-s] [-t] [<input> [<output>]]\n");      printf("Usage:   pcretest [-d] [-i] [-o <n>] [-p] [-s] [-t] [<input> [<output>]]\n");
517      printf("  -C     show PCRE compile-time options and exit\n");      printf("  -C     show PCRE compile-time options and exit\n");
518      printf("  -d     debug: show compiled code; implies -i\n");      printf("  -d     debug: show compiled code; implies -i\n");
519    #if !defined NODFA
520      printf("  -dfa   force DFA matching for all subjects\n");      printf("  -dfa   force DFA matching for all subjects\n");
521    #endif
522      printf("  -i     show information about compiled pattern\n"      printf("  -i     show information about compiled pattern\n"
523             "  -m     output memory used information\n"             "  -m     output memory used information\n"
524             "  -o <n> set size of offsets vector to <n>\n");             "  -o <n> set size of offsets vector to <n>\n");
# Line 962  while (!done) Line 978  while (!done)
978      if (do_showinfo)      if (do_showinfo)
979        {        {
980        unsigned long int get_options, all_options;        unsigned long int get_options, all_options;
981    #if !defined NOINFOCHECK
982        int old_first_char, old_options, old_count;        int old_first_char, old_options, old_count;
983    #endif
984        int count, backrefmax, first_char, need_char;        int count, backrefmax, first_char, need_char;
985        int nameentrysize, namecount;        int nameentrysize, namecount;
986        const uschar *nametable;        const uschar *nametable;
# Line 983  while (!done) Line 1001  while (!done)
1001        new_info(re, NULL, PCRE_INFO_NAMECOUNT, &namecount);        new_info(re, NULL, PCRE_INFO_NAMECOUNT, &namecount);
1002        new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable);        new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable);
1003    
1004    #if !defined NOINFOCHECK
1005        old_count = pcre_info(re, &old_options, &old_first_char);        old_count = pcre_info(re, &old_options, &old_first_char);
1006        if (count < 0) fprintf(outfile,        if (count < 0) fprintf(outfile,
1007          "Error %d from pcre_info()\n", count);          "Error %d from pcre_info()\n", count);
# Line 1000  while (!done) Line 1019  while (!done)
1019            "Options disagreement: pcre_fullinfo=%ld pcre_info=%d\n",            "Options disagreement: pcre_fullinfo=%ld pcre_info=%d\n",
1020              get_options, old_options);              get_options, old_options);
1021          }          }
1022    #endif
1023    
1024        if (size != regex_gotten_store) fprintf(outfile,        if (size != regex_gotten_store) fprintf(outfile,
1025          "Size disagreement: pcre_fullinfo=%d call to malloc for %d\n",          "Size disagreement: pcre_fullinfo=%d call to malloc for %d\n",
# Line 1259  while (!done) Line 1279  while (!done)
1279    
1280          /* Handle \x{..} specially - new Perl thing for utf8 */          /* Handle \x{..} specially - new Perl thing for utf8 */
1281    
1282    #if !defined NOUTF8
1283          if (*p == '{')          if (*p == '{')
1284            {            {
1285            unsigned char *pt = p;            unsigned char *pt = p;
# Line 1277  while (!done) Line 1298  while (!done)
1298              }              }
1299            /* Not correct form; fall through */            /* Not correct form; fall through */
1300            }            }
1301    #endif
1302    
1303          /* Ordinary \x */          /* Ordinary \x */
1304    
# Line 1357  while (!done) Line 1379  while (!done)
1379            }            }
1380          continue;          continue;
1381    
1382    #if !defined NODFA
1383          case 'D':          case 'D':
1384    #if !defined NOPOSIX
1385          if (posix || do_posix)          if (posix || do_posix)
1386            printf("** Can't use dfa matching in POSIX mode: \\D ignored\n");            printf("** Can't use dfa matching in POSIX mode: \\D ignored\n");
1387          else          else
1388    #endif
1389            use_dfa = 1;            use_dfa = 1;
1390          continue;          continue;
1391    
1392          case 'F':          case 'F':
1393          options |= PCRE_DFA_SHORTEST;          options |= PCRE_DFA_SHORTEST;
1394          continue;          continue;
1395    #endif
1396    
1397          case 'G':          case 'G':
1398          if (isdigit(*p))          if (isdigit(*p))
# Line 1422  while (!done) Line 1448  while (!done)
1448          options |= PCRE_PARTIAL;          options |= PCRE_PARTIAL;
1449          continue;          continue;
1450    
1451    #if !defined NODFA
1452          case 'R':          case 'R':
1453          options |= PCRE_DFA_RESTART;          options |= PCRE_DFA_RESTART;
1454          continue;          continue;
1455    #endif
1456    
1457          case 'S':          case 'S':
1458          show_malloc = 1;          show_malloc = 1;
# Line 1507  while (!done) Line 1535  while (!done)
1535          clock_t time_taken;          clock_t time_taken;
1536          clock_t start_time = clock();          clock_t start_time = clock();
1537    
1538    #if !defined NODFA
1539          if (all_use_dfa || use_dfa)          if (all_use_dfa || use_dfa)
1540            {            {
1541            int workspace[1000];            int workspace[1000];
# Line 1516  while (!done) Line 1545  while (!done)
1545                sizeof(workspace)/sizeof(int));                sizeof(workspace)/sizeof(int));
1546            }            }
1547          else          else
1548    #endif
1549    
1550          for (i = 0; i < LOOPREPEAT; i++)          for (i = 0; i < LOOPREPEAT; i++)
1551            count = pcre_exec(re, extra, (char *)bptr, len,            count = pcre_exec(re, extra, (char *)bptr, len,
# Line 1591  while (!done) Line 1621  while (!done)
1621        /* The normal case is just to do the match once, with the default        /* The normal case is just to do the match once, with the default
1622        value of match_limit. */        value of match_limit. */
1623    
1624    #if !defined NODFA
1625        else if (all_use_dfa || use_dfa)        else if (all_use_dfa || use_dfa)
1626          {          {
1627          int workspace[1000];          int workspace[1000];
# Line 1603  while (!done) Line 1634  while (!done)
1634            count = use_size_offsets/2;            count = use_size_offsets/2;
1635            }            }
1636          }          }
1637    #endif
1638    
1639        else        else
1640          {          {
# Line 1699  while (!done) Line 1731  while (!done)
1731        else if (count == PCRE_ERROR_PARTIAL)        else if (count == PCRE_ERROR_PARTIAL)
1732          {          {
1733          fprintf(outfile, "Partial match");          fprintf(outfile, "Partial match");
1734    #if !defined NODFA
1735          if ((all_use_dfa || use_dfa) && use_size_offsets > 2)          if ((all_use_dfa || use_dfa) && use_size_offsets > 2)
1736            fprintf(outfile, ": %.*s", use_offsets[1] - use_offsets[0],            fprintf(outfile, ": %.*s", use_offsets[1] - use_offsets[0],
1737              bptr + use_offsets[0]);              bptr + use_offsets[0]);
1738    #endif
1739          fprintf(outfile, "\n");          fprintf(outfile, "\n");
1740          break;  /* Out of the /g loop */          break;  /* Out of the /g loop */
1741          }          }

Legend:
Removed from v.78  
changed lines
  Added in v.79

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12