mirror of
https://github.com/weechat/weechat.git
synced 2026-07-06 17:53:13 +02:00
api: add infos "nick_color_ignore_case" and "nick_color_name_ignore_case" (issue #194)
This commit is contained in:
@@ -394,6 +394,70 @@ string_toupper (const char *string)
|
||||
return string_dyn_free (result, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts string to lower case (using a range of chars).
|
||||
*
|
||||
* Note: result must be freed after use.
|
||||
*/
|
||||
|
||||
char *
|
||||
string_tolower_range (const char *string, int range)
|
||||
{
|
||||
char *result, *ptr_result;
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
if (range <= 0)
|
||||
return string_tolower (string);
|
||||
|
||||
result = strdup (string);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
ptr_result = result;
|
||||
while (ptr_result && ptr_result[0])
|
||||
{
|
||||
if ((ptr_result[0] >= 'A') && (ptr_result[0] < 'A' + range))
|
||||
ptr_result[0] += ('a' - 'A');
|
||||
ptr_result = (char *)utf8_next_char (ptr_result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts string to upper case (using a range of char).
|
||||
*
|
||||
* Note: result must be freed after use.
|
||||
*/
|
||||
|
||||
char *
|
||||
string_toupper_range (const char *string, int range)
|
||||
{
|
||||
char *result, *ptr_result;
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
if (range <= 0)
|
||||
return string_toupper (string);
|
||||
|
||||
result = strdup (string);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
ptr_result = result;
|
||||
while (ptr_result && ptr_result[0])
|
||||
{
|
||||
if ((ptr_result[0] >= 'a') && (ptr_result[0] < 'a' + range))
|
||||
ptr_result[0] -= ('a' - 'A');
|
||||
ptr_result = (char *)utf8_next_char (ptr_result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compares two chars (case sensitive).
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user