From 311e4b36768a0d4e113ccf6d2256ca95c6621508 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Sat, 12 Apr 2014 19:59:21 +0300 Subject: Use strcspn instead of strtok --- lib/util.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/util.c') diff --git a/lib/util.c b/lib/util.c index a77e2ff..49f9175 100644 --- a/lib/util.c +++ b/lib/util.c @@ -27,6 +27,19 @@ char* _bmStrdup(const char *string) return (char *)memcpy(copy, string, len); } +/** + * Replaces next token in string with '\0' and returns position for the replaced token. + * + * @param string C "string" where token will be replaced. + * @return Position of the replaced token. + */ +size_t _bmStripToken(char *string, const char *token) +{ + size_t len = strcspn(string, token); + string[len] = 0; + return len; +} + /** * Portable case-insensitive strcmp. * -- cgit v1.2.3-70-g09d2