mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 13:37:12 +00:00
Merge branch 'obsd-master'
This commit is contained in:
18
arguments.c
18
arguments.c
@ -20,6 +20,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@ -77,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);
|
||||
@ -88,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);
|
||||
}
|
||||
@ -204,19 +204,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. */
|
||||
|
Reference in New Issue
Block a user