Ignore:
Timestamp:
Nov 12, 2007, 3:04:41 PM (18 years ago)
Author:
Darin Adler
Message:

Reviewed by Geoff.

  • fix use of prefix and config.h, got rid of a few unneeded things in the PCRE code; no behavior changes
  • API/JSBase.cpp: Added include of config.h.
  • API/JSCallbackConstructor.cpp: Ditto.
  • API/JSCallbackFunction.cpp: Ditto.
  • API/JSCallbackObject.cpp: Ditto.
  • API/JSClassRef.cpp: Ditto.
  • API/JSContextRef.cpp: Ditto.
  • API/JSObjectRef.cpp: Ditto.
  • API/JSStringRef.cpp: Ditto.
  • API/JSValueRef.cpp: Ditto.
  • JavaScriptCorePrefix.h: Removed obsolete <ctype.h> workaround. Moved new/delete macros after includes, as they are in WebCore's prefix. Removed "config.h".
  • pcre/dftables.cpp: (main): Changed back to not use a separate maketables function. This is needed for PCRE, but not helpful for our use. Also changed the tables to all be 128 entries long instead of 256, since only the first 128 are ever used.
  • pcre/pcre_compile.cpp: Added include of config.h. Eliminated digitab, which was only being used to check hex digits. Changed all uses of TRUE and FALSE to use the C++ true and false instead. (check_escape): Just the TRUE/FALSE thing. (is_counted_repeat): Ditto. (could_be_empty_branch): Ditto. (get_othercase_range): Ditto. (compile_branch): Ditto. (compile_regex): Ditto. (is_anchored): Ditto. (is_startline): Ditto. (find_firstassertedchar): Ditto. (jsRegExpCompile): Ditto.
  • pcre/pcre_exec.cpp: Added include of config.h. Changed all uses of TRUE and FALSE to use the C++ true and false instead. (match_ref): Just the TRUE/FALSE thing. (match): Ditto. Removed some unneeded braces. (jsRegExpExecute): Just the TRUE/FALSE thing.
  • pcre/pcre_internal.h: Moved the constants needed by dftables.cpp to the top of the file instead of the bottom, so they can be used. Also changed the table sizes to 128 instead of 256. Removed macro definitions of FALSE and TRUE. Set array sizes for all the const arrays. Changed _pcre_utf8_table1_size to be a macro instead of a extern int.
  • pcre/pcre_maketables.cpp: Removed. It's all in dftables.cpp now.
  • pcre/pcre_tables.cpp: Made table sizes explicit.
  • pcre/pcre_xclass.cpp: Just the TRUE/FALSE thing.
File:
1 edited

Legend:

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

    r27686 r27730  
    4141that does pattern matching using an NFA algorithm, following the rules from
    4242the JavaScript specification. There are also some supporting functions. */
     43
     44#include "config.h"
    4345
    4446#include "pcre_internal.h"
     
    129131} match_data;
    130132
    131 #define match_isgroup      TRUE    /* Set if start of bracketed group */
     133#define match_isgroup      true    /* Set if start of bracketed group */
    132134
    133135/* Non-error returns from the match() function. Error returns are externally
     
    155157  p           points to characters
    156158  length      number to print
    157   is_subject  TRUE if printing from within md->start_subject
    158   md          pointer to matching data block, if is_subject is TRUE
     159  is_subject  true if printing from within md->start_subject
     160  md          pointer to matching data block, if is_subject is true
    159161
    160162Returns:     nothing
     
    188190  md          points to match data block
    189191
    190 Returns:      TRUE if matched
     192Returns:      true if matched
    191193*/
    192194
     
    202204  {
    203205  printf("matching subject ");
    204   pchars(eptr, length, TRUE, md);
     206  pchars(eptr, length, true, md);
    205207  }
    206208printf(" against backref ");
    207 pchars(p, length, FALSE, md);
     209pchars(p, length, false, md);
    208210printf("\n");
    209211#endif
     
    211213/* Always fail if not enough characters left */
    212214
    213 if (length > md->end_subject - eptr) return FALSE;
     215if (length > md->end_subject - eptr) return false;
    214216
    215217/* Separate the caselesss case for speed */
     
    222224    int othercase = _pcre_ucp_othercase(c);
    223225    pcre_uchar d = *eptr++;
    224     if (c != d && othercase != d) return FALSE;
     226    if (c != d && othercase != d) return false;
    225227    }
    226228  }
    227229else
    228   { while (length-- > 0) if (*p++ != *eptr++) return FALSE; }
    229 
    230 return TRUE;
     230  { while (length-- > 0) if (*p++ != *eptr++) return false; }
     231
     232return true;
    231233}
    232234
     
    298300#define RRETURN_NO_MATCH \
    299301  {\
    300     is_match = FALSE;\
     302    is_match = false;\
    301303    RRETURN;\
    302304  }
     
    333335static int match(USPTR eptr, const uschar *ecode, int offset_top, match_data *md)
    334336{
    335 register int is_match = FALSE;
     337register int is_match = false;
    336338register int i;
    337339register int c;
     
    341343BOOL cur_is_word;
    342344BOOL prev_is_word;
    343 BOOL is_group_start = TRUE;
     345BOOL is_group_start = true;
    344346int min;
    345 BOOL minimize = FALSE; /* Initialization not really needed, but some compilers think so. */
     347BOOL minimize = false; /* Initialization not really needed, but some compilers think so. */
    346348
    347349/* The value 16 here is large enough that most regular expressions don't require
     
    450452    md->end_match_ptr = frame->eptr;          /* Record where we ended */
    451453    md->end_offset_top = frame->offset_top;   /* and how many extracts were taken */
    452     is_match = TRUE;
     454    is_match = true;
    453455    RRETURN;
    454456
     
    499501
    500502    BEGIN_OPCODE(ONCE):
    501       {
    502503      frame->prev = frame->ecode;
    503504      frame->saved_eptr = frame->eptr;
     
    554555        if (is_match) RRETURN;
    555556        }
    556       }
    557557    RRETURN;
    558558
     
    610610        md->end_match_ptr = frame->eptr;      /* For ONCE */
    611611        md->end_offset_top = frame->offset_top;
    612         is_match = TRUE;
     612        is_match = true;
    613613        RRETURN;
    614614        }
     
    618618      extraction by setting the offsets and bumping the high water mark. */
    619619
    620         {
    621620        frame->number = *frame->prev - OP_BRA;
    622621
     
    639638        if (frame->number > 0)
    640639          {
    641           if (frame->offset >= md->offset_max) md->offset_overflow = TRUE; else
     640          if (frame->offset >= md->offset_max) md->offset_overflow = true; else
    642641            {
    643642            md->offset_vector[frame->offset] =
     
    647646            }
    648647          }
    649         }
    650648
    651649      /* For a non-repeating ket, just continue at this level. This also
     
    724722
    725723        {
    726         if (frame->eptr == md->start_subject) prev_is_word = FALSE; else
     724        if (frame->eptr == md->start_subject) prev_is_word = false; else
    727725          {
    728726          const pcre_uchar *lastptr = frame->eptr - 1;
     
    731729          prev_is_word = c < 128 && (md->ctypes[c] & ctype_word) != 0;
    732730          }
    733         if (frame->eptr >= md->end_subject) cur_is_word = FALSE; else
     731        if (frame->eptr >= md->end_subject) cur_is_word = false; else
    734732          {
    735733          GETCHAR(c, frame->eptr);
     
    813811
    814812    BEGIN_OPCODE(REF):
    815       {
    816813      frame->offset = GET2(frame->ecode, 1) << 1;               /* Doubled ref number */
    817814      frame->ecode += 3;                                 /* Advance past item */
     
    911908        RRETURN_NO_MATCH;
    912909        }
    913       }
    914910    /* Control never gets here */
    915911
     
    927923    BEGIN_OPCODE(NCLASS):
    928924    BEGIN_OPCODE(CLASS):
    929       {
    930925      frame->data = frame->ecode + 1;                /* Save for matching */
    931926      frame->ecode += 33;                     /* Advance past the item */
     
    10371032        RRETURN;
    10381033        }
    1039       }
    10401034    /* Control never gets here */
    10411035
     
    10441038
    10451039    BEGIN_OPCODE(XCLASS):
    1046       {
    10471040      frame->data = frame->ecode + 1 + LINK_SIZE;                /* Save for matching */
    10481041      frame->ecode += GET(frame->ecode, 1);                      /* Advance past the item */
     
    11301123        }
    11311124
    1132       /* Control never gets here */
    1133       }
     1125    /* Control never gets here */
    11341126
    11351127    /* Match a single character, casefully */
    11361128
    11371129    BEGIN_OPCODE(CHAR):
    1138       {
    11391130      frame->length = 1;
    11401131      frame->ecode++;
     
    11571148        if (frame->fc != dc) RRETURN_NO_MATCH;
    11581149      }
    1159       }
    11601150    NEXT_OPCODE;
    11611151
     
    11631153
    11641154    BEGIN_OPCODE(CHARNC):
    1165       {
    11661155      frame->length = 1;
    11671156      frame->ecode++;
     
    11891178          }
    11901179        }
    1191       }
    11921180    NEXT_OPCODE;
    11931181
     
    12181206    BEGIN_OPCODE(EXACT):
    12191207    min = frame->max = GET2(frame->ecode, 1);
    1220     minimize = FALSE;
     1208    minimize = false;
    12211209    frame->ecode += 3;
    12221210    goto REPEATCHAR;
     
    12501238      frame->length = 1;
    12511239      GETUTF8CHARLEN(frame->fc, frame->ecode, frame->length);
    1252       {
    12531240      if (min * (frame->fc > 0xFFFF ? 2 : 1) > md->end_subject - frame->eptr) RRETURN_NO_MATCH;
    12541241      frame->ecode += frame->length;
     
    13491336          /* Control never gets here */
    13501337        }
    1351         /* Control never gets here */
    1352         }
     1338    /* Control never gets here */
    13531339
    13541340    /* Match a negated single one-byte character. The character we are
     
    13801366    BEGIN_OPCODE(NOTEXACT):
    13811367    min = frame->max = GET2(frame->ecode, 1);
    1382     minimize = FALSE;
     1368    minimize = false;
    13831369    frame->ecode += 3;
    13841370    goto REPEATNOTCHAR;
     
    15561542    BEGIN_OPCODE(TYPEEXACT):
    15571543    min = frame->max = GET2(frame->ecode, 1);
    1558     minimize = TRUE;
     1544    minimize = true;
    15591545    frame->ecode += 3;
    15601546    goto REPEATTYPE;
     
    19111897#ifdef DEBUG
    19121898        printf("start bracket %d subject=", frame->number);
    1913         pchars(frame->eptr, 16, TRUE, md);
     1899        pchars(frame->eptr, 16, true, md);
    19141900        printf("\n");
    19151901#endif
     
    20442030int req_byte = -1;
    20452031int req_byte2 = -1;
    2046 BOOL using_temporary_offsets = FALSE;
    2047 BOOL first_byte_caseless = FALSE;
     2032BOOL using_temporary_offsets = false;
     2033BOOL first_byte_caseless = false;
    20482034BOOL startline;
    2049 BOOL req_byte_caseless = FALSE;
     2035BOOL req_byte_caseless = false;
    20502036match_data match_block;
    20512037USPTR start_match = (USPTR)subject + start_offset;
     
    20942080  match_block.offset_vector = new int[ocount];
    20952081  if (match_block.offset_vector == NULL) return JSRegExpErrorNoMemory;
    2096   using_temporary_offsets = TRUE;
     2082  using_temporary_offsets = true;
    20972083  DPRINTF(("Got memory to hold back references\n"));
    20982084  }
     
    21012087match_block.offset_end = ocount;
    21022088match_block.offset_max = (2*ocount)/3;
    2103 match_block.offset_overflow = FALSE;
     2089match_block.offset_overflow = false;
    21042090
    21052091/* Compute the minimum number of offsets that we need to reset each time. Doing
     
    21302116    {
    21312117    first_byte = re->first_byte & 255;
    2132     if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
     2118    if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == true)
    21332119      first_byte = match_block.lcc[first_byte];
    21342120    }
     
    21602146    }
    21612147
    2162   /* Advance to a unique first char if possible. If firstline is TRUE, the
     2148  /* Advance to a unique first char if possible. If firstline is true, the
    21632149  start of the match is constrained to the first line of a multiline string.
    21642150  Implement this by temporarily adjusting end_subject so that we stop scanning
     
    22032189#ifdef DEBUG  /* Sigh. Some compilers never learn. */
    22042190  printf(">>>> Match against: ");
    2205   pchars(start_match, end_subject - start_match, TRUE, &match_block);
     2191  pchars(start_match, end_subject - start_match, true, &match_block);
    22062192  printf("\n");
    22072193#endif
     
    23052291      }
    23062292    if (match_block.end_offset_top > offsetcount)
    2307       match_block.offset_overflow = TRUE;
     2293      match_block.offset_overflow = true;
    23082294
    23092295    DPRINTF(("Freeing temporary memory\n"));
Note: See TracChangeset for help on using the changeset viewer.