summaryrefslogtreecommitdiffstats
path: root/third_party/libphonenumber
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 20:59:33 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 20:59:33 +0000
commitbf6391266f0d1e400ded7d4994519b3c792f8d58 (patch)
tree93698f808154fc4d334c79ff36e5143ad4cc9507 /third_party/libphonenumber
parent363a34afb1524a3420b260e13546adb4373c1176 (diff)
downloadchromium_src-bf6391266f0d1e400ded7d4994519b3c792f8d58.zip
chromium_src-bf6391266f0d1e400ded7d4994519b3c792f8d58.tar.gz
chromium_src-bf6391266f0d1e400ded7d4994519b3c792f8d58.tar.bz2
Delete old libphonenumber files (part 2)
This time via SVN... BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/9415041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/libphonenumber')
-rw-r--r--third_party/libphonenumber/patches/utf8_v186.patch251
-rw-r--r--third_party/libphonenumber/patches/version186.patch1177
-rw-r--r--third_party/libphonenumber/patches/version277.patch1416
-rw-r--r--third_party/libphonenumber/patches/version277a.patch21
4 files changed, 0 insertions, 2865 deletions
diff --git a/third_party/libphonenumber/patches/utf8_v186.patch b/third_party/libphonenumber/patches/utf8_v186.patch
deleted file mode 100644
index 70a1a1d..0000000
--- a/third_party/libphonenumber/patches/utf8_v186.patch
+++ /dev/null
@@ -1,251 +0,0 @@
-Index: D:/src/src/third_party/libphonenumber/cpp/src/phonenumberutil_test.cc
-===================================================================
---- phonenumberutil_test.cc (revision 186)
-+++ phonenumberutil_test.cc (working copy)
-@@ -1101,11 +1101,11 @@
- ExtractPossibleNumber("Tel:+800-345-600", &extracted_number);
- EXPECT_EQ("+800-345-600", extracted_number);
- // Should recognise wide digits as possible start values.
-- ExtractPossibleNumber("023", &extracted_number);
-- EXPECT_EQ("023", extracted_number);
-+ ExtractPossibleNumber("\xEF\xBC\x90\xEF\xBC\x92\xEF\xBC\x93", &extracted_number);
-+ EXPECT_EQ("\xEF\xBC\x90\xEF\xBC\x92\xEF\xBC\x93", extracted_number);
- // Dashes are not possible start values and should be removed.
-- ExtractPossibleNumber("Num-123", &extracted_number);
-- EXPECT_EQ("123", extracted_number);
-+ ExtractPossibleNumber("Num-\xEF\xBC\x91\xEF\xBC\x92\xEF\xBC\x93", &extracted_number);
-+ EXPECT_EQ("\xEF\xBC\x91\xEF\xBC\x92\xEF\xBC\x93", extracted_number);
- // If not possible number present, return empty string.
- ExtractPossibleNumber("Num-....", &extracted_number);
- EXPECT_EQ("", extracted_number);
-@@ -1119,7 +1119,7 @@
- ExtractPossibleNumber("(650) 253-0000.", &extracted_number);
- EXPECT_EQ("650) 253-0000", extracted_number);
- // This case has a trailing RTL char.
-- ExtractPossibleNumber("(650) 253-0000‏", &extracted_number);
-+ ExtractPossibleNumber("(650) 253-0000\xE2\x80\x8F", &extracted_number);
- EXPECT_EQ("650) 253-0000", extracted_number);
- }
-
-@@ -1163,7 +1163,7 @@
- // This number is no longer valid.
- EXPECT_FALSE(phone_util_.IsValidNumber(bs_number));
-
-- // La Mayotte and Réunion use 'leadingDigits' to differentiate them.
-+ // La Mayotte and R\xC3\xA9union use 'leadingDigits' to differentiate them.
- PhoneNumber re_number;
- re_number.set_country_code(262);
- re_number.set_national_number(262123456ULL);
-@@ -1631,13 +1631,13 @@
- EXPECT_TRUE(IsViablePhoneNumber("0800-4-PIZZA"));
- // Only one or two digits before possible punctuation followed by more digits.
- // The punctuation used here is the unicode character u+3000.
-- EXPECT_TRUE(IsViablePhoneNumber("1 34"));
-- EXPECT_FALSE(IsViablePhoneNumber("1 3+4"));
-+ EXPECT_TRUE(IsViablePhoneNumber("1\xE3\x80\x80" "34"));
-+ EXPECT_FALSE(IsViablePhoneNumber("1\xE3\x80\x80" "3+4"));
- // Unicode variants of possible starting character and other allowed
- // punctuation/digits.
-- EXPECT_TRUE(IsViablePhoneNumber("(1) 3456789"));
-+ EXPECT_TRUE(IsViablePhoneNumber("\xEF\xBC\x88" "1\xEF\xBC\x89\xE3\x80\x80" "3456789"));
- // Testing a leading + is okay.
-- EXPECT_TRUE(IsViablePhoneNumber("+1) 3456789"));
-+ EXPECT_TRUE(IsViablePhoneNumber("+1\xEF\xBC\x89\xE3\x80\x80" "3456789"));
- }
-
- TEST_F(PhoneNumberUtilTest, NormaliseRemovePunctuation) {
-@@ -1659,13 +1659,13 @@
- TEST_F(PhoneNumberUtilTest, NormaliseOtherDigits) {
- // The first digit is a full-width 2, the last digit is an Arabic-indic digit
- // 5.
-- string input_number("25٥");
-+ string input_number("\xEF\xBC\x92" "5\xD9\xA5");
- Normalize(&input_number);
- static const string kExpectedOutput("255");
- EXPECT_EQ(kExpectedOutput, input_number)
- << "Conversion did not correctly replace non-latin digits";
- // The first digit is an Eastern-Arabic 5, the latter an Eastern-Arabic 0.
-- string eastern_arabic_input_number("۵2۰");
-+ string eastern_arabic_input_number("\xDB\xB5" "2\xDB\xB0");
- Normalize(&eastern_arabic_input_number);
- static const string kExpectedOutput2("520");
- EXPECT_EQ(kExpectedOutput2, eastern_arabic_input_number)
-@@ -2321,21 +2321,21 @@
- // Using a full-width plus sign.
- test_number.Clear();
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("+1 (650) 333-6000",
-+ phone_util_.Parse("\xEF\xBC\x8B" "1 (650) 333-6000",
- RegionCode::SG(), &test_number));
- EXPECT_EQ(us_number, test_number);
- // The whole number, including punctuation, is here represented in full-width
- // form.
- test_number.Clear();
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("+1 (650) 333-6000",
-+ phone_util_.Parse("\xEF\xBC\x8B\xEF\xBC\x91\xE3\x80\x80\xEF\xBC\x88\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90\xEF\xBC\x89\xE3\x80\x80\xEF\xBC\x93\xEF\xBC\x93\xEF\xBC\x93\xEF\xBC\x8D\xEF\xBC\x96\xEF\xBC\x90\xEF\xBC\x90\xEF\xBC\x90",
- RegionCode::SG(), &test_number));
- EXPECT_EQ(us_number, test_number);
-
- // Using the U+30FC dash.
- test_number.Clear();
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("+1 (650) 333ー6000",
-+ phone_util_.Parse("\xEF\xBC\x8B\xEF\xBC\x91\xE3\x80\x80\xEF\xBC\x88\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90\xEF\xBC\x89\xE3\x80\x80\xEF\xBC\x93\xEF\xBC\x93\xEF\xBC\x93\xE3\x83\xBC\xEF\xBC\x96\xEF\xBC\x90\xEF\xBC\x90\xEF\xBC\x90",
- RegionCode::SG(), &test_number));
- EXPECT_EQ(us_number, test_number);
- }
-@@ -2575,7 +2575,7 @@
- // Test with full-width plus.
- result_proto.Clear();
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("+64 3 331 6005", RegionCode::ZZ(),
-+ phone_util_.Parse("\xEF\xBC\x8B" "64 3 331 6005", RegionCode::ZZ(),
- &result_proto));
- EXPECT_EQ(nz_number, result_proto);
- // Test with normal plus but leading characters that need to be stripped.
-@@ -2733,7 +2733,7 @@
- EXPECT_EQ(us_with_extension, test_number);
- test_number.Clear();
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("(800) 901-3355 ,extensión 7246433",
-+ phone_util_.Parse("(800) 901-3355 ,extensi\xC3\xB3n 7246433",
- RegionCode::US(),
- &test_number));
- EXPECT_EQ(us_with_extension, test_number);
-@@ -2741,7 +2741,7 @@
- // Repeat with the small letter o with acute accent created by combining
- // characters.
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("(800) 901-3355 ,extensión 7246433",
-+ phone_util_.Parse("(800) 901-3355 ,extensio\xCC\x81n 7246433",
- RegionCode::US(),
- &test_number));
- EXPECT_EQ(us_with_extension, test_number);
-Index: D:/src/src/third_party/libphonenumber/cpp/src/phonenumberutil.cc
-===================================================================
---- phonenumberutil.cc (revision 186)
-+++ phonenumberutil.cc (working copy)
-@@ -72,7 +72,7 @@
- // The kPlusSign signifies the international prefix.
- const char kPlusSign[] = "+";
-
--const char kPlusChars[] = "++";
-+const char kPlusChars[] = "+\xEF\xBC\x8B";
- scoped_ptr<const reg_exp::RegularExpression> plus_chars_pattern;
-
- const char kRfc3966ExtnPrefix[] = ";ext=";
-@@ -88,7 +88,7 @@
-
- // Digits accepted in phone numbers.
- // Both Arabic-Indic and Eastern Arabic-Indic are supported.
--const char kValidDigits[] = "0-90-9٠-٩۰-۹";
-+const char kValidDigits[] = "0-9\xEF\xBC\x90-\xEF\xBC\x99\xD9\xA0-\xD9\xA9\xDB\xB0-\xDB\xB9";
- // We accept alpha characters in phone numbers, ASCII only. We store lower-case
- // here only since our regular expressions are case-insensitive.
- const char kValidAlpha[] = "a-z";
-@@ -140,7 +140,7 @@
- // itself. In emacs, you can use M-x unicode-what to query information about the
- // unicode character.
- const char kValidPunctuation[] =
-- "-x‐-―−ー--/  ​⁠ ()()[].\\[\\]/~⁓∼~";
-+ "-x\xE2\x80\x90-\xE2\x80\x95\xE2\x88\x92\xE3\x83\xBC\xEF\xBC\x8D-\xEF\xBC\x8F \xC2\xA0\xE2\x80\x8B\xE2\x81\xA0\xE3\x80\x80()\xEF\xBC\x88\xEF\xBC\x89\xEF\xBC\xBB\xEF\xBC\xBD.\\[\\]/~\xE2\x81\x93\xE2\x88\xBC\xEF\xBD\x9E";
-
- // Regular expression of viable phone numbers. This is location independent.
- // Checks we have at least three leading digits, and only valid punctuation,
-@@ -454,7 +454,7 @@
- // defined order.
- void CreateRegularExpressions() {
- unique_international_prefix.reset(
-- reg_exp::CreateRegularExpression("[\\d]+(?:[~⁓∼~][\\d]+)?"));
-+ reg_exp::CreateRegularExpression("[\\d]+(?:[~\xE2\x81\x93\xE2\x88\xBC\xEF\xBD\x9E][\\d]+)?"));
- first_group_capturing_pattern.reset(
- reg_exp::CreateRegularExpression("(\\$1)"));
- carrier_code_pattern.reset(
-@@ -476,16 +476,16 @@
- StrCat("[", kPlusChars, "]*(?:[", kValidPunctuation, "]*[", kValidDigits,
- "]){3,}[", kValidAlpha, kValidPunctuation, kValidDigits, "]*")));
- // Canonical-equivalence doesn't seem to be an option with RE2, so we allow
-- // two options for representing the ó - the character itself, and one in the
-+ // two options for representing the \xC3\xB3 - the character itself, and one in the
- // unicode decomposed form with the combining acute accent. Note that there
- // are currently three capturing groups for the extension itself - if this
- // number is changed, MaybeStripExtension needs to be updated.
- const string capturing_extn_digits = StrCat("([", kValidDigits, "]{1,7})");
- known_extn_patterns.reset(new string(
- StrCat(kRfc3966ExtnPrefix, capturing_extn_digits, "|"
-- "[  \\t,]*(?:ext(?:ensi(?:ó?|ó))?n?|extn?|[,xx##~~]|"
-- "int|int|anexo)"
-- "[:\\..]?[  \\t,-]*", capturing_extn_digits, "#?|"
-+ "[ \xC2\xA0\\t,]*(?:ext(?:ensi(?:o\xCC\x81?|\xC3\xB3))?n?|\xEF\xBD\x85\xEF\xBD\x98\xEF\xBD\x94\xEF\xBD\x8E?|[,x\xEF\xBD\x98#\xEF\xBC\x83~\xEF\xBD\x9E]|"
-+ "int|\xEF\xBD\x89\xEF\xBD\x8E\xEF\xBD\x94|anexo)"
-+ "[:\\.\xEF\xBC\x8E]?[ \xC2\xA0\\t,-]*", capturing_extn_digits, "#?|"
- "[- ]+([", kValidDigits, "]{1,5})#")));
- extn_pattern.reset(reg_exp::CreateRegularExpression(
- StrCat("(?i)(?:", *known_extn_patterns, ")$").c_str()));
-@@ -509,35 +509,35 @@
- all_plus_number_grouping_symbols->insert(
- make_pair(ToUnicodeCodepoint("-"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("-"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xEF\xBC\x8D"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("‐"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x90"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("‑"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x91"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("‒"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x92"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("–"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x93"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("—"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x94"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("―"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x95"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("−"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x88\x92"), '-'));
- all_plus_number_grouping_symbols->insert(
- make_pair(ToUnicodeCodepoint("/"), '/'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("/"), '/'));
-+ make_pair(ToUnicodeCodepoint("\xEF\xBC\x8F"), '/'));
- all_plus_number_grouping_symbols->insert(
- make_pair(ToUnicodeCodepoint(" "), ' '));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint(" "), ' '));
-+ make_pair(ToUnicodeCodepoint("\xE3\x80\x80"), ' '));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("⁠"), ' '));
-+ make_pair(ToUnicodeCodepoint("\xE2\x81\xA0"), ' '));
- all_plus_number_grouping_symbols->insert(
- make_pair(ToUnicodeCodepoint("."), '.'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("."), '.'));
-+ make_pair(ToUnicodeCodepoint("\xEF\xBC\x8E"), '.'));
- // Only the upper-case letters are added here - the lower-case versions are
- // added programmatically.
- alpha_mappings->insert(make_pair(ToUnicodeCodepoint("A"), '2'));
-@@ -849,7 +849,7 @@
- // Note here that all NANPA formatting rules are contained by US, so we use
- // that to format NANPA numbers. The same applies to Russian Fed regions -
- // rules are contained by Russia. French Indian Ocean country rules are
-- // contained by Réunion.
-+ // contained by R\xC3\xA9union.
- string region_code;
- GetRegionCodeForCountryCode(country_calling_code, &region_code);
- if (!HasValidRegionCode(region_code, country_calling_code,
-@@ -1015,7 +1015,7 @@
- // For regions that share a country calling code, the country calling code
- // need not be dialled. This also applies when dialling within a region, so
- // this if clause covers both these cases.
-- // Technically this is the case for dialling from la Réunion to other
-+ // Technically this is the case for dialling from la R\xC3\xA9union to other
- // overseas departments of France (French Guiana, Martinique, Guadeloupe),
- // but not vice versa - so we don't cover this edge case for now and for
- // those cases return the version including country calling code.
diff --git a/third_party/libphonenumber/patches/version186.patch b/third_party/libphonenumber/patches/version186.patch
deleted file mode 100644
index c2885e5..0000000
--- a/third_party/libphonenumber/patches/version186.patch
+++ /dev/null
@@ -1,1177 +0,0 @@
-Index: regexp_adapter.h
-===================================================================
---- regexp_adapter.h (revision 0)
-+++ regexp_adapter.h (revision 0)
-@@ -0,0 +1,96 @@
-+// Copyright (C) 2011 Google Inc.
-+//
-+// Licensed under the Apache License, Version 2.0 (the "License");
-+// you may not use this file except in compliance with the License.
-+// You may obtain a copy of the License at
-+//
-+// http://www.apache.org/licenses/LICENSE-2.0
-+//
-+// Unless required by applicable law or agreed to in writing, software
-+// distributed under the License is distributed on an "AS IS" BASIS,
-+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-+// See the License for the specific language governing permissions and
-+// limitations under the License.
-+
-+// Author: George Yakovlev
-+
-+#ifndef I18N_PHONENUMBERS_REGEXP_ADAPTER_H_
-+#define I18N_PHONENUMBERS_REGEXP_ADAPTER_H_
-+
-+#include <string>
-+
-+// Regexp adapter to allow pluggable regexp engine, as it is external to
-+// libphonenumber.
-+
-+namespace reg_exp {
-+
-+// The reg exp input class.
-+// It supports only functions used in phonelibrary.
-+class RegularExpressionInput {
-+ public:
-+ virtual ~RegularExpressionInput() {};
-+
-+ // Matches string to regular expression, returns true if expression was
-+ // matched, false otherwise, advances position in the match.
-+ // |reg_exp| - expression to be matched.
-+ // |beginning_only| - if true match would be successfull only if appears at
-+ // the beginning of the tested region of the string.
-+ // |matched_string1| - successfully matched first string. Can be NULL.
-+ // |matched_string2| - successfully matched second string. Can be NULL.
-+ virtual bool ConsumeRegExp(std::string const& reg_exp,
-+ bool beginning_only,
-+ std::string* matched_string1,
-+ std::string* matched_string2) = 0;
-+ // Convert unmatched input to a string.
-+ virtual std::string ToString() const = 0;
-+};
-+
-+// The regular expression class.
-+// It supports only functions used in phonelibrary.
-+class RegularExpression {
-+ public:
-+ RegularExpression() {}
-+ virtual ~RegularExpression() {}
-+
-+ // Matches string to regular expression, returns true if expression was
-+ // matched, false otherwise, advances position in the match.
-+ // |input_string| - string to be searched.
-+ // |beginning_only| - if true match would be successfull only if appears at
-+ // the beginning of the tested region of the string.
-+ // |matched_string1| - successfully matched first string. Can be NULL.
-+ // |matched_string2| - successfully matched second string. Can be NULL.
-+ // |matched_string3| - successfully matched third string. Can be NULL.
-+ virtual bool Consume(RegularExpressionInput* input_string,
-+ bool beginning_only,
-+ std::string* matched_string1 = NULL,
-+ std::string* matched_string2 = NULL,
-+ std::string* matched_string3 = NULL) const = 0;
-+
-+
-+ // Matches string to regular expression, returns true if expression was
-+ // matched, false otherwise.
-+ // |input_string| - string to be searched.
-+ // |full_match| - if true match would be successfull only if it matches the
-+ // complete string.
-+ // |matched_string| - successfully matched string. Can be NULL.
-+ virtual bool Match(const char* input_string,
-+ bool full_match,
-+ std::string* matched_string) const = 0;
-+
-+ // Replaces match(es) in the |string_to_process|. if |global| is true,
-+ // replaces all the matches, only the first match otherwise.
-+ // |replacement_string| - text the matches are replaced with.
-+ // Returns true if expression successfully processed through the string,
-+ // even if no actual replacements were made. Returns false in case of an
-+ // error.
-+ virtual bool Replace(std::string* string_to_process,
-+ bool global,
-+ const char* replacement_string) const = 0;
-+};
-+
-+RegularExpressionInput* CreateRegularExpressionInput(const char* utf8_input);
-+RegularExpression* CreateRegularExpression(const char* utf8_regexp);
-+
-+} // namespace reg_exp
-+
-+#endif // I18N_PHONENUMBERS_REGEXP_ADAPTER_H_
-
-Property changes on: regexp_adapter.h
-___________________________________________________________________
-Added: svn:eol-style
- + LF
-
-Index: regexp_adapter_re2.cc
-===================================================================
---- regexp_adapter_re2.cc (revision 0)
-+++ regexp_adapter_re2.cc (revision 0)
-@@ -0,0 +1,192 @@
-+// Copyright (C) 2011 Google Inc.
-+//
-+// Licensed under the Apache License, Version 2.0 (the "License");
-+// you may not use this file except in compliance with the License.
-+// You may obtain a copy of the License at
-+//
-+// http://www.apache.org/licenses/LICENSE-2.0
-+//
-+// Unless required by applicable law or agreed to in writing, software
-+// distributed under the License is distributed on an "AS IS" BASIS,
-+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-+// See the License for the specific language governing permissions and
-+// limitations under the License.
-+
-+// Author: George Yakovlev
-+#include "regexp_adapter.h"
-+
-+#include <re2/re2.h>
-+#include <re2/stringpiece.h>
-+#include <re2/re2.h>
-+
-+namespace {
-+scoped_ptr<RE2Cache> re2_cache;
-+} // namespace
-+
-+class RE2RegularExpressionInput : public RegularExpressionInput {
-+ public:
-+ RE2RegularExpressionInput(const char* utf8_input);
-+
-+ virtual bool ConsumeRegExp(std::string const& reg_exp,
-+ bool beginning_only,
-+ std::string* matched_string1,
-+ std::string* matched_string2);
-+ virtual std::string ToString() const;
-+ private:
-+ StringPiece utf8_input_;
-+};
-+
-+
-+class RE2RegularExpression : public reg_exp::RegularExpression {
-+ public:
-+ RE2RegularExpression(const char* utf8_regexp);
-+
-+ virtual bool Consume(reg_exp::RegularExpressionInput* input_string,
-+ bool beginning_only,
-+ std::string* matched_string1,
-+ std::string* matched_string2,
-+ std::string* matched_string3) const;
-+
-+ virtual bool Match(const char* input_string,
-+ bool full_match,
-+ std::string* matched_string) const;
-+
-+ virtual bool Replace(std::string* string_to_process,
-+ bool global,
-+ const char* replacement_string) const;
-+ private:
-+ RE2 utf8_regexp_;
-+};
-+
-+RE2RegularExpressionInput::RE2RegularExpressionInput(const char* utf8_input)
-+ : utf8_input_(utf8_input) {
-+ DCHECK(utf8_input);
-+}
-+
-+bool RE2RegularExpressionInput::ConsumeRegExp(std::string const& reg_exp,
-+ bool beginning_only,
-+ std::string* matched_string1,
-+ std::string* matched_string2) {
-+ if (beginning_only) {
-+ if (matched_string2)
-+ return RE2::Consume(&utf8_input_,
-+ RE2Cache::ScopedAccess(re2_cache.get(), reg_exp),
-+ matched_string1, matched_string2);
-+ else if (matched_string1)
-+ return RE2::Consume(&utf8_input_,
-+ RE2Cache::ScopedAccess(re2_cache.get(), reg_exp),
-+ matched_string1);
-+ else
-+ return RE2::Consume(&utf8_input_,
-+ RE2Cache::ScopedAccess(re2_cache.get(), reg_exp));
-+ } else {
-+ if (matched_string2)
-+ return RE2::FindAndConsume(&utf8_input_,
-+ RE2Cache::ScopedAccess(re2_cache.get(),
-+ reg_exp),
-+ matched_string1, matched_string2);
-+ else if (matched_string1)
-+ return RE2::FindAndConsume(&utf8_input_,
-+ RE2Cache::ScopedAccess(re2_cache.get(),
-+ reg_exp),
-+ matched_string1);
-+ else
-+ return RE2::FindAndConsume(&utf8_input_,
-+ RE2Cache::ScopedAccess(re2_cache.get(),
-+ reg_exp));
-+ }
-+}
-+
-+std::string RE2RegularExpressionInput::ToString() const {
-+ utf8_input_.ToString();
-+}
-+
-+RE2RegularExpression::RE2RegularExpression(const char* utf8_regexp)
-+ : utf8_regexp_(utf8_regexp) {
-+ DCHECK(utf8_regexp);
-+}
-+
-+bool RE2RegularExpression::Consume(RegularExpressionInput* input_string,
-+ bool beginning_only,
-+ std::string* matched_string1,
-+ std::string* matched_string2,
-+ std::string* matched_string3) const {
-+ DCHECK(input_string);
-+ // matched_string1 may be NULL
-+ // matched_string2 may be NULL
-+ if (beginning_only) {
-+ if (matched_string3) {
-+ return RE2::Consume(input_string, utf8_regexp_,
-+ matched_string1, matched_string2, matched_string3);
-+ } else if (matched_string2) {
-+ return RE2::Consume(input_string, utf8_regexp_,
-+ matched_string1, matched_string2);
-+ } else if (matched_string1) {
-+ return RE2::Consume(input_string, utf8_regexp_, matched_string1);
-+ } else {
-+ return RE2::Consume(input_string, utf8_regexp_);
-+ }
-+ } else {
-+ if (matched_string3) {
-+ return RE2::FindAndConsume(input_string, utf8_regexp_,
-+ matched_string1, matched_string2,
-+ matched_string3);
-+ } else if (matched_string2) {
-+ return RE2::FindAndConsume(input_string, utf8_regexp_,
-+ matched_string1, matched_string2);
-+ } else if (matched_string1) {
-+ return RE2::FindAndConsume(input_string, utf8_regexp_, matched_string1);
-+ } else {
-+ return RE2::FindAndConsume(input_string, utf8_regexp_);
-+ }
-+ }
-+}
-+
-+bool RE2RegularExpression::Match(const char* input_string,
-+ bool full_match,
-+ std::string* matched_string) const {
-+ DCHECK(input_string);
-+ // matched_string may be NULL
-+ if (full_match) {
-+ if (matched_string)
-+ return RE2::FullMatch(input_string, matched_string);
-+ else
-+ return RE2::FullMatch(input_string);
-+ } else {
-+ if (matched_string)
-+ return RE2::PartialMatch(input_string, matched_string);
-+ else
-+ return RE2::PartialMatch(input_string);
-+ }
-+}
-+
-+bool RE2RegularExpression::Replace(std::string* string_to_process,
-+ bool global,
-+ const char* replacement_string) const {
-+ DCHECK(string_to_process);
-+ DCHECK(replacement_string);
-+ if (global) {
-+ StringPiece str(replacement_string);
-+ return RE2::GlobalReplace(string_to_process, str);
-+ } else {
-+ return RE2::Replace(string_to_process, replacement_string);
-+ }
-+}
-+
-+
-+namespace reg_exp {
-+
-+RegularExpressionInput* CreateRegularExpressionInput(const char* utf8_input) {
-+ if (!re2_cache.get())
-+ re2_cache.reset(new RE2Cache(64));
-+ return new RE2RegularExpressionInput(utf8_input);
-+}
-+
-+RegularExpression* CreateRegularExpression(const char* utf8_regexp) {
-+ if (!re2_cache.get())
-+ re2_cache.reset(new RE2Cache(64));
-+ return new RE2RegularExpression(utf8_regexp);
-+}
-+
-+} // namespace reg_exp
-+
-
-Property changes on: regexp_adapter_re2.cc
-___________________________________________________________________
-Added: svn:eol-style
- + LF
-
-Index: phonenumberutil_test.cc
-===================================================================
---- phonenumberutil_test.cc (revision 186)
-+++ phonenumberutil_test.cc (working copy)
-@@ -21,12 +21,12 @@
- #include <string>
-
- #include <gtest/gtest.h>
--#include <re2/re2.h>
-
- #include "phonemetadata.pb.h"
- #include "phonenumber.h"
- #include "phonenumber.pb.h"
- #include "phonenumberutil.h"
-+#include "regexp_adapter.h"
- #include "test_metadata.h"
-
- namespace i18n {
-Index: phonenumberutil.cc
-===================================================================
---- phonenumberutil.cc (revision 186)
-+++ phonenumberutil.cc (working copy)
-@@ -25,8 +25,6 @@
- #include <vector>
-
- #include <google/protobuf/message_lite.h>
--#include <re2/re2.h>
--#include <re2/stringpiece.h>
- #include <unicode/errorcode.h>
- #include <unicode/translit.h>
-
-@@ -38,7 +36,7 @@
- #include "phonemetadata.pb.h"
- #include "phonenumber.h"
- #include "phonenumber.pb.h"
--#include "re2_cache.h"
-+#include "regexp_adapter.h"
- #include "stringutil.h"
- #include "utf/unicodetext.h"
- #include "utf/utf.h"
-@@ -54,14 +52,11 @@
- using std::stringstream;
-
- using google::protobuf::RepeatedPtrField;
--using re2::StringPiece;
-
- namespace {
-
- scoped_ptr<LoggerAdapter> logger;
-
--scoped_ptr<RE2Cache> re2_cache;
--
- // These objects are created in the function InitializeStaticMapsAndSets.
-
- // These mappings map a character (key) to a specific digit that should replace
-@@ -78,7 +73,7 @@
- const char kPlusSign[] = "+";
-
- const char kPlusChars[] = "++";
--scoped_ptr<const RE2> plus_chars_pattern;
-+scoped_ptr<const reg_exp::RegularExpression> plus_chars_pattern;
-
- const char kRfc3966ExtnPrefix[] = ";ext=";
-
-@@ -89,7 +84,7 @@
- // prefixes in a region, they will be represented as a regex string that always
- // contains character(s) other than ASCII digits.
- // Note this regex also includes tilde, which signals waiting for the tone.
--scoped_ptr<const RE2> unique_international_prefix;
-+scoped_ptr<const reg_exp::RegularExpression> unique_international_prefix;
-
- // Digits accepted in phone numbers.
- // Both Arabic-Indic and Eastern Arabic-Indic are supported.
-@@ -97,8 +92,8 @@
- // We accept alpha characters in phone numbers, ASCII only. We store lower-case
- // here only since our regular expressions are case-insensitive.
- const char kValidAlpha[] = "a-z";
--scoped_ptr<const RE2> capturing_digit_pattern;
--scoped_ptr<const RE2> capturing_ascii_digits_pattern;
-+scoped_ptr<const reg_exp::RegularExpression> capturing_digit_pattern;
-+scoped_ptr<const reg_exp::RegularExpression> capturing_ascii_digits_pattern;
-
- // Regular expression of acceptable characters that may start a phone number
- // for the purposes of parsing. This allows us to strip away meaningless
-@@ -110,7 +105,7 @@
- // a number. The string starting with this valid character is captured.
- // This corresponds to VALID_START_CHAR in the java version.
- scoped_ptr<const string> valid_start_char;
--scoped_ptr<const RE2> valid_start_char_pattern;
-+scoped_ptr<const reg_exp::RegularExpression> valid_start_char_pattern;
-
- // Regular expression of characters typically used to start a second phone
- // number for the purposes of parsing. This allows us to strip off parts of
-@@ -121,7 +116,8 @@
- // preceding this is captured.
- // This corresponds to SECOND_NUMBER_START in the java version.
- const char kCaptureUpToSecondNumberStart[] = "(.*)[\\\\/] *x";
--scoped_ptr<const RE2> capture_up_to_second_number_start_pattern;
-+scoped_ptr<const reg_exp::RegularExpression>
-+ capture_up_to_second_number_start_pattern;
-
- // Regular expression of trailing characters that we want to remove. We remove
- // all characters that are not alpha or numerical characters. The hash
-@@ -130,7 +126,7 @@
- // number if this was a match.
- // This corresponds to UNWANTED_END_CHARS in the java version.
- const char kUnwantedEndChar[] = "[^\\p{N}\\p{L}#]";
--scoped_ptr<const RE2> unwanted_end_char_pattern;
-+scoped_ptr<const reg_exp::RegularExpression> unwanted_end_char_pattern;
-
- // Regular expression of acceptable punctuation found in phone numbers. This
- // excludes punctuation found as a leading character only. This consists of
-@@ -177,20 +173,20 @@
- scoped_ptr<const string> known_extn_patterns;
- // Regexp of all known extension prefixes used by different regions followed
- // by 1 or more valid digits, for use when parsing.
--scoped_ptr<const RE2> extn_pattern;
-+scoped_ptr<const reg_exp::RegularExpression> extn_pattern;
-
- // We append optionally the extension pattern to the end here, as a valid phone
- // number may have an extension prefix appended, followed by 1 or more digits.
--scoped_ptr<const RE2> valid_phone_number_pattern;
-+scoped_ptr<const reg_exp::RegularExpression> valid_phone_number_pattern;
-
- // We use this pattern to check if the phone number has at least three letters
- // in it - if so, then we treat it as a number where some phone-number digits
- // are represented by letters.
--scoped_ptr<const RE2> valid_alpha_phone_pattern;
-+scoped_ptr<const reg_exp::RegularExpression> valid_alpha_phone_pattern;
-
--scoped_ptr<const RE2> first_group_capturing_pattern;
-+scoped_ptr<const reg_exp::RegularExpression> first_group_capturing_pattern;
-
--scoped_ptr<const RE2> carrier_code_pattern;
-+scoped_ptr<const reg_exp::RegularExpression> carrier_code_pattern;
-
- void TransformRegularExpressionToRE2Syntax(string* regex) {
- DCHECK(regex);
-@@ -280,18 +276,19 @@
- it = available_formats.begin(); it != available_formats.end(); ++it) {
- int size = it->leading_digits_pattern_size();
- if (size > 0) {
-- StringPiece number_copy(number_for_leading_digits_match);
-+ scoped_ptr<reg_exp::RegularExpressionInput>
-+ number_copy(reg_exp::CreateRegularExpressionInput(
-+ number_for_leading_digits_match.c_str()));
- // We always use the last leading_digits_pattern, as it is the most
- // detailed.
-- if (!RE2::Consume(&number_copy,
-- RE2Cache::ScopedAccess(
-- re2_cache.get(),
-- it->leading_digits_pattern(size - 1)))) {
-+ if (!number_copy->ConsumeRegExp(it->leading_digits_pattern(size - 1),
-+ true, NULL, NULL)) {
- continue;
- }
- }
-- RE2Cache::ScopedAccess pattern_to_match(re2_cache.get(), it->pattern());
-- if (RE2::FullMatch(national_number, pattern_to_match)) {
-+ scoped_ptr<reg_exp::RegularExpression> pattern_to_match(
-+ reg_exp::CreateRegularExpression(it->pattern().c_str()));
-+ if (pattern_to_match->Match(national_number.c_str(), true, NULL)) {
- string formatting_pattern(it->format());
- if (number_format == PhoneNumberUtil::NATIONAL &&
- carrier_code.length() > 0 &&
-@@ -299,11 +296,12 @@
- // Replace the $CC in the formatting rule with the desired carrier code.
- string carrier_code_formatting_rule =
- it->domestic_carrier_code_formatting_rule();
-- RE2::Replace(&carrier_code_formatting_rule, *carrier_code_pattern,
-- carrier_code);
-+ carrier_code_pattern->Replace(&carrier_code_formatting_rule,
-+ false, carrier_code.c_str());
- TransformRegularExpressionToRE2Syntax(&carrier_code_formatting_rule);
-- RE2::Replace(&formatting_pattern, *first_group_capturing_pattern,
-- carrier_code_formatting_rule);
-+ first_group_capturing_pattern->Replace(&formatting_pattern,
-+ false,
-+ carrier_code_formatting_rule.c_str());
- } else {
- // Use the national prefix formatting rule instead.
- string national_prefix_formatting_rule =
-@@ -315,14 +313,15 @@
- // should be formatted at this point.
- TransformRegularExpressionToRE2Syntax(
- &national_prefix_formatting_rule);
-- RE2::Replace(&formatting_pattern, *first_group_capturing_pattern,
-- national_prefix_formatting_rule);
-+ first_group_capturing_pattern->Replace(&formatting_pattern,
-+ false,
-+ national_prefix_formatting_rule.c_str());
- }
- }
- TransformRegularExpressionToRE2Syntax(&formatting_pattern);
- formatted_number->assign(national_number);
-- RE2::GlobalReplace(formatted_number, pattern_to_match,
-- formatting_pattern);
-+ pattern_to_match->Replace(formatted_number, true,
-+ formatting_pattern.c_str());
- return;
- }
- }
-@@ -361,12 +360,14 @@
-
- bool IsNumberMatchingDesc(const string& national_number,
- const PhoneNumberDesc& number_desc) {
-- return (RE2::FullMatch(national_number,
-- RE2Cache::ScopedAccess(re2_cache.get(),
-- number_desc.possible_number_pattern())) &&
-- RE2::FullMatch(national_number,
-- RE2Cache::ScopedAccess(re2_cache.get(),
-- number_desc.national_number_pattern())));
-+ scoped_ptr<const reg_exp::RegularExpression>
-+ possible_pattern(reg_exp::CreateRegularExpression(
-+ number_desc.possible_number_pattern().c_str()));
-+ scoped_ptr<const reg_exp::RegularExpression>
-+ national_pattern(reg_exp::CreateRegularExpression(
-+ number_desc.national_number_pattern().c_str()));
-+ return (possible_pattern->Match(national_number.c_str(), true, NULL) &&
-+ national_pattern->Match(national_number.c_str(), true, NULL));
- }
-
- PhoneNumberUtil::PhoneNumberType GetNumberTypeHelper(
-@@ -452,18 +453,25 @@
- // Initialisation helper function used to populate the regular expressions in a
- // defined order.
- void CreateRegularExpressions() {
-- unique_international_prefix.reset(new RE2("[\\d]+(?:[~⁓∼~][\\d]+)?"));
-- first_group_capturing_pattern.reset(new RE2("(\\$1)"));
-- carrier_code_pattern.reset(new RE2("\\$CC"));
-- capturing_digit_pattern.reset(new RE2(StrCat("([", kValidDigits, "])")));
-- capturing_ascii_digits_pattern.reset(new RE2("(\\d+)"));
-+ unique_international_prefix.reset(
-+ reg_exp::CreateRegularExpression("[\\d]+(?:[~⁓∼~][\\d]+)?"));
-+ first_group_capturing_pattern.reset(
-+ reg_exp::CreateRegularExpression("(\\$1)"));
-+ carrier_code_pattern.reset(
-+ reg_exp::CreateRegularExpression("\\$CC"));
-+ capturing_digit_pattern.reset(
-+ reg_exp::CreateRegularExpression(
-+ StrCat("([", kValidDigits, "])").c_str()));
-+ capturing_ascii_digits_pattern.reset(
-+ reg_exp::CreateRegularExpression("(\\d+)"));
- valid_start_char.reset(new string(StrCat(
- "[", kPlusChars, kValidDigits, "]")));
-- valid_start_char_pattern.reset(new RE2(*valid_start_char));
-- capture_up_to_second_number_start_pattern.reset(new RE2(
-- kCaptureUpToSecondNumberStart));
-- unwanted_end_char_pattern.reset(new RE2(
-- kUnwantedEndChar));
-+ valid_start_char_pattern.reset(
-+ reg_exp::CreateRegularExpression(valid_start_char->c_str()));
-+ capture_up_to_second_number_start_pattern.reset(
-+ reg_exp::CreateRegularExpression(kCaptureUpToSecondNumberStart));
-+ unwanted_end_char_pattern.reset(
-+ reg_exp::CreateRegularExpression(kUnwantedEndChar));
- valid_phone_number.reset(new string(
- StrCat("[", kPlusChars, "]*(?:[", kValidPunctuation, "]*[", kValidDigits,
- "]){3,}[", kValidAlpha, kValidPunctuation, kValidDigits, "]*")));
-@@ -479,17 +487,19 @@
- "int|int|anexo)"
- "[:\\..]?[  \\t,-]*", capturing_extn_digits, "#?|"
- "[- ]+([", kValidDigits, "]{1,5})#")));
-- extn_pattern.reset(new RE2(StrCat("(?i)(?:", *known_extn_patterns, ")$")));
-- valid_phone_number_pattern.reset(new RE2(
-- StrCat("(?i)", *valid_phone_number, "(?:", *known_extn_patterns, ")?")));
-- valid_alpha_phone_pattern.reset(new RE2(
-- StrCat("(?i)(?:.*?[", kValidAlpha, "]){3}")));
-- plus_chars_pattern.reset(new RE2(StrCat("[", kPlusChars, "]+")));
-+ extn_pattern.reset(reg_exp::CreateRegularExpression(
-+ StrCat("(?i)(?:", *known_extn_patterns, ")$").c_str()));
-+ valid_phone_number_pattern.reset(reg_exp::CreateRegularExpression(
-+ StrCat("(?i)", *valid_phone_number, "(?:", *known_extn_patterns,
-+ ")?").c_str()));
-+ valid_alpha_phone_pattern.reset(reg_exp::CreateRegularExpression(
-+ StrCat("(?i)(?:.*?[", kValidAlpha, "]){3}").c_str()));
-+ plus_chars_pattern.reset(reg_exp::CreateRegularExpression(
-+ StrCat("[", kPlusChars, "]+").c_str()));
- }
-
- void InitializeStaticMapsAndSets() {
- // Create global objects.
-- re2_cache.reset(new RE2Cache(64));
- all_plus_number_grouping_symbols.reset(new map<char32, char>);
- alpha_mappings.reset(new map<char32, char>);
- all_normalization_mappings.reset(new map<char32, char>);
-@@ -625,36 +635,37 @@
-
- // Strips the IDD from the start of the number if present. Helper function used
- // by MaybeStripInternationalPrefixAndNormalize.
--bool ParsePrefixAsIdd(const RE2& idd_pattern, string* number) {
-+bool ParsePrefixAsIdd(const reg_exp::RegularExpression* idd_pattern,
-+ string* number) {
- DCHECK(number);
-- StringPiece number_copy(*number);
-+ scoped_ptr<reg_exp::RegularExpressionInput> number_copy(
-+ reg_exp::CreateRegularExpressionInput(number->c_str()));
- // First attempt to strip the idd_pattern at the start, if present. We make a
- // copy so that we can revert to the original string if necessary.
-- if (RE2::Consume(&number_copy, idd_pattern)) {
-+ if (idd_pattern->Consume(number_copy.get(), true, NULL, NULL)) {
- // Only strip this if the first digit after the match is not a 0, since
- // country calling codes cannot begin with 0.
- string extracted_digit;
-- if (RE2::PartialMatch(number_copy,
-- *capturing_digit_pattern,
-- &extracted_digit)) {
-+ if (capturing_digit_pattern->Match(number_copy->ToString().c_str(), false,
-+ &extracted_digit)) {
- PhoneNumberUtil::NormalizeDigitsOnly(&extracted_digit);
- if (extracted_digit == "0") {
- return false;
- }
- }
-- number->assign(number_copy.ToString());
-+ number->assign(number_copy->ToString());
- return true;
- }
- return false;
- }
-
- PhoneNumberUtil::ValidationResult TestNumberLengthAgainstPattern(
-- const RE2& number_pattern, const string& number) {
-+ const reg_exp::RegularExpression* number_pattern, const string& number) {
- string extracted_number;
-- if (RE2::FullMatch(number, number_pattern, &extracted_number)) {
-+ if (number_pattern->Match(number.c_str(), true, &extracted_number)) {
- return PhoneNumberUtil::IS_POSSIBLE;
- }
-- if (RE2::PartialMatch(number, number_pattern, &extracted_number)) {
-+ if (number_pattern->Match(number.c_str(), false, &extracted_number)) {
- return PhoneNumberUtil::TOO_LONG;
- } else {
- return PhoneNumberUtil::TOO_SHORT;
-@@ -862,8 +873,10 @@
- PhoneNumberFormat number_format,
- const RepeatedPtrField<NumberFormat>& user_defined_formats,
- string* formatted_number) const {
-- static const RE2 national_prefix_pattern("\\$NP");
-- static const RE2 first_group_pattern("\\$FG");
-+ static scoped_ptr<const reg_exp::RegularExpression>
-+ national_prefix_pattern(reg_exp::CreateRegularExpression("\\$NP"));
-+ static scoped_ptr<const reg_exp::RegularExpression>
-+ first_group_pattern(reg_exp::CreateRegularExpression("\\$FG"));
- DCHECK(formatted_number);
- int country_calling_code = number.country_code();
- // Note GetRegionCodeForCountryCode() is used because formatting information
-@@ -893,10 +906,12 @@
- num_format_copy->MergeFrom(*it);
- if (!national_prefix.empty()) {
- // Replace $NP with national prefix and $FG with the first group ($1).
-- RE2::Replace(&national_prefix_formatting_rule, national_prefix_pattern,
-- national_prefix);
-- RE2::Replace(&national_prefix_formatting_rule, first_group_pattern,
-- "$1");
-+ national_prefix_pattern->Replace(&national_prefix_formatting_rule,
-+ false,
-+ national_prefix.c_str());
-+ first_group_pattern->Replace(&national_prefix_formatting_rule,
-+ false,
-+ "$1");
- num_format_copy->set_national_prefix_formatting_rule(
- national_prefix_formatting_rule);
- } else {
-@@ -1021,7 +1036,8 @@
- // format of the number is returned, unless there is a preferred international
- // prefix.
- string international_prefix_for_formatting(
-- RE2::FullMatch(international_prefix, *unique_international_prefix)
-+ unique_international_prefix->Match(international_prefix.c_str(),
-+ true, NULL)
- ? international_prefix
- : metadata->preferred_international_prefix());
- if (!international_prefix_for_formatting.empty()) {
-@@ -1133,7 +1149,8 @@
- // format of the number is returned, unless there is a preferred international
- // prefix.
- string international_prefix_for_formatting(
-- RE2::FullMatch(international_prefix, *unique_international_prefix)
-+ unique_international_prefix->Match(international_prefix.c_str(),
-+ true, NULL)
- ? international_prefix
- : metadata->preferred_international_prefix());
- if (!international_prefix_for_formatting.empty()) {
-@@ -1179,8 +1196,10 @@
- number, carrier_code, formatted_number);
- if (number_format == RFC3966) {
- // Replace all separators with a "-".
-- static const RE2 separator_pattern(StrCat("[", kValidPunctuation, "]+"));
-- RE2::GlobalReplace(formatted_number, separator_pattern, "-");
-+ scoped_ptr<const reg_exp::RegularExpression> separator_pattern(
-+ reg_exp::CreateRegularExpression(
-+ StrCat("[", kValidPunctuation, "]+").c_str()));
-+ separator_pattern->Replace(formatted_number, true, "-");
- }
- }
-
-@@ -1288,10 +1307,9 @@
- it != region_codes.end(); ++it) {
- const PhoneMetadata* metadata = GetMetadataForRegion(*it);
- if (metadata->has_leading_digits()) {
-- StringPiece number(national_number);
-- if (RE2::Consume(&number,
-- RE2Cache::ScopedAccess(re2_cache.get(),
-- metadata->leading_digits()))) {
-+ scoped_ptr<reg_exp::RegularExpressionInput> number(
-+ reg_exp::CreateRegularExpressionInput(national_number.c_str()));
-+ if (number->ConsumeRegExp(metadata->leading_digits(), true, NULL, NULL)) {
- *region_code = *it;
- return;
- }
-@@ -1367,8 +1385,10 @@
- const string& number_to_parse,
- const string& default_region) const {
- if (!IsValidRegionCode(default_region) && !number_to_parse.empty()) {
-- StringPiece number_as_string_piece(number_to_parse);
-- if (!RE2::Consume(&number_as_string_piece, *plus_chars_pattern)) {
-+ scoped_ptr<reg_exp::RegularExpressionInput> number_as_string_piece(
-+ reg_exp::CreateRegularExpressionInput(number_to_parse.c_str()));
-+ if (!plus_chars_pattern->Consume(number_as_string_piece.get(),
-+ true, NULL, NULL)) {
- return false;
- }
- }
-@@ -1435,8 +1455,6 @@
- return TOO_SHORT_NSN;
- }
- if (country_metadata) {
-- RE2Cache::ScopedAccess valid_number_pattern(re2_cache.get(),
-- country_metadata->general_desc().national_number_pattern());
- string* carrier_code = keep_raw_input ?
- temp_number.mutable_preferred_domestic_carrier_code() : NULL;
- MaybeStripNationalPrefixAndCarrierCode(*country_metadata,
-@@ -1489,7 +1507,7 @@
- for (it = number_as_unicode.begin(); it != number_as_unicode.end(); ++it) {
- len = it.get_utf8(current_char);
- current_char[len] = '\0';
-- if (RE2::FullMatch(current_char, *valid_start_char_pattern)) {
-+ if (valid_start_char_pattern->Match(current_char, true, NULL)) {
- break;
- }
- }
-@@ -1505,7 +1523,7 @@
- for (; reverse_it.base() != it; ++reverse_it) {
- len = reverse_it.get_utf8(current_char);
- current_char[len] = '\0';
-- if (!RE2::FullMatch(current_char, *unwanted_end_char_pattern)) {
-+ if (!unwanted_end_char_pattern->Match(current_char, true, NULL)) {
- break;
- }
- }
-@@ -1521,9 +1539,9 @@
- " left with: " + *extracted_number);
-
- // Now remove any extra numbers at the end.
-- RE2::PartialMatch(*extracted_number,
-- *capture_up_to_second_number_start_pattern,
-- extracted_number);
-+ capture_up_to_second_number_start_pattern->Match(extracted_number->c_str(),
-+ false,
-+ extracted_number);
- }
-
- bool PhoneNumberUtil::IsPossibleNumber(const PhoneNumber& number) const {
-@@ -1569,9 +1587,10 @@
- return IS_POSSIBLE;
- }
- }
-- RE2Cache::ScopedAccess possible_number_pattern(re2_cache.get(),
-- StrCat("(", general_num_desc.possible_number_pattern(), ")"));
-- return TestNumberLengthAgainstPattern(possible_number_pattern,
-+ scoped_ptr<reg_exp::RegularExpression> possible_number_pattern(
-+ reg_exp::CreateRegularExpression(
-+ StrCat("(", general_num_desc.possible_number_pattern(), ")").c_str()));
-+ return TestNumberLengthAgainstPattern(possible_number_pattern.get(),
- national_number);
- }
-
-@@ -1701,13 +1720,16 @@
-
- string formatted_number;
- Format(copied_proto, INTERNATIONAL, &formatted_number);
-- StringPiece i18n_number(formatted_number);
-+ scoped_ptr<reg_exp::RegularExpressionInput> i18n_number(
-+ reg_exp::CreateRegularExpressionInput(formatted_number.c_str()));
- string digit_group;
- string ndc;
- string third_group;
- for (int i = 0; i < 3; ++i) {
-- if (!RE2::FindAndConsume(&i18n_number, *capturing_ascii_digits_pattern,
-- &digit_group)) {
-+ if (!capturing_ascii_digits_pattern->Consume(i18n_number.get(),
-+ false,
-+ &digit_group,
-+ NULL)) {
- // We should find at least three groups.
- return 0;
- }
-@@ -1734,9 +1756,11 @@
- void PhoneNumberUtil::NormalizeDigitsOnly(string* number) {
- DCHECK(number);
- // Delete everything that isn't valid digits.
-- static const RE2 invalid_digits_pattern(StrCat("[^", kValidDigits, "]"));
-- static const StringPiece empty;
-- RE2::GlobalReplace(number, invalid_digits_pattern, empty);
-+ static scoped_ptr<reg_exp::RegularExpression> invalid_digits_pattern(
-+ reg_exp::CreateRegularExpression(StrCat("[^", kValidDigits,
-+ "]").c_str()));
-+ static const char *empty = "";
-+ invalid_digits_pattern->Replace(number, true, empty);
- // Normalize all decimal digits to ASCII digits.
- UParseError error;
- icu::ErrorCode status;
-@@ -1778,7 +1802,7 @@
- string number_copy(number);
- string extension;
- MaybeStripExtension(&number_copy, &extension);
-- return RE2::FullMatch(number_copy, *valid_alpha_phone_pattern);
-+ return valid_alpha_phone_pattern->Match(number_copy.c_str(), true, NULL);
- }
-
- void PhoneNumberUtil::ConvertAlphaCharactersInNumber(string* number) const {
-@@ -1798,7 +1822,7 @@
- // - Arabic-Indic numerals are converted to European numerals.
- void PhoneNumberUtil::Normalize(string* number) const {
- DCHECK(number);
-- if (RE2::PartialMatch(*number, *valid_alpha_phone_pattern)) {
-+ if (valid_alpha_phone_pattern->Match(number->c_str(), false, NULL)) {
- NormalizeHelper(*all_normalization_mappings, true, number);
- }
- NormalizeDigitsOnly(number);
-@@ -1816,7 +1840,7 @@
- logger->Debug("Number too short to be viable:" + number);
- return false;
- }
-- return RE2::FullMatch(number, *valid_phone_number_pattern);
-+ return valid_phone_number_pattern->Match(number.c_str(), true, NULL);
- }
-
- // Strips any international prefix (such as +, 00, 011) present in the number
-@@ -1836,17 +1860,20 @@
- if (number->empty()) {
- return PhoneNumber::FROM_DEFAULT_COUNTRY;
- }
-- StringPiece number_string_piece(*number);
-- if (RE2::Consume(&number_string_piece, *plus_chars_pattern)) {
-- number->assign(number_string_piece.ToString());
-+ scoped_ptr<reg_exp::RegularExpressionInput> number_string_piece(
-+ reg_exp::CreateRegularExpressionInput(number->c_str()));
-+ if (plus_chars_pattern->Consume(number_string_piece.get(), true,
-+ NULL, NULL)) {
-+ number->assign(number_string_piece->ToString());
- // Can now normalize the rest of the number since we've consumed the "+"
- // sign at the start.
- Normalize(number);
- return PhoneNumber::FROM_NUMBER_WITH_PLUS_SIGN;
- }
- // Attempt to parse the first digits as an international prefix.
-- RE2Cache::ScopedAccess idd_pattern(re2_cache.get(), possible_idd_prefix);
-- if (ParsePrefixAsIdd(idd_pattern, number)) {
-+ scoped_ptr<reg_exp::RegularExpression> idd_pattern(
-+ reg_exp::CreateRegularExpression(possible_idd_prefix.c_str()));
-+ if (ParsePrefixAsIdd(idd_pattern.get(), number)) {
- Normalize(number);
- return PhoneNumber::FROM_NUMBER_WITH_IDD;
- }
-@@ -1854,7 +1881,7 @@
- // This shouldn't be done before, since non-numeric characters (+ and ~) may
- // legally be in the international prefix.
- Normalize(number);
-- return ParsePrefixAsIdd(idd_pattern, number)
-+ return ParsePrefixAsIdd(idd_pattern.get(), number)
- ? PhoneNumber::FROM_NUMBER_WITH_IDD
- : PhoneNumber::FROM_DEFAULT_COUNTRY;
- }
-@@ -1879,25 +1906,25 @@
- }
- // We use two copies here since Consume modifies the phone number, and if the
- // first if-clause fails the number will already be changed.
-- StringPiece number_copy(*number);
-- StringPiece number_copy_without_transform(*number);
-+ scoped_ptr<reg_exp::RegularExpressionInput> number_copy(
-+ reg_exp::CreateRegularExpressionInput(number->c_str()));
-+ scoped_ptr<reg_exp::RegularExpressionInput> number_copy_without_transform(
-+ reg_exp::CreateRegularExpressionInput(number->c_str()));
-+
- string number_string_copy(*number);
- string captured_part_of_prefix;
-- RE2Cache::ScopedAccess national_number_rule(
-- re2_cache.get(),
-- metadata.general_desc().national_number_pattern());
-+ scoped_ptr<reg_exp::RegularExpression> national_number_rule(
-+ reg_exp::CreateRegularExpression(
-+ metadata.general_desc().national_number_pattern().c_str()));
- // Attempt to parse the first digits as a national prefix. We make a
- // copy so that we can revert to the original string if necessary.
- const string& transform_rule = metadata.national_prefix_transform_rule();
- if (!transform_rule.empty() &&
-- (RE2::Consume(&number_copy,
-- RE2Cache::ScopedAccess(re2_cache.get(),
-- possible_national_prefix),
-- &carrier_code_temp, &captured_part_of_prefix) ||
-- RE2::Consume(&number_copy,
-- RE2Cache::ScopedAccess(re2_cache.get(),
-- possible_national_prefix),
-- &captured_part_of_prefix)) &&
-+ (number_copy->ConsumeRegExp(possible_national_prefix, true,
-+ &carrier_code_temp,
-+ &captured_part_of_prefix) ||
-+ number_copy->ConsumeRegExp(possible_national_prefix, true,
-+ &captured_part_of_prefix, NULL)) &&
- !captured_part_of_prefix.empty()) {
- string re2_transform_rule(transform_rule);
- TransformRegularExpressionToRE2Syntax(&re2_transform_rule);
-@@ -1905,29 +1932,27 @@
- // have been some part of the prefix that we captured.
- // We make the transformation and check that the resultant number is viable.
- // If so, replace the number and return.
-- RE2::Replace(&number_string_copy,
-- RE2Cache::ScopedAccess(re2_cache.get(),
-- possible_national_prefix),
-- re2_transform_rule);
-- if (RE2::FullMatch(number_string_copy, national_number_rule)) {
-+ scoped_ptr<reg_exp::RegularExpression> possible_national_prefix_rule(
-+ reg_exp::CreateRegularExpression(possible_national_prefix.c_str()));
-+ possible_national_prefix_rule->Replace(&number_string_copy, false,
-+ re2_transform_rule.c_str());
-+ if (national_number_rule->Match(number_string_copy.c_str(), true, NULL)) {
- number->assign(number_string_copy);
- if (carrier_code) {
- carrier_code->assign(carrier_code_temp);
- }
- }
-- } else if (RE2::Consume(&number_copy_without_transform,
-- RE2Cache::ScopedAccess(re2_cache.get(),
-- possible_national_prefix),
-- &carrier_code_temp) ||
-- RE2::Consume(&number_copy_without_transform,
-- RE2Cache::ScopedAccess(re2_cache.get(),
-- possible_national_prefix))) {
-+ } else if (number_copy_without_transform->ConsumeRegExp(
-+ possible_national_prefix, true, &carrier_code_temp, NULL) ||
-+ number_copy_without_transform->ConsumeRegExp(
-+ possible_national_prefix, true, NULL, NULL)) {
- logger->Debug("Parsed the first digits as a national prefix.");
-+ string unconsumed_part(number_copy_without_transform->ToString());
- // If captured_part_of_prefix is empty, this implies nothing was captured by
- // the capturing groups in possible_national_prefix; therefore, no
- // transformation is necessary, and we just remove the national prefix.
-- if (RE2::FullMatch(number_copy_without_transform, national_number_rule)) {
-- number->assign(number_copy_without_transform.ToString());
-+ if (national_number_rule->Match(unconsumed_part.c_str(), true, NULL)) {
-+ number->assign(unconsumed_part);
- if (carrier_code) {
- carrier_code->assign(carrier_code_temp);
- }
-@@ -1949,11 +1974,13 @@
- string possible_extension_two;
- string possible_extension_three;
- string number_copy(*number);
-- if (RE2::PartialMatch(number_copy, *extn_pattern,
-- &possible_extension_one, &possible_extension_two,
-- &possible_extension_three)) {
-+ scoped_ptr<reg_exp::RegularExpressionInput> number_copy_regex_input(
-+ reg_exp::CreateRegularExpressionInput(number_copy.c_str()));
-+ if (extn_pattern->Consume(number_copy_regex_input.get(), false,
-+ &possible_extension_one, &possible_extension_two,
-+ &possible_extension_three)) {
- // Replace the extensions in the original string here.
-- RE2::Replace(&number_copy, *extn_pattern, "");
-+ extn_pattern->Replace(&number_copy, false, "");
- logger->Debug("Found an extension. Possible extension one: "
- + possible_extension_one
- + ". Possible extension two: " + possible_extension_two
-@@ -2061,25 +2088,29 @@
- &potential_national_number)) {
- const PhoneNumberDesc& general_num_desc =
- default_region_metadata->general_desc();
-- RE2Cache::ScopedAccess valid_number_pattern(
-- re2_cache.get(),
-- general_num_desc.national_number_pattern());
-+ scoped_ptr<reg_exp::RegularExpression> valid_number_pattern(
-+ reg_exp::CreateRegularExpression(
-+ general_num_desc.national_number_pattern().c_str()));
-+
- MaybeStripNationalPrefixAndCarrierCode(*default_region_metadata,
- &potential_national_number,
- NULL);
- logger->Debug("Number without country code prefix: "
- + potential_national_number);
- string extracted_number;
-- RE2Cache::ScopedAccess possible_number_pattern(
-- re2_cache.get(),
-- StrCat("(", general_num_desc.possible_number_pattern(), ")"));
-+ scoped_ptr<reg_exp::RegularExpression> possible_number_pattern(
-+ reg_exp::CreateRegularExpression(
-+ StrCat("(", general_num_desc.possible_number_pattern(),
-+ ")").c_str()));
- // If the number was not valid before but is valid now, or if it was too
- // long before, we consider the number with the country code stripped to
- // be a better result and keep that instead.
-- if ((!RE2::FullMatch(*national_number, valid_number_pattern) &&
-- RE2::FullMatch(potential_national_number, valid_number_pattern)) ||
-- TestNumberLengthAgainstPattern(possible_number_pattern,
-- *national_number)
-+ if ((!valid_number_pattern->Match(national_number->c_str(),
-+ true, NULL) &&
-+ valid_number_pattern->Match(potential_national_number.c_str(),
-+ true, NULL)) ||
-+ TestNumberLengthAgainstPattern(possible_number_pattern.get(),
-+ *national_number)
- == TOO_LONG) {
- national_number->assign(potential_national_number);
- if (keep_raw_input) {
-Index: regexp_adapter_unittest.cc
-===================================================================
---- regexp_adapter_unittest.cc (revision 0)
-+++ regexp_adapter_unittest.cc (revision 0)
-@@ -0,0 +1,142 @@
-+// Copyright (C) 2011 Google Inc.
-+//
-+// Licensed under the Apache License, Version 2.0 (the "License");
-+// you may not use this file except in compliance with the License.
-+// You may obtain a copy of the License at
-+//
-+// http://www.apache.org/licenses/LICENSE-2.0
-+//
-+// Unless required by applicable law or agreed to in writing, software
-+// distributed under the License is distributed on an "AS IS" BASIS,
-+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-+// See the License for the specific language governing permissions and
-+// limitations under the License.
-+
-+// Author: George Yakovlev
-+#include <gtest/gtest.h>
-+
-+#include "base/scoped_ptr.h"
-+#include "regexp_adapter.h"
-+
-+namespace reg_exp {
-+
-+TEST(RegExpAdapter, TestConsumeRegExp) {
-+ scoped_ptr<const reg_exp::RegularExpression> reg_exp1(
-+ reg_exp::CreateRegularExpression("[0-9a-z]+"));
-+ scoped_ptr<const reg_exp::RegularExpression> reg_exp2(
-+ reg_exp::CreateRegularExpression(" \\(([0-9a-z]+)\\)"));
-+ scoped_ptr<const reg_exp::RegularExpression> reg_exp3(
-+ reg_exp::CreateRegularExpression("([0-9a-z]+)-([0-9a-z]+)"));
-+
-+ scoped_ptr<reg_exp::RegularExpressionInput> reg_input1(
-+ reg_exp::CreateRegularExpressionInput("+1-123-456-789"));
-+ scoped_ptr<reg_exp::RegularExpressionInput> reg_input2(
-+ reg_exp::CreateRegularExpressionInput("1 (123)456-789"));
-+
-+ EXPECT_FALSE(reg_exp1->Consume(reg_input1.get(), true, NULL, NULL));
-+ EXPECT_EQ(reg_input1->ToString(), "+1-123-456-789");
-+ EXPECT_TRUE(reg_exp1->Consume(reg_input1.get(), false, NULL, NULL));
-+ EXPECT_EQ(reg_input1->ToString(), "-123-456-789");
-+ std::string res1, res2;
-+ EXPECT_FALSE(reg_exp2->Consume(reg_input1.get(), true, &res1, NULL));
-+ EXPECT_FALSE(reg_exp3->Consume(reg_input1.get(), true, &res1, &res2));
-+ EXPECT_TRUE(reg_exp3->Consume(reg_input1.get(), false, &res1, &res2));
-+ EXPECT_EQ(reg_input1->ToString(), "-789");
-+ EXPECT_EQ(res1, "123");
-+ EXPECT_EQ(res2, "456");
-+
-+ EXPECT_EQ(reg_input2->ToString(), "1 (123)456-789");
-+ EXPECT_TRUE(reg_exp1->Consume(reg_input2.get(), true, NULL, NULL));
-+ EXPECT_EQ(reg_input2->ToString(), " (123)456-789");
-+ EXPECT_TRUE(reg_exp2->Consume(reg_input2.get(), true, &res1, NULL));
-+ EXPECT_EQ(reg_input2->ToString(), "456-789");
-+ EXPECT_EQ(res1, "123");
-+ EXPECT_TRUE(reg_exp3->Consume(reg_input2.get(), true, &res1, &res2));
-+ EXPECT_EQ(reg_input2->ToString(), "");
-+ EXPECT_EQ(res1, "456");
-+ EXPECT_EQ(res2, "789");
-+}
-+
-+TEST(RegExpAdapter, TestConsumeInput) {
-+ scoped_ptr<reg_exp::RegularExpressionInput> reg_input(
-+ reg_exp::CreateRegularExpressionInput("1 (123)456-789"));
-+ std::string res1, res2;
-+ EXPECT_EQ(reg_input->ToString(), "1 (123)456-789");
-+ EXPECT_FALSE(reg_input->ConsumeRegExp(std::string("\\[1\\]"),
-+ true,
-+ &res1,
-+ &res2));
-+ EXPECT_EQ(reg_input->ToString(), "1 (123)456-789");
-+ EXPECT_FALSE(reg_input->ConsumeRegExp(std::string("([0-9]+) \\([0-9]+\\)"),
-+ true,
-+ &res1,
-+ &res2));
-+ EXPECT_EQ(reg_input->ToString(), "1 (123)456-789");
-+ EXPECT_TRUE(reg_input->ConsumeRegExp(std::string("([0-9]+) \\(([0-9]+)\\)"),
-+ true,
-+ &res1,
-+ &res2));
-+ EXPECT_EQ(reg_input->ToString(), "456-789");
-+ EXPECT_EQ(res1, "1");
-+ EXPECT_EQ(res2, "123");
-+}
-+
-+TEST(RegExpAdapter, TestMatch) {
-+ scoped_ptr<const reg_exp::RegularExpression> reg_exp(
-+ reg_exp::CreateRegularExpression("([0-9a-z]+)"));
-+ std::string matched;
-+ EXPECT_TRUE(reg_exp->Match("12345af", true, &matched));
-+ EXPECT_EQ(matched, "12345af");
-+ EXPECT_TRUE(reg_exp->Match("12345af", false, &matched));
-+ EXPECT_EQ(matched, "12345af");
-+ EXPECT_TRUE(reg_exp->Match("12345af", false, NULL));
-+ EXPECT_TRUE(reg_exp->Match("12345af", true, NULL));
-+
-+ EXPECT_FALSE(reg_exp->Match("[12]", true, &matched));
-+ EXPECT_TRUE(reg_exp->Match("[12]", false, &matched));
-+ EXPECT_EQ(matched, "12");
-+
-+ EXPECT_FALSE(reg_exp->Match("[]", true, &matched));
-+ EXPECT_FALSE(reg_exp->Match("[]", false, &matched));
-+}
-+
-+TEST(RegExpAdapter, TestReplace) {
-+ scoped_ptr<const reg_exp::RegularExpression> reg_exp(
-+ reg_exp::CreateRegularExpression("[0-9]"));
-+
-+ std::string s("123-4567 ");
-+ EXPECT_TRUE(reg_exp->Replace(&s, false, "+"));
-+ EXPECT_EQ(s, "+23-4567 ");
-+ EXPECT_TRUE(reg_exp->Replace(&s, false, "+"));
-+ EXPECT_EQ(s, "++3-4567 ");
-+ EXPECT_TRUE(reg_exp->Replace(&s, true, "*"));
-+ EXPECT_EQ(s, "++*-**** ");
-+ EXPECT_TRUE(reg_exp->Replace(&s, true, "*"));
-+ EXPECT_EQ(s, "++*-**** ");
-+
-+ scoped_ptr<const reg_exp::RegularExpression> full_number_expr(
-+ reg_exp::CreateRegularExpression("(\\d{3})(\\d{3})(\\d{4})"));
-+ s = "1234567890:0987654321";
-+ EXPECT_TRUE(full_number_expr->Replace(&s, true, "(\\1) \\2-\\3$1"));
-+ EXPECT_EQ(s, "(123) 456-7890$1:(098) 765-4321$1");
-+}
-+
-+TEST(RegExpAdapter, TestUtf8) {
-+ // Expression: <tel symbol><opening square bracket>[<alpha>-<omega>]*
-+ // <closing square bracket>
-+ scoped_ptr<const reg_exp::RegularExpression> reg_exp(
-+ reg_exp::CreateRegularExpression(
-+ "\xe2\x84\xa1\xe2\x8a\x8f([\xce\xb1-\xcf\x89]*)\xe2\x8a\x90"));
-+ std::string matched;
-+ // The string is split to avoid problem with MSVC compiler when it thinks
-+ // 123 is a part of character code.
-+ EXPECT_FALSE(reg_exp->Match("\xe2\x84\xa1\xe2\x8a\x8f" "123\xe2\x8a\x90",
-+ true, &matched));
-+ EXPECT_TRUE(reg_exp->Match(
-+ "\xe2\x84\xa1\xe2\x8a\x8f\xce\xb1\xce\xb2\xe2\x8a\x90", true, &matched));
-+ // <alpha><betha>
-+ EXPECT_EQ(matched, "\xce\xb1\xce\xb2");
-+}
-+
-+} // namespace reg_exp
-+
-
-Property changes on: regexp_adapter_unittest.cc
-___________________________________________________________________
-Added: svn:eol-style
- + LF
-
diff --git a/third_party/libphonenumber/patches/version277.patch b/third_party/libphonenumber/patches/version277.patch
deleted file mode 100644
index 63807df3..0000000
--- a/third_party/libphonenumber/patches/version277.patch
+++ /dev/null
@@ -1,1416 +0,0 @@
-Index: src/regexp_cache.cc
-===================================================================
---- src/regexp_cache.cc (revision 277)
-+++ src/regexp_cache.cc (working copy)
-@@ -26,35 +26,17 @@
-
- using std::string;
-
--#ifdef USE_HASH_MAP
--
--// A basic text book string hash function implementation, this one taken from
--// The Practice of Programming (Kernighan and Pike 1999). It could be a good
--// idea in the future to evaluate how well it actually performs and possibly
--// switch to another hash function better suited to this particular use case.
--namespace __gnu_cxx {
--template<> struct hash<string> {
-- enum { MULTIPLIER = 31 };
-- size_t operator()(const string& key) const {
-- size_t h = 0;
-- for (const char* p = key.c_str(); *p != '\0'; ++p) {
-- h *= MULTIPLIER;
-- h += *p;
-- }
-- return h;
-- }
--};
--} // namespace __gnu_cxx
--
--#endif
--
- namespace i18n {
- namespace phonenumbers {
-
- using base::AutoLock;
-
- RegExpCache::RegExpCache(size_t min_items)
-+#ifdef USE_TR1_UNORDERED_MAP
- : cache_impl_(new CacheImpl(min_items)) {}
-+#else // USE_TR1_UNORDERED_MAP
-+ : cache_impl_(new CacheImpl()) {}
-+#endif // USE_TR1_UNORDERED_MAP
-
- RegExpCache::~RegExpCache() {
- AutoLock l(lock_);
-Index: src/phonenumberutil_test.cc
-===================================================================
---- src/phonenumberutil_test.cc (revision 277)
-+++ src/phonenumberutil_test.cc (working copy)
-@@ -1145,11 +1145,11 @@
- ExtractPossibleNumber("Tel:+800-345-600", &extracted_number);
- EXPECT_EQ("+800-345-600", extracted_number);
- // Should recognise wide digits as possible start values.
-- ExtractPossibleNumber("023", &extracted_number);
-- EXPECT_EQ("023", extracted_number);
-+ ExtractPossibleNumber("\xEF\xBC\x90\xEF\xBC\x92\xEF\xBC\x93", &extracted_number);
-+ EXPECT_EQ("\xEF\xBC\x90\xEF\xBC\x92\xEF\xBC\x93", extracted_number);
- // Dashes are not possible start values and should be removed.
-- ExtractPossibleNumber("Num-123", &extracted_number);
-- EXPECT_EQ("123", extracted_number);
-+ ExtractPossibleNumber("Num-\xEF\xBC\x91\xEF\xBC\x92\xEF\xBC\x93", &extracted_number);
-+ EXPECT_EQ("\xEF\xBC\x91\xEF\xBC\x92\xEF\xBC\x93", extracted_number);
- // If not possible number present, return empty string.
- ExtractPossibleNumber("Num-....", &extracted_number);
- EXPECT_EQ("", extracted_number);
-@@ -1163,7 +1163,7 @@
- ExtractPossibleNumber("(650) 253-0000.", &extracted_number);
- EXPECT_EQ("650) 253-0000", extracted_number);
- // This case has a trailing RTL char.
-- ExtractPossibleNumber("(650) 253-0000‏", &extracted_number);
-+ ExtractPossibleNumber("(650) 253-0000\xE2\x80\x8F", &extracted_number);
- EXPECT_EQ("650) 253-0000", extracted_number);
- }
-
-@@ -1207,7 +1207,7 @@
- // This number is no longer valid.
- EXPECT_FALSE(phone_util_.IsValidNumber(bs_number));
-
-- // La Mayotte and Réunion use 'leadingDigits' to differentiate them.
-+ // La Mayotte and R\xC3\xA9union use 'leadingDigits' to differentiate them.
- PhoneNumber re_number;
- re_number.set_country_code(262);
- re_number.set_national_number(262123456ULL);
-@@ -1675,13 +1675,13 @@
- EXPECT_TRUE(IsViablePhoneNumber("0800-4-PIZZA"));
- // Only one or two digits before possible punctuation followed by more digits.
- // The punctuation used here is the unicode character u+3000.
-- EXPECT_TRUE(IsViablePhoneNumber("1 34"));
-- EXPECT_FALSE(IsViablePhoneNumber("1 3+4"));
-+ EXPECT_TRUE(IsViablePhoneNumber("1\xE3\x80\x80" "34"));
-+ EXPECT_FALSE(IsViablePhoneNumber("1\xE3\x80\x80" "3+4"));
- // Unicode variants of possible starting character and other allowed
- // punctuation/digits.
-- EXPECT_TRUE(IsViablePhoneNumber("(1) 3456789"));
-+ EXPECT_TRUE(IsViablePhoneNumber("\xEF\xBC\x88" "1\xEF\xBC\x89\xE3\x80\x80" "3456789"));
- // Testing a leading + is okay.
-- EXPECT_TRUE(IsViablePhoneNumber("+1) 3456789"));
-+ EXPECT_TRUE(IsViablePhoneNumber("+1\xEF\xBC\x89\xE3\x80\x80" "3456789"));
- }
-
- TEST_F(PhoneNumberUtilTest, ConvertAlphaCharactersInNumber) {
-@@ -1692,8 +1692,8 @@
- EXPECT_EQ(kExpectedOutput, input);
-
- // Try with some non-ASCII characters.
-- input.assign("1 (800) ABC-DEF");
-- static const string kExpectedFullwidthOutput = "1 (800) 222-333";
-+ input.assign("1\xE3\x80\x80\xEF\xBC\x88" "800) ABC-DEF");
-+ static const string kExpectedFullwidthOutput = "1\xE3\x80\x80\xEF\xBC\x88" "800) 222-333";
- phone_util_.ConvertAlphaCharactersInNumber(&input);
- EXPECT_EQ(kExpectedFullwidthOutput, input);
- }
-@@ -1717,13 +1717,13 @@
- TEST_F(PhoneNumberUtilTest, NormaliseOtherDigits) {
- // The first digit is a full-width 2, the last digit is an Arabic-indic digit
- // 5.
-- string input_number("25٥");
-+ string input_number("\xEF\xBC\x92" "5\xD9\xA5");
- Normalize(&input_number);
- static const string kExpectedOutput("255");
- EXPECT_EQ(kExpectedOutput, input_number)
- << "Conversion did not correctly replace non-latin digits";
- // The first digit is an Eastern-Arabic 5, the latter an Eastern-Arabic 0.
-- string eastern_arabic_input_number("۵2۰");
-+ string eastern_arabic_input_number("\xDB\xB5" "2\xDB\xB0");
- Normalize(&eastern_arabic_input_number);
- static const string kExpectedOutput2("520");
- EXPECT_EQ(kExpectedOutput2, eastern_arabic_input_number)
-@@ -2379,21 +2379,21 @@
- // Using a full-width plus sign.
- test_number.Clear();
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("+1 (650) 333-6000",
-+ phone_util_.Parse("\xEF\xBC\x8B" "1 (650) 333-6000",
- RegionCode::SG(), &test_number));
- EXPECT_EQ(us_number, test_number);
- // The whole number, including punctuation, is here represented in full-width
- // form.
- test_number.Clear();
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("+1 (650) 333-6000",
-+ phone_util_.Parse("\xEF\xBC\x8B\xEF\xBC\x91\xE3\x80\x80\xEF\xBC\x88\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90\xEF\xBC\x89\xE3\x80\x80\xEF\xBC\x93\xEF\xBC\x93\xEF\xBC\x93\xEF\xBC\x8D\xEF\xBC\x96\xEF\xBC\x90\xEF\xBC\x90\xEF\xBC\x90",
- RegionCode::SG(), &test_number));
- EXPECT_EQ(us_number, test_number);
-
- // Using the U+30FC dash.
- test_number.Clear();
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("+1 (650) 333ー6000",
-+ phone_util_.Parse("\xEF\xBC\x8B\xEF\xBC\x91\xE3\x80\x80\xEF\xBC\x88\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90\xEF\xBC\x89\xE3\x80\x80\xEF\xBC\x93\xEF\xBC\x93\xEF\xBC\x93\xE3\x83\xBC\xEF\xBC\x96\xEF\xBC\x90\xEF\xBC\x90\xEF\xBC\x90",
- RegionCode::SG(), &test_number));
- EXPECT_EQ(us_number, test_number);
- }
-@@ -2633,7 +2633,7 @@
- // Test with full-width plus.
- result_proto.Clear();
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("+64 3 331 6005", RegionCode::GetUnknown(),
-+ phone_util_.Parse("\xEF\xBC\x8B" "64 3 331 6005", RegionCode::GetUnknown(),
- &result_proto));
- EXPECT_EQ(nz_number, result_proto);
- // Test with normal plus but leading characters that need to be stripped.
-@@ -2792,7 +2792,7 @@
- EXPECT_EQ(us_with_extension, test_number);
- test_number.Clear();
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("(800) 901-3355 ,extensión 7246433",
-+ phone_util_.Parse("(800) 901-3355 ,extensi\xC3\xB3n 7246433",
- RegionCode::US(),
- &test_number));
- EXPECT_EQ(us_with_extension, test_number);
-@@ -2800,7 +2800,7 @@
- // Repeat with the small letter o with acute accent created by combining
- // characters.
- EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
-- phone_util_.Parse("(800) 901-3355 ,extensión 7246433",
-+ phone_util_.Parse("(800) 901-3355 ,extensio\xCC\x81n 7246433",
- RegionCode::US(),
- &test_number));
- EXPECT_EQ(us_with_extension, test_number);
-Index: src/regexp_cache.h
-===================================================================
---- src/regexp_cache.h (revision 277)
-+++ src/regexp_cache.h (working copy)
-@@ -37,10 +37,7 @@
- #ifdef USE_TR1_UNORDERED_MAP
- # include <tr1/unordered_map>
- #elif defined(USE_HASH_MAP)
--# ifndef __DEPRECATED
--# define __DEPRECATED
--# endif
--# include <hash_map>
-+# include "base/hash_tables.h"
- #else
- # error STL map type unsupported on this platform!
- #endif
-@@ -57,7 +54,7 @@
- #ifdef USE_TR1_UNORDERED_MAP
- typedef std::tr1::unordered_map<string, const RegExp*> CacheImpl;
- #elif defined(USE_HASH_MAP)
-- typedef std::hash_map<string, const RegExp*> CacheImpl;
-+ typedef base::hash_map<string, const RegExp*> CacheImpl;
- #endif
-
- public:
-Index: src/phonenumberutil.cc
-===================================================================
---- src/phonenumberutil.cc (revision 277)
-+++ src/phonenumberutil.cc (working copy)
-@@ -33,7 +33,7 @@
- #include <unicode/utf8.h>
-
- #include "base/logging.h"
--#include "base/singleton.h"
-+#include "base/memory/singleton.h"
- #include "default_logger.h"
- #include "encoding_utils.h"
- #include "metadata.h"
-@@ -62,7 +62,7 @@
- using google::protobuf::RepeatedPtrField;
-
- // static
--const char PhoneNumberUtil::kPlusChars[] = "++";
-+const char PhoneNumberUtil::kPlusChars[] = "+\xEF\xBC\x8B";
- // To find out the unicode code-point of the characters below in vim, highlight
- // the character and type 'ga'. Note that the - is used to express ranges of
- // full-width punctuation below, as well as being present in the expression
-@@ -70,7 +70,7 @@
- // unicode character.
- // static
- const char PhoneNumberUtil::kValidPunctuation[] =
-- "-x‐-―−ー--/  ​⁠ ()()[].\\[\\]/~⁓∼";
-+ "-x\xE2\x80\x90-\xE2\x80\x95\xE2\x88\x92\xE3\x83\xBC\xEF\xBC\x8D-\xEF\xBC\x8F \xC2\xA0\xE2\x80\x8B\xE2\x81\xA0\xE3\x80\x80()\xEF\xBC\x88\xEF\xBC\x89\xEF\xBC\xBB\xEF\xBC\xBD.\\[\\]/~\xE2\x81\x93\xE2\x88\xBC";
-
- namespace {
-
-@@ -450,35 +450,35 @@
- all_plus_number_grouping_symbols->insert(
- make_pair(ToUnicodeCodepoint("-"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("-"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xEF\xBC\x8D"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("‐"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x90"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("‑"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x91"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("‒"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x92"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("–"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x93"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("—"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x94"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("―"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x80\x95"), '-'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("−"), '-'));
-+ make_pair(ToUnicodeCodepoint("\xE2\x88\x92"), '-'));
- all_plus_number_grouping_symbols->insert(
- make_pair(ToUnicodeCodepoint("/"), '/'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("/"), '/'));
-+ make_pair(ToUnicodeCodepoint("\xEF\xBC\x8F"), '/'));
- all_plus_number_grouping_symbols->insert(
- make_pair(ToUnicodeCodepoint(" "), ' '));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint(" "), ' '));
-+ make_pair(ToUnicodeCodepoint("\xE3\x80\x80"), ' '));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("⁠"), ' '));
-+ make_pair(ToUnicodeCodepoint("\xE2\x81\xA0"), ' '));
- all_plus_number_grouping_symbols->insert(
- make_pair(ToUnicodeCodepoint("."), '.'));
- all_plus_number_grouping_symbols->insert(
-- make_pair(ToUnicodeCodepoint("."), '.'));
-+ make_pair(ToUnicodeCodepoint("\xEF\xBC\x8E"), '.'));
- // Only the upper-case letters are added here - the lower-case versions are
- // added programmatically.
- alpha_mappings->insert(make_pair(ToUnicodeCodepoint("A"), '2'));
-@@ -684,15 +684,13 @@
- // Public wrapper function to get a PhoneNumberUtil instance with the default
- // metadata file.
- // static
--#ifdef USE_GOOGLE_BASE
- PhoneNumberUtil* PhoneNumberUtil::GetInstance() {
- return Singleton<PhoneNumberUtil>::get();
- }
--#endif
-
- void PhoneNumberUtil::CreateRegularExpressions() const {
- unique_international_prefix.reset(RegExp::Create(
-- "[\\d]+(?:[~⁓∼~][\\d]+)?"));
-+ "[\\d]+(?:[~\xE2\x81\x93\xE2\x88\xBC\xEF\xBD\x9E][\\d]+)?"));
- // The first_group_capturing_pattern was originally set to $1 but there are
- // some countries for which the first group is not used in the national
- // pattern (e.g. Argentina) so the $1 group does not match correctly.
-@@ -713,16 +711,16 @@
- StrCat("[", kPlusChars, "]*(?:[", kValidPunctuation, "]*[", kDigits,
- "]){3,}[", kValidAlpha, kValidPunctuation, kDigits, "]*")));
- // Canonical-equivalence doesn't seem to be an option with RE2, so we allow
-- // two options for representing the ó - the character itself, and one in the
-+ // two options for representing the \xC3\xB3 - the character itself, and one in the
- // unicode decomposed form with the combining acute accent. Note that there
- // are currently three capturing groups for the extension itself - if this
- // number is changed, MaybeStripExtension needs to be updated.
- const string capturing_extn_digits = StrCat("([", kDigits, "]{1,7})");
- known_extn_patterns.reset(new string(
- StrCat(kRfc3966ExtnPrefix, capturing_extn_digits, "|"
-- "[  \\t,]*(?:ext(?:ensi(?:ó?|ó))?n?|extn?|[,xx##~~]|"
-- "int|int|anexo)"
-- "[:\\..]?[  \\t,-]*", capturing_extn_digits, "#?|"
-+ "[ \xC2\xA0\\t,]*(?:ext(?:ensi(?:o\xCC\x81?|\xC3\xB3))?n?|\xEF\xBD\x85\xEF\xBD\x98\xEF\xBD\x94\xEF\xBD\x8E?|[,x\xEF\xBD\x98#\xEF\xBC\x83~\xEF\xBD\x9E]|"
-+ "int|\xEF\xBD\x89\xEF\xBD\x8E\xEF\xBD\x94|anexo)"
-+ "[:\\.\xEF\xBC\x8E]?[ \xC2\xA0\\t,-]*", capturing_extn_digits, "#?|"
- "[- ]+([", kDigits, "]{1,5})#")));
- extn_pattern.reset(RegExp::Create(
- StrCat("(?i)(?:", *known_extn_patterns, ")$")));
-@@ -828,7 +826,7 @@
- // Note here that all NANPA formatting rules are contained by US, so we use
- // that to format NANPA numbers. The same applies to Russian Fed regions -
- // rules are contained by Russia. French Indian Ocean country rules are
-- // contained by Réunion.
-+ // contained by R\xC3\xA9union.
- string region_code;
- GetRegionCodeForCountryCode(country_calling_code, &region_code);
- if (!HasValidRegionCode(region_code, country_calling_code,
-@@ -987,7 +985,7 @@
- // For regions that share a country calling code, the country calling code
- // need not be dialled. This also applies when dialling within a region, so
- // this if clause covers both these cases.
-- // Technically this is the case for dialling from la Réunion to other
-+ // Technically this is the case for dialling from la R\xC3\xA9union to other
- // overseas departments of France (French Guiana, Martinique, Guadeloupe),
- // but not vice versa - so we don't cover this edge case for now and for
- // those cases return the version including country calling code.
-Index: src/logger.h
-===================================================================
---- src/logger.h (revision 277)
-+++ src/logger.h (working copy)
-@@ -20,7 +20,7 @@
- #include <cstdio>
- #include <string>
-
--#include <base/scoped_ptr.h>
-+#include "base/scoped_ptr.h"
-
- namespace i18n {
- namespace phonenumbers {
-Index: src/regexp_adapter_test.cc
-===================================================================
---- src/regexp_adapter_test.cc (revision 277)
-+++ src/regexp_adapter_test.cc (working copy)
-@@ -186,12 +186,12 @@
- }
-
- TEST(RegExpAdapter, TestUtf8) {
-- const scoped_ptr<const RegExp> reg_exp(RegExp::Create("℡⊏([α-ω]*)⊐"));
-+ const scoped_ptr<const RegExp> reg_exp(RegExp::Create("\xE2\x84\xA1\xE2\x8A\x8F([\xCE\xB1-\xCF\x89]*)\xE2\x8A\x90"));
- string matched;
-
-- EXPECT_FALSE(reg_exp->Match("℡⊏123⊐", true, &matched));
-- EXPECT_TRUE(reg_exp->Match("℡⊏αβ⊐", true, &matched));
-- EXPECT_EQ("αβ", matched);
-+ EXPECT_FALSE(reg_exp->Match("\xE2\x84\xA1\xE2\x8A\x8F" "123\xE2\x8A\x90", true, &matched));
-+ EXPECT_TRUE(reg_exp->Match("\xE2\x84\xA1\xE2\x8A\x8F\xCE\xB1\xCE\xB2\xE2\x8A\x90", true, &matched));
-+ EXPECT_EQ("\xCE\xB1\xCE\xB2", matched);
- }
-
- } // namespace phonenumbers
-Index: src/phonenumberutil.h
-===================================================================
---- src/phonenumberutil.h (revision 277)
-+++ src/phonenumberutil.h (working copy)
-@@ -29,7 +29,7 @@
-
- #include "base/basictypes.h"
- #include "base/scoped_ptr.h"
--#include "base/singleton.h"
-+#include "base/memory/singleton.h"
- #include "phonenumber.pb.h"
-
- class TelephoneNumber;
-@@ -57,20 +57,15 @@
- // codes can be found here:
- // http://www.iso.org/iso/english_country_names_and_code_elements
-
--#ifdef USE_GOOGLE_BASE
- class PhoneNumberUtil {
- friend struct DefaultSingletonTraits<PhoneNumberUtil>;
--#else
--class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
-- friend class Singleton<PhoneNumberUtil>;
--#endif
- friend class PhoneNumberUtilTest;
- public:
- ~PhoneNumberUtil();
-
- // INTERNATIONAL and NATIONAL formats are consistent with the definition
- // in ITU-T Recommendation E. 123. For example, the number of the Google
-- // Zürich office will be written as "+41 44 668 1800" in INTERNATIONAL
-+ // Zurich office will be written as "+41 44 668 1800" in INTERNATIONAL
- // format, and as "044 668 1800" in NATIONAL format. E164 format is as per
- // INTERNATIONAL format but with no formatting applied e.g. +41446681800.
- // RFC3966 is as per INTERNATIONAL format, but with all spaces and other
-@@ -147,9 +142,7 @@
- //
- // The PhoneNumberUtil is implemented as a singleton. Therefore, calling
- // getInstance multiple times will only result in one instance being created.
--#ifdef USE_GOOGLE_BASE
- static PhoneNumberUtil* GetInstance();
--#endif
-
- // Initialisation helper function used to populate the regular expressions in
- // a defined order.
-Index: src/default_logger.h
-===================================================================
---- src/default_logger.h (revision 277)
-+++ src/default_logger.h (working copy)
-@@ -45,7 +45,11 @@
- struct ConvertToString<int> {
- static inline string DoWork(const int& n) {
- char buffer[16];
-+#if defined(OS_WIN)
-+ _itoa_s(n, buffer, sizeof(buffer), 10);
-+#else
- std::snprintf(buffer, sizeof(buffer), "%d", n);
-+#endif
- return string(buffer);
- }
- };
-@@ -77,19 +81,6 @@
- namespace i18n {
- namespace phonenumbers {
-
--inline LoggerHandler VLOG(int n) {
-- Logger* const logger_impl = Logger::mutable_logger_impl();
-- if (logger_impl->level() < n) {
-- return LoggerHandler(NULL);
-- }
-- logger_impl->WriteLevel();
-- return LoggerHandler(logger_impl);
--}
--
--inline LoggerHandler LOG(int n) {
-- return VLOG(n);
--}
--
- // Default logger implementation used by PhoneNumberUtil class. It outputs the
- // messages to the standard output.
- class StdoutLogger : public Logger {
-Index: src/base/string_piece.cc
-===================================================================
---- src/base/string_piece.cc (revision 277)
-+++ src/base/string_piece.cc (working copy)
-@@ -1,219 +0,0 @@
--// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
--// Use of this source code is governed by a BSD-style license that can be
--// found in the LICENSE file.
--// Copied from strings/stringpiece.cc with modifications
--
--#include <algorithm>
--#include <ostream>
--
--#include "base/string_piece.h"
--
--namespace base {
--
--typedef StringPiece::size_type size_type;
--
--std::ostream& operator<<(std::ostream& o, const StringPiece& piece) {
-- o.write(piece.data(), static_cast<std::streamsize>(piece.size()));
-- return o;
--}
--
--bool operator==(const StringPiece& x, const StringPiece& y) {
-- if (x.size() != y.size())
-- return false;
--
-- return StringPiece::wordmemcmp(x.data(), y.data(), x.size()) == 0;
--}
--
--void StringPiece::CopyToString(std::string* target) const {
-- target->assign(!empty() ? data() : "", size());
--}
--
--void StringPiece::AppendToString(std::string* target) const {
-- if (!empty())
-- target->append(data(), size());
--}
--
--size_type StringPiece::copy(char* buf, size_type n, size_type pos) const {
-- size_type ret = std::min(length_ - pos, n);
-- memcpy(buf, ptr_ + pos, ret);
-- return ret;
--}
--
--size_type StringPiece::find(const StringPiece& s, size_type pos) const {
-- if (pos > length_)
-- return npos;
--
-- const char* result = std::search(ptr_ + pos, ptr_ + length_,
-- s.ptr_, s.ptr_ + s.length_);
-- const size_type xpos = result - ptr_;
-- return xpos + s.length_ <= length_ ? xpos : npos;
--}
--
--size_type StringPiece::find(char c, size_type pos) const {
-- if (pos >= length_)
-- return npos;
--
-- const char* result = std::find(ptr_ + pos, ptr_ + length_, c);
-- return result != ptr_ + length_ ? static_cast<size_t>(result - ptr_) : npos;
--}
--
--size_type StringPiece::rfind(const StringPiece& s, size_type pos) const {
-- if (length_ < s.length_)
-- return npos;
--
-- if (s.empty())
-- return std::min(length_, pos);
--
-- const char* last = ptr_ + std::min(length_ - s.length_, pos) + s.length_;
-- const char* result = std::find_end(ptr_, last, s.ptr_, s.ptr_ + s.length_);
-- return result != last ? static_cast<size_t>(result - ptr_) : npos;
--}
--
--size_type StringPiece::rfind(char c, size_type pos) const {
-- if (length_ == 0)
-- return npos;
--
-- for (size_type i = std::min(pos, length_ - 1); ; --i) {
-- if (ptr_[i] == c)
-- return i;
-- if (i == 0)
-- break;
-- }
-- return npos;
--}
--
--// For each character in characters_wanted, sets the index corresponding
--// to the ASCII code of that character to 1 in table. This is used by
--// the find_.*_of methods below to tell whether or not a character is in
--// the lookup table in constant time.
--// The argument `table' must be an array that is large enough to hold all
--// the possible values of an unsigned char. Thus it should be be declared
--// as follows:
--// bool table[UCHAR_MAX + 1]
--static inline void BuildLookupTable(const StringPiece& characters_wanted,
-- bool* table) {
-- const size_type length = characters_wanted.length();
-- const char* const data = characters_wanted.data();
-- for (size_type i = 0; i < length; ++i) {
-- table[static_cast<unsigned char>(data[i])] = true;
-- }
--}
--
--size_type StringPiece::find_first_of(const StringPiece& s,
-- size_type pos) const {
-- if (length_ == 0 || s.length_ == 0)
-- return npos;
--
-- // Avoid the cost of BuildLookupTable() for a single-character search.
-- if (s.length_ == 1)
-- return find_first_of(s.ptr_[0], pos);
--
-- bool lookup[UCHAR_MAX + 1] = { false };
-- BuildLookupTable(s, lookup);
-- for (size_type i = pos; i < length_; ++i) {
-- if (lookup[static_cast<unsigned char>(ptr_[i])]) {
-- return i;
-- }
-- }
-- return npos;
--}
--
--size_type StringPiece::find_first_not_of(const StringPiece& s,
-- size_type pos) const {
-- if (length_ == 0)
-- return npos;
--
-- if (s.length_ == 0)
-- return 0;
--
-- // Avoid the cost of BuildLookupTable() for a single-character search.
-- if (s.length_ == 1)
-- return find_first_not_of(s.ptr_[0], pos);
--
-- bool lookup[UCHAR_MAX + 1] = { false };
-- BuildLookupTable(s, lookup);
-- for (size_type i = pos; i < length_; ++i) {
-- if (!lookup[static_cast<unsigned char>(ptr_[i])]) {
-- return i;
-- }
-- }
-- return npos;
--}
--
--size_type StringPiece::find_first_not_of(char c, size_type pos) const {
-- if (length_ == 0)
-- return npos;
--
-- for (; pos < length_; ++pos) {
-- if (ptr_[pos] != c) {
-- return pos;
-- }
-- }
-- return npos;
--}
--
--size_type StringPiece::find_last_of(const StringPiece& s, size_type pos) const {
-- if (length_ == 0 || s.length_ == 0)
-- return npos;
--
-- // Avoid the cost of BuildLookupTable() for a single-character search.
-- if (s.length_ == 1)
-- return find_last_of(s.ptr_[0], pos);
--
-- bool lookup[UCHAR_MAX + 1] = { false };
-- BuildLookupTable(s, lookup);
-- for (size_type i = std::min(pos, length_ - 1); ; --i) {
-- if (lookup[static_cast<unsigned char>(ptr_[i])])
-- return i;
-- if (i == 0)
-- break;
-- }
-- return npos;
--}
--
--size_type StringPiece::find_last_not_of(const StringPiece& s,
-- size_type pos) const {
-- if (length_ == 0)
-- return npos;
--
-- size_type i = std::min(pos, length_ - 1);
-- if (s.length_ == 0)
-- return i;
--
-- // Avoid the cost of BuildLookupTable() for a single-character search.
-- if (s.length_ == 1)
-- return find_last_not_of(s.ptr_[0], pos);
--
-- bool lookup[UCHAR_MAX + 1] = { false };
-- BuildLookupTable(s, lookup);
-- for (; ; --i) {
-- if (!lookup[static_cast<unsigned char>(ptr_[i])])
-- return i;
-- if (i == 0)
-- break;
-- }
-- return npos;
--}
--
--size_type StringPiece::find_last_not_of(char c, size_type pos) const {
-- if (length_ == 0)
-- return npos;
--
-- for (size_type i = std::min(pos, length_ - 1); ; --i) {
-- if (ptr_[i] != c)
-- return i;
-- if (i == 0)
-- break;
-- }
-- return npos;
--}
--
--StringPiece StringPiece::substr(size_type pos, size_type n) const {
-- if (pos > length_) pos = length_;
-- if (n > length_ - pos) n = length_ - pos;
-- return StringPiece(ptr_ + pos, n);
--}
--
--const StringPiece::size_type StringPiece::npos = size_type(-1);
--
--} // namespace base
-Index: src/base/synchronization/lock.h
-===================================================================
---- src/base/synchronization/lock.h (revision 277)
-+++ src/base/synchronization/lock.h (working copy)
-@@ -1,27 +0,0 @@
--// Copyright (C) 2011 Google Inc.
--//
--// Licensed under the Apache License, Version 2.0 (the "License");
--// you may not use this file except in compliance with the License.
--// You may obtain a copy of the License at
--//
--// http://www.apache.org/licenses/LICENSE-2.0
--//
--// Unless required by applicable law or agreed to in writing, software
--// distributed under the License is distributed on an "AS IS" BASIS,
--// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--// See the License for the specific language governing permissions and
--// limitations under the License.
--
--// Author: Philippe Liard
--
--#ifndef I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_H_
--#define I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_H_
--
--#include <boost/thread/mutex.hpp>
--
--namespace base {
-- typedef boost::mutex Lock;
-- typedef boost::mutex::scoped_lock AutoLock;
--}
--
--#endif // I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_H_
-Index: src/base/string_piece.h
-===================================================================
---- src/base/string_piece.h (revision 277)
-+++ src/base/string_piece.h (working copy)
-@@ -1,192 +0,0 @@
--// Copyright (c) 2011 The Chromium Authors. All rights reserved.
--// Use of this source code is governed by a BSD-style license that can be
--// found in the LICENSE file.
--// Copied from strings/stringpiece.h with modifications
--//
--// A string-like object that points to a sized piece of memory.
--//
--// Functions or methods may use const StringPiece& parameters to accept either
--// a "const char*" or a "string" value that will be implicitly converted to
--// a StringPiece. The implicit conversion means that it is often appropriate
--// to include this .h file in other files rather than forward-declaring
--// StringPiece as would be appropriate for most other Google classes.
--//
--// Systematic usage of StringPiece is encouraged as it will reduce unnecessary
--// conversions from "const char*" to "string" and back again.
--//
--
--#ifndef BASE_STRING_PIECE_H_
--#define BASE_STRING_PIECE_H_
--#pragma once
--
--#include <string>
--
--#include "base/basictypes.h"
--
--namespace base {
--
--class StringPiece {
-- public:
-- // standard STL container boilerplate
-- typedef size_t size_type;
-- typedef char value_type;
-- typedef const char* pointer;
-- typedef const char& reference;
-- typedef const char& const_reference;
-- typedef ptrdiff_t difference_type;
-- typedef const char* const_iterator;
-- typedef const char* iterator;
-- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-- typedef std::reverse_iterator<iterator> reverse_iterator;
--
-- static const size_type npos;
--
-- public:
-- // We provide non-explicit singleton constructors so users can pass
-- // in a "const char*" or a "string" wherever a "StringPiece" is
-- // expected.
-- StringPiece() : ptr_(NULL), length_(0) { }
-- StringPiece(const char* str)
-- : ptr_(str), length_((str == NULL) ? 0 : strlen(str)) { }
-- StringPiece(const std::string& str)
-- : ptr_(str.data()), length_(str.size()) { }
-- StringPiece(const char* offset, size_type len)
-- : ptr_(offset), length_(len) { }
--
-- // data() may return a pointer to a buffer with embedded NULs, and the
-- // returned buffer may or may not be null terminated. Therefore it is
-- // typically a mistake to pass data() to a routine that expects a NUL
-- // terminated string.
-- const char* data() const { return ptr_; }
-- size_type size() const { return length_; }
-- size_type length() const { return length_; }
-- bool empty() const { return length_ == 0; }
--
-- void clear() {
-- ptr_ = NULL;
-- length_ = 0;
-- }
-- void set(const char* data, size_type len) {
-- ptr_ = data;
-- length_ = len;
-- }
-- void set(const char* str) {
-- ptr_ = str;
-- length_ = str ? strlen(str) : 0;
-- }
-- void set(const void* data, size_type len) {
-- ptr_ = reinterpret_cast<const char*>(data);
-- length_ = len;
-- }
--
-- char operator[](size_type i) const { return ptr_[i]; }
--
-- void remove_prefix(size_type n) {
-- ptr_ += n;
-- length_ -= n;
-- }
--
-- void remove_suffix(size_type n) {
-- length_ -= n;
-- }
--
-- int compare(const StringPiece& x) const {
-- int r = wordmemcmp(
-- ptr_, x.ptr_, (length_ < x.length_ ? length_ : x.length_));
-- if (r == 0) {
-- if (length_ < x.length_) r = -1;
-- else if (length_ > x.length_) r = +1;
-- }
-- return r;
-- }
--
-- std::string as_string() const {
-- // std::string doesn't like to take a NULL pointer even with a 0 size.
-- return std::string(!empty() ? data() : "", size());
-- }
--
-- void CopyToString(std::string* target) const;
-- void AppendToString(std::string* target) const;
--
-- // Does "this" start with "x"
-- bool starts_with(const StringPiece& x) const {
-- return ((length_ >= x.length_) &&
-- (wordmemcmp(ptr_, x.ptr_, x.length_) == 0));
-- }
--
-- // Does "this" end with "x"
-- bool ends_with(const StringPiece& x) const {
-- return ((length_ >= x.length_) &&
-- (wordmemcmp(ptr_ + (length_-x.length_), x.ptr_, x.length_) == 0));
-- }
--
-- iterator begin() const { return ptr_; }
-- iterator end() const { return ptr_ + length_; }
-- const_reverse_iterator rbegin() const {
-- return const_reverse_iterator(ptr_ + length_);
-- }
-- const_reverse_iterator rend() const {
-- return const_reverse_iterator(ptr_);
-- }
--
-- size_type max_size() const { return length_; }
-- size_type capacity() const { return length_; }
--
-- size_type copy(char* buf, size_type n, size_type pos = 0) const;
--
-- size_type find(const StringPiece& s, size_type pos = 0) const;
-- size_type find(char c, size_type pos = 0) const;
-- size_type rfind(const StringPiece& s, size_type pos = npos) const;
-- size_type rfind(char c, size_type pos = npos) const;
--
-- size_type find_first_of(const StringPiece& s, size_type pos = 0) const;
-- size_type find_first_of(char c, size_type pos = 0) const {
-- return find(c, pos);
-- }
-- size_type find_first_not_of(const StringPiece& s, size_type pos = 0) const;
-- size_type find_first_not_of(char c, size_type pos = 0) const;
-- size_type find_last_of(const StringPiece& s, size_type pos = npos) const;
-- size_type find_last_of(char c, size_type pos = npos) const {
-- return rfind(c, pos);
-- }
-- size_type find_last_not_of(const StringPiece& s, size_type pos = npos) const;
-- size_type find_last_not_of(char c, size_type pos = npos) const;
--
-- StringPiece substr(size_type pos, size_type n = npos) const;
--
-- static int wordmemcmp(const char* p, const char* p2, size_type N) {
-- return memcmp(p, p2, N);
-- }
--
-- private:
-- const char* ptr_;
-- size_type length_;
--};
--
--bool operator==(const StringPiece& x, const StringPiece& y);
--
--inline bool operator!=(const StringPiece& x, const StringPiece& y) {
-- return !(x == y);
--}
--
--inline bool operator<(const StringPiece& x, const StringPiece& y) {
-- const int r = StringPiece::wordmemcmp(
-- x.data(), y.data(), (x.size() < y.size() ? x.size() : y.size()));
-- return ((r < 0) || ((r == 0) && (x.size() < y.size())));
--}
--
--inline bool operator>(const StringPiece& x, const StringPiece& y) {
-- return y < x;
--}
--
--inline bool operator<=(const StringPiece& x, const StringPiece& y) {
-- return !(x > y);
--}
--
--inline bool operator>=(const StringPiece& x, const StringPiece& y) {
-- return !(x < y);
--}
--
--} // namespace base
--
--#endif // BASE_STRING_PIECE_H_
-Index: src/base/scoped_ptr.h
-===================================================================
---- src/base/scoped_ptr.h (revision 277)
-+++ src/base/scoped_ptr.h (working copy)
-@@ -1,24 +0,0 @@
--// Copyright (C) 2011 Google Inc.
--//
--// Licensed under the Apache License, Version 2.0 (the "License");
--// you may not use this file except in compliance with the License.
--// You may obtain a copy of the License at
--//
--// http://www.apache.org/licenses/LICENSE-2.0
--//
--// Unless required by applicable law or agreed to in writing, software
--// distributed under the License is distributed on an "AS IS" BASIS,
--// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--// See the License for the specific language governing permissions and
--// limitations under the License.
--
--// Author: Philippe Liard
--
--#ifndef I18N_PHONENUMBERS_BASE_SCOPED_PTR_H_
--#define I18N_PHONENUMBERS_BASE_SCOPED_PTR_H_
--
--#include <boost/scoped_ptr.hpp>
--
--using boost::scoped_ptr;
--
--#endif // I18N_PHONENUMBERS_BASE_SCOPED_PTR_H_
-Index: src/base/singleton.h
-===================================================================
---- src/base/singleton.h (revision 277)
-+++ src/base/singleton.h (working copy)
-@@ -1,52 +0,0 @@
--// Copyright (C) 2011 Google Inc.
--//
--// Licensed under the Apache License, Version 2.0 (the "License");
--// you may not use this file except in compliance with the License.
--// You may obtain a copy of the License at
--//
--// http://www.apache.org/licenses/LICENSE-2.0
--//
--// Unless required by applicable law or agreed to in writing, software
--// distributed under the License is distributed on an "AS IS" BASIS,
--// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--// See the License for the specific language governing permissions and
--// limitations under the License.
--
--// Author: Philippe Liard
--
--#ifndef I18N_PHONENUMBERS_BASE_SINGLETON_H_
--#define I18N_PHONENUMBERS_BASE_SINGLETON_H_
--
--#include <boost/scoped_ptr.hpp>
--#include <boost/thread/once.hpp>
--#include <boost/utility.hpp>
--
--namespace i18n {
--namespace phonenumbers {
--
--template <class T>
--class Singleton : private boost::noncopyable {
-- public:
-- virtual ~Singleton() {}
--
-- static T* GetInstance() {
-- boost::call_once(Init, flag);
-- return instance.get();
-- }
--
-- private:
-- static void Init() {
-- instance.reset(new T());
-- }
--
-- static boost::scoped_ptr<T> instance;
-- static boost::once_flag flag;
--};
--
--template <class T> boost::scoped_ptr<T> Singleton<T>::instance;
--template <class T> boost::once_flag Singleton<T>::flag = BOOST_ONCE_INIT;
--
--} // namespace phonenumbers
--} // namespace i18n
--
--#endif // I18N_PHONENUMBERS_BASE_SINGLETON_H_
-Index: src/base/basictypes.h
-===================================================================
---- src/base/basictypes.h (revision 277)
-+++ src/base/basictypes.h (working copy)
-@@ -1,380 +0,0 @@
--// Copyright (c) 2010 The Chromium Authors. All rights reserved.
--// Use of this source code is governed by a BSD-style license that can be
--// found in the LICENSE file.
--
--#ifndef BASE_BASICTYPES_H_
--#define BASE_BASICTYPES_H_
--#pragma once
--
--#include <limits.h> // So we can set the bounds of our types
--#include <stddef.h> // For size_t
--#include <string.h> // for memcpy
--
--#ifndef COMPILER_MSVC
--// stdint.h is part of C99 but MSVC doesn't have it.
--#include <stdint.h> // For intptr_t.
--#endif
--
--#ifdef INT64_MAX
--
--// INT64_MAX is defined if C99 stdint.h is included; use the
--// native types if available.
--typedef int8_t int8;
--typedef int16_t int16;
--typedef int32_t int32;
--typedef int64_t int64;
--typedef uint8_t uint8;
--typedef uint16_t uint16;
--typedef uint32_t uint32;
--typedef uint64_t uint64;
--
--const uint8 kuint8max = UINT8_MAX;
--const uint16 kuint16max = UINT16_MAX;
--const uint32 kuint32max = UINT32_MAX;
--const uint64 kuint64max = UINT64_MAX;
--const int8 kint8min = INT8_MIN;
--const int8 kint8max = INT8_MAX;
--const int16 kint16min = INT16_MIN;
--const int16 kint16max = INT16_MAX;
--const int32 kint32min = INT32_MIN;
--const int32 kint32max = INT32_MAX;
--const int64 kint64min = INT64_MIN;
--const int64 kint64max = INT64_MAX;
--
--#else // !INT64_MAX
--
--typedef signed char int8;
--typedef short int16;
--// TODO: Remove these type guards. These are to avoid conflicts with
--// obsolete/protypes.h in the Gecko SDK.
--#ifndef _INT32
--#define _INT32
--typedef int int32;
--#endif
--
--// The NSPR system headers define 64-bit as |long| when possible. In order to
--// not have typedef mismatches, we do the same on LP64.
--#if __LP64__
--typedef long int64;
--#else
--typedef long long int64;
--#endif
--
--// NOTE: unsigned types are DANGEROUS in loops and other arithmetical
--// places. Use the signed types unless your variable represents a bit
--// pattern (eg a hash value) or you really need the extra bit. Do NOT
--// use 'unsigned' to express "this value should always be positive";
--// use assertions for this.
--
--typedef unsigned char uint8;
--typedef unsigned short uint16;
--// TODO: Remove these type guards. These are to avoid conflicts with
--// obsolete/protypes.h in the Gecko SDK.
--#ifndef _UINT32
--#define _UINT32
--typedef unsigned int uint32;
--#endif
--
--// See the comment above about NSPR and 64-bit.
--#if __LP64__
--typedef unsigned long uint64;
--#else
--typedef unsigned long long uint64;
--#endif
--
--#endif // !INT64_MAX
--
--typedef signed char schar;
--
--// A type to represent a Unicode code-point value. As of Unicode 4.0,
--// such values require up to 21 bits.
--// (For type-checking on pointers, make this explicitly signed,
--// and it should always be the signed version of whatever int32 is.)
--typedef signed int char32;
--
--// A macro to disallow the copy constructor and operator= functions
--// This should be used in the private: declarations for a class
--#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
-- TypeName(const TypeName&); \
-- void operator=(const TypeName&)
--
--// An older, deprecated, politically incorrect name for the above.
--// NOTE: The usage of this macro was baned from our code base, but some
--// third_party libraries are yet using it.
--// TODO(tfarina): Figure out how to fix the usage of this macro in the
--// third_party libraries and get rid of it.
--#define DISALLOW_EVIL_CONSTRUCTORS(TypeName) DISALLOW_COPY_AND_ASSIGN(TypeName)
--
--// A macro to disallow all the implicit constructors, namely the
--// default constructor, copy constructor and operator= functions.
--//
--// This should be used in the private: declarations for a class
--// that wants to prevent anyone from instantiating it. This is
--// especially useful for classes containing only static methods.
--#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
-- TypeName(); \
-- DISALLOW_COPY_AND_ASSIGN(TypeName)
--
--// The arraysize(arr) macro returns the # of elements in an array arr.
--// The expression is a compile-time constant, and therefore can be
--// used in defining new arrays, for example. If you use arraysize on
--// a pointer by mistake, you will get a compile-time error.
--//
--// One caveat is that arraysize() doesn't accept any array of an
--// anonymous type or a type defined inside a function. In these rare
--// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below. This is
--// due to a limitation in C++'s template system. The limitation might
--// eventually be removed, but it hasn't happened yet.
--
--// This template function declaration is used in defining arraysize.
--// Note that the function doesn't need an implementation, as we only
--// use its type.
--template <typename T, size_t N>
--char (&ArraySizeHelper(T (&array)[N]))[N];
--
--// That gcc wants both of these prototypes seems mysterious. VC, for
--// its part, can't decide which to use (another mystery). Matching of
--// template overloads: the final frontier.
--#ifndef _MSC_VER
--template <typename T, size_t N>
--char (&ArraySizeHelper(const T (&array)[N]))[N];
--#endif
--
--#define arraysize(array) (sizeof(ArraySizeHelper(array)))
--
--// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize,
--// but can be used on anonymous types or types defined inside
--// functions. It's less safe than arraysize as it accepts some
--// (although not all) pointers. Therefore, you should use arraysize
--// whenever possible.
--//
--// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type
--// size_t.
--//
--// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error
--//
--// "warning: division by zero in ..."
--//
--// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer.
--// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays.
--//
--// The following comments are on the implementation details, and can
--// be ignored by the users.
--//
--// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in
--// the array) and sizeof(*(arr)) (the # of bytes in one array
--// element). If the former is divisible by the latter, perhaps arr is
--// indeed an array, in which case the division result is the # of
--// elements in the array. Otherwise, arr cannot possibly be an array,
--// and we generate a compiler error to prevent the code from
--// compiling.
--//
--// Since the size of bool is implementation-defined, we need to cast
--// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final
--// result has type size_t.
--//
--// This macro is not perfect as it wrongfully accepts certain
--// pointers, namely where the pointer size is divisible by the pointee
--// size. Since all our code has to go through a 32-bit compiler,
--// where a pointer is 4 bytes, this means all pointers to a type whose
--// size is 3 or greater than 4 will be (righteously) rejected.
--
--#define ARRAYSIZE_UNSAFE(a) \
-- ((sizeof(a) / sizeof(*(a))) / \
-- static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
--
--
--// Use implicit_cast as a safe version of static_cast or const_cast
--// for upcasting in the type hierarchy (i.e. casting a pointer to Foo
--// to a pointer to SuperclassOfFoo or casting a pointer to Foo to
--// a const pointer to Foo).
--// When you use implicit_cast, the compiler checks that the cast is safe.
--// Such explicit implicit_casts are necessary in surprisingly many
--// situations where C++ demands an exact type match instead of an
--// argument type convertable to a target type.
--//
--// The From type can be inferred, so the preferred syntax for using
--// implicit_cast is the same as for static_cast etc.:
--//
--// implicit_cast<ToType>(expr)
--//
--// implicit_cast would have been part of the C++ standard library,
--// but the proposal was submitted too late. It will probably make
--// its way into the language in the future.
--template<typename To, typename From>
--inline To implicit_cast(From const &f) {
-- return f;
--}
--
--// The COMPILE_ASSERT macro can be used to verify that a compile time
--// expression is true. For example, you could use it to verify the
--// size of a static array:
--//
--// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES,
--// content_type_names_incorrect_size);
--//
--// or to make sure a struct is smaller than a certain size:
--//
--// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
--//
--// The second argument to the macro is the name of the variable. If
--// the expression is false, most compilers will issue a warning/error
--// containing the name of the variable.
--
--template <bool>
--struct CompileAssert {
--};
--
--#undef COMPILE_ASSERT
--#define COMPILE_ASSERT(expr, msg) \
-- typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
--
--// Implementation details of COMPILE_ASSERT:
--//
--// - COMPILE_ASSERT works by defining an array type that has -1
--// elements (and thus is invalid) when the expression is false.
--//
--// - The simpler definition
--//
--// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1]
--//
--// does not work, as gcc supports variable-length arrays whose sizes
--// are determined at run-time (this is gcc's extension and not part
--// of the C++ standard). As a result, gcc fails to reject the
--// following code with the simple definition:
--//
--// int foo;
--// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is
--// // not a compile-time constant.
--//
--// - By using the type CompileAssert<(bool(expr))>, we ensures that
--// expr is a compile-time constant. (Template arguments must be
--// determined at compile-time.)
--//
--// - The outter parentheses in CompileAssert<(bool(expr))> are necessary
--// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written
--//
--// CompileAssert<bool(expr)>
--//
--// instead, these compilers will refuse to compile
--//
--// COMPILE_ASSERT(5 > 0, some_message);
--//
--// (They seem to think the ">" in "5 > 0" marks the end of the
--// template argument list.)
--//
--// - The array size is (bool(expr) ? 1 : -1), instead of simply
--//
--// ((expr) ? 1 : -1).
--//
--// This is to avoid running into a bug in MS VC 7.1, which
--// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
--
--
--// MetatagId refers to metatag-id that we assign to
--// each metatag <name, value> pair..
--typedef uint32 MetatagId;
--
--// Argument type used in interfaces that can optionally take ownership
--// of a passed in argument. If TAKE_OWNERSHIP is passed, the called
--// object takes ownership of the argument. Otherwise it does not.
--enum Ownership {
-- DO_NOT_TAKE_OWNERSHIP,
-- TAKE_OWNERSHIP
--};
--
--// bit_cast<Dest,Source> is a template function that implements the
--// equivalent of "*reinterpret_cast<Dest*>(&source)". We need this in
--// very low-level functions like the protobuf library and fast math
--// support.
--//
--// float f = 3.14159265358979;
--// int i = bit_cast<int32>(f);
--// // i = 0x40490fdb
--//
--// The classical address-casting method is:
--//
--// // WRONG
--// float f = 3.14159265358979; // WRONG
--// int i = * reinterpret_cast<int*>(&f); // WRONG
--//
--// The address-casting method actually produces undefined behavior
--// according to ISO C++ specification section 3.10 -15 -. Roughly, this
--// section says: if an object in memory has one type, and a program
--// accesses it with a different type, then the result is undefined
--// behavior for most values of "different type".
--//
--// This is true for any cast syntax, either *(int*)&f or
--// *reinterpret_cast<int*>(&f). And it is particularly true for
--// conversions betweeen integral lvalues and floating-point lvalues.
--//
--// The purpose of 3.10 -15- is to allow optimizing compilers to assume
--// that expressions with different types refer to different memory. gcc
--// 4.0.1 has an optimizer that takes advantage of this. So a
--// non-conforming program quietly produces wildly incorrect output.
--//
--// The problem is not the use of reinterpret_cast. The problem is type
--// punning: holding an object in memory of one type and reading its bits
--// back using a different type.
--//
--// The C++ standard is more subtle and complex than this, but that
--// is the basic idea.
--//
--// Anyways ...
--//
--// bit_cast<> calls memcpy() which is blessed by the standard,
--// especially by the example in section 3.9 . Also, of course,
--// bit_cast<> wraps up the nasty logic in one place.
--//
--// Fortunately memcpy() is very fast. In optimized mode, with a
--// constant size, gcc 2.95.3, gcc 4.0.1, and msvc 7.1 produce inline
--// code with the minimal amount of data movement. On a 32-bit system,
--// memcpy(d,s,4) compiles to one load and one store, and memcpy(d,s,8)
--// compiles to two loads and two stores.
--//
--// I tested this code with gcc 2.95.3, gcc 4.0.1, icc 8.1, and msvc 7.1.
--//
--// WARNING: if Dest or Source is a non-POD type, the result of the memcpy
--// is likely to surprise you.
--
--template <class Dest, class Source>
--inline Dest bit_cast(const Source& source) {
-- // Compile time assertion: sizeof(Dest) == sizeof(Source)
-- // A compile error here means your Dest and Source have different sizes.
-- typedef char VerifySizesAreEqual [sizeof(Dest) == sizeof(Source) ? 1 : -1];
--
-- Dest dest;
-- memcpy(&dest, &source, sizeof(dest));
-- return dest;
--}
--
--// Used to explicitly mark the return value of a function as unused. If you are
--// really sure you don't want to do anything with the return value of a function
--// that has been marked WARN_UNUSED_RESULT, wrap it with this. Example:
--//
--// scoped_ptr<MyType> my_var = ...;
--// if (TakeOwnership(my_var.get()) == SUCCESS)
--// ignore_result(my_var.release());
--//
--template<typename T>
--inline void ignore_result(const T& ignored) {
--}
--
--// 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 base::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 destructor also
--// does nothing to the storage, AND there are no virtual methods, then a
--// constructor declared as
--// explicit MyClass(base::LinkerInitialized x) {}
--// and invoked as
--// static MyClass my_variable_name(base::LINKER_INITIALIZED);
--namespace base {
--enum LinkerInitialized { LINKER_INITIALIZED };
--} // base
--
--#endif // BASE_BASICTYPES_H_
-Index: src/base/logging.h
-===================================================================
---- src/base/logging.h (revision 277)
-+++ src/base/logging.h (working copy)
-@@ -1,33 +0,0 @@
--// Copyright (C) 2011 Google Inc.
--//
--// Licensed under the Apache License, Version 2.0 (the "License");
--// you may not use this file except in compliance with the License.
--// You may obtain a copy of the License at
--//
--// http://www.apache.org/licenses/LICENSE-2.0
--//
--// Unless required by applicable law or agreed to in writing, software
--// distributed under the License is distributed on an "AS IS" BASIS,
--// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--// See the License for the specific language governing permissions and
--// limitations under the License.
--
--// Author: Philippe Liard
--
--// This file does not come from Chromium.
--// It provides a minimalist implementation of common macros.
--
--#ifndef BASE_LOGGING_H_
--# define BASE_LOGGING_H_
--
--# include <cassert>
--# include <iostream>
--
--# define CHECK_EQ(X, Y) assert((X) == (Y))
--
--# define DCHECK(X) assert(X)
--# define DCHECK_EQ(X, Y) CHECK_EQ((X), (Y))
--
--# define NOTREACHED() std::cerr
--
--#endif
diff --git a/third_party/libphonenumber/patches/version277a.patch b/third_party/libphonenumber/patches/version277a.patch
deleted file mode 100644
index 8757107..0000000
--- a/third_party/libphonenumber/patches/version277a.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff -Naur src-orig/default_logger.h src/default_logger.h
---- src-orig/default_logger.h 2011-07-02 16:27:58.000000000 -0700
-+++ src/default_logger.h 2011-07-02 16:28:29.000000000 -0700
-@@ -17,6 +17,8 @@
- #ifndef I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
- #define I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
-
-+#include <stdio.h>
-+
- #include <string>
-
- #include "logger.h"
-@@ -45,7 +47,7 @@
- struct ConvertToString<int> {
- static inline string DoWork(const int& n) {
- char buffer[16];
-- std::snprintf(buffer, sizeof(buffer), "%d", n);
-+ snprintf(buffer, sizeof(buffer), "%d", n);
- return string(buffer);
- }
- };