summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-09-09 21:19:26 -0400
committerpommicket <pommicket@gmail.com>2023-09-09 21:19:26 -0400
commit16fbe87451b0ca3e8fa35fd04e0afbfab368ea65 (patch)
treedcd4c1e37b4a89173e23047f644df94a9ca92399 /util.c
parent0dcfd5a4f1fd865c24c01b17b214e1f72e4c06fe (diff)
fix handling of TextEdit[]
i hate microsoft so much
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