[Xorp-hackers] [PATCH] xorp: rtrmgr: Fix command completion with %allow-range option on multi-value nodes
Ben Greear
greearb at candelatech.com
Tue Mar 13 10:43:13 PDT 2012
On 03/13/2012 10:27 AM, Ben Greear wrote:
> On 03/13/2012 03:55 AM, igorm at etf.rs wrote:
>> From: Igor Maravic<igorm at etf.rs>
>>
>> Fixed problem of command completion for multi-value nodes with allow-range option.
>> Without this fix, if we would enter number within the allowed range, and then we would enter
>> " " + "\t" we wouldn't get any command propositions.
>>
>> Signed-off-by: Igor Maravic<igorm at etf.rs>
>> ---
>> xorp/rtrmgr/template_tree.cc | 45 +++++++++++++++++++++++++++++++-----
>> xorp/rtrmgr/template_tree_node.cc | 6 ++--
>> 2 files changed, 41 insertions(+), 10 deletions(-)
>>
>> diff --git a/xorp/rtrmgr/template_tree.cc b/xorp/rtrmgr/template_tree.cc
>> index fa04132..08c9280 100644
>
>> #ifdef HOST_OS_WINDOWS
>> #define stat _stat
>> @@ -422,18 +433,38 @@ TemplateTree::find_node(const list<string>& path_segments) const
>> // There's no exact name match, so we're probably looking for a
>> // match of an encoded typestr or a value against a typed variable.
>> for (ti = ttn->children().begin(); ti != ttn->children().end(); ++ti) {
>> - TemplateTreeNode* t = *ti;
>> - if (t->type() == NODE_VOID)
>> + TemplateTreeNode* t = *ti;
>> + if (t->type() == NODE_VOID)
>> continue;
>> - if ((t->parent() == NULL) || (! t->parent()->is_tag()))
>> + if ((t->parent() == NULL) || (! t->parent()->is_tag()))
>> continue;
>> - if (t->encoded_typestr() == segname) {
>> + if (t->encoded_typestr() == segname) {
>> matches.push_back(t);
>> continue;
>> - }
>> - string s;
>> - if (t->type_match(segname, s))
>> + }
>> +
>> + /**
>> + * Check if this segname represents some kind of range.
>> + * If it does, it will match regexp below, and we
>> + * are expecting t->encoded_typestr to be "<uint>" or"<uint64>" or"<int>"
>> + */
>> + regex_t range_reg;
>> + if (regcomp(&range_reg, "[\[][-]{0,1}[0-9]+[.][.][-]{0,1}[0-9]+]", REG_EXTENDED))
>> + XLOG_UNREACHABLE();
>> +
>> + bool is_range = !regexec(&range_reg, segname.c_str(), 0, 0, 0);
>> + regfree(&range_reg);
>> + if (is_range&&
>> + (t->encoded_typestr() == "<uint>"
>> + || t->encoded_typestr() == "<int>"
>> + || t->encoded_typestr() == "<uint64>")) {
>> matches.push_back(t);
>> + continue;
>> + }
>> +
>> + string s;
>> + if (t->type_match(segname, s))
>> + matches.push_back(t);
>> }
>
> The formatting is all weird above. Maybe using tabs instead of spaces?
>
> Please fix this and re-submit.
>
> Also, I'm not sure you sent both patches in this series?
Actually, xorp is using tabs for indentation. Maybe your patch
will look better outside of email. Let me double-check
that before you spend more time re-writing it.
Thanks,
Ben
>
> Thanks,
> Ben
>
>
--
Ben Greear <greearb at candelatech.com>
Candela Technologies Inc http://www.candelatech.com
More information about the Xorp-hackers
mailing list