From f71e26acc72b12023224f1d04fa065369b1865f1 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Mon, 6 Sep 2010 13:40:13 +0000 Subject: [PATCH] Correct count in /CLONES (reported by t3gah), and format output nicely using an /fset. /CLONES now uses the same formats as the /U command. Also tweaked those formats at the same time. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@98 13b04d17-f746-0410-82c6-800466cd88b0 --- Changelog | 3 +++ include/color.h | 6 +++--- include/misc.h | 2 +- source/commands2.c | 24 +++++++++++++++--------- source/misc.c | 30 +++++++++++++++++++++--------- 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/Changelog b/Changelog index ba92f0e..7bd9443 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,8 @@ [Changes 1.2c01] +* Correct count in /CLONES (reported by t3gah), and format output nicely + using an /fset. (caf) + * Add definition of BIND_8_COMPAT to fix build problem on Mac OS X. (caf) * Ensure that SHOW_AWAY_ONCE doesn't hide away status in /whois output. (caf) diff --git a/include/color.h b/include/color.h index 721cc6a..d7b5654 100644 --- a/include/color.h +++ b/include/color.h @@ -700,9 +700,9 @@ #define DEFAULT_FORMAT_USERLIST_FOOTER_FSET "There are $1 users on the userlist" #define DEFAULT_FORMAT_USERLIST_HEADER_FSET "level nick password host channels" -#define DEFAULT_FORMAT_USERS_FSET "%K[%n%C$5%B$[9]2%K]%K[%n$[41]3%K]%K[%n$0%K]%n$4" -#define DEFAULT_FORMAT_USERS_USER_FSET "%K[%n%C$5%B$[9]2%K]%K[%n%B$[41]3%K]%K[%n$0%K]%n$4" -#define DEFAULT_FORMAT_USERS_SHIT_FSET "%K[%n%C$5%B$[9]2%K]%K[%n%r$[41]3%K]%K[%n$[-15]0%K]%n$4" +#define DEFAULT_FORMAT_USERS_FSET "%K[%C$[1]5%B$[9]2%K][%n$[41]3%K][%n$[15]0%K](%n$4%K)" +#define DEFAULT_FORMAT_USERS_USER_FSET "%K[%C$[1]5%B$[9]2%K][%n%B$[41]3%K][%n$0%K](%n$4%K)" +#define DEFAULT_FORMAT_USERS_SHIT_FSET "%K[%C$[1]5%B$[9]2%K][%n%r$[41]3%K][%n$[-15]0%K](%n$4%K)" #define DEFAULT_FORMAT_USERS_TITLE_FSET "$G Channel userlist for %W$1%n at ($0):" #define DEFAULT_FORMAT_USERS_HEADER_FSET NULL /*"%K[ %WC%nhannel %K][ %WN%wickname %K][%n %Wu%wser@host %K][%n %Wl%wevel %K]"*/ diff --git a/include/misc.h b/include/misc.h index 92849eb..aea53fa 100644 --- a/include/misc.h +++ b/include/misc.h @@ -67,7 +67,7 @@ extern LastMsg last_ctcp_reply[2]; extern LastMsg last_sent_ctcp[2]; - + void put_user (const NickList *, const char *); void update_stats (int, NickList *, ChannelList *, int); int check_split (char *, char *); void BX_userage (char *, char *); diff --git a/source/commands2.c b/source/commands2.c index fba95ec..9689471 100644 --- a/source/commands2.c +++ b/source/commands2.c @@ -1853,26 +1853,32 @@ int clones = 0; for (nptr = next_nicklist(chan, NULL); nptr; nptr = next_nicklist(chan, nptr)) { char *q; - nptr1 = NULL; + + if (nptr->check_clone) + continue; + q = strchr(nptr->host, '@'); q++; - for (nptr1 = next_nicklist(chan, NULL); nptr1; nptr1 = next_nicklist(chan, nptr1)) + + /* Scan forward from this point, looking for clones */ + for (nptr1 = next_nicklist(chan, nptr); nptr1; nptr1 = next_nicklist(chan, nptr1)) { char *p; - if (nptr1 == nptr) - continue; + p = strchr(nptr1->host, '@'); p++; - if (!strcmp(p, q) && !nptr->check_clone) + + if (!strcmp(p, q)) { /* clone detected */ if (!clones && do_hook(CLONE_LIST, "Clones detected on %s", chan->channel)) bitchsay("Clones detected on %s", chan->channel); - if (!nptr->check_clone++ && do_hook(CLONE_LIST, "%s %s %s", nptr->nick, nptr->host, nick_isop(nptr)? "@":empty_string)) + if (!nptr->check_clone++) { - put_it("\t%s %s %s", nick_isop(nptr) ? "@":space, nptr->nick, nptr->host); + if (do_hook(CLONE_LIST, "%s %s %s", nptr->nick, nptr->host, nick_isop(nptr)? "@":empty_string)) + put_user(nptr, chan->channel); clones++; } - if (!nptr1->check_clone && do_hook(CLONE_LIST, "%s %s %s", nptr1->nick, nptr1->host, nick_isop(nptr1)? "@":empty_string)) - put_it("\t%s %s %s", nick_isop(nptr1) ? "@":space, nptr1->nick, nptr1->host); + if (do_hook(CLONE_LIST, "%s %s %s", nptr1->nick, nptr1->host, nick_isop(nptr1)? "@":empty_string)) + put_user(nptr1, chan->channel); nptr1->check_clone++; clones++; } diff --git a/source/misc.c b/source/misc.c index 67a8c03..60b5696 100644 --- a/source/misc.c +++ b/source/misc.c @@ -4040,7 +4040,27 @@ bad_ignore: return; } +void put_user(const NickList *nick, const char *channel) +{ + char *users_format; + if (nick->userlist) + users_format = fget_string_var(FORMAT_USERS_USER_FSET); + else if (nick->shitlist) + users_format = fget_string_var(FORMAT_USERS_SHIT_FSET); + else + users_format = fget_string_var(FORMAT_USERS_FSET); + + put_it("%s", convert_output_format(users_format, "%s %s %s %s %d %c", +#ifdef WANT_USERLIST + nick->userlist ? convert_flags(nick->userlist->flags) : nick->shitlist?ltoa(nick->shitlist->level):"n/a", +#else + "n/a", +#endif + channel, nick->nick, + nick->host, nick->serverhops, + nick_isop(nick) ? '@' : nick_isvoice(nick)? 'v' : ' ')); +} BUILT_IN_COMMAND(users) { @@ -4249,15 +4269,7 @@ int count = 0, nicks->host, nicks->serverhops, nick_isop(nicks) ? '@' : nick_isvoice(nicks) ? 'v' :' '))) { - put_it("%s", convert_output_format(fget_string_var(nicks->userlist?FORMAT_USERS_USER_FSET:nicks->shitlist?FORMAT_USERS_SHIT_FSET:FORMAT_USERS_FSET), "%s %s %s %s %d %s", -#ifdef WANT_USERLIST - nicks->userlist ? convert_flags(nicks->userlist->flags) : nicks->shitlist?ltoa(nicks->shitlist->level):"n/a ", -#else - "n/a ", -#endif - chan->channel, nicks->nick, - nicks->host, nicks->serverhops, - nick_isop(nicks) ? "@" : nick_isvoice(nicks)? "v" : "ÿ")); + put_user(nicks, chan->channel); } } }