aboutsummaryrefslogtreecommitdiff
path: root/cmd.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2019-03-18 15:07:51 +0000
committerThomas Adam <thomas@xteddy.org>2019-03-18 15:07:51 +0000
commitacb2413852b98745b69459d0cdd0d9698cb75e2c (patch)
tree6af803240715b8a6bccc328d5eda14f237e44944 /cmd.c
parentaa2b3472c515dd1e5f57618e17c0c612cfa3c117 (diff)
parentce6be7afd4d10b542f9cce8634d6bdd81754f775 (diff)
downloadrtmux-acb2413852b98745b69459d0cdd0d9698cb75e2c.tar.gz
rtmux-acb2413852b98745b69459d0cdd0d9698cb75e2c.tar.bz2
rtmux-acb2413852b98745b69459d0cdd0d9698cb75e2c.zip
Merge branch 'obsd-master'
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/cmd.c b/cmd.c
index 5df30798..877cd10c 100644
--- a/cmd.c
+++ b/cmd.c
@@ -318,31 +318,31 @@ cmd_stringify_argv(int argc, char **argv)
static int
cmd_try_alias(int *argc, char ***argv)
{
- struct options_entry *o;
- int old_argc = *argc, new_argc;
- char **old_argv = *argv, **new_argv;
- u_int size, idx;
- int i;
- size_t wanted;
- const char *s, *cp = NULL;
+ struct options_entry *o;
+ struct options_array_item *a;
+ int old_argc = *argc, new_argc, i;
+ char **old_argv = *argv, **new_argv;
+ size_t wanted;
+ const char *s, *cp = NULL;
o = options_get_only(global_options, "command-alias");
- if (o == NULL || options_array_size(o, &size) == -1 || size == 0)
+ if (o == NULL)
return (-1);
-
wanted = strlen(old_argv[0]);
- for (idx = 0; idx < size; idx++) {
- s = options_array_get(o, idx);
- if (s == NULL)
- continue;
- cp = strchr(s, '=');
- if (cp == NULL || (size_t)(cp - s) != wanted)
- continue;
- if (strncmp(old_argv[0], s, wanted) == 0)
- break;
+ a = options_array_first(o);
+ while (a != NULL) {
+ s = options_array_item_value(a);
+ if (s != NULL) {
+ cp = strchr(s, '=');
+ if (cp != NULL &&
+ (size_t)(cp - s) == wanted &&
+ strncmp(old_argv[0], s, wanted) == 0)
+ break;
+ }
+ a = options_array_next(a);
}
- if (idx == size)
+ if (a == NULL)
return (-1);
if (cmd_string_split(cp + 1, &new_argc, &new_argv) != 0)