]> mj.ucw.cz Git - libucw.git/commitdiff
Libucw: Added str_count_char().
authorMartin Mares <mj@ucw.cz>
Tue, 22 Jul 2008 10:13:19 +0000 (12:13 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 22 Jul 2008 10:13:19 +0000 (12:13 +0200)
ucw/string.c
ucw/string.h

index c235292a3acf7c45a60829350e2c7c8a1a27e629..195976978a4e369e78ee00263961af141d4c0ee5 100644 (file)
@@ -2,7 +2,7 @@
  *     UCW Library -- String Routines
  *
  *     (c) 2006 Pavel Charvat <pchar@ucw.cz>
- *     (c) 2007 Martin Mares <mj@ucw.cz>
+ *     (c) 2007--2008 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
@@ -27,3 +27,14 @@ str_format_flags(char *dest, const char *fmt, uns flags)
   *dest = 0;
   return start;
 }
+
+uns
+str_count_char(const char *str, uns chr)
+{
+  const byte *s = str;
+  uns i = 0;
+  while (*s)
+    if (*s++ == chr)
+      i++;
+  return i;
+}
index ffcf8fb49d87c4924e005278c94a290ddbf0371e..f96bd0234012189ecabf268c5d5d5d533273360d 100644 (file)
@@ -14,6 +14,7 @@
 /* string.c */
 
 char *str_format_flags(char *dest, const char *fmt, uns flags);
+uns str_count_char(const char *str, uns chr);
 
 /* str-esc.c */