/[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 211 by ph10, Thu Aug 9 09:52:43 2007 UTC revision 274 by ph10, Tue Nov 20 10:05:23 2007 UTC
# Line 37  POSSIBILITY OF SUCH DAMAGE. Line 37  POSSIBILITY OF SUCH DAMAGE.
37    
38    
39  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
40  #include <config.h>  #include "config.h"
41  #endif  #endif
42    
43  #include <ctype.h>  #include <ctype.h>
# Line 94  symbols to prevent clashes. */ Line 94  symbols to prevent clashes. */
94  #define _pcre_utf8_table4      utf8_table4  #define _pcre_utf8_table4      utf8_table4
95  #define _pcre_utt              utt  #define _pcre_utt              utt
96  #define _pcre_utt_size         utt_size  #define _pcre_utt_size         utt_size
97    #define _pcre_utt_names        utt_names
98  #define _pcre_OP_lengths       OP_lengths  #define _pcre_OP_lengths       OP_lengths
99    
100  #include "pcre_tables.c"  #include "pcre_tables.c"
# Line 664  return count; Line 665  return count;
665    
666    
667  /*************************************************  /*************************************************
668    *         Case-independent strncmp() function    *
669    *************************************************/
670    
671    /*
672    Arguments:
673      s         first string
674      t         second string
675      n         number of characters to compare
676    
677    Returns:    < 0, = 0, or > 0, according to the comparison
678    */
679    
680    static int
681    strncmpic(uschar *s, uschar *t, int n)
682    {
683    while (n--)
684      {
685      int c = tolower(*s++) - tolower(*t++);
686      if (c) return c;
687      }
688    return 0;
689    }
690    
691    
692    
693    /*************************************************
694  *         Check newline indicator                *  *         Check newline indicator                *
695  *************************************************/  *************************************************/
696    
# Line 681  Returns: appropriate PCRE_NEWLINE_x Line 708  Returns: appropriate PCRE_NEWLINE_x
708  static int  static int
709  check_newline(uschar *p, FILE *f)  check_newline(uschar *p, FILE *f)
710  {  {
711  if (strncmp((char *)p, "cr>", 3) == 0) return PCRE_NEWLINE_CR;  if (strncmpic(p, (uschar *)"cr>", 3) == 0) return PCRE_NEWLINE_CR;
712  if (strncmp((char *)p, "lf>", 3) == 0) return PCRE_NEWLINE_LF;  if (strncmpic(p, (uschar *)"lf>", 3) == 0) return PCRE_NEWLINE_LF;
713  if (strncmp((char *)p, "crlf>", 5) == 0) return PCRE_NEWLINE_CRLF;  if (strncmpic(p, (uschar *)"crlf>", 5) == 0) return PCRE_NEWLINE_CRLF;
714  if (strncmp((char *)p, "anycrlf>", 8) == 0) return PCRE_NEWLINE_ANYCRLF;  if (strncmpic(p, (uschar *)"anycrlf>", 8) == 0) return PCRE_NEWLINE_ANYCRLF;
715  if (strncmp((char *)p, "any>", 4) == 0) return PCRE_NEWLINE_ANY;  if (strncmpic(p, (uschar *)"any>", 4) == 0) return PCRE_NEWLINE_ANY;
716    if (strncmpic(p, (uschar *)"bsr_anycrlf>", 12) == 0) return PCRE_BSR_ANYCRLF;
717    if (strncmpic(p, (uschar *)"bsr_unicode>", 12) == 0) return PCRE_BSR_UNICODE;
718  fprintf(f, "Unknown newline type at: <%s\n", p);  fprintf(f, "Unknown newline type at: <%s\n", p);
719  return 0;  return 0;
720  }  }
# Line 859  while (argc > 1 && argv[op][0] == '-') Line 888  while (argc > 1 && argv[op][0] == '-')
888        (rc == '\n')? "LF" : (rc == ('\r'<<8 | '\n'))? "CRLF" :        (rc == '\n')? "LF" : (rc == ('\r'<<8 | '\n'))? "CRLF" :
889        (rc == -2)? "ANYCRLF" :        (rc == -2)? "ANYCRLF" :
890        (rc == -1)? "ANY" : "???");        (rc == -1)? "ANY" : "???");
891        (void)pcre_config(PCRE_CONFIG_BSR, &rc);
892        printf("  \\R matches %s\n", rc? "CR, LF, or CRLF only" :
893                                         "all Unicode newlines");
894      (void)pcre_config(PCRE_CONFIG_LINK_SIZE, &rc);      (void)pcre_config(PCRE_CONFIG_LINK_SIZE, &rc);
895      printf("  Internal link size = %d\n", rc);      printf("  Internal link size = %d\n", rc);
896      (void)pcre_config(PCRE_CONFIG_POSIX_MALLOC_THRESHOLD, &rc);      (void)pcre_config(PCRE_CONFIG_POSIX_MALLOC_THRESHOLD, &rc);
# Line 1066  while (!done) Line 1098  while (!done)
1098    
1099    if (isalnum(delimiter) || delimiter == '\\')    if (isalnum(delimiter) || delimiter == '\\')
1100      {      {
1101      fprintf(outfile, "** Delimiter must not be alphameric or \\\n");      fprintf(outfile, "** Delimiter must not be alphanumeric or \\\n");
1102      goto SKIP_DATA;      goto SKIP_DATA;
1103      }      }
1104    
# Line 1320  while (!done) Line 1352  while (!done)
1352      if (do_flip)      if (do_flip)
1353        {        {
1354        real_pcre *rre = (real_pcre *)re;        real_pcre *rre = (real_pcre *)re;
1355        rre->magic_number = byteflip(rre->magic_number, sizeof(rre->magic_number));        rre->magic_number =
1356            byteflip(rre->magic_number, sizeof(rre->magic_number));
1357        rre->size = byteflip(rre->size, sizeof(rre->size));        rre->size = byteflip(rre->size, sizeof(rre->size));
1358        rre->options = byteflip(rre->options, sizeof(rre->options));        rre->options = byteflip(rre->options, sizeof(rre->options));
1359        rre->top_bracket = byteflip(rre->top_bracket, sizeof(rre->top_bracket));        rre->flags = (pcre_uint16)byteflip(rre->flags, sizeof(rre->flags));
1360        rre->top_backref = byteflip(rre->top_backref, sizeof(rre->top_backref));        rre->top_bracket =
1361        rre->first_byte = byteflip(rre->first_byte, sizeof(rre->first_byte));          (pcre_uint16)byteflip(rre->top_bracket, sizeof(rre->top_bracket));
1362        rre->req_byte = byteflip(rre->req_byte, sizeof(rre->req_byte));        rre->top_backref =
1363        rre->name_table_offset = byteflip(rre->name_table_offset,          (pcre_uint16)byteflip(rre->top_backref, sizeof(rre->top_backref));
1364          rre->first_byte =
1365            (pcre_uint16)byteflip(rre->first_byte, sizeof(rre->first_byte));
1366          rre->req_byte =
1367            (pcre_uint16)byteflip(rre->req_byte, sizeof(rre->req_byte));
1368          rre->name_table_offset = (pcre_uint16)byteflip(rre->name_table_offset,
1369          sizeof(rre->name_table_offset));          sizeof(rre->name_table_offset));
1370        rre->name_entry_size = byteflip(rre->name_entry_size,        rre->name_entry_size = (pcre_uint16)byteflip(rre->name_entry_size,
1371          sizeof(rre->name_entry_size));          sizeof(rre->name_entry_size));
1372        rre->name_count = byteflip(rre->name_count, sizeof(rre->name_count));        rre->name_count = (pcre_uint16)byteflip(rre->name_count,
1373            sizeof(rre->name_count));
1374    
1375        if (extra != NULL)        if (extra != NULL)
1376          {          {
# Line 1357  while (!done) Line 1396  while (!done)
1396  #if !defined NOINFOCHECK  #if !defined NOINFOCHECK
1397        int old_first_char, old_options, old_count;        int old_first_char, old_options, old_count;
1398  #endif  #endif
1399        int count, backrefmax, first_char, need_char, okpartial, jchanged;        int count, backrefmax, first_char, need_char, okpartial, jchanged,
1400            hascrorlf;
1401        int nameentrysize, namecount;        int nameentrysize, namecount;
1402        const uschar *nametable;        const uschar *nametable;
1403    
# Line 1372  while (!done) Line 1412  while (!done)
1412        new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable);        new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable);
1413        new_info(re, NULL, PCRE_INFO_OKPARTIAL, &okpartial);        new_info(re, NULL, PCRE_INFO_OKPARTIAL, &okpartial);
1414        new_info(re, NULL, PCRE_INFO_JCHANGED, &jchanged);        new_info(re, NULL, PCRE_INFO_JCHANGED, &jchanged);
1415          new_info(re, NULL, PCRE_INFO_HASCRORLF, &hascrorlf);
1416    
1417  #if !defined NOINFOCHECK  #if !defined NOINFOCHECK
1418        old_count = pcre_info(re, &old_options, &old_first_char);        old_count = pcre_info(re, &old_options, &old_first_char);
# Line 1414  while (!done) Line 1455  while (!done)
1455          }          }
1456    
1457        if (!okpartial) fprintf(outfile, "Partial matching not supported\n");        if (!okpartial) fprintf(outfile, "Partial matching not supported\n");
1458          if (hascrorlf) fprintf(outfile, "Contains explicit CR or LF match\n");
1459    
1460        all_options = ((real_pcre *)re)->options;        all_options = ((real_pcre *)re)->options;
1461        if (do_flip) all_options = byteflip(all_options, sizeof(all_options));        if (do_flip) all_options = byteflip(all_options, sizeof(all_options));
1462    
1463        if (get_options == 0) fprintf(outfile, "No options\n");        if (get_options == 0) fprintf(outfile, "No options\n");
1464          else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s%s%s%s%s\n",          else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
1465            ((get_options & PCRE_ANCHORED) != 0)? " anchored" : "",            ((get_options & PCRE_ANCHORED) != 0)? " anchored" : "",
1466            ((get_options & PCRE_CASELESS) != 0)? " caseless" : "",            ((get_options & PCRE_CASELESS) != 0)? " caseless" : "",
1467            ((get_options & PCRE_EXTENDED) != 0)? " extended" : "",            ((get_options & PCRE_EXTENDED) != 0)? " extended" : "",
1468            ((get_options & PCRE_MULTILINE) != 0)? " multiline" : "",            ((get_options & PCRE_MULTILINE) != 0)? " multiline" : "",
1469            ((get_options & PCRE_FIRSTLINE) != 0)? " firstline" : "",            ((get_options & PCRE_FIRSTLINE) != 0)? " firstline" : "",
1470            ((get_options & PCRE_DOTALL) != 0)? " dotall" : "",            ((get_options & PCRE_DOTALL) != 0)? " dotall" : "",
1471              ((get_options & PCRE_BSR_ANYCRLF) != 0)? " bsr_anycrlf" : "",
1472              ((get_options & PCRE_BSR_UNICODE) != 0)? " bsr_unicode" : "",
1473            ((get_options & PCRE_DOLLAR_ENDONLY) != 0)? " dollar_endonly" : "",            ((get_options & PCRE_DOLLAR_ENDONLY) != 0)? " dollar_endonly" : "",
1474            ((get_options & PCRE_EXTRA) != 0)? " extra" : "",            ((get_options & PCRE_EXTRA) != 0)? " extra" : "",
1475            ((get_options & PCRE_UNGREEDY) != 0)? " ungreedy" : "",            ((get_options & PCRE_UNGREEDY) != 0)? " ungreedy" : "",
# Line 1558  while (!done) Line 1602  while (!done)
1602        else        else
1603          {          {
1604          uschar sbuf[8];          uschar sbuf[8];
1605          sbuf[0] = (true_size >> 24)  & 255;          sbuf[0] = (uschar)((true_size >> 24) & 255);
1606          sbuf[1] = (true_size >> 16)  & 255;          sbuf[1] = (uschar)((true_size >> 16) & 255);
1607          sbuf[2] = (true_size >>  8)  & 255;          sbuf[2] = (uschar)((true_size >>  8) & 255);
1608          sbuf[3] = (true_size)  & 255;          sbuf[3] = (uschar)((true_size) & 255);
1609    
1610          sbuf[4] = (true_study_size >> 24)  & 255;          sbuf[4] = (uschar)((true_study_size >> 24) & 255);
1611          sbuf[5] = (true_study_size >> 16)  & 255;          sbuf[5] = (uschar)((true_study_size >> 16) & 255);
1612          sbuf[6] = (true_study_size >>  8)  & 255;          sbuf[6] = (uschar)((true_study_size >>  8) & 255);
1613          sbuf[7] = (true_study_size)  & 255;          sbuf[7] = (uschar)((true_study_size) & 255);
1614    
1615          if (fwrite(sbuf, 1, 8, f) < 8 ||          if (fwrite(sbuf, 1, 8, f) < 8 ||
1616              fwrite(re, 1, true_size, f) < true_size)              fwrite(re, 1, true_size, f) < true_size)

Legend:
Removed from v.211  
changed lines
  Added in v.274

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12