Merge remote-tracking branch 'origin/topic/timw/smith-waterman-iterators'

* origin/topic/timw/smith-waterman-iterators:
  Mark Continuation.h and PacketDumper.h as deprecated
  Remove vector iterator type aliases from SmithWaterman code, fix uses of them
This commit is contained in:
Jon Siwek 2020-08-24 19:20:29 -07:00
commit 80a573d2b2
8 changed files with 44 additions and 46 deletions

View file

@ -1,3 +1,12 @@
3.3.0-dev.194 | 2020-08-24 19:20:29 -0700
* Mark Continuation.h and PacketDumper.h as deprecated (Tim Wojtulewicz, Corelight)
* Remove vector iterator type aliases from SmithWaterman code, fix uses of them (Tim Wojtulewicz, Corelight)
* Fix warning with usage of fmt() (Tim Wojtulewicz, Corelight)
3.3.0-dev.190 | 2020-08-24 14:43:06 -0700 3.3.0-dev.190 | 2020-08-24 14:43:06 -0700
* Make set_processing_status() signal-safe. * Make set_processing_status() signal-safe.

3
NEWS
View file

@ -52,7 +52,8 @@ Removed Functionality
Deprecated Functionality Deprecated Functionality
------------------------ ------------------------
TODO: nothing notable yet - Marked the Continuation.h and PacketDumper.h files as deprecated. The code
contained within them is unused by Zeek.
Zeek 3.2.0 Zeek 3.2.0
========== ==========

View file

@ -1 +1 @@
3.3.0-dev.190 3.3.0-dev.194

View file

@ -296,7 +296,6 @@ set(MAIN_SRCS
bro_inet_ntop.c bro_inet_ntop.c
patricia.c patricia.c
setsignal.c setsignal.c
PacketDumper.cc
strsep.c strsep.c
modp_numtoa.c modp_numtoa.c

View file

@ -1,3 +1,5 @@
#warning "This file will be removed in v4.1. The code here is unused by Zeek. Notify a Zeek team member if your plugins are using this code."
// Helper class to implement continuation-like mechanisms for // Helper class to implement continuation-like mechanisms for
// suspending/resuming tasks for incremental operation. // suspending/resuming tasks for incremental operation.
// //

View file

@ -1,3 +1,5 @@
#warning "This file will be removed in v4.1. The code here is unused by Zeek. Notify a Zeek team member if your plugins are using this code."
// See the file "COPYING" in the main distribution directory for copyright. // See the file "COPYING" in the main distribution directory for copyright.
#pragma once #pragma once

View file

@ -16,8 +16,8 @@ namespace zeek::detail {
Substring::Substring(const Substring& bst) Substring::Substring(const Substring& bst)
: zeek::String((const zeek::String&) bst), _num(), _new(bst._new) : zeek::String((const zeek::String&) bst), _num(), _new(bst._new)
{ {
for ( BSSAlignVecCIt it = bst._aligns.begin(); it != bst._aligns.end(); ++it ) for ( const auto& align : bst._aligns )
_aligns.push_back(*it); _aligns.push_back(align);
} }
const Substring& Substring::operator=(const Substring& bst) const Substring& Substring::operator=(const Substring& bst)
@ -26,8 +26,8 @@ const Substring& Substring::operator=(const Substring& bst)
_aligns.clear(); _aligns.clear();
for ( BSSAlignVecCIt it = bst._aligns.begin(); it != bst._aligns.end(); ++it ) for ( const auto& align : bst._aligns )
_aligns.push_back(*it); _aligns.push_back(align);
_new = bst._new; _new = bst._new;
@ -44,9 +44,9 @@ bool Substring::DoesCover(const Substring* bst) const
if ( _aligns.size() != bst->_aligns.size() ) if ( _aligns.size() != bst->_aligns.size() )
return false; return false;
BSSAlignVecCIt it_bst = bst->_aligns.begin(); auto it_bst = bst->_aligns.begin();
for ( BSSAlignVecCIt it = _aligns.begin(); it != _aligns.end(); ++it, ++it_bst ) for ( auto it = _aligns.begin(); it != _aligns.end(); ++it, ++it_bst )
{ {
const BSSAlign& a = *it; const BSSAlign& a = *it;
const BSSAlign& a_bst = *it_bst; const BSSAlign& a_bst = *it_bst;
@ -134,9 +134,9 @@ char* Substring::VecToString(Vec* vec)
{ {
std::string result("["); std::string result("[");
for ( Substring::VecIt it = vec->begin(); it != vec->end(); ++it ) for ( const auto& ss : *vec )
{ {
result += (*it)->CheckString(); result += ss->CheckString();
result += ","; result += ",";
} }
@ -148,17 +148,14 @@ zeek::String::IdxVec* Substring::GetOffsetsVec(const Vec* vec, unsigned int inde
{ {
zeek::String::IdxVec* result = new zeek::String::IdxVec(); zeek::String::IdxVec* result = new zeek::String::IdxVec();
for ( VecCIt it = vec->begin(); it != vec->end(); ++it ) for ( const auto& bst : *vec )
{ {
int start, end;
const Substring* bst = (*it);
if ( bst->_aligns.size() <= index ) if ( bst->_aligns.size() <= index )
continue; continue;
const BSSAlign& align = bst->_aligns[index]; const BSSAlign& align = bst->_aligns[index];
start = align.index; int start = align.index;
end = start + bst->Len(); int end = start + bst->Len();
result->push_back(start); result->push_back(start);
result->push_back(end); result->push_back(end);
@ -327,7 +324,7 @@ static void sw_collect_single(Substring::Vec* result, SWNodeMatrix& matrix,
// substrings are redundant (i.e., fully covered by a larger common substring). // substrings are redundant (i.e., fully covered by a larger common substring).
// //
static void sw_collect_multiple(Substring::Vec* result, static void sw_collect_multiple(Substring::Vec* result,
SWNodeMatrix& matrix, SWParams& params) SWNodeMatrix& matrix, SWParams& params)
{ {
std::vector<Substring::Vec*> als; std::vector<Substring::Vec*> als;
@ -343,21 +340,16 @@ static void sw_collect_multiple(Substring::Vec* result,
auto* new_al = new Substring::Vec(); auto* new_al = new Substring::Vec();
sw_collect_single(new_al, matrix, node, params); sw_collect_single(new_al, matrix, node, params);
for ( std::vector<Substring::Vec*>::iterator it = als.begin(); for ( auto& old_al : als )
it != als.end(); ++it )
{ {
Substring::Vec* old_al = *it;
if ( old_al == nullptr ) if ( old_al == nullptr )
continue; continue;
for ( Substring::VecIt it2 = old_al->begin(); for ( const auto& old_ss : *old_al )
it2 != old_al->end(); ++it2 )
{ {
for ( Substring::VecIt it3 = new_al->begin(); for ( const auto& new_ss : *new_al )
it3 != new_al->end(); ++it3 )
{ {
if ( (*it2)->DoesCover(*it3) ) if ( old_ss->DoesCover(new_ss) )
{ {
zeek::util::delete_each(new_al); zeek::util::delete_each(new_al);
delete new_al; delete new_al;
@ -365,11 +357,11 @@ static void sw_collect_multiple(Substring::Vec* result,
goto end_loop; goto end_loop;
} }
if ( (*it3)->DoesCover(*it2) ) if ( new_ss->DoesCover(old_ss) )
{ {
zeek::util::delete_each(old_al); zeek::util::delete_each(old_al);
delete old_al; delete old_al;
*it = 0; old_al = nullptr;
goto end_loop; goto end_loop;
} }
} }
@ -382,17 +374,13 @@ end_loop:
} }
} }
for ( std::vector<Substring::Vec*>::iterator it = als.begin(); for ( const auto& al : als )
it != als.end(); ++it )
{ {
Substring::Vec* al = *it;
if ( al == nullptr ) if ( al == nullptr )
continue; continue;
for ( Substring::VecIt it2 = al->begin(); for ( const auto& bst : *al )
it2 != al->end(); ++it2 ) result->push_back(bst);
result->push_back(*it2);
delete al; delete al;
} }

View file

@ -2,8 +2,10 @@
#pragma once #pragma once
#include "ZeekString.h"
#include <map> #include <map>
#include <vector>
#include "ZeekString.h"
namespace zeek::detail { namespace zeek::detail {
@ -16,9 +18,7 @@ namespace zeek::detail {
class Substring : public zeek::String { class Substring : public zeek::String {
public: public:
typedef std::vector<Substring*> Vec; using Vec = std::vector<Substring*>;
typedef Vec::iterator VecIt;
typedef Vec::const_iterator VecCIt;
// An alignment to another string. // An alignment to another string.
// //
@ -37,9 +37,7 @@ public:
int index; int index;
}; };
typedef std::vector<BSSAlign> BSSAlignVec; using BSSAlignVec = std::vector<BSSAlign>;
typedef BSSAlignVec::iterator BSSAlignVecIt;
typedef BSSAlignVec::const_iterator BSSAlignVecCIt;
explicit Substring(const std::string& string) explicit Substring(const std::string& string)
: zeek::String(string), _num(), _new(false) { } : zeek::String(string), _num(), _new(false) { }
@ -74,11 +72,10 @@ public:
static Vec* VecFromPolicy(zeek::VectorVal* vec); static Vec* VecFromPolicy(zeek::VectorVal* vec);
static char* VecToString(Vec* vec); static char* VecToString(Vec* vec);
static zeek::String::IdxVec* GetOffsetsVec(const Vec* vec, static zeek::String::IdxVec* GetOffsetsVec(const Vec* vec,
unsigned int index); unsigned int index);
private: private:
typedef std::map<std::string, void*> DataMap; using DataMap = std::map<std::string, void*>;
typedef DataMap::iterator DataMapIt;
Substring(); Substring();