From f01f73243327dec19042dfa0a85a09238da7fa4c Mon Sep 17 00:00:00 2001 From: Christopher Wellons Date: Sat, 30 Jun 2018 15:42:55 -0400 Subject: [PATCH] Fix number of command_names searched (fixes #18) The "help" subcommand was removed in 6d1407b, but the number of commands searched was not updated. With this commit it always checks the right number of command strings. --- src/enchive.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/enchive.c b/src/enchive.c index 879500c..dfb12aa 100644 --- a/src/enchive.c +++ b/src/enchive.c @@ -1129,8 +1129,9 @@ parse_command(char *command) { int found = COMMAND_UNKNOWN; size_t len = strlen(command); + int ncommands = sizeof(command_names) / sizeof(*command_names); int i; - for (i = 0; i < 5; i++) { + for (i = 0; i < ncommands; i++) { if (strncmp(command, command_names[i], len) == 0) { if (found >= 0) return COMMAND_AMBIGUOUS;