|
|
@@ -24,6 +24,8 @@ struct str str_rstrip(struct str str);
|
|
|
struct str str_lstrip(struct str str);
|
|
|
struct str str_strip(struct str str);
|
|
|
|
|
|
+size_t str_count_char(struct str str, char c);
|
|
|
+
|
|
|
struct str_tokenizer str_tokenize(struct str str, char c);
|
|
|
struct str str_tokenizer_next(struct str_tokenizer *st);
|
|
|
|
|
|
@@ -69,6 +71,19 @@ str_strip(struct str str)
|
|
|
return str_lstrip(str_rstrip(str));
|
|
|
}
|
|
|
|
|
|
+size_t
|
|
|
+str_count_char(struct str str, char c)
|
|
|
+{
|
|
|
+ size_t i = 0;
|
|
|
+ size_t res = 0;
|
|
|
+
|
|
|
+ for ( i = 0; i < str.size; ++i ) {
|
|
|
+ res += ( str.data[i] == c );
|
|
|
+ }
|
|
|
+
|
|
|
+ return res;
|
|
|
+}
|
|
|
+
|
|
|
struct str_tokenizer
|
|
|
str_tokenize(struct str str, char c)
|
|
|
{
|