X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fstring.c;h=195976978a4e369e78ee00263961af141d4c0ee5;hb=a4fe009d3366b0a3e119713b0ecc7fc0070efdfa;hp=c235292a3acf7c45a60829350e2c7c8a1a27e629;hpb=031256ad2e123eec58521f8e3eb9496c197641d2;p=libucw.git diff --git a/ucw/string.c b/ucw/string.c index c235292a..19597697 100644 --- a/ucw/string.c +++ b/ucw/string.c @@ -2,7 +2,7 @@ * UCW Library -- String Routines * * (c) 2006 Pavel Charvat - * (c) 2007 Martin Mares + * (c) 2007--2008 Martin Mares * * 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; +}