summaryrefslogtreecommitdiff
path: root/Ivy
diff options
context:
space:
mode:
Diffstat (limited to 'Ivy')
-rw-r--r--Ivy/IvyApplication.cxx24
1 files changed, 21 insertions, 3 deletions
diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx
index b27b77b..7f798c2 100644
--- a/Ivy/IvyApplication.cxx
+++ b/Ivy/IvyApplication.cxx
@@ -11,7 +11,25 @@
#define ARG_START "\002"
#define ARG_END "\003"
-
+/*
+function like strok but do not eat consecutive separator
+*/
+static char * nextArg( char *s, const char *separator )
+{
+ static char *start = NULL;
+ static char *end = NULL;
+ if ( s )
+ {
+ end = s;
+ }
+ start = end;
+
+ while ( *end && *end != *separator )
+ end++;
+ if ( *end == *separator ) *end++ = '\0';
+ if ( end == start ) return NULL;
+ return start;
+}
/////////////////////////////////////////////////////////////////////////////
// IvyApplication
@@ -183,11 +201,11 @@ void IvyApplication::OnReceive(char * line)
TRACE("Message id=%d msg='%s'\n", id, arg);
#endif //IVY_DEBUG
- arg = strtok( arg, ARG_END);
+ arg = nextArg( arg, ARG_END);
while ( arg )
{
argv[argc++] = arg;
- arg = strtok( NULL, ARG_END );
+ arg = nextArg( NULL, ARG_END );
}
bus->CallMessageCallback( this, id, argc, argv );
break;