OLD | NEW |
(Empty) | |
| 1 diff --git a/AUTHORS b/AUTHORS |
| 2 index 3c0f928..e17d9bf 100644 |
| 3 --- a/AUTHORS |
| 4 +++ b/AUTHORS |
| 5 @@ -8,5 +8,6 @@ |
| 6 |
| 7 # Please keep the list sorted. |
| 8 |
| 9 +Brian Gunlogson <unixman83@gmail.com> |
| 10 Google Inc. |
| 11 Stefano Rivera <stefano.rivera@gmail.com> |
| 12 diff --git a/CONTRIBUTORS b/CONTRIBUTORS |
| 13 index 7b44e04..7f6a93d 100644 |
| 14 --- a/CONTRIBUTORS |
| 15 +++ b/CONTRIBUTORS |
| 16 @@ -26,6 +26,7 @@ |
| 17 |
| 18 # Please keep the list sorted. |
| 19 |
| 20 +Brian Gunlogson <unixman83@gmail.com> |
| 21 Dominic Battré <battre@chromium.org> |
| 22 John Millikin <jmillikin@gmail.com> |
| 23 Rob Pike <r@google.com> |
| 24 diff --git a/re2/compile.cc b/re2/compile.cc |
| 25 index 9cddb71..adb45fd 100644 |
| 26 --- a/re2/compile.cc |
| 27 +++ b/re2/compile.cc |
| 28 @@ -502,7 +502,7 @@ int Compiler::RuneByteSuffix(uint8 lo, uint8 hi, bool foldca
se, int next) { |
| 29 return UncachedRuneByteSuffix(lo, hi, foldcase, next); |
| 30 } |
| 31 |
| 32 - uint64 key = ((uint64)next << 17) | (lo<<9) | (hi<<1) | foldcase; |
| 33 + uint64 key = ((uint64)next << 17) | (lo<<9) | (hi<<1) | (foldcase ? 1ULL : 0U
LL); |
| 34 map<uint64, int>::iterator it = rune_cache_.find(key); |
| 35 if (it != rune_cache_.end()) |
| 36 return it->second; |
| 37 diff --git a/re2/prefilter_tree.cc b/re2/prefilter_tree.cc |
| 38 index d8bc37a..cdcf77e 100644 |
| 39 --- a/re2/prefilter_tree.cc |
| 40 +++ b/re2/prefilter_tree.cc |
| 41 @@ -8,6 +8,11 @@ |
| 42 #include "re2/prefilter_tree.h" |
| 43 #include "re2/re2.h" |
| 44 |
| 45 +#ifdef WIN32 |
| 46 +#include <stdio.h> |
| 47 +#define snprintf _snprintf |
| 48 +#endif |
| 49 + |
| 50 DEFINE_int32(filtered_re2_min_atom_len, |
| 51 3, |
| 52 "Strings less than this length are not stored as atoms"); |
| 53 diff --git a/re2/re2.cc b/re2/re2.cc |
| 54 index 8d1d468..0da886d 100644 |
| 55 --- a/re2/re2.cc |
| 56 +++ b/re2/re2.cc |
| 57 @@ -11,7 +11,13 @@ |
| 58 |
| 59 #include <stdio.h> |
| 60 #include <string> |
| 61 +#ifdef WIN32 |
| 62 +#define strtoll _strtoi64 |
| 63 +#define strtoull _strtoui64 |
| 64 +#define strtof strtod |
| 65 +#else |
| 66 #include <pthread.h> |
| 67 +#endif |
| 68 #include <errno.h> |
| 69 #include "util/util.h" |
| 70 #include "util/flags.h" |
| 71 @@ -31,10 +37,22 @@ const VariadicFunction2<bool, const StringPiece&, const RE2&
, RE2::Arg, RE2::Par |
| 72 const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::ConsumeN
> RE2::Consume; |
| 73 const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::FindAndC
onsumeN> RE2::FindAndConsume; |
| 74 |
| 75 -// This will trigger LNK2005 error in MSVC. |
| 76 -#ifndef COMPILER_MSVC |
| 77 -const int RE2::Options::kDefaultMaxMem; // initialized in re2.h |
| 78 -#endif // COMPILER_MSVC |
| 79 +#define kDefaultMaxMem (8<<20) |
| 80 + |
| 81 +RE2::Options::Options() |
| 82 + : encoding_(EncodingUTF8), |
| 83 + posix_syntax_(false), |
| 84 + longest_match_(false), |
| 85 + log_errors_(true), |
| 86 + max_mem_(kDefaultMaxMem), |
| 87 + literal_(false), |
| 88 + never_nl_(false), |
| 89 + never_capture_(false), |
| 90 + case_sensitive_(true), |
| 91 + perl_classes_(false), |
| 92 + word_boundary_(false), |
| 93 + one_line_(false) { |
| 94 +} |
| 95 |
| 96 RE2::Options::Options(RE2::CannedOptions opt) |
| 97 : encoding_(opt == RE2::Latin1 ? EncodingLatin1 : EncodingUTF8), |
| 98 diff --git a/re2/re2.h b/re2/re2.h |
| 99 index 272028b..c509853 100644 |
| 100 --- a/re2/re2.h |
| 101 +++ b/re2/re2.h |
| 102 @@ -552,28 +552,16 @@ class RE2 { |
| 103 // If this happens too often, RE2 falls back on the NFA implementation. |
| 104 |
| 105 // For now, make the default budget something close to Code Search. |
| 106 +#ifndef WIN32 |
| 107 static const int kDefaultMaxMem = 8<<20; |
| 108 +#endif |
| 109 |
| 110 enum Encoding { |
| 111 EncodingUTF8 = 1, |
| 112 EncodingLatin1 |
| 113 }; |
| 114 |
| 115 - Options() : |
| 116 - encoding_(EncodingUTF8), |
| 117 - posix_syntax_(false), |
| 118 - longest_match_(false), |
| 119 - log_errors_(true), |
| 120 - max_mem_(kDefaultMaxMem), |
| 121 - literal_(false), |
| 122 - never_nl_(false), |
| 123 - never_capture_(false), |
| 124 - case_sensitive_(true), |
| 125 - perl_classes_(false), |
| 126 - word_boundary_(false), |
| 127 - one_line_(false) { |
| 128 - } |
| 129 - |
| 130 + Options(); |
| 131 /*implicit*/ Options(CannedOptions); |
| 132 |
| 133 Encoding encoding() const { return encoding_; } |
| 134 diff --git a/re2/stringpiece.h b/re2/stringpiece.h |
| 135 index ab9297c..38a5150 100644 |
| 136 --- a/re2/stringpiece.h |
| 137 +++ b/re2/stringpiece.h |
| 138 @@ -23,6 +23,9 @@ |
| 139 #include <cstddef> |
| 140 #include <iosfwd> |
| 141 #include <string> |
| 142 +#ifdef WIN32 |
| 143 +#include <algorithm> |
| 144 +#endif |
| 145 |
| 146 namespace re2 { |
| 147 |
| 148 diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc |
| 149 index b99cacf..911e868 100644 |
| 150 --- a/re2/testing/re2_test.cc |
| 151 +++ b/re2/testing/re2_test.cc |
| 152 @@ -6,7 +6,9 @@ |
| 153 // TODO: Test extractions for PartialMatch/Consume |
| 154 |
| 155 #include <sys/types.h> |
| 156 +#ifndef WIN32 |
| 157 #include <sys/mman.h> |
| 158 +#endif |
| 159 #include <sys/stat.h> |
| 160 #include <errno.h> |
| 161 #include <vector> |
| 162 @@ -14,6 +16,11 @@ |
| 163 #include "re2/re2.h" |
| 164 #include "re2/regexp.h" |
| 165 |
| 166 +#ifdef WIN32 |
| 167 +#include <stdio.h> |
| 168 +#define snprintf _snprintf |
| 169 +#endif |
| 170 + |
| 171 DECLARE_bool(logtostderr); |
| 172 |
| 173 namespace re2 { |
| 174 @@ -657,6 +664,7 @@ TEST(RE2, FullMatchTypedNullArg) { |
| 175 CHECK(!RE2::FullMatch("hello", "(.*)", (float*)NULL)); |
| 176 } |
| 177 |
| 178 +#ifndef WIN32 |
| 179 // Check that numeric parsing code does not read past the end of |
| 180 // the number being parsed. |
| 181 TEST(RE2, NULTerminated) { |
| 182 @@ -678,6 +686,7 @@ TEST(RE2, NULTerminated) { |
| 183 CHECK(RE2::FullMatch(StringPiece(v + pagesize - 1, 1), "(.*)", &x)); |
| 184 CHECK_EQ(x, 1); |
| 185 } |
| 186 +#endif |
| 187 |
| 188 TEST(RE2, FullMatchTypeTests) { |
| 189 // Type tests |
| 190 diff --git a/util/logging.h b/util/logging.h |
| 191 index 4443f7c..d0a2d87 100644 |
| 192 --- a/util/logging.h |
| 193 +++ b/util/logging.h |
| 194 @@ -7,8 +7,13 @@ |
| 195 #ifndef RE2_UTIL_LOGGING_H__ |
| 196 #define RE2_UTIL_LOGGING_H__ |
| 197 |
| 198 +#ifndef WIN32 |
| 199 #include <unistd.h> /* for write */ |
| 200 +#endif |
| 201 #include <sstream> |
| 202 +#ifdef WIN32 |
| 203 +#include <io.h> |
| 204 +#endif |
| 205 |
| 206 // Debug-only checking. |
| 207 #define DCHECK(condition) assert(condition) |
| 208 diff --git a/util/mutex.h b/util/mutex.h |
| 209 index 9787bfb..e321fae 100644 |
| 210 --- a/util/mutex.h |
| 211 +++ b/util/mutex.h |
| 212 @@ -12,8 +12,10 @@ |
| 213 |
| 214 namespace re2 { |
| 215 |
| 216 +#ifndef WIN32 |
| 217 #define HAVE_PTHREAD 1 |
| 218 #define HAVE_RWLOCK 1 |
| 219 +#endif |
| 220 |
| 221 #if defined(NO_THREADS) |
| 222 typedef int MutexType; // to keep a lock-count |
| 223 @@ -32,7 +34,9 @@ namespace re2 { |
| 224 # include <pthread.h> |
| 225 typedef pthread_mutex_t MutexType; |
| 226 #elif defined(WIN32) |
| 227 -# define WIN32_LEAN_AND_MEAN // We only need minimal includes |
| 228 +# ifndef WIN32_LEAN_AND_MEAN |
| 229 +# define WIN32_LEAN_AND_MEAN // We only need minimal includes |
| 230 +# endif |
| 231 # ifdef GMUTEX_TRYLOCK |
| 232 // We need Windows NT or later for TryEnterCriticalSection(). If you |
| 233 // don't need that functionality, you can remove these _WIN32_WINNT |
| 234 diff --git a/util/pcre.cc b/util/pcre.cc |
| 235 index 5e67e1f..1602133 100644 |
| 236 --- a/util/pcre.cc |
| 237 +++ b/util/pcre.cc |
| 238 @@ -11,6 +11,11 @@ |
| 239 #include "util/flags.h" |
| 240 #include "util/pcre.h" |
| 241 |
| 242 +#ifdef WIN32 |
| 243 +#define strtoll _strtoi64 |
| 244 +#define strtoull _strtoui64 |
| 245 +#endif |
| 246 + |
| 247 #define PCREPORT(level) LOG(level) |
| 248 |
| 249 // Default PCRE limits. |
| 250 diff --git a/util/pcre.h b/util/pcre.h |
| 251 index 4dda95d..771ac91 100644 |
| 252 --- a/util/pcre.h |
| 253 +++ b/util/pcre.h |
| 254 @@ -180,9 +180,15 @@ struct pcre_extra { int flags, match_limit, match_limit_rec
ursion; }; |
| 255 #define PCRE_ERROR_MATCHLIMIT 2 |
| 256 #define PCRE_ERROR_RECURSIONLIMIT 3 |
| 257 #define PCRE_INFO_CAPTURECOUNT 0 |
| 258 +#ifndef WIN32 |
| 259 #define pcre_compile(a,b,c,d,e) ({ (void)(a); (void)(b); *(c)=""; *(d)=0; (void
)(e); ((pcre*)0); }) |
| 260 #define pcre_exec(a, b, c, d, e, f, g, h) ({ (void)(a); (void)(b); (void)(c); (
void)(d); (void)(e); (void)(f); (void)(g); (void)(h); 0; }) |
| 261 #define pcre_fullinfo(a, b, c, d) ({ (void)(a); (void)(b); (void)(c); *(d) = 0;
0; }) |
| 262 +#else |
| 263 +#define pcre_compile(a,b,c,d,e) NULL |
| 264 +#define pcre_exec(a, b, c, d, e, f, g, h) NULL |
| 265 +#define pcre_fullinfo(a, b, c, d) NULL |
| 266 +#endif |
| 267 } // namespace re2 |
| 268 #endif |
| 269 |
| 270 diff --git a/util/test.cc b/util/test.cc |
| 271 index 0644829..2fe1bfa 100644 |
| 272 --- a/util/test.cc |
| 273 +++ b/util/test.cc |
| 274 @@ -3,7 +3,9 @@ |
| 275 // license that can be found in the LICENSE file. |
| 276 |
| 277 #include <stdio.h> |
| 278 +#ifndef WIN32 |
| 279 #include <sys/resource.h> |
| 280 +#endif |
| 281 #include "util/test.h" |
| 282 |
| 283 DEFINE_string(test_tmpdir, "/var/tmp", "temp directory"); |
| 284 @@ -23,9 +25,13 @@ void RegisterTest(void (*fn)(void), const char *name) { |
| 285 |
| 286 namespace re2 { |
| 287 int64 VirtualProcessSize() { |
| 288 +#ifndef WIN32 |
| 289 struct rusage ru; |
| 290 getrusage(RUSAGE_SELF, &ru); |
| 291 return (int64)ru.ru_maxrss*1024; |
| 292 +#else |
| 293 + return 0; |
| 294 +#endif |
| 295 } |
| 296 } // namespace re2 |
| 297 |
| 298 diff --git a/util/util.h b/util/util.h |
| 299 index c46ab1b..17ef824 100644 |
| 300 --- a/util/util.h |
| 301 +++ b/util/util.h |
| 302 @@ -12,7 +12,9 @@ |
| 303 #include <stddef.h> // For size_t |
| 304 #include <assert.h> |
| 305 #include <stdarg.h> |
| 306 +#ifndef WIN32 |
| 307 #include <sys/time.h> |
| 308 +#endif |
| 309 #include <time.h> |
| 310 #include <ctype.h> // For isdigit, isalpha. |
| 311 |
| 312 @@ -51,7 +53,11 @@ using std::tr1::unordered_set; |
| 313 #else |
| 314 |
| 315 #include <unordered_set> |
| 316 +#ifdef WIN32 |
| 317 +using std::tr1::unordered_set; |
| 318 +#else |
| 319 using std::unordered_set; |
| 320 +#endif |
| 321 |
| 322 #endif |
| 323 |
| 324 diff --git a/util/valgrind.h b/util/valgrind.h |
| 325 index ca10b1a..d097b0c 100644 |
| 326 --- a/util/valgrind.h |
| 327 +++ b/util/valgrind.h |
| 328 @@ -4064,6 +4064,7 @@ typedef |
| 329 #endif /* PLAT_ppc64_aix5 */ |
| 330 |
| 331 |
| 332 +#ifndef WIN32 |
| 333 /* ------------------------------------------------------------------ */ |
| 334 /* ARCHITECTURE INDEPENDENT MACROS for CLIENT REQUESTS. */ |
| 335 /* */ |
| 336 @@ -4170,7 +4171,7 @@ typedef |
| 337 VG_USERREQ__DISCARD_TRANSLATIONS, \ |
| 338 _qzz_addr, _qzz_len, 0, 0, 0); \ |
| 339 } |
| 340 - |
| 341 +#endif |
| 342 |
| 343 /* These requests are for getting Valgrind itself to print something. |
| 344 Possibly with a backtrace. This is a really ugly hack. The return value |
OLD | NEW |