Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Copyright 2016 The RE2 Authors. All Rights Reserved. | 5 // Copyright 2016 The RE2 Authors. All Rights Reserved. |
| 6 // Use of this source code is governed by a BSD-style | 6 // Use of this source code is governed by a BSD-style |
| 7 // license that can be found in the LICENSE file. | 7 // license that can be found in the LICENSE file. |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 | 11 |
| 12 #include <map> | 12 #include <map> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "re2/re2.h" | 15 #include "re2/re2.h" |
| 16 #include "util/logging.h" | |
|
tfarina
2017/02/13 10:09:05
Is this change and the other below necessary for t
mmoroz
2017/02/13 10:15:46
Yes. This header doesn't exist anymore. Due to tha
| |
| 17 | 16 |
| 18 using re2::StringPiece; | 17 using re2::StringPiece; |
| 19 using std::string; | 18 using std::string; |
| 20 | 19 |
| 21 // NOT static, NOT signed. | 20 // NOT static, NOT signed. |
| 22 uint8_t dummy = 0; | 21 uint8_t dummy = 0; |
| 23 | 22 |
| 24 void Test(StringPiece pattern, const RE2::Options& options, StringPiece text) { | 23 void Test(StringPiece pattern, const RE2::Options& options, StringPiece text) { |
| 25 RE2 re(pattern, options); | 24 RE2 re(pattern, options); |
| 26 if (!re.ok()) | 25 if (!re.ok()) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 uint32_t hash = 0; | 62 uint32_t hash = 0; |
| 64 for (size_t i = 0; i < size; i++) { | 63 for (size_t i = 0; i < size; i++) { |
| 65 hash += data[i]; | 64 hash += data[i]; |
| 66 hash += (hash << 10); | 65 hash += (hash << 10); |
| 67 hash ^= (hash >> 6); | 66 hash ^= (hash >> 6); |
| 68 } | 67 } |
| 69 hash += (hash << 3); | 68 hash += (hash << 3); |
| 70 hash ^= (hash >> 11); | 69 hash ^= (hash >> 11); |
| 71 hash += (hash << 15); | 70 hash += (hash << 15); |
| 72 | 71 |
| 73 re2::FLAGS_minloglevel = 3; | |
| 74 RE2::Options options; | 72 RE2::Options options; |
| 75 options.set_log_errors(false); | 73 options.set_log_errors(false); |
| 76 options.set_encoding(hash & 1 ? RE2::Options::EncodingLatin1 | 74 options.set_encoding(hash & 1 ? RE2::Options::EncodingLatin1 |
| 77 : RE2::Options::EncodingUTF8); | 75 : RE2::Options::EncodingUTF8); |
| 78 options.set_posix_syntax(hash & 2); | 76 options.set_posix_syntax(hash & 2); |
| 79 options.set_longest_match(hash & 4); | 77 options.set_longest_match(hash & 4); |
| 80 options.set_literal(hash & 8); | 78 options.set_literal(hash & 8); |
| 81 options.set_never_nl(hash & 16); | 79 options.set_never_nl(hash & 16); |
| 82 options.set_dot_nl(hash & 32); | 80 options.set_dot_nl(hash & 32); |
| 83 options.set_never_capture(hash & 64); | 81 options.set_never_capture(hash & 64); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 98 break; | 96 break; |
| 99 | 97 |
| 100 int frac = len / i; | 98 int frac = len / i; |
| 101 pattern = StringPiece(ptr, frac); | 99 pattern = StringPiece(ptr, frac); |
| 102 text = StringPiece(ptr + frac, len - frac); | 100 text = StringPiece(ptr + frac, len - frac); |
| 103 Test(pattern, options, text); | 101 Test(pattern, options, text); |
| 104 } | 102 } |
| 105 | 103 |
| 106 return 0; | 104 return 0; |
| 107 } | 105 } |
| OLD | NEW |