From 0a4563c486f43bf613730d1f00fb7ba876eae868 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:55 +0000 Subject: Utilisateur : Fcolin Date : 8/10/01 Heure : 14:15 Archivé dans $/Ivy Commentaire: bug strtok si argument vide !!! (vss 14) --- Ivy/IvyApplication.cxx | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'Ivy/IvyApplication.cxx') 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; -- cgit v1.1