Changeset 35027 in webkit for trunk/JavaScriptCore/kjs/regexp.cpp


Ignore:
Timestamp:
Jul 6, 2008, 7:49:29 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-07-06 Sam Weinig <[email protected]>

Reviewed by Cameron Zwarich.

Second step in broad cleanup effort.

[ File list elided ]

WebCore:

2008-07-06 Sam Weinig <[email protected]>

Reviewed by Cameron Zwarich.

Add #include for kjs/protect.h.

  • xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::loadRequestAsynchronously):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/regexp.cpp

    r34580 r35027  
    1 // -*- c-basic-offset: 2 -*-
    21/*
    32 *  Copyright (C) 1999-2001, 2004 Harri Porten ([email protected])
     
    3433
    3534inline RegExp::RegExp(const UString& pattern)
    36   : m_pattern(pattern)
    37   , m_flagBits(0)
    38   , m_constructionError(0)
    39   , m_numSubpatterns(0)
     35    : m_pattern(pattern)
     36    , m_flagBits(0)
     37    , m_constructionError(0)
     38    , m_numSubpatterns(0)
    4039{
    4140    m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(pattern.data()), pattern.size(),
     
    4948
    5049inline RegExp::RegExp(const UString& pattern, const UString& flags)
    51   : m_pattern(pattern)
    52   , m_flags(flags)
    53   , m_flagBits(0)
    54   , m_constructionError(0)
    55   , m_numSubpatterns(0)
     50    : m_pattern(pattern)
     51    , m_flags(flags)
     52    , m_flagBits(0)
     53    , m_constructionError(0)
     54    , m_numSubpatterns(0)
    5655{
    5756    // NOTE: The global flag is handled on a case-by-case basis by functions like
     
    7271        multilineOption = JSRegExpMultiline;
    7372    }
    74    
     73
    7574    m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(pattern.data()), pattern.size(),
    7675        ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError);
     
    8988int RegExp::match(const UString& s, int i, OwnArrayPtr<int>* ovector)
    9089{
    91   if (i < 0)
    92     i = 0;
    93   if (ovector)
    94     ovector->clear();
     90    if (i < 0)
     91        i = 0;
     92    if (ovector)
     93        ovector->clear();
    9594
    96   if (i > s.size() || s.isNull())
    97     return -1;
     95    if (i > s.size() || s.isNull())
     96        return -1;
    9897
    99   if (!m_regExp)
    100     return -1;
     98    if (!m_regExp)
     99        return -1;
    101100
    102   // Set up the offset vector for the result.
    103   // First 2/3 used for result, the last third used by PCRE.
    104   int* offsetVector;
    105   int offsetVectorSize;
    106   int fixedSizeOffsetVector[3];
    107   if (!ovector) {
    108     offsetVectorSize = 3;
    109     offsetVector = fixedSizeOffsetVector;
    110   } else {
    111     offsetVectorSize = (m_numSubpatterns + 1) * 3;
    112     offsetVector = new int [offsetVectorSize];
    113     ovector->set(offsetVector);
    114   }
     101    // Set up the offset vector for the result.
     102    // First 2/3 used for result, the last third used by PCRE.
     103    int* offsetVector;
     104    int offsetVectorSize;
     105    int fixedSizeOffsetVector[3];
     106    if (!ovector) {
     107        offsetVectorSize = 3;
     108        offsetVector = fixedSizeOffsetVector;
     109    } else {
     110        offsetVectorSize = (m_numSubpatterns + 1) * 3;
     111        offsetVector = new int [offsetVectorSize];
     112        ovector->set(offsetVector);
     113    }
    115114
    116   int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const UChar*>(s.data()), s.size(), i, offsetVector, offsetVectorSize);
     115    int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const UChar*>(s.data()), s.size(), i, offsetVector, offsetVectorSize);
    117116
    118   if (numMatches < 0) {
     117    if (numMatches < 0) {
    119118#ifndef NDEBUG
    120     if (numMatches != JSRegExpErrorNoMatch)
    121       fprintf(stderr, "jsRegExpExecute failed with result %d\n", numMatches);
     119        if (numMatches != JSRegExpErrorNoMatch)
     120            fprintf(stderr, "jsRegExpExecute failed with result %d\n", numMatches);
    122121#endif
    123     if (ovector)
    124       ovector->clear();
    125     return -1;
    126   }
     122        if (ovector)
     123            ovector->clear();
     124        return -1;
     125    }
    127126
    128   return offsetVector[0];
     127    return offsetVector[0];
    129128}
    130129
Note: See TracChangeset for help on using the changeset viewer.