diff --git a/CHANGES b/CHANGES index 8430bbf0b8..e01a71748c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +7.1.0-dev.459 | 2024-11-04 18:47:02 +0100 + + * switched CPPCompile::Canonicalize() to take std::string instead of const char* (Vern Paxson, Corelight) + 7.1.0-dev.457 | 2024-11-04 16:33:14 +0100 * minor ZAM BTest updates for recently added fnv1a64 BiF (Vern Paxson, Corelight) diff --git a/VERSION b/VERSION index 83d3175eac..9f8f5ba78f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.1.0-dev.457 +7.1.0-dev.459 diff --git a/src/script_opt/CPP/DeclFunc.cc b/src/script_opt/CPP/DeclFunc.cc index 7e0845bc08..7087bfedcd 100644 --- a/src/script_opt/CPP/DeclFunc.cc +++ b/src/script_opt/CPP/DeclFunc.cc @@ -10,7 +10,7 @@ void CPPCompile::DeclareFunc(const FuncInfo& func) { if ( ! IsCompilable(func) ) return; - auto fname = Canonicalize(BodyName(func).c_str()) + "_zf"; + auto fname = Canonicalize(BodyName(func)) + "_zf"; auto pf = func.Profile(); auto f = func.Func(); const auto& body = func.Body(); @@ -25,7 +25,7 @@ void CPPCompile::DeclareFunc(const FuncInfo& func) { void CPPCompile::DeclareLambda(const LambdaExpr* l, const ProfileFunc* pf) { ASSERT(is_CPP_compilable(pf)); - auto lname = Canonicalize(l->Name().c_str()) + "_lb"; + auto lname = Canonicalize(l->Name()) + "_lb"; auto body = l->Ingredients()->Body(); auto l_id = l->Ingredients()->GetID(); auto& ids = l->OuterIDs(); diff --git a/src/script_opt/CPP/Exprs.cc b/src/script_opt/CPP/Exprs.cc index c653d56e47..482b04f61f 100644 --- a/src/script_opt/CPP/Exprs.cc +++ b/src/script_opt/CPP/Exprs.cc @@ -646,7 +646,7 @@ string CPPCompile::GenLambdaExpr(const Expr* e) { string CPPCompile::GenLambdaExpr(const Expr* e, string capture_args) { auto l = static_cast(e); - auto name = Canonicalize(l->Name().c_str()) + "_lb_cl"; + auto name = Canonicalize(l->Name()) + "_lb_cl"; auto cl_args = string("\"") + name + "\"" + std::move(capture_args); auto body = string("make_intrusive<") + name + ">(" + cl_args + ")"; auto func = string("make_intrusive(\"") + l->Name() + "\", cast_intrusive(" + diff --git a/src/script_opt/CPP/GenFunc.cc b/src/script_opt/CPP/GenFunc.cc index 598df3e0fb..693af9a681 100644 --- a/src/script_opt/CPP/GenFunc.cc +++ b/src/script_opt/CPP/GenFunc.cc @@ -10,7 +10,7 @@ void CPPCompile::CompileFunc(const FuncInfo& func) { if ( ! IsCompilable(func) ) return; - auto fname = Canonicalize(BodyName(func).c_str()) + "_zf"; + auto fname = Canonicalize(BodyName(func)) + "_zf"; auto pf = func.Profile(); auto f = func.Func(); const auto& body = func.Body(); @@ -19,7 +19,7 @@ void CPPCompile::CompileFunc(const FuncInfo& func) { } void CPPCompile::CompileLambda(const LambdaExpr* l, const ProfileFunc* pf) { - auto lname = Canonicalize(l->Name().c_str()) + "_lb"; + auto lname = Canonicalize(l->Name()) + "_lb"; auto body = l->Ingredients()->Body(); auto l_id = l->Ingredients()->GetID(); auto& ids = l->OuterIDs(); diff --git a/src/script_opt/CPP/Inits.cc b/src/script_opt/CPP/Inits.cc index e14bb21931..0906d1c55b 100644 --- a/src/script_opt/CPP/Inits.cc +++ b/src/script_opt/CPP/Inits.cc @@ -259,7 +259,7 @@ void CPPCompile::GenStandaloneActivation() { auto f = func.Func(); auto fname = BodyName(func); - auto bname = Canonicalize(fname.c_str()) + "_zf"; + auto bname = Canonicalize(fname) + "_zf"; if ( compiled_funcs.count(bname) == 0 ) // We didn't wind up compiling it. diff --git a/src/script_opt/CPP/Vars.cc b/src/script_opt/CPP/Vars.cc index bdbf62e8ac..38ec046aa9 100644 --- a/src/script_opt/CPP/Vars.cc +++ b/src/script_opt/CPP/Vars.cc @@ -129,7 +129,7 @@ static string trim_name(const ID* id) { return ns; } -string CPPCompile::LocalName(const ID* l) const { return Canonicalize(trim_name(l).c_str()); } +string CPPCompile::LocalName(const ID* l) const { return Canonicalize(trim_name(l)); } string CPPCompile::CaptureName(const ID* c) const { // We want to strip both the module and any inlining appendage. @@ -139,15 +139,13 @@ string CPPCompile::CaptureName(const ID* c) const { if ( appendage != string::npos ) tn.erase(tn.begin() + appendage, tn.end()); - return Canonicalize(tn.c_str()); + return Canonicalize(tn); } -string CPPCompile::Canonicalize(const char* name) const { +string CPPCompile::Canonicalize(const std::string& name) const { string cname; - for ( int i = 0; name[i]; ++i ) { - auto c = name[i]; - + for ( auto c : name ) { // Strip <>'s - these get introduced for lambdas. if ( c == '<' || c == '>' ) continue; diff --git a/src/script_opt/CPP/Vars.h b/src/script_opt/CPP/Vars.h index 00c94d18dc..cfbeb2db3c 100644 --- a/src/script_opt/CPP/Vars.h +++ b/src/script_opt/CPP/Vars.h @@ -47,7 +47,7 @@ std::string CaptureName(const IDPtr& l) const { return CaptureName(l.get()); } // Returns a canonicalized name, with various non-alphanumeric characters // stripped or transformed, and guaranteed not to conflict with C++ keywords. -std::string Canonicalize(const char* name) const; +std::string Canonicalize(const std::string& name) const; // Returns the name of the global corresponding to an expression (which must // be a EXPR_NAME).