This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/14437 Change subject: vty: command.c: Fix: single-choice optional args are no longer passed incomplete to vty func ...................................................................... vty: command.c: Fix: single-choice optional args are no longer passed incomplete to vty func For instance, take command "single0 [one]": If user executes "single0 on", VTY func will receive argv[0]="one" instead of argv[0]="on". Related: OS#4045 Change-Id: I5f4e2d16c62a2d22717989c6acc77450957168cb --- M src/vty/command.c M tests/vty/vty_transcript_test.vty 2 files changed, 15 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/37/14437/1 diff --git a/src/vty/command.c b/src/vty/command.c index 6e8bc5b..9e2a4b8 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -2310,16 +2310,26 @@ } vector descvec = vector_slot(matched_element->strvec, i); + const char *tmp_cmd; if (vector_active(descvec) == 1) { + /* Single coice argument, no "(...|...)". */ struct desc *desc = vector_slot(descvec, 0); - if (CMD_VARARG(desc->cmd)) - varflag = 1; + if (CMD_OPTION(desc->cmd)) { + /* we need to first remove the [] chars, then check to see what's inside (var or token) */ + tmp_cmd = cmd_deopt(cmd_deopt_ctx, desc->cmd); + } else { + tmp_cmd = desc->cmd; + } - if (varflag || CMD_VARIABLE(desc->cmd) - || CMD_OPTION(desc->cmd)) + if (CMD_VARARG(tmp_cmd)) + varflag = 1; + if (varflag || CMD_VARIABLE(tmp_cmd)) argv[argc++] = vector_slot(vline, i); + else if (CMD_OPTION(desc->cmd)) + argv[argc++] = tmp_cmd; + /* else : we don't want to add non-opt single-choice static args in argv[] */ } else { /* multi choice argument. look up which choice the user meant (can only be one after @@ -2328,7 +2338,6 @@ want to pass "three" in argv[]. */ for (j = 0; j < vector_active(descvec); j++) { struct desc *desc = vector_slot(descvec, j); - const char *tmp_cmd; if (!desc) continue; if (cmd_match(desc->cmd, vector_slot(vline, i), ANY_MATCH, true) == NO_MATCH) diff --git a/tests/vty/vty_transcript_test.vty b/tests/vty/vty_transcript_test.vty index f2dbacb..db58830 100644 --- a/tests/vty/vty_transcript_test.vty +++ b/tests/vty/vty_transcript_test.vty @@ -80,7 +80,7 @@ ok argc=1 one vty_transcript_test> single0 on -ok argc=1 on +ok argc=1 one vty_transcript_test> single0 ok argc=0 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/14437 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I5f4e2d16c62a2d22717989c6acc77450957168cb Gerrit-Change-Number: 14437 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190613/0380bb5e/attachment.htm>