diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-29 01:13:47 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-29 01:13:47 +0200 |
commit | 4ff09664d2570be8358a3bde62123cc8e0a17c9e (patch) | |
tree | a5cfc2f235f9a46f737b261186e7926aca202ebe /irc_commands.c | |
parent | cdca30b360c09399f1e5a2556d83ec997006cd75 (diff) | |
parent | 79b6213c1fa2ffaa102365515551e9f0ea9fdc1a (diff) |
Merging from main/jelmer.
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'; |