mirror of
https://github.com/irssi/irssi.git
synced 2026-08-23 02:22:36 +02:00
Minor changes as per review
This commit is contained in:
parent
7a9d9bd40b
commit
11bc71a2ea
3 changed files with 18 additions and 13 deletions
|
|
@ -168,7 +168,7 @@ int strarray_find(char **array, const char *item)
|
|||
return -1;
|
||||
}
|
||||
|
||||
gboolean strarray_find_prefix(char **array, const char *item)
|
||||
int strarray_find_prefix(char **array, const char *item)
|
||||
{
|
||||
char **tmp;
|
||||
int index;
|
||||
|
|
@ -176,14 +176,14 @@ gboolean strarray_find_prefix(char **array, const char *item)
|
|||
g_return_val_if_fail(array != NULL, -1);
|
||||
g_return_val_if_fail(item != NULL, -1);
|
||||
|
||||
item = g_ascii_strdown(item, -1);
|
||||
index = 0;
|
||||
for (tmp = array; *tmp != NULL; tmp++, index++) {
|
||||
if (g_str_has_prefix(g_ascii_strdown(*tmp, -1), item))
|
||||
return TRUE;
|
||||
//if (g_str_has_prefix(g_ascii_strdown(*tmp, -1), item))
|
||||
if (g_ascii_strncasecmp(*tmp, item, length(item)) == 0)
|
||||
return index;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
GSList *gslist_find_string(GSList *list, const char *key)
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ char *replace_chars(char *str, char from, char to);
|
|||
int strarray_find(char **array, const char *item);
|
||||
|
||||
/* return index of element in `array' starting with `item' or -1 if not found */
|
||||
gboolean strarray_find_prefix(char **array, const char *item);
|
||||
int strarray_find_prefix(char **array, const char *item);
|
||||
|
||||
/* string -> uoff_t */
|
||||
uoff_t str_to_uofft(const char *str);
|
||||
|
|
|
|||
|
|
@ -462,12 +462,18 @@ void fe_common_core_finish_init(void)
|
|||
|
||||
gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
|
||||
{
|
||||
const WindowType type = window_item_get_type(dest->window->active);
|
||||
GSList *targets = NULL, *iterator = NULL;
|
||||
gboolean found = FALSE;
|
||||
|
||||
g_return_val_if_fail(array != NULL, FALSE);
|
||||
WindowType type = window_item_get_type(dest->window->active);
|
||||
|
||||
// we ignore all targets
|
||||
if (strarray_find(array, "*") != -1)
|
||||
return TRUE;
|
||||
// exit if not a channel or query
|
||||
else if (type & WI_TYPE_OTHER)
|
||||
return FALSE;
|
||||
// we ignore all channels
|
||||
else if (type & WI_TYPE_CHANNEL && strarray_find(array, "#") != -1)
|
||||
return TRUE;
|
||||
|
|
@ -478,17 +484,16 @@ gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
|
|||
else if (type & WI_TYPE_PRIVMSG && strarray_find(array, "@") != -1)
|
||||
return TRUE;
|
||||
|
||||
if (dest->server_tag == NULL)
|
||||
return FALSE;
|
||||
g_return_val_if_fail(dest->server_tag != NULL, FALSE);
|
||||
|
||||
char *prefix = g_strdup_printf("%s/", dest->server_tag);
|
||||
if (!strarray_find_prefix(array, prefix)) {
|
||||
if (strarray_find_prefix(array, prefix) == -1) {
|
||||
g_free(prefix);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GSList *targets = NULL, *iterator = NULL;
|
||||
gboolean found = FALSE;
|
||||
g_free(prefix);
|
||||
|
||||
// create a list of types to look for
|
||||
targets = g_slist_append(targets, g_strdup("*"));
|
||||
if (type & WI_TYPE_CHANNEL) {
|
||||
|
|
@ -514,6 +519,6 @@ gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
|
|||
|
||||
g_slist_foreach(targets, (GFunc)g_free, NULL);
|
||||
g_slist_free(targets);
|
||||
g_free(prefix);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue