/[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 121 by ph10, Mon Mar 12 12:12:47 2007 UTC revision 145 by ph10, Wed Apr 4 14:06:52 2007 UTC
# Line 67  input mode under Windows. */ Line 67  input mode under Windows. */
67  #endif  #endif
68    
69    
70  #define PCRE_SPY        /* For Win32 build, import data, not export */  /* We have to include pcre_internal.h because we need the internal info for
71    displaying the results of pcre_study() and we also need to know about the
72  /* We include pcre_internal.h because we need the internal info for displaying  internal macros, structures, and other internal data values; pcretest has
73  the results of pcre_study() and we also need to know about the internal  "inside information" compared to a program that strictly follows the PCRE API.
74  macros, structures, and other internal data values; pcretest has "inside  
75  information" compared to a program that strictly follows the PCRE API. */  Although pcre_internal.h does itself include pcre.h, we explicitly include it
76    here before pcre_internal.h so that the PCRE_EXP_xxx macros get set
77    appropriately for an application, not for building PCRE. */
78    
79    #include "pcre.h"
80  #include "pcre_internal.h"  #include "pcre_internal.h"
81    
82  /* We need access to the data tables that PCRE uses. So as not to have to keep  /* We need access to the data tables that PCRE uses. So as not to have to keep
# Line 944  while (!done) Line 947  while (!done)
947    size_t size, regex_gotten_store;    size_t size, regex_gotten_store;
948    int do_study = 0;    int do_study = 0;
949    int do_debug = debug;    int do_debug = debug;
950    int debug_lengths = 1;    int debug_lengths = 1;
951    int do_G = 0;    int do_G = 0;
952    int do_g = 0;    int do_g = 0;
953    int do_showinfo = showinfo;    int do_showinfo = showinfo;
# Line 1135  while (!done) Line 1138  while (!done)
1138        case 'S': do_study = 1; break;        case 'S': do_study = 1; break;
1139        case 'U': options |= PCRE_UNGREEDY; break;        case 'U': options |= PCRE_UNGREEDY; break;
1140        case 'X': options |= PCRE_EXTRA; break;        case 'X': options |= PCRE_EXTRA; break;
1141        case 'Z': debug_lengths = 0;        case 'Z': debug_lengths = 0; break;
1142        case '8': options |= PCRE_UTF8; use_utf8 = 1; break;        case '8': options |= PCRE_UTF8; use_utf8 = 1; break;
1143        case '?': options |= PCRE_NO_UTF8_CHECK; break;        case '?': options |= PCRE_NO_UTF8_CHECK; break;
1144    
# Line 2211  while (!done) Line 2214  while (!done)
2214          }          }
2215    
2216        /* Failed to match. If this is a /g or /G loop and we previously set        /* Failed to match. If this is a /g or /G loop and we previously set
2217        g_notempty after a null match, this is not necessarily the end.        g_notempty after a null match, this is not necessarily the end. We want
2218        We want to advance the start offset, and continue. In the case of UTF-8        to advance the start offset, and continue. We won't be at the end of the
2219        matching, the advance must be one character, not one byte. Fudge the        string - that was checked before setting g_notempty.
2220        offset values to achieve this. We won't be at the end of the string -  
2221        that was checked before setting g_notempty. */        Complication arises in the case when the newline option is "any".
2222          If the previous match was at the end of a line terminated by CRLF, an
2223          advance of one character just passes the \r, whereas we should prefer the
2224          longer newline sequence, as does the code in pcre_exec(). Fudge the
2225          offset value to achieve this.
2226    
2227          Otherwise, in the case of UTF-8 matching, the advance must be one
2228          character, not one byte. */
2229    
2230        else        else
2231          {          {
# Line 2223  while (!done) Line 2233  while (!done)
2233            {            {
2234            int onechar = 1;            int onechar = 1;
2235            use_offsets[0] = start_offset;            use_offsets[0] = start_offset;
2236            if (use_utf8)            if ((((real_pcre *)re)->options & PCRE_NEWLINE_BITS) ==
2237                      PCRE_NEWLINE_ANY &&
2238                  start_offset < len - 1 &&
2239                  bptr[start_offset] == '\r' &&
2240                  bptr[start_offset+1] == '\n')
2241                onechar++;
2242              else if (use_utf8)
2243              {              {
2244              while (start_offset + onechar < len)              while (start_offset + onechar < len)
2245                {                {
# Line 2258  while (!done) Line 2274  while (!done)
2274        character. */        character. */
2275    
2276        g_notempty = 0;        g_notempty = 0;
2277    
2278        if (use_offsets[0] == use_offsets[1])        if (use_offsets[0] == use_offsets[1])
2279          {          {
2280          if (use_offsets[0] == len) break;          if (use_offsets[0] == len) break;

Legend:
Removed from v.121  
changed lines
  Added in v.145

  ViewVC Help
Powered by ViewVC 1.1.5