/[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 839 by zherczeg, Fri Dec 30 13:22:28 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 2512  while (!done) Line 2527  while (!done)
2527      FILE *f;      FILE *f;
2528    
2529      p++;      p++;
2530        if (*p == '!')
2531          {
2532          do_debug = TRUE;
2533          do_showinfo = TRUE;
2534          p++;
2535          }
2536    
2537      pp = p + (int)strlen((char *)p);      pp = p + (int)strlen((char *)p);
2538      while (isspace(pp[-1])) pp--;      while (isspace(pp[-1])) pp--;
2539      *pp = 0;      *pp = 0;
# Line 2523  while (!done) Line 2545  while (!done)
2545        continue;        continue;
2546        }        }
2547    
2548        first_gotten_store = 0;
2549      if (fread(sbuf, 1, 8, f) != 8) goto FAIL_READ;      if (fread(sbuf, 1, 8, f) != 8) goto FAIL_READ;
2550    
2551      true_size =      true_size =
# Line 2550  while (!done) Line 2573  while (!done)
2573          }          }
2574        }        }
2575    
2576        /* We hide the byte-invert info for little and big endian tests. */
2577      fprintf(outfile, "Compiled pattern%s loaded from %s\n",      fprintf(outfile, "Compiled pattern%s loaded from %s\n",
2578        do_flip? " (byte-inverted)" : "", p);        do_flip && (p[-1] == '<') ? " (byte-inverted)" : "", p);
2579    
2580      /* Now see if there is any following study data. */      /* Now see if there is any following study data. */
2581    
# Line 2585  while (!done) Line 2609  while (!done)
2609      /* Flip the necessary bytes. */      /* Flip the necessary bytes. */
2610      if (do_flip)      if (do_flip)
2611        {        {
2612        PCRE_PATTERN_TO_HOST_BYTE_ORDER(re, extra, NULL);        int rc;
2613          PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, NULL);
2614          if (rc == PCRE_ERROR_BADMODE)
2615            {
2616            /* Simulate the result of the function call below. */
2617            fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc,
2618              use_pcre16? "16" : "", PCRE_INFO_OPTIONS);
2619            fprintf(outfile, "Running in %s-bit mode but pattern was compiled in "
2620              "%s-bit mode\n", use_pcre16? "16":"8", use_pcre16? "8":"16");
2621            continue;
2622            }
2623        }        }
2624    
2625      /* Need to know if UTF-8 for printing data strings. */      /* Need to know if UTF-8 for printing data strings. */

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

  ViewVC Help
Powered by ViewVC 1.1.5