summaryrefslogtreecommitdiff
path: root/Ivy/IvyApplication.cxx
diff options
context:
space:
mode:
authorfcolin2007-02-01 12:59:55 +0000
committerfcolin2007-02-01 12:59:55 +0000
commit0a4563c486f43bf613730d1f00fb7ba876eae868 (patch)
treea36324b3d2901731eda4337833d4d8245b96d2d5 /Ivy/IvyApplication.cxx
parentfd1b7bce694095d4cecb2724b6dfe71449f16f6f (diff)
downloadivy-cplusplus-0a4563c486f43bf613730d1f00fb7ba876eae868.zip
ivy-cplusplus-0a4563c486f43bf613730d1f00fb7ba876eae868.tar.gz
ivy-cplusplus-0a4563c486f43bf613730d1f00fb7ba876eae868.tar.bz2
ivy-cplusplus-0a4563c486f43bf613730d1f00fb7ba876eae868.tar.xz
Utilisateur : Fcolin Date : 8/10/01 Heure : 14:15 Archivé dans $/Ivy Commentaire: bug strtok si argument vide !!! (vss 14)
Diffstat (limited to 'Ivy/IvyApplication.cxx')
-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;