diff options
author | Alexander Færøy <ahf@0x90.dk> | 2015-04-17 21:13:18 +0200 |
---|---|---|
committer | Alexander Færøy <ahf@0x90.dk> | 2015-04-17 21:13:18 +0200 |
commit | 03be2861dcec9e8d088be6a0cae2848388923dab (patch) | |
tree | 2355318b525a4bbae3c1651ab37f89901500b2ab /src/fe-common/core | |
parent | ef5ac430c75a3a551991aff8dae08ceeaca25d3f (diff) | |
parent | 9890daca797b31d34d97d953c512378aabe3d51f (diff) | |
download | irssi-03be2861dcec9e8d088be6a0cae2848388923dab.zip |
Merge pull request #235 from dequis/g_strcmp0
Change all strcmp() to g_strcmp0() to handle nulls gracefully
Diffstat (limited to 'src/fe-common/core')
-rw-r--r-- | src/fe-common/core/command-history.c | 6 | ||||
-rw-r--r-- | src/fe-common/core/completion.c | 4 | ||||
-rw-r--r-- | src/fe-common/core/fe-channels.c | 6 | ||||
-rw-r--r-- | src/fe-common/core/fe-exec.c | 2 | ||||
-rw-r--r-- | src/fe-common/core/fe-help.c | 6 | ||||
-rw-r--r-- | src/fe-common/core/fe-ignore.c | 2 | ||||
-rw-r--r-- | src/fe-common/core/fe-log.c | 4 | ||||
-rw-r--r-- | src/fe-common/core/fe-messages.c | 8 | ||||
-rw-r--r-- | src/fe-common/core/fe-queries.c | 2 | ||||
-rw-r--r-- | src/fe-common/core/fe-recode.c | 2 | ||||
-rw-r--r-- | src/fe-common/core/fe-server.c | 4 | ||||
-rw-r--r-- | src/fe-common/core/fe-settings.c | 2 | ||||
-rw-r--r-- | src/fe-common/core/hilight-text.c | 4 | ||||
-rw-r--r-- | src/fe-common/core/keyboard.c | 10 | ||||
-rw-r--r-- | src/fe-common/core/themes.c | 6 | ||||
-rw-r--r-- | src/fe-common/core/window-commands.c | 4 |
16 files changed, 36 insertions, 36 deletions
diff --git a/src/fe-common/core/command-history.c b/src/fe-common/core/command-history.c index 37405c43..f9c3884c 100644 --- a/src/fe-common/core/command-history.c +++ b/src/fe-common/core/command-history.c @@ -42,7 +42,7 @@ void command_history_add(HISTORY_REC *history, const char *text) g_return_if_fail(text != NULL); link = g_list_last(history->list); - if (link != NULL && strcmp(link->data, text) == 0) + if (link != NULL && g_strcmp0(link->data, text) == 0) return; /* same as previous entry */ if (settings_get_int("max_command_history") < 1 || @@ -121,7 +121,7 @@ const char *command_history_prev(WINDOW_REC *window, const char *text) } if (*text != '\0' && - (pos == NULL || strcmp(pos->data, text) != 0)) { + (pos == NULL || g_strcmp0(pos->data, text) != 0)) { /* save the old entry to history */ command_history_add(history, text); } @@ -145,7 +145,7 @@ const char *command_history_next(WINDOW_REC *window, const char *text) } if (*text != '\0' && - (pos == NULL || strcmp(pos->data, text) != 0)) { + (pos == NULL || g_strcmp0(pos->data, text) != 0)) { /* save the old entry to history */ command_history_add(history, text); } diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index 31d62e10..c607a884 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -141,7 +141,7 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, i g_return_val_if_fail(pos != NULL, NULL); continue_complete = complist != NULL && *pos == last_line_pos && - strcmp(line, last_line) == 0; + g_strcmp0(line, last_line) == 0; if (erase && !continue_complete) return NULL; @@ -681,7 +681,7 @@ static void sig_complete_set(GList **list, WINDOW_REC *window, g_return_if_fail(line != NULL); if (*line == '\0' || - !strcmp("-clear", line) || !strcmp("-default", line)) + !g_strcmp0("-clear", line) || !g_strcmp0("-default", line)) *list = completion_get_settings(word, -1); else if (*line != '\0' && *word == '\0') { SETTINGS_REC *rec = settings_get_record(line); diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c index aefd1034..a171596d 100644 --- a/src/fe-common/core/fe-channels.c +++ b/src/fe-common/core/fe-channels.c @@ -287,7 +287,7 @@ static void cmd_channel_add(const char *data) if (g_hash_table_lookup(optlist, "noauto")) rec->autojoin = FALSE; if (botarg != NULL && *botarg != '\0') rec->botmasks = g_strdup(botarg); if (botcmdarg != NULL && *botcmdarg != '\0') rec->autosendcmd = g_strdup(botcmdarg); - if (*password != '\0' && strcmp(password, "-") != 0) rec->password = g_strdup(password); + if (*password != '\0' && g_strcmp0(password, "-") != 0) rec->password = g_strdup(password); signal_emit("channel add fill", 2, rec, optlist); @@ -523,7 +523,7 @@ static void cmd_names(const char *data, SERVER_REC *server, WI_ITEM_REC *item) "names", &optlist, &channel)) return; - if (strcmp(channel, "*") == 0 || *channel == '\0') { + if (g_strcmp0(channel, "*") == 0 || *channel == '\0') { if (!IS_CHANNEL(item)) cmd_param_error(CMDERR_NOT_JOINED); @@ -561,7 +561,7 @@ static void cmd_names(const char *data, SERVER_REC *server, WI_ITEM_REC *item) if (unknowns->len > 1) g_string_truncate(unknowns, unknowns->len-1); - if (unknowns->len > 0 && strcmp(channel, unknowns->str) != 0) + if (unknowns->len > 0 && g_strcmp0(channel, unknowns->str) != 0) signal_emit("command names", 3, unknowns->str, server, item); g_string_free(unknowns, TRUE); diff --git a/src/fe-common/core/fe-exec.c b/src/fe-common/core/fe-exec.c index 9249f432..b5f289ce 100644 --- a/src/fe-common/core/fe-exec.c +++ b/src/fe-common/core/fe-exec.c @@ -161,7 +161,7 @@ static PROCESS_REC *process_find(const char *name, int verbose) for (tmp = processes; tmp != NULL; tmp = tmp->next) { PROCESS_REC *rec = tmp->data; - if (rec->name != NULL && strcmp(rec->name, name) == 0) + if (rec->name != NULL && g_strcmp0(rec->name, name) == 0) return rec; } diff --git a/src/fe-common/core/fe-help.c b/src/fe-common/core/fe-help.c index 4ea7c89f..23a6e701 100644 --- a/src/fe-common/core/fe-help.c +++ b/src/fe-common/core/fe-help.c @@ -37,12 +37,12 @@ static int commands_equal(COMMAND_REC *rec, COMMAND_REC *rec2) if (rec2->category == NULL && rec->category != NULL) return 1; if (rec->category != NULL && rec2->category != NULL) { - i = strcmp(rec->category, rec2->category); + i = g_strcmp0(rec->category, rec2->category); if (i != 0) return i; } - return strcmp(rec->cmd, rec2->cmd); + return g_strcmp0(rec->cmd, rec2->cmd); } static int get_cmd_length(void *data) @@ -176,7 +176,7 @@ static void show_help(const char *data) if (last != NULL && rec->category != NULL && (last->category == NULL || - strcmp(rec->category, last->category) != 0)) { + g_strcmp0(rec->category, last->category) != 0)) { /* category changed */ if (items > 0) { if (!header) { diff --git a/src/fe-common/core/fe-ignore.c b/src/fe-common/core/fe-ignore.c index 1a0b8339..533cda31 100644 --- a/src/fe-common/core/fe-ignore.c +++ b/src/fe-common/core/fe-ignore.c @@ -165,7 +165,7 @@ static void cmd_ignore(const char *data) rec = g_new0(IGNORE_REC, 1); rec->mask = mask == NULL || *mask == '\0' || - strcmp(mask, "*") == 0 ? NULL : g_strdup(mask); + g_strcmp0(mask, "*") == 0 ? NULL : g_strdup(mask); rec->channels = channels; } else { g_free_and_null(rec->pattern); diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c index 9d68faf9..a39623d2 100644 --- a/src/fe-common/core/fe-log.c +++ b/src/fe-common/core/fe-log.c @@ -485,7 +485,7 @@ static void autolog_open_check(TEXT_DEST_REC *dest) return; if (target != NULL) - autolog_open(server, server_tag, strcmp(target, "*") ? target : deftarget); + autolog_open(server, server_tag, g_strcmp0(target, "*") ? target : deftarget); } static void log_single_line(WINDOW_REC *window, const char *server_tag, @@ -629,7 +629,7 @@ static void sig_log_create_failed(LOG_REC *log) static void sig_log_new(LOG_REC *log) { if (!settings_get_bool("awaylog_colors") && - strcmp(log->fname, settings_get_str("awaylog_file")) == 0) + g_strcmp0(log->fname, settings_get_str("awaylog_file")) == 0) log->colorizer = log_colorizer_strip; } diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c index 1d44bdd9..3bd2b666 100644 --- a/src/fe-common/core/fe-messages.c +++ b/src/fe-common/core/fe-messages.c @@ -249,7 +249,7 @@ static void sig_message_private(SERVER_REC *server, const char *msg, int level = MSGLEVEL_MSGS; /* own message returned by bouncer? */ - int own = (!strcmp(nick, server->nick)); + int own = (!g_strcmp0(nick, server->nick)); query = query_find(server, own ? target : nick); @@ -323,8 +323,8 @@ static void sig_message_own_private(SERVER_REC *server, const char *msg, /* this should only happen if some special target failed and we should display some error message. currently the special targets are only ',' and '.'. */ - g_return_if_fail(strcmp(origtarget, ",") == 0 || - strcmp(origtarget, ".") == 0); + g_return_if_fail(g_strcmp0(origtarget, ",") == 0 || + g_strcmp0(origtarget, ".") == 0); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, *origtarget == ',' ? TXT_NO_MSGS_GOT : @@ -569,7 +569,7 @@ static int printnick_exists(NICK_REC *first, NICK_REC *ignore, while (first != NULL) { if (first != ignore) { printnick = g_hash_table_lookup(printnicks, first); - if (printnick != NULL && strcmp(printnick, nick) == 0) + if (printnick != NULL && g_strcmp0(printnick, nick) == 0) return TRUE; } diff --git a/src/fe-common/core/fe-queries.c b/src/fe-common/core/fe-queries.c index 5cdf87ee..121417e4 100644 --- a/src/fe-common/core/fe-queries.c +++ b/src/fe-common/core/fe-queries.c @@ -331,7 +331,7 @@ static void sig_message_private(SERVER_REC *server, const char *msg, QUERY_REC *query; /* own message returned by bouncer? */ - int own = (!strcmp(nick, server->nick)); + int own = (!g_strcmp0(nick, server->nick)); /* create query window if needed */ query = privmsg_get_query(server, own ? target : nick, FALSE, MSGLEVEL_MSGS); diff --git a/src/fe-common/core/fe-recode.c b/src/fe-common/core/fe-recode.c index dbc43574..829c89e7 100644 --- a/src/fe-common/core/fe-recode.c +++ b/src/fe-common/core/fe-recode.c @@ -45,7 +45,7 @@ static const char *fe_recode_get_target (WI_ITEM_REC *witem) static int fe_recode_compare_func (CONFIG_NODE *node1, CONFIG_NODE *node2) { - return strcmp(node1->key, node2->key); + return g_strcmp0(node1->key, node2->key); } /* SYNTAX: RECODE */ diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index ec9b5e4c..429e6dac 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -189,7 +189,7 @@ static void cmd_server_add(const char *data) if (g_hash_table_lookup(optlist, "proxy")) rec->no_proxy = FALSE; if (g_hash_table_lookup(optlist, "noproxy")) rec->no_proxy = TRUE; - if (*password != '\0' && strcmp(password, "-") != 0) rec->password = g_strdup(password); + if (*password != '\0' && g_strcmp0(password, "-") != 0) rec->password = g_strdup(password); value = g_hash_table_lookup(optlist, "host"); if (value != NULL && *value != '\0') { rec->own_host = g_strdup(value); @@ -268,7 +268,7 @@ static void cmd_server_connect(const char *data) "connect", &optlist, &addr)) return; - if (*addr == '\0' || strcmp(addr, "+") == 0) + if (*addr == '\0' || g_strcmp0(addr, "+") == 0) cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (*addr == '+') window_create(NULL, FALSE); diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c index 96e03ceb..9c370838 100644 --- a/src/fe-common/core/fe-settings.c +++ b/src/fe-common/core/fe-settings.c @@ -53,7 +53,7 @@ static void set_print_pattern(const char *pattern) if (stristr(rec->key, pattern) == NULL) continue; - if (strcmp(last_section, rec->section) != 0) { + if (g_strcmp0(last_section, rec->section) != 0) { /* print section */ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_SET_TITLE, rec->section); diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index ff3a7085..beb4ed7a 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -168,7 +168,7 @@ static HILIGHT_REC *hilight_find(const char *text, char **channels) if ((channels == NULL && rec->channels == NULL)) return rec; /* no channels - ok */ - if (channels != NULL && strcmp(*channels, "*") == 0) + if (channels != NULL && g_strcmp0(*channels, "*") == 0) return rec; /* ignore channels */ if (channels == NULL || rec->channels == NULL) @@ -306,7 +306,7 @@ void hilight_update_text_dest(TEXT_DEST_REC *dest, HILIGHT_REC *rec) dest->hilight_priority = rec->priority; g_free_and_null(dest->hilight_color); - if (rec->act_color != NULL && strcmp(rec->act_color, "%n") == 0) + if (rec->act_color != NULL && g_strcmp0(rec->act_color, "%n") == 0) dest->level |= MSGLEVEL_NO_ACT; else dest->hilight_color = hilight_get_act_color(rec); diff --git a/src/fe-common/core/keyboard.c b/src/fe-common/core/keyboard.c index bec1502e..eac8525b 100644 --- a/src/fe-common/core/keyboard.c +++ b/src/fe-common/core/keyboard.c @@ -118,7 +118,7 @@ static CONFIG_NODE *key_config_find(const char *key) for (; tmp != NULL; tmp = config_node_next(tmp)) { node = tmp->data; - if (strcmp(config_node_get_str(node, "key", ""), key) == 0) + if (g_strcmp0(config_node_get_str(node, "key", ""), key) == 0) return node; } @@ -211,7 +211,7 @@ static int expand_combo(const char *start, const char *end, GSList **out) for (tmp = info->keys; tmp != NULL; tmp = tmp->next) { KEY_REC *rec = tmp->data; - if (strcmp(rec->data, str) == 0) + if (g_strcmp0(rec->data, str) == 0) list = g_slist_append(list, rec); } @@ -347,7 +347,7 @@ static void key_states_scan_key(const char *key, KEY_REC *rec) { GSList *tmp, *out; - if (strcmp(rec->info->id, "key") == 0) + if (g_strcmp0(rec->info->id, "key") == 0) return; out = g_slist_append(NULL, g_string_new(NULL)); @@ -383,7 +383,7 @@ static void key_states_rescan(void) g_tree_foreach(key_states, (GTraverseFunc) key_state_destroy, NULL); g_tree_destroy(key_states); - key_states = g_tree_new((GCompareFunc) strcmp); + key_states = g_tree_new((GCompareFunc) g_strcmp0); temp = g_string_new(NULL); g_hash_table_foreach(keys, (GHFunc) key_states_scan_key, temp); @@ -860,7 +860,7 @@ void keyboard_init(void) default_keys = g_hash_table_new((GHashFunc) g_str_hash, (GCompareFunc) g_str_equal); keyinfos = NULL; - key_states = g_tree_new((GCompareFunc) strcmp); + key_states = g_tree_new((GCompareFunc) g_strcmp0); key_config_frozen = 0; memset(used_keys, 0, sizeof(used_keys)); diff --git a/src/fe-common/core/themes.c b/src/fe-common/core/themes.c index c0741cef..0ef98fee 100644 --- a/src/fe-common/core/themes.c +++ b/src/fe-common/core/themes.c @@ -895,7 +895,7 @@ THEME_REC *theme_load(const char *setname) name = g_strdup(setname); p = strrchr(name, '.'); - if (p != NULL && strcmp(p, ".theme") == 0) { + if (p != NULL && g_strcmp0(p, ".theme") == 0) { /* remove the trailing .theme */ *p = '\0'; } @@ -1358,9 +1358,9 @@ static void read_settings(void) theme = settings_get_str("theme"); len = strlen(current_theme->name); - if (strcmp(current_theme->name, theme) != 0 && + if (g_strcmp0(current_theme->name, theme) != 0 && (strncmp(current_theme->name, theme, len) != 0 || - strcmp(theme+len, ".theme") != 0)) + g_strcmp0(theme+len, ".theme") != 0)) change_theme(theme, TRUE); } diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c index 61357324..c6ab68c0 100644 --- a/src/fe-common/core/window-commands.c +++ b/src/fe-common/core/window-commands.c @@ -127,7 +127,7 @@ static void cmd_window_info(WINDOW_REC *win) win->active_server->tag : "NONE"); } else { if (win->active_server != NULL && - strcmp(win->active_server->tag, win->servertag) != 0) + g_strcmp0(win->active_server->tag, win->servertag) != 0) g_warning("Active server isn't the sticky server!"); printformat_window(win, MSGLEVEL_CLIENTCRAP, @@ -609,7 +609,7 @@ static void cmd_window_name(const char *data) if (win == NULL || win == active_win) window_set_name(active_win, data); else if (active_win->name == NULL || - strcmp(active_win->name, data) != 0) { + g_strcmp0(active_win->name, data) != 0) { printformat_window(active_win, MSGLEVEL_CLIENTERROR, TXT_WINDOW_NAME_NOT_UNIQUE, data); } |