summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-09 00:10:06 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-09 00:10:06 +0200
commitf907f1e3dcf7d6922cee4433297c3b4249d899e6 (patch)
tree35d431a76d0ac53cc9f3dd6647858ec8c724529b /degesch.c
parentd3b1754e14b6508bddfda674edecbffdafe3d4f8 (diff)
downloadxK-f907f1e3dcf7d6922cee4433297c3b4249d899e6.tar.gz
xK-f907f1e3dcf7d6922cee4433297c3b4249d899e6.tar.xz
xK-f907f1e3dcf7d6922cee4433297c3b4249d899e6.zip
Add str_cut_until()
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/degesch.c b/degesch.c
index 6294316..6e3d6a6 100644
--- a/degesch.c
+++ b/degesch.c
@@ -2139,7 +2139,7 @@ irc_server_strncmp (struct server *s, const char *a, const char *b, size_t n)
static char *
irc_cut_nickname (const char *prefix)
{
- return xstrndup (prefix, strcspn (prefix, "!@"));
+ return str_cut_until (prefix, "!@");
}
static const char *
@@ -6251,8 +6251,7 @@ dump_matching_options
for (size_t i = 0; i < output->len; i++)
{
// Yeah, I know
- const char *line = output->vector[i];
- char *key = xstrndup (line, strcspn (line, " "));
+ char *key = str_cut_until (output->vector[i], " ");
if (fnmatch (mask, key, 0))
str_vector_remove (output, i--);
free (key);
@@ -6702,7 +6701,7 @@ handle_command_set_assign
}
for (size_t i = 0; i < all->len; i++)
{
- char *key = xstrndup (all->vector[i], strcspn (all->vector[i], " "));
+ char *key = str_cut_until (all->vector[i], " ");
handle_command_set_assign_item (ctx, key, new_, add, remove);
free (key);
}
@@ -7837,8 +7836,7 @@ complete_option (struct app_context *ctx, struct completion *data,
char *mask = xstrdup_printf ("%s*", word);
for (size_t i = 0; i < options.len; i++)
{
- const char *line = options.vector[i];
- char *key = xstrndup (line, strcspn (line, " "));
+ char *key = str_cut_until (options.vector[i], " ");
if (!fnmatch (mask, key, 0))
str_vector_add_owned (output, key);
else