| 128 | } |
| 129 | |
| 130 | int RE2::Options::ParseFlags() const { |
| 131 | int flags = Regexp::ClassNL; |
| 132 | switch (encoding()) { |
| 133 | default: |
| 134 | if (log_errors()) |
| 135 | LOG(ERROR) << "Unknown encoding " << encoding(); |
| 136 | break; |
| 137 | case RE2::Options::EncodingUTF8: |
| 138 | break; |
| 139 | case RE2::Options::EncodingLatin1: |
| 140 | flags |= Regexp::Latin1; |
| 141 | break; |
| 142 | } |
| 143 | |
| 144 | if (!posix_syntax()) |
| 145 | flags |= Regexp::LikePerl; |
| 146 | |
| 147 | if (literal()) |
| 148 | flags |= Regexp::Literal; |
| 149 | |
| 150 | if (never_nl()) |
| 151 | flags |= Regexp::NeverNL; |
| 152 | |
| 153 | if (dot_nl()) |
| 154 | flags |= Regexp::DotNL; |
| 155 | |
| 156 | if (never_capture()) |
| 157 | flags |= Regexp::NeverCapture; |
| 158 | |
| 159 | if (!case_sensitive()) |
| 160 | flags |= Regexp::FoldCase; |
| 161 | |
| 162 | if (perl_classes()) |
| 163 | flags |= Regexp::PerlClasses; |
| 164 | |
| 165 | if (word_boundary()) |
| 166 | flags |= Regexp::PerlB; |
| 167 | |
| 168 | if (one_line()) |
| 169 | flags |= Regexp::OneLine; |
| 170 | |
| 171 | return flags; |
| 172 | } |
| 173 | |
| 174 | void RE2::Init(const StringPiece& pattern, const Options& options) { |
| 175 | static std::once_flag empty_once; |