mirror of
https://github.com/irssi/irssi.git
synced 2026-08-22 10:02:22 +02:00
New function to find matching prefix in char* array
This commit is contained in:
parent
38ea52d09f
commit
adc5779b01
2 changed files with 20 additions and 0 deletions
|
|
@ -168,6 +168,23 @@ int strarray_find(char **array, const char *item)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int strarray_find_prefix(char **array, const char *item)
|
||||
{
|
||||
char **tmp;
|
||||
int index;
|
||||
|
||||
g_return_val_if_fail(array != NULL, -1);
|
||||
g_return_val_if_fail(item != NULL, -1);
|
||||
|
||||
index = 0;
|
||||
for (tmp = array; *tmp != NULL; tmp++, index++) {
|
||||
if (g_str_has_prefix(*tmp, item))
|
||||
return index;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
GSList *gslist_find_string(GSList *list, const char *key)
|
||||
{
|
||||
for (; list != NULL; list = list->next)
|
||||
|
|
|
|||
|
|
@ -100,6 +100,9 @@ char *replace_chars(char *str, char from, char to);
|
|||
/* return index of `item' in `array' or -1 if not found */
|
||||
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);
|
||||
|
||||
/* string -> uoff_t */
|
||||
uoff_t str_to_uofft(const char *str);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue