From b7917e5d1c8570c2fc8f63d04ad184730b63ae83 Mon Sep 17 00:00:00 2001 From: fcolin Date: Mon, 8 Oct 2001 09:41:17 +0000 Subject: correction bug du a l'utilisation de strtok pour decortiquer les arguments recu pb en cas d'arg vide !!! ([0-9]*) --- src/ivy.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ivy.c b/src/ivy.c index 1fd5a99..362aef2 100644 --- a/src/ivy.c +++ b/src/ivy.c @@ -128,6 +128,25 @@ static IvyClientPtr clients = 0; static const char *ready_message = 0; +/* + * 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; +} static void MsgSendTo( Client client, MsgType msgtype, int id, const char *message ) { SocketSend( client, "%d %d" ARG_START "%s\n", msgtype, id, message); @@ -387,11 +406,11 @@ static void Receive( Client client, void *data, char *line ) { if ( id == rcv->id ) { - arg = strtok( arg, ARG_END); + arg = nextArg( arg, ARG_END); while ( arg ) { argv[argc++] = arg; - arg = strtok( 0, ARG_END ); + arg = nextArg( 0, ARG_END ); } #ifdef DEBUG printf("Calling id=%d argc=%d for %s\n", id, argc,rcv->regexp); -- cgit v1.1