/[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 850 by zherczeg, Wed Jan 4 17:29:11 2012 UTC revision 916 by ph10, Wed Feb 15 09:50:53 2012 UTC
# Line 424  BOOL utf = (md->poptions & PCRE_UTF8) != Line 424  BOOL utf = (md->poptions & PCRE_UTF8) !=
424  BOOL utf = FALSE;  BOOL utf = FALSE;
425  #endif  #endif
426    
427    BOOL reset_could_continue = FALSE;
428    
429  rlevel++;  rlevel++;
430  offsetcount &= (-2);  offsetcount &= (-2);
431    
# Line 571  for (;;) Line 573  for (;;)
573    int clen, dlen;    int clen, dlen;
574    unsigned int c, d;    unsigned int c, d;
575    int forced_fail = 0;    int forced_fail = 0;
576    BOOL could_continue = FALSE;    BOOL partial_newline = FALSE;
577      BOOL could_continue = reset_could_continue;
578      reset_could_continue = FALSE;
579    
580    /* Make the new state list into the active state list and empty the    /* Make the new state list into the active state list and empty the
581    new state list. */    new state list. */
582    
# Line 641  for (;;) Line 645  for (;;)
645    
646      /* A negative offset is a special case meaning "hold off going to this      /* A negative offset is a special case meaning "hold off going to this
647      (negated) state until the number of characters in the data field have      (negated) state until the number of characters in the data field have
648      been skipped". */      been skipped". If the could_continue flag was passed over from a previous
649        state, arrange for it to passed on. */
650    
651      if (state_offset < 0)      if (state_offset < 0)
652        {        {
# Line 650  for (;;) Line 655  for (;;)
655          DPRINTF(("%.*sSkipping this character\n", rlevel*2-2, SP));          DPRINTF(("%.*sSkipping this character\n", rlevel*2-2, SP));
656          ADD_NEW_DATA(state_offset, current_state->count,          ADD_NEW_DATA(state_offset, current_state->count,
657            current_state->data - 1);            current_state->data - 1);
658            if (could_continue) reset_could_continue = TRUE;
659          continue;          continue;
660          }          }
661        else        else
# Line 916  for (;;) Line 922  for (;;)
922                 (ptr == end_subject - md->nllen)                 (ptr == end_subject - md->nllen)
923              ))              ))
924            { ADD_ACTIVE(state_offset + 1, 0); }            { ADD_ACTIVE(state_offset + 1, 0); }
925            else if (ptr + 1 >= md->end_subject &&
926                     (md->moptions & (PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT)) != 0 &&
927                     NLBLOCK->nltype == NLTYPE_FIXED &&
928                     NLBLOCK->nllen == 2 &&
929                     c == NLBLOCK->nl[0])
930              {
931              if ((md->moptions & PCRE_PARTIAL_HARD) != 0)
932                {
933                reset_could_continue = TRUE;
934                ADD_NEW_DATA(-(state_offset + 1), 0, 1);
935                }
936              else could_continue = partial_newline = TRUE;
937              }
938          }          }
939        break;        break;
940    
# Line 928  for (;;) Line 947  for (;;)
947          else if (clen == 0 ||          else if (clen == 0 ||
948              ((md->poptions & PCRE_DOLLAR_ENDONLY) == 0 && IS_NEWLINE(ptr)))              ((md->poptions & PCRE_DOLLAR_ENDONLY) == 0 && IS_NEWLINE(ptr)))
949            { ADD_ACTIVE(state_offset + 1, 0); }            { ADD_ACTIVE(state_offset + 1, 0); }
950            else if (ptr + 1 >= md->end_subject &&
951                     (md->moptions & (PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT)) != 0 &&
952                     NLBLOCK->nltype == NLTYPE_FIXED &&
953                     NLBLOCK->nllen == 2 &&
954                     c == NLBLOCK->nl[0])
955              {
956              if ((md->moptions & PCRE_PARTIAL_HARD) != 0)
957                {
958                reset_could_continue = TRUE;
959                ADD_NEW_DATA(-(state_offset + 1), 0, 1);
960                }
961              else could_continue = partial_newline = TRUE;
962              }
963          }          }
964        else if (IS_NEWLINE(ptr))        else if (IS_NEWLINE(ptr))
965          { ADD_ACTIVE(state_offset + 1, 0); }          { ADD_ACTIVE(state_offset + 1, 0); }
# Line 1824  for (;;) Line 1856  for (;;)
1856            ncount++;            ncount++;
1857            nptr += ndlen;            nptr += ndlen;
1858            }            }
1859            if (nptr >= end_subject && (md->moptions & PCRE_PARTIAL_HARD) != 0)
1860                reset_could_continue = TRUE;
1861          if (++count >= GET2(code, 1))          if (++count >= GET2(code, 1))
1862            { ADD_NEW_DATA(-(state_offset + 2 + IMM2_SIZE), 0, ncount); }            { ADD_NEW_DATA(-(state_offset + 2 + IMM2_SIZE), 0, ncount); }
1863          else          else
# Line 2037  for (;;) Line 2071  for (;;)
2071            ncount++;            ncount++;
2072            nptr += nclen;            nptr += nclen;
2073            }            }
2074            if (nptr >= end_subject && (md->moptions & PCRE_PARTIAL_HARD) != 0)
2075                reset_could_continue = TRUE;
2076          ADD_NEW_DATA(-(state_offset + 1), 0, ncount);          ADD_NEW_DATA(-(state_offset + 1), 0, ncount);
2077          }          }
2078        break;        break;
# Line 2062  for (;;) Line 2098  for (;;)
2098          break;          break;
2099    
2100          case 0x000d:          case 0x000d:
2101          if (ptr + 1 < end_subject && ptr[1] == 0x0a)          if (ptr + 1 >= end_subject)
2102              {
2103              ADD_NEW(state_offset + 1, 0);
2104              if ((md->moptions & PCRE_PARTIAL_HARD) != 0)
2105                reset_could_continue = TRUE;
2106              }
2107            else if (ptr[1] == 0x0a)
2108            {            {
2109            ADD_NEW_DATA(-(state_offset + 1), 0, 1);            ADD_NEW_DATA(-(state_offset + 1), 0, 1);
2110            }            }
2111          else          else
2112            {            {
2113            ADD_NEW(state_offset + 1, 0);            ADD_NEW(state_offset + 1, 0);
2114            }            }
2115          break;          break;
2116          }          }
2117        break;        break;
# Line 2557  for (;;) Line 2599  for (;;)
2599              cb.version          = 1;   /* Version 1 of the callout block */              cb.version          = 1;   /* Version 1 of the callout block */
2600              cb.callout_number   = code[LINK_SIZE+2];              cb.callout_number   = code[LINK_SIZE+2];
2601              cb.offset_vector    = offsets;              cb.offset_vector    = offsets;
2602    #ifdef COMPILE_PCRE8
2603              cb.subject          = (PCRE_SPTR)start_subject;              cb.subject          = (PCRE_SPTR)start_subject;
2604    #else
2605                cb.subject          = (PCRE_SPTR16)start_subject;
2606    #endif
2607              cb.subject_length   = (int)(end_subject - start_subject);              cb.subject_length   = (int)(end_subject - start_subject);
2608              cb.start_match      = (int)(current_subject - start_subject);              cb.start_match      = (int)(current_subject - start_subject);
2609              cb.current_position = (int)(ptr - start_subject);              cb.current_position = (int)(ptr - start_subject);
# Line 2686  for (;;) Line 2732  for (;;)
2732            {            {
2733            for (rc = rc*2 - 2; rc >= 0; rc -= 2)            for (rc = rc*2 - 2; rc >= 0; rc -= 2)
2734              {              {
             const pcre_uchar *p = start_subject + local_offsets[rc];  
             const pcre_uchar *pp = start_subject + local_offsets[rc+1];  
2735              int charcount = local_offsets[rc+1] - local_offsets[rc];              int charcount = local_offsets[rc+1] - local_offsets[rc];
2736  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
2737                const pcre_uchar *p = start_subject + local_offsets[rc];
2738                const pcre_uchar *pp = start_subject + local_offsets[rc+1];
2739              while (p < pp) if (NOT_FIRSTCHAR(*p++)) charcount--;              while (p < pp) if (NOT_FIRSTCHAR(*p++)) charcount--;
2740  #endif  #endif
2741              if (charcount > 0)              if (charcount > 0)
# Line 2896  for (;;) Line 2942  for (;;)
2942          cb.version          = 1;   /* Version 1 of the callout block */          cb.version          = 1;   /* Version 1 of the callout block */
2943          cb.callout_number   = code[1];          cb.callout_number   = code[1];
2944          cb.offset_vector    = offsets;          cb.offset_vector    = offsets;
2945    #ifdef COMPILE_PCRE8
2946          cb.subject          = (PCRE_SPTR)start_subject;          cb.subject          = (PCRE_SPTR)start_subject;
2947    #else
2948            cb.subject          = (PCRE_SPTR16)start_subject;
2949    #endif
2950          cb.subject_length   = (int)(end_subject - start_subject);          cb.subject_length   = (int)(end_subject - start_subject);
2951          cb.start_match      = (int)(current_subject - start_subject);          cb.start_match      = (int)(current_subject - start_subject);
2952          cb.current_position = (int)(ptr - start_subject);          cb.current_position = (int)(ptr - start_subject);
# Line 2934  for (;;) Line 2984  for (;;)
2984    
2985    The "could_continue" variable is true if a state could have continued but    The "could_continue" variable is true if a state could have continued but
2986    for the fact that the end of the subject was reached. */    for the fact that the end of the subject was reached. */
2987    
2988    if (new_count <= 0)    if (new_count <= 0)
2989      {      {
2990      if (rlevel == 1 &&                               /* Top level, and */      if (rlevel == 1 &&                               /* Top level, and */
# Line 2946  for (;;) Line 2996  for (;;)
2996          ((md->moptions & PCRE_PARTIAL_SOFT) != 0 &&  /* Soft partial and */          ((md->moptions & PCRE_PARTIAL_SOFT) != 0 &&  /* Soft partial and */
2997           match_count < 0)                            /* no matches */           match_count < 0)                            /* no matches */
2998          ) &&                                         /* And... */          ) &&                                         /* And... */
2999          ptr >= end_subject &&                  /* Reached end of subject */          (
3000            ptr >= end_subject ||                  /* Reached end of subject or */
3001            partial_newline                        /* a partial newline */
3002            ) &&
3003          ptr > md->start_used_ptr)              /* Inspected non-empty string */          ptr > md->start_used_ptr)              /* Inspected non-empty string */
3004        {        {
3005        if (offsetcount >= 2)        if (offsetcount >= 2)
# Line 3013  pcre_dfa_exec(const pcre *argument_re, c Line 3066  pcre_dfa_exec(const pcre *argument_re, c
3066    int offsetcount, int *workspace, int wscount)    int offsetcount, int *workspace, int wscount)
3067  #else  #else
3068  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
3069  pcre16_dfa_exec(const pcre *argument_re, const pcre16_extra *extra_data,  pcre16_dfa_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,
3070    PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,    PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,
3071    int offsetcount, int *workspace, int wscount)    int offsetcount, int *workspace, int wscount)
3072  #endif  #endif
3073  {  {
3074  real_pcre *re = (real_pcre *)argument_re;  REAL_PCRE *re = (REAL_PCRE *)argument_re;
3075  dfa_match_data match_block;  dfa_match_data match_block;
3076  dfa_match_data *md = &match_block;  dfa_match_data *md = &match_block;
3077  BOOL utf, anchored, startline, firstline;  BOOL utf, anchored, startline, firstline;
3078  const pcre_uchar *current_subject, *end_subject;  const pcre_uchar *current_subject, *end_subject;
 const pcre_uint8 *lcc;  
   
3079  const pcre_study_data *study = NULL;  const pcre_study_data *study = NULL;
3080    
3081  const pcre_uchar *req_char_ptr;  const pcre_uchar *req_char_ptr;
# Line 3186  in other programs later. */ Line 3237  in other programs later. */
3237    
3238  if (md->tables == NULL) md->tables = PRIV(default_tables);  if (md->tables == NULL) md->tables = PRIV(default_tables);
3239    
3240  /* The lower casing table and the "must be at the start of a line" flag are  /* The "must be at the start of a line" flags are used in a loop when finding
3241  used in a loop when finding where to start. */  where to start. */
3242    
 lcc = md->tables + lcc_offset;  
3243  startline = (re->flags & PCRE_STARTLINE) != 0;  startline = (re->flags & PCRE_STARTLINE) != 0;
3244  firstline = (re->options & PCRE_FIRSTLINE) != 0;  firstline = (re->options & PCRE_FIRSTLINE) != 0;
3245    
# Line 3204  if (!anchored) Line 3254  if (!anchored)
3254    if ((re->flags & PCRE_FIRSTSET) != 0)    if ((re->flags & PCRE_FIRSTSET) != 0)
3255      {      {
3256      has_first_char = TRUE;      has_first_char = TRUE;
3257      first_char = first_char2 = re->first_char;      first_char = first_char2 = (pcre_uchar)(re->first_char);
3258      if ((re->flags & PCRE_FCH_CASELESS) != 0)      if ((re->flags & PCRE_FCH_CASELESS) != 0)
3259        {        {
3260        first_char2 = TABLE_GET(first_char, md->tables + fcc_offset, first_char);        first_char2 = TABLE_GET(first_char, md->tables + fcc_offset, first_char);
# Line 3228  character" set. */ Line 3278  character" set. */
3278  if ((re->flags & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
3279    {    {
3280    has_req_char = TRUE;    has_req_char = TRUE;
3281    req_char = req_char2 = re->req_char;    req_char = req_char2 = (pcre_uchar)(re->req_char);
3282    if ((re->flags & PCRE_RCH_CASELESS) != 0)    if ((re->flags & PCRE_RCH_CASELESS) != 0)
3283      {      {
3284      req_char2 = TABLE_GET(req_char, md->tables + fcc_offset, req_char);      req_char2 = TABLE_GET(req_char, md->tables + fcc_offset, req_char);

Legend:
Removed from v.850  
changed lines
  Added in v.916

  ViewVC Help
Powered by ViewVC 1.1.5