summaryrefslogtreecommitdiffstats
path: root/third_party/re2
diff options
context:
space:
mode:
authorbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-24 10:39:59 +0000
committerbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-24 10:39:59 +0000
commit4728ca82099a214decd0e5c3b1b7fb2fa54ad7c8 (patch)
tree5bd88d7eb5d1bed7d90653d59e9039c903071a0d /third_party/re2
parentd3acbfadc21e5f5cb8fc98bedc725618e76ac072 (diff)
downloadchromium_src-4728ca82099a214decd0e5c3b1b7fb2fa54ad7c8.zip
chromium_src-4728ca82099a214decd0e5c3b1b7fb2fa54ad7c8.tar.gz
chromium_src-4728ca82099a214decd0e5c3b1b7fb2fa54ad7c8.tar.bz2
Migrate WebRequestRedirectByRegExAction to use RE2 and roll RE2 to revision 97:401ab4168e8e
This is a relanding of https://chromiumcodereview.appspot.com/10826120/ after RE2 has been fixed upstream to contain no static initializers. In contrast to https://chromiumcodereview.appspot.com/10873029/ is also removes some static initializers, see remove-static-initializers.patch. TBR=yoz@chromium.org BUG=112155 Review URL: https://chromiumcodereview.appspot.com/10875047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153185 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/re2')
-rw-r--r--third_party/re2/CONTRIBUTORS1
-rw-r--r--third_party/re2/README.chromium13
-rw-r--r--third_party/re2/patches/fix-implicit-conversion.patch2
-rw-r--r--third_party/re2/patches/re2-android.patch25
-rw-r--r--third_party/re2/patches/re2-msvc9-chrome.patch1140
-rw-r--r--third_party/re2/patches/remove-posix-option.patch24
-rw-r--r--third_party/re2/patches/remove-static-initializers.patch95
-rw-r--r--third_party/re2/patches/remove-valgrind-code.patch21
-rw-r--r--third_party/re2/patches/rename-posix-option.patch28
-rw-r--r--third_party/re2/re2/compile.cc16
-rw-r--r--third_party/re2/re2/dfa.cc94
-rw-r--r--third_party/re2/re2/parse.cc16
-rw-r--r--third_party/re2/re2/prefilter.cc66
-rw-r--r--third_party/re2/re2/re2.cc99
-rw-r--r--third_party/re2/re2/re2.h97
-rw-r--r--third_party/re2/re2/regexp.cc45
-rw-r--r--third_party/re2/re2/regexp.h3
-rw-r--r--third_party/re2/re2/testing/filtered_re2_test.cc17
-rw-r--r--third_party/re2/re2/testing/parse_test.cc75
-rw-r--r--third_party/re2/re2/testing/re2_arg_test.cc15
-rw-r--r--third_party/re2/re2/testing/re2_test.cc18
-rw-r--r--third_party/re2/re2/testing/set_test.cc12
-rw-r--r--third_party/re2/re2/variadic_function.h2
-rw-r--r--third_party/re2/util/logging.h13
-rw-r--r--third_party/re2/util/mutex.h23
-rw-r--r--third_party/re2/util/sparse_array.h8
-rw-r--r--third_party/re2/util/sparse_set.h10
-rw-r--r--third_party/re2/util/util.h2
-rw-r--r--third_party/re2/util/valgrind.cc10
-rw-r--r--third_party/re2/util/valgrind.h1
30 files changed, 747 insertions, 1244 deletions
diff --git a/third_party/re2/CONTRIBUTORS b/third_party/re2/CONTRIBUTORS
index 0b70807..15053eb5 100644
--- a/third_party/re2/CONTRIBUTORS
+++ b/third_party/re2/CONTRIBUTORS
@@ -27,6 +27,7 @@
# Please keep the list sorted.
Brian Gunlogson <unixman83@gmail.com>
+Dominic Battré <battre@chromium.org>
Rob Pike <r@google.com>
Russ Cox <rsc@swtch.com>
Sanjay Ghemawat <sanjay@google.com>
diff --git a/third_party/re2/README.chromium b/third_party/re2/README.chromium
index 1e315e1..ac5da6d 100644
--- a/third_party/re2/README.chromium
+++ b/third_party/re2/README.chromium
@@ -1,9 +1,9 @@
Name: re2 - an efficient, principled regular expression library
Short Name: re2
URL: http://code.google.com/p/re2/
-Version: 83:c79416ca4228
+Version: 401ab4168e8e
Date: 2012-06-20
-Revision: 83:c79416ca4228
+Revision: 97:401ab4168e8e
License: BSD 3-Clause License
License File: LICENSE
Security Critical: yes
@@ -13,13 +13,14 @@ RE2 is a fast, safe, thread-friendly alternative to backtracking regular
expression engines like those used in PCRE, Perl, and Python.
Local Modifications (to be applied in this order):
-- Dropped POSIX configuration (patches/remove-posix-option.patch)
-- Support for Windows (patches/re2-msvc9-chrome.patch)
+- Rename POSIX configuration (patches/rename-posix-option.patch)
- Remove valgrind specific code that exists in chromium already
(patches/remove-valgrind-code.patch)
- Fix an implicit conversion from NULL to false
(patches/fix-implicit-conversion.patch)
-- Support Android (re2-android.patch)
+- Support for Windows (patches/re2-msvc9-chrome.patch)
+- Support Android (patches/re2-android.patch)
- Remove testinstall.cc because it lacks a license header and remove executable
bit from non-executable .py file.
- (remove-testinstall.cc-and-fix-filepermissions.patch)
+ (patches/remove-testinstall.cc-and-fix-filepermissions.patch)
+- Remove static initializers (patches/remove-static-initializers.patch)
diff --git a/third_party/re2/patches/fix-implicit-conversion.patch b/third_party/re2/patches/fix-implicit-conversion.patch
index ab6c2f0..bc68f11 100644
--- a/third_party/re2/patches/fix-implicit-conversion.patch
+++ b/third_party/re2/patches/fix-implicit-conversion.patch
@@ -1,7 +1,7 @@
diff -r e12d4aa8907f re2/dfa.cc
--- a/re2/dfa.cc Wed Jul 25 15:13:19 2012 +0200
+++ b/re2/dfa.cc Wed Jul 25 15:13:47 2012 +0200
-@@ -1736,7 +1736,7 @@
+@@ -1778,7 +1780,7 @@
return false;
}
if (params.start == DeadState)
diff --git a/third_party/re2/patches/re2-android.patch b/third_party/re2/patches/re2-android.patch
index a622035..bcaea8d 100644
--- a/third_party/re2/patches/re2-android.patch
+++ b/third_party/re2/patches/re2-android.patch
@@ -1,6 +1,7 @@
-diff -r cae1910ce3c5 re2/parse.cc
---- a/re2/parse.cc Mon Jul 30 16:12:46 2012 +0200
-+++ b/re2/parse.cc Tue Jul 31 14:12:31 2012 +0200
+diff --git a/third_party/re2/re2/parse.cc b/third_party/re2/re2/parse.cc
+index 0cf4ab4..6423fe9 100644
+--- a/third_party/re2/re2/parse.cc
++++ b/third_party/re2/re2/parse.cc
@@ -16,6 +16,8 @@
// and recognizes the Perl escape sequences \d, \s, \w, \D, \S, and \W.
// See regexp.h for rationale.
@@ -10,9 +11,10 @@ diff -r cae1910ce3c5 re2/parse.cc
#include "util/util.h"
#include "re2/regexp.h"
#include "re2/stringpiece.h"
-diff -r cae1910ce3c5 re2/re2.cc
---- a/re2/re2.cc Mon Jul 30 16:12:46 2012 +0200
-+++ b/re2/re2.cc Tue Jul 31 14:12:31 2012 +0200
+diff --git a/third_party/re2/re2/re2.cc b/third_party/re2/re2/re2.cc
+index 989add6..78978f1 100644
+--- a/third_party/re2/re2/re2.cc
++++ b/third_party/re2/re2/re2.cc
@@ -9,6 +9,8 @@
#include "re2/re2.h"
@@ -22,9 +24,10 @@ diff -r cae1910ce3c5 re2/re2.cc
#include <stdio.h>
#include <string>
#ifdef WIN32
-diff -r cae1910ce3c5 util/util.h
---- a/util/util.h Mon Jul 30 16:12:46 2012 +0200
-+++ b/util/util.h Tue Jul 31 14:12:31 2012 +0200
+diff --git a/third_party/re2/util/util.h b/third_party/re2/util/util.h
+index dab7e16..11b5f4a 100644
+--- a/third_party/re2/util/util.h
++++ b/third_party/re2/util/util.h
@@ -28,6 +28,7 @@
#include <utility>
#include <set>
@@ -33,7 +36,7 @@ diff -r cae1910ce3c5 util/util.h
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
// Use std names.
-@@ -44,7 +45,7 @@
+@@ -44,7 +45,7 @@ using std::sort;
using std::swap;
using std::make_pair;
@@ -42,7 +45,7 @@ diff -r cae1910ce3c5 util/util.h
#include <tr1/unordered_set>
using std::tr1::unordered_set;
-@@ -52,7 +53,7 @@
+@@ -52,7 +53,7 @@ using std::tr1::unordered_set;
#else
#include <unordered_set>
diff --git a/third_party/re2/patches/re2-msvc9-chrome.patch b/third_party/re2/patches/re2-msvc9-chrome.patch
index 2d9ed28..17da0cd 100644
--- a/third_party/re2/patches/re2-msvc9-chrome.patch
+++ b/third_party/re2/patches/re2-msvc9-chrome.patch
@@ -1,6 +1,7 @@
-diff -r c79416ca4228 AUTHORS
---- a/AUTHORS Tue May 29 11:50:48 2012 -0400
-+++ b/AUTHORS Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/AUTHORS b/third_party/re2/AUTHORS
+index 3c0f928..e17d9bf 100644
+--- a/third_party/re2/AUTHORS
++++ b/third_party/re2/AUTHORS
@@ -8,5 +8,6 @@
# Please keep the list sorted.
@@ -8,20 +9,23 @@ diff -r c79416ca4228 AUTHORS
+Brian Gunlogson <unixman83@gmail.com>
Google Inc.
Stefano Rivera <stefano.rivera@gmail.com>
-diff -r c79416ca4228 CONTRIBUTORS
---- a/CONTRIBUTORS Tue May 29 11:50:48 2012 -0400
-+++ b/CONTRIBUTORS Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/CONTRIBUTORS b/third_party/re2/CONTRIBUTORS
+index ac64332..15053eb 100644
+--- a/third_party/re2/CONTRIBUTORS
++++ b/third_party/re2/CONTRIBUTORS
@@ -26,6 +26,7 @@
# Please keep the list sorted.
+Brian Gunlogson <unixman83@gmail.com>
+ Dominic Battré <battre@chromium.org>
Rob Pike <r@google.com>
Russ Cox <rsc@swtch.com>
- Sanjay Ghemawat <sanjay@google.com>
-diff -r c79416ca4228 mswin/stdint.h
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mswin/stdint.h Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/mswin/stdint.h b/third_party/re2/mswin/stdint.h
+new file mode 100644
+index 0000000..d02608a
+--- /dev/null
++++ b/third_party/re2/mswin/stdint.h
@@ -0,0 +1,247 @@
+// ISO C9x compliant stdint.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
@@ -270,383 +274,11 @@ diff -r c79416ca4228 mswin/stdint.h
+
+
+#endif // _MSC_STDINT_H_ ]
-diff -r c79416ca4228 re2.sln
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/re2.sln Wed Jun 20 19:00:08 2012 +0200
-@@ -0,0 +1,38 @@
-+
-+Microsoft Visual Studio Solution File, Format Version 10.00
-+# Visual Studio 2008
-+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "re2", "re2.vcproj", "{494BD4B2-1ADD-4053-981D-BA14D6DF9219}"
-+ ProjectSection(ProjectDependencies) = postProject
-+ {AB36233A-643A-4D2E-93B3-0602DA52C8D5} = {AB36233A-643A-4D2E-93B3-0602DA52C8D5}
-+ EndProjectSection
-+EndProject
-+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "re2_testing", "re2_testing\re2_testing.vcproj", "{1B9A5974-DA06-4F57-BFFC-4DE19B968AE8}"
-+ ProjectSection(ProjectDependencies) = postProject
-+ {494BD4B2-1ADD-4053-981D-BA14D6DF9219} = {494BD4B2-1ADD-4053-981D-BA14D6DF9219}
-+ EndProjectSection
-+EndProject
-+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util", "util\util.vcproj", "{AB36233A-643A-4D2E-93B3-0602DA52C8D5}"
-+EndProject
-+Global
-+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
-+ Debug|Win32 = Debug|Win32
-+ Release|Win32 = Release|Win32
-+ EndGlobalSection
-+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
-+ {494BD4B2-1ADD-4053-981D-BA14D6DF9219}.Debug|Win32.ActiveCfg = Debug|Win32
-+ {494BD4B2-1ADD-4053-981D-BA14D6DF9219}.Debug|Win32.Build.0 = Debug|Win32
-+ {494BD4B2-1ADD-4053-981D-BA14D6DF9219}.Release|Win32.ActiveCfg = Release|Win32
-+ {494BD4B2-1ADD-4053-981D-BA14D6DF9219}.Release|Win32.Build.0 = Release|Win32
-+ {1B9A5974-DA06-4F57-BFFC-4DE19B968AE8}.Debug|Win32.ActiveCfg = Debug|Win32
-+ {1B9A5974-DA06-4F57-BFFC-4DE19B968AE8}.Debug|Win32.Build.0 = Debug|Win32
-+ {1B9A5974-DA06-4F57-BFFC-4DE19B968AE8}.Release|Win32.ActiveCfg = Release|Win32
-+ {1B9A5974-DA06-4F57-BFFC-4DE19B968AE8}.Release|Win32.Build.0 = Release|Win32
-+ {AB36233A-643A-4D2E-93B3-0602DA52C8D5}.Debug|Win32.ActiveCfg = Debug|Win32
-+ {AB36233A-643A-4D2E-93B3-0602DA52C8D5}.Debug|Win32.Build.0 = Debug|Win32
-+ {AB36233A-643A-4D2E-93B3-0602DA52C8D5}.Release|Win32.ActiveCfg = Release|Win32
-+ {AB36233A-643A-4D2E-93B3-0602DA52C8D5}.Release|Win32.Build.0 = Release|Win32
-+ EndGlobalSection
-+ GlobalSection(SolutionProperties) = preSolution
-+ HideSolutionNode = FALSE
-+ EndGlobalSection
-+EndGlobal
-diff -r c79416ca4228 re2.vcproj
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/re2.vcproj Wed Jun 20 19:00:08 2012 +0200
-@@ -0,0 +1,327 @@
-+<?xml version="1.0" encoding="Windows-1252"?>
-+<VisualStudioProject
-+ ProjectType="Visual C++"
-+ Version="9.00"
-+ Name="re2"
-+ ProjectGUID="{494BD4B2-1ADD-4053-981D-BA14D6DF9219}"
-+ RootNamespace="re2"
-+ Keyword="Win32Proj"
-+ TargetFrameworkVersion="196613"
-+ >
-+ <Platforms>
-+ <Platform
-+ Name="Win32"
-+ />
-+ </Platforms>
-+ <ToolFiles>
-+ </ToolFiles>
-+ <Configurations>
-+ <Configuration
-+ Name="Debug|Win32"
-+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-+ IntermediateDirectory="$(ConfigurationName)"
-+ ConfigurationType="4"
-+ CharacterSet="1"
-+ >
-+ <Tool
-+ Name="VCPreBuildEventTool"
-+ />
-+ <Tool
-+ Name="VCCustomBuildTool"
-+ />
-+ <Tool
-+ Name="VCXMLDataGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCWebServiceProxyGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCMIDLTool"
-+ />
-+ <Tool
-+ Name="VCCLCompilerTool"
-+ Optimization="0"
-+ AdditionalIncludeDirectories=".;.\mswin"
-+ PreprocessorDefinitions="WIN32;NOMINMAX;DEBUG;_WINDOWS;_UNICODE;NOPCH;WIN32_LEAN_AND_MEAN"
-+ MinimalRebuild="true"
-+ BasicRuntimeChecks="3"
-+ RuntimeLibrary="3"
-+ UsePrecompiledHeader="0"
-+ WarningLevel="3"
-+ DebugInformationFormat="4"
-+ />
-+ <Tool
-+ Name="VCManagedResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCPreLinkEventTool"
-+ />
-+ <Tool
-+ Name="VCLibrarianTool"
-+ AdditionalDependencies="$(TargetDir)\util.lib"
-+ />
-+ <Tool
-+ Name="VCALinkTool"
-+ />
-+ <Tool
-+ Name="VCXDCMakeTool"
-+ />
-+ <Tool
-+ Name="VCBscMakeTool"
-+ />
-+ <Tool
-+ Name="VCFxCopTool"
-+ />
-+ <Tool
-+ Name="VCPostBuildEventTool"
-+ />
-+ </Configuration>
-+ <Configuration
-+ Name="Release|Win32"
-+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-+ IntermediateDirectory="$(ConfigurationName)"
-+ ConfigurationType="4"
-+ CharacterSet="1"
-+ WholeProgramOptimization="1"
-+ >
-+ <Tool
-+ Name="VCPreBuildEventTool"
-+ />
-+ <Tool
-+ Name="VCCustomBuildTool"
-+ />
-+ <Tool
-+ Name="VCXMLDataGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCWebServiceProxyGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCMIDLTool"
-+ />
-+ <Tool
-+ Name="VCCLCompilerTool"
-+ Optimization="2"
-+ EnableIntrinsicFunctions="true"
-+ AdditionalIncludeDirectories=".;.\mswin"
-+ PreprocessorDefinitions="WIN32;NOMINMAX;NDEBUG;_WINDOWS;_UNICODE;NOPCH;WIN32_LEAN_AND_MEAN"
-+ StringPooling="true"
-+ RuntimeLibrary="2"
-+ EnableFunctionLevelLinking="true"
-+ UsePrecompiledHeader="0"
-+ WarningLevel="3"
-+ DebugInformationFormat="3"
-+ />
-+ <Tool
-+ Name="VCManagedResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCPreLinkEventTool"
-+ />
-+ <Tool
-+ Name="VCLibrarianTool"
-+ />
-+ <Tool
-+ Name="VCALinkTool"
-+ />
-+ <Tool
-+ Name="VCXDCMakeTool"
-+ />
-+ <Tool
-+ Name="VCBscMakeTool"
-+ />
-+ <Tool
-+ Name="VCFxCopTool"
-+ />
-+ <Tool
-+ Name="VCPostBuildEventTool"
-+ />
-+ </Configuration>
-+ </Configurations>
-+ <References>
-+ </References>
-+ <Files>
-+ <Filter
-+ Name="Source Files"
-+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-+ >
-+ <File
-+ RelativePath=".\re2\bitstate.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\compile.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\dfa.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\filtered_re2.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\mimics_pcre.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\nfa.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\onepass.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\parse.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\perl_groups.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\prefilter.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\prefilter_tree.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\prog.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\re2.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\regexp.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\util\rune.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\set.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\simplify.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\util\strutil.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\tostring.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\unicode_casefold.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\unicode_groups.cc"
-+ >
-+ </File>
-+ </Filter>
-+ <Filter
-+ Name="Header Files"
-+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
-+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-+ >
-+ <File
-+ RelativePath=".\re2\filtered_re2.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\util\logging.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\util\mutex.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\prefilter.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\prefilter_tree.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\prog.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\util\random.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\re2.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\regexp.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\set.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\stdint.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\unicode_casefold.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\unicode_groups.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\util\utf.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\util\util.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\variadic_function.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\re2\walker-inl.h"
-+ >
-+ </File>
-+ </Filter>
-+ <Filter
-+ Name="Resource Files"
-+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
-+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-+ >
-+ </Filter>
-+ <File
-+ RelativePath=".\ClassDiagram1.cd"
-+ >
-+ </File>
-+ </Files>
-+ <Globals>
-+ </Globals>
-+</VisualStudioProject>
-diff -r c79416ca4228 re2/compile.cc
---- a/re2/compile.cc Tue May 29 11:50:48 2012 -0400
-+++ b/re2/compile.cc Wed Jun 20 19:00:08 2012 +0200
-@@ -501,7 +501,7 @@
+diff --git a/third_party/re2/re2/compile.cc b/third_party/re2/re2/compile.cc
+index 9cddb71..adb45fd 100644
+--- a/third_party/re2/re2/compile.cc
++++ b/third_party/re2/re2/compile.cc
+@@ -502,7 +502,7 @@ int Compiler::RuneByteSuffix(uint8 lo, uint8 hi, bool foldcase, int next) {
return UncachedRuneByteSuffix(lo, hi, foldcase, next);
}
@@ -655,9 +287,10 @@ diff -r c79416ca4228 re2/compile.cc
map<uint64, int>::iterator it = rune_cache_.find(key);
if (it != rune_cache_.end())
return it->second;
-diff -r c79416ca4228 re2/prefilter_tree.cc
---- a/re2/prefilter_tree.cc Tue May 29 11:50:48 2012 -0400
-+++ b/re2/prefilter_tree.cc Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/re2/prefilter_tree.cc b/third_party/re2/re2/prefilter_tree.cc
+index d8bc37a..cdcf77e 100644
+--- a/third_party/re2/re2/prefilter_tree.cc
++++ b/third_party/re2/re2/prefilter_tree.cc
@@ -8,6 +8,11 @@
#include "re2/prefilter_tree.h"
#include "re2/re2.h"
@@ -670,9 +303,10 @@ diff -r c79416ca4228 re2/prefilter_tree.cc
DEFINE_int32(filtered_re2_min_atom_len,
3,
"Strings less than this length are not stored as atoms");
-diff -r c79416ca4228 re2/re2.cc
---- a/re2/re2.cc Tue May 29 11:50:48 2012 -0400
-+++ b/re2/re2.cc Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/re2/re2.cc b/third_party/re2/re2/re2.cc
+index 3cc3dd4..989add6 100644
+--- a/third_party/re2/re2/re2.cc
++++ b/third_party/re2/re2/re2.cc
@@ -11,7 +11,13 @@
#include <stdio.h>
@@ -687,40 +321,73 @@ diff -r c79416ca4228 re2/re2.cc
#include <errno.h>
#include "util/util.h"
#include "util/flags.h"
-@@ -31,8 +37,6 @@
+@@ -31,10 +37,22 @@ const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::Par
const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::ConsumeN> RE2::Consume;
const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::FindAndConsumeN> RE2::FindAndConsume;
+-// This will trigger LNK2005 error in MSVC.
+-#ifndef COMPILER_MSVC
-const int RE2::Options::kDefaultMaxMem; // initialized in re2.h
--
- // Commonly-used option sets; arguments to constructor are:
- // utf8 input
- // posix syntax
-diff -r c79416ca4228 re2/re2.h
---- a/re2/re2.h Tue May 29 11:50:48 2012 -0400
-+++ b/re2/re2.h Wed Jun 20 19:00:08 2012 +0200
-@@ -5,6 +5,8 @@
- #ifndef RE2_RE2_H
- #define RE2_RE2_H
-
+-#endif // COMPILER_MSVC
+#define kDefaultMaxMem (8<<20)
+
- // C++ interface to the re2 regular-expression library.
- // RE2 supports Perl-style regular expressions (with extensions like
- // \d, \w, \s, ...).
-@@ -517,9 +519,6 @@
- // Once a DFA fills its budget, it flushes its cache and starts over.
++RE2::Options::Options()
++ : encoding_(EncodingUTF8),
++ posix_syntax_(false),
++ longest_match_(false),
++ log_errors_(true),
++ max_mem_(kDefaultMaxMem),
++ literal_(false),
++ never_nl_(false),
++ never_capture_(false),
++ case_sensitive_(true),
++ perl_classes_(false),
++ word_boundary_(false),
++ one_line_(false) {
++}
+
+ RE2::Options::Options(RE2::CannedOptions opt)
+ : encoding_(opt == RE2::Latin1 ? EncodingLatin1 : EncodingUTF8),
+diff --git a/third_party/re2/re2/re2.h b/third_party/re2/re2/re2.h
+index 9f5b66d..98b06b8 100644
+--- a/third_party/re2/re2/re2.h
++++ b/third_party/re2/re2/re2.h
+@@ -552,28 +552,16 @@ class RE2 {
// If this happens too often, RE2 falls back on the NFA implementation.
-- // For now, make the default budget something close to Code Search.
-- static const int kDefaultMaxMem = 8<<20;
--
+ // For now, make the default budget something close to Code Search.
++#ifndef WIN32
+ static const int kDefaultMaxMem = 8<<20;
++#endif
+
enum Encoding {
EncodingUTF8 = 1,
EncodingLatin1
-diff -r c79416ca4228 re2/stringpiece.h
---- a/re2/stringpiece.h Tue May 29 11:50:48 2012 -0400
-+++ b/re2/stringpiece.h Wed Jun 20 19:00:08 2012 +0200
+ };
+
+- Options() :
+- encoding_(EncodingUTF8),
+- posix_syntax_(false),
+- longest_match_(false),
+- log_errors_(true),
+- max_mem_(kDefaultMaxMem),
+- literal_(false),
+- never_nl_(false),
+- never_capture_(false),
+- case_sensitive_(true),
+- perl_classes_(false),
+- word_boundary_(false),
+- one_line_(false) {
+- }
+-
++ Options();
+ /*implicit*/ Options(CannedOptions);
+
+ Encoding encoding() const { return encoding_; }
+diff --git a/third_party/re2/re2/stringpiece.h b/third_party/re2/re2/stringpiece.h
+index ab9297c..38a5150 100644
+--- a/third_party/re2/re2/stringpiece.h
++++ b/third_party/re2/re2/stringpiece.h
@@ -23,6 +23,9 @@
#include <cstddef>
#include <iosfwd>
@@ -731,9 +398,10 @@ diff -r c79416ca4228 re2/stringpiece.h
namespace re2 {
-diff -r c79416ca4228 re2/testing/re2_test.cc
---- a/re2/testing/re2_test.cc Tue May 29 11:50:48 2012 -0400
-+++ b/re2/testing/re2_test.cc Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/re2/testing/re2_test.cc b/third_party/re2/re2/testing/re2_test.cc
+index b99cacf..911e868 100644
+--- a/third_party/re2/re2/testing/re2_test.cc
++++ b/third_party/re2/re2/testing/re2_test.cc
@@ -6,7 +6,9 @@
// TODO: Test extractions for PartialMatch/Consume
@@ -756,7 +424,7 @@ diff -r c79416ca4228 re2/testing/re2_test.cc
DECLARE_bool(logtostderr);
namespace re2 {
-@@ -657,6 +664,7 @@
+@@ -657,6 +664,7 @@ TEST(RE2, FullMatchTypedNullArg) {
CHECK(!RE2::FullMatch("hello", "(.*)", (float*)NULL));
}
@@ -764,7 +432,7 @@ diff -r c79416ca4228 re2/testing/re2_test.cc
// Check that numeric parsing code does not read past the end of
// the number being parsed.
TEST(RE2, NULTerminated) {
-@@ -678,6 +686,7 @@
+@@ -678,6 +686,7 @@ TEST(RE2, NULTerminated) {
CHECK(RE2::FullMatch(StringPiece(v + pagesize - 1, 1), "(.*)", &x));
CHECK_EQ(x, 1);
}
@@ -772,311 +440,10 @@ diff -r c79416ca4228 re2/testing/re2_test.cc
TEST(RE2, FullMatchTypeTests) {
// Type tests
-diff -r c79416ca4228 re2_testing/re2_testing.vcproj
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/re2_testing/re2_testing.vcproj Wed Jun 20 19:00:08 2012 +0200
-@@ -0,0 +1,298 @@
-+<?xml version="1.0" encoding="Windows-1252"?>
-+<VisualStudioProject
-+ ProjectType="Visual C++"
-+ Version="9.00"
-+ Name="re2_testing"
-+ ProjectGUID="{1B9A5974-DA06-4F57-BFFC-4DE19B968AE8}"
-+ RootNamespace="re2_testing"
-+ TargetFrameworkVersion="196613"
-+ >
-+ <Platforms>
-+ <Platform
-+ Name="Win32"
-+ />
-+ </Platforms>
-+ <ToolFiles>
-+ </ToolFiles>
-+ <Configurations>
-+ <Configuration
-+ Name="Debug|Win32"
-+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-+ IntermediateDirectory="$(ConfigurationName)"
-+ ConfigurationType="1"
-+ CharacterSet="2"
-+ >
-+ <Tool
-+ Name="VCPreBuildEventTool"
-+ />
-+ <Tool
-+ Name="VCCustomBuildTool"
-+ />
-+ <Tool
-+ Name="VCXMLDataGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCWebServiceProxyGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCMIDLTool"
-+ />
-+ <Tool
-+ Name="VCCLCompilerTool"
-+ Optimization="0"
-+ AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;..\mswin"
-+ PreprocessorDefinitions="WIN32;NOMINMAX;DEBUG;_WINDOWS;_UNICODE;NOPCH;WIN32_LEAN_AND_MEAN;NOGDI"
-+ MinimalRebuild="true"
-+ BasicRuntimeChecks="3"
-+ RuntimeLibrary="3"
-+ WarningLevel="3"
-+ DebugInformationFormat="4"
-+ />
-+ <Tool
-+ Name="VCManagedResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCPreLinkEventTool"
-+ />
-+ <Tool
-+ Name="VCLinkerTool"
-+ AdditionalDependencies="$(TargetDir)/re2.lib"
-+ GenerateDebugInformation="true"
-+ TargetMachine="1"
-+ />
-+ <Tool
-+ Name="VCALinkTool"
-+ />
-+ <Tool
-+ Name="VCManifestTool"
-+ />
-+ <Tool
-+ Name="VCXDCMakeTool"
-+ />
-+ <Tool
-+ Name="VCBscMakeTool"
-+ />
-+ <Tool
-+ Name="VCFxCopTool"
-+ />
-+ <Tool
-+ Name="VCAppVerifierTool"
-+ />
-+ <Tool
-+ Name="VCPostBuildEventTool"
-+ />
-+ </Configuration>
-+ <Configuration
-+ Name="Release|Win32"
-+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-+ IntermediateDirectory="$(ConfigurationName)"
-+ ConfigurationType="1"
-+ CharacterSet="2"
-+ WholeProgramOptimization="1"
-+ >
-+ <Tool
-+ Name="VCPreBuildEventTool"
-+ />
-+ <Tool
-+ Name="VCCustomBuildTool"
-+ />
-+ <Tool
-+ Name="VCXMLDataGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCWebServiceProxyGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCMIDLTool"
-+ />
-+ <Tool
-+ Name="VCCLCompilerTool"
-+ Optimization="2"
-+ EnableIntrinsicFunctions="true"
-+ AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;..\mswin"
-+ PreprocessorDefinitions="WIN32;NOMINMAX;DEBUG;_WINDOWS;_UNICODE;NOPCH;WIN32_LEAN_AND_MEAN;NOGDI"
-+ RuntimeLibrary="2"
-+ EnableFunctionLevelLinking="true"
-+ WarningLevel="3"
-+ DebugInformationFormat="3"
-+ />
-+ <Tool
-+ Name="VCManagedResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCPreLinkEventTool"
-+ />
-+ <Tool
-+ Name="VCLinkerTool"
-+ AdditionalDependencies="$(TargetDir)/re2.lib"
-+ GenerateDebugInformation="true"
-+ OptimizeReferences="2"
-+ EnableCOMDATFolding="2"
-+ TargetMachine="1"
-+ />
-+ <Tool
-+ Name="VCALinkTool"
-+ />
-+ <Tool
-+ Name="VCManifestTool"
-+ />
-+ <Tool
-+ Name="VCXDCMakeTool"
-+ />
-+ <Tool
-+ Name="VCBscMakeTool"
-+ />
-+ <Tool
-+ Name="VCFxCopTool"
-+ />
-+ <Tool
-+ Name="VCAppVerifierTool"
-+ />
-+ <Tool
-+ Name="VCPostBuildEventTool"
-+ />
-+ </Configuration>
-+ </Configurations>
-+ <References>
-+ </References>
-+ <Files>
-+ <Filter
-+ Name="Source Files"
-+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-+ >
-+ <File
-+ RelativePath="..\re2\testing\backtrack.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\charclass_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\compile_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\dump.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\exhaustive_tester.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\filtered_re2_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\mimics_pcre_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\null_walker.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\parse_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\possible_match_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\util\random.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\re2_arg_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\re2_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\regexp_generator.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\regexp_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\required_prefix_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\search_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\set_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\simplify_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\string_generator.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\string_generator_test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\util\test.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\tester.cc"
-+ >
-+ </File>
-+ </Filter>
-+ <Filter
-+ Name="Header Files"
-+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
-+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-+ >
-+ <File
-+ RelativePath="..\re2\testing\exhaustive_tester.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\regexp_generator.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\string_generator.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\util\test.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath="..\re2\testing\tester.h"
-+ >
-+ </File>
-+ </Filter>
-+ <Filter
-+ Name="Resource Files"
-+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
-+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-+ >
-+ </Filter>
-+ </Files>
-+ <Globals>
-+ </Globals>
-+</VisualStudioProject>
-diff -r c79416ca4228 util/logging.h
---- a/util/logging.h Tue May 29 11:50:48 2012 -0400
-+++ b/util/logging.h Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/util/logging.h b/third_party/re2/util/logging.h
+index 734e7a1..7302ea6 100644
+--- a/third_party/re2/util/logging.h
++++ b/third_party/re2/util/logging.h
@@ -7,8 +7,13 @@
#ifndef RE2_UTIL_LOGGING_H__
#define RE2_UTIL_LOGGING_H__
@@ -1091,9 +458,10 @@ diff -r c79416ca4228 util/logging.h
// Debug-only checking.
#define DCHECK(condition) assert(condition)
-diff -r c79416ca4228 util/mutex.h
---- a/util/mutex.h Tue May 29 11:50:48 2012 -0400
-+++ b/util/mutex.h Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/util/mutex.h b/third_party/re2/util/mutex.h
+index 9787bfb..e321fae 100644
+--- a/third_party/re2/util/mutex.h
++++ b/third_party/re2/util/mutex.h
@@ -12,8 +12,10 @@
namespace re2 {
@@ -1105,7 +473,7 @@ diff -r c79416ca4228 util/mutex.h
#if defined(NO_THREADS)
typedef int MutexType; // to keep a lock-count
-@@ -32,7 +34,9 @@
+@@ -32,7 +34,9 @@ namespace re2 {
# include <pthread.h>
typedef pthread_mutex_t MutexType;
#elif defined(WIN32)
@@ -1116,9 +484,10 @@ diff -r c79416ca4228 util/mutex.h
# ifdef GMUTEX_TRYLOCK
// We need Windows NT or later for TryEnterCriticalSection(). If you
// don't need that functionality, you can remove these _WIN32_WINNT
-diff -r c79416ca4228 util/pcre.cc
---- a/util/pcre.cc Tue May 29 11:50:48 2012 -0400
-+++ b/util/pcre.cc Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/util/pcre.cc b/third_party/re2/util/pcre.cc
+index 5e67e1f..1602133 100644
+--- a/third_party/re2/util/pcre.cc
++++ b/third_party/re2/util/pcre.cc
@@ -11,6 +11,11 @@
#include "util/flags.h"
#include "util/pcre.h"
@@ -1131,10 +500,11 @@ diff -r c79416ca4228 util/pcre.cc
#define PCREPORT(level) LOG(level)
// Default PCRE limits.
-diff -r c79416ca4228 util/pcre.h
---- a/util/pcre.h Tue May 29 11:50:48 2012 -0400
-+++ b/util/pcre.h Wed Jun 20 19:00:08 2012 +0200
-@@ -180,9 +180,15 @@
+diff --git a/third_party/re2/util/pcre.h b/third_party/re2/util/pcre.h
+index 4dda95d..771ac91 100644
+--- a/third_party/re2/util/pcre.h
++++ b/third_party/re2/util/pcre.h
+@@ -180,9 +180,15 @@ struct pcre_extra { int flags, match_limit, match_limit_recursion; };
#define PCRE_ERROR_MATCHLIMIT 2
#define PCRE_ERROR_RECURSIONLIMIT 3
#define PCRE_INFO_CAPTURECOUNT 0
@@ -1150,9 +520,10 @@ diff -r c79416ca4228 util/pcre.h
} // namespace re2
#endif
-diff -r c79416ca4228 util/stringprintf.cc
---- a/util/stringprintf.cc Tue May 29 11:50:48 2012 -0400
-+++ b/util/stringprintf.cc Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/util/stringprintf.cc b/third_party/re2/util/stringprintf.cc
+index c908181..d4691d1 100644
+--- a/third_party/re2/util/stringprintf.cc
++++ b/third_party/re2/util/stringprintf.cc
@@ -4,6 +4,10 @@
#include "util/util.h"
@@ -1164,9 +535,10 @@ diff -r c79416ca4228 util/stringprintf.cc
namespace re2 {
static void StringAppendV(string* dst, const char* format, va_list ap) {
-diff -r c79416ca4228 util/test.cc
---- a/util/test.cc Tue May 29 11:50:48 2012 -0400
-+++ b/util/test.cc Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/util/test.cc b/third_party/re2/util/test.cc
+index 0644829..2fe1bfa 100644
+--- a/third_party/re2/util/test.cc
++++ b/third_party/re2/util/test.cc
@@ -3,7 +3,9 @@
// license that can be found in the LICENSE file.
@@ -1177,7 +549,7 @@ diff -r c79416ca4228 util/test.cc
#include "util/test.h"
DEFINE_string(test_tmpdir, "/var/tmp", "temp directory");
-@@ -23,9 +25,13 @@
+@@ -23,9 +25,13 @@ void RegisterTest(void (*fn)(void), const char *name) {
namespace re2 {
int64 VirtualProcessSize() {
@@ -1191,9 +563,10 @@ diff -r c79416ca4228 util/test.cc
}
} // namespace re2
-diff -r c79416ca4228 util/util.h
---- a/util/util.h Tue May 29 11:50:48 2012 -0400
-+++ b/util/util.h Wed Jun 20 19:00:08 2012 +0200
+diff --git a/third_party/re2/util/util.h b/third_party/re2/util/util.h
+index 63a9c6f..dab7e16 100644
+--- a/third_party/re2/util/util.h
++++ b/third_party/re2/util/util.h
@@ -12,7 +12,9 @@
#include <stddef.h> // For size_t
#include <assert.h>
@@ -1204,7 +577,7 @@ diff -r c79416ca4228 util/util.h
#include <time.h>
// C++
-@@ -48,7 +50,11 @@
+@@ -50,7 +52,11 @@ using std::tr1::unordered_set;
#else
#include <unordered_set>
@@ -1216,276 +589,19 @@ diff -r c79416ca4228 util/util.h
#endif
-diff -r c79416ca4228 util/util.vcproj
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/util/util.vcproj Wed Jun 20 19:00:08 2012 +0200
-@@ -0,0 +1,253 @@
-+<?xml version="1.0" encoding="Windows-1252"?>
-+<VisualStudioProject
-+ ProjectType="Visual C++"
-+ Version="9.00"
-+ Name="util"
-+ ProjectGUID="{AB36233A-643A-4D2E-93B3-0602DA52C8D5}"
-+ RootNamespace="util"
-+ Keyword="Win32Proj"
-+ TargetFrameworkVersion="196613"
-+ >
-+ <Platforms>
-+ <Platform
-+ Name="Win32"
-+ />
-+ </Platforms>
-+ <ToolFiles>
-+ </ToolFiles>
-+ <Configurations>
-+ <Configuration
-+ Name="Debug|Win32"
-+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-+ IntermediateDirectory="$(ConfigurationName)"
-+ ConfigurationType="4"
-+ CharacterSet="1"
-+ >
-+ <Tool
-+ Name="VCPreBuildEventTool"
-+ />
-+ <Tool
-+ Name="VCCustomBuildTool"
-+ />
-+ <Tool
-+ Name="VCXMLDataGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCWebServiceProxyGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCMIDLTool"
-+ />
-+ <Tool
-+ Name="VCCLCompilerTool"
-+ Optimization="0"
-+ AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;..\mswin"
-+ PreprocessorDefinitions="WIN32;NOMINMAX;DEBUG;_WINDOWS;_UNICODE;NOPCH;WIN32_LEAN_AND_MEAN;NOGDI"
-+ MinimalRebuild="true"
-+ BasicRuntimeChecks="3"
-+ RuntimeLibrary="3"
-+ UsePrecompiledHeader="0"
-+ WarningLevel="3"
-+ DebugInformationFormat="4"
-+ />
-+ <Tool
-+ Name="VCManagedResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCPreLinkEventTool"
-+ />
-+ <Tool
-+ Name="VCLibrarianTool"
-+ />
-+ <Tool
-+ Name="VCALinkTool"
-+ />
-+ <Tool
-+ Name="VCXDCMakeTool"
-+ />
-+ <Tool
-+ Name="VCBscMakeTool"
-+ />
-+ <Tool
-+ Name="VCFxCopTool"
-+ />
-+ <Tool
-+ Name="VCPostBuildEventTool"
-+ />
-+ </Configuration>
-+ <Configuration
-+ Name="Release|Win32"
-+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-+ IntermediateDirectory="$(ConfigurationName)"
-+ ConfigurationType="4"
-+ CharacterSet="1"
-+ WholeProgramOptimization="1"
-+ >
-+ <Tool
-+ Name="VCPreBuildEventTool"
-+ />
-+ <Tool
-+ Name="VCCustomBuildTool"
-+ />
-+ <Tool
-+ Name="VCXMLDataGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCWebServiceProxyGeneratorTool"
-+ />
-+ <Tool
-+ Name="VCMIDLTool"
-+ />
-+ <Tool
-+ Name="VCCLCompilerTool"
-+ Optimization="2"
-+ EnableIntrinsicFunctions="true"
-+ AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;..\mswin"
-+ PreprocessorDefinitions="WIN32;NOMINMAX;DEBUG;_WINDOWS;_UNICODE;NOPCH;WIN32_LEAN_AND_MEAN;NOGDI"
-+ RuntimeLibrary="2"
-+ EnableFunctionLevelLinking="true"
-+ UsePrecompiledHeader="0"
-+ WarningLevel="3"
-+ DebugInformationFormat="3"
-+ />
-+ <Tool
-+ Name="VCManagedResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCResourceCompilerTool"
-+ />
-+ <Tool
-+ Name="VCPreLinkEventTool"
-+ />
-+ <Tool
-+ Name="VCLibrarianTool"
-+ />
-+ <Tool
-+ Name="VCALinkTool"
-+ />
-+ <Tool
-+ Name="VCXDCMakeTool"
-+ />
-+ <Tool
-+ Name="VCBscMakeTool"
-+ />
-+ <Tool
-+ Name="VCFxCopTool"
-+ />
-+ <Tool
-+ Name="VCPostBuildEventTool"
-+ />
-+ </Configuration>
-+ </Configurations>
-+ <References>
-+ </References>
-+ <Files>
-+ <Filter
-+ Name="Source Files"
-+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-+ >
-+ <File
-+ RelativePath=".\arena.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\hash.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\pcre.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\random.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\rune.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\stringpiece.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\stringprintf.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\strutil.cc"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\valgrind.cc"
-+ >
-+ </File>
-+ </Filter>
-+ <Filter
-+ Name="Header Files"
-+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
-+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-+ >
-+ <File
-+ RelativePath=".\arena.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\atomicops.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\benchmark.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\flags.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\logging.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\pcre.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\random.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\sparse_array.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\sparse_set.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\utf.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\util.h"
-+ >
-+ </File>
-+ <File
-+ RelativePath=".\valgrind.h"
-+ >
-+ </File>
-+ </Filter>
-+ <Filter
-+ Name="Resource Files"
-+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
-+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-+ >
-+ </Filter>
-+ </Files>
-+ <Globals>
-+ </Globals>
-+</VisualStudioProject>
-diff -r c79416ca4228 util/valgrind.h
---- a/util/valgrind.h Tue May 29 11:50:48 2012 -0400
-+++ b/util/valgrind.h Wed Jun 20 19:00:08 2012 +0200
-@@ -4063,7 +4063,7 @@
-
+diff --git a/third_party/re2/util/valgrind.h b/third_party/re2/util/valgrind.h
+index ca10b1a..d097b0c 100644
+--- a/third_party/re2/util/valgrind.h
++++ b/third_party/re2/util/valgrind.h
+@@ -4064,6 +4064,7 @@ typedef
#endif /* PLAT_ppc64_aix5 */
--
+
+#ifndef WIN32
/* ------------------------------------------------------------------ */
/* ARCHITECTURE INDEPENDENT MACROS for CLIENT REQUESTS. */
/* */
-@@ -4170,7 +4170,7 @@
+@@ -4170,7 +4171,7 @@ typedef
VG_USERREQ__DISCARD_TRANSLATIONS, \
_qzz_addr, _qzz_len, 0, 0, 0); \
}
diff --git a/third_party/re2/patches/remove-posix-option.patch b/third_party/re2/patches/remove-posix-option.patch
deleted file mode 100644
index ba55172..0000000
--- a/third_party/re2/patches/remove-posix-option.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff -r 2d252384c5e8 re2/re2.cc
---- a/re2/re2.cc Mon Mar 05 14:20:36 2012 -0500
-+++ b/re2/re2.cc Wed Jun 20 20:32:24 2012 +0200
-@@ -40,7 +40,7 @@
- // log errors
- const RE2::Options RE2::DefaultOptions; // EncodingUTF8, false, false, true
- const RE2::Options RE2::Latin1(RE2::Options::EncodingLatin1, false, false, true);
--const RE2::Options RE2::POSIX(RE2::Options::EncodingUTF8, true, true, true);
-+//const RE2::Options RE2::POSIX(RE2::Options::EncodingUTF8, true, true, true);
- const RE2::Options RE2::Quiet(RE2::Options::EncodingUTF8, false, false, false);
-
- // If a regular expression has no error, its error_ field points here
-diff -r 2d252384c5e8 re2/re2.h
---- a/re2/re2.h Mon Mar 05 14:20:36 2012 -0500
-+++ b/re2/re2.h Wed Jun 20 20:32:24 2012 +0200
-@@ -233,7 +233,7 @@
- // RE2 constructor.
- static const Options DefaultOptions;
- static const Options Latin1; // treat input as Latin-1 (default UTF-8)
-- static const Options POSIX; // POSIX syntax, leftmost-longest match
-+ //static const Options POSIX; // POSIX syntax, leftmost-longest match
- static const Options Quiet; // do not log about regexp parse errors
-
- // Need to have the const char* and const string& forms for implicit
diff --git a/third_party/re2/patches/remove-static-initializers.patch b/third_party/re2/patches/remove-static-initializers.patch
new file mode 100644
index 0000000..73df64c
--- /dev/null
+++ b/third_party/re2/patches/remove-static-initializers.patch
@@ -0,0 +1,95 @@
+diff --git a/third_party/re2/re2/compile.cc b/third_party/re2/re2/compile.cc
+index adb45fd..14e401a 100644
+--- a/third_party/re2/re2/compile.cc
++++ b/third_party/re2/re2/compile.cc
+@@ -44,7 +44,7 @@ struct PatchList {
+ static PatchList Append(Prog::Inst *inst0, PatchList l1, PatchList l2);
+ };
+
+-static PatchList nullPatchList;
++static PatchList nullPatchList = { 0 };
+
+ // Returns patch list containing just p.
+ PatchList PatchList::Mk(uint32 p) {
+@@ -106,12 +106,13 @@ struct Frag {
+ uint32 begin;
+ PatchList end;
+
+- explicit Frag(LinkerInitialized) {}
+ Frag() : begin(0) { end.p = 0; } // needed so Frag can go in vector
+ Frag(uint32 begin, PatchList end) : begin(begin), end(end) {}
+ };
+
+-static Frag kNullFrag(LINKER_INITIALIZED);
++static Frag NullFrag() {
++ return Frag();
++}
+
+ // Input encodings.
+ enum Encoding {
+@@ -684,13 +685,13 @@ Frag Compiler::PreVisit(Regexp* re, Frag, bool* stop) {
+ if (failed_)
+ *stop = true;
+
+- return kNullFrag; // not used by caller
++ return NullFrag(); // not used by caller
+ }
+
+ Frag Compiler::Literal(Rune r, bool foldcase) {
+ switch (encoding_) {
+ default:
+- return kNullFrag;
++ return NullFrag();
+
+ case kEncodingLatin1:
+ return ByteRange(r, r, foldcase);
+@@ -1006,7 +1007,7 @@ Prog* Compiler::Compile(Regexp* re, bool reversed, int64 max_mem) {
+ bool is_anchor_end = IsAnchorEnd(&sre, 0);
+
+ // Generate fragment for entire regexp.
+- Frag f = c.WalkExponential(sre, kNullFrag, 2*c.max_inst_);
++ Frag f = c.WalkExponential(sre, NullFrag(), 2*c.max_inst_);
+ sre->Decref();
+ if (c.failed_)
+ return NULL;
+@@ -1097,7 +1098,7 @@ Prog* Compiler::CompileSet(const RE2::Options& options, RE2::Anchor anchor,
+ c.Setup(pf, options.max_mem(), anchor);
+
+ // Compile alternation of fragments.
+- Frag all = c.WalkExponential(re, kNullFrag, 2*c.max_inst_);
++ Frag all = c.WalkExponential(re, NullFrag(), 2*c.max_inst_);
+ re->Decref();
+ if (c.failed_)
+ return NULL;
+diff --git a/third_party/re2/re2/re2.cc b/third_party/re2/re2/re2.cc
+index 78978f1..61b88e7 100644
+--- a/third_party/re2/re2/re2.cc
++++ b/third_party/re2/re2/re2.cc
+@@ -34,10 +34,10 @@ namespace re2 {
+ static const int kMaxArgs = 16;
+ static const int kVecSize = 1+kMaxArgs;
+
+-const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::FullMatchN> RE2::FullMatch;
+-const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::PartialMatchN> RE2::PartialMatch;
+-const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::ConsumeN> RE2::Consume;
+-const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::FindAndConsumeN> RE2::FindAndConsume;
++const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::FullMatchN> RE2::FullMatch = {};
++const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::PartialMatchN> RE2::PartialMatch = {};
++const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::ConsumeN> RE2::Consume = {};
++const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::FindAndConsumeN> RE2::FindAndConsume = {};
+
+ #define kDefaultMaxMem (8<<20)
+
+diff --git a/third_party/re2/re2/variadic_function.h b/third_party/re2/re2/variadic_function.h
+index 8d2b763..7c7d6d5 100644
+--- a/third_party/re2/re2/variadic_function.h
++++ b/third_party/re2/re2/variadic_function.h
+@@ -11,8 +11,6 @@ template <typename Result, typename Param0, typename Param1, typename Arg,
+ Result (*Func)(Param0, Param1, const Arg* const [], int count)>
+ class VariadicFunction2 {
+ public:
+- VariadicFunction2() {}
+-
+ Result operator()(Param0 p0, Param1 p1) const {
+ return Func(p0, p1, 0, 0);
+ }
diff --git a/third_party/re2/patches/remove-valgrind-code.patch b/third_party/re2/patches/remove-valgrind-code.patch
index 20fea48..1d8884a 100644
--- a/third_party/re2/patches/remove-valgrind-code.patch
+++ b/third_party/re2/patches/remove-valgrind-code.patch
@@ -1,6 +1,7 @@
-diff -r ceab86d470c1 re2/dfa.cc
---- a/re2/dfa.cc Tue Jul 03 16:43:11 2012 +0200
-+++ b/re2/dfa.cc Tue Jul 03 17:03:00 2012 +0200
+diff --git a/third_party/re2/re2/dfa.cc b/third_party/re2/re2/dfa.cc
+index 3a6a387..32c8c33 100644
+--- a/third_party/re2/re2/dfa.cc
++++ b/third_party/re2/re2/dfa.cc
@@ -27,6 +27,8 @@
#include "util/flags.h"
#include "util/sparse_set.h"
@@ -10,10 +11,11 @@ diff -r ceab86d470c1 re2/dfa.cc
DEFINE_bool(re2_dfa_bail_when_slow, true,
"Whether the RE2 DFA should bail out early "
"if the NFA would be faster (for testing).");
-diff -r ceab86d470c1 util/util.h
---- a/util/util.h Tue Jul 03 16:43:11 2012 +0200
-+++ b/util/util.h Tue Jul 03 17:03:00 2012 +0200
-@@ -28,6 +28,8 @@
+diff --git a/third_party/re2/util/util.h b/third_party/re2/util/util.h
+index a43ff76..63a9c6f 100644
+--- a/third_party/re2/util/util.h
++++ b/third_party/re2/util/util.h
+@@ -26,6 +26,8 @@
#include <utility>
#include <set>
@@ -22,7 +24,7 @@ diff -r ceab86d470c1 util/util.h
// Use std names.
using std::set;
using std::pair;
-@@ -86,16 +88,6 @@
+@@ -80,17 +82,6 @@ template<bool> struct CompileAssert {};
#define arraysize(array) (sizeof(array)/sizeof((array)[0]))
@@ -35,11 +37,12 @@ diff -r ceab86d470c1 util/util.h
-#define NO_THREAD_SAFETY_ANALYSIS
-#define ANNOTATE_HAPPENS_BEFORE(x)
-#define ANNOTATE_HAPPENS_AFTER(x)
+-#define ANNOTATE_UNPROTECTED_READ(x) (x)
-
class StringPiece;
string CEscape(const StringPiece& src);
-@@ -121,8 +113,6 @@
+@@ -116,8 +107,6 @@ static inline uint64 Hash64StringWithSeed(const char* s, int len, uint32 seed) {
return ((uint64)x << 32) | y;
}
diff --git a/third_party/re2/patches/rename-posix-option.patch b/third_party/re2/patches/rename-posix-option.patch
new file mode 100644
index 0000000..5c8a8e7
--- /dev/null
+++ b/third_party/re2/patches/rename-posix-option.patch
@@ -0,0 +1,28 @@
+diff --git a/third_party/re2/re2/re2.cc b/third_party/re2/re2/re2.cc
+index 6acd802..3cc3dd4 100644
+--- a/third_party/re2/re2/re2.cc
++++ b/third_party/re2/re2/re2.cc
+@@ -38,8 +38,8 @@ const int RE2::Options::kDefaultMaxMem; // initialized in re2.h
+
+ RE2::Options::Options(RE2::CannedOptions opt)
+ : encoding_(opt == RE2::Latin1 ? EncodingLatin1 : EncodingUTF8),
+- posix_syntax_(opt == RE2::POSIX),
+- longest_match_(opt == RE2::POSIX),
++ posix_syntax_(opt == RE2::POSIX_SYNTAX),
++ longest_match_(opt == RE2::POSIX_SYNTAX),
+ log_errors_(opt != RE2::Quiet),
+ max_mem_(kDefaultMaxMem),
+ literal_(false),
+diff --git a/third_party/re2/re2/re2.h b/third_party/re2/re2/re2.h
+index 272028b..9f5b66d 100644
+--- a/third_party/re2/re2/re2.h
++++ b/third_party/re2/re2/re2.h
+@@ -251,7 +251,7 @@ class RE2 {
+ enum CannedOptions {
+ DefaultOptions = 0,
+ Latin1, // treat input as Latin-1 (default UTF-8)
+- POSIX, // POSIX syntax, leftmost-longest match
++ POSIX_SYNTAX, // POSIX syntax, leftmost-longest match
+ Quiet // do not log about regexp parse errors
+ };
+
diff --git a/third_party/re2/re2/compile.cc b/third_party/re2/re2/compile.cc
index 0c96d33..14e401a 100644
--- a/third_party/re2/re2/compile.cc
+++ b/third_party/re2/re2/compile.cc
@@ -110,7 +110,9 @@ struct Frag {
Frag(uint32 begin, PatchList end) : begin(begin), end(end) {}
};
-static Frag kNullFrag;
+static Frag NullFrag() {
+ return Frag();
+}
// Input encodings.
enum Encoding {
@@ -588,7 +590,7 @@ static struct ByteRangeProg {
};
void Compiler::Add_80_10ffff() {
- int inst[arraysize(prog_80_10ffff)];
+ int inst[arraysize(prog_80_10ffff)] = { 0 }; // does not need to be initialized; silences gcc warning
for (int i = 0; i < arraysize(prog_80_10ffff); i++) {
const ByteRangeProg& p = prog_80_10ffff[i];
int next = 0;
@@ -683,13 +685,13 @@ Frag Compiler::PreVisit(Regexp* re, Frag, bool* stop) {
if (failed_)
*stop = true;
- return kNullFrag; // not used by caller
+ return NullFrag(); // not used by caller
}
Frag Compiler::Literal(Rune r, bool foldcase) {
switch (encoding_) {
default:
- return kNullFrag;
+ return NullFrag();
case kEncodingLatin1:
return ByteRange(r, r, foldcase);
@@ -732,7 +734,7 @@ Frag Compiler::PostVisit(Regexp* re, Frag, Frag, Frag* child_frags,
Frag f = Match(re->match_id());
// Remember unanchored match to end of string.
if (anchor_ != RE2::ANCHOR_BOTH)
- f = Cat(DotStar(), f);
+ f = Cat(DotStar(), Cat(EmptyWidth(kEmptyEndText), f));
return f;
}
@@ -1005,7 +1007,7 @@ Prog* Compiler::Compile(Regexp* re, bool reversed, int64 max_mem) {
bool is_anchor_end = IsAnchorEnd(&sre, 0);
// Generate fragment for entire regexp.
- Frag f = c.WalkExponential(sre, kNullFrag, 2*c.max_inst_);
+ Frag f = c.WalkExponential(sre, NullFrag(), 2*c.max_inst_);
sre->Decref();
if (c.failed_)
return NULL;
@@ -1096,7 +1098,7 @@ Prog* Compiler::CompileSet(const RE2::Options& options, RE2::Anchor anchor,
c.Setup(pf, options.max_mem(), anchor);
// Compile alternation of fragments.
- Frag all = c.WalkExponential(re, kNullFrag, 2*c.max_inst_);
+ Frag all = c.WalkExponential(re, NullFrag(), 2*c.max_inst_);
re->Decref();
if (c.failed_)
return NULL;
diff --git a/third_party/re2/re2/dfa.cc b/third_party/re2/re2/dfa.cc
index 344ef41..32c8c33 100644
--- a/third_party/re2/re2/dfa.cc
+++ b/third_party/re2/re2/dfa.cc
@@ -117,6 +117,7 @@ class DFA {
kFlagNeedShift = 16, // needed kEmpty bits are or'ed in shifted left
};
+#ifndef STL_MSVC
// STL function structures for use with unordered_set.
struct StateEqual {
bool operator()(const State* a, const State* b) const {
@@ -134,6 +135,7 @@ class DFA {
return true; // they're equal
}
};
+#endif // STL_MSVC
struct StateHash {
size_t operator()(const State* a) const {
if (a == NULL)
@@ -145,9 +147,34 @@ class DFA {
else
return Hash64StringWithSeed(s, len, a->flag_);
}
+#ifdef STL_MSVC
+ // Less than operator.
+ bool operator()(const State* a, const State* b) const {
+ if (a == b)
+ return false;
+ if (a == NULL || b == NULL)
+ return a == NULL;
+ if (a->ninst_ != b->ninst_)
+ return a->ninst_ < b->ninst_;
+ if (a->flag_ != b->flag_)
+ return a->flag_ < b->flag_;
+ for (int i = 0; i < a->ninst_; ++i)
+ if (a->inst_[i] != b->inst_[i])
+ return a->inst_[i] < b->inst_[i];
+ return false; // they're equal
+ }
+ // The two public members are required by msvc. 4 and 8 are default values.
+ // Reference: http://msdn.microsoft.com/en-us/library/1s1byw77.aspx
+ static const size_t bucket_size = 4;
+ static const size_t min_buckets = 8;
+#endif // STL_MSVC
};
+#ifdef STL_MSVC
+ typedef unordered_set<State*, StateHash> StateSet;
+#else // !STL_MSVC
typedef unordered_set<State*, StateHash, StateEqual> StateSet;
+#endif // STL_MSVC
private:
@@ -964,8 +991,10 @@ DFA::State* DFA::RunStateOnByte(State* state, int c) {
// If someone else already computed this, return it.
MaybeReadMemoryBarrier(); // On alpha we need to ensure read ordering
- if (state->next_[ByteMap(c)])
- return state->next_[ByteMap(c)];
+ State* ns = state->next_[ByteMap(c)];
+ ANNOTATE_HAPPENS_AFTER(ns);
+ if (ns != NULL)
+ return ns;
// Convert state into Workq.
StateToWorkq(state, q0_);
@@ -1008,7 +1037,17 @@ DFA::State* DFA::RunStateOnByte(State* state, int c) {
}
bool ismatch = false;
RunWorkqOnByte(q0_, q1_, c, afterflag, &ismatch, kind_, start_unanchored_);
- swap(q0_, q1_);
+
+ // Most of the time, we build the state from the output of
+ // RunWorkqOnByte, so swap q0_ and q1_ here. However, so that
+ // RE2::Set can tell exactly which match instructions
+ // contributed to the match, don't swap if c is kByteEndText.
+ // The resulting state wouldn't be correct for further processing
+ // of the string, but we're at the end of the text so that's okay.
+ // Leaving q0_ alone preseves the match instructions that led to
+ // the current setting of ismatch.
+ if (c != kByteEndText || kind_ != Prog::kManyMatch)
+ swap(q0_, q1_);
// Save afterflag along with ismatch and isword in new state.
uint flag = afterflag;
@@ -1017,7 +1056,7 @@ DFA::State* DFA::RunStateOnByte(State* state, int c) {
if (isword)
flag |= kFlagLastWord;
- State* ns = WorkqToCachedState(q0_, flag);
+ ns = WorkqToCachedState(q0_, flag);
// Write barrier before updating state->next_ so that the
// main search loop can proceed without any locking, for speed.
@@ -1026,9 +1065,9 @@ DFA::State* DFA::RunStateOnByte(State* state, int c) {
// a) the access to next_ should be ignored,
// b) 'ns' is properly published.
WriteMemoryBarrier(); // Flush ns before linking to it.
- ANNOTATE_PUBLISH_MEMORY_RANGE(ns, sizeof(*ns));
ANNOTATE_IGNORE_WRITES_BEGIN();
+ ANNOTATE_HAPPENS_BEFORE(ns);
state->next_[ByteMap(c)] = ns;
ANNOTATE_IGNORE_WRITES_END();
return ns;
@@ -1353,6 +1392,7 @@ inline bool DFA::InlinedSearchLoop(SearchParams* params,
MaybeReadMemoryBarrier(); // On alpha we need to ensure read ordering
State* ns = s->next_[bytemap[c]];
+ ANNOTATE_HAPPENS_AFTER(ns);
if (ns == NULL) {
ns = RunStateOnByteUnlocked(s, c);
if (ns == NULL) {
@@ -1424,20 +1464,6 @@ inline bool DFA::InlinedSearchLoop(SearchParams* params,
}
}
- // Peek in state to see if a match is coming up.
- if (params->matches && kind_ == Prog::kManyMatch) {
- vector<int>* v = params->matches;
- v->clear();
- if (s > SpecialStateMax) {
- for (int i = 0; i < s->ninst_; i++) {
- Prog::Inst* ip = prog_->inst(s->inst_[i]);
- if (ip->opcode() == kInstMatch)
- v->push_back(ip->match_id());
- }
- }
- }
-
-
// Process one more byte to see if it triggers a match.
// (Remember, matches are delayed one byte.)
int lastbyte;
@@ -1455,6 +1481,7 @@ inline bool DFA::InlinedSearchLoop(SearchParams* params,
MaybeReadMemoryBarrier(); // On alpha we need to ensure read ordering
State* ns = s->next_[ByteMap(lastbyte)];
+ ANNOTATE_HAPPENS_AFTER(ns);
if (ns == NULL) {
ns = RunStateOnByteUnlocked(s, lastbyte);
if (ns == NULL) {
@@ -1482,6 +1509,15 @@ inline bool DFA::InlinedSearchLoop(SearchParams* params,
if (s > SpecialStateMax && s->IsMatch()) {
matched = true;
lastmatch = p;
+ if (params->matches && kind_ == Prog::kManyMatch) {
+ vector<int>* v = params->matches;
+ v->clear();
+ for (int i = 0; i < s->ninst_; i++) {
+ Prog::Inst* ip = prog_->inst(s->inst_[i]);
+ if (ip->opcode() == kInstMatch)
+ v->push_back(ip->match_id());
+ }
+ }
if (DebugDFA)
fprintf(stderr, "match @%d! [%s]\n", static_cast<int>(lastmatch - bp),
DumpState(s).c_str());
@@ -1639,7 +1675,7 @@ bool DFA::AnalyzeSearch(SearchParams* params) {
DumpState(info->start).c_str(), info->firstbyte);
params->start = info->start;
- params->firstbyte = info->firstbyte;
+ params->firstbyte = ANNOTATE_UNPROTECTED_READ(info->firstbyte);
return true;
}
@@ -1648,12 +1684,16 @@ bool DFA::AnalyzeSearch(SearchParams* params) {
bool DFA::AnalyzeSearchHelper(SearchParams* params, StartInfo* info,
uint flags) {
// Quick check; okay because of memory barriers below.
- if (info->firstbyte != kFbUnknown)
+ if (ANNOTATE_UNPROTECTED_READ(info->firstbyte) != kFbUnknown) {
+ ANNOTATE_HAPPENS_AFTER(&info->firstbyte);
return true;
+ }
MutexLock l(&mutex_);
- if (info->firstbyte != kFbUnknown)
+ if (info->firstbyte != kFbUnknown) {
+ ANNOTATE_HAPPENS_AFTER(&info->firstbyte);
return true;
+ }
q0_->clear();
AddToQueue(q0_,
@@ -1664,12 +1704,14 @@ bool DFA::AnalyzeSearchHelper(SearchParams* params, StartInfo* info,
return false;
if (info->start == DeadState) {
+ ANNOTATE_HAPPENS_BEFORE(&info->firstbyte);
WriteMemoryBarrier(); // Synchronize with "quick check" above.
info->firstbyte = kFbNone;
return true;
}
if (info->start == FullMatchState) {
+ ANNOTATE_HAPPENS_BEFORE(&info->firstbyte);
WriteMemoryBarrier(); // Synchronize with "quick check" above.
info->firstbyte = kFbNone; // will be ignored
return true;
@@ -1682,6 +1724,7 @@ bool DFA::AnalyzeSearchHelper(SearchParams* params, StartInfo* info,
for (int i = 0; i < 256; i++) {
State* s = RunStateOnByte(info->start, i);
if (s == NULL) {
+ ANNOTATE_HAPPENS_BEFORE(&info->firstbyte);
WriteMemoryBarrier(); // Synchronize with "quick check" above.
info->firstbyte = firstbyte;
return false;
@@ -1696,6 +1739,7 @@ bool DFA::AnalyzeSearchHelper(SearchParams* params, StartInfo* info,
break;
}
}
+ ANNOTATE_HAPPENS_BEFORE(&info->firstbyte);
WriteMemoryBarrier(); // Synchronize with "quick check" above.
info->firstbyte = firstbyte;
return true;
@@ -1778,7 +1822,7 @@ DFA* Prog::GetDFA(MatchKind kind) {
}
// Quick check; okay because of memory barrier below.
- DFA *dfa = *pdfa;
+ DFA *dfa = ANNOTATE_UNPROTECTED_READ(*pdfa);
if (dfa != NULL) {
ANNOTATE_HAPPENS_AFTER(dfa);
return dfa;
@@ -1786,8 +1830,10 @@ DFA* Prog::GetDFA(MatchKind kind) {
MutexLock l(&dfa_mutex_);
dfa = *pdfa;
- if (dfa != NULL)
+ if (dfa != NULL) {
+ ANNOTATE_HAPPENS_AFTER(dfa);
return dfa;
+ }
// For a forward DFA, half the memory goes to each DFA.
// For a reverse DFA, all the memory goes to the
diff --git a/third_party/re2/re2/parse.cc b/third_party/re2/re2/parse.cc
index 551555a..6423fe9 100644
--- a/third_party/re2/re2/parse.cc
+++ b/third_party/re2/re2/parse.cc
@@ -1455,6 +1455,13 @@ static void AddUGroup(CharClassBuilder *cc, UGroup *g, int sign,
// to what's already missing. Too hard, so do in two steps.
CharClassBuilder ccb1;
AddUGroup(&ccb1, g, +1, parse_flags);
+ // If the flags say to take out \n, put it in, so that negating will take it out.
+ // Normally AddRangeFlags does this, but we're bypassing AddRangeFlags.
+ bool cutnl = !(parse_flags & Regexp::ClassNL) ||
+ (parse_flags & Regexp::NeverNL);
+ if (cutnl) {
+ ccb1.AddRange('\n', '\n');
+ }
ccb1.Negate();
cc->AddCharClass(&ccb1);
return;
@@ -1997,8 +2004,13 @@ Regexp* Regexp::Parse(const StringPiece& s, ParseFlags global_flags,
return NULL;
break;
}
- if (!ps.DoLeftParen(NULL))
- return NULL;
+ if (ps.flags() & NeverCapture) {
+ if (!ps.DoLeftParenNoCapture())
+ return NULL;
+ } else {
+ if (!ps.DoLeftParen(NULL))
+ return NULL;
+ }
t.remove_prefix(1); // '('
break;
diff --git a/third_party/re2/re2/prefilter.cc b/third_party/re2/re2/prefilter.cc
index 30e4c01..4b9c35d 100644
--- a/third_party/re2/re2/prefilter.cc
+++ b/third_party/re2/re2/prefilter.cc
@@ -181,6 +181,12 @@ static Rune ToLowerRune(Rune r) {
return ApplyFold(f, r);
}
+static Rune ToLowerRuneLatin1(Rune r) {
+ if ('A' <= r && r <= 'Z')
+ r += 'a' - 'A';
+ return r;
+}
+
Prefilter* Prefilter::FromString(const string& str) {
Prefilter* m = new Prefilter(Prefilter::ATOM);
m->atom_ = str;
@@ -205,8 +211,9 @@ class Prefilter::Info {
static Info* EmptyString();
static Info* NoMatch();
static Info* AnyChar();
- static Info* CClass(CharClass* cc);
+ static Info* CClass(CharClass* cc, bool latin1);
static Info* Literal(Rune r);
+ static Info* LiteralLatin1(Rune r);
static Info* AnyMatch();
// Format Info as a string.
@@ -390,6 +397,11 @@ static string RuneToString(Rune r) {
return string(buf, n);
}
+static string RuneToStringLatin1(Rune r) {
+ char c = r & 0xff;
+ return string(&c, 1);
+}
+
// Constructs Info for literal rune.
Prefilter::Info* Prefilter::Info::Literal(Rune r) {
Info* info = new Info();
@@ -398,6 +410,14 @@ Prefilter::Info* Prefilter::Info::Literal(Rune r) {
return info;
}
+// Constructs Info for literal rune for Latin1 encoded string.
+Prefilter::Info* Prefilter::Info::LiteralLatin1(Rune r) {
+ Info* info = new Info();
+ info->exact_.insert(RuneToStringLatin1(ToLowerRuneLatin1(r)));
+ info->is_exact_ = true;
+ return info;
+}
+
// Constructs Info for dot (any character).
Prefilter::Info* Prefilter::Info::AnyChar() {
Prefilter::Info* info = new Prefilter::Info();
@@ -432,7 +452,8 @@ Prefilter::Info* Prefilter::Info::EmptyString() {
// Constructs Prefilter::Info for a character class.
typedef CharClass::iterator CCIter;
-Prefilter::Info* Prefilter::Info::CClass(CharClass *cc) {
+Prefilter::Info* Prefilter::Info::CClass(CharClass *cc,
+ bool latin1) {
if (Trace) {
VLOG(0) << "CharClassInfo:";
for (CCIter i = cc->begin(); i != cc->end(); ++i)
@@ -445,8 +466,14 @@ Prefilter::Info* Prefilter::Info::CClass(CharClass *cc) {
Prefilter::Info *a = new Prefilter::Info();
for (CCIter i = cc->begin(); i != cc->end(); ++i)
- for (Rune r = i->lo; r <= i->hi; r++)
- a->exact_.insert(RuneToString(ToLowerRune(r)));
+ for (Rune r = i->lo; r <= i->hi; r++) {
+ if (latin1) {
+ a->exact_.insert(RuneToStringLatin1(ToLowerRuneLatin1(r)));
+ } else {
+ a->exact_.insert(RuneToString(ToLowerRune(r)));
+ }
+ }
+
a->is_exact_ = true;
@@ -459,7 +486,7 @@ Prefilter::Info* Prefilter::Info::CClass(CharClass *cc) {
class Prefilter::Info::Walker : public Regexp::Walker<Prefilter::Info*> {
public:
- Walker() {}
+ Walker(bool latin1) : latin1_(latin1) {}
virtual Info* PostVisit(
Regexp* re, Info* parent_arg,
@@ -470,7 +497,9 @@ class Prefilter::Info::Walker : public Regexp::Walker<Prefilter::Info*> {
Regexp* re,
Info* parent_arg);
+ bool latin1() { return latin1_; }
private:
+ bool latin1_;
DISALLOW_EVIL_CONSTRUCTORS(Walker);
};
@@ -478,7 +507,9 @@ Prefilter::Info* Prefilter::BuildInfo(Regexp* re) {
if (Trace) {
LOG(INFO) << "BuildPrefilter::Info: " << re->ToString();
}
- Prefilter::Info::Walker w;
+
+ bool latin1 = re->parse_flags() & Regexp::Latin1;
+ Prefilter::Info::Walker w(latin1);
Prefilter::Info* info = w.WalkExponential(re, NULL, 100000);
if (w.stopped_early()) {
@@ -524,7 +555,12 @@ Prefilter::Info* Prefilter::Info::Walker::PostVisit(
break;
case kRegexpLiteral:
- info = Literal(re->rune());
+ if (latin1()) {
+ info = LiteralLatin1(re->rune());
+ }
+ else {
+ info = Literal(re->rune());
+ }
break;
case kRegexpLiteralString:
@@ -532,9 +568,17 @@ Prefilter::Info* Prefilter::Info::Walker::PostVisit(
info = NoMatch();
break;
}
- info = Literal(re->runes()[0]);
- for (int i = 1; i < re->nrunes(); i++)
- info = Concat(info, Literal(re->runes()[i]));
+ if (latin1()) {
+ info = LiteralLatin1(re->runes()[0]);
+ for (int i = 1; i < re->nrunes(); i++) {
+ info = Concat(info, LiteralLatin1(re->runes()[i]));
+ }
+ } else {
+ info = Literal(re->runes()[0]);
+ for (int i = 1; i < re->nrunes(); i++) {
+ info = Concat(info, Literal(re->runes()[i]));
+ }
+ }
break;
case kRegexpConcat: {
@@ -585,7 +629,7 @@ Prefilter::Info* Prefilter::Info::Walker::PostVisit(
break;
case kRegexpCharClass:
- info = CClass(re->cc());
+ info = CClass(re->cc(), latin1());
break;
case kRegexpCapture:
diff --git a/third_party/re2/re2/re2.cc b/third_party/re2/re2/re2.cc
index 858b6a48..61b88e7 100644
--- a/third_party/re2/re2/re2.cc
+++ b/third_party/re2/re2/re2.cc
@@ -34,23 +34,59 @@ namespace re2 {
static const int kMaxArgs = 16;
static const int kVecSize = 1+kMaxArgs;
-const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::FullMatchN> RE2::FullMatch;
-const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::PartialMatchN> RE2::PartialMatch;
-const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::ConsumeN> RE2::Consume;
-const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::FindAndConsumeN> RE2::FindAndConsume;
-
-// Commonly-used option sets; arguments to constructor are:
-// utf8 input
-// posix syntax
-// longest match
-// log errors
-const RE2::Options RE2::DefaultOptions; // EncodingUTF8, false, false, true
-const RE2::Options RE2::Latin1(RE2::Options::EncodingLatin1, false, false, true);
-//const RE2::Options RE2::POSIX(RE2::Options::EncodingUTF8, true, true, true);
-const RE2::Options RE2::Quiet(RE2::Options::EncodingUTF8, false, false, false);
-
-// If a regular expression has no error, its error_ field points here
-static const string empty_string;
+const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::FullMatchN> RE2::FullMatch = {};
+const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::PartialMatchN> RE2::PartialMatch = {};
+const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::ConsumeN> RE2::Consume = {};
+const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::FindAndConsumeN> RE2::FindAndConsume = {};
+
+#define kDefaultMaxMem (8<<20)
+
+RE2::Options::Options()
+ : encoding_(EncodingUTF8),
+ posix_syntax_(false),
+ longest_match_(false),
+ log_errors_(true),
+ max_mem_(kDefaultMaxMem),
+ literal_(false),
+ never_nl_(false),
+ never_capture_(false),
+ case_sensitive_(true),
+ perl_classes_(false),
+ word_boundary_(false),
+ one_line_(false) {
+}
+
+RE2::Options::Options(RE2::CannedOptions opt)
+ : encoding_(opt == RE2::Latin1 ? EncodingLatin1 : EncodingUTF8),
+ posix_syntax_(opt == RE2::POSIX_SYNTAX),
+ longest_match_(opt == RE2::POSIX_SYNTAX),
+ log_errors_(opt != RE2::Quiet),
+ max_mem_(kDefaultMaxMem),
+ literal_(false),
+ never_nl_(false),
+ never_capture_(false),
+ case_sensitive_(true),
+ perl_classes_(false),
+ word_boundary_(false),
+ one_line_(false) {
+}
+
+// static empty things for use as const references.
+// To avoid global constructors, initialized on demand.
+GLOBAL_MUTEX(empty_mutex);
+static const string *empty_string;
+static const map<string, int> *empty_named_groups;
+static const map<int, string> *empty_group_names;
+
+static void InitEmpty() {
+ GLOBAL_MUTEX_LOCK(empty_mutex);
+ if (empty_string == NULL) {
+ empty_string = new string;
+ empty_named_groups = new map<string, int>;
+ empty_group_names = new map<int, string>;
+ }
+ GLOBAL_MUTEX_UNLOCK(empty_mutex);
+}
// Converts from Regexp error code to RE2 error code.
// Maybe some day they will diverge. In any event, this
@@ -134,6 +170,9 @@ int RE2::Options::ParseFlags() const {
if (never_nl())
flags |= Regexp::NeverNL;
+ if (never_capture())
+ flags |= Regexp::NeverCapture;
+
if (!case_sensitive())
flags |= Regexp::FoldCase;
@@ -153,7 +192,8 @@ void RE2::Init(const StringPiece& pattern, const Options& options) {
mutex_ = new Mutex;
pattern_ = pattern.as_string();
options_.Copy(options);
- error_ = &empty_string;
+ InitEmpty();
+ error_ = empty_string;
error_code_ = NoError;
suffix_regexp_ = NULL;
entire_regexp_ = NULL;
@@ -169,7 +209,7 @@ void RE2::Init(const StringPiece& pattern, const Options& options) {
static_cast<Regexp::ParseFlags>(options_.ParseFlags()),
&status);
if (entire_regexp_ == NULL) {
- if (error_ == &empty_string)
+ if (error_ == empty_string)
error_ = new string(status.Text());
if (options_.log_errors()) {
LOG(ERROR) << "Error parsing '" << trunc(pattern_) << "': "
@@ -211,7 +251,7 @@ void RE2::Init(const StringPiece& pattern, const Options& options) {
// Returns rprog_, computing it if needed.
re2::Prog* RE2::ReverseProg() const {
MutexLock l(mutex_);
- if (rprog_ == NULL && error_ == &empty_string) {
+ if (rprog_ == NULL && error_ == empty_string) {
rprog_ = suffix_regexp_->CompileToReverseProg(options_.max_mem()/3);
if (rprog_ == NULL) {
if (options_.log_errors())
@@ -224,9 +264,6 @@ re2::Prog* RE2::ReverseProg() const {
return rprog_;
}
-static const map<string, int> empty_named_groups;
-static const map<int, string> empty_group_names;
-
RE2::~RE2() {
if (suffix_regexp_)
suffix_regexp_->Decref();
@@ -235,11 +272,11 @@ RE2::~RE2() {
delete mutex_;
delete prog_;
delete rprog_;
- if (error_ != &empty_string)
+ if (error_ != empty_string)
delete error_;
- if (named_groups_ != NULL && named_groups_ != &empty_named_groups)
+ if (named_groups_ != NULL && named_groups_ != empty_named_groups)
delete named_groups_;
- if (group_names_ != NULL && group_names_ != &empty_group_names)
+ if (group_names_ != NULL && group_names_ != empty_group_names)
delete group_names_;
}
@@ -253,11 +290,11 @@ int RE2::ProgramSize() const {
const map<string, int>& RE2::NamedCapturingGroups() const {
MutexLock l(mutex_);
if (!ok())
- return empty_named_groups;
+ return *empty_named_groups;
if (named_groups_ == NULL) {
named_groups_ = suffix_regexp_->NamedCaptures();
if (named_groups_ == NULL)
- named_groups_ = &empty_named_groups;
+ named_groups_ = empty_named_groups;
}
return *named_groups_;
}
@@ -266,11 +303,11 @@ const map<string, int>& RE2::NamedCapturingGroups() const {
const map<int, string>& RE2::CapturingGroupNames() const {
MutexLock l(mutex_);
if (!ok())
- return empty_group_names;
+ return *empty_group_names;
if (group_names_ == NULL) {
group_names_ = suffix_regexp_->CaptureNames();
if (group_names_ == NULL)
- group_names_ = &empty_group_names;
+ group_names_ = empty_group_names;
}
return *group_names_;
}
@@ -311,7 +348,7 @@ bool RE2::FindAndConsumeN(StringPiece* input, const RE2& re,
// Returns the maximum submatch needed for the rewrite to be done by Replace().
// E.g. if rewrite == "foo \\2,\\1", returns 2.
-static int MaxSubmatch(const StringPiece& rewrite) {
+int RE2::MaxSubmatch(const StringPiece& rewrite) {
int max = 0;
for (const char *s = rewrite.data(), *end = s + rewrite.size();
s < end; s++) {
diff --git a/third_party/re2/re2/re2.h b/third_party/re2/re2/re2.h
index 6cc4e8e..98b06b8 100644
--- a/third_party/re2/re2/re2.h
+++ b/third_party/re2/re2/re2.h
@@ -5,8 +5,6 @@
#ifndef RE2_RE2_H
#define RE2_RE2_H
-#define kDefaultMaxMem (8<<20)
-
// C++ interface to the re2 regular-expression library.
// RE2 supports Perl-style regular expressions (with extensions like
// \d, \w, \s, ...).
@@ -189,12 +187,28 @@
#include "re2/variadic_function.h"
namespace re2 {
+
using std::string;
using std::map;
class Mutex;
class Prog;
class Regexp;
+// The following enum should be used only as a constructor argument to indicate
+// that the variable has static storage class, and that the constructor should
+// do nothing to its state. It indicates to the reader that it is legal to
+// declare a static instance of the class, provided the constructor is given
+// the LINKER_INITIALIZED argument. Normally, it is unsafe to declare a
+// static variable that has a constructor or a destructor because invocation
+// order is undefined. However, IF the type can be initialized by filling with
+// zeroes (which the loader does for static variables), AND the type's
+// destructor does nothing to the storage, then a constructor for static
+// initialization can be declared as
+// explicit MyClass(LinkerInitialized x) {}
+// and invoked as
+// static MyClass my_variable_name(LINKER_INITIALIZED);
+enum LinkerInitialized { LINKER_INITIALIZED };
+
// Interface for regular expression matching. Also corresponds to a
// pre-compiled regular expression. An "RE2" object is safe for
// concurrent use by multiple threads.
@@ -231,12 +245,15 @@ class RE2 {
// Predefined common options.
// If you need more complicated things, instantiate
- // an Option class, change the settings, and pass it to the
- // RE2 constructor.
- static const Options DefaultOptions;
- static const Options Latin1; // treat input as Latin-1 (default UTF-8)
- //static const Options POSIX; // POSIX syntax, leftmost-longest match
- static const Options Quiet; // do not log about regexp parse errors
+ // an Option class, possibly passing one of these to
+ // the Option constructor, change the settings, and pass that
+ // Option class to the RE2 constructor.
+ enum CannedOptions {
+ DefaultOptions = 0,
+ Latin1, // treat input as Latin-1 (default UTF-8)
+ POSIX_SYNTAX, // POSIX syntax, leftmost-longest match
+ Quiet // do not log about regexp parse errors
+ };
// Need to have the const char* and const string& forms for implicit
// conversions when passing string literals to FullMatch and PartialMatch.
@@ -469,6 +486,20 @@ class RE2 {
// fail because of a bad rewrite string.
bool CheckRewriteString(const StringPiece& rewrite, string* error) const;
+ // Returns the maximum submatch needed for the rewrite to be done by
+ // Replace(). E.g. if rewrite == "foo \\2,\\1", returns 2.
+ static int MaxSubmatch(const StringPiece& rewrite);
+
+ // Append the "rewrite" string, with backslash subsitutions from "vec",
+ // to string "out".
+ // Returns true on success. This method can fail because of a malformed
+ // rewrite string. CheckRewriteString guarantees that the rewrite will
+ // be sucessful.
+ bool Rewrite(string *out,
+ const StringPiece &rewrite,
+ const StringPiece* vec,
+ int veclen) const;
+
// Constructor options
class Options {
public:
@@ -481,6 +512,7 @@ class RE2 {
// max_mem (see below) approx. max memory footprint of RE2
// literal (false) interpret string as literal, not regexp
// never_nl (false) never match \n, even if it is in regexp
+ // never_capture (false) parse all parens as non-capturing
// case_sensitive (true) match is case-sensitive (regexp can override
// with (?i) unless in posix_syntax mode)
//
@@ -519,24 +551,18 @@ class RE2 {
// Once a DFA fills its budget, it flushes its cache and starts over.
// If this happens too often, RE2 falls back on the NFA implementation.
+ // For now, make the default budget something close to Code Search.
+#ifndef WIN32
+ static const int kDefaultMaxMem = 8<<20;
+#endif
+
enum Encoding {
EncodingUTF8 = 1,
EncodingLatin1
};
- Options() :
- encoding_(EncodingUTF8),
- posix_syntax_(false),
- longest_match_(false),
- log_errors_(true),
- max_mem_(kDefaultMaxMem),
- literal_(false),
- never_nl_(false),
- case_sensitive_(true),
- perl_classes_(false),
- word_boundary_(false),
- one_line_(false) {
- }
+ Options();
+ /*implicit*/ Options(CannedOptions);
Encoding encoding() const { return encoding_; }
void set_encoding(Encoding encoding) { encoding_ = encoding; }
@@ -570,6 +596,9 @@ class RE2 {
bool never_nl() const { return never_nl_; }
void set_never_nl(bool b) { never_nl_ = b; }
+ bool never_capture() const { return never_capture_; }
+ void set_never_capture(bool b) { never_capture_ = b; }
+
bool case_sensitive() const { return case_sensitive_; }
void set_case_sensitive(bool b) { case_sensitive_ = b; }
@@ -590,6 +619,7 @@ class RE2 {
max_mem_ = src.max_mem_;
literal_ = src.literal_;
never_nl_ = src.never_nl_;
+ never_capture_ = src.never_capture_;
case_sensitive_ = src.case_sensitive_;
perl_classes_ = src.perl_classes_;
word_boundary_ = src.word_boundary_;
@@ -599,25 +629,6 @@ class RE2 {
int ParseFlags() const;
private:
- // Private constructor for defining constants like RE2::Latin1.
- friend class RE2;
- Options(Encoding encoding,
- bool posix_syntax,
- bool longest_match,
- bool log_errors) :
- encoding_(encoding),
- posix_syntax_(posix_syntax),
- longest_match_(longest_match),
- log_errors_(log_errors),
- max_mem_(kDefaultMaxMem),
- literal_(false),
- never_nl_(false),
- case_sensitive_(true),
- perl_classes_(false),
- word_boundary_(false),
- one_line_(false) {
- }
-
Encoding encoding_;
bool posix_syntax_;
bool longest_match_;
@@ -625,6 +636,7 @@ class RE2 {
int64_t max_mem_;
bool literal_;
bool never_nl_;
+ bool never_capture_;
bool case_sensitive_;
bool perl_classes_;
bool word_boundary_;
@@ -669,11 +681,6 @@ class RE2 {
private:
void Init(const StringPiece& pattern, const Options& options);
- bool Rewrite(string *out,
- const StringPiece &rewrite,
- const StringPiece* vec,
- int veclen) const;
-
bool DoMatch(const StringPiece& text,
Anchor anchor,
int* consumed,
diff --git a/third_party/re2/re2/regexp.cc b/third_party/re2/re2/regexp.cc
index 9486b3c..a74ceec 100644
--- a/third_party/re2/re2/regexp.cc
+++ b/third_party/re2/re2/regexp.cc
@@ -59,29 +59,39 @@ bool Regexp::QuickDestroy() {
return false;
}
-static map<Regexp*, int> ref_map;
-static Mutex ref_mutex;
+static map<Regexp*, int> *ref_map;
+GLOBAL_MUTEX(ref_mutex);
int Regexp::Ref() {
if (ref_ < kMaxRef)
return ref_;
- MutexLock l(&ref_mutex);
- return ref_map[this];
+ GLOBAL_MUTEX_LOCK(ref_mutex);
+ int r = 0;
+ if (ref_map != NULL) {
+ r = (*ref_map)[this];
+ }
+ GLOBAL_MUTEX_UNLOCK(ref_mutex);
+ return r;
}
// Increments reference count, returns object as convenience.
Regexp* Regexp::Incref() {
if (ref_ >= kMaxRef-1) {
// Store ref count in overflow map.
- MutexLock l(&ref_mutex);
- if (ref_ == kMaxRef) { // already overflowed
- ref_map[this]++;
- return this;
+ GLOBAL_MUTEX_LOCK(ref_mutex);
+ if (ref_map == NULL) {
+ ref_map = new map<Regexp*, int>;
+ }
+ if (ref_ == kMaxRef) {
+ // already overflowed
+ (*ref_map)[this]++;
+ } else {
+ // overflowing now
+ (*ref_map)[this] = kMaxRef;
+ ref_ = kMaxRef;
}
- // overflowing now
- ref_map[this] = kMaxRef;
- ref_ = kMaxRef;
+ GLOBAL_MUTEX_UNLOCK(ref_mutex);
return this;
}
@@ -93,14 +103,15 @@ Regexp* Regexp::Incref() {
void Regexp::Decref() {
if (ref_ == kMaxRef) {
// Ref count is stored in overflow map.
- MutexLock l(&ref_mutex);
- int r = ref_map[this] - 1;
+ GLOBAL_MUTEX_LOCK(ref_mutex);
+ int r = (*ref_map)[this] - 1;
if (r < kMaxRef) {
ref_ = r;
- ref_map.erase(this);
+ ref_map->erase(this);
} else {
- ref_map[this] = r;
+ (*ref_map)[this] = r;
}
+ GLOBAL_MUTEX_UNLOCK(ref_mutex);
return;
}
ref_--;
@@ -447,7 +458,7 @@ bool Regexp::Equal(Regexp* a, Regexp* b) {
}
// Keep in sync with enum RegexpStatusCode in regexp.h
-static const string kErrorStrings[] = {
+static const char *kErrorStrings[] = {
"no error",
"unexpected error",
"invalid escape sequence",
@@ -464,7 +475,7 @@ static const string kErrorStrings[] = {
"invalid named capture group",
};
-const string& RegexpStatus::CodeText(enum RegexpStatusCode code) {
+string RegexpStatus::CodeText(enum RegexpStatusCode code) {
if (code < 0 || code >= arraysize(kErrorStrings))
code = kRegexpInternalError;
return kErrorStrings[code];
diff --git a/third_party/re2/re2/regexp.h b/third_party/re2/re2/regexp.h
index 1aebc16..331c017 100644
--- a/third_party/re2/re2/regexp.h
+++ b/third_party/re2/re2/regexp.h
@@ -197,7 +197,7 @@ class RegexpStatus {
// Returns text equivalent of code, e.g.:
// "Bad character class"
- static const string& CodeText(enum RegexpStatusCode code);
+ static string CodeText(enum RegexpStatusCode code);
// Returns text describing error, e.g.:
// "Bad character class: [z-a]"
@@ -299,6 +299,7 @@ class Regexp {
// and \P{Han} for its negation.
NeverNL = 1<<11, // Never match NL, even if the regexp mentions
// it explicitly.
+ NeverCapture = 1<<12, // Parse all parens as non-capturing.
// As close to Perl as we can get.
LikePerl = ClassNL | OneLine | PerlClasses | PerlB | PerlX |
diff --git a/third_party/re2/re2/testing/filtered_re2_test.cc b/third_party/re2/re2/testing/filtered_re2_test.cc
index 7755d30..e3a0dd1 100644
--- a/third_party/re2/re2/testing/filtered_re2_test.cc
+++ b/third_party/re2/re2/testing/filtered_re2_test.cc
@@ -39,6 +39,23 @@ TEST(FilteredRE2Test, SmallOrTest) {
EXPECT_EQ(id, v.matches[0]);
}
+TEST(FilteredRE2Test, SmallLatinTest) {
+ FLAGS_filtered_re2_min_atom_len = 3;
+ FilterTestVars v;
+ int id;
+
+ v.opts.set_utf8(false);
+ v.f.Add("\xde\xadQ\xbe\xef", v.opts, &id);
+ v.f.Compile(&v.atoms);
+ EXPECT_EQ(1, v.atoms.size());
+ EXPECT_EQ(v.atoms[0], "\xde\xadq\xbe\xef");
+
+ v.atom_indices.push_back(0);
+ v.f.AllMatches("foo\xde\xadQ\xbe\xeflemur", v.atom_indices, &v.matches);
+ EXPECT_EQ(1, v.matches.size());
+ EXPECT_EQ(id, v.matches[0]);
+}
+
struct AtomTest {
const char* testname;
// If any test needs more than this many regexps or atoms, increase
diff --git a/third_party/re2/re2/testing/parse_test.cc b/third_party/re2/re2/testing/parse_test.cc
index f895316..f67b477 100644
--- a/third_party/re2/re2/testing/parse_test.cc
+++ b/third_party/re2/re2/testing/parse_test.cc
@@ -11,11 +11,19 @@
namespace re2 {
+static const Regexp::ParseFlags TestZeroFlags = Regexp::ParseFlags(1<<30);
+
struct Test {
const char* regexp;
const char* parse;
+ Regexp::ParseFlags flags;
};
+static Regexp::ParseFlags kTestFlags = Regexp::MatchNL |
+ Regexp::PerlX |
+ Regexp::PerlClasses |
+ Regexp::UnicodeGroups;
+
static Test tests[] = {
// Base cases
{ "a", "lit{a}" },
@@ -138,12 +146,53 @@ static Test tests[] = {
// Strings
{ "abcde", "str{abcde}" },
{ "[Aa][Bb]cd", "cat{strfold{ab}str{cd}}" },
-};
-static Regexp::ParseFlags kTestFlags = Regexp::MatchNL |
- Regexp::PerlX |
- Regexp::PerlClasses |
- Regexp::UnicodeGroups;
+ // Reported bug involving \n leaking in despite use of NeverNL.
+ { "[^ ]", "cc{0-0x9 0xb-0x1f 0x21-0x10ffff}", TestZeroFlags },
+ { "[^ ]", "cc{0-0x9 0xb-0x1f 0x21-0x10ffff}", Regexp::FoldCase },
+ { "[^ ]", "cc{0-0x9 0xb-0x1f 0x21-0x10ffff}", Regexp::NeverNL },
+ { "[^ ]", "cc{0-0x9 0xb-0x1f 0x21-0x10ffff}", Regexp::NeverNL | Regexp::FoldCase },
+ { "[^ \f]", "cc{0-0x9 0xb 0xd-0x1f 0x21-0x10ffff}", TestZeroFlags },
+ { "[^ \f]", "cc{0-0x9 0xb 0xd-0x1f 0x21-0x10ffff}", Regexp::FoldCase },
+ { "[^ \f]", "cc{0-0x9 0xb 0xd-0x1f 0x21-0x10ffff}", Regexp::NeverNL },
+ { "[^ \f]", "cc{0-0x9 0xb 0xd-0x1f 0x21-0x10ffff}", Regexp::NeverNL | Regexp::FoldCase },
+ { "[^ \r]", "cc{0-0x9 0xb-0xc 0xe-0x1f 0x21-0x10ffff}", TestZeroFlags },
+ { "[^ \r]", "cc{0-0x9 0xb-0xc 0xe-0x1f 0x21-0x10ffff}", Regexp::FoldCase },
+ { "[^ \r]", "cc{0-0x9 0xb-0xc 0xe-0x1f 0x21-0x10ffff}", Regexp::NeverNL },
+ { "[^ \r]", "cc{0-0x9 0xb-0xc 0xe-0x1f 0x21-0x10ffff}", Regexp::NeverNL | Regexp::FoldCase },
+ { "[^ \v]", "cc{0-0x9 0xc-0x1f 0x21-0x10ffff}", TestZeroFlags },
+ { "[^ \v]", "cc{0-0x9 0xc-0x1f 0x21-0x10ffff}", Regexp::FoldCase },
+ { "[^ \v]", "cc{0-0x9 0xc-0x1f 0x21-0x10ffff}", Regexp::NeverNL },
+ { "[^ \v]", "cc{0-0x9 0xc-0x1f 0x21-0x10ffff}", Regexp::NeverNL | Regexp::FoldCase },
+ { "[^ \t]", "cc{0-0x8 0xb-0x1f 0x21-0x10ffff}", TestZeroFlags },
+ { "[^ \t]", "cc{0-0x8 0xb-0x1f 0x21-0x10ffff}", Regexp::FoldCase },
+ { "[^ \t]", "cc{0-0x8 0xb-0x1f 0x21-0x10ffff}", Regexp::NeverNL },
+ { "[^ \t]", "cc{0-0x8 0xb-0x1f 0x21-0x10ffff}", Regexp::NeverNL | Regexp::FoldCase },
+ { "[^ \r\f\v]", "cc{0-0x9 0xe-0x1f 0x21-0x10ffff}", Regexp::NeverNL },
+ { "[^ \r\f\v]", "cc{0-0x9 0xe-0x1f 0x21-0x10ffff}", Regexp::NeverNL | Regexp::FoldCase },
+ { "[^ \r\f\t\v]", "cc{0-0x8 0xe-0x1f 0x21-0x10ffff}", Regexp::NeverNL },
+ { "[^ \r\f\t\v]", "cc{0-0x8 0xe-0x1f 0x21-0x10ffff}", Regexp::NeverNL | Regexp::FoldCase },
+ { "[^ \r\n\f\t\v]", "cc{0-0x8 0xe-0x1f 0x21-0x10ffff}", Regexp::NeverNL },
+ { "[^ \r\n\f\t\v]", "cc{0-0x8 0xe-0x1f 0x21-0x10ffff}", Regexp::NeverNL | Regexp::FoldCase },
+ { "[^ \r\n\f\t]", "cc{0-0x8 0xb 0xe-0x1f 0x21-0x10ffff}", Regexp::NeverNL },
+ { "[^ \r\n\f\t]", "cc{0-0x8 0xb 0xe-0x1f 0x21-0x10ffff}", Regexp::NeverNL | Regexp::FoldCase },
+ { "[^\t-\n\f-\r ]", "cc{0-0x8 0xb 0xe-0x1f 0x21-0x10ffff}",
+ Regexp::PerlClasses },
+ { "[^\t-\n\f-\r ]", "cc{0-0x8 0xb 0xe-0x1f 0x21-0x10ffff}",
+ Regexp::PerlClasses | Regexp::FoldCase },
+ { "[^\t-\n\f-\r ]", "cc{0-0x8 0xb 0xe-0x1f 0x21-0x10ffff}",
+ Regexp::PerlClasses | Regexp::NeverNL },
+ { "[^\t-\n\f-\r ]", "cc{0-0x8 0xb 0xe-0x1f 0x21-0x10ffff}",
+ Regexp::PerlClasses | Regexp::NeverNL | Regexp::FoldCase },
+ { "\\S", "cc{0-0x8 0xb 0xe-0x1f 0x21-0x10ffff}",
+ Regexp::PerlClasses },
+ { "\\S", "cc{0-0x8 0xb 0xe-0x1f 0x21-0x10ffff}",
+ Regexp::PerlClasses | Regexp::FoldCase },
+ { "\\S", "cc{0-0x8 0xb 0xe-0x1f 0x21-0x10ffff}",
+ Regexp::PerlClasses | Regexp::NeverNL },
+ { "\\S", "cc{0-0x8 0xb 0xe-0x1f 0x21-0x10ffff}",
+ Regexp::PerlClasses | Regexp::NeverNL | Regexp::FoldCase },
+};
bool RegexpEqualTestingOnly(Regexp* a, Regexp* b) {
return Regexp::Equal(a, b);
@@ -154,12 +203,16 @@ void TestParse(const Test* tests, int ntests, Regexp::ParseFlags flags,
Regexp** re = new Regexp*[ntests];
for (int i = 0; i < ntests; i++) {
RegexpStatus status;
- re[i] = Regexp::Parse(tests[i].regexp, flags, &status);
+ Regexp::ParseFlags f = flags;
+ if (tests[i].flags != 0) {
+ f = tests[i].flags & ~TestZeroFlags;
+ }
+ re[i] = Regexp::Parse(tests[i].regexp, f, &status);
CHECK(re[i] != NULL) << " " << tests[i].regexp << " "
<< status.Text();
string s = re[i]->Dump();
EXPECT_EQ(string(tests[i].parse), s) << "Regexp: " << tests[i].regexp
- << "\nparse: " << tests[i].parse << " s: " << s;
+ << "\nparse: " << tests[i].parse << " s: " << s << " flag=" << f;
}
for (int i = 0; i < ntests; i++) {
@@ -328,10 +381,14 @@ TEST(TestParse, InvalidRegexps) {
TEST(TestToString, EquivalentParse) {
for (int i = 0; i < arraysize(tests); i++) {
RegexpStatus status;
- Regexp* re = Regexp::Parse(tests[i].regexp, kTestFlags, &status);
+ Regexp::ParseFlags f = kTestFlags;
+ if (tests[i].flags != 0) {
+ f = tests[i].flags & ~TestZeroFlags;
+ }
+ Regexp* re = Regexp::Parse(tests[i].regexp, f, &status);
CHECK(re != NULL) << " " << tests[i].regexp << " " << status.Text();
string s = re->Dump();
- EXPECT_EQ(string(tests[i].parse), s);
+ EXPECT_EQ(string(tests[i].parse), s) << " " << tests[i].regexp << " " << string(tests[i].parse) << " " << s;
string t = re->ToString();
if (t != tests[i].regexp) {
// If ToString didn't return the original regexp,
diff --git a/third_party/re2/re2/testing/re2_arg_test.cc b/third_party/re2/re2/testing/re2_arg_test.cc
index 0a77d95..ae7a7b0 100644
--- a/third_party/re2/re2/testing/re2_arg_test.cc
+++ b/third_party/re2/re2/testing/re2_arg_test.cc
@@ -57,7 +57,8 @@ const SuccessTable kSuccessTable[] = {
// -2^15-1 to -2^31
{ "-32769", -32769, { false, false, true, false, true, false }},
{ "-2147483648",
- 0xFFFFFFFF80000000LL, { false, false, true, false, true, false }},
+ static_cast<int64>(0xFFFFFFFF80000000LL),
+{ false, false, true, false, true, false }},
// 2^31 to 2^32-1
{ "2147483648", 2147483648U, { false, false, false, true, true, true }},
@@ -70,14 +71,14 @@ const SuccessTable kSuccessTable[] = {
// -2^31-1 to -2^63
{ "-2147483649", -2147483649LL, { false, false, false, false, true, false }},
-{ "-9223372036854775808",
- 0x8000000000000000LL, { false, false, false, false, true, false }},
+{ "-9223372036854775808", static_cast<int64>(0x8000000000000000LL),
+ { false, false, false, false, true, false }},
// 2^63 to 2^64-1
-{ "9223372036854775808",
- 9223372036854775808ULL, { false, false, false, false, false, true }},
-{ "18446744073709551615",
- 18446744073709551615ULL, { false, false, false, false, false, true }},
+{ "9223372036854775808", static_cast<int64>(9223372036854775808ULL),
+ { false, false, false, false, false, true }},
+{ "18446744073709551615", static_cast<int64>(18446744073709551615ULL),
+ { false, false, false, false, false, true }},
// >= 2^64
{ "18446744073709551616", 0, { false, false, false, false, false, false }},
diff --git a/third_party/re2/re2/testing/re2_test.cc b/third_party/re2/re2/testing/re2_test.cc
index ef5d4aa..911e868 100644
--- a/third_party/re2/re2/testing/re2_test.cc
+++ b/third_party/re2/re2/testing/re2_test.cc
@@ -757,18 +757,18 @@ TEST(RE2, FullMatchTypeTests) {
CHECK(RE2::FullMatch("100", "(-?\\d+)", &v)); CHECK_EQ(v, 100);
CHECK(RE2::FullMatch("-100", "(-?\\d+)", &v)); CHECK_EQ(v, -100);
- snprintf(buf, sizeof(buf), "%lld", max);
+ snprintf(buf, sizeof(buf), "%lld", (long long int)max);
CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, max);
- snprintf(buf, sizeof(buf), "%lld", min);
+ snprintf(buf, sizeof(buf), "%lld", (long long int)min);
CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, min);
- snprintf(buf, sizeof(buf), "%lld", max);
+ snprintf(buf, sizeof(buf), "%lld", (long long int)max);
assert(buf[strlen(buf)-1] != '9');
buf[strlen(buf)-1]++;
CHECK(!RE2::FullMatch(buf, "(-?\\d+)", &v));
- snprintf(buf, sizeof(buf), "%lld", min);
+ snprintf(buf, sizeof(buf), "%lld", (long long int)min);
assert(buf[strlen(buf)-1] != '9');
buf[strlen(buf)-1]++;
CHECK(!RE2::FullMatch(buf, "(-?\\d+)", &v));
@@ -782,7 +782,7 @@ TEST(RE2, FullMatchTypeTests) {
CHECK(RE2::FullMatch("100", "(-?\\d+)", &v)); CHECK_EQ(v, 100);
CHECK(RE2::FullMatch("-100", "(-?\\d+)", &v2)); CHECK_EQ(v2, -100);
- snprintf(buf, sizeof(buf), "%llu", max);
+ snprintf(buf, sizeof(buf), "%llu", (long long unsigned)max);
CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, max);
assert(buf[strlen(buf)-1] != '9');
@@ -1253,6 +1253,14 @@ TEST(RE2, NeverNewline) {
}
}
+// Check that there are no capturing groups in "never capture" mode.
+TEST(RE2, NeverCapture) {
+ RE2::Options opt;
+ opt.set_never_capture(true);
+ RE2 re("(r)(e)", opt);
+ EXPECT_EQ(0, re.NumberOfCapturingGroups());
+}
+
// Bitstate bug was looking at submatch[0] even if nsubmatch == 0.
// Triggered by a failed DFA search falling back to Bitstate when
// using Match with a NULL submatch set. Bitstate tried to read
diff --git a/third_party/re2/re2/testing/set_test.cc b/third_party/re2/re2/testing/set_test.cc
index 89aed80..74058a4 100644
--- a/third_party/re2/re2/testing/set_test.cc
+++ b/third_party/re2/re2/testing/set_test.cc
@@ -69,6 +69,18 @@ TEST(Set, UnanchoredFactored) {
CHECK_EQ(v.size(), 0);
}
+TEST(Set, UnanchoredDollar) {
+ RE2::Set s(RE2::DefaultOptions, RE2::UNANCHORED);
+
+ CHECK_EQ(s.Add("foo$", NULL), 0);
+ CHECK_EQ(s.Compile(), true);
+
+ vector<int> v;
+ CHECK_EQ(s.Match("foo", &v), true);
+ CHECK_EQ(v.size(), 1);
+ CHECK_EQ(v[0], 0);
+}
+
TEST(Set, Anchored) {
RE2::Set s(RE2::DefaultOptions, RE2::ANCHOR_BOTH);
diff --git a/third_party/re2/re2/variadic_function.h b/third_party/re2/re2/variadic_function.h
index 8d2b763..7c7d6d5 100644
--- a/third_party/re2/re2/variadic_function.h
+++ b/third_party/re2/re2/variadic_function.h
@@ -11,8 +11,6 @@ template <typename Result, typename Param0, typename Param1, typename Arg,
Result (*Func)(Param0, Param1, const Arg* const [], int count)>
class VariadicFunction2 {
public:
- VariadicFunction2() {}
-
Result operator()(Param0 p0, Param1 p1) const {
return Func(p0, p1, 0, 0);
}
diff --git a/third_party/re2/util/logging.h b/third_party/re2/util/logging.h
index 53f7198..7302ea6 100644
--- a/third_party/re2/util/logging.h
+++ b/third_party/re2/util/logging.h
@@ -53,17 +53,24 @@
class LogMessage {
public:
- LogMessage(const char* file, int line) {
+ LogMessage(const char* file, int line) : flushed_(false) {
stream() << file << ":" << line << ": ";
}
- ~LogMessage() {
+ void Flush() {
stream() << "\n";
string s = str_.str();
if(write(2, s.data(), s.size()) < 0) {} // shut up gcc
+ flushed_ = true;
+ }
+ ~LogMessage() {
+ if (!flushed_) {
+ Flush();
+ }
}
ostream& stream() { return str_; }
private:
+ bool flushed_;
std::ostringstream str_;
DISALLOW_EVIL_CONSTRUCTORS(LogMessage);
};
@@ -73,7 +80,7 @@ class LogMessageFatal : public LogMessage {
LogMessageFatal(const char* file, int line)
: LogMessage(file, line) { }
~LogMessageFatal() {
- std::cerr << "\n";
+ Flush();
abort();
}
private:
diff --git a/third_party/re2/util/mutex.h b/third_party/re2/util/mutex.h
index 4bb6fec..e321fae 100644
--- a/third_party/re2/util/mutex.h
+++ b/third_party/re2/util/mutex.h
@@ -76,7 +76,7 @@ class Mutex {
MutexType mutex_;
// Catch the error of writing Mutex when intending MutexLock.
- Mutex(Mutex *ignored) {}
+ Mutex(Mutex *ignored);
// Disallow "evil" constructors
Mutex(const Mutex&);
void operator=(const Mutex&);
@@ -189,6 +189,27 @@ class WriterMutexLock {
#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
+// Provide safe way to declare and use global, linker-initialized mutex. Sigh.
+#ifdef HAVE_PTHREAD
+
+#define GLOBAL_MUTEX(name) \
+ static pthread_mutex_t (name) = PTHREAD_MUTEX_INITIALIZER
+#define GLOBAL_MUTEX_LOCK(name) \
+ pthread_mutex_lock(&(name))
+#define GLOBAL_MUTEX_UNLOCK(name) \
+ pthread_mutex_unlock(&(name))
+
+#else
+
+#define GLOBAL_MUTEX(name) \
+ static Mutex name
+#define GLOBAL_MUTEX_LOCK(name) \
+ name.Lock()
+#define GLOBAL_MUTEX_UNLOCK(name) \
+ name.Unlock()
+
+#endif
+
} // namespace re2
#endif /* #define RE2_UTIL_MUTEX_H_ */
diff --git a/third_party/re2/util/sparse_array.h b/third_party/re2/util/sparse_array.h
index c024bed..3e33f89 100644
--- a/third_party/re2/util/sparse_array.h
+++ b/third_party/re2/util/sparse_array.h
@@ -224,13 +224,14 @@ class SparseArray {
int max_size_;
int* sparse_to_dense_;
vector<IndexValue> dense_;
+ bool valgrind_;
DISALLOW_EVIL_CONSTRUCTORS(SparseArray);
};
template<typename Value>
SparseArray<Value>::SparseArray()
- : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_() {}
+ : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(), valgrind_(RunningOnValgrind()) {}
// IndexValue pairs: exposed in SparseArray::iterator.
template<typename Value>
@@ -272,7 +273,7 @@ void SparseArray<Value>::resize(int new_max_size) {
if (sparse_to_dense_) {
memmove(a, sparse_to_dense_, max_size_*sizeof a[0]);
// Don't need to zero the memory but appease Valgrind.
- if (RunningOnValgrind()) {
+ if (valgrind_) {
for (int i = max_size_; i < new_max_size; i++)
a[i] = 0xababababU;
}
@@ -417,9 +418,10 @@ void SparseArray<Value>::create_index(int i) {
template<typename Value> SparseArray<Value>::SparseArray(int max_size) {
max_size_ = max_size;
sparse_to_dense_ = new int[max_size];
+ valgrind_ = RunningOnValgrind();
dense_.resize(max_size);
// Don't need to zero the new memory, but appease Valgrind.
- if (RunningOnValgrind()) {
+ if (valgrind_) {
for (int i = 0; i < max_size; i++) {
sparse_to_dense_[i] = 0xababababU;
dense_[i].index_ = 0xababababU;
diff --git a/third_party/re2/util/sparse_set.h b/third_party/re2/util/sparse_set.h
index 9cb5753..165dd09 100644
--- a/third_party/re2/util/sparse_set.h
+++ b/third_party/re2/util/sparse_set.h
@@ -54,15 +54,16 @@ namespace re2 {
class SparseSet {
public:
SparseSet()
- : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(NULL) {}
+ : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(NULL), valgrind_(RunningOnValgrind()) {}
SparseSet(int max_size) {
max_size_ = max_size;
sparse_to_dense_ = new int[max_size];
dense_ = new int[max_size];
+ valgrind_ = RunningOnValgrind();
// Don't need to zero the memory, but do so anyway
// to appease Valgrind.
- if (RunningOnValgrind()) {
+ if (valgrind_) {
for (int i = 0; i < max_size; i++) {
dense_[i] = 0xababababU;
sparse_to_dense_[i] = 0xababababU;
@@ -94,7 +95,7 @@ class SparseSet {
int* a = new int[new_max_size];
if (sparse_to_dense_) {
memmove(a, sparse_to_dense_, max_size_*sizeof a[0]);
- if (RunningOnValgrind()) {
+ if (valgrind_) {
for (int i = max_size_; i < new_max_size; i++)
a[i] = 0xababababU;
}
@@ -105,7 +106,7 @@ class SparseSet {
a = new int[new_max_size];
if (dense_) {
memmove(a, dense_, size_*sizeof a[0]);
- if (RunningOnValgrind()) {
+ if (valgrind_) {
for (int i = size_; i < new_max_size; i++)
a[i] = 0xababababU;
}
@@ -168,6 +169,7 @@ class SparseSet {
int max_size_;
int* sparse_to_dense_;
int* dense_;
+ bool valgrind_;
DISALLOW_EVIL_CONSTRUCTORS(SparseSet);
};
diff --git a/third_party/re2/util/util.h b/third_party/re2/util/util.h
index 0a15a81..11b5f4a 100644
--- a/third_party/re2/util/util.h
+++ b/third_party/re2/util/util.h
@@ -24,7 +24,7 @@
#include <iosfwd>
#include <map>
#include <stack>
-#include <iostream>
+#include <ostream>
#include <utility>
#include <set>
diff --git a/third_party/re2/util/valgrind.cc b/third_party/re2/util/valgrind.cc
index 749bb59..46f804b 100644
--- a/third_party/re2/util/valgrind.cc
+++ b/third_party/re2/util/valgrind.cc
@@ -7,18 +7,12 @@
namespace re2 {
-static bool checkValgrind() {
+int RunningOnValgrind() {
#ifdef RUNNING_ON_VALGRIND
return RUNNING_ON_VALGRIND;
#else
- return false;
+ return 0;
#endif
}
-static const int valgrind = checkValgrind();
-
-int RunningOnValgrind() {
- return valgrind;
-}
-
} // namespace re2
diff --git a/third_party/re2/util/valgrind.h b/third_party/re2/util/valgrind.h
index 3cfd6fe..d097b0c 100644
--- a/third_party/re2/util/valgrind.h
+++ b/third_party/re2/util/valgrind.h
@@ -4063,6 +4063,7 @@ typedef
#endif /* PLAT_ppc64_aix5 */
+
#ifndef WIN32
/* ------------------------------------------------------------------ */
/* ARCHITECTURE INDEPENDENT MACROS for CLIENT REQUESTS. */