diff options
Diffstat (limited to 'libmailutils/string/strcount.c')
-rw-r--r-- | libmailutils/string/strcount.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/libmailutils/string/strcount.c b/libmailutils/string/strcount.c index d86e96601..0d9d38aa1 100644 --- a/libmailutils/string/strcount.c +++ b/libmailutils/string/strcount.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 2016-2019 Free Software Foundation, Inc. + Copyright (C) 2016-2024 Free Software Foundation, Inc. GNU Mailutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -64,3 +64,25 @@ mu_str_count (char const *str, char const *chr, size_t *cnt) } return count; } + +/* Find the number of occurrences of character C in byte array + STR of length LEN. */ +size_t +mu_mem_c_count (char const *str, int c, size_t len) +{ + size_t n = 0; + while (len--) + if (*str++ == c) + n++; + return n; +} + +size_t +mu_mem_8bit_count (char const *str, size_t len) +{ + size_t n = 0; + while (len--) + if (*str & 0xf0) + n++; + return n; +} |