Ignore:
Timestamp:
Nov 29, 2007, 3:19:42 AM (18 years ago)
Author:
[email protected]
Message:

2007-11-24 Eric Seidel <[email protected]>

Reviewed by Sam.

split first_significant_code into two simpler functions

  • pcre/pcre_compile.cpp: (firstSignificantOpCode): (firstSignificantOpCodeSkippingAssertions): (is_anchored): (canApplyFirstCharOptimization): (find_firstassertedchar):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/pcre/pcre_exec.cpp

    r28149 r28156  
    123123  int    offset_end;            /* One past the end */
    124124  int    offset_max;            /* The maximum usable for return data */
    125   const uschar* lcc;            /* Points to lower casing table */
     125  const uschar* lowerCaseChars; /* Points to lower casing table */
    126126  const uschar* ctypes;         /* Points to table of type maps */
    127127  bool   offset_overflow;       /* Set if too many extractions */
     
    131131  int    end_offset_top;        /* Highwater mark at end of match */
    132132  bool   multiline;
    133   bool   caseless;
     133  bool   ignoreCase;
    134134};
    135135
     
    223223    /* Separate the caselesss case for speed */
    224224   
    225     if (md.caseless) {
     225    if (md.ignoreCase) {
    226226        while (length-- > 0) {
    227227            UChar c = *p++;
     
    13081308               
    13091309                if (stack.currentFrame->fc <= 0xFFFF) {
    1310                     int othercase = md.caseless ? _pcre_ucp_othercase(stack.currentFrame->fc) : -1;
     1310                    int othercase = md.ignoreCase ? _pcre_ucp_othercase(stack.currentFrame->fc) : -1;
    13111311                   
    13121312                    for (i = 1; i <= min; i++) {
     
    14091409                stack.currentFrame->ecode++;
    14101410                GETCHARINCTEST(c, stack.currentFrame->eptr);
    1411                 if (md.caseless) {
     1411                if (md.ignoreCase) {
    14121412                    if (c < 128)
    1413                         c = md.lcc[c];
    1414                     if (md.lcc[*stack.currentFrame->ecode++] == c)
     1413                        c = md.lowerCaseChars[c];
     1414                    if (md.lowerCaseChars[*stack.currentFrame->ecode++] == c)
    14151415                        RRETURN_NO_MATCH;
    14161416                } else {
     
    14721472                DPRINTF(("negative matching %c{%d,%d}\n", stack.currentFrame->fc, min, stack.currentFrame->max));
    14731473               
    1474                 if (md.caseless) {
     1474                if (md.ignoreCase) {
    14751475                    if (stack.currentFrame->fc < 128)
    1476                         stack.currentFrame->fc = md.lcc[stack.currentFrame->fc];
     1476                        stack.currentFrame->fc = md.lowerCaseChars[stack.currentFrame->fc];
    14771477                   
    14781478                    {
     
    14811481                            GETCHARINC(d, stack.currentFrame->eptr);
    14821482                            if (d < 128)
    1483                                 d = md.lcc[d];
     1483                                d = md.lowerCaseChars[d];
    14841484                            if (stack.currentFrame->fc == d)
    14851485                                RRETURN_NO_MATCH;
     
    14981498                            GETCHARINC(d, stack.currentFrame->eptr);
    14991499                            if (d < 128)
    1500                                 d = md.lcc[d];
     1500                                d = md.lowerCaseChars[d];
    15011501                            if (stack.currentFrame->fi >= stack.currentFrame->max || stack.currentFrame->eptr >= md.end_subject || stack.currentFrame->fc == d)
    15021502                                RRETURN;
     
    15181518                                GETCHARLEN(d, stack.currentFrame->eptr, len);
    15191519                                if (d < 128)
    1520                                     d = md.lcc[d];
     1520                                    d = md.lowerCaseChars[d];
    15211521                                if (stack.currentFrame->fc == d)
    15221522                                    break;
     
    20772077    UChar* end_subject = match_block.end_subject;
    20782078   
    2079     match_block.lcc = _pcre_default_tables + lcc_offset;
     2079    match_block.lowerCaseChars = _pcre_default_tables + lcc_offset;
    20802080    match_block.ctypes = _pcre_default_tables + ctypes_offset;
    20812081   
    20822082    match_block.multiline = (re->options & PCRE_MULTILINE);
    2083     match_block.caseless = (re->options & PCRE_CASELESS);
     2083    match_block.ignoreCase = (re->options & OptionIgnoreCase);
    20842084   
    20852085    /* If the expression has got more back references than the offsets supplied can
     
    21332133    if (re->options & PCRE_FIRSTSET) {
    21342134        first_byte = re->first_byte & 255;
    2135         if ((first_byte_caseless = (re->first_byte & REQ_CASELESS)))
    2136             first_byte = match_block.lcc[first_byte];
     2135        if ((first_byte_caseless = (re->first_byte & REQ_IGNORE_CASE)))
     2136            first_byte = match_block.lowerCaseChars[first_byte];
    21372137    }
    21382138   
     
    21452145    if (re->options & PCRE_REQCHSET) {
    21462146        req_byte = re->req_byte & 255;
    2147         req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;
     2147        req_byte_caseless = (re->req_byte & REQ_IGNORE_CASE);
    21482148        req_byte2 = (_pcre_default_tables + fcc_offset)[req_byte];  /* case flipped */
    21492149    }
     
    21832183                    if (sm > 127)
    21842184                        break;
    2185                     if (match_block.lcc[sm] == first_char)
     2185                    if (match_block.lowerCaseChars[sm] == first_char)
    21862186                        break;
    21872187                    start_match++;
Note: See TracChangeset for help on using the changeset viewer.