summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/util.c b/util.c
index bdeb687..89b3dc2 100644
--- a/util.c
+++ b/util.c
@@ -262,6 +262,21 @@ void str_trim(char *str) {
str_trim_start(str);
}
+size_t str_count_char(const char *s, char c) {
+ const char *p = s;
+ size_t count = 0;
+ while (1) {
+ p = strchr(p, c);
+ if (p) {
+ ++count;
+ ++p;
+ } else {
+ break;
+ }
+ }
+ return count;
+}
+
char *a_sprintf(PRINTF_FORMAT_STRING const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
char *a_sprintf(const char *fmt, ...) {
// idk if you can always just pass NULL to vsnprintf