summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/util.c b/util.c
index 1649f91..b86a4ca 100644
--- a/util.c
+++ b/util.c
@@ -38,6 +38,12 @@ void rc_str_incref(RcStr *str) {
str->ref_count += 1;
}
+
+RcStr *rc_str_copy(RcStr *str) {
+ rc_str_incref(str);
+ return str;
+}
+
void rc_str_decref(RcStr **pstr) {
RcStr *const str = *pstr;
if (!str) return;
@@ -300,6 +306,13 @@ void str_trim(char *str) {
str_trim_start(str);
}
+void str_ascii_to_lowercase(char *str) {
+ for (char *p = str; *p; p++) {
+ if (*p > 0 && *p < 127)
+ *p = (char)tolower(*p);
+ }
+}
+
size_t str_count_char(const char *s, char c) {
const char *p = s;
size_t count = 0;