diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/weechat.c | 25 | ||||
-rw-r--r-- | src/common/weechat.h | 1 | ||||
-rw-r--r-- | src/common/weeconfig.c | 4 |
3 files changed, 28 insertions, 2 deletions
diff --git a/src/common/weechat.c b/src/common/weechat.c index 76d426aa0..7e99ae250 100644 --- a/src/common/weechat.c +++ b/src/common/weechat.c @@ -196,6 +196,31 @@ ascii_strncasecmp (char *string1, char *string2, int max) } /* + * ascii_strcasestr: locale and case independent string search + */ + +char * +ascii_strcasestr (char *string, char *search) +{ + int length_search; + + length_search = strlen (search); + + if (!string || !search || (length_search == 0)) + return NULL; + + while (string[0]) + { + if (ascii_strncasecmp (string, search, length_search) == 0) + return string; + + string++; + } + + return NULL; +} + +/* * weechat_iconv: convert string to another charset */ diff --git a/src/common/weechat.h b/src/common/weechat.h index 5c08702e4..c238008b8 100644 --- a/src/common/weechat.h +++ b/src/common/weechat.h @@ -108,6 +108,7 @@ extern void ascii_tolower (char *); extern void ascii_toupper (char *); extern int ascii_strcasecmp (char *, char *); extern int ascii_strncasecmp (char *, char *, int); +extern char *ascii_strcasestr (char *, char *); extern char *weechat_iconv (char *, char *, char *); extern char *weechat_strreplace (char *, char *, char *); extern void weechat_dump (int); diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c index 4a142e977..20d5604b2 100644 --- a/src/common/weeconfig.c +++ b/src/common/weeconfig.c @@ -1366,7 +1366,7 @@ config_option_list_remove (char **string, char *item) name = (char *) malloc (strlen (item) + 2); strcpy (name, item); strcat (name, ":"); - pos = strstr (*string, name); + pos = ascii_strcasestr (*string, name); free (name); if (pos) { @@ -1442,7 +1442,7 @@ config_option_list_get_value (char **string, char *item, name = (char *) malloc (strlen (item) + 2); strcpy (name, item); strcat (name, ":"); - pos = strstr (*string, name); + pos = ascii_strcasestr (*string, name); free (name); if (pos) { |