diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-28 20:24:43 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-28 20:24:43 +0200 |
commit | 42616d147d9b6bfb5d09ea6dc237605917765853 (patch) | |
tree | a0b3162939e07285d4b54012666c0b355a2e64a8 /irc_commands.c | |
parent | db28304aed1fbe47f0a4076f3c97850059f262e6 (diff) |
"ISON :nick1 nick2" works too now, which seems to be what the RFCs really
want (although the example says "ISON nick1 nick2").
Diffstat (limited to 'irc_commands.c')
-rw-r--r-- | irc_commands.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/irc_commands.c b/irc_commands.c index fe67a534..f80f50f5 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -320,7 +320,7 @@ static void irc_cmd_userhost( irc_t *irc, char **cmd ) static void irc_cmd_ison( irc_t *irc, char **cmd ) { user_t *u; - char buff[IRC_MAX_LINE]; + char buff[IRC_MAX_LINE], *s; int lenleft, i; buff[0] = '\0'; @@ -330,28 +330,41 @@ static void irc_cmd_ison( irc_t *irc, char **cmd ) for( i = 1; cmd[i]; i ++ ) { - if( ( u = user_find( irc, cmd[i] ) ) && u->online ) + char *this, *next; + + this = cmd[i]; + while( *this ) { - /* [SH] Make sure we don't use too much buffer space. */ - lenleft -= strlen( u->nick ) + 1; + if( ( next = strchr( this, ' ' ) ) ) + *next = 0; - if( lenleft < 0 ) + if( ( u = user_find( irc, this ) ) && u->online ) { - break; + lenleft -= strlen( u->nick ) + 1; + + if( lenleft < 0 ) + break; + + strcat( buff, u->nick ); + strcat( buff, " " ); } - /* [SH] Add the nick to the buffer. Note - * that an extra space is always added. Even - * if it's the last nick in the list. Who - * cares? - */ - - strcat( buff, u->nick ); - strcat( buff, " " ); + if( next ) + { + *next = ' '; + this = next + 1; + } + else + { + break; + } } + + /* *sigh* */ + if( lenleft < 0 ) + break; } - /* [WvG] Well, maybe someone cares, so why not remove it? */ if( strlen( buff ) > 0 ) buff[strlen(buff)-1] = '\0'; |