From 30275bc61081023b4e0a56452e90fac23c6f6b60 Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 17 Nov 2013 20:19:36 +0000 Subject: Include unistd.h as it is the standard location for getopt(). OK millert@ --- arguments.c | 1 + 1 file changed, 1 insertion(+) (limited to 'arguments.c') diff --git a/arguments.c b/arguments.c index ca828f00..e699834c 100644 --- a/arguments.c +++ b/arguments.c @@ -20,6 +20,7 @@ #include #include +#include #include "tmux.h" -- cgit From 66829ee12e45656fccfe8879b7ac2f983d138b42 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 9 Jan 2014 13:51:57 +0000 Subject: Simplify args_set, from Tiago Cunha. --- arguments.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'arguments.c') diff --git a/arguments.c b/arguments.c index e699834c..4a3f4579 100644 --- a/arguments.c +++ b/arguments.c @@ -205,19 +205,15 @@ args_set(struct args *args, u_char ch, const char *value) /* Replace existing argument. */ if ((entry = args_find(args, ch)) != NULL) { free(entry->value); - if (value != NULL) - entry->value = xstrdup(value); - else - entry->value = NULL; - return; + entry->value = NULL; + } else { + entry = xcalloc(1, sizeof *entry); + entry->flag = ch; + RB_INSERT(args_tree, &args->tree, entry); } - entry = xcalloc(1, sizeof *entry); - entry->flag = ch; if (value != NULL) entry->value = xstrdup(value); - - RB_INSERT(args_tree, &args->tree, entry); } /* Get argument value. Will be NULL if it isn't present. */ -- cgit From 3368b602a868eb6570c4ee92f45c2e0ee78631cb Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 15 Jan 2014 11:44:18 +0000 Subject: Couple of fixes from cppcheck via Tiago Cunha. --- arguments.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'arguments.c') diff --git a/arguments.c b/arguments.c index 4a3f4579..5ff7ed2c 100644 --- a/arguments.c +++ b/arguments.c @@ -78,7 +78,6 @@ struct args * args_parse(const char *template, int argc, char **argv) { struct args *args; - char *ptr; int opt; args = xcalloc(1, sizeof *args); @@ -89,7 +88,7 @@ args_parse(const char *template, int argc, char **argv) while ((opt = getopt(argc, argv, template)) != -1) { if (opt < 0) continue; - if (opt == '?' || (ptr = strchr(template, opt)) == NULL) { + if (opt == '?' || strchr(template, opt) == NULL) { args_free(args); return (NULL); } -- cgit