diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-07-14 15:49:56 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-07-14 15:49:56 (GMT) |
commit | 8fd9cbc859346d758bb730e85c679635f00940df (patch) | |
tree | bc3b10d79a458933b1f481bd7e88d1a633e7bc1e /src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp | |
parent | 65b788014759fa06d65d1677b3dbd5cc4b596f6b (diff) | |
parent | 06af27069497a693f5b1a867b29d96297f68eb75 (diff) | |
download | Qt-8fd9cbc859346d758bb730e85c679635f00940df.zip Qt-8fd9cbc859346d758bb730e85c679635f00940df.tar.gz Qt-8fd9cbc859346d758bb730e85c679635f00940df.tar.bz2 |
Merge branch 'qtwebkit-4.6-staging' into qtscript-jsc-backend
Conflicts:
src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp
src/script/qscriptecmafunction.cpp
src/script/qscriptecmaglobal.cpp
src/script/qscriptengine.cpp
src/script/qscriptengine_p.cpp
src/script/qscriptenginefwd_p.h
src/script/qscriptextqobject.cpp
src/script/qscriptextqobject_p.h
tests/auto/qscriptqobject/tst_qscriptqobject.cpp
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp')
-rw-r--r-- | src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp index 857a316..7dd4a8f 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 1999-2001, 2004 Harri Porten (porten@kde.org) * Copyright (c) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2009 Torch Mobile, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -110,7 +111,7 @@ void RegExp::compile(JSGlobalData* globalData) #endif } -int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector) +int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector) { if (startOffset < 0) startOffset = 0; @@ -126,16 +127,20 @@ int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector) if (m_regExpBytecode) { #endif int offsetVectorSize = (m_numSubpatterns + 1) * 3; // FIXME: should be 2 - but adding temporary fallback to pcre. - int* offsetVector = new int [offsetVectorSize]; + int* offsetVector; + Vector<int, 32> nonReturnedOvector; + if (ovector) { + ovector->resize(offsetVectorSize); + offsetVector = ovector->data(); + } else { + nonReturnedOvector.resize(offsetVectorSize); + offsetVector = nonReturnedOvector.data(); + } + ASSERT(offsetVector); for (int j = 0; j < offsetVectorSize; ++j) offsetVector[j] = -1; - OwnArrayPtr<int> nonReturnedOvector; - if (!ovector) - nonReturnedOvector.set(offsetVector); - else - ovector->set(offsetVector); #if ENABLE(YARR_JIT) int result = Yarr::executeRegex(m_regExpJITCode, s.data(), startOffset, s.size(), offsetVector, offsetVectorSize); @@ -177,7 +182,7 @@ void RegExp::compile(JSGlobalData* globalData) m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(m_pattern.data()), m_pattern.size(), ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError); } -int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector) +int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector) { if (startOffset < 0) startOffset = 0; @@ -190,17 +195,19 @@ int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector) #if ENABLE(WREC) if (m_wrecFunction) { int offsetVectorSize = (m_numSubpatterns + 1) * 2; - int* offsetVector = new int [offsetVectorSize]; + int* offsetVector; + Vector<int, 32> nonReturnedOvector; + if (ovector) { + ovector->resize(offsetVectorSize); + offsetVector = ovector->data(); + } else { + nonReturnedOvector.resize(offsetVectorSize); + offsetVector = nonReturnedOvector.data(); + } ASSERT(offsetVector); for (int j = 0; j < offsetVectorSize; ++j) offsetVector[j] = -1; - OwnArrayPtr<int> nonReturnedOvector; - if (!ovector) - nonReturnedOvector.set(offsetVector); - else - ovector->set(offsetVector); - int result = m_wrecFunction(s.data(), startOffset, s.size(), offsetVector); if (result < 0) { @@ -226,8 +233,8 @@ int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector) offsetVector = fixedSizeOffsetVector; } else { offsetVectorSize = (m_numSubpatterns + 1) * 3; - offsetVector = new int [offsetVectorSize]; - ovector->set(offsetVector); + ovector->resize(offsetVectorSize); + offsetVector = ovector->data(); } int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const UChar*>(s.data()), s.size(), startOffset, offsetVector, offsetVectorSize); |