/[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 604 by ph10, Thu Jun 2 19:04:54 2011 UTC revision 608 by ph10, Sun Jun 12 16:25:55 2011 UTC
# Line 1305  for (;;) Line 1305  for (;;)
1305      break;      break;
1306    
1307    
1308      /* End of the pattern, either real or forced. If we are in a top-level      /* End of the pattern, either real or forced. If we are in a recursion, we
1309      recursion, we should restore the offsets appropriately and continue from      should restore the offsets appropriately, and if it's a top-level
1310      after the call. */      recursion, continue from after the call. */
1311    
1312      case OP_ACCEPT:      case OP_ACCEPT:
1313      case OP_END:      case OP_END:
1314      if (md->recursive != NULL && md->recursive->group_num == 0)      if (md->recursive != NULL)
1315        {        {
1316        recursion_info *rec = md->recursive;        recursion_info *rec = md->recursive;
       DPRINTF(("End of pattern in a (?0) recursion\n"));  
1317        md->recursive = rec->prevrec;        md->recursive = rec->prevrec;
1318        memmove(md->offset_vector, rec->offset_save,        memmove(md->offset_vector, rec->offset_save,
1319          rec->saved_max * sizeof(int));          rec->saved_max * sizeof(int));
1320        offset_top = rec->save_offset_top;        offset_top = rec->save_offset_top;
1321        ecode = rec->after_call;        if (rec->group_num == 0)
1322        break;          {
1323            ecode = rec->after_call;
1324            break;
1325            }
1326        }        }
1327    
1328      /* Otherwise, if we have matched an empty string, fail if PCRE_NOTEMPTY is      /* Otherwise, if we have matched an empty string, fail if PCRE_NOTEMPTY is
# Line 1328  for (;;) Line 1330  for (;;)
1330      the subject. In both cases, backtracking will then try other alternatives,      the subject. In both cases, backtracking will then try other alternatives,
1331      if any. */      if any. */
1332    
1333      if (eptr == mstart &&      else if (eptr == mstart &&
1334          (md->notempty ||          (md->notempty ||
1335            (md->notempty_atstart &&            (md->notempty_atstart &&
1336              mstart == md->start_subject + md->start_offset)))              mstart == md->start_subject + md->start_offset)))
1337        MRRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
1338    
1339      /* Otherwise, we have a match. */      /* Otherwise, we have a match. */
1340    
1341      md->end_match_ptr = eptr;           /* Record where we ended */      md->end_match_ptr = eptr;           /* Record where we ended */
1342      md->end_offset_top = offset_top;    /* and how many extracts were taken */      md->end_offset_top = offset_top;    /* and how many extracts were taken */
1343      md->start_match_ptr = mstart;       /* and the start (\K can modify) */      md->start_match_ptr = mstart;       /* and the start (\K can modify) */
# Line 1538  for (;;) Line 1540  for (;;)
1540        memcpy(new_recursive.offset_save, md->offset_vector,        memcpy(new_recursive.offset_save, md->offset_vector,
1541              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
1542        new_recursive.save_offset_top = offset_top;        new_recursive.save_offset_top = offset_top;
1543    
1544        /* OK, now we can do the recursion. For each top-level alternative we        /* OK, now we can do the recursion. For each top-level alternative we
1545        restore the offset and recursion data. */        restore the offset and recursion data. */
1546    
# Line 5999  if (md->partial && (re->flags & PCRE_NOP Line 6001  if (md->partial && (re->flags & PCRE_NOP
6001    return PCRE_ERROR_BADPARTIAL;    return PCRE_ERROR_BADPARTIAL;
6002    
6003  /* Check a UTF-8 string if required. Pass back the character offset and error  /* Check a UTF-8 string if required. Pass back the character offset and error
6004  code if a results vector is available. */  code for an invalid string if a results vector is available. */
6005    
6006  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
6007  if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)  if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)
6008    {    {
6009    int errorcode;    int erroroffset;
6010    int tb = _pcre_valid_utf8((USPTR)subject, length, &errorcode);    int errorcode = _pcre_valid_utf8((USPTR)subject, length, &erroroffset);
6011    if (tb >= 0)    if (errorcode != 0)
6012      {      {
6013      if (offsetcount >= 2)      if (offsetcount >= 2)
6014        {        {
6015        offsets[0] = tb;        offsets[0] = erroroffset;
6016        offsets[1] = errorcode;        offsets[1] = errorcode;
6017        }        }
6018      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?
6019        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;
6020      }      }
6021    if (start_offset > 0 && start_offset < length)  
6022      {    /* Check that a start_offset points to the start of a UTF-8 character. */
6023      tb = ((USPTR)subject)[start_offset] & 0xc0;  
6024      if (tb == 0x80) return PCRE_ERROR_BADUTF8_OFFSET;    if (start_offset > 0 && start_offset < length &&
6025      }        (((USPTR)subject)[start_offset] & 0xc0) == 0x80)
6026        return PCRE_ERROR_BADUTF8_OFFSET;
6027    }    }
6028  #endif  #endif
6029    

Legend:
Removed from v.604  
changed lines
  Added in v.608

  ViewVC Help
Powered by ViewVC 1.1.5