1 diff --git a/re2/compile.cc b/re2/compile.cc 2 index adb45fd..14e401a 100644 3 --- a/re2/compile.cc 4 +++ b/re2/compile.cc 5 @@ -44,7 +44,7 @@ struct PatchList { 6 static PatchList Append(Prog::Inst *inst0, PatchList l1, PatchList l2); 7 }; 8 9 -static PatchList nullPatchList; 10 +static PatchList nullPatchList = { 0 }; 11 12 // Returns patch list containing just p. 13 PatchList PatchList::Mk(uint32 p) { 14 @@ -106,12 +106,13 @@ struct Frag { 15 uint32 begin; 16 PatchList end; 17 18 - explicit Frag(LinkerInitialized) {} 19 Frag() : begin(0) { end.p = 0; } // needed so Frag can go in vector 20 Frag(uint32 begin, PatchList end) : begin(begin), end(end) {} 21 }; 22 23 -static Frag kNullFrag(LINKER_INITIALIZED); 24 +static Frag NullFrag() { 25 + return Frag(); 26 +} 27 28 // Input encodings. 29 enum Encoding { 30 @@ -684,13 +685,13 @@ Frag Compiler::PreVisit(Regexp* re, Frag, bool* stop) { 31 if (failed_) 32 *stop = true; 33 34 - return kNullFrag; // not used by caller 35 + return NullFrag(); // not used by caller 36 } 37 38 Frag Compiler::Literal(Rune r, bool foldcase) { 39 switch (encoding_) { 40 default: 41 - return kNullFrag; 42 + return NullFrag(); 43 44 case kEncodingLatin1: 45 return ByteRange(r, r, foldcase); 46 @@ -1006,7 +1007,7 @@ Prog* Compiler::Compile(Regexp* re, bool reversed, int64 max_mem) { 47 bool is_anchor_end = IsAnchorEnd(&sre, 0); 48 49 // Generate fragment for entire regexp. 50 - Frag f = c.WalkExponential(sre, kNullFrag, 2*c.max_inst_); 51 + Frag f = c.WalkExponential(sre, NullFrag(), 2*c.max_inst_); 52 sre->Decref(); 53 if (c.failed_) 54 return NULL; 55 @@ -1097,7 +1098,7 @@ Prog* Compiler::CompileSet(const RE2::Options& options, RE2::Anchor anchor, 56 c.Setup(pf, options.max_mem(), anchor); 57 58 // Compile alternation of fragments. 59 - Frag all = c.WalkExponential(re, kNullFrag, 2*c.max_inst_); 60 + Frag all = c.WalkExponential(re, NullFrag(), 2*c.max_inst_); 61 re->Decref(); 62 if (c.failed_) 63 return NULL; 64 diff --git a/re2/re2.cc b/re2/re2.cc 65 index 0da886d..b9e44fc 100644 66 --- a/re2/re2.cc 67 +++ b/re2/re2.cc 68 @@ -32,10 +32,10 @@ namespace re2 { 69 static const int kMaxArgs = 16; 70 static const int kVecSize = 1+kMaxArgs; 71 72 -const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::FullMatchN> RE2::FullMatch; 73 -const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::PartialMatchN> RE2::PartialMatch; 74 -const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::ConsumeN> RE2::Consume; 75 -const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::FindAndConsumeN> RE2::FindAndConsume; 76 +const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::FullMatchN> RE2::FullMatch = {}; 77 +const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::PartialMatchN> RE2::PartialMatch = {}; 78 +const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::ConsumeN> RE2::Consume = {}; 79 +const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::FindAndConsumeN> RE2::FindAndConsume = {}; 80 81 #define kDefaultMaxMem (8<<20) 82 83 diff --git a/re2/variadic_function.h b/re2/variadic_function.h 84 index 8d2b763..7c7d6d5 100644 85 --- a/re2/variadic_function.h 86 +++ b/re2/variadic_function.h 87 @@ -11,8 +11,6 @@ template <typename Result, typename Param0, typename Param1, typename Arg, 88 Result (*Func)(Param0, Param1, const Arg* const [], int count)> 89 class VariadicFunction2 { 90 public: 91 - VariadicFunction2() {} 92 - 93 Result operator()(Param0 p0, Param1 p1) const { 94 return Func(p0, p1, 0, 0); 95 } 96