diff options
author | 2013-07-19 11:29:28 +0200 | |
---|---|---|
committer | 2013-07-19 11:29:28 +0200 | |
commit | 7ccd2e068561dfcb4355f999474c89231f4b6c4d (patch) | |
tree | c5b2f297fd5f02c879fe40c79fa60451a2081521 /smtpd/parser.c | |
parent | Merge branch 'portable' of ssh://ssh.poolp.org/git/opensmtpd into portable (diff) | |
parent | Implement command abbreviation when there is no ambiguity. (diff) | |
download | OpenSMTPD-7ccd2e068561dfcb4355f999474c89231f4b6c4d.tar.xz OpenSMTPD-7ccd2e068561dfcb4355f999474c89231f4b6c4d.zip |
Merge branch 'master' into portable
Diffstat (limited to 'smtpd/parser.c')
-rw-r--r-- | smtpd/parser.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/smtpd/parser.c b/smtpd/parser.c index 0f0cd5ee..8fd280a6 100644 --- a/smtpd/parser.c +++ b/smtpd/parser.c @@ -176,7 +176,7 @@ int cmd_run(int argc, char **argv) { struct parameter param[ARGVMAX]; - struct node *node, *tmp, *stack[ARGVMAX]; + struct node *node, *tmp, *stack[ARGVMAX], *best; int i, j, np; node = root; @@ -193,8 +193,25 @@ cmd_run(int argc, char **argv) break; } } - if (tmp == NULL) - goto fail; + if (tmp == NULL) { + best = NULL; + TAILQ_FOREACH(tmp, &node->children, entry) { + if (tmp->type != P_TOKEN) + continue; + if (strstr(tmp->token, argv[i]) != tmp->token) + continue; + if (best) + goto fail; + best = tmp; + } + if (best == NULL) + goto fail; + stack[i] = best; + node = best; + param[np].type = node->type; + if (node->type != P_TOKEN) + np++; + } } if (node->cmd == NULL) |