/[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 916 by ph10, Wed Feb 15 09:50:53 2012 UTC
# Line 140  Arguments: Line 140  Arguments:
140    md          points to match data block    md          points to match data block
141    caseless    TRUE if caseless    caseless    TRUE if caseless
142    
143  Returns:      < 0 if not matched, otherwise the number of subject bytes matched  Returns:      >= 0 the number of subject bytes matched
144                  -1 no match
145                  -2 partial match; always given if at end subject
146  */  */
147    
148  static int  static int
# Line 163  pchars(p, length, FALSE, md); Line 165  pchars(p, length, FALSE, md);
165  printf("\n");  printf("\n");
166  #endif  #endif
167    
168  /* Always fail if reference not set (and not JavaScript compatible). */  /* Always fail if reference not set (and not JavaScript compatible - in that
169    case the length is passed as zero). */
170    
171  if (length < 0) return -1;  if (length < 0) return -1;
172    
# Line 189  if (caseless) Line 192  if (caseless)
192      while (p < endptr)      while (p < endptr)
193        {        {
194        int c, d;        int c, d;
195        if (eptr >= md->end_subject) return -1;        if (eptr >= md->end_subject) return -2;   /* Partial match */
196        GETCHARINC(c, eptr);        GETCHARINC(c, eptr);
197        GETCHARINC(d, p);        GETCHARINC(d, p);
198        if (c != d && c != UCD_OTHERCASE(d)) return -1;        if (c != d && c != UCD_OTHERCASE(d)) return -1;
# Line 202  if (caseless) Line 205  if (caseless)
205    /* The same code works when not in UTF-8 mode and in UTF-8 mode when there    /* The same code works when not in UTF-8 mode and in UTF-8 mode when there
206    is no UCP support. */    is no UCP support. */
207      {      {
     if (eptr + length > md->end_subject) return -1;  
208      while (length-- > 0)      while (length-- > 0)
209        {        {
210          if (eptr >= md->end_subject) return -2;   /* Partial match */
211        if (TABLE_GET(*p, md->lcc, *p) != TABLE_GET(*eptr, md->lcc, *eptr)) return -1;        if (TABLE_GET(*p, md->lcc, *p) != TABLE_GET(*eptr, md->lcc, *eptr)) return -1;
212        p++;        p++;
213        eptr++;        eptr++;
# Line 217  are in UTF-8 mode. */ Line 220  are in UTF-8 mode. */
220    
221  else  else
222    {    {
223    if (eptr + length > md->end_subject) return -1;    while (length-- > 0)
224    while (length-- > 0) if (*p++ != *eptr++) return -1;      {
225        if (eptr >= md->end_subject) return -2;   /* Partial match */
226        if (*p++ != *eptr++) return -1;
227        }
228    }    }
229    
230  return (int)(eptr - eptr_start);  return (int)(eptr - eptr_start);
# Line 332  argument of match(), which never changes Line 338  argument of match(), which never changes
338    {\    {\
339    heapframe *oldframe = frame;\    heapframe *oldframe = frame;\
340    frame = oldframe->Xprevframe;\    frame = oldframe->Xprevframe;\
341    (PUBL(stack_free))(oldframe);\    if (oldframe != &frame_zero) (PUBL(stack_free))(oldframe);\
342    if (frame != NULL)\    if (frame != NULL)\
343      {\      {\
344      rrc = ra;\      rrc = ra;\
# Line 468  Returns:       MATCH_MATCH if matched Line 474  Returns:       MATCH_MATCH if matched
474    
475  static int  static int
476  match(REGISTER PCRE_PUCHAR eptr, REGISTER const pcre_uchar *ecode,  match(REGISTER PCRE_PUCHAR eptr, REGISTER const pcre_uchar *ecode,
477    PCRE_PUCHAR mstart, int offset_top, match_data *md, eptrblock *eptrb,    PCRE_PUCHAR mstart, int offset_top, match_data *md, eptrblock *eptrb,
478    unsigned int rdepth)    unsigned int rdepth)
479  {  {
480  /* 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 485  BOOL caseless; Line 491  BOOL caseless;
491  int condcode;  int condcode;
492    
493  /* When recursion is not being used, all "local" variables that have to be  /* When recursion is not being used, all "local" variables that have to be
494  preserved over calls to RMATCH() are part of a "frame" which is obtained from  preserved over calls to RMATCH() are part of a "frame". We set up the top-level
495  heap storage. Set up the top-level frame here; others are obtained from the  frame on the stack here; subsequent instantiations are obtained from the heap
496  heap whenever RMATCH() does a "recursion". See the macro definitions above. */  whenever RMATCH() does a "recursion". See the macro definitions above. Putting
497    the top-level on the stack rather than malloc-ing them all gives a performance
498    boost in many cases where there is not much "recursion". */
499    
500  #ifdef NO_RECURSE  #ifdef NO_RECURSE
501  heapframe *frame = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));  heapframe frame_zero;
502  if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY);  heapframe *frame = &frame_zero;
503  frame->Xprevframe = NULL;            /* Marks the top level */  frame->Xprevframe = NULL;            /* Marks the top level */
504    
505  /* Copy in the original argument variables */  /* Copy in the original argument variables */
# Line 613  int save_offset1, save_offset2, save_off Line 621  int save_offset1, save_offset2, save_off
621  int stacksave[REC_STACK_SAVE_MAX];  int stacksave[REC_STACK_SAVE_MAX];
622    
623  eptrblock newptrb;  eptrblock newptrb;
624    
625    /* There is a special fudge for calling match() in a way that causes it to
626    measure the size of its basic stack frame when the stack is being used for
627    recursion. The second argument (ecode) being NULL triggers this behaviour. It
628    cannot normally ever be NULL. The return is the negated value of the frame
629    size. */
630    
631    if (ecode == NULL)
632      {
633      if (rdepth == 0)
634        return match((PCRE_PUCHAR)&rdepth, NULL, NULL, 0, NULL, NULL, 1);
635      else
636        {
637        int len = (char *)&rdepth - (char *)eptr;
638        return (len > 0)? -len : len;
639        }
640      }
641  #endif     /* NO_RECURSE */  #endif     /* NO_RECURSE */
642    
643  /* 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 626  the alternative names that are used. */ Line 651  the alternative names that are used. */
651  #define condassert    condition  #define condassert    condition
652  #define matched_once  prev_is_word  #define matched_once  prev_is_word
653  #define foc           number  #define foc           number
654    #define save_mark     data
655    
656  /* These statements are here to stop the compiler complaining about unitialized  /* These statements are here to stop the compiler complaining about unitialized
657  variables. */  variables. */
# Line 818  for (;;) Line 844  for (;;)
844      case OP_ONCE_NC:      case OP_ONCE_NC:
845      prev = ecode;      prev = ecode;
846      saved_eptr = eptr;      saved_eptr = eptr;
847        save_mark = md->mark;
848      do      do
849        {        {
850        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 863  for (;;)
863    
864        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
865        ecode += GET(ecode,1);        ecode += GET(ecode,1);
866          md->mark = save_mark;
867        }        }
868      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
869    
# Line 915  for (;;) Line 943  for (;;)
943        save_offset2 = md->offset_vector[offset+1];        save_offset2 = md->offset_vector[offset+1];
944        save_offset3 = md->offset_vector[md->offset_end - number];        save_offset3 = md->offset_vector[md->offset_end - number];
945        save_capture_last = md->capture_last;        save_capture_last = md->capture_last;
946          save_mark = md->mark;
947    
948        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
949        md->offset_vector[md->offset_end - number] =        md->offset_vector[md->offset_end - number] =
# Line 951  for (;;) Line 980  for (;;)
980          if (rrc != MATCH_NOMATCH) RRETURN(rrc);          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
981          md->capture_last = save_capture_last;          md->capture_last = save_capture_last;
982          ecode += GET(ecode, 1);          ecode += GET(ecode, 1);
983            md->mark = save_mark;
984          if (*ecode != OP_ALT) break;          if (*ecode != OP_ALT) break;
985          }          }
986    
# Line 1016  for (;;) Line 1046  for (;;)
1046    
1047        /* In all other cases, we have to make another call to match(). */        /* In all other cases, we have to make another call to match(). */
1048    
1049          save_mark = md->mark;
1050        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,
1051          RM2);          RM2);
1052    
# Line 1045  for (;;) Line 1076  for (;;)
1076          RRETURN(rrc);          RRETURN(rrc);
1077          }          }
1078        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1079          md->mark = save_mark;
1080        if (*ecode != OP_ALT) break;        if (*ecode != OP_ALT) break;
1081        }        }
1082    
# Line 1223  for (;;) Line 1255  for (;;)
1255        {        {
1256        if (PUBL(callout) != NULL)        if (PUBL(callout) != NULL)
1257          {          {
1258          pcre_callout_block cb;          PUBL(callout_block) cb;
1259          cb.version          = 2;   /* Version 1 of the callout block */          cb.version          = 2;   /* Version 1 of the callout block */
1260          cb.callout_number   = ecode[LINK_SIZE+2];          cb.callout_number   = ecode[LINK_SIZE+2];
1261          cb.offset_vector    = md->offset_vector;          cb.offset_vector    = md->offset_vector;
1262    #ifdef COMPILE_PCRE8
1263          cb.subject          = (PCRE_SPTR)md->start_subject;          cb.subject          = (PCRE_SPTR)md->start_subject;
1264    #else
1265            cb.subject          = (PCRE_SPTR16)md->start_subject;
1266    #endif
1267          cb.subject_length   = (int)(md->end_subject - md->start_subject);          cb.subject_length   = (int)(md->end_subject - md->start_subject);
1268          cb.start_match      = (int)(mstart - md->start_subject);          cb.start_match      = (int)(mstart - md->start_subject);
1269          cb.current_position = (int)(eptr - md->start_subject);          cb.current_position = (int)(eptr - md->start_subject);
# Line 1519  for (;;) Line 1555  for (;;)
1555    
1556      case OP_ASSERT:      case OP_ASSERT:
1557      case OP_ASSERTBACK:      case OP_ASSERTBACK:
1558        save_mark = md->mark;
1559      if (md->match_function_type == MATCH_CONDASSERT)      if (md->match_function_type == MATCH_CONDASSERT)
1560        {        {
1561        condassert = TRUE;        condassert = TRUE;
# Line 1540  for (;;) Line 1577  for (;;)
1577    
1578        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1579        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1580          md->mark = save_mark;
1581        }        }
1582      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1583    
# Line 1563  for (;;) Line 1601  for (;;)
1601    
1602      case OP_ASSERT_NOT:      case OP_ASSERT_NOT:
1603      case OP_ASSERTBACK_NOT:      case OP_ASSERTBACK_NOT:
1604        save_mark = md->mark;
1605      if (md->match_function_type == MATCH_CONDASSERT)      if (md->match_function_type == MATCH_CONDASSERT)
1606        {        {
1607        condassert = TRUE;        condassert = TRUE;
# Line 1573  for (;;) Line 1612  for (;;)
1612      do      do
1613        {        {
1614        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);
1615          md->mark = save_mark;
1616        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);
1617        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
1618          {          {
# Line 1633  for (;;) Line 1673  for (;;)
1673      case OP_CALLOUT:      case OP_CALLOUT:
1674      if (PUBL(callout) != NULL)      if (PUBL(callout) != NULL)
1675        {        {
1676        pcre_callout_block cb;        PUBL(callout_block) cb;
1677        cb.version          = 2;   /* Version 1 of the callout block */        cb.version          = 2;   /* Version 1 of the callout block */
1678        cb.callout_number   = ecode[1];        cb.callout_number   = ecode[1];
1679        cb.offset_vector    = md->offset_vector;        cb.offset_vector    = md->offset_vector;
1680    #ifdef COMPILE_PCRE8
1681        cb.subject          = (PCRE_SPTR)md->start_subject;        cb.subject          = (PCRE_SPTR)md->start_subject;
1682    #else
1683          cb.subject          = (PCRE_SPTR16)md->start_subject;
1684    #endif
1685        cb.subject_length   = (int)(md->end_subject - md->start_subject);        cb.subject_length   = (int)(md->end_subject - md->start_subject);
1686        cb.start_match      = (int)(mstart - md->start_subject);        cb.start_match      = (int)(mstart - md->start_subject);
1687        cb.current_position = (int)(eptr - md->start_subject);        cb.current_position = (int)(eptr - md->start_subject);
# Line 2021  for (;;) Line 2065  for (;;)
2065    
2066      case OP_DOLLM:      case OP_DOLLM:
2067      if (eptr < md->end_subject)      if (eptr < md->end_subject)
2068        { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); }        {
2069          if (!IS_NEWLINE(eptr))
2070            {
2071            if (eptr + 1 >= md->end_subject &&
2072                md->partial != 0 &&
2073                NLBLOCK->nltype == NLTYPE_FIXED &&
2074                NLBLOCK->nllen == 2 &&
2075                *eptr == NLBLOCK->nl[0])
2076              {
2077              md->hitend = TRUE;
2078              if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2079              }
2080            RRETURN(MATCH_NOMATCH);
2081            }
2082          }
2083      else      else
2084        {        {
2085        if (md->noteol) RRETURN(MATCH_NOMATCH);        if (md->noteol) RRETURN(MATCH_NOMATCH);
# Line 2053  for (;;) Line 2111  for (;;)
2111      ASSERT_NL_OR_EOS:      ASSERT_NL_OR_EOS:
2112      if (eptr < md->end_subject &&      if (eptr < md->end_subject &&
2113          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
2114          {
2115          if (eptr + 1 >= md->end_subject &&
2116              md->partial != 0 &&
2117              NLBLOCK->nltype == NLTYPE_FIXED &&
2118              NLBLOCK->nllen == 2 &&
2119              *eptr == NLBLOCK->nl[0])
2120            {
2121            md->hitend = TRUE;
2122            if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2123            }
2124        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2125          }
2126    
2127      /* Either at end of string or \n before end. */      /* Either at end of string or \n before end. */
2128    
# Line 2327  for (;;) Line 2396  for (;;)
2396        default: RRETURN(MATCH_NOMATCH);        default: RRETURN(MATCH_NOMATCH);
2397    
2398        case 0x000d:        case 0x000d:
2399        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;        if (eptr >= md->end_subject)
2400            {
2401            SCHECK_PARTIAL();
2402            }
2403          else if (*eptr == 0x0a) eptr++;
2404        break;        break;
2405    
2406        case 0x000a:        case 0x000a:
# Line 2557  for (;;) Line 2630  for (;;)
2630        if (UCD_CATEGORY(c) != ucp_M) break;        if (UCD_CATEGORY(c) != ucp_M) break;
2631        eptr += len;        eptr += len;
2632        }        }
2633        CHECK_PARTIAL();
2634      ecode++;      ecode++;
2635      break;      break;
2636  #endif  #endif
# Line 2622  for (;;) Line 2696  for (;;)
2696        default:               /* No repeat follows */        default:               /* No repeat follows */
2697        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)
2698          {          {
2699            if (length == -2) eptr = md->end_subject;   /* Partial match */
2700          CHECK_PARTIAL();          CHECK_PARTIAL();
2701          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2702          }          }
# Line 2631  for (;;) Line 2706  for (;;)
2706    
2707      /* Handle repeated back references. If the length of the reference is      /* Handle repeated back references. If the length of the reference is
2708      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
2709      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
2710      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
2711      minimum, carrying on will result in NOMATCH. */      minimum, carrying on will result in NOMATCH. */
2712    
2713      if (length == 0) continue;      if (length == 0) continue;
# Line 2647  for (;;) Line 2722  for (;;)
2722        int slength;        int slength;
2723        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2724          {          {
2725            if (slength == -2) eptr = md->end_subject;   /* Partial match */
2726          CHECK_PARTIAL();          CHECK_PARTIAL();
2727          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2728          }          }
# Line 2670  for (;;) Line 2746  for (;;)
2746          if (fi >= max) RRETURN(MATCH_NOMATCH);          if (fi >= max) RRETURN(MATCH_NOMATCH);
2747          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2748            {            {
2749              if (slength == -2) eptr = md->end_subject;   /* Partial match */
2750            CHECK_PARTIAL();            CHECK_PARTIAL();
2751            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2752            }            }
# Line 2688  for (;;) Line 2765  for (;;)
2765          int slength;          int slength;
2766          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2767            {            {
2768            CHECK_PARTIAL();            /* Can't use CHECK_PARTIAL because we don't want to update eptr in
2769              the soft partial matching case. */
2770    
2771              if (slength == -2 && md->partial != 0 &&
2772                  md->end_subject > md->start_used_ptr)
2773                {
2774                md->hitend = TRUE;
2775                if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2776                }
2777            break;            break;
2778            }            }
2779          eptr += slength;          eptr += slength;
2780          }          }
2781    
2782        while (eptr >= pp)        while (eptr >= pp)
2783          {          {
2784          RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);          RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);
# Line 3470  for (;;) Line 3556  for (;;)
3556      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
3557      if (op == OP_NOTI)         /* The caseless case */      if (op == OP_NOTI)         /* The caseless case */
3558        {        {
3559        register int ch, och;        register unsigned int ch, och;
3560        ch = *ecode++;        ch = *ecode++;
3561  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
3562        /* ch must be < 128 if UTF is enabled. */        /* ch must be < 128 if UTF is enabled. */
# Line 3616  for (;;) Line 3702  for (;;)
3702              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3703              }              }
3704            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3705            if (fc == d || foc == d) RRETURN(MATCH_NOMATCH);            if (fc == d || (unsigned int) foc == d) RRETURN(MATCH_NOMATCH);
3706            }            }
3707          }          }
3708        else        else
# Line 3654  for (;;) Line 3740  for (;;)
3740                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3741                }                }
3742              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3743              if (fc == d || foc == d) RRETURN(MATCH_NOMATCH);              if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
3744              }              }
3745            }            }
3746          else          else
# Line 3697  for (;;) Line 3783  for (;;)
3783                break;                break;
3784                }                }
3785              GETCHARLEN(d, eptr, len);              GETCHARLEN(d, eptr, len);
3786              if (fc == d || foc == d) break;              if (fc == d || (unsigned int)foc == d) break;
3787              eptr += len;              eptr += len;
3788              }              }
3789          if (possessive) continue;            if (possessive) continue;
3790          for(;;)            for(;;)
3791              {              {
3792              RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);
3793              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
# Line 4126  for (;;) Line 4212  for (;;)
4212              if (UCD_CATEGORY(c) != ucp_M) break;              if (UCD_CATEGORY(c) != ucp_M) break;
4213              eptr += len;              eptr += len;
4214              }              }
4215              CHECK_PARTIAL();
4216            }            }
4217          }          }
4218    
# Line 4910  for (;;) Line 4997  for (;;)
4997              if (UCD_CATEGORY(c) != ucp_M) break;              if (UCD_CATEGORY(c) != ucp_M) break;
4998              eptr += len;              eptr += len;
4999              }              }
5000              CHECK_PARTIAL();
5001            }            }
5002          }          }
5003        else        else
# Line 5453  for (;;) Line 5541  for (;;)
5541              if (UCD_CATEGORY(c) != ucp_M) break;              if (UCD_CATEGORY(c) != ucp_M) break;
5542              eptr += len;              eptr += len;
5543              }              }
5544              CHECK_PARTIAL();
5545            }            }
5546    
5547          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
# Line 6030  switch (frame->Xwhere) Line 6119  switch (frame->Xwhere)
6119    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)
6120    LBL(65) LBL(66)    LBL(65) LBL(66)
6121  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
6122    LBL(21)    LBL(21)
6123  #endif  #endif
6124  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
6125    LBL(16) LBL(18) LBL(20)    LBL(16) LBL(18) LBL(20)
6126    LBL(22) LBL(23) LBL(28) LBL(30)    LBL(22) LBL(23) LBL(28) LBL(30)
6127    LBL(32) LBL(34) LBL(42) LBL(46)    LBL(32) LBL(34) LBL(42) LBL(46)
6128  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 6043  switch (frame->Xwhere) Line 6132  switch (frame->Xwhere)
6132  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
6133    default:    default:
6134    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));
6135    
6136  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);
6137    
6138    return PCRE_ERROR_INTERNAL;    return PCRE_ERROR_INTERNAL;
# Line 6139  pcre_exec(const pcre *argument_re, const Line 6228  pcre_exec(const pcre *argument_re, const
6228    int offsetcount)    int offsetcount)
6229  #else  #else
6230  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
6231  pcre16_exec(const pcre *argument_re, const pcre_extra *extra_data,  pcre16_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,
6232    PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,    PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,
6233    int offsetcount)    int offsetcount)
6234  #endif  #endif
# Line 6167  PCRE_PUCHAR start_partial = NULL; Line 6256  PCRE_PUCHAR start_partial = NULL;
6256  PCRE_PUCHAR req_char_ptr = start_match - 1;  PCRE_PUCHAR req_char_ptr = start_match - 1;
6257    
6258  const pcre_study_data *study;  const pcre_study_data *study;
6259  const real_pcre *external_re = (const real_pcre *)argument_re;  const REAL_PCRE *re = (const REAL_PCRE *)argument_re;
6260  const real_pcre *re = external_re;  
6261    /* Check for the special magic call that measures the size of the stack used
6262    per recursive call of match(). Without the funny casting for sizeof, a Windows
6263    compiler gave this error: "unary minus operator applied to unsigned type,
6264    result still unsigned". Hopefully the cast fixes that. */
6265    
6266    if (re == NULL && extra_data == NULL && subject == NULL && length == -999 &&
6267        start_offset == -999)
6268    #ifdef NO_RECURSE
6269      return -((int)sizeof(heapframe));
6270    #else
6271      return match(NULL, NULL, NULL, 0, NULL, NULL, 0);
6272    #endif
6273    
6274  /* Plausibility checks */  /* Plausibility checks */
6275    
6276  if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;  if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
6277  if (re == NULL || subject == NULL ||  if (re == NULL || subject == NULL || (offsets == NULL && offsetcount > 0))
6278     (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;    return PCRE_ERROR_NULL;
6279  if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;  if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;
6280  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;
6281    
6282    /* Check that the first field in the block is the magic number. If it is not,
6283    return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to
6284    REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which
6285    means that the pattern is likely compiled with different endianness. */
6286    
6287    if (re->magic_number != MAGIC_NUMBER)
6288      return re->magic_number == REVERSED_MAGIC_NUMBER?
6289        PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;
6290    if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
6291    
6292  /* 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
6293  follows immediately afterwards. Other values in the md block are used only  follows immediately afterwards. Other values in the md block are used only
6294  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 6209  if (utf && (options & PCRE_NO_UTF8_CHECK Line 6320  if (utf && (options & PCRE_NO_UTF8_CHECK
6320  #else  #else
6321      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?
6322        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;
6323  #endif  #endif
6324      }      }
6325    
6326    /* 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 6222  if (utf && (options & PCRE_NO_UTF8_CHECK Line 6333  if (utf && (options & PCRE_NO_UTF8_CHECK
6333  /* If the pattern was successfully studied with JIT support, run the JIT  /* If the pattern was successfully studied with JIT support, run the JIT
6334  executable instead of the rest of this function. Most options must be set at  executable instead of the rest of this function. Most options must be set at
6335  compile time for the JIT code to be usable. Fallback to the normal code path if  compile time for the JIT code to be usable. Fallback to the normal code path if
6336  an unsupported flag is set. In particular, JIT does not support partial  an unsupported flag is set. */
 matching. */  
6337    
6338  #ifdef SUPPORT_JIT  #ifdef SUPPORT_JIT
6339  if (extra_data != NULL  if (extra_data != NULL
6340      && (extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0      && (extra_data->flags & (PCRE_EXTRA_EXECUTABLE_JIT |
6341                                 PCRE_EXTRA_TABLES)) == PCRE_EXTRA_EXECUTABLE_JIT
6342      && extra_data->executable_jit != NULL      && extra_data->executable_jit != NULL
     && (extra_data->flags & PCRE_EXTRA_TABLES) == 0  
6343      && (options & ~(PCRE_NO_UTF8_CHECK | PCRE_NOTBOL | PCRE_NOTEOL |      && (options & ~(PCRE_NO_UTF8_CHECK | PCRE_NOTBOL | PCRE_NOTEOL |
6344                      PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART)) == 0)                      PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART |
6345    return PRIV(jit_exec)(re, extra_data->executable_jit,                      PCRE_PARTIAL_SOFT | PCRE_PARTIAL_HARD)) == 0)
6346      {
6347      rc = PRIV(jit_exec)(re, extra_data->executable_jit,
6348      (const pcre_uchar *)subject, length, start_offset, options,      (const pcre_uchar *)subject, length, start_offset, options,
6349      ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0)      ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0)
6350      ? MATCH_LIMIT : extra_data->match_limit, offsets, offsetcount);      ? MATCH_LIMIT : extra_data->match_limit, offsets, offsetcount);
6351    
6352      /* PCRE_ERROR_NULL means that the selected normal or partial matching
6353      mode is not compiled. In this case we simply fallback to interpreter. */
6354    
6355      if (rc != PCRE_ERROR_NULL) return rc;
6356      }
6357  #endif  #endif
6358    
6359  /* Carry on with non-JIT matching. This information is for finding all the  /* Carry on with non-JIT matching. This information is for finding all the
# Line 6255  md->callout_data = NULL; Line 6373  md->callout_data = NULL;
6373    
6374  /* The table pointer is always in native byte order. */  /* The table pointer is always in native byte order. */
6375    
6376  tables = external_re->tables;  tables = re->tables;
6377    
6378  if (extra_data != NULL)  if (extra_data != NULL)
6379    {    {
# Line 6277  in other programs later. */ Line 6395  in other programs later. */
6395    
6396  if (tables == NULL) tables = PRIV(default_tables);  if (tables == NULL) tables = PRIV(default_tables);
6397    
 /* 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;  
   
6398  /* Set up other data */  /* Set up other data */
6399    
6400  anchored = ((re->options | options) & PCRE_ANCHORED) != 0;  anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
# Line 6295  firstline = (re->options & PCRE_FIRSTLIN Line 6403  firstline = (re->options & PCRE_FIRSTLIN
6403    
6404  /* 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. */
6405    
6406  md->start_code = (const pcre_uchar *)external_re + re->name_table_offset +  md->start_code = (const pcre_uchar *)re + re->name_table_offset +
6407    re->name_count * re->name_entry_size;    re->name_count * re->name_entry_size;
6408    
6409  md->start_subject = (PCRE_PUCHAR)subject;  md->start_subject = (PCRE_PUCHAR)subject;
# Line 6448  if (!anchored) Line 6556  if (!anchored)
6556    if ((re->flags & PCRE_FIRSTSET) != 0)    if ((re->flags & PCRE_FIRSTSET) != 0)
6557      {      {
6558      has_first_char = TRUE;      has_first_char = TRUE;
6559      first_char = first_char2 = re->first_char;      first_char = first_char2 = (pcre_uchar)(re->first_char);
6560      if ((re->flags & PCRE_FCH_CASELESS) != 0)      if ((re->flags & PCRE_FCH_CASELESS) != 0)
6561        {        {
6562        first_char2 = TABLE_GET(first_char, md->fcc, first_char);        first_char2 = TABLE_GET(first_char, md->fcc, first_char);
# Line 6470  character" set. */ Line 6578  character" set. */
6578  if ((re->flags & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
6579    {    {
6580    has_req_char = TRUE;    has_req_char = TRUE;
6581    req_char = req_char2 = re->req_char;    req_char = req_char2 = (pcre_uchar)(re->req_char);
6582    if ((re->flags & PCRE_RCH_CASELESS) != 0)    if ((re->flags & PCRE_RCH_CASELESS) != 0)
6583      {      {
6584      req_char2 = TABLE_GET(req_char, md->fcc, req_char);      req_char2 = TABLE_GET(req_char, md->fcc, req_char);
# Line 6765  for(;;) Line 6873  for(;;)
6873    
6874    /* 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
6875    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
6876    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
6877    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
6878    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
6879    why the first test exists. */    why the first test exists. */
6880    
6881    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 6966  if (rc == MATCH_MATCH || rc == MATCH_ACC
6966    /* Return MARK data if requested */    /* Return MARK data if requested */
6967    
6968    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
6969      *(extra_data->mark) = (unsigned char *)(md->mark);      *(extra_data->mark) = (pcre_uchar *)md->mark;
6970    DPRINTF((">>>> returning %d\n", rc));    DPRINTF((">>>> returning %d\n", rc));
6971    return rc;    return rc;
6972    }    }
# Line 6905  else Line 7013  else
7013  /* Return the MARK data if it has been requested. */  /* Return the MARK data if it has been requested. */
7014    
7015  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
7016    *(extra_data->mark) = (unsigned char *)(md->nomatch_mark);    *(extra_data->mark) = (pcre_uchar *)md->nomatch_mark;
7017  return rc;  return rc;
7018  }  }
7019    

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

  ViewVC Help
Powered by ViewVC 1.1.5