commit d8950c5dd092c092688c75cf0ec42cd950c7f7c4 from: Florian Westphal date: Mon Oct 02 21:55:49 2006 UTC cleaned up Channel_IsValidName (now uses strcspn()) commit - 257312b102df5b66c25c97b803e9e4c78b6be54d commit + d8950c5dd092c092688c75cf0ec42cd950c7f7c4 blob - 2d656c8684c720e207dd744576160caff130b3f2 blob + 5e3b9a802dc1d4ad28a8d7e6753ea792066675ca --- src/ngircd/channel.c +++ src/ngircd/channel.c @@ -17,7 +17,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: channel.c,v 1.57 2006/08/12 11:58:21 fw Exp $"; +static char UNUSED id[] = "$Id: channel.c,v 1.58 2006/10/02 21:55:49 fw Exp $"; #include "imp.h" #include @@ -462,25 +462,13 @@ Channel_GetChannel( CL2CHAN *Cl2Chan ) GLOBAL bool -Channel_IsValidName( char *Name ) +Channel_IsValidName( const char *Name ) { - /* Pruefen, ob Name als Channelname gueltig */ - - char *ptr, badchars[10]; - assert( Name != NULL ); if(( Name[0] != '#' ) || ( strlen( Name ) >= CHANNEL_NAME_LEN )) return false; - ptr = Name; - strcpy( badchars, " ,:\007" ); - while( *ptr ) - { - if( strchr( badchars, *ptr )) return false; - ptr++; - } - - return true; + return Name[strcspn(Name, " ,:\007")] == 0; } /* Channel_IsValidName */ blob - 2f6e32513d60107c52dfa4e608a491cc492cbcd4 blob + 3dc3c59042bdb85a4c91efc242d538bb15e9380c --- src/ngircd/channel.h +++ src/ngircd/channel.h @@ -8,7 +8,7 @@ * (at your option) any later version. * Please read the file COPYING, README and AUTHORS for more information. * - * $Id: channel.h,v 1.29 2005/09/02 12:50:25 alex Exp $ + * $Id: channel.h,v 1.30 2006/10/02 21:55:50 fw Exp $ * * Channel management (header) */ @@ -94,7 +94,7 @@ GLOBAL CL2CHAN *Channel_NextChannelOf PARAMS(( CLIENT GLOBAL CLIENT *Channel_GetClient PARAMS(( CL2CHAN *Cl2Chan )); GLOBAL CHANNEL *Channel_GetChannel PARAMS(( CL2CHAN *Cl2Chan )); -GLOBAL bool Channel_IsValidName PARAMS(( char *Name )); +GLOBAL bool Channel_IsValidName PARAMS(( const char *Name )); GLOBAL bool Channel_ModeAdd PARAMS(( CHANNEL *Chan, char Mode )); GLOBAL bool Channel_ModeDel PARAMS(( CHANNEL *Chan, char Mode ));