mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Added support to create a Hashkey for PatternVals using their Pattern Texts
This commit is contained in:
parent
33571e7d19
commit
a907732e25
2 changed files with 16 additions and 1 deletions
|
@ -401,6 +401,21 @@ HashKey* CompositeHash::ComputeSingletonHash(const Val* v, int type_check) const
|
||||||
if ( v->Type()->Tag() == TYPE_FUNC )
|
if ( v->Type()->Tag() == TYPE_FUNC )
|
||||||
return new HashKey(v->AsFunc()->GetUniqueFuncID());
|
return new HashKey(v->AsFunc()->GetUniqueFuncID());
|
||||||
|
|
||||||
|
if (v->Type()->Tag() == TYPE_PATTERN) {
|
||||||
|
char* texts[2] = {
|
||||||
|
v->AsPattern()->PatternText(),
|
||||||
|
v->AsPattern()->AnywherePatternText()
|
||||||
|
};
|
||||||
|
|
||||||
|
char key [ sizeof(size_t) * 2 + strlen(texts[0]) + strlen(texts[1]) ];
|
||||||
|
std::memcpy(key, strlen(texts[0]), sizeof(size_t));
|
||||||
|
std::memcpy(*(key + sizeof(size_t)), strlen(texts[1]), sizeof(size_t));
|
||||||
|
std::memcpy(key + 2 * sizeof(size_t), texts[0], strlen(texts[0]));
|
||||||
|
std::memcpy(key + 2 * sizeof(size_t) + strlen(texts[0]), texts[1], strlen(texts[1]));
|
||||||
|
|
||||||
|
return new HashKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
reporter->InternalError("bad index type in CompositeHash::ComputeSingletonHash");
|
reporter->InternalError("bad index type in CompositeHash::ComputeSingletonHash");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -391,7 +391,7 @@ TableType::TableType(TypeList* ind, BroType* yield)
|
||||||
// Allow functions, since they can be compared
|
// Allow functions, since they can be compared
|
||||||
// for Func* pointer equality.
|
// for Func* pointer equality.
|
||||||
if ( t == TYPE_INTERNAL_OTHER && tli->Tag() != TYPE_FUNC &&
|
if ( t == TYPE_INTERNAL_OTHER && tli->Tag() != TYPE_FUNC &&
|
||||||
tli->Tag() != TYPE_RECORD )
|
tli->Tag() != TYPE_RECORD && tli->Tag() != TYPE_PATTERN)
|
||||||
{
|
{
|
||||||
tli->Error("bad index type");
|
tli->Error("bad index type");
|
||||||
SetError();
|
SetError();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue