diff --git a/src/script_opt/ZAM/BuiltInSupport.cc b/src/script_opt/ZAM/BuiltInSupport.cc index c85786561a..84903ac95a 100644 --- a/src/script_opt/ZAM/BuiltInSupport.cc +++ b/src/script_opt/ZAM/BuiltInSupport.cc @@ -7,7 +7,7 @@ namespace zeek::detail { -FixedCatArg::FixedCatArg(const TypePtr& _t) : t(_t) { +FixedCatArg::FixedCatArg(TypePtr _t) : t(std::move(_t)) { switch ( t->Tag() ) { case TYPE_BOOL: max_size = 1; break; @@ -27,13 +27,13 @@ FixedCatArg::FixedCatArg(const TypePtr& _t) : t(_t) { case TYPE_ENUM: { size_t n = 0; for ( const auto& e : t->AsEnumType()->Names() ) - n += e.first.size(); + n = std::max(n, e.first.size()); max_size = n; break; } case TYPE_PORT: - max_size = 5 + 1 + 7; // + / + "unknown + max_size = 5 + 1 + 7; // + / + "unknown" break; case TYPE_ADDR: diff --git a/src/script_opt/ZAM/BuiltInSupport.h b/src/script_opt/ZAM/BuiltInSupport.h index f216c068ef..7169ea94d1 100644 --- a/src/script_opt/ZAM/BuiltInSupport.h +++ b/src/script_opt/ZAM/BuiltInSupport.h @@ -36,12 +36,12 @@ protected: class FixedCatArg : public CatArg { public: - FixedCatArg(const TypePtr& t); + FixedCatArg(TypePtr t); void RenderInto(ZVal* zframe, int slot, char*& res) override; protected: - const TypePtr& t; + TypePtr t; char tmp[256]; }; @@ -80,7 +80,7 @@ protected: class DescCatArg : public CatArg { public: - DescCatArg(const TypePtr& _t) : CatArg(), t(_t) { d.SetStyle(RAW_STYLE); } + DescCatArg(TypePtr _t) : CatArg(), t(std::move(_t)) { d.SetStyle(RAW_STYLE); } void RenderInto(ZVal* zframe, int slot, char*& res) override { auto n = d.Len(); diff --git a/src/script_opt/ZAM/Ops.in b/src/script_opt/ZAM/Ops.in index 3d9a3db95e..38413bb092 100644 --- a/src/script_opt/ZAM/Ops.in +++ b/src/script_opt/ZAM/Ops.in @@ -2446,7 +2446,8 @@ type VV eval Cat1OpRef(frame[z.v2]) macro Cat1FullVal(val) - Cat1Op(ZVal(ZAM_val_cat(val.ToVal(z.t)))) + auto formatted_val = ZVal(ZAM_val_cat(val.ToVal(z.t))); + Cat1Op(formatted_val) internal-op Cat1Full type VC