/[pcre]/code/trunk/pcre_dfa_exec.c
ViewVC logotype

Diff of /code/trunk/pcre_dfa_exec.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 926 by ph10, Wed Feb 22 15:01:32 2012 UTC revision 960 by ph10, Thu Apr 19 17:30:38 2012 UTC
# Line 41  POSSIBILITY OF SUCH DAMAGE. Line 41  POSSIBILITY OF SUCH DAMAGE.
41    
42  /* This module contains the external function pcre_dfa_exec(), which is an  /* This module contains the external function pcre_dfa_exec(), which is an
43  alternative matching function that uses a sort of DFA algorithm (not a true  alternative matching function that uses a sort of DFA algorithm (not a true
44  FSM). This is NOT Perl- compatible, but it has advantages in certain  FSM). This is NOT Perl-compatible, but it has advantages in certain
45  applications. */  applications. */
46    
47    
# Line 282  typedef struct stateblock { Line 282  typedef struct stateblock {
282    int data;                       /* Some use extra data */    int data;                       /* Some use extra data */
283  } stateblock;  } stateblock;
284    
285  #define INTS_PER_STATEBLOCK  (sizeof(stateblock)/sizeof(int))  #define INTS_PER_STATEBLOCK  (int)(sizeof(stateblock)/sizeof(int))
286    
287    
288  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
# Line 3162  if (offsetcount < 0) return PCRE_ERROR_B Line 3162  if (offsetcount < 0) return PCRE_ERROR_B
3162  if (wscount < 20) return PCRE_ERROR_DFA_WSSIZE;  if (wscount < 20) return PCRE_ERROR_DFA_WSSIZE;
3163  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;
3164    
3165  /* We need to find the pointer to any study data before we test for byte  /* Check that the first field in the block is the magic number. If it is not,
3166  flipping, so we scan the extra_data block first. This may set two fields in the  return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to
3167  match block, so we must initialize them beforehand. However, the other fields  REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which
3168  in the match block must not be set until after the byte flipping. */  means that the pattern is likely compiled with different endianness. */
3169    
3170    if (re->magic_number != MAGIC_NUMBER)
3171      return re->magic_number == REVERSED_MAGIC_NUMBER?
3172        PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;
3173    if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
3174    
3175    /* If restarting after a partial match, do some sanity checks on the contents
3176    of the workspace. */
3177    
3178    if ((options & PCRE_DFA_RESTART) != 0)
3179      {
3180      if ((workspace[0] & (-2)) != 0 || workspace[1] < 1 ||
3181        workspace[1] > (wscount - 2)/INTS_PER_STATEBLOCK)
3182          return PCRE_ERROR_DFA_BADRESTART;
3183      }
3184    
3185    /* Set up study, callout, and table data */
3186    
3187  md->tables = re->tables;  md->tables = re->tables;
3188  md->callout_data = NULL;  md->callout_data = NULL;
# Line 3184  if (extra_data != NULL) Line 3201  if (extra_data != NULL)
3201      md->tables = extra_data->tables;      md->tables = extra_data->tables;
3202    }    }
3203    
 /* Check that the first field in the block is the magic number. If it is not,  
 return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to  
 REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which  
 means that the pattern is likely compiled with different endianness. */  
   
 if (re->magic_number != MAGIC_NUMBER)  
   return re->magic_number == REVERSED_MAGIC_NUMBER?  
     PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;  
 if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;  
   
3204  /* Set some local values */  /* Set some local values */
3205    
3206  current_subject = (const pcre_uchar *)subject + start_offset;  current_subject = (const pcre_uchar *)subject + start_offset;

Legend:
Removed from v.926  
changed lines
  Added in v.960

  ViewVC Help
Powered by ViewVC 1.1.5