summaryrefslogtreecommitdiff
path: root/Ivy/IvyApplication.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Ivy/IvyApplication.cxx')
-rw-r--r--Ivy/IvyApplication.cxx17
1 files changed, 8 insertions, 9 deletions
diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx
index 26d0adf..de43bd0 100644
--- a/Ivy/IvyApplication.cxx
+++ b/Ivy/IvyApplication.cxx
@@ -129,20 +129,18 @@ void IvyApplication::OnReceive(char * line)
TRACE("IvyApplication %s\n",err.c_str());
return;
}
- if ( id +1 < regexp_in.size() )
- regexp_in[ id ] = exp ;
- else regexp_in.push_back( exp );
+ regexp_in[ id ] = exp ;
break;
case DelRegexp:
#ifdef DEBUG
TRACE("Regexp Delete id=%d\n", id);
#endif //DEBUG
- if ( id < regexp_in.size() )
+ if ( regexp_in.find(id) != regexp_in.end() )
{
exp = regexp_in[ id ];
delete exp;
- regexp_in[ id ] = NULL ;
+ regexp_in.erase( id );
}
break;
case StartRegexp:
@@ -263,11 +261,12 @@ int IvyApplication::SendMsg(const char *message)
{
int count = 0;
Regexp *exp;
-
+ map<int,Regexp*>::iterator iter;
/* send to already connected */
- for ( int id = 0; id < regexp_in.size(); id++ )
+ if ( !regexp_in.empty() )
+ for ( iter = regexp_in.begin(); iter != regexp_in.end(); iter++ )
{
- exp = regexp_in[ id ];
+ exp = (*iter).second;
if ( exp && exp->Match( message ) )
{
@@ -277,7 +276,7 @@ int IvyApplication::SendMsg(const char *message)
buffer += (*exp)[i];
buffer += ARG_END;
}
- SendMsg( Msg, id, buffer.c_str() );
+ SendMsg( Msg, (*iter).first, buffer.c_str() );
count++;
}
}