summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vty/command.c185
1 files changed, 94 insertions, 91 deletions
diff --git a/src/vty/command.c b/src/vty/command.c
index 104053ff..4189c7c0 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -1510,109 +1510,112 @@ is_cmd_ambiguous(char *command, vector v, int index, enum match_type type)
* or ambiguities to cause a noticeable memory footprint from keeping all allocations. */
void *cmd_deopt_ctx = NULL;
- for (i = 0; i < vector_active(v); i++)
- if ((cmd_element = vector_slot(v, i)) != NULL) {
- int match = 0;
+ for (i = 0; i < vector_active(v); i++) {
+ cmd_element = vector_slot(v, i);
+ if (!cmd_element)
+ continue;
- descvec = vector_slot(cmd_element->strvec, index);
+ int match = 0;
- for (j = 0; j < vector_active(descvec); j++) {
- desc = vector_slot(descvec, j);
- if (!desc)
- continue;
+ descvec = vector_slot(cmd_element->strvec, index);
- enum match_type mtype;
- const char *str = desc->cmd;
+ for (j = 0; j < vector_active(descvec); j++) {
+ desc = vector_slot(descvec, j);
+ if (!desc)
+ continue;
- if (CMD_OPTION(str)) {
- if (!cmd_deopt_ctx)
- cmd_deopt_ctx =
- talloc_named_const(tall_vty_cmd_ctx, 0,
- __func__);
- str = cmd_deopt(cmd_deopt_ctx, str);
- if (str == NULL)
- continue;
- }
+ enum match_type mtype;
+ const char *str = desc->cmd;
- switch (type) {
- case EXACT_MATCH:
- if (!(CMD_VARIABLE (str))
- && strcmp(command, str) == 0)
- match++;
- break;
- case PARTLY_MATCH:
- if (!(CMD_VARIABLE (str))
- && strncmp(command, str, strlen (command)) == 0)
- {
- if (matched
- && strcmp(matched,
- str) != 0) {
- ret = 1; /* There is ambiguous match. */
- goto free_and_return;
- } else
- matched = str;
- match++;
- }
- break;
- case RANGE_MATCH:
- if (cmd_range_match
- (str, command)) {
- if (matched
- && strcmp(matched,
- str) != 0) {
- ret = 1;
- goto free_and_return;
- } else
- matched = str;
- match++;
- }
- break;
-#ifdef HAVE_IPV6
- case IPV6_MATCH:
- if (CMD_IPV6(str))
- match++;
- break;
- case IPV6_PREFIX_MATCH:
- if ((mtype =
- cmd_ipv6_prefix_match
- (command)) != NO_MATCH) {
- if (mtype == PARTLY_MATCH) {
- ret = 2; /* There is incomplete match. */
- goto free_and_return;
- }
+ if (CMD_OPTION(str)) {
+ if (!cmd_deopt_ctx)
+ cmd_deopt_ctx =
+ talloc_named_const(tall_vty_cmd_ctx, 0,
+ __func__);
+ str = cmd_deopt(cmd_deopt_ctx, str);
+ if (str == NULL)
+ continue;
+ }
- match++;
+ switch (type) {
+ case EXACT_MATCH:
+ if (!(CMD_VARIABLE (str))
+ && strcmp(command, str) == 0)
+ match++;
+ break;
+ case PARTLY_MATCH:
+ if (!(CMD_VARIABLE (str))
+ && strncmp(command, str, strlen (command)) == 0)
+ {
+ if (matched
+ && strcmp(matched,
+ str) != 0) {
+ ret = 1; /* There is ambiguous match. */
+ goto free_and_return;
+ } else
+ matched = str;
+ match++;
+ }
+ break;
+ case RANGE_MATCH:
+ if (cmd_range_match
+ (str, command)) {
+ if (matched
+ && strcmp(matched,
+ str) != 0) {
+ ret = 1;
+ goto free_and_return;
+ } else
+ matched = str;
+ match++;
+ }
+ break;
+#ifdef HAVE_IPV6
+ case IPV6_MATCH:
+ if (CMD_IPV6(str))
+ match++;
+ break;
+ case IPV6_PREFIX_MATCH:
+ if ((mtype =
+ cmd_ipv6_prefix_match
+ (command)) != NO_MATCH) {
+ if (mtype == PARTLY_MATCH) {
+ ret = 2; /* There is incomplete match. */
+ goto free_and_return;
}
- break;
-#endif /* HAVE_IPV6 */
- case IPV4_MATCH:
- if (CMD_IPV4(str))
- match++;
- break;
- case IPV4_PREFIX_MATCH:
- if ((mtype =
- cmd_ipv4_prefix_match
- (command)) != NO_MATCH) {
- if (mtype == PARTLY_MATCH) {
- ret = 2; /* There is incomplete match. */
- goto free_and_return;
- }
- match++;
+ match++;
+ }
+ break;
+#endif /* HAVE_IPV6 */
+ case IPV4_MATCH:
+ if (CMD_IPV4(str))
+ match++;
+ break;
+ case IPV4_PREFIX_MATCH:
+ if ((mtype =
+ cmd_ipv4_prefix_match
+ (command)) != NO_MATCH) {
+ if (mtype == PARTLY_MATCH) {
+ ret = 2; /* There is incomplete match. */
+ goto free_and_return;
}
- break;
- case EXTEND_MATCH:
- if (CMD_VARIABLE (str))
- match++;
- break;
- case NO_MATCH:
- default:
- break;
+
+ match++;
}
+ break;
+ case EXTEND_MATCH:
+ if (CMD_VARIABLE (str))
+ match++;
+ break;
+ case NO_MATCH:
+ default:
+ break;
}
- if (!match)
- vector_slot(v, i) = NULL;
}
+ if (!match)
+ vector_slot(v, i) = NULL;
+ }
free_and_return:
if (cmd_deopt_ctx)