/[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 836 by ph10, Wed Dec 28 17:16:11 2011 UTC revision 882 by ph10, Sun Jan 15 18:45:27 2012 UTC
# Line 468  Returns:       MATCH_MATCH if matched Line 468  Returns:       MATCH_MATCH if matched
468    
469  static int  static int
470  match(REGISTER PCRE_PUCHAR eptr, REGISTER const pcre_uchar *ecode,  match(REGISTER PCRE_PUCHAR eptr, REGISTER const pcre_uchar *ecode,
471    PCRE_PUCHAR mstart, int offset_top, match_data *md, eptrblock *eptrb,    PCRE_PUCHAR mstart, int offset_top, match_data *md, eptrblock *eptrb,
472    unsigned int rdepth)    unsigned int rdepth)
473  {  {
474  /* These variables do not need to be preserved over recursion in this function,  /* These variables do not need to be preserved over recursion in this function,
# Line 626  the alternative names that are used. */ Line 626  the alternative names that are used. */
626  #define condassert    condition  #define condassert    condition
627  #define matched_once  prev_is_word  #define matched_once  prev_is_word
628  #define foc           number  #define foc           number
629    #define save_mark     data
630    
631  /* These statements are here to stop the compiler complaining about unitialized  /* These statements are here to stop the compiler complaining about unitialized
632  variables. */  variables. */
# Line 818  for (;;) Line 819  for (;;)
819      case OP_ONCE_NC:      case OP_ONCE_NC:
820      prev = ecode;      prev = ecode;
821      saved_eptr = eptr;      saved_eptr = eptr;
822        save_mark = md->mark;
823      do      do
824        {        {
825        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);
# Line 836  for (;;) Line 838  for (;;)
838    
839        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
840        ecode += GET(ecode,1);        ecode += GET(ecode,1);
841          md->mark = save_mark;
842        }        }
843      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
844    
# Line 915  for (;;) Line 918  for (;;)
918        save_offset2 = md->offset_vector[offset+1];        save_offset2 = md->offset_vector[offset+1];
919        save_offset3 = md->offset_vector[md->offset_end - number];        save_offset3 = md->offset_vector[md->offset_end - number];
920        save_capture_last = md->capture_last;        save_capture_last = md->capture_last;
921          save_mark = md->mark;
922    
923        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
924        md->offset_vector[md->offset_end - number] =        md->offset_vector[md->offset_end - number] =
# Line 951  for (;;) Line 955  for (;;)
955          if (rrc != MATCH_NOMATCH) RRETURN(rrc);          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
956          md->capture_last = save_capture_last;          md->capture_last = save_capture_last;
957          ecode += GET(ecode, 1);          ecode += GET(ecode, 1);
958            md->mark = save_mark;
959          if (*ecode != OP_ALT) break;          if (*ecode != OP_ALT) break;
960          }          }
961    
# Line 1016  for (;;) Line 1021  for (;;)
1021    
1022        /* In all other cases, we have to make another call to match(). */        /* In all other cases, we have to make another call to match(). */
1023    
1024          save_mark = md->mark;
1025        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,
1026          RM2);          RM2);
1027    
1028        /* See comment in the code for capturing groups above about handling        /* See comment in the code for capturing groups above about handling
1029        THEN. */        THEN. */
1030    
# Line 1045  for (;;) Line 1051  for (;;)
1051          RRETURN(rrc);          RRETURN(rrc);
1052          }          }
1053        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1054          md->mark = save_mark;
1055        if (*ecode != OP_ALT) break;        if (*ecode != OP_ALT) break;
1056        }        }
1057    
# Line 1223  for (;;) Line 1230  for (;;)
1230        {        {
1231        if (PUBL(callout) != NULL)        if (PUBL(callout) != NULL)
1232          {          {
1233          pcre_callout_block cb;          PUBL(callout_block) cb;
1234          cb.version          = 2;   /* Version 1 of the callout block */          cb.version          = 2;   /* Version 1 of the callout block */
1235          cb.callout_number   = ecode[LINK_SIZE+2];          cb.callout_number   = ecode[LINK_SIZE+2];
1236          cb.offset_vector    = md->offset_vector;          cb.offset_vector    = md->offset_vector;
1237    #ifdef COMPILE_PCRE8
1238          cb.subject          = (PCRE_SPTR)md->start_subject;          cb.subject          = (PCRE_SPTR)md->start_subject;
1239    #else
1240            cb.subject          = (PCRE_SPTR16)md->start_subject;
1241    #endif
1242          cb.subject_length   = (int)(md->end_subject - md->start_subject);          cb.subject_length   = (int)(md->end_subject - md->start_subject);
1243          cb.start_match      = (int)(mstart - md->start_subject);          cb.start_match      = (int)(mstart - md->start_subject);
1244          cb.current_position = (int)(eptr - md->start_subject);          cb.current_position = (int)(eptr - md->start_subject);
# Line 1633  for (;;) Line 1644  for (;;)
1644      case OP_CALLOUT:      case OP_CALLOUT:
1645      if (PUBL(callout) != NULL)      if (PUBL(callout) != NULL)
1646        {        {
1647        pcre_callout_block cb;        PUBL(callout_block) cb;
1648        cb.version          = 2;   /* Version 1 of the callout block */        cb.version          = 2;   /* Version 1 of the callout block */
1649        cb.callout_number   = ecode[1];        cb.callout_number   = ecode[1];
1650        cb.offset_vector    = md->offset_vector;        cb.offset_vector    = md->offset_vector;
1651    #ifdef COMPILE_PCRE8
1652        cb.subject          = (PCRE_SPTR)md->start_subject;        cb.subject          = (PCRE_SPTR)md->start_subject;
1653    #else
1654          cb.subject          = (PCRE_SPTR16)md->start_subject;
1655    #endif
1656        cb.subject_length   = (int)(md->end_subject - md->start_subject);        cb.subject_length   = (int)(md->end_subject - md->start_subject);
1657        cb.start_match      = (int)(mstart - md->start_subject);        cb.start_match      = (int)(mstart - md->start_subject);
1658        cb.current_position = (int)(eptr - md->start_subject);        cb.current_position = (int)(eptr - md->start_subject);
# Line 2631  for (;;) Line 2646  for (;;)
2646    
2647      /* Handle repeated back references. If the length of the reference is      /* Handle repeated back references. If the length of the reference is
2648      zero, just continue with the main loop. If the length is negative, it      zero, just continue with the main loop. If the length is negative, it
2649      means the reference is unset in non-Java-compatible mode. If the minimum is      means the reference is unset in non-Java-compatible mode. If the minimum is
2650      zero, we can continue at the same level without recursion. For any other      zero, we can continue at the same level without recursion. For any other
2651      minimum, carrying on will result in NOMATCH. */      minimum, carrying on will result in NOMATCH. */
2652    
2653      if (length == 0) continue;      if (length == 0) continue;
# Line 6030  switch (frame->Xwhere) Line 6045  switch (frame->Xwhere)
6045    LBL(53) LBL(54) LBL(55) LBL(56) LBL(57) LBL(58) LBL(63) LBL(64)    LBL(53) LBL(54) LBL(55) LBL(56) LBL(57) LBL(58) LBL(63) LBL(64)
6046    LBL(65) LBL(66)    LBL(65) LBL(66)
6047  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
6048    LBL(21)    LBL(21)
6049  #endif  #endif
6050  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
6051    LBL(16) LBL(18) LBL(20)    LBL(16) LBL(18) LBL(20)
6052    LBL(22) LBL(23) LBL(28) LBL(30)    LBL(22) LBL(23) LBL(28) LBL(30)
6053    LBL(32) LBL(34) LBL(42) LBL(46)    LBL(32) LBL(34) LBL(42) LBL(46)
6054  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 6043  switch (frame->Xwhere) Line 6058  switch (frame->Xwhere)
6058  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
6059    default:    default:
6060    DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere));    DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere));
6061    
6062  printf("+++jump error in pcre match: label %d non-existent\n", frame->Xwhere);  printf("+++jump error in pcre match: label %d non-existent\n", frame->Xwhere);
6063    
6064    return PCRE_ERROR_INTERNAL;    return PCRE_ERROR_INTERNAL;
# Line 6139  pcre_exec(const pcre *argument_re, const Line 6154  pcre_exec(const pcre *argument_re, const
6154    int offsetcount)    int offsetcount)
6155  #else  #else
6156  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
6157  pcre16_exec(const pcre *argument_re, const pcre_extra *extra_data,  pcre16_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,
6158    PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,    PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,
6159    int offsetcount)    int offsetcount)
6160  #endif  #endif
# Line 6167  PCRE_PUCHAR start_partial = NULL; Line 6182  PCRE_PUCHAR start_partial = NULL;
6182  PCRE_PUCHAR req_char_ptr = start_match - 1;  PCRE_PUCHAR req_char_ptr = start_match - 1;
6183    
6184  const pcre_study_data *study;  const pcre_study_data *study;
6185  const real_pcre *external_re = (const real_pcre *)argument_re;  const REAL_PCRE *re = (const REAL_PCRE *)argument_re;
 const real_pcre *re = external_re;  
6186    
6187  /* Plausibility checks */  /* Plausibility checks */
6188    
# Line 6209  if (utf && (options & PCRE_NO_UTF8_CHECK Line 6223  if (utf && (options & PCRE_NO_UTF8_CHECK
6223  #else  #else
6224      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?
6225        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;
6226  #endif  #endif
6227      }      }
6228    
6229    /* Check that a start_offset points to the start of a UTF character. */    /* Check that a start_offset points to the start of a UTF character. */
# Line 6255  md->callout_data = NULL; Line 6269  md->callout_data = NULL;
6269    
6270  /* The table pointer is always in native byte order. */  /* The table pointer is always in native byte order. */
6271    
6272  tables = external_re->tables;  tables = re->tables;
6273    
6274  if (extra_data != NULL)  if (extra_data != NULL)
6275    {    {
# Line 6295  firstline = (re->options & PCRE_FIRSTLIN Line 6309  firstline = (re->options & PCRE_FIRSTLIN
6309    
6310  /* The code starts after the real_pcre block and the capture name table. */  /* The code starts after the real_pcre block and the capture name table. */
6311    
6312  md->start_code = (const pcre_uchar *)external_re + re->name_table_offset +  md->start_code = (const pcre_uchar *)re + re->name_table_offset +
6313    re->name_count * re->name_entry_size;    re->name_count * re->name_entry_size;
6314    
6315  md->start_subject = (PCRE_PUCHAR)subject;  md->start_subject = (PCRE_PUCHAR)subject;
# Line 6765  for(;;) Line 6779  for(;;)
6779    
6780    /* If we have just passed a CR and we are now at a LF, and the pattern does    /* If we have just passed a CR and we are now at a LF, and the pattern does
6781    not contain any explicit matches for \r or \n, and the newline option is CRLF    not contain any explicit matches for \r or \n, and the newline option is CRLF
6782    or ANY or ANYCRLF, advance the match position by one more character. In    or ANY or ANYCRLF, advance the match position by one more character. In
6783    normal matching start_match will aways be greater than the first position at    normal matching start_match will aways be greater than the first position at
6784    this stage, but a failed *SKIP can cause a return at the same point, which is    this stage, but a failed *SKIP can cause a return at the same point, which is
6785    why the first test exists. */    why the first test exists. */
6786    
6787    if (start_match > (PCRE_PUCHAR)subject + start_offset &&    if (start_match > (PCRE_PUCHAR)subject + start_offset &&
# Line 6858  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 6872  if (rc == MATCH_MATCH || rc == MATCH_ACC
6872    /* Return MARK data if requested */    /* Return MARK data if requested */
6873    
6874    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
6875      *(extra_data->mark) = (unsigned char *)(md->mark);      *(extra_data->mark) = (pcre_uchar *)md->mark;
6876    DPRINTF((">>>> returning %d\n", rc));    DPRINTF((">>>> returning %d\n", rc));
6877    return rc;    return rc;
6878    }    }
# Line 6905  else Line 6919  else
6919  /* Return the MARK data if it has been requested. */  /* Return the MARK data if it has been requested. */
6920    
6921  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
6922    *(extra_data->mark) = (unsigned char *)(md->nomatch_mark);    *(extra_data->mark) = (pcre_uchar *)md->nomatch_mark;
6923  return rc;  return rc;
6924  }  }
6925    

Legend:
Removed from v.836  
changed lines
  Added in v.882

  ViewVC Help
Powered by ViewVC 1.1.5