summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-08-24 18:19:32 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-08-24 18:19:32 +0200
commit5d9af2902450cc8a3e181a515f13e86a26aa591d (patch)
tree92b031e47751d44a565b8ceeff69404386f1e068 /src/core
parent965c6ac2ea6c42eb3031dc4193fb7cbb7637f193 (diff)
downloadweechat-5d9af2902450cc8a3e181a515f13e86a26aa591d.zip
api: add infos "nick_color_ignore_case" and "nick_color_name_ignore_case" (issue #194)
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-string.c64
-rw-r--r--src/core/wee-string.h2
2 files changed, 66 insertions, 0 deletions
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index 83ee9e63c..ab0bee82e 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -395,6 +395,70 @@ string_toupper (const char *string)
}
/*
+ * 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).
*
* Returns: arithmetic result of subtracting the first UTF-8 char in string2
diff --git a/src/core/wee-string.h b/src/core/wee-string.h
index 19c616e5e..522d3e440 100644
--- a/src/core/wee-string.h
+++ b/src/core/wee-string.h
@@ -44,6 +44,8 @@ extern char *string_reverse_screen (const char *string);
extern char *string_repeat (const char *string, int count);
extern char *string_tolower (const char *string);
extern char *string_toupper (const char *string);
+extern char *string_tolower_range (const char *string, int range);
+extern char *string_toupper_range (const char *string, int range);
extern int string_charcmp (const char *string1, const char *string2);
extern int string_charcasecmp (const char *string1, const char *string2);
extern int string_charcasecmp_range (const char *string1, const char *string2,