Commit ee752e7d authored by darin@apple.com's avatar darin@apple.com

JavaScriptCore:

        Reviewed by Sam.

        - http://bugs.webkit.org/show_bug.cgi?id=15924
          next round of changes to JSRegExp (formerly PCRE)

        This is a combination of converting to C++, tweaking the API, and adding
        some additional optimizations.

        Future steps will involve getting rid of the use of UTF-8 completely
        (we'll use UTF-16 exclusively instead), eliminating more source files,
        and some more speed-ups.

        SunSpider says the current round is an 0.9% speed-up overall, and a
        5.3% speed-up for regexp.

        * JavaScriptCore.exp: Updated for new entry points.

        * JavaScriptCore.pri:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
        * JavaScriptCore.vcproj/dftables/dftables.vcproj:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * JavaScriptCoreSources.bkl:
        * jscore.bkl:
        Updated for new source file names and ForwardingHeaders.

        * kjs/regexp.cpp:
        (KJS::RegExp::RegExp): Changed to use the error message without calling
        strdup on it and to pass the new types and options.
        (KJS::RegExp::~RegExp): Removed the now-unneeded free of the error message.
        (KJS::RegExp::match): Pass the new types and options.
        * kjs/regexp.h: Update type of m_constructionError.

        * pcre/AUTHORS: Update to reflect the status of the project -- we don't include
        the Google parts, and this isn't the PCRE library, per se.
        * pcre/COPYING: Ditto.

        * pcre/dftables.cpp: Copied from JavaScriptCore/pcre/dftables.c.
        (main): Removed unneeded ctype_digit.

        * pcre/pcre.h: Convert to C++, tweak API a bit. Use UChar instead of JSRegExpChar.

        * pcre/pcre_compile.cpp: Copied from JavaScriptCore/pcre/pcre_compile.c.
        Moved a lot of private stuff used only within this file here from pcre_internal.h.
        Renumbered the error codes.
        (error_text): Use a single string with embedded nulls for the error text (I got
        this idea from newer versions of PCRE).
        (check_escape): Changed return type to be enum instead of int. Replaced ctype_digit
        uses with isASCIIDigit.
        (is_counted_repeat): Ditto.
        (read_repeat_counts): Ditto.
        (first_significant_code): Ditto.
        (find_fixedlength): Ditto.
        (could_be_empty_branch): Ditto.
        (compile_branch): Ditto. Also removed some code that handles changing options.
        JavaScript doesn't have any of the features that allow options to change.
        (compile_regex): Updated for change to options parameter.
        (is_anchored): Ditto.
        (find_firstassertedchar): Ditto.
        (jsRegExpCompile): Changed to take separate flags instead of an options int.
        Also changed to call new/delete instead of pcre_malloc/free.
        (jsRegExpFree): Ditto.

        * pcre/pcre_exec.cpp: Copied from JavaScriptCore/pcre/pcre_exec.c.
        Added a case that uses computed goto for the opcode loop, but did not turn it on.
        Changed the RMATCH macro to handle returns more efficiently by putting the where
        pointer in the new frame instead of the old one, allowing us to branch to the
        return with a single statement. Switched to new/delete from pcre_malloc/free.
        Changed many RRETURN callers to not set the return value since it's already
        set correctly. Replaced the rrc variable with an is_match variable. Values other
        than "match" and "no match" are now handled differently. This allows us to remove
        the code to check for those cases in various rules.
        (match): All the case statements use a macro BEGIN_OPCODE instead. And all the
        continue statements, or break statements that break out of the outer case use
        a macro NEXT_OPCODE instead. Replaced a few if statements with assertions.
        (jsRegExpExecute): Use new/delete instead of pcre_malloc/free. Removed unused
        start_match field from the match block.

        * pcre/pcre_internal.h: Moved the last few configuration macros from pcre-config.h
        in here. Removed various unused types. Converted from JSRegExpChar to UChar.
        Eliminated pcre_malloc/free. Replaced the opcode enum with a macro that can be
        used in multiple places. Unfortunately we lose the comments for each opcode; we
        should find a place to put those back. Removed ctype_digit.

        * pcre/pcre_maketables.cpp: Copied from JavaScriptCore/pcre/pcre_maketables.c.
        (pcre_maketables): Got rid of the conditional code that allows this to be compiled
        in -- it's only used for dftables now (and soon may be obsolete entirely).
        Changed code for cbit_digit to not use isdigit, and took the "_" case out of the
        loop. Removed ctype_digit.

        * pcre/pcre_ord2utf8.cpp: Copied from JavaScriptCore/pcre/pcre_ord2utf8.c.

        * pcre/pcre_tables.cpp: Copied from JavaScriptCore/pcre/pcre_tables.c.
        Moved _pcre_OP_lengths out of here into pcre_exec.cpp.

        * pcre/pcre_ucp_searchfuncs.cpp: Copied from JavaScriptCore/pcre/pcre_ucp_searchfuncs.c.
        Updated for other file name changes.

        * pcre/pcre_xclass.cpp: Copied from JavaScriptCore/pcre/pcre_xclass.c.

        * pcre/ucpinternal.h: Updated header.

        * pcre/ucptable.cpp: Copied from JavaScriptCore/pcre/ucptable.c.

        * wtf/ASCIICType.h: (WTF::isASCIIDigit): Removed a branch by changing from && to
        & for this operation. Also added an overload that takes an int because that's
        useful for PCRE. Later we could optimize for int and overload other functions in
        this file; stuck to this simple one for now.

        * wtf/unicode/icu/UnicodeIcu.h: Removed unused isUpper.
        * wtf/unicode/qt4/UnicodeQt4.h: Ditto.

        * pcre/LICENCE: Removed.
        * pcre/pcre-config.h: Removed.
        * wtf/FastMallocPCRE.cpp: Removed.

        * pcre/dftables.c: Renamed to cpp.
        * pcre/pcre_compile.c: Ditto.
        * pcre/pcre_exec.c: Ditto.
        * pcre/pcre_maketables.c: Ditto.
        * pcre/pcre_ord2utf8.c: Ditto.
        * pcre/pcre_tables.c: Ditto.
        * pcre/pcre_ucp_searchfuncs.c: Ditto.
        * pcre/pcre_xclass.c: Ditto.
        * pcre/ucptable.c: Ditto.

WebCore:

        Reviewed by Sam.

        - updated for JSRegExp function changes

        * platform/RegularExpression.cpp:
        (WebCore::RegularExpression::Private::compile):
        (WebCore::RegularExpression::match):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@27686 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 059734cf
2007-11-11 Darin Adler <darin@apple.com>
Reviewed by Sam.
- http://bugs.webkit.org/show_bug.cgi?id=15924
next round of changes to JSRegExp (formerly PCRE)
This is a combination of converting to C++, tweaking the API, and adding
some additional optimizations.
Future steps will involve getting rid of the use of UTF-8 completely
(we'll use UTF-16 exclusively instead), eliminating more source files,
and some more speed-ups.
SunSpider says the current round is an 0.9% speed-up overall, and a
5.3% speed-up for regexp.
* JavaScriptCore.exp: Updated for new entry points.
* JavaScriptCore.pri:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.vcproj/dftables/dftables.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* JavaScriptCoreSources.bkl:
* jscore.bkl:
Updated for new source file names and ForwardingHeaders.
* kjs/regexp.cpp:
(KJS::RegExp::RegExp): Changed to use the error message without calling
strdup on it and to pass the new types and options.
(KJS::RegExp::~RegExp): Removed the now-unneeded free of the error message.
(KJS::RegExp::match): Pass the new types and options.
* kjs/regexp.h: Update type of m_constructionError.
* pcre/AUTHORS: Update to reflect the status of the project -- we don't include
the Google parts, and this isn't the PCRE library, per se.
* pcre/COPYING: Ditto.
* pcre/dftables.cpp: Copied from JavaScriptCore/pcre/dftables.c.
(main): Removed unneeded ctype_digit.
* pcre/pcre.h: Convert to C++, tweak API a bit. Use UChar instead of JSRegExpChar.
* pcre/pcre_compile.cpp: Copied from JavaScriptCore/pcre/pcre_compile.c.
Moved a lot of private stuff used only within this file here from pcre_internal.h.
Renumbered the error codes.
(error_text): Use a single string with embedded nulls for the error text (I got
this idea from newer versions of PCRE).
(check_escape): Changed return type to be enum instead of int. Replaced ctype_digit
uses with isASCIIDigit.
(is_counted_repeat): Ditto.
(read_repeat_counts): Ditto.
(first_significant_code): Ditto.
(find_fixedlength): Ditto.
(could_be_empty_branch): Ditto.
(compile_branch): Ditto. Also removed some code that handles changing options.
JavaScript doesn't have any of the features that allow options to change.
(compile_regex): Updated for change to options parameter.
(is_anchored): Ditto.
(find_firstassertedchar): Ditto.
(jsRegExpCompile): Changed to take separate flags instead of an options int.
Also changed to call new/delete instead of pcre_malloc/free.
(jsRegExpFree): Ditto.
* pcre/pcre_exec.cpp: Copied from JavaScriptCore/pcre/pcre_exec.c.
Added a case that uses computed goto for the opcode loop, but did not turn it on.
Changed the RMATCH macro to handle returns more efficiently by putting the where
pointer in the new frame instead of the old one, allowing us to branch to the
return with a single statement. Switched to new/delete from pcre_malloc/free.
Changed many RRETURN callers to not set the return value since it's already
set correctly. Replaced the rrc variable with an is_match variable. Values other
than "match" and "no match" are now handled differently. This allows us to remove
the code to check for those cases in various rules.
(match): All the case statements use a macro BEGIN_OPCODE instead. And all the
continue statements, or break statements that break out of the outer case use
a macro NEXT_OPCODE instead. Replaced a few if statements with assertions.
(jsRegExpExecute): Use new/delete instead of pcre_malloc/free. Removed unused
start_match field from the match block.
* pcre/pcre_internal.h: Moved the last few configuration macros from pcre-config.h
in here. Removed various unused types. Converted from JSRegExpChar to UChar.
Eliminated pcre_malloc/free. Replaced the opcode enum with a macro that can be
used in multiple places. Unfortunately we lose the comments for each opcode; we
should find a place to put those back. Removed ctype_digit.
* pcre/pcre_maketables.cpp: Copied from JavaScriptCore/pcre/pcre_maketables.c.
(pcre_maketables): Got rid of the conditional code that allows this to be compiled
in -- it's only used for dftables now (and soon may be obsolete entirely).
Changed code for cbit_digit to not use isdigit, and took the "_" case out of the
loop. Removed ctype_digit.
* pcre/pcre_ord2utf8.cpp: Copied from JavaScriptCore/pcre/pcre_ord2utf8.c.
* pcre/pcre_tables.cpp: Copied from JavaScriptCore/pcre/pcre_tables.c.
Moved _pcre_OP_lengths out of here into pcre_exec.cpp.
* pcre/pcre_ucp_searchfuncs.cpp: Copied from JavaScriptCore/pcre/pcre_ucp_searchfuncs.c.
Updated for other file name changes.
* pcre/pcre_xclass.cpp: Copied from JavaScriptCore/pcre/pcre_xclass.c.
* pcre/ucpinternal.h: Updated header.
* pcre/ucptable.cpp: Copied from JavaScriptCore/pcre/ucptable.c.
* wtf/ASCIICType.h: (WTF::isASCIIDigit): Removed a branch by changing from && to
& for this operation. Also added an overload that takes an int because that's
useful for PCRE. Later we could optimize for int and overload other functions in
this file; stuck to this simple one for now.
* wtf/unicode/icu/UnicodeIcu.h: Removed unused isUpper.
* wtf/unicode/qt4/UnicodeQt4.h: Ditto.
* pcre/LICENCE: Removed.
* pcre/pcre-config.h: Removed.
* wtf/FastMallocPCRE.cpp: Removed.
* pcre/dftables.c: Renamed to cpp.
* pcre/pcre_compile.c: Ditto.
* pcre/pcre_exec.c: Ditto.
* pcre/pcre_maketables.c: Ditto.
* pcre/pcre_ord2utf8.c: Ditto.
* pcre/pcre_tables.c: Ditto.
* pcre/pcre_ucp_searchfuncs.c: Ditto.
* pcre/pcre_xclass.c: Ditto.
* pcre/ucptable.c: Ditto.
2007-11-11 Eric Seidel <eric@webkit.org>
Reviewed by Oliver.
......
......@@ -101,6 +101,9 @@ __NPN_RetainObject
__NPN_SetException
__NPN_SetProperty
__NPN_UTF8FromIdentifier
__Z12jsRegExpFreeP8JSRegExp
__Z15jsRegExpCompilePKti24JSRegExpIgnoreCaseOption23JSRegExpMultilineOptionPjPPKc
__Z15jsRegExpExecutePK8JSRegExpPKtiiPii
__Z23_NPN_CreateScriptObjectP4_NPPPN3KJS8JSObjectEN3WTF10PassRefPtrINS1_8Bindings10RootObjectEEES8_
__Z25_NPN_CreateNoScriptObjectv
__ZN3KJS10Identifier11addSlowCaseEPNS_7UString3RepE
......@@ -285,9 +288,6 @@ __ZTVN3KJS14StringInstanceE
__ZTVN3KJS15JSWrapperObjectE
__ZTVN3KJS19InternalFunctionImpE
__ZTVN3KJS8JSObjectE
_jsRegExpCompile
_jsRegExpExecute
_jsRegExpFree
_jscore_collector_introspection
_jscore_fastmalloc_introspection
_kJSClassDefinitionEmpty
......
......@@ -33,7 +33,6 @@ SOURCES += \
wtf/Assertions.cpp \
wtf/HashTable.cpp \
wtf/FastMalloc.cpp \
wtf/FastMallocPCRE.cpp \
bindings/NP_jsobject.cpp \
bindings/npruntime.cpp \
bindings/runtime_array.cpp \
......
......@@ -566,24 +566,16 @@
<Filter
Name="PCRE"
>
<File
RelativePath="..\..\wtf\FastMallocPCRE.cpp"
>
</File>
<File
RelativePath="..\..\pcre\pcre-config.h"
>
</File>
<File
RelativePath="..\..\pcre\pcre.h"
>
</File>
<File
RelativePath="..\..\pcre\pcre_compile.c"
RelativePath="..\..\pcre\pcre_compile.cpp"
>
</File>
<File
RelativePath="..\..\pcre\pcre_exec.c"
RelativePath="..\..\pcre\pcre_exec.cpp"
>
</File>
<File
......@@ -591,19 +583,19 @@
>
</File>
<File
RelativePath="..\..\pcre\pcre_ord2utf8.c"
RelativePath="..\..\pcre\pcre_ord2utf8.cpp"
>
</File>
<File
RelativePath="..\..\pcre\pcre_tables.c"
RelativePath="..\..\pcre\pcre_tables.cpp"
>
</File>
<File
RelativePath="..\..\pcre\pcre_ucp_searchfuncs.c"
RelativePath="..\..\pcre\pcre_ucp_searchfuncs.cpp"
>
</File>
<File
RelativePath="..\..\pcre\pcre_xclass.c"
RelativePath="..\..\pcre\pcre_xclass.cpp"
>
</File>
<File
......
......@@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../wtf"
AdditionalIncludeDirectories="../../wtf;../..;&quot;$(WebKitLibrariesDir)\include\&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
ExceptionHandling="0"
......
......@@ -30,7 +30,6 @@ Source files for JSCore.
-->
<makefile>
<set append="1" var="JSCORE_SOURCES_API">
API/JSBase.cpp
API/JSCallbackConstructor.cpp
API/JSCallbackFunction.cpp
......@@ -40,11 +39,9 @@ Source files for JSCore.
API/JSObjectRef.cpp
API/JSStringRef.cpp
API/JSValueRef.cpp
</set>
<set append="1" var="JSCORE_SOURCES_BINDINGS">
bindings/c/c_class.cpp
bindings/c/c_instance.cpp
bindings/c/c_runtime.cpp
......@@ -56,7 +53,6 @@ Source files for JSCore.
bindings/runtime_method.cpp
bindings/runtime_object.cpp
bindings/runtime_root.cpp
</set>
<set append="1" var="JSCORE_SOURCES_KJS">
......@@ -104,18 +100,17 @@ Source files for JSCore.
</set>
<set append="1" var="JSCORE_SOURCES_PCRE">
pcre/pcre_compile.c
pcre/pcre_exec.c
pcre/pcre_ord2utf8.c
pcre/pcre_tables.c
pcre/pcre_ucp_searchfuncs.c
pcre/pcre_xclass.c
pcre/pcre_compile.cpp
pcre/pcre_exec.cpp
pcre/pcre_ord2utf8.cpp
pcre/pcre_tables.cpp
pcre/pcre_ucp_searchfuncs.cpp
pcre/pcre_xclass.cpp
</set>
<set append="1" var="WTF_SOURCES">
wtf/Assertions.cpp
wtf/FastMalloc.cpp
wtf/FastMallocPCRE.cpp
wtf/HashTable.cpp
wtf/TCSystemAlloc.cpp
</set>
......
......@@ -106,7 +106,7 @@ JavaScriptCore Bakefile project file.
<exe id="dftables">
<dirname>$(SRCDIR)</dirname>
<include>$(SRCDIR)/wtf</include>
<sources>$(SRCDIR)/pcre/dftables.c</sources>
<sources>$(SRCDIR)/pcre/dftables.cpp</sources>
</exe>
<action id="DerivedSources">
......
......@@ -37,10 +37,8 @@ RegExp::RegExp(const UString& pattern)
, m_constructionError(0)
, m_numSubpatterns(0)
{
const char* errorMessage;
m_regExp = jsRegExpCompile(reinterpret_cast<const JSRegExpChar*>(m_pattern.data()), m_pattern.size(), 0, &m_numSubpatterns, &errorMessage);
if (!m_regExp)
m_constructionError = strdup(errorMessage);
m_regExp = jsRegExpCompile(reinterpret_cast<const ::UChar*>(m_pattern.data()), m_pattern.size(),
JSRegExpDoNotIgnoreCase, JSRegExpSingleLine, &m_numSubpatterns, &m_constructionError);
}
RegExp::RegExp(const UString& pattern, const UString& flags)
......@@ -55,28 +53,26 @@ RegExp::RegExp(const UString& pattern, const UString& flags)
if (flags.find('g') != -1)
m_flags |= Global;
// FIXME: Eliminate duplication by adding a way ask a JSRegExp what its flags are.
int options = 0;
// FIXME: Eliminate duplication by adding a way ask a JSRegExp what its flags are?
JSRegExpIgnoreCaseOption ignoreCaseOption = JSRegExpDoNotIgnoreCase;
if (flags.find('i') != -1) {
m_flags |= IgnoreCase;
options |= JS_REGEXP_CASELESS;
ignoreCaseOption = JSRegExpIgnoreCase;
}
JSRegExpMultilineOption multilineOption = JSRegExpSingleLine;
if (flags.find('m') != -1) {
m_flags |= Multiline;
options |= JS_REGEXP_MULTILINE;
multilineOption = JSRegExpMultiline;
}
const char* errorMessage;
m_regExp = jsRegExpCompile(reinterpret_cast<const JSRegExpChar*>(m_pattern.data()), m_pattern.size(), options, &m_numSubpatterns, &errorMessage);
if (!m_regExp)
m_constructionError = strdup(errorMessage);
m_regExp = jsRegExpCompile(reinterpret_cast<const ::UChar*>(m_pattern.data()), m_pattern.size(),
ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError);
}
RegExp::~RegExp()
{
jsRegExpFree(m_regExp);
free(m_constructionError);
jsRegExpFree(m_regExp);
}
int RegExp::match(const UString& s, int i, OwnArrayPtr<int>* ovector)
......@@ -106,11 +102,11 @@ int RegExp::match(const UString& s, int i, OwnArrayPtr<int>* ovector)
ovector->set(offsetVector);
}
int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const JSRegExpChar*>(s.data()), s.size(), i, offsetVector, offsetVectorSize);
int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const ::UChar*>(s.data()), s.size(), i, offsetVector, offsetVectorSize);
if (numMatches < 0) {
#ifndef NDEBUG
if (numMatches != JS_REGEXP_ERROR_NOMATCH)
if (numMatches != JSRegExpErrorNoMatch)
fprintf(stderr, "KJS: pcre_exec() failed with result %d\n", numMatches);
#endif
if (ovector)
......
......@@ -68,7 +68,7 @@ namespace KJS {
// Data supplied by PCRE.
JSRegExp* m_regExp;
char* m_constructionError;
const char* m_constructionError;
unsigned m_numSubpatterns;
};
......
THE MAIN PCRE LIBRARY
---------------------
Written by: Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
Originally written by: Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
University of Cambridge Computing Service,
Cambridge, England. Phone: +44 1223 334714.
Copyright (c) 1997-2005 University of Cambridge
All rights reserved
UTF-16 changes by Darin Adler and Geoff Garen
Copyright (c) 2005, 2006, 2007 Apple Inc.
All rights reserved
THE C++ WRAPPER LIBRARY
-----------------------
Written by: Google Inc.
Copyright (c) 1997-2005 University of Cambridge. All rights reserved.
Copyright (c) 2005 Google Inc
All rights reserved
Adapted for JavaScriptCore and WebKit by Apple Inc.
####
Copyright (c) 2005, 2006, 2007 Apple Inc. All rights reserved.
PCRE LICENCE
------------
PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Release 6 of PCRE is distributed under the terms of the "BSD" licence, as
specified below. The documentation for PCRE, supplied in the "doc"
directory, is distributed under the same terms as the software itself.
The basic library functions are written in C and are freestanding. Also
included in the distribution is a set of C++ wrapper functions.
THE BASIC LIBRARY FUNCTIONS
---------------------------
Written by: Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
University of Cambridge Computing Service,
Cambridge, England. Phone: +44 1223 334714.
Copyright (c) 1997-2005 University of Cambridge
All rights reserved.
This is JavaScriptCore's variant of the PCRE library. While this library
started out as a copy of PCRE, many of the features of PCRE have been
removed.
THE C++ WRAPPER FUNCTIONS
-------------------------
Contributed by: Google Inc.
Copyright (c) 2005, Google Inc.
All rights reserved.
THE "BSD" LICENCE
-----------------
Copyright (c) 1997-2005 University of Cambridge. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
......@@ -48,7 +17,7 @@ modification, are permitted provided that the following conditions are met:
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the name of Google
* Neither the name of the University of Cambridge nor the name of Apple
Inc. nor the names of their contributors may be used to endorse or
promote products derived from this software without specific prior
written permission.
......@@ -64,5 +33,3 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
End
PCRE LICENCE
------------
PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Release 6 of PCRE is distributed under the terms of the "BSD" licence, as
specified below. The documentation for PCRE, supplied in the "doc"
directory, is distributed under the same terms as the software itself.
The basic library functions are written in C and are freestanding. Also
included in the distribution is a set of C++ wrapper functions.
THE BASIC LIBRARY FUNCTIONS
---------------------------
Written by: Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
University of Cambridge Computing Service,
Cambridge, England. Phone: +44 1223 334714.
Copyright (c) 1997-2006 University of Cambridge
All rights reserved.
THE C++ WRAPPER FUNCTIONS
-------------------------
Contributed by: Google Inc.
Copyright (c) 2005, Google Inc.
All rights reserved.
THE "BSD" LICENCE
-----------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the name of Google
Inc. nor the names of their contributors may be used to endorse or
promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
End
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* This is JavaScriptCore's variant of the PCRE library. While this library
started out as a copy of PCRE, many of the features of PCRE have been
removed. This library now supports only the regular expression features
required by the JavaScript language specification, and has only the functions
needed by JavaScriptCore and the rest of WebKit.
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
......@@ -49,9 +49,7 @@ make use of its code from here in order to be consistent. */
#include "pcre_internal.h"
#define DFTABLES /* pcre_maketables.c notices this */
#include "pcre_maketables.c"
#include "pcre_maketables.cpp"
int main(int argc, char **argv)
{
......@@ -133,10 +131,9 @@ fprintf(f, ",\n\n");
fprintf(f,
"/* This table identifies various classes of character by individual bits:\n"
" 0x%02x white space character\n"
" 0x%02x decimal digit\n"
" 0x%02x hexadecimal digit\n"
" 0x%02x alphanumeric or '_'\n*/\n\n",
ctype_space, ctype_digit, ctype_xdigit, ctype_word);
ctype_space, ctype_xdigit, ctype_word);
fprintf(f, " ");
for (i = 0; i < 256; i++)
......@@ -165,5 +162,3 @@ fclose(f);
free((void *)base_of_tables);
return 0;
}
/* End of dftables.c */
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle qt
SOURCES = dftables.c
SOURCES = dftables.cpp
TARGET = dftables
DESTDIR = tmp
......@@ -12,4 +12,3 @@ gtk-port {
} else {
DEFINES += BUILDING_QT__
}
/* The value of LINK_SIZE determines the number of bytes used to store links as
offsets within the compiled regex. The default is 2, which allows for compiled
patterns up to 64K long. This covers the vast majority of cases. However, PCRE
can also be compiled to use 3 or 4 bytes instead. This allows for longer
patterns in extreme cases. On systems that support it, "configure" can be used
to override this default. */
#define LINK_SIZE 2
/* The value of MATCH_LIMIT determines the default number of times the internal
match() function can be called during a single execution of pcre_exec(). There
is a runtime interface for setting a different limit. The limit exists in order
to catch runaway regular expressions that take for ever to determine that they
do not match. The default is set very large so that it does not accidentally
catch legitimate cases. On systems that support it, "configure" can be used to
override this default default. */
#define MATCH_LIMIT 10000000
/* The above limit applies to all calls of match(), whether or not they
increase the recursion depth. In some environments it is desirable to limit the
depth of recursive calls of match() more strictly, in order to restrict the
maximum amount of stack (or heap, if NO_RECURSE is defined) that is used. The
value of MATCH_LIMIT_RECURSION applies only to recursive calls of match(). To
have any useful effect, it must be less than the value of MATCH_LIMIT. There is
a runtime method for setting a different limit. On systems that support it,
"configure" can be used to override this default default. */
#define MATCH_LIMIT_RECURSION MATCH_LIMIT
/* End */
/* This is the public header file for JavaScriptCore's variant of the PCRE
library. While this library started out as a copy of PCRE, many of the
features of PCRE have been removed. This library now supports only the
regular expression features required by the JavaScript language specification,
and has only the functions needed by JavaScriptCore and the rest of WebKit.
regular expression features required by the JavaScript language
specification, and has only the functions needed by JavaScriptCore and the
rest of WebKit.
Copyright (c) 1997-2005 University of Cambridge
Copyright (c) 2004, 2005, 2006, 2007 Apple Inc.
Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
......@@ -36,41 +37,33 @@ POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
// FIXME: Header needs to be renamed.
// FIXME: This file needs to be renamed to JSRegExp.h; it's no longer PCRE.
#ifndef PCRE_H
#define PCRE_H
#ifndef JSRegExp_h
#define JSRegExp_h
#ifdef __cplusplus
extern "C" {