From 72930e0be3a8841e8149b246542832128310c350 Mon Sep 17 00:00:00 2001 From: Emanuele Giaquinta Date: Sun, 9 Mar 2008 12:17:55 +0000 Subject: [PATCH] Use g_ascii_str{,n}casecmp for case insensitive comparison with ascii only strings. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4739 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/misc.c | 28 ++++++++++---------- src/core/servers-reconnect.c | 4 +-- src/core/servers.c | 4 +-- src/fe-common/irc/fe-events.c | 2 +- src/fe-common/irc/notifylist/fe-notifylist.c | 2 +- src/fe-text/mainwindows.c | 2 +- src/irc/core/ctcp.c | 2 +- src/irc/core/irc-servers.c | 2 +- src/irc/dcc/dcc-chat.c | 10 +++---- src/irc/dcc/dcc-server.c | 8 +++--- src/irc/dcc/dcc.c | 4 +-- src/irc/flood/flood.c | 2 +- 12 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/core/misc.c b/src/core/misc.c index 0c404363..b97d2fa6 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -836,24 +836,24 @@ int parse_time_interval(const char *time, int *msecs) return TRUE; } - if (g_strncasecmp(desc, "days", len) == 0) { + if (g_ascii_strncasecmp(desc, "days", len) == 0) { if (number > 24) { /* would overflow */ return FALSE; } *msecs += number * 1000*3600*24; - } else if (g_strncasecmp(desc, "hours", len) == 0) + } else if (g_ascii_strncasecmp(desc, "hours", len) == 0) *msecs += number * 1000*3600; - else if (g_strncasecmp(desc, "minutes", len) == 0 || - g_strncasecmp(desc, "mins", len) == 0) + else if (g_ascii_strncasecmp(desc, "minutes", len) == 0 || + g_ascii_strncasecmp(desc, "mins", len) == 0) *msecs += number * 1000*60; - else if (g_strncasecmp(desc, "seconds", len) == 0 || - g_strncasecmp(desc, "secs", len) == 0) + else if (g_ascii_strncasecmp(desc, "seconds", len) == 0 || + g_ascii_strncasecmp(desc, "secs", len) == 0) *msecs += number * 1000; - else if (g_strncasecmp(desc, "milliseconds", len) == 0 || - g_strncasecmp(desc, "millisecs", len) == 0 || - g_strncasecmp(desc, "mseconds", len) == 0 || - g_strncasecmp(desc, "msecs", len) == 0) + else if (g_ascii_strncasecmp(desc, "milliseconds", len) == 0 || + g_ascii_strncasecmp(desc, "millisecs", len) == 0 || + g_ascii_strncasecmp(desc, "mseconds", len) == 0 || + g_ascii_strncasecmp(desc, "msecs", len) == 0) *msecs += number; else { ret = FALSE; @@ -907,13 +907,13 @@ int parse_size(const char *size, int *bytes) return FALSE; } - if (g_strncasecmp(desc, "gbytes", len) == 0) + if (g_ascii_strncasecmp(desc, "gbytes", len) == 0) *bytes += number * 1024*1024*1024; - if (g_strncasecmp(desc, "mbytes", len) == 0) + if (g_ascii_strncasecmp(desc, "mbytes", len) == 0) *bytes += number * 1024*1024; - if (g_strncasecmp(desc, "kbytes", len) == 0) + if (g_ascii_strncasecmp(desc, "kbytes", len) == 0) *bytes += number * 1024; - if (g_strncasecmp(desc, "bytes", len) == 0) + if (g_ascii_strncasecmp(desc, "bytes", len) == 0) *bytes += number; /* skip punctuation */ diff --git a/src/core/servers-reconnect.c b/src/core/servers-reconnect.c index 2b227ebe..ae1942af 100644 --- a/src/core/servers-reconnect.c +++ b/src/core/servers-reconnect.c @@ -415,7 +415,7 @@ static void cmd_reconnect(const char *data, SERVER_REC *server) cmd_param_error(CMDERR_NOT_CONNECTED); rec = reconnects->data; } else { - if (g_strncasecmp(data, "RECON-", 6) == 0) + if (g_ascii_strncasecmp(data, "RECON-", 6) == 0) data += 6; tagnum = atoi(tag); @@ -439,7 +439,7 @@ static void cmd_disconnect(const char *data, SERVER_REC *server) { RECONNECT_REC *rec; - if (g_strncasecmp(data, "RECON-", 6) != 0) + if (g_ascii_strncasecmp(data, "RECON-", 6) != 0) return; /* handle only reconnection removing */ rec = reconnect_find_tag(atoi(data+6)); diff --git a/src/core/servers.c b/src/core/servers.c index 2e9d11fc..9b9e8263 100644 --- a/src/core/servers.c +++ b/src/core/servers.c @@ -77,8 +77,8 @@ static char *server_create_address_tag(const char *address) /* try to generate a reasonable server tag */ if (strchr(address, '.') == NULL) { start = end = NULL; - } else if (g_strncasecmp(address, "irc", 3) == 0 || - g_strncasecmp(address, "chat", 4) == 0) { + } else if (g_ascii_strncasecmp(address, "irc", 3) == 0 || + g_ascii_strncasecmp(address, "chat", 4) == 0) { /* irc-2.cs.hut.fi -> hut, chat.bt.net -> bt */ end = strrchr(address, '.'); start = end-1; diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c index 57e360d6..dc952a66 100644 --- a/src/fe-common/irc/fe-events.c +++ b/src/fe-common/irc/fe-events.c @@ -269,7 +269,7 @@ static void event_wallops(IRC_SERVER_REC *server, const char *data, const char * if (ignore_check(SERVER(server), nick, addr, NULL, data, MSGLEVEL_WALLOPS)) return; - if (g_strncasecmp(data, "\001ACTION ", 8) != 0) + if (g_ascii_strncasecmp(data, "\001ACTION ", 8) != 0) printformat(server, NULL, MSGLEVEL_WALLOPS, IRCTXT_WALLOPS, nick, data); else { /* Action in WALLOP */ diff --git a/src/fe-common/irc/notifylist/fe-notifylist.c b/src/fe-common/irc/notifylist/fe-notifylist.c index 35bed36d..036c07e9 100644 --- a/src/fe-common/irc/notifylist/fe-notifylist.c +++ b/src/fe-common/irc/notifylist/fe-notifylist.c @@ -177,7 +177,7 @@ static void cmd_notify(const char *data) signal_stop(); } - if (g_strncasecmp(data, "-list", 4) == 0) { + if (g_ascii_strncasecmp(data, "-list", 4) == 0) { cmd_notifylist_show(); signal_stop(); } diff --git a/src/fe-text/mainwindows.c b/src/fe-text/mainwindows.c index 398c5b58..125fea97 100644 --- a/src/fe-text/mainwindows.c +++ b/src/fe-text/mainwindows.c @@ -974,7 +974,7 @@ static void cmd_window_stick(const char *data) while (*data == ' ') data++; } - if (g_strncasecmp(data, "OF", 2) == 0 || i_toupper(*data) == 'N') { + if (g_ascii_strncasecmp(data, "OF", 2) == 0 || i_toupper(*data) == 'N') { /* unset sticky */ if (!WINDOW_GUI(win)->sticky) { printformat_window(win, MSGLEVEL_CLIENTERROR, diff --git a/src/irc/core/ctcp.c b/src/irc/core/ctcp.c index 8ae3be43..cc4bd6ca 100644 --- a/src/irc/core/ctcp.c +++ b/src/irc/core/ctcp.c @@ -224,7 +224,7 @@ static void ctcp_msg(IRC_SERVER_REC *server, const char *data, { char *args, *str; - if (g_strncasecmp(data, "ACTION ", 7) == 0) { + if (g_ascii_strncasecmp(data, "ACTION ", 7) == 0) { /* special treatment for actions */ signal_emit("ctcp action", 5, server, data+7, nick, addr, target); diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index 94bb51ec..43b47855 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -257,7 +257,7 @@ void irc_server_purge_output(IRC_SERVER_REC *server, const char *target) redirect = tmp->next->data; if ((target == NULL || command_has_target(cmd, target)) && - g_strncasecmp(cmd, "PONG ", 5) != 0) { + g_ascii_strncasecmp(cmd, "PONG ", 5) != 0) { /* remove the redirection */ link = tmp->next; server->cmdqueue = diff --git a/src/irc/dcc/dcc-chat.c b/src/irc/dcc/dcc-chat.c index 5569cd96..782c33b3 100644 --- a/src/irc/dcc/dcc-chat.c +++ b/src/irc/dcc/dcc-chat.c @@ -539,7 +539,7 @@ static void cmd_mircdcc(const char *data, SERVER_REC *server, if (dcc == NULL) return; dcc->mirc_ctcp = i_toupper(*data) != 'N' && - g_strncasecmp(data, "OF", 2) != 0; + g_ascii_strncasecmp(data, "OF", 2) != 0; } /* DCC CLOSE CHAT - check only from chat_ids in open DCC chats, @@ -553,7 +553,7 @@ static void cmd_dcc_close(char *data, SERVER_REC *server) g_return_if_fail(data != NULL); - if (g_strncasecmp(data, "CHAT ", 5) != 0 || + if (g_ascii_strncasecmp(data, "CHAT ", 5) != 0 || !cmd_get_params(data, &free_arg, 2, NULL, &nick)) return; @@ -694,11 +694,11 @@ static void dcc_chat_msg(CHAT_DCC_REC *dcc, const char *msg) g_return_if_fail(msg != NULL); reply = FALSE; - if (g_strncasecmp(msg, "CTCP_MESSAGE ", 13) == 0) { + if (g_ascii_strncasecmp(msg, "CTCP_MESSAGE ", 13) == 0) { /* bitchx (and ircii?) sends this */ msg += 13; dcc->mirc_ctcp = FALSE; - } else if (g_strncasecmp(msg, "CTCP_REPLY ", 11) == 0) { + } else if (g_ascii_strncasecmp(msg, "CTCP_REPLY ", 11) == 0) { /* bitchx (and ircii?) sends this */ msg += 11; reply = TRUE; @@ -761,7 +761,7 @@ static void ctcp_reply_dcc_reject(IRC_SERVER_REC *server, const char *data, /* default REJECT handler checks args too - we don't care about it in DCC chats. */ - if (g_strncasecmp(data, "CHAT", 4) == 0 && + if (g_ascii_strncasecmp(data, "CHAT", 4) == 0 && (data[4] == '\0' || data[4] == ' ')) { dcc = dcc_find_request(DCC_CHAT_TYPE, nick, NULL); if (dcc != NULL) dcc_close(dcc); diff --git a/src/irc/dcc/dcc-server.c b/src/irc/dcc/dcc-server.c index 147e83fa..73a56d62 100644 --- a/src/irc/dcc/dcc-server.c +++ b/src/irc/dcc/dcc-server.c @@ -199,7 +199,7 @@ static void dcc_server_msg(SERVER_DCC_REC *dcc, const char *msg) g_return_if_fail(msg != NULL); /* Check for CHAT protocol */ - if (g_strncasecmp(msg, "100 ", 4) == 0) { + if (g_ascii_strncasecmp(msg, "100 ", 4) == 0) { msg += 4; /* Check if this server is accepting chat requests.*/ if (dcc->accept_chat) { @@ -227,7 +227,7 @@ static void dcc_server_msg(SERVER_DCC_REC *dcc, const char *msg) } /* Check for FSERVE protocol */ - if (g_strncasecmp(msg, "110 ", 4) == 0) { + if (g_ascii_strncasecmp(msg, "110 ", 4) == 0) { msg += 4; /* Check if this server is accepting fserve requests.*/ if (dcc->accept_fserve) { @@ -236,7 +236,7 @@ static void dcc_server_msg(SERVER_DCC_REC *dcc, const char *msg) } /* Check for SEND protocol */ - if (g_strncasecmp(msg, "120 ", 4) == 0) { + if (g_ascii_strncasecmp(msg, "120 ", 4) == 0) { msg += 4; /* Check if this server is accepting send requests.*/ if (dcc->accept_send) { @@ -368,7 +368,7 @@ static void cmd_dcc_close(char *data, SERVER_REC *server) g_return_if_fail(data != NULL); - if (g_strncasecmp(data, "SERVER ", 7) != 0 || + if (g_ascii_strncasecmp(data, "SERVER ", 7) != 0 || !cmd_get_params(data, &free_arg, 2, NULL, &port_str)) { return; } diff --git a/src/irc/dcc/dcc.c b/src/irc/dcc/dcc.c index 3078a093..bc8d8452 100644 --- a/src/irc/dcc/dcc.c +++ b/src/irc/dcc/dcc.c @@ -332,7 +332,7 @@ static void sig_server_nick_changed(IRC_SERVER_REC *server) static void ctcp_msg(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr, const char *target) { - if (g_strncasecmp(data, "dcc ", 4) != 0) + if (g_ascii_strncasecmp(data, "dcc ", 4) != 0) return; data += 4; @@ -345,7 +345,7 @@ static void ctcp_msg(IRC_SERVER_REC *server, const char *data, static void ctcp_reply(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr, const char *target) { - if (g_strncasecmp(data, "dcc ", 4) != 0) + if (g_ascii_strncasecmp(data, "dcc ", 4) != 0) return; data += 4; diff --git a/src/irc/flood/flood.c b/src/irc/flood/flood.c index 21e01787..ebb07d2c 100644 --- a/src/irc/flood/flood.c +++ b/src/irc/flood/flood.c @@ -274,7 +274,7 @@ static void flood_ctcp(IRC_SERVER_REC *server, const char *data, if (addr == NULL || g_strcasecmp(nick, server->nick) == 0) return; - level = g_strncasecmp(data, "ACTION ", 7) != 0 ? MSGLEVEL_CTCPS : + level = g_ascii_strncasecmp(data, "ACTION ", 7) != 0 ? MSGLEVEL_CTCPS : (ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS); if (!ignore_check(SERVER(server), nick, addr, target, data, level)) flood_newmsg(server, level, nick, addr, target);