/[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 756 by ph10, Mon Nov 21 10:48:42 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 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 2118  while (!done) Line 2117  while (!done)
2117            fprintf(outfile, "Study returned NULL\n");            fprintf(outfile, "Study returned NULL\n");
2118          else          else
2119            {            {
2120            uschar *start_bits = NULL;            pcre_uint8 *start_bits = NULL;
2121            int minlength;            int minlength;
2122    
2123            new_info(re, extra, PCRE_INFO_MINLENGTH, &minlength);            new_info(re, extra, PCRE_INFO_MINLENGTH, &minlength);
# Line 2188  while (!done) Line 2187  while (!done)
2187          }          }
2188        else        else
2189          {          {
2190          uschar sbuf[8];          pcre_uint8 sbuf[8];
2191          sbuf[0] = (uschar)((true_size >> 24) & 255);          sbuf[0] = (pcre_uint8)((true_size >> 24) & 255);
2192          sbuf[1] = (uschar)((true_size >> 16) & 255);          sbuf[1] = (pcre_uint8)((true_size >> 16) & 255);
2193          sbuf[2] = (uschar)((true_size >>  8) & 255);          sbuf[2] = (pcre_uint8)((true_size >>  8) & 255);
2194          sbuf[3] = (uschar)((true_size) & 255);          sbuf[3] = (pcre_uint8)((true_size) & 255);
2195    
2196          sbuf[4] = (uschar)((true_study_size >> 24) & 255);          sbuf[4] = (pcre_uint8)((true_study_size >> 24) & 255);
2197          sbuf[5] = (uschar)((true_study_size >> 16) & 255);          sbuf[5] = (pcre_uint8)((true_study_size >> 16) & 255);
2198          sbuf[6] = (uschar)((true_study_size >>  8) & 255);          sbuf[6] = (pcre_uint8)((true_study_size >>  8) & 255);
2199          sbuf[7] = (uschar)((true_study_size) & 255);          sbuf[7] = (pcre_uint8)((true_study_size) & 255);
2200    
2201          if (fwrite(sbuf, 1, 8, f) < 8 ||          if (fwrite(sbuf, 1, 8, f) < 8 ||
2202              fwrite(re, 1, true_size, f) < true_size)              fwrite(re, 1, true_size, f) < true_size)
# Line 2240  while (!done) Line 2239  while (!done)
2239    
2240    for (;;)    for (;;)
2241      {      {
2242      uschar *q;      pcre_uint8 *q;
2243      uschar *bptr;      pcre_uint8 *bptr;
2244      int *use_offsets = offsets;      int *use_offsets = offsets;
2245      int use_size_offsets = size_offsets;      int use_size_offsets = size_offsets;
2246      int callout_data = 0;      int callout_data = 0;
# Line 2418  while (!done) Line 2417  while (!done)
2417            }            }
2418          else if (isalnum(*p))          else if (isalnum(*p))
2419            {            {
2420            uschar *npp = copynamesptr;            pcre_uchar *npp = copynamesptr;
2421            while (isalnum(*p)) *npp++ = *p++;            while (isalnum(*p)) *npp++ = *p++;
2422            *npp++ = 0;            *npp++ = 0;
2423            *npp = 0;            *npp = 0;
# Line 2488  while (!done) Line 2487  while (!done)
2487            }            }
2488          else if (isalnum(*p))          else if (isalnum(*p))
2489            {            {
2490            uschar *npp = getnamesptr;            pcre_uchar *npp = getnamesptr;
2491            while (isalnum(*p)) *npp++ = *p++;            while (isalnum(*p)) *npp++ = *p++;
2492            *npp++ = 0;            *npp++ = 0;
2493            *npp = 0;            *npp = 0;

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

  ViewVC Help
Powered by ViewVC 1.1.5