diff options
author | fcolin | 2001-10-08 09:41:17 +0000 |
---|---|---|
committer | fcolin | 2001-10-08 09:41:17 +0000 |
commit | b7917e5d1c8570c2fc8f63d04ad184730b63ae83 (patch) | |
tree | edc00291151ef65a3f557ed8f5235022c5190e35 /src | |
parent | 70519ae7685e8c56e5a7df49b647f2b945a2e421 (diff) | |
download | ivy-c-b7917e5d1c8570c2fc8f63d04ad184730b63ae83.zip ivy-c-b7917e5d1c8570c2fc8f63d04ad184730b63ae83.tar.gz ivy-c-b7917e5d1c8570c2fc8f63d04ad184730b63ae83.tar.bz2 ivy-c-b7917e5d1c8570c2fc8f63d04ad184730b63ae83.tar.xz |
correction bug du a l'utilisation de strtok pour decortiquer
les arguments recu
pb en cas d'arg vide !!! ([0-9]*)
Diffstat (limited to 'src')
-rw-r--r-- | src/ivy.c | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -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); |