/[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 755 by ph10, Mon Nov 21 10:41:54 2011 UTC revision 774 by zherczeg, Thu Dec 1 06:08:45 2011 UTC
# Line 118  external symbols to prevent clashes. */ Line 118  external symbols to prevent clashes. */
118  #define _pcre_utf8_table2      utf8_table2  #define _pcre_utf8_table2      utf8_table2
119  #define _pcre_utf8_table3      utf8_table3  #define _pcre_utf8_table3      utf8_table3
120  #define _pcre_utf8_table4      utf8_table4  #define _pcre_utf8_table4      utf8_table4
 #define _pcre_utf8_char_sizes  utf8_char_sizes  
121  #define _pcre_utt              utt  #define _pcre_utt              utt
122  #define _pcre_utt_size         utt_size  #define _pcre_utt_size         utt_size
123  #define _pcre_utt_names        utt_names  #define _pcre_utt_names        utt_names
# Line 196  static const unsigned char *last_callout Line 195  static const unsigned char *last_callout
195  /* The buffers grow automatically if very long input lines are encountered. */  /* The buffers grow automatically if very long input lines are encountered. */
196    
197  static int buffer_size = 50000;  static int buffer_size = 50000;
198  static uschar *buffer = NULL;  static pcre_uint8 *buffer = NULL;
199  static uschar *dbuffer = NULL;  static pcre_uint8 *dbuffer = NULL;
200  static uschar *pbuffer = NULL;  static pcre_uint8 *pbuffer = NULL;
201    
202  /* Textual explanations for runtime error codes */  /* Textual explanations for runtime error codes */
203    
# Line 615  Returns:       pointer to the start of n Line 614  Returns:       pointer to the start of n
614                 NULL if no data read and EOF reached                 NULL if no data read and EOF reached
615  */  */
616    
617  static uschar *  static pcre_uint8 *
618  extend_inputline(FILE *f, uschar *start, const char *prompt)  extend_inputline(FILE *f, pcre_uint8 *start, const char *prompt)
619  {  {
620  uschar *here = start;  pcre_uint8 *here = start;
621    
622  for (;;)  for (;;)
623    {    {
# Line 665  for (;;) Line 664  for (;;)
664    else    else
665      {      {
666      int new_buffer_size = 2*buffer_size;      int new_buffer_size = 2*buffer_size;
667      uschar *new_buffer = (unsigned char *)malloc(new_buffer_size);      pcre_uint8 *new_buffer = (unsigned char *)malloc(new_buffer_size);
668      uschar *new_dbuffer = (unsigned char *)malloc(new_buffer_size);      pcre_uint8 *new_dbuffer = (unsigned char *)malloc(new_buffer_size);
669      uschar *new_pbuffer = (unsigned char *)malloc(new_buffer_size);      pcre_uint8 *new_pbuffer = (unsigned char *)malloc(new_buffer_size);
670    
671      if (new_buffer == NULL || new_dbuffer == NULL || new_pbuffer == NULL)      if (new_buffer == NULL || new_dbuffer == NULL || new_pbuffer == NULL)
672        {        {
# Line 809  Returns:     number of characters placed Line 808  Returns:     number of characters placed
808  #if !defined NOUTF8  #if !defined NOUTF8
809    
810  static int  static int
811  ord2utf8(int cvalue, uschar *utf8bytes)  ord2utf8(int cvalue, pcre_uint8 *utf8bytes)
812  {  {
813  register int i, j;  register int i, j;
814  for (i = 0; i < utf8_table1_size; i++)  for (i = 0; i < utf8_table1_size; i++)
# Line 1072  return ((value & 0x000000ff) << 24) | Line 1071  return ((value & 0x000000ff) << 24) |
1071  *************************************************/  *************************************************/
1072    
1073  static int  static int
1074  check_match_limit(pcre *re, pcre_extra *extra, uschar *bptr, int len,  check_match_limit(pcre *re, pcre_extra *extra, pcre_uint8 *bptr, int len,
1075    int start_offset, int options, int *use_offsets, int use_size_offsets,    int start_offset, int options, int *use_offsets, int use_size_offsets,
1076    int flag, unsigned long int *limit, int errnumber, const char *msg)    int flag, unsigned long int *limit, int errnumber, const char *msg)
1077  {  {
# Line 1132  Returns:    < 0, = 0, or > 0, according Line 1131  Returns:    < 0, = 0, or > 0, according
1131  */  */
1132    
1133  static int  static int
1134  strncmpic(uschar *s, uschar *t, int n)  strncmpic(pcre_uint8 *s, pcre_uint8 *t, int n)
1135  {  {
1136  while (n--)  while (n--)
1137    {    {
# Line 1159  Returns:      appropriate PCRE_NEWLINE_x Line 1158  Returns:      appropriate PCRE_NEWLINE_x
1158  */  */
1159    
1160  static int  static int
1161  check_newline(uschar *p, FILE *f)  check_newline(pcre_uint8 *p, FILE *f)
1162  {  {
1163  if (strncmpic(p, (uschar *)"cr>", 3) == 0) return PCRE_NEWLINE_CR;  if (strncmpic(p, (pcre_uint8 *)"cr>", 3) == 0) return PCRE_NEWLINE_CR;
1164  if (strncmpic(p, (uschar *)"lf>", 3) == 0) return PCRE_NEWLINE_LF;  if (strncmpic(p, (pcre_uint8 *)"lf>", 3) == 0) return PCRE_NEWLINE_LF;
1165  if (strncmpic(p, (uschar *)"crlf>", 5) == 0) return PCRE_NEWLINE_CRLF;  if (strncmpic(p, (pcre_uint8 *)"crlf>", 5) == 0) return PCRE_NEWLINE_CRLF;
1166  if (strncmpic(p, (uschar *)"anycrlf>", 8) == 0) return PCRE_NEWLINE_ANYCRLF;  if (strncmpic(p, (pcre_uint8 *)"anycrlf>", 8) == 0) return PCRE_NEWLINE_ANYCRLF;
1167  if (strncmpic(p, (uschar *)"any>", 4) == 0) return PCRE_NEWLINE_ANY;  if (strncmpic(p, (pcre_uint8 *)"any>", 4) == 0) return PCRE_NEWLINE_ANY;
1168  if (strncmpic(p, (uschar *)"bsr_anycrlf>", 12) == 0) return PCRE_BSR_ANYCRLF;  if (strncmpic(p, (pcre_uint8 *)"bsr_anycrlf>", 12) == 0) return PCRE_BSR_ANYCRLF;
1169  if (strncmpic(p, (uschar *)"bsr_unicode>", 12) == 0) return PCRE_BSR_UNICODE;  if (strncmpic(p, (pcre_uint8 *)"bsr_unicode>", 12) == 0) return PCRE_BSR_UNICODE;
1170  fprintf(f, "Unknown newline type at: <%s\n", p);  fprintf(f, "Unknown newline type at: <%s\n", p);
1171  return 0;  return 0;
1172  }  }
# Line 1255  pcre_jit_stack *jit_stack = NULL; Line 1254  pcre_jit_stack *jit_stack = NULL;
1254  /* These vectors store, end-to-end, a list of captured substring names. Assume  /* These vectors store, end-to-end, a list of captured substring names. Assume
1255  that 1024 is plenty long enough for the few names we'll be testing. */  that 1024 is plenty long enough for the few names we'll be testing. */
1256    
1257  uschar copynames[1024];  pcre_uchar copynames[1024];
1258  uschar getnames[1024];  pcre_uchar getnames[1024];
1259    
1260  uschar *copynamesptr;  pcre_uchar *copynamesptr;
1261  uschar *getnamesptr;  pcre_uchar *getnamesptr;
1262    
1263  /* Get buffers from malloc() so that Electric Fence will check their misuse  /* Get buffers from malloc() so that Electric Fence will check their misuse
1264  when I am debugging. They grow automatically when very long lines are read. */  when I am debugging. They grow automatically when very long lines are read. */
1265    
1266  buffer = (unsigned char *)malloc(buffer_size);  buffer = (pcre_uint8 *)malloc(buffer_size);
1267  dbuffer = (unsigned char *)malloc(buffer_size);  dbuffer = (pcre_uint8 *)malloc(buffer_size);
1268  pbuffer = (unsigned char *)malloc(buffer_size);  pbuffer = (pcre_uint8 *)malloc(buffer_size);
1269    
1270  /* The outfile variable is static so that new_malloc can use it. */  /* The outfile variable is static so that new_malloc can use it. */
1271    
# Line 1497  while (!done) Line 1496  while (!done)
1496    if (*p == '<' && strchr((char *)(p+1), '<') == NULL)    if (*p == '<' && strchr((char *)(p+1), '<') == NULL)
1497      {      {
1498      unsigned long int magic, get_options;      unsigned long int magic, get_options;
1499      uschar sbuf[8];      pcre_uint8 sbuf[8];
1500      FILE *f;      FILE *f;
1501    
1502      p++;      p++;
# Line 1733  while (!done) Line 1732  while (!done)
1732    
1733        case '<':        case '<':
1734          {          {
1735          if (strncmpic(pp, (uschar *)"JS>", 3) == 0)          if (strncmpic(pp, (pcre_uint8 *)"JS>", 3) == 0)
1736            {            {
1737            options |= PCRE_JAVASCRIPT_COMPAT;            options |= PCRE_JAVASCRIPT_COMPAT;
1738            pp += 3;            pp += 3;
# Line 1921  while (!done) Line 1920  while (!done)
1920          (pcre_uint16)byteflip(rre->top_bracket, sizeof(rre->top_bracket));          (pcre_uint16)byteflip(rre->top_bracket, sizeof(rre->top_bracket));
1921        rre->top_backref =        rre->top_backref =
1922          (pcre_uint16)byteflip(rre->top_backref, sizeof(rre->top_backref));          (pcre_uint16)byteflip(rre->top_backref, sizeof(rre->top_backref));
1923        rre->first_byte =        rre->first_char =
1924          (pcre_uint16)byteflip(rre->first_byte, sizeof(rre->first_byte));          (pcre_uint16)byteflip(rre->first_char, sizeof(rre->first_char));
1925        rre->req_byte =        rre->req_char =
1926          (pcre_uint16)byteflip(rre->req_byte, sizeof(rre->req_byte));          (pcre_uint16)byteflip(rre->req_char, sizeof(rre->req_char));
1927        rre->name_table_offset = (pcre_uint16)byteflip(rre->name_table_offset,        rre->name_table_offset = (pcre_uint16)byteflip(rre->name_table_offset,
1928          sizeof(rre->name_table_offset));          sizeof(rre->name_table_offset));
1929        rre->name_entry_size = (pcre_uint16)byteflip(rre->name_entry_size,        rre->name_entry_size = (pcre_uint16)byteflip(rre->name_entry_size,
# Line 1962  while (!done) Line 1961  while (!done)
1961        int count, backrefmax, first_char, need_char, okpartial, jchanged,        int count, backrefmax, first_char, need_char, okpartial, jchanged,
1962          hascrorlf;          hascrorlf;
1963        int nameentrysize, namecount;        int nameentrysize, namecount;
1964        const uschar *nametable;        const pcre_uchar *nametable;
1965    
1966        new_info(re, NULL, PCRE_INFO_SIZE, &size);        new_info(re, NULL, PCRE_INFO_SIZE, &size);
1967        new_info(re, NULL, PCRE_INFO_CAPTURECOUNT, &count);        new_info(re, NULL, PCRE_INFO_CAPTURECOUNT, &count);
# Line 2080  while (!done) Line 2079  while (!done)
2079          }          }
2080        else        else
2081          {          {
2082          int ch = first_char & 255;          const char *caseless =
2083          const char *caseless = ((first_char & REQ_CASELESS) == 0)?            ((((real_pcre *)re)->flags & PCRE_FCH_CASELESS) == 0)?
2084            "" : " (caseless)";            "" : " (caseless)";
2085          if (PRINTHEX(ch))  
2086            fprintf(outfile, "First char = \'%c\'%s\n", ch, caseless);          if (PRINTHEX(first_char))
2087              fprintf(outfile, "First char = \'%c\'%s\n", first_char, caseless);
2088          else          else
2089            fprintf(outfile, "First char = %d%s\n", ch, caseless);            fprintf(outfile, "First char = %d%s\n", first_char, caseless);
2090          }          }
2091    
2092        if (need_char < 0)        if (need_char < 0)
# Line 2095  while (!done) Line 2095  while (!done)
2095          }          }
2096        else        else
2097          {          {
2098          int ch = need_char & 255;          const char *caseless =
2099          const char *caseless = ((need_char & REQ_CASELESS) == 0)?            ((((real_pcre *)re)->flags & PCRE_RCH_CASELESS) == 0)?
2100            "" : " (caseless)";            "" : " (caseless)";
2101          if (PRINTHEX(ch))  
2102            fprintf(outfile, "Need char = \'%c\'%s\n", ch, caseless);          if (PRINTHEX(need_char))
2103              fprintf(outfile, "Need char = \'%c\'%s\n", need_char, caseless);
2104          else          else
2105            fprintf(outfile, "Need char = %d%s\n", ch, caseless);            fprintf(outfile, "Need char = %d%s\n", need_char, caseless);
2106          }          }
2107    
2108        /* 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
# Line 2118  while (!done) Line 2119  while (!done)
2119            fprintf(outfile, "Study returned NULL\n");            fprintf(outfile, "Study returned NULL\n");
2120          else          else
2121            {            {
2122            uschar *start_bits = NULL;            pcre_uint8 *start_bits = NULL;
2123            int minlength;            int minlength;
2124    
2125            new_info(re, extra, PCRE_INFO_MINLENGTH, &minlength);            new_info(re, extra, PCRE_INFO_MINLENGTH, &minlength);
# Line 2188  while (!done) Line 2189  while (!done)
2189          }          }
2190        else        else
2191          {          {
2192          uschar sbuf[8];          pcre_uint8 sbuf[8];
2193          sbuf[0] = (uschar)((true_size >> 24) & 255);          sbuf[0] = (pcre_uint8)((true_size >> 24) & 255);
2194          sbuf[1] = (uschar)((true_size >> 16) & 255);          sbuf[1] = (pcre_uint8)((true_size >> 16) & 255);
2195          sbuf[2] = (uschar)((true_size >>  8) & 255);          sbuf[2] = (pcre_uint8)((true_size >>  8) & 255);
2196          sbuf[3] = (uschar)((true_size) & 255);          sbuf[3] = (pcre_uint8)((true_size) & 255);
2197    
2198          sbuf[4] = (uschar)((true_study_size >> 24) & 255);          sbuf[4] = (pcre_uint8)((true_study_size >> 24) & 255);
2199          sbuf[5] = (uschar)((true_study_size >> 16) & 255);          sbuf[5] = (pcre_uint8)((true_study_size >> 16) & 255);
2200          sbuf[6] = (uschar)((true_study_size >>  8) & 255);          sbuf[6] = (pcre_uint8)((true_study_size >>  8) & 255);
2201          sbuf[7] = (uschar)((true_study_size) & 255);          sbuf[7] = (pcre_uint8)((true_study_size) & 255);
2202    
2203          if (fwrite(sbuf, 1, 8, f) < 8 ||          if (fwrite(sbuf, 1, 8, f) < 8 ||
2204              fwrite(re, 1, true_size, f) < true_size)              fwrite(re, 1, true_size, f) < true_size)
# Line 2240  while (!done) Line 2241  while (!done)
2241    
2242    for (;;)    for (;;)
2243      {      {
2244      uschar *q;      pcre_uint8 *q;
2245      uschar *bptr;      pcre_uint8 *bptr;
2246      int *use_offsets = offsets;      int *use_offsets = offsets;
2247      int use_size_offsets = size_offsets;      int use_size_offsets = size_offsets;
2248      int callout_data = 0;      int callout_data = 0;
# Line 2418  while (!done) Line 2419  while (!done)
2419            }            }
2420          else if (isalnum(*p))          else if (isalnum(*p))
2421            {            {
2422            uschar *npp = copynamesptr;            pcre_uchar *npp = copynamesptr;
2423            while (isalnum(*p)) *npp++ = *p++;            while (isalnum(*p)) *npp++ = *p++;
2424            *npp++ = 0;            *npp++ = 0;
2425            *npp = 0;            *npp = 0;
# Line 2488  while (!done) Line 2489  while (!done)
2489            }            }
2490          else if (isalnum(*p))          else if (isalnum(*p))
2491            {            {
2492            uschar *npp = getnamesptr;            pcre_uchar *npp = getnamesptr;
2493            while (isalnum(*p)) *npp++ = *p++;            while (isalnum(*p)) *npp++ = *p++;
2494            *npp++ = 0;            *npp++ = 0;
2495            *npp = 0;            *npp = 0;

Legend:
Removed from v.755  
changed lines
  Added in v.774

  ViewVC Help
Powered by ViewVC 1.1.5