diff options
author | dequis <dx@dxzone.com.ar> | 2015-04-07 22:39:05 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-04-07 22:41:05 -0300 |
commit | f14199d9c15a8062b5663fa6fcdae00390473b15 (patch) | |
tree | 730f9fdb49b2e1f26dd56422f83e6b6ab9867d8a /src/irc | |
parent | 9ffe52ec5e3f0643e7ddd12f4d21c0788d2f8cea (diff) | |
download | irssi-f14199d9c15a8062b5663fa6fcdae00390473b15.zip |
Change all strcmp() to g_strcmp0() to handle nulls gracefully
Just a string replacement (but i did check every one of them)
sed -i 's/strcmp(/g_strcmp0(/g' **/*.c
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/core/bans.c | 4 | ||||
-rw-r--r-- | src/irc/core/channel-events.c | 2 | ||||
-rw-r--r-- | src/irc/core/irc-commands.c | 20 | ||||
-rw-r--r-- | src/irc/core/irc-queries.c | 6 | ||||
-rw-r--r-- | src/irc/core/irc-servers.c | 2 | ||||
-rw-r--r-- | src/irc/core/modes.c | 4 | ||||
-rw-r--r-- | src/irc/core/servers-redirect.c | 6 | ||||
-rw-r--r-- | src/irc/dcc/dcc-autoget.c | 2 | ||||
-rw-r--r-- | src/irc/dcc/dcc-chat.c | 4 | ||||
-rw-r--r-- | src/irc/dcc/dcc-get.c | 2 | ||||
-rw-r--r-- | src/irc/dcc/dcc.c | 4 | ||||
-rw-r--r-- | src/irc/notifylist/notifylist.c | 2 | ||||
-rw-r--r-- | src/irc/proxy/dump.c | 2 | ||||
-rw-r--r-- | src/irc/proxy/listen.c | 44 |
14 files changed, 52 insertions, 52 deletions
diff --git a/src/irc/core/bans.c b/src/irc/core/bans.c index 38c81aab..b60e681b 100644 --- a/src/irc/core/bans.c +++ b/src/irc/core/bans.c @@ -188,7 +188,7 @@ static void command_set_ban(const char *data, IRC_SERVER_REC *server, item, &channel, &nicks)) return; if (!ischannel(*channel)) cmd_param_error(CMDERR_NOT_JOINED); if (*nicks == '\0') { - if (strcmp(data, "*") != 0) + if (g_strcmp0(data, "*") != 0) cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); /* /BAN * or /UNBAN * - ban/unban everyone */ nicks = (char *) data; @@ -318,7 +318,7 @@ static void cmd_unban(const char *data, IRC_SERVER_REC *server, void *item) static void read_settings(void) { if (default_ban_type_str != NULL && - strcmp(default_ban_type_str, settings_get_str("ban_type")) == 0) + g_strcmp0(default_ban_type_str, settings_get_str("ban_type")) == 0) return; g_free_not_null(default_ban_type_str); diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index 6fdfeef3..6cb9b088 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -270,7 +270,7 @@ static void event_join(IRC_SERVER_REC *server, const char *data, const char *nic } chanrec->joined = TRUE; - if (strcmp(chanrec->name, channel) != 0) { + if (g_strcmp0(chanrec->name, channel) != 0) { g_free(chanrec->name); chanrec->name = g_strdup(channel); } diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c index 7c3d3f5f..e7fb5067 100644 --- a/src/irc/core/irc-commands.c +++ b/src/irc/core/irc-commands.c @@ -72,7 +72,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server, if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &target, &msg)) return; - if (strcmp(target, "*") == 0) + if (g_strcmp0(target, "*") == 0) target = item == NULL ? NULL : window_item_get_target(item); if (target == NULL || *target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); @@ -99,7 +99,7 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server, if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, &target, &ctcpcmd, &ctcpdata)) return; - if (strcmp(target, "*") == 0) + if (g_strcmp0(target, "*") == 0) target = item == NULL ? NULL : window_item_get_target(item); if (target == NULL || *target == '\0' || *ctcpcmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); @@ -133,7 +133,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server, if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, &target, &ctcpcmd, &ctcpdata)) return; - if (strcmp(target, "*") == 0) + if (g_strcmp0(target, "*") == 0) target = item == NULL ? NULL : window_item_get_target(item); if (target == NULL || *target == '\0' || *ctcpcmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); @@ -238,7 +238,7 @@ static void cmd_invite(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *it return; if (*nick == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - if (*channame == '\0' || strcmp(channame, "*") == 0) { + if (*channame == '\0' || g_strcmp0(channame, "*") == 0) { if (!IS_IRC_CHANNEL(item)) cmd_param_error(CMDERR_NOT_JOINED); @@ -284,13 +284,13 @@ static void cmd_who(const char *data, IRC_SERVER_REC *server, if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &channel, &rest)) return; - if (strcmp(channel, "*") == 0 || *channel == '\0') { + if (g_strcmp0(channel, "*") == 0 || *channel == '\0') { if (!IS_IRC_CHANNEL(item)) cmd_param_error(CMDERR_NOT_JOINED); channel = IRC_CHANNEL(item)->name; } - if (strcmp(channel, "**") == 0) { + if (g_strcmp0(channel, "**") == 0) { /* ** displays all nicks.. */ *channel = '\0'; } @@ -313,14 +313,14 @@ static void cmd_names(const char *data, IRC_SERVER_REC *server, PARAM_FLAG_GETREST, "names", &optlist, &channel)) return; - if (strcmp(channel, "*") == 0 || *channel == '\0') { + if (g_strcmp0(channel, "*") == 0 || *channel == '\0') { if (!IS_IRC_CHANNEL(item)) cmd_param_error(CMDERR_NOT_JOINED); channel = IRC_CHANNEL(item)->name; } - if (strcmp(channel, "**") == 0) { + if (g_strcmp0(channel, "**") == 0) { /* ** displays all nicks.. */ irc_send_cmd(server, "NAMES"); } else { @@ -409,7 +409,7 @@ static void cmd_whois(const char *data, IRC_SERVER_REC *server, query = qserver = queryitem->name; } - if (strcmp(query, "*") == 0 && + if (g_strcmp0(query, "*") == 0 && g_hash_table_lookup(optlist, "yes") == NULL) cmd_param_error(CMDERR_NOT_GOOD_IDEA); @@ -810,7 +810,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server, for (ptr = server->knockoutlist; ptr != NULL; ptr = ptr->next) { rec = ptr->data; if (channel == rec->channel && - !strcmp(rec->ban, banmasks)) + !g_strcmp0(rec->ban, banmasks)) break; } if (ptr == NULL) { diff --git a/src/irc/core/irc-queries.c b/src/irc/core/irc-queries.c index ac1a72a1..72c17df1 100644 --- a/src/irc/core/irc-queries.c +++ b/src/irc/core/irc-queries.c @@ -67,13 +67,13 @@ static void check_query_changes(IRC_SERVER_REC *server, const char *nick, if (query == NULL) return; - if (strcmp(query->name, nick) != 0) { + if (g_strcmp0(query->name, nick) != 0) { /* upper/lowercase chars in nick changed */ query_change_nick(query, nick); } if (address != NULL && (query->address == NULL || - strcmp(query->address, address) != 0)) { + g_strcmp0(query->address, address) != 0)) { /* host changed */ query_change_address(query, address); } @@ -109,7 +109,7 @@ static void event_nick(SERVER_REC *server, const char *data, query = query_find(server, orignick); if (query != NULL) { params = event_get_params(data, 1, &nick); - if (strcmp(query->name, nick) != 0) + if (g_strcmp0(query->name, nick) != 0) query_change_nick(query, nick); g_free(params); } diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index baf8a0d2..d7122eae 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -638,7 +638,7 @@ static void event_connected(IRC_SERVER_REC *server, const char *data, const char params = event_get_params(data, 1, &nick); - if (strcmp(server->nick, nick) != 0) { + if (g_strcmp0(server->nick, nick) != 0) { /* nick changed unexpectedly .. connected via proxy, etc. */ g_free(server->nick); server->nick = g_strdup(nick); diff --git a/src/irc/core/modes.c b/src/irc/core/modes.c index ebaf4b8f..a812691c 100644 --- a/src/irc/core/modes.c +++ b/src/irc/core/modes.c @@ -398,7 +398,7 @@ void parse_channel_modes(IRC_CHANNEL_REC *channel, const char *setby, old_key = NULL; } - if (strcmp(newmode->str, channel->mode) != 0) { + if (g_strcmp0(newmode->str, channel->mode) != 0) { g_free(channel->mode); channel->mode = g_strdup(newmode->str); @@ -842,7 +842,7 @@ static void cmd_mode(const char *data, IRC_SERVER_REC *server, return; } - if (strcmp(target, "*") == 0) { + if (g_strcmp0(target, "*") == 0) { if (!IS_IRC_CHANNEL(channel)) cmd_param_error(CMDERR_NOT_JOINED); diff --git a/src/irc/core/servers-redirect.c b/src/irc/core/servers-redirect.c index 518248cb..f0a285df 100644 --- a/src/irc/core/servers-redirect.c +++ b/src/irc/core/servers-redirect.c @@ -339,7 +339,7 @@ static GSList *redirect_cmd_list_find(GSList *list, const char *event) while (list != NULL) { const char *str = list->data; - if (strcmp(str, event) == 0) + if (g_strcmp0(str, event) == 0) break; list = list->next->next; } @@ -365,7 +365,7 @@ static const char *redirect_match(REDIRECT_REC *redirect, const char *event, use the default signal */ signal = NULL; for (tmp = redirect->signals; tmp != NULL; tmp = tmp->next->next) { - if (strcmp(tmp->data, event) == 0) { + if (g_strcmp0(tmp->data, event) == 0) { signal = tmp->next->data; break; } @@ -527,7 +527,7 @@ server_redirect_get(IRC_SERVER_REC *server, const char *prefix, next = ptr->next; r = ptr->data; if (prefix != NULL && r->prefix != NULL && - strcmp(prefix, r->prefix)) { + g_strcmp0(prefix, r->prefix)) { /* not from this server */ continue; } diff --git a/src/irc/dcc/dcc-autoget.c b/src/irc/dcc/dcc-autoget.c index 4768641b..38170c56 100644 --- a/src/irc/dcc/dcc-autoget.c +++ b/src/irc/dcc/dcc-autoget.c @@ -57,7 +57,7 @@ static void sig_dcc_request(GET_DCC_REC *dcc, const char *nickaddr) /* don't autoget files beginning with a dot, if download dir is our home dir (stupid kludge for stupid people) */ if (*dcc->arg == '.' && - strcmp(settings_get_str("dcc_download_path"), "~") == 0) + g_strcmp0(settings_get_str("dcc_download_path"), "~") == 0) return; /* check file size limit, NOTE: it's still possible to send a diff --git a/src/irc/dcc/dcc-chat.c b/src/irc/dcc/dcc-chat.c index 8ee4decd..e3dbe72d 100644 --- a/src/irc/dcc/dcc-chat.c +++ b/src/irc/dcc/dcc-chat.c @@ -191,7 +191,7 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item) return; /* handle only DCC messages */ - if (strcmp(target, "*") == 0) + if (g_strcmp0(target, "*") == 0) dcc = item_get_dcc(item); else if (*target == '=') dcc = dcc_chat_find_id(target+1); @@ -625,7 +625,7 @@ static void ctcp_msg_dcc_chat(IRC_SERVER_REC *server, const char *data, g_strfreev(params); return; } - passive = paramcount == 4 && strcmp(params[2], "0") == 0; + passive = paramcount == 4 && g_strcmp0(params[2], "0") == 0; dcc = DCC_CHAT(dcc_find_request(DCC_CHAT_TYPE, nick, NULL)); if (dcc != NULL) { diff --git a/src/irc/dcc/dcc-get.c b/src/irc/dcc/dcc-get.c index 69fdc746..1208b5c5 100644 --- a/src/irc/dcc/dcc-get.c +++ b/src/irc/dcc/dcc-get.c @@ -554,7 +554,7 @@ void cmd_dcc_receive(const char *data, DCC_GET_FUNC accept_func, next = tmp->next; if (IS_DCC_GET(dcc) && g_ascii_strcasecmp(dcc->nick, nick) == 0 && (dcc_is_waiting_user(dcc) || dcc->from_dccserver) && - (*fname == '\0' || strcmp(dcc->arg, fname) == 0)) { + (*fname == '\0' || g_strcmp0(dcc->arg, fname) == 0)) { found = TRUE; if (!dcc_is_passive(dcc)) accept_func(dcc); diff --git a/src/irc/dcc/dcc.c b/src/irc/dcc/dcc.c index 6f0d5c81..17f6c477 100644 --- a/src/irc/dcc/dcc.c +++ b/src/irc/dcc/dcc.c @@ -149,7 +149,7 @@ DCC_REC *dcc_find_request(int type, const char *nick, const char *arg) if (dcc->type == type && !dcc_is_connected(dcc) && g_ascii_strcasecmp(dcc->nick, nick) == 0 && - (arg == NULL || strcmp(dcc->arg, arg) == 0)) + (arg == NULL || g_strcmp0(dcc->arg, arg) == 0)) return dcc; } @@ -516,7 +516,7 @@ static void cmd_dcc_close(char *data, IRC_SERVER_REC *server) next = tmp->next; if (dcc->type == type && g_ascii_strcasecmp(dcc->nick, nick) == 0 && - (*arg == '\0' || strcmp(dcc->arg, arg) == 0)) { + (*arg == '\0' || g_strcmp0(dcc->arg, arg) == 0)) { dcc_reject(dcc, server); found = TRUE; } diff --git a/src/irc/notifylist/notifylist.c b/src/irc/notifylist/notifylist.c index b0b7ee1c..573f7a7f 100644 --- a/src/irc/notifylist/notifylist.c +++ b/src/irc/notifylist/notifylist.c @@ -91,7 +91,7 @@ int notifylist_ircnets_match(NOTIFYLIST_REC *rec, const char *ircnet) if (rec->ircnets == NULL) return TRUE; if (ircnet == NULL) return FALSE; - if (strcmp(ircnet, "*") == 0) return TRUE; + if (g_strcmp0(ircnet, "*") == 0) return TRUE; for (tmp = rec->ircnets; *tmp != NULL; tmp++) { if (g_ascii_strcasecmp(*tmp, ircnet) == 0) diff --git a/src/irc/proxy/dump.c b/src/irc/proxy/dump.c index 80fd7c2e..3d7bf546 100644 --- a/src/irc/proxy/dump.c +++ b/src/irc/proxy/dump.c @@ -209,7 +209,7 @@ static void dump_join(IRC_CHANNEL_REC *channel, CLIENT_REC *client) void proxy_client_reset_nick(CLIENT_REC *client) { if (client->server == NULL || - strcmp(client->nick, client->server->nick) == 0) + g_strcmp0(client->nick, client->server->nick) == 0) return; proxy_outdata(client, ":%s!proxy NICK :%s\n", diff --git a/src/irc/proxy/listen.c b/src/irc/proxy/listen.c index 33392285..4c3bcf68 100644 --- a/src/irc/proxy/listen.c +++ b/src/irc/proxy/listen.c @@ -82,7 +82,7 @@ static void grab_who(CLIENT_REC *client, const char *channel) arg = g_string_new(channel); for (tmp = list, count = 0; *tmp != NULL; tmp++, count++) { - if (strcmp(*tmp, "0") == 0) { + if (g_strcmp0(*tmp, "0") == 0) { /* /who 0 displays everyone */ **tmp = '*'; } @@ -106,18 +106,18 @@ static void handle_client_connect_cmd(CLIENT_REC *client, password = settings_get_str("irssiproxy_password"); - if (password != NULL && strcmp(cmd, "PASS") == 0) { - if (strcmp(password, args) == 0) + if (password != NULL && g_strcmp0(cmd, "PASS") == 0) { + if (g_strcmp0(password, args) == 0) client->pass_sent = TRUE; else { /* wrong password! */ remove_client(client); return; } - } else if (strcmp(cmd, "NICK") == 0) { + } else if (g_strcmp0(cmd, "NICK") == 0) { g_free_not_null(client->nick); client->nick = g_strdup(args); - } else if (strcmp(cmd, "USER") == 0) { + } else if (g_strcmp0(cmd, "USER") == 0) { client->user_sent = TRUE; } @@ -141,12 +141,12 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args, return; } - if (strcmp(cmd, "QUIT") == 0) { + if (g_strcmp0(cmd, "QUIT") == 0) { remove_client(client); return; } - if (strcmp(cmd, "PING") == 0) { + if (g_strcmp0(cmd, "PING") == 0) { /* Reply to PING, if the target parameter is either proxy_adress, our own nick or empty. */ char *params, *origin, *target; @@ -164,7 +164,7 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args, g_free(params); } - if (strcmp(cmd, "PROXY") == 0) { + if (g_strcmp0(cmd, "PROXY") == 0) { if (g_ascii_strcasecmp(args, "CTCP ON") == 0) { /* client wants all ctcps */ client->want_ctcp = 1; @@ -200,11 +200,11 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args, } /* check if the command could be redirected */ - if (strcmp(cmd, "WHO") == 0) + if (g_strcmp0(cmd, "WHO") == 0) grab_who(client, args); - else if (strcmp(cmd, "WHOWAS") == 0) + else if (g_strcmp0(cmd, "WHOWAS") == 0) proxy_redirect_event(client, "whowas", 1, args, -1); - else if (strcmp(cmd, "WHOIS") == 0) { + else if (g_strcmp0(cmd, "WHOIS") == 0) { char *p; /* convert dots to spaces */ @@ -212,11 +212,11 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args, if (*p == ',') *p = ' '; proxy_redirect_event(client, "whois", 1, args, TRUE); - } else if (strcmp(cmd, "ISON") == 0) + } else if (g_strcmp0(cmd, "ISON") == 0) proxy_redirect_event(client, "ison", 1, args, -1); - else if (strcmp(cmd, "USERHOST") == 0) + else if (g_strcmp0(cmd, "USERHOST") == 0) proxy_redirect_event(client, "userhost", 1, args, -1); - else if (strcmp(cmd, "MODE") == 0) { + else if (g_strcmp0(cmd, "MODE") == 0) { /* convert dots to spaces */ char *slist, *str, mode, *p; int argc; @@ -252,7 +252,7 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args, } g_free(str); g_free(slist); - } else if (strcmp(cmd, "PRIVMSG") == 0) { + } else if (g_strcmp0(cmd, "PRIVMSG") == 0) { /* send the message to other clients as well */ char *params, *target, *msg; @@ -283,9 +283,9 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args, } ignore_next = FALSE; g_free(params); - } else if (strcmp(cmd, "PING") == 0) { + } else if (g_strcmp0(cmd, "PING") == 0) { proxy_redirect_event(client, "ping", 1, NULL, TRUE); - } else if (strcmp(cmd, "AWAY") == 0) { + } else if (g_strcmp0(cmd, "AWAY") == 0) { /* set the away reason */ if (args != NULL) { g_free(client->server->away_reason); @@ -347,7 +347,7 @@ static void sig_listen(LISTEN_REC *listen) rec->listen = listen; rec->handle = sendbuf; rec->host = g_strdup(host); - if (strcmp(listen->ircnet, "*") == 0) { + if (g_strcmp0(listen->ircnet, "*") == 0) { rec->proxy_address = g_strdup("irc.proxy"); rec->server = servers == NULL ? NULL : IRC_SERVER(servers->data); } else { @@ -415,7 +415,7 @@ static void sig_server_event(IRC_SERVER_REC *server, const char *line, } } - if (strcmp(event, "event privmsg") == 0 && + if (g_strcmp0(event, "event privmsg") == 0 && strstr(args, " :\001") != NULL && strstr(args, " :\001ACTION") == NULL) { /* CTCP - either answer ourself or forward it to one client */ @@ -435,8 +435,8 @@ static void sig_server_event(IRC_SERVER_REC *server, const char *line, return; } - if (strcmp(event, "event ping") == 0 || - strcmp(event, "event pong") == 0) { + if (g_strcmp0(event, "event ping") == 0 || + g_strcmp0(event, "event pong") == 0) { /* We want to answer ourself to PINGs and CTCPs. Also hide PONGs from clients. */ g_free(event); @@ -462,7 +462,7 @@ static void event_connected(IRC_SERVER_REC *server) CLIENT_REC *rec = tmp->data; if (rec->connected && rec->server == NULL && - (strcmp(rec->listen->ircnet, "*") == 0 || + (g_strcmp0(rec->listen->ircnet, "*") == 0 || (chatnet != NULL && g_ascii_strcasecmp(chatnet, rec->listen->ircnet) == 0))) { proxy_outdata(rec, ":%s NOTICE %s :Connected to server\n", |