| 1150 | } |
| 1151 | |
| 1152 | void StringFunctions::RegexpMatchCountPrepare(FunctionContext* context, |
| 1153 | FunctionContext::FunctionStateScope scope) { |
| 1154 | if (scope != FunctionContext::THREAD_LOCAL) return; |
| 1155 | int num_args = context->GetNumArgs(); |
| 1156 | DCHECK(num_args == 2 || num_args == 4); |
| 1157 | if (!context->IsArgConstant(1) || (num_args == 4 && !context->IsArgConstant(3))) return; |
| 1158 | |
| 1159 | DCHECK_EQ(context->GetArgType(1)->type, FunctionContext::TYPE_STRING); |
| 1160 | StringVal* pattern = reinterpret_cast<StringVal*>(context->GetConstantArg(1)); |
| 1161 | if (pattern->is_null) return; |
| 1162 | |
| 1163 | StringVal* match_parameter = NULL; |
| 1164 | if (num_args == 4) { |
| 1165 | DCHECK_EQ(context->GetArgType(3)->type, FunctionContext::TYPE_STRING); |
| 1166 | match_parameter = reinterpret_cast<StringVal*>(context->GetConstantArg(3)); |
| 1167 | } |
| 1168 | string error_str; |
| 1169 | re2::RE2* re = CompileRegex(*pattern, &error_str, match_parameter == NULL ? |
| 1170 | StringVal::null() : *match_parameter); |
| 1171 | if (re == NULL) { |
| 1172 | context->SetError(error_str.c_str()); |
| 1173 | return; |
| 1174 | } |
| 1175 | context->SetFunctionState(scope, re); |
| 1176 | } |
| 1177 | |
| 1178 | IntVal StringFunctions::RegexpMatchCount2Args(FunctionContext* context, |
| 1179 | const StringVal& str, const StringVal& pattern) { |
nothing calls this directly
no test coverage detected