libre2.patch 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. diff -rupN re2_orig/re2/compile.cc re2_new/re2/compile.cc
  2. --- re2_orig/re2/compile.cc 2015-06-03 21:01:39.859724500 +0300
  3. +++ re2_new/re2/compile.cc 2015-06-03 21:04:00.834589300 +0300
  4. @@ -7,7 +7,10 @@
  5. // Prog and Inst are defined in prog.h.
  6. // This file's external interface is just Regexp::CompileToProg.
  7. // The Compiler class defined in this file is private.
  8. -
  9. +#ifdef WIN32
  10. +#include <stdio.h>
  11. +#define snprintf _snprintf
  12. +#endif
  13. #include "re2/prog.h"
  14. #include "re2/re2.h"
  15. #include "re2/regexp.h"
  16. @@ -503,7 +506,7 @@ int Compiler::RuneByteSuffix(uint8 lo, u
  17. return UncachedRuneByteSuffix(lo, hi, foldcase, next);
  18. }
  19. - uint64 key = ((uint64)next << 17) | (lo<<9) | (hi<<1) | foldcase;
  20. + uint64 key = ((uint64)next << 17) | (lo<<9) | (hi<<1) | (foldcase ? 1ULL : 0ULL);
  21. map<uint64, int>::iterator it = rune_cache_.find(key);
  22. if (it != rune_cache_.end())
  23. return it->second;
  24. diff -rupN re2_orig/re2/prefilter_tree.cc re2_new/re2/prefilter_tree.cc
  25. --- re2_orig/re2/prefilter_tree.cc 2015-06-03 21:01:39.941447500 +0300
  26. +++ re2_new/re2/prefilter_tree.cc 2015-06-03 21:04:34.520203500 +0300
  27. @@ -7,6 +7,10 @@
  28. #include "re2/prefilter.h"
  29. #include "re2/prefilter_tree.h"
  30. #include "re2/re2.h"
  31. +#ifdef WIN32
  32. +#include <stdio.h>
  33. +#define snprintf _snprintf
  34. +#endif
  35. DEFINE_int32(filtered_re2_min_atom_len,
  36. 3,
  37. diff -rupN re2_orig/re2/re2.cc re2_new/re2/re2.cc
  38. --- re2_orig/re2/re2.cc 2015-06-03 21:01:39.959349200 +0300
  39. +++ re2_new/re2/re2.cc 2015-06-03 21:05:47.173725000 +0300
  40. @@ -11,7 +11,13 @@
  41. #include <stdio.h>
  42. #include <string>
  43. -#include <pthread.h>
  44. +#ifdef WIN32
  45. +#define strtoll _strtoi64
  46. +#define strtoull _strtoui64
  47. +#define strtof strtod
  48. +#else
  49. + #include <pthread.h>
  50. +#endif
  51. #include <errno.h>
  52. #include "util/atomicops.h"
  53. #include "util/util.h"
  54. @@ -35,7 +41,7 @@ const VariadicFunction2<bool, StringPiec
  55. // This will trigger LNK2005 error in MSVC.
  56. #ifndef COMPILER_MSVC
  57. -const int RE2::Options::kDefaultMaxMem; // initialized in re2.h
  58. +//const int RE2::Options::kDefaultMaxMem; // initialized in re2.h
  59. #endif // COMPILER_MSVC
  60. RE2::Options::Options(RE2::CannedOptions opt)
  61. diff -rupN re2_orig/re2/re2.h re2_new/re2/re2.h
  62. --- re2_orig/re2/re2.h 2015-06-03 21:01:39.963230400 +0300
  63. +++ re2_new/re2/re2.h 2015-06-03 21:06:35.371015500 +0300
  64. @@ -5,6 +5,7 @@
  65. #ifndef RE2_RE2_H
  66. #define RE2_RE2_H
  67. +#define kDefaultMaxMem (8<<20)
  68. // C++ interface to the re2 regular-expression library.
  69. // RE2 supports Perl-style regular expressions (with extensions like
  70. // \d, \w, \s, ...).
  71. @@ -563,7 +564,6 @@ class RE2 {
  72. // If this happens too often, RE2 falls back on the NFA implementation.
  73. // For now, make the default budget something close to Code Search.
  74. - static const int kDefaultMaxMem = 8<<20;
  75. enum Encoding {
  76. EncodingUTF8 = 1,
  77. diff -rupN re2_orig/re2/stringpiece.h re2_new/re2/stringpiece.h
  78. --- re2_orig/re2/stringpiece.h 2015-06-03 21:01:39.999380800 +0300
  79. +++ re2_new/re2/stringpiece.h 2015-06-03 21:07:02.478501800 +0300
  80. @@ -23,6 +23,9 @@
  81. #include <cstddef>
  82. #include <iosfwd>
  83. #include <string>
  84. +#ifdef WIN32
  85. +#include <algorithm>
  86. +#endif
  87. namespace re2 {
  88. diff -rupN re2_orig/util/logging.h re2_new/util/logging.h
  89. --- re2_orig/util/logging.h 2015-06-03 21:01:40.236689900 +0300
  90. +++ re2_new/util/logging.h 2015-06-03 21:07:48.737390800 +0300
  91. @@ -7,7 +7,11 @@
  92. #ifndef RE2_UTIL_LOGGING_H__
  93. #define RE2_UTIL_LOGGING_H__
  94. -#include <unistd.h> /* for write */
  95. +#ifdef WIN32
  96. + #include <io.h>
  97. +#else
  98. + #include <unistd.h> /* for write */
  99. +#endif
  100. #include <sstream>
  101. // Debug-only checking.
  102. diff -rupN re2_orig/util/mutex.h re2_new/util/mutex.h
  103. --- re2_orig/util/mutex.h 2015-06-03 21:01:40.240105400 +0300
  104. +++ re2_new/util/mutex.h 2015-06-03 21:08:41.660376900 +0300
  105. @@ -14,7 +14,10 @@
  106. namespace re2 {
  107. -#define HAVE_PTHREAD 1
  108. +#ifndef WIN32
  109. + #define HAVE_PTHREAD 1
  110. + #define HAVE_RWLOCK 1
  111. +#endif
  112. #define HAVE_RWLOCK 1
  113. #if defined(NO_THREADS)
  114. diff -rupN re2_orig/util/stringprintf.cc re2_new/util/stringprintf.cc
  115. --- re2_orig/util/stringprintf.cc 2015-06-03 21:01:40.271834700 +0300
  116. +++ re2_new/util/stringprintf.cc 2015-06-03 21:09:07.784384200 +0300
  117. @@ -3,6 +3,9 @@
  118. // license that can be found in the LICENSE file.
  119. #include "util/util.h"
  120. +#ifndef va_copy
  121. +#define va_copy(d,s) ((d) = (s)) //KLUGE: for MS compilers
  122. +#endif
  123. namespace re2 {
  124. diff -rupN re2_orig/util/util.h re2_new/util/util.h
  125. --- re2_orig/util/util.h 2015-06-03 21:01:40.304059500 +0300
  126. +++ re2_new/util/util.h 2015-06-04 14:27:55.625698100 +0300
  127. @@ -64,12 +64,12 @@ using std::unordered_set;
  128. #ifdef WIN32
  129. #define snprintf _snprintf_s
  130. -#define sprintf sprintf_s
  131. +//#define sprintf sprintf_s
  132. #define stricmp _stricmp
  133. #define strtof strtod /* not really correct but best we can do */
  134. #define strtoll _strtoi64
  135. #define strtoull _strtoui64
  136. -#define vsnprintf vsnprintf_s
  137. +//#define vsnprintf vsnprintf_s
  138. #pragma warning(disable: 4018) // signed/unsigned mismatch
  139. #pragma warning(disable: 4244) // possible data loss in int conversion
  140. diff -rupN re2_orig/util/valgrind.h re2_new/util/valgrind.h
  141. --- re2_orig/util/valgrind.h 2015-06-03 21:01:40.315784200 +0300
  142. +++ re2_new/util/valgrind.h 2015-06-03 21:11:07.508240700 +0300
  143. @@ -126,6 +126,7 @@
  144. #endif
  145. +#ifndef WIN32
  146. /* ------------------------------------------------------------------ */
  147. /* ARCHITECTURE SPECIFICS for SPECIAL INSTRUCTIONS. There is nothing */
  148. /* in here of use to end-users -- skip to the next section. */
  149. @@ -4171,6 +4172,7 @@ typedef
  150. _qzz_addr, _qzz_len, 0, 0, 0); \
  151. }
  152. +#endif
  153. /* These requests are for getting Valgrind itself to print something.
  154. Possibly with a backtrace. This is a really ugly hack. The return value