On Wednesday 18 May 2005 11:01 pm, tabris wrote: > > There is a bug I'm running into with this patch on debian boxen... > aparrently prefix is getting junk data in it, and I do not know why, > then prefixes is NULL (as the char ')' does not exist in the junk > string) > > This happens when the client is initially connecting, so > server->isupport isn't initialized yet. > > What am I doing wrong?
After some fiddling, I got it work, but _only_ if I compile with
garbage-collection. Without the garbage-collection it gets through the
login and then chews CPU for a while. I got a trace and it was in
mallopt().
Is there something I'm missing?
--
Everybody gets free BORSCHT!
Index: src/fe-common/irc/fe-irc-commands.c
===================================================================
--- src/fe-common/irc/fe-irc-commands.c (revision 3742)
+++ src/fe-common/irc/fe-irc-commands.c (working copy)
@@ -41,16 +41,48 @@
#include "printtext.h"
#include "keyboard.h"
-static const char *skip_target(const char *target)
+static const char *skip_target(IRC_SERVER_REC *server, const char *target)
{
- if (*target == '@') {
- /* @#channel, @+#channel - Hybrid6 / Bahamut features */
- if (target[1] == '+' && ischannel(target[2]))
- target += 2;
- else if (ischannel(target[1]))
- target++;
+ int i = 0, j = 0, isprefix = 0;
+ const char *prefix = NULL, *prefixes = NULL;
+
+ prefix = g_hash_table_lookup(server->isupport, "PREFIX");
+
+ if (prefix) {
+ // PREFIX=(ov)@+
+ prefixes = strchr(prefix, ')');
}
+ else {
+ prefixes = strdup("@+");
+ };
+ if (!prefixes) {
+ g_free(prefix);
+ prefixes = strdup("@+");
+ };
+
+ for(i = 0; i < strlen(target); i++) {
+ isprefix = 0;
+ for(j = 0; j < strlen(prefixes); j++) {
+ if(target[i] == prefixes[j]) {
+ isprefix = 1;
+ break;
+ }
+ }
+ if (!isprefix)
+ break;
+ };
+
+ if(ischannel(target[i]))
+ target += i;
+
+ if(prefix) {
+ g_free(prefix);
+ }
+ else {
+ g_free(prefixes);
+ };
+
return target;
}
@@ -103,7 +135,7 @@ static void cmd_action(const char *data,
recoded = recode_out(SERVER(server), text, target);
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, recoded);
- target = skip_target(target);
+ target = skip_target(server, target);
signal_emit("message irc own_action", 3, server, recoded, target);
g_free(recoded);
@@ -158,7 +190,7 @@ static void cmd_ctcp(const char *data, I
return;
}
- target = skip_target(target);
+ target = skip_target(server, target);
g_strup(ctcpcmd);
signal_emit("message irc own_ctcp", 4,
@@ -183,7 +215,7 @@ static void cmd_nctcp(const char *data,
if (*target == '\0' || *text == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
- target = skip_target(target);
+ target = skip_target(server, target);
signal_emit("message irc own_notice", 3, server, text, target);
cmd_params_free(free_arg);
}
Index: src/fe-common/irc/fe-irc-messages.c
===================================================================
--- src/fe-common/irc/fe-irc-messages.c (revision 3742)
+++ src/fe-common/irc/fe-irc-messages.c (working copy)
@@ -37,16 +37,48 @@
#include "fe-queries.h"
#include "window-items.h"
-static const char *skip_target(const char *target)
+static const char *skip_target(IRC_SERVER_REC *server, const char *target)
{
- if (target != NULL && *target == '@') {
- /* @#channel, @+#channel - Hybrid6 / Bahamut features */
- if (target[1] == '+' && ischannel(target[2]))
- target += 2;
- else if (ischannel(target[1]))
- target++;
+ int i = 0, j = 0, isprefix = 0;
+ const char *prefix = NULL, *prefixes = NULL;
+
+ prefix = g_hash_table_lookup(server->isupport, "PREFIX");
+
+ if (prefix) {
+ // PREFIX=(ov)@+
+ prefixes = strchr(prefix, ')');
}
+ else {
+ prefixes = strdup("@+");
+ };
+
+ if (!prefixes) {
+ g_free(prefix);
+ prefixes = strdup("@+");
+ };
+
+ for(i = 0; i < strlen(target); i++) {
+ isprefix = 0;
+ for(j = 0; j < strlen(prefixes); j++) {
+ if(target[i] == prefixes[j]) {
+ isprefix = 1;
+ break;
+ }
+ }
+ if (!isprefix)
+ break;
+ };
+
+ if(ischannel(target[i]))
+ target += i;
+ if(prefix) {
+ g_free(prefix);
+ }
+ else {
+ g_free(prefixes);
+ };
+
return target;
}
@@ -57,7 +89,7 @@ static void sig_message_own_public(SERVE
char *nickmode;
oldtarget = target;
- target = skip_target(target);
+ target = skip_target(IRC_SERVER(server), target);
if (IS_IRC_SERVER(server) && target != oldtarget) {
/* Hybrid 6 / Bahamut feature, send msg to all
ops / ops+voices in channel */
@@ -179,7 +211,7 @@ static void sig_message_irc_action(IRC_S
static void sig_message_own_notice(IRC_SERVER_REC *server, const char *msg,
const char *target)
{
- printformat(server, skip_target(target), MSGLEVEL_NOTICES |
+ printformat(server, skip_target(server, target), MSGLEVEL_NOTICES |
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
IRCTXT_OWN_NOTICE, target, msg);
}
@@ -191,7 +223,7 @@ static void sig_message_irc_notice(SERVE
const char *oldtarget;
oldtarget = target;
- target = skip_target(target);
+ target = skip_target(IRC_SERVER(server), target);
if (address == NULL || *address == '\0') {
/* notice from server */
pgpzx1ogG7znW.pgp
Description: PGP signature
