]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/string.c
Merge branch 'master' into dev-lib
[libucw.git] / ucw / string.c
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;
+}