/[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 9 by nigel, Sat Feb 24 21:38:13 2007 UTC revision 19 by nigel, Sat Feb 24 21:38:33 2007 UTC
# Line 38  static const char *OP_names[] = { Line 38  static const char *OP_names[] = {
38    "*", "*?", "+", "+?", "?", "??", "{", "{", "{",    "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
39    "*", "*?", "+", "+?", "?", "??", "{", "{", "{",    "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
40    "*", "*?", "+", "+?", "?", "??", "{", "{",    "*", "*?", "+", "+?", "?", "??", "{", "{",
41    "class", "Ref",    "class", "negclass", "Ref",
42    "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not", "Once",    "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not", "Once",
43    "Brazero", "Braminzero", "Bra"    "Brazero", "Braminzero", "Bra"
44  };  };
# Line 122  for(;;) Line 122  for(;;)
122      case OP_TYPEUPTO:      case OP_TYPEUPTO:
123      case OP_TYPEMINUPTO:      case OP_TYPEMINUPTO:
124      printf("    %s{", OP_names[code[3]]);      printf("    %s{", OP_names[code[3]]);
125      if (*code != OP_TYPEEXACT) printf(",");      if (*code != OP_TYPEEXACT) printf("0,");
126      printf("%d}", (code[1] << 8) + code[2]);      printf("%d}", (code[1] << 8) + code[2]);
127      if (*code == OP_TYPEMINUPTO) printf("?");      if (*code == OP_TYPEMINUPTO) printf("?");
128      code += 3;      code += 3;
# Line 161  for(;;) Line 161  for(;;)
161      goto CLASS_REF_REPEAT;      goto CLASS_REF_REPEAT;
162    
163      case OP_CLASS:      case OP_CLASS:
164        case OP_NEGCLASS:
165        {        {
166        int i, min, max;        int i, min, max;
167          if (*code++ == OP_CLASS) printf("    [");
168        code++;          else printf("   ^[");
       printf("    [");  
169    
170        for (i = 0; i < 256; i++)        for (i = 0; i < 256; i++)
171          {          {
# Line 268  int timeit = 0; Line 268  int timeit = 0;
268  int showinfo = 0;  int showinfo = 0;
269  int posix = 0;  int posix = 0;
270  int debug = 0;  int debug = 0;
271    int done = 0;
272  unsigned char buffer[30000];  unsigned char buffer[30000];
273  unsigned char dbuffer[1024];  unsigned char dbuffer[1024];
274    
# Line 326  fprintf(outfile, "PCRE version %s\n\n", Line 327  fprintf(outfile, "PCRE version %s\n\n",
327    
328  /* Main loop */  /* Main loop */
329    
330  for (;;)  while (!done)
331    {    {
332    pcre *re = NULL;    pcre *re = NULL;
333    pcre_extra *extra = NULL;    pcre_extra *extra = NULL;
# Line 375  for (;;) Line 376  for (;;)
376      if (fgets((char *)pp, len, infile) == NULL)      if (fgets((char *)pp, len, infile) == NULL)
377        {        {
378        fprintf(outfile, "** Unexpected EOF\n");        fprintf(outfile, "** Unexpected EOF\n");
379        goto END_OFF;        done = 1;
380          goto CONTINUE;
381        }        }
382      if (infile != stdin) fprintf(outfile, (char *)pp);      if (infile != stdin) fprintf(outfile, (char *)pp);
383      }      }
# Line 402  for (;;) Line 404  for (;;)
404        case 'P': do_posix = 1; break;        case 'P': do_posix = 1; break;
405        case 'S': do_study = 1; break;        case 'S': do_study = 1; break;
406        case 'I': study_options |= PCRE_CASELESS; break;        case 'I': study_options |= PCRE_CASELESS; break;
407          case 'U': options |= PCRE_UNGREEDY; break;
408        case 'X': options |= PCRE_EXTRA; break;        case 'X': options |= PCRE_EXTRA; break;
409        case '\n': case ' ': break;        case '\n': case ' ': break;
410        default:        default:
# Line 410  for (;;) Line 413  for (;;)
413        }        }
414      }      }
415    
416    /* Handle compiing via the POSIX interface, which doesn't support the    /* Handle compiling via the POSIX interface, which doesn't support the
417    timing, showing, or debugging options. */    timing, showing, or debugging options. */
418    
419    if (posix || do_posix)    if (posix || do_posix)
# Line 465  for (;;) Line 468  for (;;)
468          for (;;)          for (;;)
469            {            {
470            if (fgets((char *)buffer, sizeof(buffer), infile) == NULL)            if (fgets((char *)buffer, sizeof(buffer), infile) == NULL)
471              goto END_OFF;              {
472                done = 1;
473                goto CONTINUE;
474                }
475            len = (int)strlen((char *)buffer);            len = (int)strlen((char *)buffer);
476            while (len > 0 && isspace(buffer[len-1])) len--;            while (len > 0 && isspace(buffer[len-1])) len--;
477            if (len == 0) break;            if (len == 0) break;
# Line 490  for (;;) Line 496  for (;;)
496          {          {
497          fprintf(outfile, "Identifying subpattern count = %d\n", count);          fprintf(outfile, "Identifying subpattern count = %d\n", count);
498          if (options == 0) fprintf(outfile, "No options\n");          if (options == 0) fprintf(outfile, "No options\n");
499            else fprintf(outfile, "Options:%s%s%s%s%s%s%s\n",            else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s\n",
500              ((options & PCRE_ANCHORED) != 0)? " anchored" : "",              ((options & PCRE_ANCHORED) != 0)? " anchored" : "",
501              ((options & PCRE_CASELESS) != 0)? " caseless" : "",              ((options & PCRE_CASELESS) != 0)? " caseless" : "",
502              ((options & PCRE_EXTENDED) != 0)? " extended" : "",              ((options & PCRE_EXTENDED) != 0)? " extended" : "",
503              ((options & PCRE_MULTILINE) != 0)? " multiline" : "",              ((options & PCRE_MULTILINE) != 0)? " multiline" : "",
504              ((options & PCRE_DOTALL) != 0)? " dotall" : "",              ((options & PCRE_DOTALL) != 0)? " dotall" : "",
505              ((options & PCRE_DOLLAR_ENDONLY) != 0)? " dollar_endonly" : "",              ((options & PCRE_DOLLAR_ENDONLY) != 0)? " dollar_endonly" : "",
506              ((options & PCRE_EXTRA) != 0)? " extra" : "");              ((options & PCRE_EXTRA) != 0)? " extra" : "",
507                ((options & PCRE_UNGREEDY) != 0)? " ungreedy" : "");
508          if (first_char == -1)          if (first_char == -1)
509            {            {
510            fprintf(outfile, "First char at start or follows \\n\n");            fprintf(outfile, "First char at start or follows \\n\n");
# Line 592  for (;;) Line 599  for (;;)
599      options = 0;      options = 0;
600    
601      if (infile == stdin) printf("  data> ");      if (infile == stdin) printf("  data> ");
602      if (fgets((char *)buffer, sizeof(buffer), infile) == NULL) goto END_OFF;      if (fgets((char *)buffer, sizeof(buffer), infile) == NULL)
603          {
604          done = 1;
605          goto CONTINUE;
606          }
607      if (infile != stdin) fprintf(outfile, (char *)buffer);      if (infile != stdin) fprintf(outfile, (char *)buffer);
608    
609      len = (int)strlen((char *)buffer);      len = (int)strlen((char *)buffer);
# Line 762  for (;;) Line 773  for (;;)
773        }        }
774      }      }
775    
776      CONTINUE:
777    if (posix || do_posix) regfree(&preg);    if (posix || do_posix) regfree(&preg);
778    if (re != NULL) free(re);    if (re != NULL) free(re);
779    if (extra != NULL) free(extra);    if (extra != NULL) free(extra);
780    }    }
781    
 END_OFF:  
782  fprintf(outfile, "\n");  fprintf(outfile, "\n");
783  return 0;  return 0;
784  }  }

Legend:
Removed from v.9  
changed lines
  Added in v.19

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12