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
* Make set_processing_status() signal-safe.

3
NEWS
View file

@ -52,7 +52,8 @@ Removed 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
==========

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
patricia.c
setsignal.c
PacketDumper.cc
strsep.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
// 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.
#pragma once

View file

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

View file

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