mirror of
https://github.com/irssi/irssi.git
synced 2026-08-11 12:53:42 +02:00
Merge pull request #235 from dequis/g_strcmp0
Change all strcmp() to g_strcmp0() to handle nulls gracefully
This commit is contained in:
commit
03be2861dc
58 changed files with 174 additions and 170 deletions
|
|
@ -243,7 +243,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);
|
||||
|
|
|
|||
|
|
@ -427,7 +427,7 @@ static void event_no_such_nick(IRC_SERVER_REC *server, const char *data,
|
|||
g_return_if_fail(data != NULL);
|
||||
|
||||
params = event_get_params(data, 2, NULL, &unick);
|
||||
if (!strcmp(unick, "*"))
|
||||
if (!g_strcmp0(unick, "*"))
|
||||
/* more information will be in the description,
|
||||
* e.g. * :Target left IRC. Failed to deliver: [hi] */
|
||||
print_event_received(server, data, nick, FALSE);
|
||||
|
|
@ -605,7 +605,7 @@ static void print_event_received(IRC_SERVER_REC *server, const char *data,
|
|||
|
||||
recoded = recode_in(SERVER(server), args, NULL);
|
||||
format = nick == NULL || server->real_address == NULL ||
|
||||
strcmp(nick, server->real_address) == 0 ?
|
||||
g_strcmp0(nick, server->real_address) == 0 ?
|
||||
IRCTXT_DEFAULT_EVENT : IRCTXT_DEFAULT_EVENT_SERVER;
|
||||
printformat(server, target, MSGLEVEL_CRAP, format,
|
||||
nick, recoded, current_server_event);
|
||||
|
|
|
|||
|
|
@ -110,7 +110,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 ? "" : window_item_get_target(item);
|
||||
|
||||
if (*target == '\0' || *msg == '\0')
|
||||
|
|
@ -133,7 +133,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 ? "" : window_item_get_target(item);
|
||||
if (*target == '\0' || *ctcpcmd == '\0')
|
||||
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
|
|
@ -162,7 +162,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
|
|||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
|
||||
&target, &text))
|
||||
return;
|
||||
if (strcmp(target, "*") == 0)
|
||||
if (g_strcmp0(target, "*") == 0)
|
||||
target = item == NULL ? "" : window_item_get_target(item);
|
||||
if (*target == '\0' || *text == '\0')
|
||||
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
|
|
@ -262,7 +262,7 @@ static void cmd_ban(const char *data, IRC_SERVER_REC *server,
|
|||
if (chanrec == NULL && *channel == '\0')
|
||||
cmd_param_error(CMDERR_NOT_JOINED);
|
||||
|
||||
if (*channel != '\0' && strcmp(channel, "*") != 0)
|
||||
if (*channel != '\0' && g_strcmp0(channel, "*") != 0)
|
||||
chanrec = irc_channel_find(server, channel);
|
||||
|
||||
if (chanrec == NULL || !chanrec->synced) {
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||
if (ischannel(*target)) {
|
||||
item = irc_channel_find(server, target);
|
||||
} else {
|
||||
own = (!strcmp(nick, server->nick));
|
||||
own = (!g_strcmp0(nick, server->nick));
|
||||
item = privmsg_get_query(SERVER(server), own ? target : nick, FALSE, level);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ static void msg_multi_mode(IRC_CHANNEL_REC *channel, const char *sender,
|
|||
signal_add("print starting", (SIGNAL_FUNC) sig_print_starting);
|
||||
|
||||
rec = mode_find_channel(channel);
|
||||
if (rec != NULL && strcmp(rec->mode, mode) != 0) {
|
||||
if (rec != NULL && g_strcmp0(rec->mode, mode) != 0) {
|
||||
/* different mode than last time, show and remove the old */
|
||||
print_mode(rec);
|
||||
mode_destroy(rec);
|
||||
|
|
|
|||
|
|
@ -134,8 +134,8 @@ static void event_whois_realhost(IRC_SERVER_REC *server, const char *data)
|
|||
/* <yournick> real hostname <nick> <hostname> */
|
||||
params = event_get_params(data, 5, NULL, &nick, &txt_real,
|
||||
&txt_hostname, &hostname);
|
||||
if (strcmp(txt_real, "real") != 0 ||
|
||||
strcmp(txt_hostname, "hostname") != 0) {
|
||||
if (g_strcmp0(txt_real, "real") != 0 ||
|
||||
g_strcmp0(txt_hostname, "hostname") != 0) {
|
||||
/* <yournick> <nick> :... from <hostname> */
|
||||
g_free(params);
|
||||
params = event_get_params(data, 3, NULL, &nick, &hostname);
|
||||
|
|
@ -219,7 +219,7 @@ static void event_whois_usermode(IRC_SERVER_REC *server, const char *data)
|
|||
params = event_get_params(data, 4, NULL, &txt_usermodes,
|
||||
&nick, &usermode);
|
||||
|
||||
if (strcmp(txt_usermodes, "usermodes") == 0) {
|
||||
if (g_strcmp0(txt_usermodes, "usermodes") == 0) {
|
||||
/* <yournick> usermodes <nick> usermode */
|
||||
printformat(server, nick, MSGLEVEL_CRAP,
|
||||
IRCTXT_WHOIS_USERMODE, nick, usermode);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue