summaryrefslogtreecommitdiff
path: root/lib/util.c
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2014-04-12 19:59:21 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2014-04-12 19:59:21 +0300
commit311e4b36768a0d4e113ccf6d2256ca95c6621508 (patch)
tree04be6cb3158375ca9932481f279167eff145435d /lib/util.c
parentcd73a1ba610db7cfa928b37039a1bbdaee88972a (diff)
downloadbemenu-311e4b36768a0d4e113ccf6d2256ca95c6621508.tar.gz
bemenu-311e4b36768a0d4e113ccf6d2256ca95c6621508.tar.bz2
bemenu-311e4b36768a0d4e113ccf6d2256ca95c6621508.zip
Use strcspn instead of strtok
Diffstat (limited to 'lib/util.c')
-rw-r--r--lib/util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/util.c b/lib/util.c
index a77e2ff..49f9175 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -28,6 +28,19 @@ char* _bmStrdup(const char *string)
}
/**
+ * 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.
*
* @param hay C "string" to match against.