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

Diff of /code/trunk/pcre_exec.c

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

revision 892 by ph10, Wed Jan 18 17:23:20 2012 UTC revision 893 by ph10, Thu Jan 19 17:15:11 2012 UTC
# Line 615  int save_offset1, save_offset2, save_off Line 615  int save_offset1, save_offset2, save_off
615  int stacksave[REC_STACK_SAVE_MAX];  int stacksave[REC_STACK_SAVE_MAX];
616    
617  eptrblock newptrb;  eptrblock newptrb;
618    
619    /* There is a special fudge for calling match() in a way that causes it to
620    measure the size of its basic stack frame when the stack is being used for
621    recursion. The first argument (eptr) points to a pointer that is used
622    "statically" for doing the calculation. The second argument (ecode) being NULL
623    triggers this behaviour. It cannot normally every be NULL. The return is the
624    negated value of the frame size. */
625    
626    if (ecode == NULL)
627      {
628      char **aptr = (char **)eptr;
629      if (rdepth == 0)
630        {
631        *aptr = (char *)&rdepth;
632        return match(eptr, NULL, NULL, 0, NULL, NULL, 1);
633        }
634      else
635        {
636        int len = (char *)&rdepth - *aptr;
637        return (len > 0)? -len : len;
638        }
639      }
640  #endif     /* NO_RECURSE */  #endif     /* NO_RECURSE */
641    
642  /* To save space on the stack and in the heap frame, I have doubled up on some  /* To save space on the stack and in the heap frame, I have doubled up on some
# Line 6190  PCRE_PUCHAR req_char_ptr = start_match - Line 6212  PCRE_PUCHAR req_char_ptr = start_match -
6212  const pcre_study_data *study;  const pcre_study_data *study;
6213  const REAL_PCRE *re = (const REAL_PCRE *)argument_re;  const REAL_PCRE *re = (const REAL_PCRE *)argument_re;
6214    
6215    /* Check for the special magic call that measures the size of the stack used
6216    per recursive call of match(). */
6217    
6218    if (re == NULL && extra_data == NULL && subject == NULL && length == -1)
6219    #ifdef NO_RECURSE
6220      return -sizeof(heapframe);
6221    #else
6222      return match((PCRE_PUCHAR)&start_partial, NULL, NULL, 0, NULL, NULL, 0);
6223    #endif
6224    
6225  /* Plausibility checks */  /* Plausibility checks */
6226    
6227  if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;  if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
6228  if (re == NULL || subject == NULL ||  if (re == NULL || subject == NULL || (offsets == NULL && offsetcount > 0))
6229     (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;    return PCRE_ERROR_NULL;
6230  if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;  if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;
6231  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;
6232    
6233    /* Check that the first field in the block is the magic number. If it is not,
6234    return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to
6235    REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which
6236    means that the pattern is likely compiled with different endianness. */
6237    
6238    if (re->magic_number != MAGIC_NUMBER)
6239      return re->magic_number == REVERSED_MAGIC_NUMBER?
6240        PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;
6241    if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
6242    
6243  /* These two settings are used in the code for checking a UTF-8 string that  /* These two settings are used in the code for checking a UTF-8 string that
6244  follows immediately afterwards. Other values in the md block are used only  follows immediately afterwards. Other values in the md block are used only
6245  during "normal" pcre_exec() processing, not when the JIT support is in use,  during "normal" pcre_exec() processing, not when the JIT support is in use,
# Line 6297  in other programs later. */ Line 6339  in other programs later. */
6339    
6340  if (tables == NULL) tables = PRIV(default_tables);  if (tables == NULL) tables = PRIV(default_tables);
6341    
 /* 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;  
   
6342  /* Set up other data */  /* Set up other data */
6343    
6344  anchored = ((re->options | options) & PCRE_ANCHORED) != 0;  anchored = ((re->options | options) & PCRE_ANCHORED) != 0;

Legend:
Removed from v.892  
changed lines
  Added in v.893

  ViewVC Help
Powered by ViewVC 1.1.5