diff options
author | pommicket <pommicket@gmail.com> | 2023-09-09 21:19:26 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-09-09 21:19:26 -0400 |
commit | 16fbe87451b0ca3e8fa35fd04e0afbfab368ea65 (patch) | |
tree | dcd4c1e37b4a89173e23047f644df94a9ca92399 /util.c | |
parent | 0dcfd5a4f1fd865c24c01b17b214e1f72e4c06fe (diff) |
fix handling of TextEdit[]
i hate microsoft so much
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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 |