/[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 836 by ph10, Wed Dec 28 17:16:11 2011 UTC revision 841 by zherczeg, Sat Dec 31 07:04:43 2011 UTC
# Line 259  argument, the casting might be incorrect Line 259  argument, the casting might be incorrect
259  #define PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr) \  #define PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr) \
260    rc = pcre_get_substring_list((const char *)bptr, offsets, count, listptr)    rc = pcre_get_substring_list((const char *)bptr, offsets, count, listptr)
261    
262  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER8(re, extra, tables) \  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables) \
263    pcre_pattern_to_host_byte_order(re, extra, tables)    rc = pcre_pattern_to_host_byte_order(re, extra, tables)
264    
265  #define PCRE_PRINTINT8(re, outfile, debug_lengths) \  #define PCRE_PRINTINT8(re, outfile, debug_lengths) \
266    pcre_printint(re, outfile, debug_lengths)    pcre_printint(re, outfile, debug_lengths)
# Line 336  argument, the casting might be incorrect Line 336  argument, the casting might be incorrect
336    rc = pcre16_get_substring_list((PCRE_SPTR16)bptr, offsets, count, \    rc = pcre16_get_substring_list((PCRE_SPTR16)bptr, offsets, count, \
337      (PCRE_SPTR16 **)(void*)listptr)      (PCRE_SPTR16 **)(void*)listptr)
338    
339  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER16(re, extra, tables) \  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables) \
340    pcre16_pattern_to_host_byte_order(re, extra, tables)    rc = pcre16_pattern_to_host_byte_order(re, extra, tables)
341    
342  #define PCRE_PRINTINT16(re, outfile, debug_lengths) \  #define PCRE_PRINTINT16(re, outfile, debug_lengths) \
343    pcre16_printint(re, outfile, debug_lengths)    pcre16_printint(re, outfile, debug_lengths)
# Line 476  version is called. ----- */ Line 476  version is called. ----- */
476  #define PCRE_MAKETABLES \  #define PCRE_MAKETABLES \
477    (use_pcre16? pcre16_maketables() : pcre_maketables())    (use_pcre16? pcre16_maketables() : pcre_maketables())
478    
479  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER(re, extra, tables) \  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \
480    if (use_pcre16) \    if (use_pcre16) \
481      PCRE_PATTERN_TO_HOST_BYTE_ORDER16(re, extra, tables); \      PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables); \
482    else \    else \
483      PCRE_PATTERN_TO_HOST_BYTE_ORDER8(re, extra, tables)      PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables)
484    
485  #define PCRE_PRINTINT(re, outfile, debug_lengths) \  #define PCRE_PRINTINT(re, outfile, debug_lengths) \
486    if (use_pcre16) \    if (use_pcre16) \
# Line 625  COMPILE_PCRE16 is *not* set. */ Line 625  COMPILE_PCRE16 is *not* set. */
625  #error LINK_SIZE must be either 2, 3, or 4  #error LINK_SIZE must be either 2, 3, or 4
626  #endif  #endif
627    
628    #undef IMM2_SIZE
629    #define IMM2_SIZE 1
630    
631  #endif /* SUPPORT_PCRE8 */  #endif /* SUPPORT_PCRE8 */
632    
633  static const pcre_uint16 OP_lengths16[] = { OP_LENGTHS };  static const pcre_uint16 OP_lengths16[] = { OP_LENGTHS };
# Line 1913  while(TRUE) Line 1916  while(TRUE)
1916      break;      break;
1917    
1918      case OP_XCLASS:      case OP_XCLASS:
1919        /* LINK_SIZE can be 1 or 2 in 16 bit mode. */
1920        if (LINK_SIZE > 1)
1921          length = (int)((((unsigned int)(ptr[0]) << 16) | (unsigned int)(ptr[1]))
1922            - (1 + LINK_SIZE + 1));
1923        else
1924          length = (int)((unsigned int)(ptr[0]) - (1 + LINK_SIZE + 1));
1925    
1926      /* Reverse the size of the XCLASS instance. */      /* Reverse the size of the XCLASS instance. */
     ptr++;  
1927      *ptr = swap_uint16(*ptr);      *ptr = swap_uint16(*ptr);
1928        ptr++;
1929      if (LINK_SIZE > 1)      if (LINK_SIZE > 1)
1930        {        {
       /* LINK_SIZE can be 1 or 2 in 16 bit mode. */  
       ptr++;  
1931        *ptr = swap_uint16(*ptr);        *ptr = swap_uint16(*ptr);
1932          ptr++;
1933        }        }
     ptr++;  
   
     if (LINK_SIZE > 1)  
       length = ((ptr[-LINK_SIZE] << 16) | ptr[-LINK_SIZE + 1]) -  
         (1 + LINK_SIZE + 1);  
     else  
       length = ptr[-LINK_SIZE] - (1 + LINK_SIZE + 1);  
1934    
1935      op = *ptr;      op = *ptr;
1936      *ptr = swap_uint16(op);      *ptr = swap_uint16(op);
1937        ptr++;
1938      if ((op & XCL_MAP) != 0)      if ((op & XCL_MAP) != 0)
1939        {        {
1940        /* Skip the character bit map. */        /* Skip the character bit map. */
# Line 2082  printf("     pcre16       16 bit library Line 2085  printf("     pcre16       16 bit library
2085  printf("     utf          Unicode Transformation Format supported [0, 1]\n");  printf("     utf          Unicode Transformation Format supported [0, 1]\n");
2086  printf("     ucp          Unicode Properties supported [0, 1]\n");  printf("     ucp          Unicode Properties supported [0, 1]\n");
2087  printf("     jit          Just-in-time compiler supported [0, 1]\n");  printf("     jit          Just-in-time compiler supported [0, 1]\n");
2088    printf("     newline      Newline type [CR, LF, CRLF, ANYCRLF, ANY, ???]\n");
2089  printf("  -d       debug: show compiled code and information (-b and -i)\n");  printf("  -d       debug: show compiled code and information (-b and -i)\n");
2090  #if !defined NODFA  #if !defined NODFA
2091  printf("  -dfa     force DFA matching for all subjects\n");  printf("  -dfa     force DFA matching for all subjects\n");
# Line 2331  while (argc > 1 && argv[op][0] == '-') Line 2335  while (argc > 1 && argv[op][0] == '-')
2335          yield = rc;          yield = rc;
2336          goto EXIT;          goto EXIT;
2337          }          }
2338        printf("Unknown option: %s\n", argv[op + 1]);        if (strcmp(argv[op + 1], "newline") == 0)
2339            {
2340            (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);
2341            /* Note that these values are always the ASCII values, even
2342            in EBCDIC environments. CR is 13 and NL is 10. */
2343            printf("%s\n", (rc == 13)? "CR" :
2344              (rc == 10)? "LF" : (rc == (13<<8 | 10))? "CRLF" :
2345              (rc == -2)? "ANYCRLF" :
2346              (rc == -1)? "ANY" : "???");
2347            goto EXIT;
2348            }
2349          printf("Unknown -C option: %s\n", argv[op + 1]);
2350        goto EXIT;        goto EXIT;
2351        }        }
2352    
# Line 2477  while (!done) Line 2492  while (!done)
2492    pcre_uint8 *p, *pp, *ppp;    pcre_uint8 *p, *pp, *ppp;
2493    pcre_uint8 *to_file = NULL;    pcre_uint8 *to_file = NULL;
2494    const pcre_uint8 *tables = NULL;    const pcre_uint8 *tables = NULL;
2495      pcre_uint32 get_options;
2496    unsigned long int true_size, true_study_size = 0;    unsigned long int true_size, true_study_size = 0;
2497    size_t size, regex_gotten_store;    size_t size, regex_gotten_store;
2498    int do_allcaps = 0;    int do_allcaps = 0;
# Line 2507  while (!done) Line 2523  while (!done)
2523    
2524    if (*p == '<' && strchr((char *)(p+1), '<') == NULL)    if (*p == '<' && strchr((char *)(p+1), '<') == NULL)
2525      {      {
2526      unsigned long int magic, get_options;      pcre_uint32 magic;
2527      pcre_uint8 sbuf[8];      pcre_uint8 sbuf[8];
2528      FILE *f;      FILE *f;
2529    
2530      p++;      p++;
2531        if (*p == '!')
2532          {
2533          do_debug = TRUE;
2534          do_showinfo = TRUE;
2535          p++;
2536          }
2537    
2538      pp = p + (int)strlen((char *)p);      pp = p + (int)strlen((char *)p);
2539      while (isspace(pp[-1])) pp--;      while (isspace(pp[-1])) pp--;
2540      *pp = 0;      *pp = 0;
# Line 2523  while (!done) Line 2546  while (!done)
2546        continue;        continue;
2547        }        }
2548    
2549        first_gotten_store = 0;
2550      if (fread(sbuf, 1, 8, f) != 8) goto FAIL_READ;      if (fread(sbuf, 1, 8, f) != 8) goto FAIL_READ;
2551    
2552      true_size =      true_size =
# Line 2550  while (!done) Line 2574  while (!done)
2574          }          }
2575        }        }
2576    
2577        /* We hide the byte-invert info for little and big endian tests. */
2578      fprintf(outfile, "Compiled pattern%s loaded from %s\n",      fprintf(outfile, "Compiled pattern%s loaded from %s\n",
2579        do_flip? " (byte-inverted)" : "", p);        do_flip && (p[-1] == '<') ? " (byte-inverted)" : "", p);
2580    
2581      /* Now see if there is any following study data. */      /* Now see if there is any following study data. */
2582    
# Line 2585  while (!done) Line 2610  while (!done)
2610      /* Flip the necessary bytes. */      /* Flip the necessary bytes. */
2611      if (do_flip)      if (do_flip)
2612        {        {
2613        PCRE_PATTERN_TO_HOST_BYTE_ORDER(re, extra, NULL);        int rc;
2614          PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, NULL);
2615          if (rc == PCRE_ERROR_BADMODE)
2616            {
2617            /* Simulate the result of the function call below. */
2618            fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc,
2619              use_pcre16? "16" : "", PCRE_INFO_OPTIONS);
2620            fprintf(outfile, "Running in %s-bit mode but pattern was compiled in "
2621              "%s-bit mode\n", use_pcre16? "16":"8", use_pcre16? "8":"16");
2622            continue;
2623            }
2624        }        }
2625    
2626      /* Need to know if UTF-8 for printing data strings. */      /* Need to know if UTF-8 for printing data strings. */
# Line 2818  while (!done) Line 2853  while (!done)
2853  #endif  /* !defined NOPOSIX */  #endif  /* !defined NOPOSIX */
2854    
2855      {      {
     unsigned long int get_options;  
   
2856      /* In 16-bit mode, convert the input. */      /* In 16-bit mode, convert the input. */
2857    
2858  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16

Legend:
Removed from v.836  
changed lines
  Added in v.841

  ViewVC Help
Powered by ViewVC 1.1.5