/[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 1248 by ph10, Wed Feb 13 17:36:38 2013 UTC revision 1313 by ph10, Wed Apr 24 12:07:09 2013 UTC
# Line 121  input mode under Windows. */ Line 121  input mode under Windows. */
121  #endif  #endif
122  #endif  #endif
123    
124    #ifdef __VMS
125    #include <ssdef.h>
126    void vms_setsymbol( char *, char *, int );
127    #endif
128    
129    
130  #define PRIV(name) name  #define PRIV(name) name
131    
132  /* We have to include pcre_internal.h because we need the internal info for  /* We have to include pcre_internal.h because we need the internal info for
# Line 1790  Returns:       TRUE  if the string is a Line 1796  Returns:       TRUE  if the string is a
1796                 FALSE otherwise                 FALSE otherwise
1797  */  */
1798    
1799  #ifdef NEVER  #ifdef NEVER   /* Not used */
   
1800  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
1801  static BOOL  static BOOL
1802  valid_utf32(pcre_uint32 *string, int length)  valid_utf32(pcre_uint32 *string, int length)
# Line 1802  register pcre_uint32 c; Line 1807  register pcre_uint32 c;
1807  for (p = string; length-- > 0; p++)  for (p = string; length-- > 0; p++)
1808    {    {
1809    c = *p;    c = *p;
1810      if (c > 0x10ffffu) return FALSE;                 /* Too big */
1811    if (c > 0x10ffffu)    if ((c & 0xfffff800u) == 0xd800u) return FALSE;  /* Surrogate */
     return FALSE;  
   
   /* A surrogate */  
   if ((c & 0xfffff800u) == 0xd800u)  
     return FALSE;  
   
   /* Non-character */  
   if ((c & 0xfffeu) == 0xfffeu || (c >= 0xfdd0u && c <= 0xfdefu))  
     return FALSE;  
1812    }    }
1813    
1814  return TRUE;  return TRUE;
1815  }  }
1816  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
   
1817  #endif /* NEVER */  #endif /* NEVER */
1818    #endif /* SUPPORT_PCRE32 */
1819    
1820    
 #endif  
   
1821  /*************************************************  /*************************************************
1822  *        Read or extend an input line            *  *        Read or extend an input line            *
1823  *************************************************/  *************************************************/
# Line 2082  while (length-- > 0) Line 2076  while (length-- > 0)
2076    if (use_utf && c >= 0xD800 && c < 0xDC00 && length > 0)    if (use_utf && c >= 0xD800 && c < 0xDC00 && length > 0)
2077      {      {
2078      int d = *p & 0xffff;      int d = *p & 0xffff;
2079      if (d >= 0xDC00 && d < 0xDFFF)      if (d >= 0xDC00 && d <= 0xDFFF)
2080        {        {
2081        c = ((c & 0x3ff) << 10) + (d & 0x3ff) + 0x10000;        c = ((c & 0x3ff) << 10) + (d & 0x3ff) + 0x10000;
2082        length--;        length--;
# Line 2401  else Line 2395  else
2395    rc = PCRE_ERROR_BADMODE;    rc = PCRE_ERROR_BADMODE;
2396  #endif  #endif
2397    
2398  if (rc < 0)  if (rc < 0 && rc != PCRE_ERROR_UNSET)
2399    {    {
2400    fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc,    fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc,
2401      pcre_mode == PCRE32_MODE ? "32" : pcre_mode == PCRE16_MODE ? "16" : "", option);      pcre_mode == PCRE32_MODE ? "32" : pcre_mode == PCRE16_MODE ? "16" : "", option);
# Line 2477  BOOL utf16_char = FALSE; Line 2471  BOOL utf16_char = FALSE;
2471  re->magic_number = REVERSED_MAGIC_NUMBER;  re->magic_number = REVERSED_MAGIC_NUMBER;
2472  re->size = swap_uint32(re->size);  re->size = swap_uint32(re->size);
2473  re->options = swap_uint32(re->options);  re->options = swap_uint32(re->options);
2474  re->flags = swap_uint16(re->flags);  re->flags = swap_uint32(re->flags);
2475  re->top_bracket = swap_uint16(re->top_bracket);  re->limit_match = swap_uint32(re->limit_match);
2476  re->top_backref = swap_uint16(re->top_backref);  re->limit_recursion = swap_uint32(re->limit_recursion);
2477  re->first_char = swap_uint16(re->first_char);  re->first_char = swap_uint16(re->first_char);
2478  re->req_char = swap_uint16(re->req_char);  re->req_char = swap_uint16(re->req_char);
2479    re->max_lookbehind = swap_uint16(re->max_lookbehind);
2480    re->top_bracket = swap_uint16(re->top_bracket);
2481    re->top_backref = swap_uint16(re->top_backref);
2482  re->name_table_offset = swap_uint16(re->name_table_offset);  re->name_table_offset = swap_uint16(re->name_table_offset);
2483  re->name_entry_size = swap_uint16(re->name_entry_size);  re->name_entry_size = swap_uint16(re->name_entry_size);
2484  re->name_count = swap_uint16(re->name_count);  re->name_count = swap_uint16(re->name_count);
2485    re->ref_count = swap_uint16(re->ref_count);
2486    
2487  if (extra != NULL)  if (extra != NULL)
2488    {    {
# Line 2654  int length = re->name_count * re->name_e Line 2652  int length = re->name_count * re->name_e
2652  re->magic_number = REVERSED_MAGIC_NUMBER;  re->magic_number = REVERSED_MAGIC_NUMBER;
2653  re->size = swap_uint32(re->size);  re->size = swap_uint32(re->size);
2654  re->options = swap_uint32(re->options);  re->options = swap_uint32(re->options);
2655  re->flags = swap_uint16(re->flags);  re->flags = swap_uint32(re->flags);
2656  re->top_bracket = swap_uint16(re->top_bracket);  re->limit_match = swap_uint32(re->limit_match);
2657  re->top_backref = swap_uint16(re->top_backref);  re->limit_recursion = swap_uint32(re->limit_recursion);
2658  re->first_char = swap_uint32(re->first_char);  re->first_char = swap_uint32(re->first_char);
2659  re->req_char = swap_uint32(re->req_char);  re->req_char = swap_uint32(re->req_char);
2660    re->max_lookbehind = swap_uint16(re->max_lookbehind);
2661    re->top_bracket = swap_uint16(re->top_bracket);
2662    re->top_backref = swap_uint16(re->top_backref);
2663  re->name_table_offset = swap_uint16(re->name_table_offset);  re->name_table_offset = swap_uint16(re->name_table_offset);
2664  re->name_entry_size = swap_uint16(re->name_entry_size);  re->name_entry_size = swap_uint16(re->name_entry_size);
2665  re->name_count = swap_uint16(re->name_count);  re->name_count = swap_uint16(re->name_count);
2666    re->ref_count = swap_uint16(re->ref_count);
2667    
2668  if (extra != NULL)  if (extra != NULL)
2669    {    {
# Line 3099  while (argc > 1 && argv[op][0] == '-') Line 3101  while (argc > 1 && argv[op][0] == '-')
3101        ((stack_size = get_value((pcre_uint8 *)argv[op+1], &endptr)),        ((stack_size = get_value((pcre_uint8 *)argv[op+1], &endptr)),
3102          *endptr == 0))          *endptr == 0))
3103      {      {
3104  #if defined(_WIN32) || defined(WIN32) || defined(__minix) || defined(NATIVE_ZOS)  #if defined(_WIN32) || defined(WIN32) || defined(__minix) || defined(NATIVE_ZOS) || defined(__VMS)
3105      printf("PCRE: -S not supported on this OS\n");      printf("PCRE: -S not supported on this OS\n");
3106      exit(1);      exit(1);
3107  #else  #else
# Line 3132  while (argc > 1 && argv[op][0] == '-') Line 3134  while (argc > 1 && argv[op][0] == '-')
3134          (void)PCRE_CONFIG(PCRE_CONFIG_LINK_SIZE, &rc);          (void)PCRE_CONFIG(PCRE_CONFIG_LINK_SIZE, &rc);
3135          printf("%d\n", rc);          printf("%d\n", rc);
3136          yield = rc;          yield = rc;
3137    
3138    #ifdef __VMS
3139            vms_setsymbol("LINKSIZE",0,yield );
3140    #endif
3141          }          }
3142        else if (strcmp(argv[op + 1], "pcre8") == 0)        else if (strcmp(argv[op + 1], "pcre8") == 0)
3143          {          {
# Line 3142  while (argc > 1 && argv[op][0] == '-') Line 3148  while (argc > 1 && argv[op][0] == '-')
3148          printf("0\n");          printf("0\n");
3149          yield = 0;          yield = 0;
3150  #endif  #endif
3151          goto EXIT;  #ifdef __VMS
3152            vms_setsymbol("PCRE8",0,yield );
3153    #endif
3154          }          }
3155        else if (strcmp(argv[op + 1], "pcre16") == 0)        else if (strcmp(argv[op + 1], "pcre16") == 0)
3156          {          {
# Line 3153  while (argc > 1 && argv[op][0] == '-') Line 3161  while (argc > 1 && argv[op][0] == '-')
3161          printf("0\n");          printf("0\n");
3162          yield = 0;          yield = 0;
3163  #endif  #endif
3164          goto EXIT;  #ifdef __VMS
3165            vms_setsymbol("PCRE16",0,yield );
3166    #endif
3167          }          }
3168        else if (strcmp(argv[op + 1], "pcre32") == 0)        else if (strcmp(argv[op + 1], "pcre32") == 0)
3169          {          {
# Line 3164  while (argc > 1 && argv[op][0] == '-') Line 3174  while (argc > 1 && argv[op][0] == '-')
3174          printf("0\n");          printf("0\n");
3175          yield = 0;          yield = 0;
3176  #endif  #endif
3177          goto EXIT;  #ifdef __VMS
3178            vms_setsymbol("PCRE32",0,yield );
3179    #endif
3180          }          }
3181        if (strcmp(argv[op + 1], "utf") == 0)        else if (strcmp(argv[op + 1], "utf") == 0)
3182          {          {
3183  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
3184          if (pcre_mode == PCRE8_MODE)          if (pcre_mode == PCRE8_MODE)
# Line 3182  while (argc > 1 && argv[op][0] == '-') Line 3194  while (argc > 1 && argv[op][0] == '-')
3194  #endif  #endif
3195          printf("%d\n", rc);          printf("%d\n", rc);
3196          yield = rc;          yield = rc;
3197          goto EXIT;  #ifdef __VMS
3198            vms_setsymbol("UTF",0,yield );
3199    #endif
3200          }          }
3201        else if (strcmp(argv[op + 1], "ucp") == 0)        else if (strcmp(argv[op + 1], "ucp") == 0)
3202          {          {
# Line 3519  while (!done) Line 3533  while (!done)
3533        PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, NULL);        PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, NULL);
3534        if (rc == PCRE_ERROR_BADMODE)        if (rc == PCRE_ERROR_BADMODE)
3535          {          {
3536          pcre_uint16 flags_in_host_byte_order;          pcre_uint32 flags_in_host_byte_order;
3537          if (REAL_PCRE_MAGIC(re) == MAGIC_NUMBER)          if (REAL_PCRE_MAGIC(re) == MAGIC_NUMBER)
3538            flags_in_host_byte_order = REAL_PCRE_FLAGS(re);            flags_in_host_byte_order = REAL_PCRE_FLAGS(re);
3539          else          else
3540            flags_in_host_byte_order = swap_uint16(REAL_PCRE_FLAGS(re));            flags_in_host_byte_order = swap_uint32(REAL_PCRE_FLAGS(re));
3541          /* Simulate the result of the function call below. */          /* Simulate the result of the function call below. */
3542          fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc,          fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc,
3543            pcre_mode == PCRE32_MODE ? "32" : pcre_mode == PCRE16_MODE ? "16" : "",            pcre_mode == PCRE32_MODE ? "32" : pcre_mode == PCRE16_MODE ? "16" : "",
# Line 3683  while (!done) Line 3697  while (!done)
3697        case 'Y': options |= PCRE_NO_START_OPTIMISE; break;        case 'Y': options |= PCRE_NO_START_OPTIMISE; break;
3698        case 'Z': debug_lengths = 0; break;        case 'Z': debug_lengths = 0; break;
3699        case '8': options |= PCRE_UTF8; use_utf = 1; break;        case '8': options |= PCRE_UTF8; use_utf = 1; break;
3700          case '9': options |= PCRE_NEVER_UTF; break;
3701        case '?': options |= PCRE_NO_UTF8_CHECK; break;        case '?': options |= PCRE_NO_UTF8_CHECK; break;
3702    
3703        case 'T':        case 'T':
# Line 4003  while (!done) Line 4018  while (!done)
4018        {        {
4019        unsigned long int all_options;        unsigned long int all_options;
4020        pcre_uint32 first_char, need_char;        pcre_uint32 first_char, need_char;
4021          pcre_uint32 match_limit, recursion_limit;
4022        int count, backrefmax, first_char_set, need_char_set, okpartial, jchanged,        int count, backrefmax, first_char_set, need_char_set, okpartial, jchanged,
4023          hascrorlf, maxlookbehind;          hascrorlf, maxlookbehind;
4024        int nameentrysize, namecount;        int nameentrysize, namecount;
# Line 4030  while (!done) Line 4046  while (!done)
4046          (int)size, (int)regex_gotten_store);          (int)size, (int)regex_gotten_store);
4047    
4048        fprintf(outfile, "Capturing subpattern count = %d\n", count);        fprintf(outfile, "Capturing subpattern count = %d\n", count);
4049    
4050        if (backrefmax > 0)        if (backrefmax > 0)
4051          fprintf(outfile, "Max back reference = %d\n", backrefmax);          fprintf(outfile, "Max back reference = %d\n", backrefmax);
4052    
4053          if (maxlookbehind > 0)
4054            fprintf(outfile, "Max lookbehind = %d\n", maxlookbehind);
4055    
4056          if (new_info(re, NULL, PCRE_INFO_MATCHLIMIT, &match_limit) == 0)
4057            fprintf(outfile, "Match limit = %u\n", match_limit);
4058    
4059          if (new_info(re, NULL, PCRE_INFO_RECURSIONLIMIT, &recursion_limit) == 0)
4060            fprintf(outfile, "Recursion limit = %u\n", recursion_limit);
4061    
4062        if (namecount > 0)        if (namecount > 0)
4063          {          {
4064          fprintf(outfile, "Named capturing subpatterns:\n");          fprintf(outfile, "Named capturing subpatterns:\n");
# Line 4066  while (!done) Line 4092  while (!done)
4092        if (do_flip) all_options = swap_uint32(all_options);        if (do_flip) all_options = swap_uint32(all_options);
4093    
4094        if (get_options == 0) fprintf(outfile, "No options\n");        if (get_options == 0) fprintf(outfile, "No options\n");
4095          else fprintf(outfile, "Options:%s%s%s%s%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%s%s%s\n",
4096            ((get_options & PCRE_ANCHORED) != 0)? " anchored" : "",            ((get_options & PCRE_ANCHORED) != 0)? " anchored" : "",
4097            ((get_options & PCRE_CASELESS) != 0)? " caseless" : "",            ((get_options & PCRE_CASELESS) != 0)? " caseless" : "",
4098            ((get_options & PCRE_EXTENDED) != 0)? " extended" : "",            ((get_options & PCRE_EXTENDED) != 0)? " extended" : "",
# Line 4083  while (!done) Line 4109  while (!done)
4109            ((get_options & PCRE_UCP) != 0)? " ucp" : "",            ((get_options & PCRE_UCP) != 0)? " ucp" : "",
4110            ((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf_check" : "",            ((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf_check" : "",
4111            ((get_options & PCRE_NO_START_OPTIMIZE) != 0)? " no_start_optimize" : "",            ((get_options & PCRE_NO_START_OPTIMIZE) != 0)? " no_start_optimize" : "",
4112            ((get_options & PCRE_DUPNAMES) != 0)? " dupnames" : "");            ((get_options & PCRE_DUPNAMES) != 0)? " dupnames" : "",
4113              ((get_options & PCRE_NEVER_UTF) != 0)? " never_utf" : "");
4114    
4115        if (jchanged) fprintf(outfile, "Duplicate name status changes\n");        if (jchanged) fprintf(outfile, "Duplicate name status changes\n");
4116    
# Line 4157  while (!done) Line 4184  while (!done)
4184            }            }
4185          }          }
4186    
       if (maxlookbehind > 0)  
         fprintf(outfile, "Max lookbehind = %d\n", maxlookbehind);  
   
4187        /* Don't output study size; at present it is in any case a fixed        /* Don't output study size; at present it is in any case a fixed
4188        value, but it varies, depending on the computer architecture, and        value, but it varies, depending on the computer architecture, and
4189        so messes up the test suite. (And with the /F option, it might be        so messes up the test suite. (And with the /F option, it might be
# Line 5263  while (!done) Line 5287  while (!done)
5287            }            }
5288          }          }
5289    
5290        /* There was a partial match */        /* There was a partial match. If the bumpalong point is not the same as
5291          the first inspected character, show the offset explicitly. */
5292    
5293        else if (count == PCRE_ERROR_PARTIAL)        else if (count == PCRE_ERROR_PARTIAL)
5294          {          {
5295          if (markptr == NULL) fprintf(outfile, "Partial match");          fprintf(outfile, "Partial match");
5296          else          if (use_size_offsets > 2 && use_offsets[0] != use_offsets[2])
5297              fprintf(outfile, " at offset %d", use_offsets[2]);
5298            if (markptr != NULL)
5299            {            {
5300            fprintf(outfile, "Partial match, mark=");            fprintf(outfile, ", mark=");
5301            PCHARSV(markptr, 0, -1, outfile);            PCHARSV(markptr, 0, -1, outfile);
5302            }            }
5303          if (use_size_offsets > 1)          if (use_size_offsets > 1)
# Line 5484  if (dfa_workspace != NULL) Line 5511  if (dfa_workspace != NULL)
5511    free(dfa_workspace);    free(dfa_workspace);
5512  #endif  #endif
5513    
5514    #if defined(__VMS)
5515      yield = SS$_NORMAL;  /* Return values via DCL symbols */
5516    #endif
5517    
5518  return yield;  return yield;
5519  }  }
5520    

Legend:
Removed from v.1248  
changed lines
  Added in v.1313

  ViewVC Help
Powered by ViewVC 1.1.5